From fdc0067d05b875da82a5bed4bd364df0b4fde980 Mon Sep 17 00:00:00 2001 From: gitbot Date: Wed, 19 Mar 2025 20:11:29 +0000 Subject: [PATCH 1/7] Squashed 'library/' changes from 78fc550584d..3e6029532f5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3e6029532f5 Rollup merge of #138387 - RalfJung:intrinsic-arg-names, r=oli-obk 0424c57b1c5 Rollup merge of #138269 - Ayush1325:uefi-fs-permission, r=joboet d0620fa5214 Rollup merge of #138161 - HeroicKatora:heap-peek-mut-refresh, r=dtolnay f152d093dd6 intrinsics: remove unnecessary leading underscore from argument names 7d081598bdc Auto merge of #138366 - matthiaskrgr:rollup-cn16m7q, r=matthiaskrgr fbcff157c8c Rollup merge of #138002 - 1c3t3a:fix-std-cfi-violation, r=rcvalle 7b2fc7c72f3 Auto merge of #128440 - oli-obk:defines, r=lcnr 8c0e5623691 Add PeekMut::refresh 7dfdb320eef Rollup merge of #137967 - mustartt:fix-aix-test-hangs, r=workingjubilee 77851590e0f Rollup merge of #135987 - hkBst:patch-20, r=joboet 065a29b09ba Implement `#[define_opaque]` attribute for functions. a270d44b6ab Auto merge of #135651 - arjunr2:master, r=davidtwco 1119688c98b Auto merge of #136932 - m-ou-se:fmt-width-precision-u16, r=scottmcm 43a303d2209 Target definition for `wasm32-wali-linux-musl` to support the Wasm Linux Interface 24955d9a35b Add #[track_caller] to from_usize. 20f622c3a0f Remove unnecessary semicolon. 323a077ba20 Update tests. 3670dc846fb Limit formatting width and precision to 16 bits. b6daa44dda1 Add comments for #[no_sanitize(cfi)] in stdlib 93b68c0a706 Disable CFI for weakly linked syscalls c5a68b2fbd4 Rollup merge of #138074 - thaliaarchi:hermit-seek, r=ChrisDenton 625546926c0 Rollup merge of #137585 - xizheyin:issue-135801, r=workingjubilee 434a8f644a2 uefi: fs: Partially implement FileAttr 0ada98e13e2 uefi: fs: Implement FileType c76e918218c uefi: fs: Implement FilePermission 0b6a2072982 std: move stdio to `sys` d598e4bd4fe Support File::seek for Hermit 659e8026fd5 Update hermit-abi to 0.5.0 2077b050da5 Rollup merge of #138276 - bdbai:fix-uwp-ntopenfile, r=ChrisDenton 2cbf2700ff1 Rollup merge of #138233 - smmalis37:no-advapi32, r=ChrisDenton 5890e4e2ee6 Rollup merge of #138228 - TDecking:master, r=jhpratt 06ea4f49285 Rollup merge of #137650 - thaliaarchi:move-fs-pal, r=Noratrieb 3714bfb0746 Lazy load NtOpenFile for UWP bcd6e0a3240 Clarify iterator by_ref docs 7b5f82feaa9 Move fs into sys 1fdabf2a48d Stabilize `const_vec_string_slice` dd014257180 Don't link against advapi32, except on win7. a057b0da7f3 Use `disjoint_bitor` inside `borrowing_sub` 9769e9ff76e Rollup merge of #138189 - GuillaumeGomez:env-var, r=joshtriplett 3264f9d39f6 Rollup merge of #137528 - ChrisDenton:rename-win, r=joboet 2be3c651fbb Rollup merge of #136642 - bjorn3:separate_alloctest_crate, r=cuviper 1f261ba7dc2 Rollup merge of #138000 - RalfJung:atomic-rmw, r=Amanieu 4eeadd427e3 Rollup merge of #137606 - davidtwco:next-edition, r=traviscross,ehuss 092c7ba3e10 Mention `env` and `option_env` macros in `std::env::var` docs 22a32779933 Add comments 91fe85b6f01 Fully test the alloc crate through alloctests 738178b3ff1 Move last remaining Rc test to alloctests db8476eb542 Move most Rc tests to alloctests cf8c29ab10b Move all alloc integration tests to a new alloctests crate d15d3f7cafc Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis bf748af1ab5 Return OutOfMemoryError and update docs 3fae24535d2 Windows: Use MoveFileEx by default in `fs:rename` dfca1534be9 Auto merge of #138155 - matthiaskrgr:rollup-xq5buio, r=matthiaskrgr b615fd5118c Rollup merge of #138034 - thaliaarchi:use-prelude-size-of, r=tgross35 982f3698922 Rollup merge of #137674 - heiher:enable-f16-loong, r=tgross35 b68bc98478f Rollup merge of #138129 - RalfJung:stabilize-const-things, r=tgross35 04830fde02f Rollup merge of #137904 - scottmcm:ordering-is, r=workingjubilee ba4c03ea49a Rollup merge of #137832 - wgwoods:fix-bufreader-peek, r=joboet b4519d15185 Rollup merge of #137777 - thaliaarchi:os_string-push-str, r=joboet f4bc9a14703 Rollup merge of #137107 - thaliaarchi:io-optional-methods/cursors, r=joboet bb84112aee8 Rollup merge of #136667 - vita-rust:revert-vita-c-char, r=cuviper 560a1947351 Use turbofish for size_of and align_of in docs 9e34c62e21a library: Use size_of from the prelude instead of imported 83d396c9341 Auto merge of #138127 - compiler-errors:rollup-kcarqrz, r=compiler-errors ace5e0f89ab Auto merge of #138114 - compiler-errors:rollup-7xr4b69, r=compiler-errors be21da06ced stabilize const_sockaddr_setters 0b2d34d4ef5 stabilize const_char_classify 64dedc18a10 Add allow(incomplete_features) to alloc 4e10427c3c6 Add examples in stdlib demonstrating the use syntax d05912eafeb Add UseCloned trait related code 168b9ce30fc Rollup merge of #138105 - reddevilmidzy:fix-broken-link, r=saethlin 17d426f1bb6 Update stdarch e2b4056a8b5 Rollup merge of #138038 - tgross35:update-builtins, r=tgross35 a3cd875e04b Rollup merge of #137808 - jswrenn:droppy-unsafe-fields, r=nnethercote 60d296a16d2 Rollup merge of #137772 - thaliaarchi:bstr-display, r=joshtriplett 88a93b34799 Rollup merge of #137764 - compiler-errors:always-applicable-negative-impl, r=lcnr 7279a4a1d3b Rollup merge of #137327 - arlosi:home-dir, r=Mark-Simulacrum 75b3a4ca7f0 Rollup merge of #136922 - oli-obk:pattern-types-option-ends, r=BoxyUwU f0cd1b9cff2 Rollup merge of #135895 - hkBst:patch-15, r=joboet 09eff082c04 Fix broken link to Miri intrinsics in documentation 053197ee347 Stabilize `const_copy_from_slice` feature 65914ce9ec2 Remove the `Option` part of range ends in the HIR c05e8e747ea Make `is_le` and friends work like clang's bb10e81a1dc Rollup merge of #137728 - Darksonn:no-tuple-unsize, r=oli-obk 49fc02972a0 Rollup merge of #137679 - bjorn3:coretests_improvements, r=jieyouxu,onur-ozkan 30cbf2b969e Rollup merge of #137569 - aDotInTheVoid:for-iurii, r=ibraheemdev 8d8586942c1 Rollup merge of #137477 - Ayush1325:uefi-service-binding, r=Noratrieb abb02d0af85 Rollup merge of #137463 - sunshowers:illumos-posix-spawn, r=Mark-Simulacrum ba1aa35f85d Rollup merge of #137240 - jieyouxu:remove_dir_all, r=Mark-Simulacrum 2053ad714b2 Rollup merge of #136798 - pcorwin:master, r=tgross35 f21f527e87f Rollup merge of #136662 - thaliaarchi:formatter-pad-char-count, r=m-ou-se 72e4ab911ce Rollup merge of #134063 - tgross35:dec2flt-refactoring, r=Noratrieb 0f84f75d82c Auto merge of #138031 - workingjubilee:rollup-5bsotpz, r=workingjubilee 87d50046767 Update `compiler-builtins` to 0.1.151 784016ec4e0 Rollup merge of #137986 - fuyangpengqi:master, r=Amanieu 18ea57539bb Rollup merge of #137850 - slanterns:box_uninit_write, r=ibraheemdev 5a551b653db Rollup merge of #137829 - cramertj:stabilize-split-off, r=jhpratt 4a7fcd9b1fc Rollup merge of #137634 - tgross35:update-builtins, r=tgross35 ae3814d6bcc Ensure that negative auto impls are always applicable 9119bf37986 Added documentation for flushing 6c41114a50a Fix test hangs on AIX 7e45b3b3f4b atomic: clarify that failing conditional RMW operations are not 'writes' fbd7405888c Fix some typos fc90fca4c57 Auto merge of #137959 - matthiaskrgr:rollup-62vjvwr, r=matthiaskrgr c94967b512b Rollup merge of #137054 - jhpratt:phantom-variance, r=Mark-Simulacrum 809ce0f4eb0 fix order on shl impl 220dacb85b7 Rollup merge of #137873 - tgross35:disable-f16-without-neon, r=workingjubilee 195c76625cb Rollup merge of #137871 - pitaj:rangebounds-is_empty-intersect, r=scottmcm d096ef59cd2 Rollup merge of #137641 - kpreid:dealloc, r=Amanieu 1262ab4aa8a Rollup merge of #137375 - steffahn:clarify-read_line-comment, r=Mark-Simulacrum 5272d97be65 Document workings of successors more clearly c17d71592dd dec2flt: Refactor the fast path a6d01b31728 dec2flt: Refactor float traits e3c1689bda5 dec2flt: Rename fields to be consistent with documented notation 1e78b10f58b dec2flt: Rename `Number` to `Decimal` 18e13b5b553 dec2flt: Rename `Decimal` to `DecimalSeq` 0963dce5dfa dec2flt: Update documentation of existing methods c631fa8b902 float: Update some constants to `pub(crate)` 9046ba2878d Disable `f16` on Aarch64 without `neon` b03df5425b2 fix `RangeBounds::is_empty` documentation 09b755873d0 Update `compiler-builtins` to 0.1.150 f31b2f7eaa5 uefi: Add Service Binding Protocol abstraction ce33bb9985d Rollup merge of #137828 - folkertdev:simd-intrinsic-doc-fixes, r=workingjubilee 6e6d0803101 Rollup merge of #137809 - Noratrieb:io-error-casing, r=thomcc 5506ca034e5 stabilize `box_uninit_write` 071d976677d Rollup merge of #137730 - RalfJung:checked_ilog_tests, r=tgross35 67dc2fd0d56 Fix logic error in Buffer::read_more() c4a6461b2bc Tweak BufReader::peek() doctest to expose bug in Buffer::read_more() 435f1416b35 intrinsics::simd: document that masks must be signed integer vectors 1769d573609 correct the docs on `simd_` comparison operators 88563ddfd85 Stabilize [T]::split_off... methods 6f643c3af5d Specialize constructing OsString from strings b6401ed27b2 Specialize OsString::push for strings 37cad6d139f Use correct error message casing for `io::const_error`s be383826afc Do not require that unsafe fields lack drop glue 23d9066ec80 Rollup merge of #137673 - ChrisDenton:search-path-bug, r=dtolnay f7930f32a43 Rollup merge of #137551 - folkertdev:import-simd-intrinsics, r=RalfJung eeaf188b75b Rollup merge of #137197 - scottmcm:cmp-20, r=ibraheemdev 9ddd920fa62 Fix char count in Display for ByteStr de1dedd307d Override default Write methods for cursor-like types 5142c874b21 Inline VecDeque and BorrowedCursor methods eef63e569b8 Count char width at most once in Formatter::pad ce363e1f5a3 checked_ilog tests: deal with a bit of float imprecision 527700acb28 make `simd_insert` and `simd_extract` `const fn`s bcf698c9310 Delete tuple unsizing 655937cfffd Rollup merge of #137480 - fuzzypixelz:fix/124466, r=workingjubilee 8e62371cff2 Rollup merge of #137304 - pitaj:rangebounds-is_empty-intersect, r=ibraheemdev bcd2e09423d require trait impls to have matching const stabilities as the traits 83e302acdba Rollup merge of #137620 - SergioGasquez:fix/espidf-maybeunit, r=ChrisDenton 97600a048b0 Rollup merge of #136187 - hkBst:patch-27, r=workingjubilee ea50b435ee8 Rollup merge of #134585 - cyrgani:uninit_array, r=Amanieu 07c0a800b86 Fix unused import in coretests on wasm32 f30b9d5a2fa Fix Windows `Command` search path bug 39314228214 Enable `f16` for LoongArch af61cb55382 Rollup merge of #137614 - xizheyin:issue-134874, r=cuviper 9f8f1da9f8a Rollup merge of #137311 - martn3:enable-f16-mips, r=tgross35 d98eda35cc7 Rollup merge of #137154 - thaliaarchi:wtf8-fast-paths, r=ChrisDenton 38b89473ddd Auto merge of #137594 - RalfJung:miri-sync, r=RalfJung f6439abf57d More precisely document `Global::deallocate()`'s safety. df916c9f372 Auto merge of #137608 - fmease:rollup-h4siso6, r=fmease 129cda1f586 fix: attr cast for espidf 3aeaf5120c8 fix doc in library/core/src/pin.rs 9768712318a Rollup merge of #137515 - tgross35:update-builtins, r=tgross35 87be353d74c Use `.expect(..)` instead ea230c2badf Rollup merge of #137576 - goffrie:setvalzst, r=lcnr 33c26395bed disable a potentially bogus test on Miri 24657f1ca1d Merge from rustc 48573410f77 Auto merge of #137571 - tgross35:rollup-i1tcnv1, r=tgross35 34c878b87fc fix doc in library/core/src/sync/atomic.rs bdf09503ea5 Don't doc-comment BTreeMap 34f05a38094 Rollup merge of #137543 - petrochenkov:wintest, r=ChrisDenton 0e4b3df587c Rollup merge of #137489 - RalfJung:no-more-rustc_intrinsic_must_be_overridden, r=oli-obk 3b6f96f870c Rollup merge of #137321 - aviraxp:patch-1, r=cuviper 4ed2ab3ed35 Rollup merge of #137516 - RalfJung:rustc_const_unstable-cleanup, r=Amanieu 763f918aa56 Rollup merge of #137349 - thaliaarchi:io-optional-methods/zkvm, r=Noratrieb 8df024d161b Rollup merge of #137109 - bend-n:knife, r=oli-obk 00bb0b92047 Rollup merge of #136775 - robertbastian:patch-2, r=Amanieu 128fd654118 Rollup merge of #136668 - WaffleLapkin:from_utf8_mut, r=Amanieu 3fc5093bfbc Rollup merge of #135933 - hkBst:patch-19, r=workingjubilee fdc6f873867 Rollup merge of #134655 - GrigorenkoPV:hash_extract_if, r=cuviper 4a4acbfd64a Stablize `string_extend_from_within` 780a3d470ae Simplify trait error message for CoercePointee validation fb4e1b8e933 span: add a "future" edition f5c2e86bd6b std: Fix another new symlink test on Windows 4c451e86fe9 Update string.rs 9d1ad26a7c4 Remove speculation on cause of error 2dad07891a2 remove some unnecessary rustc_const_unstable 9bcae8d3756 Update `compiler-builtins` to 0.1.148 474351c0ffe Rollup merge of #137495 - madhav-madhusoodanan:feature-unstable-control-flow-into-value, r=jhpratt c0b3b0214a1 Rollup merge of #137484 - chenyukang:yukang-fix-sort-doc, r=Noratrieb 8b8593f569f Rollup merge of #137482 - rust9x:win-file-open-truncate, r=ChrisDenton 42749e05c04 Rollup merge of #137393 - chorman0773:unbounded-shifts-stabilize, r=Amanieu e63e6ce99cb Rollup merge of #137061 - progressive-galib:gen_future-closing#76249, r=ibraheemdev 377b0d5e48d Merge from rustc 7be8a82ca96 remove uses of rustc_intrinsic_must_be_overridden from standard library f7b28853ff5 Added into_value const function to ControlFlow 4fb5a2768e0 Rollup merge of #137483 - bend-n:😅, r=Noratrieb 87f88783d22 Rollup merge of #137297 - tgross35:update-builtins, r=tgross35 33e45d65a21 Rollup merge of #136543 - RalfJung:round-ties-even, r=tgross35 e11873b1751 rename sub_ptr 😅 e29396c8cb0 Fix documentation for unstable sort eb9a602d424 Stabilize `core::str::from_utf8_mut` 0d6361ef2c0 stabilize extract_if 66d3b7527b8 Win: use existing wrappers for `SetFileInformationByHandle` in `File::open_native` 9d830bdb584 Return error on unexpected termination in `Thread::join`. 3abc6940750 Auto merge of #137237 - cuviper:stage0, r=Mark-Simulacrum 4eb3105e762 add stdarch compatibility hack 97b3a661885 Rollup merge of #137194 - kornelski:ftls, r=tgross35 947d1fa0376 Rollup merge of #136826 - xizheyin:issue-136737, r=thomcc f9b2f527775 [illumos] attempt to use posix_spawn to spawn processes f31cb937609 Update `compiler-builtins` to 0.1.147 85335cc78f3 Rollup merge of #137383 - folkertdev:stabilize-unsigned-is-multiple-of, r=Noratrieb e5b671a44a5 Rollup merge of #137121 - bend-n:master, r=Noratrieb 36a59f86f93 Rollup merge of #135501 - tgross35:stdlib-dependencies-private, r=bjorn3 359de44870d make the new intrinsics safe a36adc48c04 Rollup merge of #137388 - PaulDance:disable-rename-posix-semantics-tests-under-win7, r=ChrisDenton 9294e5f976f Rollup merge of #136910 - okaneco:sig_ones, r=thomcc 37defc963bf Rollup merge of #137207 - petertodd:2025-add-track-caller-to-duration-div, r=jhpratt 6a5acde0349 Auto merge of #137397 - matthiaskrgr:rollup-ls2pilo, r=matthiaskrgr e2bc4b8c37b Fix(lib/fs/tests): Disable rename POSIX semantics FS tests under Windows 7 00c5f8a98e1 Fix unbounded_shifts tests 8960db9c01c Rollup merge of #137353 - thaliaarchi:io-optional-methods/wasi-stdin, r=alexcrichton f192be550c3 Rollup merge of #137336 - riverbl:stabilise-os-str-display, r=tgross35 72deb39375c Rollup merge of #136609 - mammothbane:master, r=scottmcm b8795e9e25f Rollup merge of #136148 - kpreid:type-str, r=joboet 45635480085 Replace some instances of `pub` with `pub(crate)` dd5703d6193 Use `public-dependencies` in all sysroot crates 28e2c6a465a Stabilize `unbounded_shifts` ec588f17554 stabilize `unsigned_is_multiple_of` 5a68dd2c32e Auto merge of #137371 - matthiaskrgr:rollup-3qkdqar, r=matthiaskrgr e7ca18efc24 Do not use CString in the examples of CStr. 42e10aff157 Use faster thread_local! for stdout 267c460933d Use faster thread_local in current_thread_id() c572f028539 Highlight thread_local! const init in docs 71a1fb96c06 Rollup merge of #136089 - jwong101:box-default-debug-stack-usage, r=Amanieu 919ca9f6cc0 Explain how Vec::with_capacity is faithful 0a38e5c2335 Auto merge of #137192 - kornelski:windows-tls-lto, r=ChrisDenton fbd1c780e2c Clarify/update comments in `BufRead::read_line`'s default body with where to *actually* look for more details 388d94e67e5 Implement read_buf for WASI stdin 56175d3c50a Implement read_buf for zkVM stdin beb7d40fb5d Rollup merge of #137270 - QianNangong:master, r=ChrisDenton e05373bef28 Rollup merge of #134340 - Urgau:stabilize-num_midpoint_signed, r=scottmcm 3205f6f8401 Stabilise `os_str_display` c33f0218629 Auto merge of #136771 - scottmcm:poke-slice-iter-next, r=joboet 0e3713a96d6 Undeprecate env::home_dir 7f2f0ccc4db Correct doc about `temp_dir()` behavior on Android ca767c6a439 Enable `f16` for MIPS 5fb2e42857d Implement feature `isolate_most_least_significant_one` for integer types d6b87df28e3 add `IntoBounds::intersect` and `RangeBounds::is_empty` f1c6d786632 Skip scanning for surrogates when not known valid 86402a4df84 Add fast path for displaying pre-validated Wtf8Buf f9d795e857b Auto merge of #137295 - matthiaskrgr:rollup-tdu3t39, r=matthiaskrgr b51ff7a2af3 Rollup merge of #137277 - m4rch3n1ng:stabilize-inherent-str-constructors, r=tgross35 e7decbcc618 Auto merge of #137290 - matthiaskrgr:rollup-a7xdbi4, r=matthiaskrgr fb345261a92 Rollup merge of #137155 - thaliaarchi:wtf8-organize, r=ChrisDenton 7b3d14c2dac Rollup merge of #136923 - samueltardieu:push-vxxqvqwspssv, r=davidtwco 105431d09b4 Rollup merge of #136690 - Voultapher:use-more-explicit-and-reliable-ptr-select, r=thomcc 0083d27be4c Rollup merge of #132268 - elichai:string_try_from_vec, r=Amanieu daabdc1c710 Rollup merge of #120580 - HTGAzureX1212:HTGAzureX1212/issue-45795, r=m-ou-se 85ae6a2f8f3 stabilize `inherent_str_constructors` 3a375d00778 Rollup merge of #136794 - cberner:stabilize, r=joshtriplett 2a2c9d829b0 Rollup merge of #136347 - allevo:patch-1, r=Amanieu d1667fc8ca4 Rollup merge of #136301 - hkBst:patch-33, r=thomcc baacf0f3994 Rollup merge of #134995 - DaniPopes:stable-const_slice_flatten, r=Amanieu 18931269a1c fix by comments ff43a1fcdca Fix `*-win7-windows-msvc` target since 26eeac1a1e9fe46ffd80dd0d3dafdd2c2a644306 9584036e9b5 Update library/std/src/fs.rs 667572fc819 core/net: IpAddr*::as_octets() e3bbe483fd3 remove assume_init in stack_overflow af9fc8f38f4 Merge from rustc fd5d2c601ae Rollup merge of #137228 - steffahn:one-coerces-to-supertypes-not-subtypes, r=the8472 7f4597fc397 Rollup merge of #137026 - GrigorenkoPV:integer_sign_cast, r=jhpratt d48df9dfe47 Auto merge of #137235 - matthiaskrgr:rollup-2kjua2t, r=matthiaskrgr 2a68133763c Remove outdated target `unexpected_cfgs` 272bdfd371b std::fs: slightly reformat `remove_dir_all` error docs 1eeac08ba0d Rollup merge of #137126 - m4rch3n1ng:fix-inherent-str-docs, r=Amanieu f1f08cafa7a Rollup merge of #136876 - joshtriplett:locking-might-not-be-advisory, r=Amanieu 102e63b0480 Rollup merge of #137214 - cyrgani:clippy_diagnostic_items, r=compiler-errors 5b72eaad8ed Rollup merge of #137205 - thaliaarchi:remove-wasi-fileext-tell, r=alexcrichton 1220ccf6944 Rollup merge of #137167 - martn3:reliable_f16_math-f16-erfc, r=tgross35 d9110584f0d Rollup merge of #136750 - kornelski:ub-bug, r=saethlin 48b02132eac update `cfg(bootstrap)` d43df0d231a Fix typo in hidden internal docs of `TrustedRandomAccess` ac553cb6319 update version placeholders ba8bd37a540 Reorder "This lock may be advisory or mandatory." earlier in the lock docs 84472b88ffe Clarify that locking on Windows also works for files opened with `.read(true)` 1eb38edd9fa add last std diagnostic items for clippy dad8c58641e Add #[track_caller] to Duration Div impl 74abdb5a254 Remove std::os::wasi::fs::FileExt::tell c439b11d9f4 Update some comparison tests now that they pass in LLVM20 33d4cd0c792 Remove obsolete MinGW ThinLTO+TLS workaround b7b81469900 Rollup merge of #137165 - thaliaarchi:file-tell, r=ChrisDenton f6b7cbc698d Use tell for ::stream_position 083489d1c96 Auto merge of #137164 - matthiaskrgr:rollup-dj5826k, r=matthiaskrgr 087c32bace1 tests: Also gate `f16::erfc()` doctest with `reliable_f16_math` cfg 48884882a6e Rollup merge of #137105 - zachs18:cow-derefpure-restrict, r=Nadrieril ebcf8a346b7 Rollup merge of #137101 - GrigorenkoPV:str-inherent-lint, r=Urgau 319f0802bbb Rollup merge of #136844 - thaliaarchi:const-io-error, r=ChrisDenton 900e66fd93c Merge from rustc e9eaf8fd3df stabilize (const_)ptr_sub_ptr 25f6fd491c7 Synchronize platform adaptors for OsString/OsStr d68ea39842d Simplify control flow with while-let 61eea6c7af2 Improve WTF-8 comments 78f5f6895e8 Rollup merge of #137114 - ChrisDenton:error, r=Noratrieb f49474ec257 Rollup merge of #136986 - ehuss:library-unsafe-fun, r=Noratrieb c9de0946aa8 invalid_from_utf8[_unchecked]: also lint inherent methods bfeda0a52f7 add MAX_LEN_UTF8 and MAX_LEN_UTF16 constants 0aeba5b388f fix docs for inherent str constructors 0ca46456e46 Add an example for std::error::Error 9b26bae8acd Merge from rustc 263e4b25f16 Restrict DerefPure for Cow impl to T = impl Clone, [impl Clone], str. 6b9b271d1bd Make ub_check message clear that it's not an assert 4f6a457616c remove MaybeUninit::uninit_array 27d76de79bf docs: fix broken intra-doc links that never worked 16ea589cd4b Auto merge of #137065 - jhpratt:rollup-ree9mej, r=jhpratt c2b1e088c4f Rollup merge of #137062 - thaliaarchi:io-optional-methods/write, r=workingjubilee 94b1a33307f Rollup merge of #136978 - ChrisDenton:windows-bindgen, r=Amanieu 2bc3e8b2635 Rollup merge of #136879 - kornelski:non1, r=Noratrieb df761061e6d Rollup merge of #136749 - mzeitlin11:extend-asciichar, r=scottmcm 2d1f245f652 Rollup merge of #135687 - joseluis:feat-reexport_from_coroutine, r=scottmcm 7496de0af43 tidying up tidy 45580317d51 Add real safety comments c71d9b123fb Go back to `Some` instead of transmuting to it. 304ce1b3b8a Save another BB by using `SubUnchecked` instead of a call to `arith_offset` f13856002b6 Simplify `slice::Iter::next` enough that it inlines c887174a273 Forward all default methods for I/O impls a7c46dd7b8d replaced the four occurrences of issue ="50547" in library/core/src/future/mod.rs with issue = "none" d241320273b Merge from rustc 9691b85c13c Auto merge of #136324 - GrigorenkoPV:erf, r=tgross35 f08d486c103 Make phantom variance markers transparent 147f24812ad Rollup merge of #136983 - ehuss:misc-2024-prep, r=tgross35 64d4df82fa3 Rollup merge of #134016 - zachs18:stable-const-str-split_at, r=Amanieu a1d6e57f8da Stabilize (and const-stabilize) `integer_sign_cast` 5f7a207ad9a proc_macro: Apply unsafe_op_in_unsafe_fn 231fc7d5115 std: Apply unsafe_op_in_unsafe_fn 13e034d1509 Fix safety of windows uwp functions 99021161db3 unwind: Apply unsafe_op_in_unsafe_fn 0ed0d928c15 panic_unwind: Apply unsafe_op_in_unsafe_fn 1ed3d402bd4 panic_abort: Apply unsafe_op_in_unsafe_fn 4c1262b3978 core: Apply unsafe_op_in_unsafe_fn 0617326e5e1 Rollup merge of #136976 - jedbrown:jed/doc-boxed-deferred-init, r=tgross35 ab7e5e6e973 Rollup merge of #136967 - DaniPopes:io-repeat-fill, r=joboet a26d6a8d876 Rollup merge of #136886 - ehuss:remove-prelude-common, r=jhpratt d8188dd66e1 Rollup merge of #136052 - no1wudi:fix, r=workingjubilee 827593948bc Add safe new to NotAllOnes 74c0eeaca74 Auto merge of #136735 - scottmcm:transmute-nonnull, r=oli-obk 30de706e194 Rollup merge of #136992 - ehuss:update-backtrace, r=workingjubilee a8d90674e4e Rollup merge of #136908 - mustartt:aix-mutex-destory-einval, r=joboet e455964a4d1 Rollup merge of #136904 - pitaj:range-into_bounds, r=tgross35 44c37a8084d Update backtrace ab632ba7993 Implement `f{16,32,64,128}::{erf,erfc}` 346c0f5521a std: Apply deprecated_safe_2024 f158ad20936 test: Apply deprecated_safe_2024 163c2871768 std: Apply fixes for tail drop expressions d5feb71dd61 std: Apply rust_2024_incompatible_pat a9dddc5ef5b std: Apply dependency_on_unit_never_type_fallback 378344935e6 std: Apply missing_unsafe_on_extern 3140f7daeff std: Apply unsafe_attr_outside_unsafe eb27443f29d alloc: Apply missing_unsafe_on_extern 8aab2dd2569 alloc: Apply unsafe_attr_outside_unsafe e983f6aed11 alloc: Workaround hidden doctest line 55127d7d462 Migrate coretests to Rust 2024 ad44a5905b9 Auto merge of #134633 - GrigorenkoPV:get_disjoint_mut, r=cuviper 680d54900c2 library: Update rand to 0.9.0 c8c0557cfc7 core: Apply unsafe_attr_outside_unsafe 216bdd3e399 alloc boxed: docs: use MaybeUninit::write instead of as_mut_ptr 6f4d9234b93 Consistently using as_mut_ptr() and as_ptr() in thread d7dc0a00893 Replace mem::zeroed with mem::MaybeUninit::uninit for large struct in unix 0ab18c7b508 Use `slice::fill` in `io::Repeat` implementation da4ed381b0a Windows: Update generated bindings to 0.59 3a3d327ef19 Rollup merge of #136949 - ehuss:wasm-bench-time, r=jhpratt 1ee869f3c63 Rollup merge of #136660 - compiler-errors:BikeshedGuaranteedNoDrop, r=lcnr 8ea18d80d82 `transmute` should also assume non-null pointers 32f3b03288c Merge from rustc b1035170c03 Implement and use BikeshedGuaranteedNoDrop for union/unsafe field validity 19c0893315e Rollup merge of #136945 - samueltardieu:push-rsqlyknnvyqm, r=fmease 966b014bfdf Rollup merge of #136818 - a1phyr:io_repeat_exact, r=jhpratt 55830306895 Rollup merge of #136699 - joboet:netaddr_from_inner, r=cuviper c795fe44468 Rollup merge of #134090 - veluca93:stable-tf11, r=oli-obk 7b96a46867d add `IntoBounds` trait fc1fd29a71a Fix import in bench for wasm 9219f4e6c4c Add diagnostic item for `std::io::BufRead` 0e05aa56601 Rollup merge of #136890 - saethlin:swap_nonoverlapping, r=RalfJung 3715d9e0c16 Change swap_nonoverlapping from lang to library UB 384e69994e1 std: replace the `FromInner` implementation for addresses with private conversion functions 8676bc869bd Remove ignored `#[must_use]` attributes from portable-simd b2adc75b1d3 Auto merge of #136918 - GuillaumeGomez:rollup-f6h21gg, r=GuillaumeGomez 4104dfa0c49 Rollup merge of #136915 - eyelash:float-precision, r=workingjubilee eac6d788e7f Rollup merge of #136875 - BoxyUwU:rdg-push, r=jieyouxu 7b900a0c001 Auto merge of #136897 - workingjubilee:revert-unfcped-stab, r=WaffleLapkin d7a30378ff8 `f128` is quadruple-precision c747c4c9355 `f16` is half-precision c01794babe2 expect EINVAL for pthread_mutex_destroy for aix 64453dd64ac Rollup merge of #136874 - tgross35:likely-unlikely-tracking, r=jhpratt dbf8f031153 library: amend revert of extended_varargs_abi_support for beta diff 703da525681 Optionally add type names to `TypeId`s. a3aa8e0ebf9 Revert "Stabilize `extended_varargs_abi_support`" 7fb3f7ff532 Remove the common prelude module 66541f0e466 Document that locking a file fails on Windows if the file is opened only for append 168693dd1b7 Reword file lock documentation to clarify advisory vs mandatory 9cb690dbd8a Rollup merge of #136354 - hkBst:patch-34, r=ibraheemdev e0b12260f17 Rollup merge of #136246 - hkBst:patch-29, r=ibraheemdev 928bef99674 Change the issue number for `likely_unlikely` and `cold_path` aae7e6cad6b Auto merge of #136851 - jhpratt:rollup-ftijn95, r=jhpratt b4de212ba47 include note on variance and example 98e87084daf Update docs for impl keyword 53df90005c6 Rollup merge of #136704 - benschulz:patch-1, r=ibraheemdev 13617787a75 Rollup merge of #136672 - safinaskar:alloc-2025-02-07-09-10, r=cuviper 890c49d1e28 Rollup merge of #136663 - WaffleLapkin:count-non-zero-ones, r=cuviper 961e80f546e Merge from rustc 91276cbc2e2 Fix long lines which rustfmt fails to format ea86b6b61d0 Rollup merge of #136107 - dingxiangfei2009:coerce-pointee-wellformed, r=compiler-errors e262e3ea663 Fix &&str and trailing commas in io::const_error! 7dd9fdced8c Use io::const_error! when possible over io::Error::new 8937afec85c Auto merge of #136823 - matthiaskrgr:rollup-vp20mk1, r=matthiaskrgr 0ae37883417 Reword doc comment on `CoercePointeeValidated` 30a505f2920 Rollup merge of #136714 - tgross35:update-builtins, r=tgross35 038d4e4e622 Auto merge of #135701 - calebzulawski:sync-from-portable-simd-2025-01-18, r=workingjubilee 1d698993f59 Implement `read*_exact` for `std:io::repeat` 66529b7c34d Rollup merge of #136805 - RalfJung:miri-win-delete-self, r=Noratrieb a995068a518 Rollup merge of #136705 - compiler-errors:edition-library, r=jhpratt 40908d20b69 Rollup merge of #136552 - ChrisDenton:option-find-handle, r=Mark-Simulacrum 2710c50c59d Rollup merge of #136353 - purplesyringa:libtest-instant-wasm, r=Mark-Simulacrum 5e7940f9979 Rollup merge of #136228 - hkBst:patch-28, r=Mark-Simulacrum a2ba8ac771d ignore win_delete_self test in Miri df899865ee4 Merge from rustc 92386bd518c Stabilize file_lock 4fa9ad28bb2 fix(libtest): Enable Instant on Emscripten targets 6980c51378f block coerce_pointee_validated for stabilization 951ffaba4e3 Rollup merge of #135488 - GrigorenkoPV:vec_pop_if, r=jhpratt cbc61e8f2ba Fix pattern matching mode changes and unsafe_op_in_unsafe_fn d9e0a425f20 Mark extern blocks as unsafe 370f8629369 Rename field in OnceWith from gen to make 2dc589bef37 Mark link_section attr with unsafe 1fdb5970812 Update string.rs 8d0206bb68c Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrum 372b6212e4a Auto merge of #136754 - Urgau:rollup-qlkhjqr, r=Urgau e7b600fe4b4 rename the trait to validity and place a feature gate afront 767ecf57208 introduce CoercePointeeWellformed for coherence checks at typeck stage 594556dd299 Rollup merge of #136724 - steffahn:asyncfn-non-fundamental, r=compiler-errors 69d386ec244 Rollup merge of #136710 - JakenHerman:jaken/iterator-docs, r=workingjubilee 3d64f4c1ba6 Rollup merge of #136686 - bjoernager:master, r=jhpratt 9e2eb8d4b91 Rollup merge of #136601 - compiler-errors:borrow-null-zst, r=saethlin de555d8a276 Rollup merge of #136213 - erickt:fs, r=Mark-Simulacrum 3bc72bb59f9 Rollup merge of #134679 - ChrisDenton:rm-readonly, r=Mark-Simulacrum 275be806bf5 occured -> occurred c74f8b5fc1f Rustfmt 88ee8a04b47 Document `Sum::sum` returns additive identities for `[]` 9cf53b6ea43 Implement Extend for String 1d535de7364 Rollup merge of #136099 - Kijewski:pr-rc-str-default, r=ibraheemdev c6124b4c448 Rollup merge of #135696 - joboet:move_pal_io, r=Noratrieb 2a7a079772a Merge from rustc 2b41365cfca Auto merge of #136713 - matthiaskrgr:rollup-sy6py39, r=matthiaskrgr 95ea59d5173 Make `AsyncFnOnce`, `AsyncFnMut`, `AsyncFn` non-`#[fundamental]` ad5aea5e454 Update `compiler-builtins` to 0.1.146 82e98ea854e Rollup merge of #136682 - ChrisDenton:move-win-proc-tests, r=joboet 20e702ffb2e Rollup merge of #136635 - jieyouxu:base_port, r=joboet f673e1606ed Rollup merge of #136615 - Ayush1325:uefi-net-unsupported, r=joboet fc11b454ce5 Improve examples for file locking 4b3e632673b Rollup merge of #135945 - estebank:useless-parens, r=compiler-errors 0d0527e1702 Rollup merge of #134367 - WaffleLapkin:trait_upcasting_as_a_treat, r=compiler-errors 7dd6829164d std: get rid of `sys_common::io` 9b7104dbe47 std: move `io` module out of `pal` c1f3f20b634 Use more explicit and reliable ptr select in sort impls e8e96403b8a Clean up 'HashMap' and 'HashSet' docs; 8f754628013 Rollup merge of #136634 - bjoernager:const-mut-cursor, r=m-ou-se 1ff33ee233d Move two windows process tests to tests/ui ff5abb62988 library: doc: core::alloc::Allocator: trivial typo fix 900da4f3fd7 Revert vita's c_char back to i8 fe1439a94eb remove use of `feature(trait_upcasting)` from core tests 4c33132baee Remove some unnecessary parens in `assert!` conditions 10eb42d9237 stabilize `NonZero::count_ones` 10c27803bc3 Rollup merge of #136152 - Urgau:stabilize-map_many_mut, r=joshtriplett f973a52645b Rollup merge of #136630 - jieyouxu:render_tests, r=ChrisDenton bf2eee8a588 Stabilise 'Cursor::{get_mut, set_position}' in 'const' scenarios; c055c57b6f9 tests(std/net): remove outdated `base_port` calculation 0a62a04415e tests(std): don't output to std{out,err} in `test_creation_flags` and `test_proc_thread_attributes` 26037053b33 Auto merge of #136613 - workingjubilee:rollup-ry6rw0m, r=workingjubilee 94b8c8abce3 sys: net: Add UEFI stubs 0e43e9c22ce Rollup merge of #136595 - thaliaarchi:hermit-unreachable-pub, r=Noratrieb ef106388320 Rollup merge of #136566 - hkBst:patch-1, r=scottmcm ccd78f8a0e2 Auto merge of #136409 - TDecking:mul_hi, r=Mark-Simulacrum ae8a4a9d009 Rollup merge of #136555 - cramertj:split_off, r=dtolnay 5792f5cd50b Rollup merge of #136537 - tgross35:update-builtins, r=tgross35 29d0feddcab Rollup merge of #136517 - m4rch3n1ng:inherent-str-constructors, r=jhpratt 48b038cf2af Rollup merge of #136449 - joboet:move_pal_net, r=ChrisDenton a20c46c0a18 Rollup merge of #136418 - Ayush1325:command-env, r=jhpratt b0449f2f6e1 Fix link in from_fn.rs 3dd32ae84d9 Fix unreachable_pub lint for hermit target 08a556e6906 Rollup merge of #136502 - yotamofek:pr/fmt-from-fn-must-use, r=dtolnay 1420e0334e9 Rollup merge of #128045 - pnkfelix:rustc-contracts, r=oli-obk b5db0562096 Add OneSidedRangeBound to eliminate panic in `split_point_of` 3daa09ada6e Rename slice::take methods to split_off 10189db6e75 Use Option for FindNextFileHandle d9ad3d612d2 Auto merge of #135760 - scottmcm:disjoint-bitor, r=WaffleLapkin 023ac462a65 intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic 3e9dee72261 Auto merge of #136534 - jhpratt:rollup-dnz57dq, r=jhpratt f3cc8954938 Auto merge of #136533 - jhpratt:rollup-s0ign8n, r=jhpratt 5880f67026b Update `compiler-builtins` to 0.1.145 c78c36fa474 Rollup merge of #136518 - Urgau:fn_ptr-public-bound, r=Noratrieb 40c37fc3799 Rollup merge of #136511 - joshtriplett:nonzero-cast-signed-unsigned, r=dtolnay 4a1eec8014f Rollup merge of #136479 - RalfJung:dirent64, r=tgross35 0bb9ad7ace0 Rollup merge of #136398 - pitaj:unsafecell_access, r=dtolnay 29498e70b30 Rollup merge of #136334 - ricci009:primitivers, r=tgross35 6e1295bc8c9 Rollup merge of #136167 - pitaj:new_range, r=Nadrieril dbe125183da Rollup merge of #135621 - bjorn3:move_tests_to_stdtests, r=Noratrieb ecfdcb94bc0 Auto merge of #135265 - pascaldekloe:fmt-int-speed, r=tgross35,ChrisDenton ee3eff0675a specify a prim@slice in docs 43ef876e485 implement inherent str constructors c1c78464cdb Add note about `FnPtr` being exposed as public bound 60976d84595 primitive type migration from mod.rs to primitives.rs 8de1ae17be7 Rename rustc_contract to contract b2f1b5b4843 Improve contracts intrisics and remove wrapper function 900d21991f3 Separate contract feature gates for the internal machinery 3c987305a09 Desugars contract into the internal AST extensions 0cd98e7eeb8 Add `cast_signed` and `cast_unsigned` methods for `NonZero` types b861e819bfe Express contracts as part of function header and lower it to the contract lang items 4b5a5aa6989 contracts: added lang items that act as hooks for rustc-injected code to invoke. 9130a03fa38 Contracts core intrinsics. 32a2eb06555 Mark `std::fmt::from_fn` as `#[must_use]` 76c4a227353 Rollup merge of #136289 - Pyr0de:oncecell-docs, r=tgross35 19154314fd1 no unsafe pointer and no overflowing_literals in fmt::Display of integers ea88c5f84a4 For NonZero impl macros, give unsigned impls access to the corresponding signed type 3b1968368f2 OnceCell & OnceLock docs: Using (un)initialized consistently a6874f4ca1e std::fs: further simplify dirent64 handling e39a0b26a7b Merge from rustc 4a49a0c399e Docs for f16 and f128: correct a typo and add details d3a623284ec Rollup merge of #136452 - RalfJung:miri-sync, r=RalfJung 9c480135f36 Remove stabilized feature gate b6239637fc3 std: move network code into `sys` 703cbc1fec9 Rollup merge of #136434 - RalfJung:rustc_allowed_through_unstable_modules-deprecation-required, r=compiler-errors 7af9dd25aff Rollup merge of #136283 - hkBst:patch-31, r=workingjubilee 74f272849c8 Rollup merge of #134272 - RalfJung:destabilize-rustc_encodable_decodable, r=oli-obk a58c0451843 Merge from rustc 54a0b27009a rustc_allowed_through_unstable_modules: require deprecation message a120861e34b Rollup merge of #136133 - hkBst:patch-23, r=ibraheemdev 4ad629e9758 uefi: process: Add support for command environment variables 046ce6a1061 Use `widening_mul` 1c4078f12c8 add UnsafeCell direct access APIs c74858a43f2 Rollup merge of #136364 - hkBst:ptr_cmp_docs, r=tgross35 b55be6bc42d Rollup merge of #136360 - slanterns:once_wait, r=tgross35 b2c29a5d3ce Rollup merge of #136307 - WaffleLapkin:minminmin, r=scottmcm bd111f66c41 Rollup merge of #135684 - ranger-ross:mutex-docs, r=joboet 4d54555054f document ptr comparison being by address 322f4ff60ea Fix sentence in process::abort 86eb99c849a More PR feedback 1ad1e30da56 PR feedback 21ff5a9f1e2 Add `unchecked_disjoint_bitor` with fallback intrinsic implementation 7c35620e431 docs: Documented Send and Sync requirements for Mutex + MutexGuard bd42cf90f26 Merge from rustc fdf76cc8147 Rollup merge of #136351 - Darksonn:coerce-pointee-docs, r=compiler-errors c019c23231f Rollup merge of #136163 - uellenberg:driftsort-off-by-one, r=Mark-Simulacrum fed18ca6d6c stabilize `once_wait` f29597fd21e Auto merge of #134424 - 1c3t3a:null-checks, r=saethlin 2db2320e5b6 Add documentation for derive(CoercePointee) d3b13153b26 Insert null checks for pointer dereferences when debug assertions are enabled aa603ac5d92 Update encode_utf16 to mention it is native endian 8c6905a4de2 Update fs.rs 16badee296b Auto merge of #136332 - jhpratt:rollup-aa69d0e, r=jhpratt 28c497cc543 Rollup merge of #136300 - RalfJung:compare-and-swap, r=joboet a5de5134ed8 Rollup merge of #136296 - RalfJung:float-min-max, r=tgross35 ca9639dab13 Rollup merge of #135414 - tgross35:stabilize-const_black_box, r=dtolnay 370a1cdeea7 Merge from rustc b88edf4ecc1 implement all min/max fns in terms of `<`/`is_lt` fcb2bc3cc94 implement unstable `new_range` feature 24bdb9aa495 improve doc tests for (min/max/minmax).* functions f7de368b9dd std::range 137c2bb32b5 Rollup merge of #136288 - joshtriplett:would-you-could-you-with-some-locks--would-you-could-you-in-some-docs, r=m-ou-se 796e5e780fd Rollup merge of #136271 - Sky9x:debug-maybeuninit-footgun, r=tgross35 163f5dd0a3f Rollup merge of #135852 - lukas-code:asyncfn-prelude-core, r=compiler-errors edde199a2aa Rollup merge of #135475 - Ayush1325:uefi-absolute-path, r=jhpratt c31ed471b03 black_box integer-input on fmt benches 10a7afcda8c Auto merge of #134824 - niklasf:int_from_ascii, r=ibraheemdev cea1bedbf46 Improve instant docs 26491184e2e atomic: extend compare_and_swap migration docs 0c79ce207e1 float::min/max: mention the non-determinism around signed 0 b4e2280fef5 Improve documentation for file locking 21622375a4e Merge from rustc 24ff8ae468a Rollup merge of #136259 - hkBst:patch-30, r=thomcc 83aa5c1315a Rollup merge of #136215 - btj:patch-1, r=cuviper 6d7c45f8fd6 Rollup merge of #135847 - edwloef:slice_ptr_rotate_opt, r=scottmcm 819ca901db1 Remove minor future footgun in `impl Debug for MaybeUninit` 3830bbed32e Cleanup docs for Allocator e4ae302d24f add inline attribute and codegen test b4f1712972e split slice::ptr_rotate into three separate algorithms, to hopefully help inlining 963194bd855 Auto merge of #136248 - matthiaskrgr:rollup-leaxgfd, r=matthiaskrgr 506db6f503d Rollup merge of #136092 - tbu-:pr_io_pipe_test, r=joboet 665fab7c016 Auto merge of #136227 - fmease:rollup-ewpvznh, r=fmease 10598dc2e3b Fix off-by-one error causing driftsort to crash f23398091be btree/node.rs: pop_internal_level: does not invalidate other handles 579d90bd9ff Merge from rustc 72aeea30fa0 Simplify Rc::as_ptr docs + typo fix 44051b31651 Rollup merge of #136186 - Ayush1325:uefi-process-args-fix, r=nicholasbishop,Noratrieb c8953bcdc54 Rollup merge of #135625 - c410-f3r:cfg-match-foo-bar-baz, r=tgross35,jhpratt 7276d04619b Allow Rust to use a number of libc filesystem calls dcd657596b0 btree/node.rs: remove incorrect comment from pop_internal_level docs e6a7f5d73d6 Auto merge of #136203 - matthiaskrgr:rollup-1k0f44l, r=matthiaskrgr 7205f0af655 Rollup merge of #136173 - taiki-e:c-char, r=tgross35 0ae2a30dfce Rollup merge of #136071 - wowinter13:clippy-add-diagnostic-items, r=flip1995 e449a6c2eba Rollup merge of #135869 - hkBst:patch-12, r=Noratrieb ced312fce29 Stabilize `get_many_mut` as `get_disjoint_mut` 344f948cf64 uefi: process: Fix args 496fe7162ba Rollup merge of #136012 - hkBst:patch-22, r=workingjubilee,tgross35 7a3a419ca8a Rollup merge of #135886 - hkBst:patch-14, r=workingjubilee d53c0000980 Rollup merge of #135805 - DiuDiu777:master, r=Noratrieb d37ac725dd2 Rollup merge of #135367 - Urgau:unreach_pub-std-3, r=Noratrieb 403b0b39947 Rollup merge of #133829 - GrigorenkoPV:fetch_update_infallible, r=Noratrieb 061edde269f Fix platform-specific doc string for AtomicUsize::from_mut to be platform-independent 527882bf14d Document powf and powi calls that always return 1.0 c4cd0b7c050 Update comments and sort target_arch in c_char_definition b93feb588c2 Stabilize target_feature_11 1056a819cfd Auto merge of #136110 - RalfJung:miri-sync, r=RalfJung f9be93972e7 Stabilize `HashMap::get_many_mut` as `HashMap::get_disjoint_mut` 35704ea4c8d Stabilize `num_midpoint_signed` feature 32749149926 Rollup merge of #135876 - usamoi:mpmc-doc, r=tgross35 f64b962fba0 Rollup merge of #135807 - jhpratt:phantom-variance, r=Amanieu a50e3d7f54a Rollup merge of #135773 - hkBst:patch-10, r=tgross35 63483318baa Clarify WindowsMut (Lending)Iterator 6837e59fd85 Stabilize `const_black_box` fb9d3ac464c Auto merge of #136116 - fmease:rollup-c8pk3mj, r=fmease 67ec627b006 Auto merge of #135937 - bjorn3:separate_coretests_crate, r=jieyouxu,tgross35 5b36cacd712 fix doc for std::sync::mpmc 1f97890ce49 Rollup merge of #136079 - RalfJung:compiler-fence-example, r=jhpratt 87604101dfd Rollup merge of #135635 - tbu-:pr_io_pipe, r=joboet 84e37e67d7a compiler_fence: fix example bcb90340247 Optimize `Rc::::default()` implementation 89d7937a36b Document purpose of closure in from_fn.rs more clearly 68f6b01c245 Auto merge of #136087 - jhpratt:rollup-tam1mzn, r=jhpratt d98d447d2b7 Test pipes also when not running on Windows and Linux simultaneously d1fa0a4fbd4 Update `std::io::{pipe, PipeReader, PipeWriter}` docs the new location 7ce37737631 Move `std::io::pipe` code into its own file 21785685d34 Actually run the bstr test 8033d307f45 Move env modifying tests to a separate integration test fcaf2f1c5f0 Fix for SGX a3e6b238bf3 Fix benchmarking of libstd 2e6b5b9050d Move std::sync unit tests to integration tests d2711596742 Move std::thread_local unit tests to integration tests 7e7ca2b9660 Move std::time unit tests to integration tests 316f77df27a Move std::path unit tests to integration tests 8c02a576d13 Move std::panic unit tests to integration tests 74893de3fef Move std::num unit tests to integration tests a32e504c488 Move std float unit tests to integration tests bac6108c031 Move std::error unit tests to integration tests f7bc549cb3f Move std::env unit tests to integration tests 555025b0c6f Update comment 06ee7516ffb Put all coretests in a separate crate 1396e007c88 reduce `Box::default` stack copies in debug mode 7aec69acb8a Rollup merge of #136019 - scottmcm:alias-unchecked-div, r=Mark-Simulacrum 567ad8ea64d Rollup merge of #133631 - flba-eb:add_nto_qnx71_iosock_support, r=workingjubilee cd30b1eb972 Windows: Test that deleting a running binary fails 063f8c2636a Update platform information for remove_file c3df8206e50 Windows: remove readonly files ddd1a4cecea Merge from rustc 5fe03baa519 Implement phantom variance markers c0037d7ad4d Rollup merge of #135948 - bjorn3:update_emscripten_std_tests, r=Mark-Simulacrum ca5e77e0499 Rollup merge of #134283 - epage:logfile, r=Amanieu 9d4544cc8ca [Clippy] Add vec_reserve & vecdeque_reserve diagnostic items 90506de9204 Rollup merge of #136039 - nvanbenschoten:pin-typo, r=Amanieu af1ba12a51d Rollup merge of #136005 - BLANKatGITHUB:library, r=RalfJung f1213b300c6 Improve and expand documentation of pipes 6c1c3c0bf7c Correct comment for FreeBSD and DragonFly BSD in unix/thread 0285d898938 Rollup merge of #135991 - no1wudi:master, r=thomcc bb0afaa57fe Rollup merge of #135977 - nyurik:fix-fmt-options, r=joboet ff9e88a2097 docs: fix typo in std::pin overview 37370b0c584 Merge from rustc 8ecd2bcf0a9 Rollup merge of #135938 - carlsverre:master, r=joboet cdb3e29386a Rollup merge of #135728 - hkBst:patch-8, r=joboet 773b5d508cb Rollup merge of #135415 - Harshit933:hard-link-error, r=ChrisDenton af788b438df Stabilize `vec_pop_if` 03ab09910c1 fix(libtest): Deprecate '--logfile' 74e2341dc38 Add an `unchecked_div` alias to the `Div>` impls eb6fbc8096a Update library/core/src/num/nonzero.rs 92835a3f194 Add `File already exists` error doc to `hard_link` function f0f1a87d800 ports last few library files to new intrinsic style cf546c814bb Rollup merge of #135983 - hkBst:patch-13, r=jhpratt 7edb3047441 Rollup merge of #135956 - GrigorenkoPV:vec_pop_off, r=dtolnay ee9cefa410f Fix set_name in thread mod for NuttX 3620eec3493 add nto80 x86-64 and aarch64 target 9bb1668f214 Add support for QNX 7.1 with io-sock on x64 d6342fa9aba Add new target for supporting Neutrino QNX 6.1 with `io-socket` network stack on aarch64 035c12ec8bf Doc difference between extend and extend_from_slice a274dc05834 Update a bunch of comments from before wasi support was added 558f11a550d Remove a bunch of emscripten test ignores 2b9f32ec29a Fix testing of the standard library with Emscripten 5551cba498d Auto merge of #135978 - matthiaskrgr:rollup-ni16gqr, r=matthiaskrgr b2c0a9ef4e7 Rollup merge of #135890 - GrigorenkoPV:deque-pop-if, r=thomcc 1acbfe7524b Rollup merge of #135489 - RalfJung:TryFromSliceError, r=tgross35 6544b00a8fb Fix `FormattingOptions` instantiation with `Default` 1b48955d367 Auto merge of #135959 - matthiaskrgr:rollup-0jenyfw, r=matthiaskrgr 2f8df6078a7 Rollup merge of #135366 - Urgau:unreach_pub-std-2, r=cuviper 7996d149512 Make `Vec::pop_if` a bit more presentable a2a21f1de2f Rollup merge of #135073 - joshtriplett:bstr, r=BurntSushi 25a698d219d Add memory layout documentation to generic NonZero c5b0f81666b Rollup merge of #135883 - GrigorenkoPV:btree_set_upper_bound_mut, r=tgross35 8bd8c106e94 Implement `AtomicT::update` & `AtomicT::try_update` 85dbbfdff48 Rollup merge of #135856 - fmease:library-mv-obj-save-dyn-compat-ii, r=tgross35 12bfc4e7bf7 Rollup merge of #135837 - ChrisDenton:trunc, r=Noratrieb 23cbfa61496 Implement `VecDeque::pop_front_if` & `VecDeque::pop_back_if` 5a5cbddddb9 Implement `CloneToUninit` for `ByteStr` 7f701724cf5 Remove erroneous `unsafe` in `BTreeSet::upper_bound_mut` 70c35f71879 Add doc aliases for BStr and BString 93da2972cf8 Library: Finalize dyn compatibility renaming f1b7b24d44e Add `AsyncFn*` to core prelude 6ab5ba61e9a Rollup merge of #135821 - hkBst:patch-11, r=ibraheemdev 8ea3470dd75 Rollup merge of #135750 - scottmcm:cma-example, r=cuviper 6ea8945f347 optimize slice::ptr_rotate for compile-time-constant small rotates 84b04a92dfd [cfg_match] Document the use of expressions c55947fa5e9 Remove test panic from File::open cd5dca3ed5c fix OsString::from_encoded_bytes_unchecked description a8ce127e2ee add missing allocator safety in alloc crate 9e9be1932e2 Auto merge of #135224 - wyfo:tls-panic-outline, r=cuviper 465366c7574 Auto merge of #134286 - Urgau:unreach_pub-std, r=ibraheemdev 9e295224a6a Rollup merge of #135741 - bardiharborow:std/net/rfc9637, r=Amanieu 8f124ce2150 Rollup merge of #133695 - x17jiri:hint_likely, r=Amanieu 64f6d4d4203 alloc: add `#![warn(unreachable_pub)]` 9f1e1f2f90b test: add `#![warn(unreachable_pub)]` a1a4f7a5752 proc_macro: add `#![warn(unreachable_pub)]` 7c020ae9a45 core: `#[allow(unreachable_pub)]` on unreachable `pub use` 9412a163d7b core: add `#![warn(unreachable_pub)]` e82f2a31a59 rtstartup: add `#![warn(unreachable_pub)]` 7e3f5d54b07 panic_unwind: add `#![warn(unreachable_pub)]` 9dff2820ffd 1. Removed 'rustc_nounwind' 2. Rewording of comments b3e668cd01d Rollup merge of #135762 - TomFryersMidsummer:patch-1, r=joboet 6982b19d1e4 Rollup merge of #135626 - clubby789:env-note, r=ibraheemdev 150649f77be Correct counting to four in cell module docs 151c72de98d Rollup merge of #135491 - RalfJung:remove-dead-rustc_allowed_through_unstable_modules, r=Mark-Simulacrum d19faac64ad Rollup merge of #135446 - klensy:panic_immediate_abort_ext, r=Mark-Simulacrum 2ab070f4daa Add an example of using `carrying_mul_add` to write wider multiplication 552e6773cb0 Recognise new IPv6 documentation range from RFC9637 0db32633608 Fix whitespace f02e25ecde7 Auto merge of #135714 - rust-lang:cargo_update, r=clubby789 a8c73bd904b document order of items in iterator from drain 5cfbae8e8f5 Auto merge of #134976 - mgsloan:improve-select-nth-unstable-docs, r=ibraheemdev 1591282e846 Auto merge of #135709 - lqd:bring-back-len, r=compiler-errors a0600dba81c Rewrap following accepting review suggestions from @ibraheemdev aa330bd99ef Update library/core/src/slice/mod.rs 44de88ef1b5 Update library/core/src/slice/mod.rs baec7cbb213 Update library/core/src/slice/mod.rs 3cf8967abc5 Update library/core/src/slice/mod.rs d63afbbadb2 Update library/core/src/slice/mod.rs 18b80248051 Update library/core/src/slice/mod.rs ab43bf71397 Update library/core/src/slice/mod.rs db5a4e83ae6 Update library/core/src/slice/mod.rs d714fcb42f4 Update library/core/src/slice/mod.rs 5d51a1c1bc8 Update library/core/src/slice/mod.rs 953b13a9edc cargo update a0babe16715 Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper" f02ac3b184b `then be` -> `be` based on feedback from @ibraheemdev 76a0bc6c4c9 Merge commit '3383cfbd3572465febc7a8f816a46304373de46a' into sync-from-portable-simd-2025-01-18 852288aff02 re-export `core::iter::FromCoroutine` 2209a2962d4 Rollup merge of #135661 - tgross35:stabilize-float_next_up_down, r=scottmcm c4b0bc2837e Rollup merge of #135583 - NobodyXu:move-pipe-to-io, r=joshtriplett 5cd9dd86a00 Add references to the IEEE functions for `float_next_up_down` e5fcc9c0b76 Stabilize `float_next_up_down` 1284521932c Fix import of pipe in kernel_copy.rs 5e4fcffc97d doc: Point to methods on `Command` as alternatives to `set/remove_var` 805c2dccd44 Rollup merge of #135556 - AeonSolstice:patch-1, r=tgross35 5b7ffd59c43 Rollup merge of #134496 - DiuDiu777:fix-doc, r=ibraheemdev cbe64a01fc5 Rollup merge of #133720 - c410-f3r:cfg-match-foo-bar-baz, r=joshtriplett ef9aea47059 Move `std::pipe::*` into `std::io` 4f467b42ba7 fix typo in library/alloc/src/sync.rs da96665eefc Less unsafe in `dangling`/`without_provenance` d3abf38600a uefi: Implement path 65a01a5f4b1 Auto merge of #135555 - matthiaskrgr:rollup-jnqdbuu, r=matthiaskrgr d9505c70d6c Clarify note in `std::sync::LazyLock` example 21e4a2d669d Rollup merge of #135497 - DJMrTV:master, r=jhpratt 83ed08293cb Export likely(), unlikely() and cold_path() in std::hint fe946414929 fix typo in typenames of pin documentation bb9ef57a909 Rollup merge of #135003 - RalfJung:deprecate-allowed-through-unstable, r=davidtwco 6e419fe7a8c Rollup merge of #132654 - joboet:lazy_main, r=ChrisDenton e3e8b608446 Auto merge of #135525 - jhpratt:rollup-4gu2wpm, r=jhpratt 877f6cf897c Rollup merge of #134678 - zachs18:offset-ptr-update, r=tgross35 c6b3ac166a6 Rollup merge of #134338 - tgross35:overflowing-c-safe-ret, r=bjorn3,antoyo 849de68f9db Rollup merge of #134143 - nyurik:err-nul, r=dtolnay cba1b03c4c3 intrinsics: deprecate calling them via the unstable std::intrinsics path 2a3b9f9605d Update ReadDir::next in std::sys::pal::unix::fs to use `&raw const (*ptr).field` instead of `ptr.offset(...).cast()`. 9415759b85a Update compiler-builtins to 0.1.143 9e11ae06d7e Rollup merge of #135423 - compiler-errors:enforce-const-trait-syntactical, r=oli-obk,RalfJung f29524bd8d6 Enforce syntactical stability of const traits in HIR 4bfbfccb5fb Update compiler-builtins to 0.1.141 b18eda95208 wasi/io: remove dead files bdb206ed163 remove unnecessary rustc_allowed_through_unstable_modules 46700095e23 remove pointless allowed_through_unstable_modules on TryFromSliceError 1089a250343 remove Rustc{En,De}codable from library and compiler a40af1146a7 make rustc_encodable_decodable feature properly unstable 9207ccdd921 add comments explaining main thread identification bb7893c2eb6 std: lazily allocate the main thread handle 7ad0ee7d8f9 Revert "Remove the Arc rt::init allocation for thread info" da43f89db02 Auto merge of #135473 - matthiaskrgr:rollup-ksnst4l, r=matthiaskrgr 5647815cb1d Rollup merge of #135381 - cod10129:vec-splice-doc, r=tgross35 a6fe12e559e Auto merge of #135359 - RalfJung:lang-start-unwind, r=joboet 919b916b23e Auto merge of #135465 - jhpratt:rollup-7p93bct, r=jhpratt 5146a4581f5 Rollup merge of #135393 - Ayush1325:uefi-helper-path, r=thomcc 33d0c87f82c Add another `Vec::splice` example 0c666f9d720 uefi: helpers: Introduce OwnedDevicePath 0537880dc4e further improve panic_immediate_abort by removing rtprintpanic messages 3c898262b72 Rollup merge of #135405 - Ayush1325:path-is-absolute, r=tgross35 6bf6a713d82 path: Move is_absolute check to sys::path 535c131a2c3 Auto merge of #135420 - GuillaumeGomez:rollup-93vepka, r=GuillaumeGomez 185ce5d37ad Auto merge of #135384 - saethlin:inline-copy-from-slice, r=joboet 1aa84ce9770 Update the explanation for why we use box_new in vec! a73d8c4b667 Auto merge of #135402 - matthiaskrgr:rollup-cz7hs13, r=matthiaskrgr 1dc48ed3e0d Omit some more `From` impls to avoid inference failures 51792a48082 Rollup merge of #135379 - steffahn:uniquerc-invariant, r=Mark-Simulacrum f794b72956c Add inherent versions of MaybeUninit methods for slices 3a45a4eb1ed Add #[inline] to copy_from_slice 303e0607772 Auto merge of #135360 - RalfJung:structural-partial-eq, r=compiler-errors 82a0d964348 Make UniqueRc invariant for soundness 9b1aa855cea avoid nesting the user-defined main so deeply on the stack a2eb38a8ae0 use a single large catch_unwind in lang_start cd296bda550 update and clarify StructuralPartialEq docs b90f4f50a8b Rename `pos` to `position` 79d1b07ab32 Convert `struct FromBytesWithNulError` into enum abfb421b3b4 Rollup merge of #135347 - samueltardieu:push-qvyxtxsqyxyr, r=jhpratt 8a581ca8709 Rollup merge of #135324 - Ayush1325:uefi-fs-unsupported, r=joboet 26b3e33a49d Rollup merge of #135236 - scottmcm:more-mcp807-library-updates, r=ChrisDenton 626b75c9284 Support `no_rc`, `no_sync`, and `no_global_oom_handling` e178b996c13 Add `#[cfg(not(test))]` to some impls to work around https://github.com/rust-lang/rust/issues/135100 3b795a30635 Implement `ByteStr` and `ByteString` types d2a7e08319c Improve the safety documentation on new_unchecked 5562e3eda39 Use `NonNull::without_provenance` within the standard library 1c5b11eb90e alloc: remove unsound `IsZero` for raw pointers c0a400e1845 Rollup merge of #134693 - SpriteOvO:proc-macro-use-to-tokens-in-quote, r=tgross35 65debb141be Rollup merge of #132607 - YohDeadfall:pthread-name-fn-with-result, r=tgross35 113f9a457d7 Update a bunch of library types for MCP807 024e87c1e02 Initial fs module for uefi e339830a52e Rollup merge of #134908 - madsmtm:ptr-from_ref-docs, r=ibraheemdev 23cbdb5d6c4 Rollup merge of #134619 - hkBst:patch-7, r=jhpratt fbd1013a4e7 Fix `proc_macro::quote!` for raw ident c91f89602fb Append `TokenTree` with `ToTokens` in `proc_macro::quote!` 88431131a2c Used pthread name functions returning result for FreeBSD and DragonFly 9b9b82a1935 Auto merge of #135268 - pietroalbini:pa-bump-stage0, r=Mark-Simulacrum 0cae6ffb6fd Rollup merge of #135269 - estebank:unneeded-into, r=compiler-errors 91009c36e85 Rollup merge of #135242 - RalfJung:nonnull-provenance, r=jhpratt c4bd937e407 Remove some unnecessary `.into()` calls f63527614d9 fmt 5662ec1f8fa update cfg(bootstrap) f2aeadc0772 update version placeholders 845e44902d3 add missing provenance APIs on NonNull e4396934376 Rollup merge of #135176 - kornelski:env-example, r=cuviper 9f93eda235b Rollup merge of #134389 - rust-wasi-web:condvar-no-threads, r=m-ou-se 743b57e0c3f Rollup merge of #133057 - tisonkun:into-chars, r=Amanieu c3e22fe7795 Outline panicking code for `LocalKey::with` 8628897d12a Avoid naming variables `str` 339a2dc76ff Rollup merge of #135139 - c410-f3r:8-years-rfc, r=jhpratt 7cf409a5b7d Rollup merge of #131830 - hoodmane:emscripten-wasm-eh, r=workingjubilee 3b5d689fec8 More compelling env_clear() examples 484095e7fa3 Rollup merge of #135153 - crystalstall:master, r=workingjubilee 76b384d41d7 Add support for wasm exception handling to Emscripten target 0c09a242f2f chore: remove redundant words in comment 2d2189b7506 Rollup merge of #135111 - tgross35:float-doc-aliases, r=Noratrieb d91ef098887 [generic_assert] Constify methods used by the formatting system 669fed8acb3 Rollup merge of #135121 - okaneco:const_slice_reverse, r=jhpratt 4ada746967e Mark `slice::reverse` unstably const 24ca61e77ac Clarified the documentation on core::iter::from_fn and core::iter::successors 65d0dcd8df1 Rollup merge of #135110 - matthiaskrgr:adler, r=workingjubilee 747526fc059 Rollup merge of #135104 - the8472:disable-in-place-iter-for-flatten, r=Mark-Simulacrum 55c357e2dd1 Rollup merge of #134996 - bdbai:uwp-support, r=jieyouxu,ChrisDenton 5ffa79c0ac0 Add doc aliases for `libm` and IEEE names 594064c0242 library: fix adler{-> 2}.debug 5e20cf6fbae add regression test for unsound Flatten/FlatMap specialization acbb92c21b0 do not in-place-iterate over flatmap/flatten 81e046bad74 Rollup merge of #135091 - workingjubilee:backtrace-0.3.75, r=workingjubilee 22e773a058e Rollup merge of #135070 - klensy:backtrace-deps, r=workingjubilee d59d6ccf103 Rollup merge of #135046 - RalfJung:rustc_box_intrinsic, r=compiler-errors 010824d0035 Rollup merge of #133964 - joboet:select_unpredictable, r=tgross35 13f8d6dbc50 Bump backtrace to 0.3.75 e6ba295a9bc Rollup merge of #133420 - thesummer:rtems-unwind, r=workingjubilee 2f9707577b5 sync to actual dep verions of backtrace 735f9e90dec turn rustc_box into an intrinsic 9a23ebf3f4c Auto merge of #135059 - matthiaskrgr:rollup-0ka9o3h, r=matthiaskrgr 4a71d50df08 Rollup merge of #134241 - liigo:patch-16, r=dtolnay 174456429ba Auto merge of #134692 - GrigorenkoPV:sync_poision, r=tgross35 ee339481ec7 Fix UWP build 953aceec482 Bump backtrace to rust-lang/backtrace-rs@4d7906b 7219780eba4 Auto merge of #122565 - Zoxc:atomic-panic-msg, r=the8472 0ab3dac3cff path in detail a22793a0737 Move some things to `std::sync::poison` and reexport them in `std::sync` 27c2ef23a25 fix doc for missing Box allocator consistency c580f13d89b Auto merge of #135005 - matthiaskrgr:rollup-5ubuitt, r=matthiaskrgr 473e405d358 Rollup merge of #134985 - mgsloan:remove-unnecessary-qualification-in-Ord-trait-docs, r=Noratrieb 44eecab953b Rename the internal simpler `quote` macro to `minimal_quote` 92a0f5b9ce0 Auto merge of #134080 - kleisauke:avoid-lfs64-emscripten, r=Noratrieb f1922549d00 Try to write the panic message with a single `write_all` call ff578a7444e Stabilize const_slice_flatten 0e32305c45a std::fs::DirEntry.metadata(): prefer use of lstat() on Emscripten e21d7001f85 Avoid use of LFS64 symbols on Emscripten 1d06d767d86 Auto merge of #134969 - Marcondiro:master, r=jhpratt,programmerjake 8d8d1ab5e75 Rollup merge of #131439 - mu001999-contrib:cleanup/static-mut, r=estebank 9c387e43f6e Improve `select_nth_unstable` documentation clarity 2f4c9479f60 Remove qualification of `std::cmp::Ordering` in `Ord` doc 44ca9a9da1b Auto merge of #132195 - clarfonthey:bigint-mul, r=scottmcm 663fff5f91b Auto merge of #134966 - matthiaskrgr:rollup-lmhmgsv, r=matthiaskrgr 6e286412535 char to_digit: avoid unnecessary casts to u64 ebe0a39f970 Rollup merge of #134953 - DiuDiu777:unaligned-doc, r=RalfJung 05d409aecb0 Auto merge of #134620 - ChrisDenton:line-writer, r=tgross35 fe9fa091c0d Rollup merge of #134930 - RalfJung:ptr-docs-valid-access, r=jhpratt b590818e284 Rollup merge of #134927 - DaniPopes:const-as_flattened_mut, r=scottmcm cd7dd952e65 fix doc for read write unaligned in zst operation e6cbb9884c5 Auto merge of #134757 - RalfJung:const_swap, r=scottmcm f3b61eb75cb ptr docs: make it clear that we are talking only about memory accesses c2180531193 Make slice::as_flattened_mut unstably const e4bf0b2c8d7 Fix ptr::from_ref documentation example comment 24280da0df3 Rollup merge of #134884 - calciumbe:patch1, r=jieyouxu d22d9cd4b0e Rollup merge of #134870 - geofft:patch-1, r=jhpratt 211f0aac301 fix: typos 93da50afe8e Rollup merge of #134851 - lukas-code:alloc-ffi, r=tgross35 985891839da Fix sentence fragment in `pin` module docs cf7b103c90c docs: inline `alloc::ffi::c_str` types to `alloc::ffi` a552fd31531 Auto merge of #134547 - SUPERCILEX:unify-copy, r=thomcc 5eacc1ec770 Rollup merge of #134832 - tgross35:update-builtins, r=tgross35 b7c05b6b0b9 Tidy up bigint mul methods 61896c646bd Rollup merge of #134823 - chloefeal:fix, r=tgross35,dtolnay 3cb6477c99d Update library/alloc/tests/sort/tests.rs 3fa0bd334f0 Update `compiler-builtins` to 0.1.140 24cacb9c2a9 Implement `int_from_ascii` (#134821) f2b0874f58c Rollup merge of #133663 - scottmcm:carrying_mul_add, r=Amanieu 809cfe5ccfd Override `carrying_mul_add` in cg_llvm 944a0d085b0 Move `{widening, carrying}_mul` to an intrinsic with fallback MIR ff7dd3274c3 Fix typos 8b4329f0c13 Auto merge of #134822 - jieyouxu:rollup-5xuaq82, r=jieyouxu e21e9758e22 Rollup merge of #134819 - ChrisDenton:trunc, r=Mark-Simulacrum 17924ab0222 Rollup merge of #134622 - ChrisDenton:write-file-utf8, r=Mark-Simulacrum 1e681e05edf Rollup merge of #134606 - RalfJung:ptr-copy-docs, r=Mark-Simulacrum 0f9f222a983 Auto merge of #134786 - ChrisDenton:fix-rename-symlink, r=tgross35 3b7acb6b147 Fix renaming symlinks on Windows 050be5afa1d Fix mistake in windows file open dcf8d223e6d Rollup merge of #134791 - notriddle:notriddle/inline-ffi-error-types, r=tgross35 210d040c235 Rollup merge of #134789 - betrusted-io:bump-unwinding-to-0.25.0, r=Mark-Simulacrum 6a86ed7c6cc Rollup merge of #134782 - wtlin1228:docs/iter-rposition, r=Mark-Simulacrum 075f6056ac0 Rollup merge of #134728 - deltragon:barrier-doc, r=tgross35 5f603319705 Rollup merge of #134649 - SUPERCILEX:statx-remember, r=thomcc bcdde83c731 Rollup merge of #134644 - kpreid:duplicates, r=Mark-Simulacrum 5651a28e1c2 Rollup merge of #134379 - bjoernager:slice-as-array, r=dtolnay 7a16d998228 docs: inline `core::ffi::c_str` types to `core::ffi` 80a24fdefb6 docs: inline `std::ffi::c_str` types to `std::ffi` e6d43362543 unwinding: bump version to fix asm 9ea8b0f732e Impl FromIterator for tuples with arity 1-12 3fca93e4a73 Fix formatting a2ae1c6c047 docs: update code example for Iterator#rposition 8b49125d7f7 stabilize const_alloc_layout e02160c4a25 rename typed_swap → typed_swap_nonoverlapping 5b283da67c3 stabilize const_swap 47f50bb1091 Auto merge of #134729 - oliveredget:typo, r=jieyouxu e984c76c349 Auto merge of #134722 - ChrisDenton:trunc, r=Amanieu 774f8087433 Auto merge of #134333 - daxpedda:stdarch-bump, r=daxpedda 3e858a9d32a Fix compilation issues on other unixes cb1b72d99e6 Bump `stdarch` 035687a75ad chore: fix typos 5d20e21efb9 Use scoped threads in `std::sync::Barrier` examples e80cf22041e Windows: Use FILE_ALLOCATION_INFO for truncation ebfa0c1084f Rollup merge of #134689 - RalfJung:ptr-swap-test, r=oli-obk 5988ca95f08 Rollup merge of #134662 - ionicmc-rs:any-safety-docs, r=Amanieu 6bfbfb067d6 core: fix const ptr::swap_nonoverlapping when there are pointers at odd offsets in the type 1421c8733b7 Rollup merge of #134363 - estebank:derive-default, r=SparrowLii 9e289dbd5ea Rollup merge of #134672 - Zalathar:revert-coverage-attr, r=wesleywiser c3988d4fe03 Use `#[derive(Default)]` instead of manually implementing it c5476870276 Revert "Auto merge of #130766 - clarfonthey:stable-coverage-attribute, r=wesleywiser" eb56651bbde Auto merge of #134666 - matthiaskrgr:rollup-whe0chp, r=matthiaskrgr 7f59b6e8703 Auto merge of #131311 - rust-lang:cargo_update, r=clubby789 675a0dc735c Rollup merge of #134642 - kpreid:pointerlike-cell, r=compiler-errors 178224c20f4 Rollup merge of #134583 - Enselic:maybe-uninit-transmute, r=workingjubilee e2723bd9475 Rollup merge of #130289 - intgr-forks:Permissions-readonly-vs-unix-root, r=ChrisDenton 1acf2df67ea Adjust syntax 4bf1dc61521 Fixes safety docs for `dyn Any + Send {+ Sync}` 35382bc9501 Implement `PointerLike` for `isize`, `NonNull`, `Cell`, `UnsafeCell`, and `SyncUnsafeCell`. 4a1f6d7109e Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper 177a2ab4756 docs: Permissions.readonly() also ignores root user special permissions 8198b118e81 Improve prose around `as_slice` example of IterMut a3a6b99125c Specify only that duplicates are discarded, not the order. ac12bfb386b Auto merge of #131193 - EFanZh:asserts-vec-len, r=the8472 b1151c66fa3 Delete `Rvalue::Len` c5f6d826cd3 docs: `transmute<&mut T, &mut MaybeUninit>` is unsound when exposed to safe code d22659c0e48 Impl String::into_chars ad3549bd588 Stabilize `hash_extract_if` 45467334d33 Rollup merge of #134602 - kpreid:pointerlike-doc, r=tgross35 c7e8fb44cdf Fix forgetting to save statx availability on success 07172200a6c Auto merge of #134640 - matthiaskrgr:rollup-xlstm3o, r=matthiaskrgr 28c860b4c8c Document collection `From` and `FromIterator` impls that drop duplicate keys. aed9dc03570 Rollup merge of #134630 - fifty-six:master, r=workingjubilee 5e7cf4f81e0 Auto merge of #130733 - okaneco:is_ascii, r=scottmcm 2c57eaf3e7d cargo update f5201b89fc9 Eliminate redundant statx syscalls 3a79bbe6b81 Rollup merge of #134325 - theemathas:is_null-docs, r=RalfJung feddec9b49f Rollup merge of #131072 - Fulgen301:windows-rename-posix-semantics, r=ChrisDenton 28ac7bfba97 Use `&raw` for `ptr` primitive docs e63eeba1b98 Unify fs::copy and io::copy 7b6a9ccc464 Windows: Use WriteFile to write to a UTF-8 console 2b4c33516bd Avoid short writes in LineWriter 2f63fd886e5 Document CTFE behavior of methods that call is_null 0c3132fcb3c Correctly document is_null CTFE behavior. f719b4e3226 ptr::copy: fix docs for the overlapping case b176a9910ca Rollup merge of #134593 - kornelski:less-unwrap, r=jhpratt d4885751137 Rollup merge of #134579 - hkBst:patch-6, r=jhpratt 9420b21b202 Rollup merge of #134577 - hkBst:patch-5, r=jhpratt b1507559aa1 Rollup merge of #134576 - hkBst:patch-4, r=jhpratt 99b8c86155a Document `PointerLike` implementation restrictions. e0c9b99a164 Less unwrap() in documentation 3392d71fb7b Rollup merge of #123604 - michaelvanstraten:proc_thread_attribute_list, r=ChrisDenton 8fdd27af678 Rollup merge of #134573 - lukas-code:unimpl-dyn-pointerlike, r=compiler-errors 7d1b26a50fd Rollup merge of #134570 - hkBst:patch-3, r=joboet 8476fd227b2 Rollup merge of #134560 - RalfJung:miri-thread-spawn, r=jhpratt dda9903d80a Improve prose around into_slice example of IterMut a32744fcf9f Improve prose around `as_slice` example of Iter bab182f9f90 Improve prose around basic examples of Iter and IterMut 19920a98dac remove reference to dangling from slice::Iter cdbb56c972e fix `PointerLike` docs 6be16279395 unimplement `PointerLike` for trait objects 69e3125711c split up `#[rustc_deny_explicit_impl]` attribute 1f9e0af2898 mri: add track_caller to thread spawning methods for better backtraces 0c5380c426c Rollup merge of #134518 - hltj:typo-fix, r=tgross35 02266003fdf Rollup merge of #132830 - wr7:substr_range_documentation, r=tgross35 7060dcee63c Rollup merge of #126118 - jan-ferdinand:docs_for_vec_set_len, r=the8472 780625e0931 fix typos in the example code in the doc comments of `Ipv4Addr::from_bits()`, `Ipv6Addr::from_bits()` & `Ipv6Addr::to_bits()` 798943c031f Add missing safety descriptions to Arc's 'from_raw','increment_strong_count','decrement_strong_count' d764565c27b build: Update libc version 84dffc2070b Rollup merge of #134490 - hong9lol:typo, r=jhpratt e06b3100397 Rollup merge of #132056 - weiznich:diagnostic_do_not_recommend_final_tests, r=compiler-errors e293151a2bf fix typo in ptr/mod.rs ce47855f6f4 Auto merge of #134443 - joshtriplett:use-field-init-shorthand, r=lqd,tgross35,nnethercote d8624465122 Rollup merge of #134452 - jalil-salame:fix-lazy-cell-docs, r=tgross35 ed1ae716633 Add 'into_array' conversion destructors for 'Box', 'Rc', and 'Arc'; 66f83500c2e Implement Condvar::wait_timeout for targets without threads 721226f31dd Auto merge of #134425 - clubby789:cargo-update, r=jieyouxu 1a49e2a2864 fix(LazyCell): documentation of get[_mut] was wrong cc5a5966ba3 Stabilize `#[diagnostic::do_not_recommend]` c08be9b4a8f Use field init shorthand where possible c3f255c1758 Rollup merge of #134426 - hkBst:patch-3, r=lqd 0452ec570a4 Rollup merge of #133265 - the8472:extract-if-ranges, r=cuviper 3dd9c4fc9df compiler & tools dependencies: Updating allocator-api2 v0.2.20 -> v0.2.21 Updating annotate-snippets v0.11.4 -> v0.11.5 Updating anyhow v1.0.93 -> v1.0.94 Updating bstr v1.11.0 -> v1.11.1 Updating chrono v0.4.38 -> v0.4.39 Updating clap v4.5.21 -> v4.5.23 Updating clap_builder v4.5.21 -> v4.5.23 Updating clap_complete v4.5.38 -> v4.5.39 Updating clap_lex v0.7.3 -> v0.7.4 Updating colored v2.1.0 -> v2.2.0 Updating console v0.15.8 -> v0.15.10 Updating crossbeam-channel v0.5.13 -> v0.5.14 Updating crossbeam-deque v0.8.5 -> v0.8.6 Updating crossbeam-utils v0.8.20 -> v0.8.21 Updating encode_unicode v0.3.6 -> v1.0.0 Updating fastrand v2.2.0 -> v2.3.0 Updating home v0.5.9 -> v0.5.11 Updating js-sys v0.3.74 -> v0.3.76 Updating libc v0.2.167 -> v0.2.168 Updating miniz_oxide v0.8.0 -> v0.8.1 Updating pest v2.7.14 -> v2.7.15 Updating pest_derive v2.7.14 -> v2.7.15 Updating pest_generator v2.7.14 -> v2.7.15 Updating pest_meta v2.7.14 -> v2.7.15 Updating redox_syscall v0.5.7 -> v0.5.8 Updating rustc-stable-hash v0.1.0 -> v0.1.1 Updating rustix v0.38.41 -> v0.38.42 Updating self_cell v1.0.4 -> v1.1.0 Updating semver v1.0.23 -> v1.0.24 Updating serde v1.0.215 -> v1.0.216 Updating serde_derive v1.0.215 -> v1.0.216 Adding thiserror v2.0.7 Adding thiserror-impl v2.0.7 Updating time v0.3.36 -> v0.3.37 Updating time-macros v0.2.18 -> v0.2.19 Updating tokio v1.41.1 -> v1.42.0 Updating wasm-bindgen v0.2.97 -> v0.2.99 Updating wasm-bindgen-backend v0.2.97 -> v0.2.99 Updating wasm-bindgen-macro v0.2.97 -> v0.2.99 Updating wasm-bindgen-macro-support v0.2.97 -> v0.2.99 Updating wasm-bindgen-shared v0.2.97 -> v0.2.99 Updating wasm-encoder v0.221.0 -> v0.221.2 Updating wasmparser v0.221.0 -> v0.221.2 Updating wast v221.0.0 -> v221.0.2 Updating wat v1.221.0 -> v1.221.2 d73b1b021da Auto merge of #130766 - clarfonthey:stable-coverage-attribute, r=wesleywiser b9e462a1953 Fix typo in uint_macros.rs 736211c3da8 Rollup merge of #134202 - nnethercote:rm-existing_doc_keyword, r=GuillaumeGomez 7efcdd17843 Remove `rustc::existing_doc_keyword` lint. 656071aab38 Move `doc(keyword = "while")`. 90348fcf577 Stabilize #[coverage] attribute ec0e91b8979 remove obsolete comment and pub(super) visibility 5968f77838d remove bounds from vec and linkedlist ExtractIf 29d14e102fc Add a range argument to vec.extract_if 6cbb970e579 Rollup merge of #134277 - notriddle:notriddle/inline-into, r=GuillaumeGomez d662587509d Auto merge of #134332 - Zalathar:rollup-oe23hkw, r=Zalathar 4a5a0d689a1 Rollup merge of #134310 - tkr-sh:master, r=Noratrieb 92855d42ff4 Rollup merge of #133406 - EFanZh:lock-value-accessors, r=Noratrieb 0b9d747141d Rollup merge of #130361 - devnexen:sock_cloexec_solaris, r=cuviper 6e144b21413 Auto merge of #133223 - zachs18:uniquerc-impls, r=Noratrieb 79c9aee97ec Asserts the maximum value that can be returned from `Vec::len` c9ef1c2bc5b Auto merge of #134258 - bjorn3:no_public_specialization, r=petrochenkov e87c314124d Rollup merge of #134022 - shahn:doc_clarify_extend_for_tuple_version, r=tgross35 407baa130fd Rollup merge of #133986 - olishmollie:tracking-issue-127154-documentation, r=tgross35 a15b8510505 Correct spelling of CURRENT_RUSTC_VERSION 830c41a3b9a Replace i32 by char in `split_at` & `_unchecked` b0ce62f98d5 Add clarity to the "greater" of `VecDeque::insert` 7e9303973a0 Replace i32 by char to add clarity d2447f75ebe Auto merge of #134296 - matthiaskrgr:rollup-o0sxozj, r=matthiaskrgr 69d3f60506c Add documentation for anonymous pipe module eef21b1d77b Rollup merge of #133942 - BD103:black-box-docs, r=saethlin 50c69ad6111 Rollup merge of #134255 - bjoernager:master, r=Noratrieb 90f93527afa Rollup merge of #134254 - hermit-os:hermit-c_char, r=workingjubilee 77308c25af0 Rollup merge of #134252 - hermit-os:hermit-is_absolute, r=tgross35 5bb7b3b777d rustdoc-search: let From and Into be unboxed fc277ec239c Rollup merge of #134229 - purplesyringa:provenance-docs, r=saethlin 8f229d1c45e Rollup merge of #134140 - compiler-errors:unsafe-binders-ast, r=oli-obk 27f37568893 Remove support for specializing ToString outside the standard library 06ffb2a5c21 Auto merge of #134047 - saethlin:inline-fmt-rt, r=m-ou-se 03089923ff1 Update includes in '/library/core/src/error.rs'; 7b382d49db0 Fix building `std` for Hermit after `c_char` change 17aedf195cb Fix `Path::is_absolute` on Hermit 78a0ffe0586 Reword prelude for AsyncFn stabilization fa1bb78c513 Stabilize async closures c55d1790360 Fix typos in docs on provenance 0a51c5c2509 feat: clarify how to use `black_box()` 5c06504bad2 Add unwrap_unsafe_binder and wrap_unsafe_binder macro operators 04d4cba289b Rollup merge of #134179 - zachs18:align_offset_mut_ptr_doc, r=workingjubilee 9f9501649f6 Rollup merge of #134178 - ehuss:stabilize-2024-prelude, r=amanieu,traviscross,tgross35 80e8c7d9d4f Rollup merge of #134155 - sthibaul:unsafe_op_in_unsafe_fn, r=tgross35 5233a52ed46 Rollup merge of #133859 - bjorn3:move_tests_to_alloctests, r=tgross35 d6354150519 Rollup merge of #122003 - mati865:gnullvm-build-libunwind, r=petrochenkov 6e362c34dcb Stabilize the Rust 2024 prelude da008bb9f17 Auto merge of #134177 - matthiaskrgr:rollup-hgp8q60, r=matthiaskrgr dc27b6e6675 Rollup merge of #133598 - ChayimFriedman2:get-many-mut-detailed-err, r=scottmcm 6f047747190 Rollup merge of #132975 - arichardson:ffi-c-char, r=tgross35 4ab0e8ed9b5 Remove consteval note from <*mut T>::align_offset docs. c58f76c5e3d Rollup merge of #134079 - tbu-:pr_doc_x8_to_from_xe_bytes, r=jhpratt 11af9c6b919 Add a note saying that `{u8,i8}::from_{be,le,ne}_bytes` is meaningless d724d6560bf Forbid unsafe_op_in_unsafe_fn in hurd-specific os and sys files 08a3185c22b Rollup merge of #134116 - RalfJung:const_nonnull_new, r=jhpratt ac7aa894b2c Rollup merge of #134100 - eholk:noop-rustc-const-stable, r=dtolnay 97ff918e4ef Add references to the specific ABI documents c08f8717bfc Remove l4re from the unsigned char operating system list cfdb7c248bd De-duplicate and improve definition of core::ffi::c_char cae4102a69e stabilize const_nonnull_new dd8b372aab3 Rollup merge of #133472 - rust-wasi-web:master, r=joboet f21eb1bbf20 Rollup merge of #133456 - clubby789:cargo-update, r=ChrisDenton c403963c8dc Rollup merge of #133184 - osiewicz:wasm-fix-infinite-loop-in-remove-dir-all, r=Noratrieb d347b65f7bc Remove rustc_const_stable attribute on const NOOP 1f8d8e2ac53 Rollup merge of #134032 - snprajwal:fix-docs, r=joboet 66f11d51ecc core: use public method instead of instrinsic 596fd3559d3 core: improve comments b591b9bb582 Auto merge of #134052 - matthiaskrgr:rollup-puxwqrk, r=matthiaskrgr 948eb05f3d6 Rollup merge of #134050 - RalfJung:miri-sync, r=RalfJung b343c5154f8 Rollup merge of #133880 - ChrisDenton:homedir, r=Mark-Simulacrum eba56285c42 Rollup merge of #133789 - rossmacarthur:then-with-doc-alias, r=Mark-Simulacrum f2f918448ae Switch inline(always) in core/src/fmt/rt.rs to plain inline c95571c6f3e Downgrade cc 7732aee412f Rollup merge of #134013 - BLANKatGITHUB:intrinsic, r=saethlin 37e3ad70e3a Adds new intrinsic declaration 321e15467b6 Rollup merge of #133987 - Will-Low:DefineTlsAcronym, r=workingjubilee fa629100eb6 docs: better examples for `std::ops::ControlFlow` 9351abd146c Merge from rustc 227cb73136a Const-stabilize `str::is_char_boundary` and `str::split_at(_mut)(_checked)`. 5e9d429daf8 Auto merge of #133978 - matthiaskrgr:rollup-6gh1iho, r=matthiaskrgr 559d097737d Merge from rustc e64cc8f0b01 Define acronym for thread local storage 583e5c38fb2 Auto merge of #118159 - EliasHolzmann:formatting_options, r=m-ou-se fb2f7f59542 Rollup merge of #132187 - shahn:extend_more_tuples, r=dtolnay eea8026b615 Rollup merge of #130254 - GrigorenkoPV:QuotaExceeded, r=dtolnay 6b532c5a3ec Rollup merge of #130209 - GrigorenkoPV:CrossesDevices, r=dtolnay 65dfcbf3228 Auto merge of #133089 - eholk:stabilize-noop-waker, r=dtolnay e7f87ced7f7 core: implement `bool::select_unpredictable` 76a0c103f85 Rollup merge of #133790 - HypheX:improve-vec-docs, r=harudagondi,workingjubilee c5b36235821 Merge from rustc 9a35941d30c Rollup merge of #133821 - Kobzol:replace-black-with-ruff, r=onur-ozkan 8e70d440609 Stabilize noop_waker 079deca158e Access members of `FormattingOptions` directly instead of via getters/setters 71ca7b7021e Removed constness for methods receiving a `&mut` parameter 44211bdeaf7 Added better reason for exposing `flags` and `get_flags` as unstable 19a746ad96d Formatted 7b0c4b28419 Refactored FormattingOptions to use a bitmask for storing flags 1f799846b6e Revert "Turned public+unstable+hidden functions into private functions" 829b61a1246 Turned public+unstable+hidden functions into private functions e9281c8e9a3 Made all fns const f864bca7c6a impl Default for fmt::FormattingOptions aa9bd365b8e Fixed copy+paste error in comment 08f0702f0e5 fmt::FormattingOptions: Renamed `alignment` to `align` 2823ff934ab Formatter::with_options: Use different lifetimes b64be9fba0e Fixed another broken test 5e26a3b8414 Added struct `fmt::FormattingOptions` 7b1865455ac Formatter: Access members via getter methods wherever possible b880b8647ca Improve documentation 3bd82e97bef Add libc funcitons only for wasm32-wasip1-threads. 446d6a769c5 Fix compilation for wasm32-wasip1 (without threads). c5fadd2a455 Rollup merge of #133882 - jyn514:doc-backtraces, r=saethlin 4b68145938a Rollup merge of #133844 - RalfJung:simd_relaxed_fma-nondet, r=workingjubilee 1ed910d355b Rollup merge of #127565 - esp-rs:xtensa-vaargs, r=workingjubilee b3a46486625 Rollup merge of #133863 - oli-obk:push-pystoxvtvssx, r=lqd 0e9a4d8417b Rollup merge of #118833 - Urgau:lint_function_pointer_comparisons, r=cjgillot 8ed8886175f Improve comments for the default backtrace printer 23d6fda4069 Expand home_dir docs 5d1aa1675a3 Reformat Python code with `ruff` 14f2e23f839 Rename `core_pattern_type` and `core_pattern_types` lib feature gates to `pattern_type_macro` aa4f52b5035 Move some alloc tests to the alloctests crate 9c94d5d7655 clarify simd_relaxed_fma non-determinism b1f3a26d27a Rollup merge of #133651 - scottmcm:nonnull-nonzero-no-field-projection, r=oli-obk 72036111be5 Auto merge of #133818 - matthiaskrgr:rollup-iav1wq7, r=matthiaskrgr 69ed392762d Rollup merge of #133726 - joshtriplett:breakpoint, r=oli-obk ae20aa74638 Rollup merge of #132937 - xmh0511:master, r=m-ou-se a748abbc719 Update `NonZero` and `NonNull` to not field-project (per MCP807) fdc60cf05a4 Rollup merge of #133796 - TDecking:borrowing-sub, r=tgross35 7e6e6e2b1a3 Rollup merge of #133762 - RalfJung:const-size-of-val, r=workingjubilee 55a7efe9106 Rollup merge of #133696 - RalfJung:const-hashmap, r=cuviper d2614640319 Use UNIX thread_local implementation for WASI. ed4cdaf9441 Update the definition of `borrowing_sub` 5d9e73921d2 Teach rust core about Xtensa VaListImpl and add a custom lowering of vaarg for xtensa. a43b76ee94b Add `core::arch::breakpoint` and test bda8e4b1f12 Add doc alias 'then_with' for `then` method on `bool` d27d3181909 ./x miri: fix sysroot build 19de684bc57 Rollup merge of #133395 - calebzulawski:simd_relaxed_fma, r=workingjubilee 00e15d1d5a9 Rollup merge of #133763 - Urgau:f16-midpoint-const-feat, r=Amanieu 3a955a29554 Rollup merge of #133701 - kornelski:c-str, r=workingjubilee a45b5e9fbd5 Rollup merge of #131713 - tgross35:stabilize-const_maybe_uninit_write, r=RalfJung,dtolnay 9692301b67d stabilize const_{size,align}_of_val d7a7815759e Stabilize `const_maybe_uninit_write` 67506c0fe20 Use c"lit" for CStrings without unwrap 883c1e03b7b Allow fn pointers comparisons lint in library a55ae54b880 Fix `f16::midpoint` const feature gate 6bfd483adaa Rollup merge of #133743 - bjoernager:slice-as-array, r=joboet 61f1e02390d stabilize const_collections_with_hasher and build_hasher_default_const_new 4a29e83103d Auto merge of #133728 - jhpratt:rollup-k1i60pg, r=jhpratt ee0d5ab0752 Fix docs for '<[T]>::as_array'; d6f6f17a4ad Rollup merge of #133678 - Urgau:stabilize-ptr_fn_addr_eq, r=jhpratt 75fc94fe555 Rollup merge of #133672 - RalfJung:const-stability-cleanup, r=jhpratt 1c3d879674e Rollup merge of #133711 - cod10129:master, r=Noratrieb 812ac8de503 Rollup merge of #131784 - Urgau:stabilize-midpoint, r=dtolnay 8a64116590c Rollup merge of #131416 - okaneco:const_copy, r=RalfJung e790064fe66 Mark `slice::copy_from_slice` unstably const 23a071ba9e6 add isatty alias for is_terminal 3f337703717 Rollup merge of #133674 - scottmcm:chain-carrying-add, r=Amanieu f77fe3fcc4e Rollup merge of #133669 - RalfJung:const_swap_splitup, r=dtolnay 9924f497242 Run `cargo update` and update licenses 479c469cf3b Stabilize unsigned `num_midpoint` feature 795d603b70c Rollup merge of #133686 - samueltardieu:push-xkxwxzxqokuu, r=compiler-errors e32ed338ac6 Rollup merge of #133622 - mkroening:exception-blog, r=cuviper 627d4b2f9cb Rollup merge of #133602 - SanchithHegde:fix-pathbuf-example-codeblocks, r=cuviper eb3536842cd Rollup merge of #133515 - SteveLauC:fix/hurd, r=ChrisDenton 75479cf0c93 Rollup merge of #128184 - joboet:refactor_pthread_sync, r=workingjubilee 75360470dab Auto merge of #133684 - RalfJung:rollup-j2tmrg7, r=RalfJung b08a2e48192 Switch rtems target to panic unwind d85224a1b0a Add diagnostic item for `std::ops::ControlFlow` 2b3f1e38af8 Rollup merge of #133670 - RalfJung:hashbrown, r=Amanieu a681bf22338 Auto merge of #133659 - jieyouxu:rollup-576gh4p, r=jieyouxu fdd8daeaa07 std: clarify comments about initialization a866ba30609 Stabilize `ptr::fn_addr_eq` 20ad9f3a771 Add value accessor methods to `Mutex` and `RwLock` d45c3ac10f7 fix: hurd build, stat64.st_fsid was renamed to st_dev 20335c6f01c rustc_allow_const_fn_unstable is not used in proc_macro ab1acf8489c get rid of a bunch of unnecessary rustc_const_unstable e8d5e83ff42 Fix chaining `carrying_add`s 5a138bd16df add test for bytewise ptr::swap of a pointer a28b4c94924 remove a whole bunch of unnecessary const feature gates 632384019c0 Abstract `ProcThreadAttributeList` into its own struct 7a561f25eb3 move swap_nonoverlapping constness to separate feature gate 8e56f2b3beb bump hashbrown version c35c426aa6b move slice::swap_unchecked constness to slice_swap_unchecked feature gate 6795e57d557 Rollup merge of #133548 - cuviper:btreeset-entry-api, r=Mark-Simulacrum 4b6b44ec31b Rollup merge of #133496 - rust-wasi-web:wasi-available-parallelism, r=Amanieu 55088029695 Rollup merge of #133106 - BLANKatGITHUB:intrinsic, r=RalfJung e19d9e1f67c Rollup merge of #132515 - kornelski:home_fix, r=jhpratt 558146cd092 Rollup merge of #133625 - RalfJung:custom-mir-debug-info, r=compiler-errors c7244e4548d Rollup merge of #116161 - Soveu:varargs2, r=cjgillot 46a2f6dd74c Auto merge of #133533 - BoxyUwU:bump-boostrap, r=jieyouxu,Mark-Simulacrum 444dbb1fd6b refine mir debuginfo docs 4eac633b0dc Doc comment custom MIR debuginfo. c8a70037002 update link to "C++ Exceptions under the hood" blog d4d187e948b Rollup merge of #133530 - timvisee:master, r=jhpratt 91fbd9f5864 Rollup merge of #133466 - aksh1618:patch-1, r=thomcc 9063415181e fix: fix codeblocks in `PathBuf` example 035129281e6 Auto merge of #123244 - Mark-Simulacrum:share-inline-never-generics, r=saethlin d21c03c9da5 Change `GetManyMutError` to match T-libs-api decision 13648408c0b Share inline(never) generics across crates 781da31e05b Also use zero when referencing to capacity or length c82f6eec24d Use consistent wording in docs, use zero instead of 0 bcc2e91240a Auto merge of #133561 - GuillaumeGomez:rollup-g4upmv4, r=GuillaumeGomez 04463a7f7f4 Rollup merge of #133543 - mustartt:aix-lgammaf_r-shim, r=cuviper f7a615efa01 Rollup merge of #133512 - bjoernager:slice-as-array, r=Amanieu 8663d4492ee Rollup merge of #129409 - grinapo:patch-1, r=Amanieu 4fb4a00e34d Rollup merge of #133498 - GuillaumeGomez:missing-examples, r=joboet e203dac0af0 Stabilize `extended_varargs_abi_support` 2b6de08a835 Fill in a `BTreeSet::entry` example 173ee652528 Add a tracking issue for `btree_set_entry` f57718afaa9 Add `BTreeSet` entry APIs to match `HashSet` b52d6ea6391 fmt b4b18cab0e9 update cfgs 69ebec2d136 Implement code review 9d15a385fcf replace placeholder version 7ec1cdfe7a3 Auto merge of #133369 - Zalathar:profiler-builtins-no-core, r=jieyouxu a55e6bb8d3a Rollup merge of #133449 - joboet:io_const_error, r=tgross35 e3456c67844 Rollup merge of #133402 - compiler-errors:drop-and-destruct, r=lcnr 7d1132f4450 Auto merge of #133505 - compiler-errors:rollup-xjp8hdi, r=compiler-errors 095b004d343 chore: Improve doc comments 53c5cc9a882 Add '<[T]>::as_array', '<[T]>::as_mut_array', '<*const [T]>::as_array', and '<*mut [T]>::as_mut_array' conversion methods; 29f1a9fc0e1 std: update internal uses of `io::const_error!` 9d96a4d024b Rollup merge of #133435 - RalfJung:test_downgrade_observe, r=tgross35 4be8acba9ed Rollup merge of #133282 - tgross35:maybe-uninit-debug, r=Amanieu 90447aac1c9 Rollup merge of #133136 - ChayimFriedman2:get-many-mut, r=Amanieu 1b8f2e255be Rollup merge of #133042 - cuviper:btreemap-insert_entry, r=Amanieu 423e4c5ac67 Rollup merge of #133464 - RalfJung:whitespace-panic, r=joboet e1c57aaa291 Rollup merge of #133419 - CromFr:add-path-strip_prefix-test-example, r=Amanieu fe5ddb839d6 Add missing code examples on `LocalKey` 77a8b1dd704 thread::available_parallelism for wasm32-wasip1-threads c1576656965 Refactor ReadDir into a state machine 73e18ef0f70 Run TLS destructors for wasm32-wasip1-threads ae14c35ae28 Fix typos in pin.rs a4ef660cb44 std::thread: avoid leading whitespace in some panic messages f1c8fff3eca Constify Drop and Destruct 2b53683f359 std: expose `const_io_error!` as `const_error!` 0ebbd604aca Auto merge of #133247 - GuillaumeGomez:reduce-integer-display-impl, r=workingjubilee 4cb91d2c8ea Support ranges in `<[T]>::get_many_mut()` 654434a13c1 miri: disable test_downgrade_observe test on macOS 94a4251e601 Rollup merge of #132982 - suaviloquence:2-doc-changed-alloc-methods, r=Mark-Simulacrum 141df9d9f11 Rollup merge of #132533 - SUPERCILEX:patch-4, r=Mark-Simulacrum 6b85d41e68e fix `Allocator` method names in `alloc` free function docs 6eb0c106532 Rollup merge of #133298 - n0toose:remove-dir-all-but-not-paths, r=Noratrieb d9da2d525b6 Rollup merge of #133260 - compiler-errors:deref, r=fee1-dead ed139b53ab6 Rollup merge of #132730 - joboet:after_main_sync, r=Noratrieb 4c0534bf7d4 Added a doc test for std::path::strip_prefix 09b85d8fd9d Rollup merge of #133389 - eduardosm:stabilize-const_float_methods, r=RalfJung 53902c2caee Rollup merge of #133301 - GuillaumeGomez:add-example-wrapping-neg, r=workingjubilee 66ab6b5066a changes old intrinsic declaration to new declaration 516ce5869e0 Auto merge of #132611 - compiler-errors:async-prelude, r=ibraheemdev eb02a21bc1f Auto merge of #132597 - lukas-code:btree-plug-leak, r=jhpratt 7b72794dcc0 Make profiler_builtins `#![no_core]` instead of just `#![no_std]` 9f90bb0f6f2 Remove unnecessary `#![allow(unused_features)]` c339b9f7bf6 Sort and separate lint/feature attributes in `profiler_builtins` 839d12cd4ab Constify Deref and DerefMut 802356c5f74 Match simd_relaxed_fma documentation to fmuladd intrinsic bee4ecd9429 Auto merge of #133379 - jieyouxu:rollup-00jxo71, r=jieyouxu f72470ca5ea Add simd_relaxed_fma intrinsic 70729ec3239 Stabilize `const_float_methods` 76d265e503b Auto merge of #133377 - jieyouxu:rollup-n536hzq, r=jieyouxu c6e5bf3fabb Improve code by using `unsigned_abs` f70996f1d61 Rollup merge of #133237 - fee1-dead-contrib:constadd, r=compiler-errors 7aa679938f3 Rollup merge of #133332 - bjoernager:const-array-as-mut-slice, r=jhpratt 30666a45e6f Rollup merge of #131505 - madsmtm:darwin_user_temp_dir, r=dtolnay 225b618ddf4 Auto merge of #132994 - clubby789:cc-bisect, r=Kobzol 0b65b01a424 Auto merge of #133360 - compiler-errors:rollup-a2o38tq, r=compiler-errors 881c5ef131c Rollup merge of #133264 - lolbinarycat:os-string-truncate, r=joboet c5f45296fbb Auto merge of #132329 - compiler-errors:fn-and-destruct, r=lcnr 08ac834d1b8 Shorten the `MaybeUninit` `Debug` implementation 0010fe8458b aix: create shim for lgammaf_r bff4879cf09 Add code example for `wrapping_neg` method for signed integers a97a88475f6 Deduplicate checking drop terminator b92dda90422 Gate const drop behind const_destruct feature, and fix const_precise_live_drops post-drop-elaboration check 129c3e53a09 Auto merge of #133339 - jieyouxu:rollup-gav0nvr, r=jieyouxu 6474e8ec0a1 Rollup merge of #133337 - ColinFinck:thread-scoped-fix-typo, r=joboet d2ab35c9472 Rollup merge of #133330 - RalfJung:close, r=the8472 2f36a49c194 Rollup merge of #133313 - thesummer:fix-arc4random, r=cuviper ffe6b3179cd Rollup merge of #133288 - bjoernager:const-array-each-ref, r=jhpratt 4ddec3f7ae5 Rollup merge of #133238 - heiher:loong-stdarch-rexport, r=Amanieu edcaf2bfb68 Auto merge of #130867 - michirakara:steps_between, r=dtolnay 4fa0b696f8c Fix typo in `std::thread::Scope::spawn` documentation. 4540393046c Mark '<[T; N]>::as_mut_slice' as 'const'; ec55169f806 library: update comment around close() 7ee0a859f11 Don't try to use confstr in Miri 6404c969509 Auto merge of #129238 - umgefahren:stabilize-ipv6-unique-local, r=dtolnay e34a80249b1 distinguish overflow and unimplemented in Step::steps_between 9b076218086 Use arc4random of libc for RTEMS target 4760f7c6d8a Mention that std::fs::remove_dir_all fails on files 8d9d792081f Mark and implement 'each_ref' and 'each_mut' in '[T; N]' as const; e32598f5b57 constify `Add` 6c4dc0bf75a Rollup merge of #131736 - hoodmane:emscripten-wasm-bigint, r=workingjubilee ed658469f4b implement OsString::truncate 49ffd7711ca Rollup merge of #133226 - compiler-errors:opt-in-pointer-like, r=lcnr d1150b80cc3 Rollup merge of #130800 - bjoernager:const-mut-cursor, r=joshtriplett 8259d64c16c Rollup merge of #129838 - Ayush1325:uefi-process-args, r=joboet d4c6e8b623a Make PointerLike opt-in as a trait ee1d522c3ac Reduce integer `Display` implementation size 5518b631c4b Stabilize const_pin_2 99c5401b663 re-export `is_loongarch_feature_detected` 45b75690bfb Rollup merge of #132732 - gavincrawford:as_ptr_attribute, r=Urgau e1d07359441 UniqueRc: platform-specific AsFd/Handle/etc impls to mirror Rc 0edb7261e0f UniqueRc: PinCoerceUnsized and DerefPure cc920055663 UniqueRc: comparisons and Hash c012f090e5a Rollup merge of #133183 - n0toose:improve-remove-dir-docs, r=joboet bbfbad1656f Rollup merge of #125405 - m-ou-se:thread-add-spawn-hook, r=WaffleLapkin f6d49a95d63 Rollup merge of #123947 - zopsicle:vec_deque-Iter-as_slices, r=Amanieu 39c49a04e07 UniqueRc: Add more trait impls. 6cc4451b732 Update doc comments for spawn hook. a0f7d9ee77a Address review comments. 2d181ada07f Fix tracking issue. 249a39a0cac Add tracking issue. 20b5a6fc539 Use Send + Sync for spawn hooks. 98317baa88e Add thread Builder::no_hooks(). c5fb87d4f63 Update thread spawn hooks. e41e6fcf479 Use add_spawn_hook for libtest's output capturing. 4db7a02e736 Add std::thread::add_spawn_hook. 38e5188d7a3 Correct comments concerning updated dangling pointer lint 1a64424cdbc Auto merge of #133205 - matthiaskrgr:rollup-xhhhp5u, r=matthiaskrgr c7d24c82193 Rollup merge of #133200 - RalfJung:miri-rwlock-test, r=tgross35 5b6fd0c324c ignore an occasionally-failing test in Miri a01aa1b5cf0 Rollup merge of #133182 - RalfJung:const-panic-inline, r=tgross35 455a0f5a44a Rollup merge of #132758 - nnethercote:improve-get_key_value-docs, r=cuviper 62141a9774f Mention std::fs::remove_dir_all in std::fs::remove_dir 6da3b3ce795 wasi/fs: Improve stopping condition for ::next a99228d348f Bump `stdarch` to the latest master ed5b026e017 const_panic: inline in bootstrap builds to avoid f16/f128 crashes de0b1aba8db std: allow after-main use of synchronization primitives df764f75160 Auto merge of #133160 - jhpratt:rollup-wzj9q15, r=jhpratt 16cce54e64d Rollup merge of #133145 - kornelski:static-mutex, r=traviscross f3a4f1bd760 Auto merge of #128219 - connortsui20:rwlock-downgrade, r=tgross35 33ae0fd84fb rename rustc_const_stable_intrinsic -> rustc_intrinsic_const_stable_indirect 794109a0c23 Improve `{BTreeMap,HashMap}::get_key_value` docs. 8d07e3bfaa1 Document alternatives to `static mut` 434abd790f6 Auto merge of #120370 - x17jiri:likely_unlikely_fix, r=saethlin bf2b57d090e Likely unlikely fix 4f4dc7b6c32 Rollup merge of #133126 - ohno418:fix-String-doc, r=jhpratt c671049d583 Rollup merge of #133116 - RalfJung:const-null-ptr, r=dtolnay 7c4267e947e alloc: fix `String`'s doc 3ffd42de62b clean up const stability around UB checks 7915de7dde6 stabilize const_ptr_is_null 450fb6a212a Rollup merge of #132449 - RalfJung:is_val_statically_known, r=compiler-errors 1704c189beb Rollup merge of #131717 - tgross35:stabilize-const_atomic_from_ptr, r=RalfJung 1797cbd6f90 reduce threads in downgrade test 91c1ee084db fix `DOWNGRADED` bit unpreserved 6d48a443aec fix memory ordering bug + bad test e28e3bc7931 add safety comments for queue implementation 2bdea4c86c9 add `downgrade` to `queue` implementation bbb8dac1b8c modify queue implementation documentation 642703d065a add `downgrade` to `futex` implementation 90e9e015f82 add simple `downgrade` implementations 086ad6d2b2c add `downgrade` method onto `RwLockWriteGuard` cd047c1b37f add `RwLock` `downgrade` tests 3470c81a169 Rollup merge of #133050 - tgross35:inline-f16-f128, r=saethlin cf3259b0e8d Rollup merge of #133048 - cyrgani:ptr-doc-update, r=Amanieu 19a03c46226 Rollup merge of #133019 - sorairolake:add-missing-period-and-colon, r=tgross35 a4f486ae44f Rollup merge of #132984 - sunshowers:pipe2, r=tgross35 bf078975d4e Rollup merge of #132977 - cberner:fix_solaris, r=tgross35 fc8cdb67a10 Rollup merge of #132790 - aDotInTheVoid:ioslice-asslice-rides-again, r=cuviper 4dd6b59105e Pass `f16` and `f128` by value in `const_assert!` 28460d3aceb Remove one stray space. a97d1e8073a use `&raw` in `{read, write}_unaligned` documentation ee7207a0d90 btree: add `{Entry,VacantEntry}::insert_entry` 425456c7115 Auto merge of #132709 - programmerjake:optimize-charto_digit, r=joshtriplett 416546b05ec Rollup merge of #133027 - no1wudi:master, r=jhpratt 351a4687a5e Auto merge of #133026 - workingjubilee:rollup-q8ig6ah, r=workingjubilee 14fc77f322a Fix a copy-paste issue in the NuttX raw type definition b836ab705ff Rollup merge of #133008 - onur-ozkan:update-outdated-comment, r=jieyouxu 025f9109b33 Rollup merge of #133004 - cuviper:unrecover-btree, r=ibraheemdev 38276efae30 Rollup merge of #133003 - zachs18:clonetouninit-dyn-compat-u8, r=dtolnay ea2d685129b Rollup merge of #132907 - BLANKatGITHUB:intrinsic, r=saethlin faa1da1bb95 Rollup merge of #131304 - RalfJung:float-core, r=tgross35 736c7d89e1d Auto merge of #122770 - iximeow:ixi/int-formatting-optimization, r=workingjubilee 25dce5d0167 docs: Fix missing colon in methods for primitive types 02a1f6cbfe2 docs: Fix missing period in methods for integer types c054c2bbe3a Auto merge of #133006 - matthiaskrgr:rollup-dz6oiq5, r=matthiaskrgr 33c3615acf4 update outdated comment about test-float-parse adecda8a77d Rollup merge of #126046 - davidzeng0:mixed_integer_ops_unsigned_sub, r=Amanieu 51542950d0e Auto merge of #132662 - RalfJung:const-panic-inlining, r=tgross35 1abb10629d3 Update core CloneToUninit tests 13854a8e2ff btree: simplify the backdoor between set and map c90d22c922e Bump `cc` 3d904bd3bce Fix compilation error on Solaris due to flock usage eaf521eefcc Auto merge of #132556 - clubby789:cargo-update, r=Mark-Simulacrum 46a29c98717 Run `cargo update` and update licenses 89e4fc96f98 const_panic: don't wrap it in a separate function 6688c0ed773 [illumos] use pipe2 to create anonymous pipes 02f9d305b25 Auto merge of #132883 - LaihoE:vectorized_is_sorted, r=thomcc 88d8ceaf9b2 Auto merge of #132972 - matthiaskrgr:rollup-456osr7, r=matthiaskrgr 2a3153711ca Rollup merge of #132970 - tyilo:nonzero-u-div-ceil-issue, r=tgross35 d15ffa9b9d7 Rollup merge of #132966 - RalfJung:const_option_ext, r=jhpratt 8da08fb04e3 Rollup merge of #132948 - RalfJung:const_unicode_case_lookup, r=Noratrieb 4b3e44af4bf Rollup merge of #132851 - chansuke:update-comment, r=thomcc 9deb5611817 Auto merge of #132870 - Noratrieb:inline-int-parsing, r=tgross35 791200ecdc3 Add tracking issue number to unsigned_nonzero_div_ceil feature 7675ada911e Make `CloneToUninit` dyn-compatible 2c2a45cc451 stabilize const_option_ext f039e03516e Rollup merge of #132541 - RalfJung:const-stable-extern-crate, r=compiler-errors a4ad65d17fa stabilize const_unicode_case_lookup bc37c778f31 Stabilize `Ipv6Addr::is_unique_local` and `Ipv6Addr::is_unicast_link_local` 9c0e541eac3 adds new declaration to codegen 86ea8e7a9ca Auto merge of #132943 - matthiaskrgr:rollup-164l3ej, r=matthiaskrgr 098ae18ff80 Rollup merge of #132914 - rcorre:cell-grammar, r=tgross35 192301c3fac Rollup merge of #132895 - scottmcm:generalize-nonnull-from-raw-parts, r=ibraheemdev 2de06879a44 remove no-longer-needed abs_private 6c244aacfac allow rustc_private feature in force-unstable-if-unmarked crates 01bd3b6e11e Rollup merge of #132929 - cuviper:check-alloc_zeroed, r=tgross35 261729621b3 Rollup merge of #132869 - lolbinarycat:library-fix-too_long_first_doc_paragraph, r=tgross35 7e4bbb6c5a0 Rollup merge of #132847 - RalfJung:addr-dont-expose, r=Mark-Simulacrum d6ca95198bb Auto merge of #132919 - matthiaskrgr:rollup-ogghyvp, r=matthiaskrgr eefb0e3194a a release operation synchronizes with an acquire operation 1e66740d60a Check for null in the `alloc_zeroed` example afa8f1b7b42 new intrinsic declaration 40473d3c81d new intrinsic declaration b77452a321e Rollup merge of #132144 - adetaylor:receiver-trait-itself, r=wesleywiser 1646d6d2410 Rollup merge of #120077 - SUPERCILEX:set-entry, r=Amanieu 5f15da6bb77 Update dangling pointer tests 0fa82e32093 Tag relevant functions with #[rustc_as_ptr] attribute 48d78822e7f Auto merge of #132902 - matthiaskrgr:rollup-43qgg3t, r=matthiaskrgr 52dcc5069d0 Update grammar in std::cell docs. 97e5f187171 Emscripten: link with -sWASM_BIGINT 28bdd22cd93 Rollup merge of #130999 - cberner:flock_pr, r=joboet dfbff1c87d1 Auto merge of #127589 - notriddle:notriddle/search-sem-3, r=GuillaumeGomez adc20879918 Generalize `NonNull::from_raw_parts` per ACP362 dcbb3714ee3 vectorize slice::is_sorted cda88a80ad3 `#[inline]` integer parsing functions 1a54cb0a557 split up the first paragraph of doc comments for better summaries 0af8240bade Update the doc comment of `ASCII_CASE_MASK` 04dcc7e898f elem_offset / subslice_range: use addr() instead of 'as usize' cae173c25b6 Rollup merge of #132136 - RalfJung:target-feature-abi-compat, r=Mark-Simulacrum 6a872864a29 honor rustc_const_stable_indirect in non-staged_api crate with -Zforce-unstable-if-unmarked 6bb75bc7265 Improve documentation of `element_offset` and related methods 5349f6256ed Rename `elem_offset` to `element_offset` 4953b1cc926 Add as_slice/into_slice for IoSlice/IoSliceMut. a67f0e5d4d2 Rollup merge of #132778 - lolbinarycat:io-Error-into_inner-docs, r=cuviper 6f846111769 update io::Error::into_inner to acknowlage io::Error::other fec30ee8c7b Address review comments ef394a83e4c Update library/std/src/sys/pal/windows/fs.rs ecb4a7d4e02 Auto merge of #132717 - RalfJung:rustc_safe_intrinsic, r=compiler-errors 113ab03ea05 remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead b5bdce4299e Rollup merge of #132738 - cuviper:channel-heap-init, r=ibraheemdev 92d91d14138 mark is_val_statically_known intrinsic as stably const-callable 9ec0a314feb Rollup merge of #132696 - fortanix:raoul/rte-235-fix_fmodl_missing_symbol_issue, r=tgross35 e9f8ddce79d Rollup merge of #132639 - RalfJung:intrinsics, r=workingjubilee,Amanieu 52e18bac5ef Initialize channel `Block`s directly on the heap 0aafa2537b4 core: move intrinsics.rs into intrinsics folder d41e9588680 Auto merge of #132714 - mati865:update-memchr, r=tgross35 770b1273dd5 Rollup merge of #132715 - tabokie:fix-lazy-lock-doc, r=Noratrieb 27137ebac83 Rollup merge of #132665 - tyilo:nonzero-u-div-ceil, r=joboet 8a79cc2a902 Separate f128 `%` operation to deal with missing `fmodl` symbol a4e277296d8 Auto merge of #132705 - kornelski:inline-repeat, r=tgross35 065691735b2 fix lazylock comment acde4f2ebd9 Auto merge of #131888 - ChrisDenton:deopt, r=ibraheemdev d254610401f unpin and update memchr b5bdb7233ec optimize char::to_digit and assert radix is at least 2 c8ca6f9ca35 Inline str::repeat fe654f661fc Rollup merge of #132617 - uellenberg:fix-rendered-doc, r=cuviper 8cb10fda070 Auto merge of #131721 - okaneco:const_eq_ignore_ascii_case, r=m-ou-se e27a4c4a666 Add `is_ascii` function optimized for x86-64 for [u8] 5999d8cfc11 Auto merge of #132500 - RalfJung:char-is-whitespace-const, r=jhpratt 94701c9559a Add new implementation benchmark 47a959d3a5e Add new unstable feature `const_eq_ignore_ascii_case` 0b055c7a907 Auto merge of #132664 - matthiaskrgr:rollup-i27nr7i, r=matthiaskrgr 9a885ec1b0b Change some code blocks to quotes in rendered std doc f38040034e4 Rollup merge of #131261 - clarfonthey:unsafe-cell-from-mut, r=m-ou-se bf62de1efc4 Auto merge of #132661 - matthiaskrgr:rollup-npytbl6, r=matthiaskrgr 8b443562db5 Implement div_ceil for NonZero 864631d7e9d Rollup merge of #132571 - RalfJung:const_eval_select_macro, r=oli-obk 1e5b657574c Rollup merge of #132473 - ZhekaS:core_fmt_radix_no_panic, r=joboet f374a17b406 Rollup merge of #132153 - bjoernager:const-char-encode-utf16, r=dtolnay c1f2ccdb4bb add const_eval_select macro to reduce redundancy 5c07b20393c Rollup merge of #132609 - NotWearingPants:patch-1, r=Amanieu 0bce73ce9f3 Rollup merge of #132606 - eduardosm:char-slice-str-pattern-doc, r=tgross35 730a754a5fc most const intrinsics don't need an explicit rustc_const_unstable any more 7aaf6e185f1 add new rustc_const_stable_intrinsic attribute for const-stable intrinsics 0034b01a54f convert all const-callable intrinsics into the new form (without extern block) 864c8257f84 docs: fix grammar in doc comment at unix/process.rs 2e394d8b845 Improve example of `impl Pattern for &[char]` 6179adc1ff1 Add AsyncFn* to to the prelude in all editions 0552b3f85f0 Fixed typo, rebased 4e62a42457f Updated SAFETY comment to address underflow eab4613c217 Replace checked slice indexing by unchecked to support panic-free code 1e7bf99fe2a Rollup merge of #132579 - RalfJung:rustc-std-workspace-crates, r=Amanieu fb1ea67d71b btree: don't leak value if destructor of key panics 63abecb133b Stabilise 'const_char_encode_utf16'; 430033ea0e5 Auto merge of #132586 - workingjubilee:rollup-qrmn49a, r=workingjubilee cd724873fca update rustc-std-workspace crates 1eec164c45a Rollup merge of #132423 - RalfJung:const-eval-align-offset, r=dtolnay 777fd92cc60 Auto merge of #132434 - tgross35:f128-tests, r=workingjubilee 6d4f7acbe1a Fix and undeprecate home_dir() e8a1e496b59 Enable `f128` tests on all non-buggy platforms 🎉 94e030b38cc Auto merge of #132581 - workingjubilee:rollup-4wj318p, r=workingjubilee 4f1d92dcf0b Update `compiler_builtins` to 0.1.138 and pin it fb1f9637da0 Rollup merge of #132563 - frectonz:master, r=Amanieu f470b30ac9b Auto merge of #123723 - madsmtm:apple-std-os, r=dtolnay 3a7965ad211 Auto merge of #132479 - compiler-errors:fx-feat-yeet, r=fee1-dead 60bc96292e7 Rename the FIXMEs, remove a few that dont matter anymore e90f5ce2258 Auto merge of #132542 - RalfJung:const_panic, r=tgross35 9dfe28a76fc remove const-support for align_offset c069ebee079 Modify `NonZero` documentation to reference the underlying integer type df824eb205a Rollup merge of #132511 - RalfJung:const_arguments_as_str, r=dtolnay 0b80aa9e630 Rollup merge of #132503 - RalfJung:const-hash-map, r=Amanieu 6b8d05eb8b7 Rollup merge of #132499 - RalfJung:unicode_data.rs, r=tgross35 6c1622c4a18 Rollup merge of #132393 - zedddie16:issue-131865-fix, r=tgross35 5433ffec0be Rollup merge of #131377 - rick-de-water:nonzero-exp, r=dtolnay 0feaedf124a Rollup merge of #129329 - eduardosm:rc-from-mut-slice, r=dtolnay e85c756afd9 add const_panic macro to make it easier to fall back to non-formatting panic in const 499b7b63443 stabilize const_arguments_as_str 15a53e6ce5d Auto merge of #132458 - RalfJung:rustc-const-unstable, r=Amanieu efac6bd9c1d Rustdoc: added brief colon explanation 1bbe4896012 Add Set entry API 68ad673c9c7 Add BorrowedBuf::into_filled{,_mut} methods to allow returning buffer with original lifetime 2c527392d6c Rollup merge of #132495 - Houtamelo:remove_unintended_link, r=jieyouxu dbd89a205aa Rollup merge of #132493 - Houtamelo:doc_type-ref_html-tag, r=jieyouxu fd18e8ace91 Rollup merge of #132482 - lukas-code:stab-attrs, r=Noratrieb eb8de73ac7f remove const_hash feature leftovers 9f19c7d66bd const_with_hasher test: actually construct a usable HashMap 9577250e322 make char::is_whitespace unstably const b87112c2790 unicode_data.rs: show command for generating file 86aebd4e765 get rid of a whole bunch of unnecessary rustc_const_unstable attributes 212ac7f119a Rollup merge of #132398 - krtab:add_doc_link, r=Noratrieb 2f89c285043 Remove unintended link 24c896506d6 Fix type reference in documents which was being confused with html tags. acd358ebfd5 fix some stability annotations 022c129f048 Rollup merge of #132459 - RalfJung:byte_sub_ptr, r=scottmcm b227b16c8a6 Rollup merge of #132455 - RalfJung:const_alloc_layout, r=dtolnay 68d9733d309 Rollup merge of #132451 - RalfJung:less-rustc_allow_const_fn_unstable, r=tgross35 4b86f48f189 Rollup merge of #132445 - RalfJung:const-unchecked-shifts, r=tgross35 b2e7436ed69 Rollup merge of #132413 - lolbinarycat:offset_of_nested-docs, r=workingjubilee 73606d36a9f remove no-longer-needed attribute 73d2995026d add missing safety comments 79106b21d6a adjust test gating for f16/f128 13198e7eda5 float types: move copysign, abs, signum to libcore 962b70e7f73 offset_from / sub_ptr docs: emphasize that pointers must be in the same allocation 8f57f09b8ae feat(byte_sub_ptr): add ptr::byte_sub_ptr 6d83ae8c1d2 make const_alloc_layout feature gate only about functions that are already stable 90816a70eb4 unchecked_shifts, unchecked_neg are safe-to-const-expose-on-stable, so we can get rid of a bunch of attributes eff698a8f2f remove some unnecessary rustc_allow_const_fn_unstable d3e299995f1 Auto merge of #132206 - tgross35:update-builtins, r=wesleywiser afcfca63950 use semantic line break 30811c0b08b update offset_of! docs to reflect the stablization of nesting c5c45f60508 Add intra-doc link in str::xxx_char_boundary 543afa2fb09 Add a `collect_into` tuple test case 9edb2a7ec03 Don't impl Extend for 13-tuples b800d7b4389 rustdoc-search: simplify rules for generics and type params dc1e5cd6de3 Remove do_not_const_check from Iterator methods 9c14188973e Add intra-doc link in str::xxx_prefix d1d6f677939 Auto merge of #132238 - Urgau:midpoint-i64-hackers-impl, r=joboet 0ae9385e148 Implement `From<&mut {slice}>` for `Box/Rc/Arc<{slice}>` 0274f5daed0 Auto merge of #132326 - matthiaskrgr:rollup-ngyw18g, r=matthiaskrgr d5fd99cedb3 Rollup merge of #132321 - betrusted-io:xous/fix-rustc_const_stable-attribute, r=joboet 51b0778b46b Auto merge of #132231 - lukas-code:rc-plug-leaks, r=tgross35 1a47a3c093e xous: sync: remove `rustc_const_stable` attribute 95dcac90959 Win: rename: Use offset_of! in struct size calculation 72a57b2d487 Rollup merge of #132270 - yakiimoninja:fs-truncate-docs, r=Noratrieb 6f72d9516bd Rollup merge of #132233 - WaffleLapkin:box-module-split, r=workingjubilee df48a1c69eb Rollup merge of #131520 - zachs18:const-str-split, r=Noratrieb ff56c436c33 Auto merge of #132277 - workingjubilee:rollup-5e6q6e4, r=workingjubilee 2836956193a Stabilize `const_atomic_from_ptr` 381361ce4c3 Auto merge of #128985 - GrigorenkoPV:instantly-dangling-pointer, r=Urgau ff9fa8358ca Rc destructor: tweak inlining a57cb4cfbad Split `boxed.rs` into a few modules 11f0b5e2751 Rollup merge of #131441 - SpriteOvO:proc-macro-to-tokens-trait, r=dtolnay 8005427c22b clarified std::fs truncate doc f891dab5aaf Auto merge of #132145 - RalfJung:stdarch, r=Amanieu 0dd76301d77 clarified doc for `std::fs::OpenOptions.truncate()` e39e691e2f2 std: refactor `pthread`-based synchronization d5f89d2bd48 Impl TryFrom> for String b6f3ca0d4fb New lint: `dangling_pointers_from_temporaries` 4ccc424a270 Rollup merge of #131391 - ChaiTRex:isqrt, r=scottmcm,tgross35 9879fea09ed we can now enable the 'const stable fn must be stable' check 8529c7c6441 bump stdarch bfe37cb3caa Auto merge of #132251 - jieyouxu:rollup-mtv9mpd, r=jieyouxu 6a736f15deb Auto merge of #132200 - Mark-Simulacrum:strengthen-cross-lang, r=RalfJung b7917f12858 Support `char::is_digit` in const contexts 6c7088f0e7b Use Hacker's Delight impl in `i64::midpoint` instead of wide `i128` impl 1efc1ae3c57 Rc/Arc: don't leak the allocation if drop panics 3aee01d5690 add test for panicking drop in Box/Rc/Arc 47a80dfdde8 Auto merge of #131284 - dingxiangfei2009:rename-smart-ptr-to-coerce-referent, r=compiler-errors a7f53911b55 Auto merge of #132191 - Urgau:midpoint_signed_towards_zero, r=dtolnay 11d98406ed4 Add a new trait `proc_macro::ToTokens` 9a4a4d9fd73 Update compiler-builtins to 0.1.136 cd62f1d523a Auto merge of #131715 - tgross35:add-const_sockaddr_setters, r=Amanieu 6db264b79e5 Make clearer that guarantees in ABI compatibility are for Rust only 236e128eb86 Add test for all midpoint expectations 8fca6b9efc8 Simplify documentation for Extend impl for tuples 082c694aaf8 Round negative signed integer towards zero in `iN::midpoint` 755b1ab1347 Rollup merge of #132019 - daboross:document-partialeq-oncelock, r=Mark-Simulacrum bd9b46110d1 Add Extend impls for tuples of arity 1 through 12 1b51c66ce4d Auto merge of #131349 - RalfJung:const-stability-checks, r=compiler-errors 8c8c35b23f4 Rollup merge of #132137 - RalfJung:behavior, r=Noratrieb 3b5d62c9f9f get rid of the internal unlikely macro 4eada202868 Re-do recursive const stability checks 22ff5f7abeb Arbitrary self types v2: (unused) Receiver trait 3dade31b679 library: consistently use American spelling for 'behavior' 3b5135c2c51 ABI compatibility: remove section on target features b0b47f3937c Rollup merge of #131457 - kpreid:fnaddr, r=dtolnay 3d42c20e2b4 Auto merge of #132121 - workingjubilee:rollup-yrtn33e, r=workingjubilee 198bf9cdd39 Rollup merge of #132113 - LaihoE:pattern_as_utf8_default_impl, r=workingjubilee d14e7968296 Rollup merge of #132101 - youknowone:thread_local-gyneiene, r=tgross35 727e47673d9 Rollup merge of #132048 - mustartt:aix-random-impl, r=workingjubilee f3ae18ad7fc Rollup merge of #131851 - sunshowers:musl-posix, r=workingjubilee 676335272ac Avoid use imports in thread_local_inner! in statik 776f2d06a46 Auto merge of #132116 - matthiaskrgr:rollup-3a0ia4r, r=matthiaskrgr 349b38bb2bc Rollup merge of #131790 - nmathewson:doc_socketaddr_representation, r=tgross35 29c1731a7a8 Auto merge of #131985 - compiler-errors:const-pred, r=fee1-dead e4cbfc64481 provide default impl for as_utf8_pattern 2e302cbbd11 Auto merge of #123550 - GnomedDev:remove-initial-arc, r=Noratrieb c88ee64de11 Document textual format of SocketAddrV{4,6} 848c9f5832d Remove associated type based effects logic b28f00a3d90 [musl] use posix_spawn if a directory change was requested 015f57e4878 Rollup merge of #130225 - adetaylor:rename-old-receiver, r=wesleywiser f6bbac1a310 Rollup merge of #132066 - tifv:ptr-docs-typo, r=Amanieu f652a61bbf6 Rollup merge of #132065 - tifv:dangling-docs, r=Noratrieb 2b67d02b021 Rollup merge of #132060 - joshtriplett:innermost-outermost, r=jieyouxu 63c9f582767 Rollup merge of #132039 - a1phyr:vecdeque_read_exact, r=Noratrieb b53985874a2 Rollup merge of #130991 - LaihoE:vectorized_slice_contains, r=Noratrieb 75e9daca7f2 const fn str::split_at* 735ac4eec96 const fn str::is_char_boundary 5086505ea04 vectorized SliceContains 6b22b9decc7 s/SmartPointer/CoerceReferent/g 32a9cdaed75 fix a typo in documentation of pointer::sub_ptr() 690e7f211cb fix documentation of ptr::dangling() function 555cdc8b893 "innermost", "outermost", "leftmost", and "rightmost" don't need hyphens 1cc41525fce Specialize `read_exact` and `read_buf_exact` for `VecDeque` 584a5687f18 Rollup merge of #132031 - slanterns:rc_default, r=ibraheemdev 8831d5200ef Rollup merge of #131707 - clarfonthey:constify-core-tests, r=thomcc 75553b1246e Auto merge of #131929 - LaihoE:replace_default_capacity, r=joboet 895c27b5adc AIX use /dev/urandom for impl 0fe65e774f4 better default capacity for str::replace 945972d271e Rename Receiver -> LegacyReceiver 2bebece9481 refactor `Arc::default` 358ebd3c867 optimize `Rc::default` dd420354199 Rollup merge of #131697 - ShE3py:rt-arg-lifetimes, r=Amanieu c4e0fc064f7 Document PartialEq impl for OnceLock 246c621724e Rollup merge of #132003 - RalfJung:abi-compat-docs, r=traviscross 5aac8b82b95 Rollup merge of #130350 - RalfJung:strict-provenance, r=dtolnay 1896bae5914 update ABI compatibility docs for new option-like rules 738382e0c9c move strict provenance lints to new feature gate, remove old feature gates 0daf8520945 stabilize Strict Provenance and Exposed Provenance 31031a2c4b0 fix docs 3a7dfd7acc2 replace FindFirstFileW with FindFirstFileExW and apply optimization 68bc07c1905 replace FindFirstFileW with FindFirstFileExW and regenerate bindings 19b51014181 Auto merge of #131948 - matthiaskrgr:rollup-c9rvzu6, r=matthiaskrgr e7ec78d9b4c Support lock() and lock_shared() on async IO Files 378fa810450 Rollup merge of #131921 - klensy:statx_all, r=ChrisDenton ff17f8dd55a Rollup merge of #131772 - GnomedDev:remove-proc_macro-todo, r=petrochenkov a6e4c380998 Auto merge of #131907 - saethlin:update-compiler-builtins, r=tgross35 57be217014c Update `compiler-builtins` to 0.1.134 fd0a70e8481 Rollup merge of #131919 - RalfJung:zero-sized-accesses, r=jhpratt 40beeb980ce Rollup merge of #131890 - printfn:precise-capturing-docs, r=traviscross f1390deae9a Rollup merge of #127462 - Ayush1325:uefi-env, r=joboet cc5bea37eed Remove the Arc rt::init allocation for thread info a0f57624d0c Auto merge of #131816 - Zalathar:profiler-feature, r=Kobzol fed63726a8e replace STATX_ALL with (STATX_BASIC_STATS | STATX_BTIME) as former is deprecated 431a480314f zero-sized accesses are fine on null pointers 156a48c4530 Update `use` keyword docs to describe precise capturing 53d15a0be9e std: uefi: Use common function for UEFI shell 55e03fdcfaf std: uefi: Add basic Env variables da5c78f6590 Auto merge of #131895 - jieyouxu:rollup-jyt3pic, r=jieyouxu fcbec09300f Rollup merge of #126207 - devnexen:stack_overflow_libc_upd, r=joboet 7fec020fb18 Auto merge of #131841 - paulmenage:futex-abstraction, r=joboet 4f730a63e21 Revert using `HEAP` static in Windows alloc 2e16e148ba8 Rollup merge of #131866 - jieyouxu:thread_local, r=jhpratt d90176ca69a Rollup merge of #131858 - AnthonyMikh:AnthonyMikh/repeat_n-is-not-that-special-anymore, r=jhpratt 907f60e514f Rollup merge of #131809 - collinoc:fix-retain-mut-docs, r=jhpratt 286ada488df Rollup merge of #131774 - thesummer:rtems-add-getentropy, r=joboet f3d57d85500 Rollup merge of #130136 - GKFX:stabilize-const-pin, r=dtolnay 849d02d749f Add entropy source for RTEMS 892f0615bab Rollup merge of #131850 - lexeyOK:master, r=compiler-errors bedb0f789b5 Rollup merge of #131823 - thesummer:bump-libc-0.2.160, r=workingjubilee 789f32ae58c Rollup merge of #131654 - betrusted-io:xous-various-fixes, r=thomcc 11b058c865e Avoid shadowing user provided types or type aliases in `thread_local!` 228d752cfbf remove outdated documentation for `repeat_n` 3b31256e3da Auto merge of #131572 - cuviper:ub-index_range, r=thomcc d6a3dafe8ef Bump libc to 0.2.161 0366b77e5f8 std::unix::stack_overflow::drop_handler addressing todo through libc update 1c3c026667c Missing parenthesis 695b190d5f0 Abstract the state type for futexes 08e5e7511f9 Rollup merge of #131835 - ferrocene:amanjeev/add-missing-attribute-unwind, r=Noratrieb f175893eb19 Rollup merge of #131833 - c-ryan747:patch-1, r=Noratrieb 8a0d50e7003 Auto merge of #130223 - LaihoE:faster_str_replace, r=thomcc 1b2df71cf50 Do not run test where it cannot run 7b478ff6f08 Add must_use to CommandExt::exec 67590d6acaa Make `profiler_builtins` an optional dependency of sysroot, not std 5859c61a333 Remove TODO in proc_macro now `const_refs_to_static` is stable c252f55b117 Fix predicate signatures in retain_mut docs 46783197e04 Win: Remove special casing of the win7 target for `std::fs::rename` 7f2be37a3b8 Auto merge of #131797 - matthiaskrgr:rollup-lzpze2k, r=matthiaskrgr 5397edd5b30 Partially stabilize const_pin 86373ece361 Rollup merge of #131730 - zlfn:master, r=tgross35 e65f9381367 Auto merge of #131792 - matthiaskrgr:rollup-480nwg4, r=matthiaskrgr 1f954c615c7 Rollup merge of #130822 - bjoernager:non-null-from-ref, r=dtolnay fd2e0505e86 Auto merge of #131767 - cuviper:bump-stage0, r=Mark-Simulacrum 94e2de73f09 Rollup merge of #131746 - slanterns:once_box_order, r=joboet 0a0232c7464 Rollup merge of #131712 - tgross35:const-lazy_cell_into_inner, r=joboet 007c410cdfc Auto merge of #131460 - jwong101:default-placement-new, r=ibraheemdev ea1a0b8f62e update bootstrap configs 0a361d09562 replace placeholder version a8199be4be2 relax a memory order in `once_box` d72b3caf360 Rollup merge of #131521 - jdonszelmann:rc, r=joboet c2725957a3c Rollup merge of #130568 - eduardosm:const-float-methods, r=RalfJung,tgross35 0b6650cc80f Rollup merge of #129794 - Ayush1325:uefi-os-expand, r=joboet 48915864283 Refactor `floating` macro and nofloat panic message 6ea2bc0ed60 Auto merge of #131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgr 752e847f4ce Rename debug! macro to impl_Debug! ee518416f8e Combine impl_int and impl_uint 5ed2ba51c4c Make some float methods unstable `const fn` b09886c1015 Auto merge of #131724 - matthiaskrgr:rollup-ntgkkk8, r=matthiaskrgr 84548d0d806 Rollup merge of #131706 - GKFX:fix-const-hacks, r=tgross35 d3e8f9c197a Rollup merge of #131496 - bjoernager:const-make-ascii, r=dtolnay 40ed81690d3 Rollup merge of #130608 - YohDeadfall:cstr-from-into-str, r=workingjubilee f23a220482c Rollup merge of #131339 - HeroicKatora:set_ptr_value-documentation, r=Mark-Simulacrum f0723221a81 Rollup merge of #122670 - beetrees:non-unicode-option-env-error, r=compiler-errors 2b306410b92 Auto merge of #129458 - EnzymeAD:enzyme-frontend, r=jieyouxu 876d3222868 Stabilise 'const_make_ascii' 304f4711690 Add a `const_sockaddr_setters` feature 6a2ec50b496 Mark LazyCell::into_inner unstably const c149bc6eb88 Run most core::num tests in const context too d4e6f11a78a Fix two const-hacks d885deba0f3 `rt::Argument`: elide lifetimes 0644be83339 Rollup merge of #131384 - saethlin:precondition-tests, r=ibraheemdev 3f2ef13c6ee Rollup merge of #129424 - coolreader18:stabilize-pin_as_deref_mut, r=dtolnay 94962bfff3f Auto merge of #131672 - matthiaskrgr:rollup-gyzysj4, r=matthiaskrgr dc4830d3194 Remove allowing static_mut_refs lint bbc0505218e uefi: Implement getcwd and chdir 86666b851c1 Rollup merge of #131616 - RalfJung:const_ip, r=tgross35 37a28536bee Rollup merge of #131274 - workingjubilee:stabilize-the-one-that-got-away, r=scottmcm bf512386889 Rollup merge of #130629 - Dirbaio:net-from-octets, r=tgross35 ac98773ab0c Rollup merge of #128967 - devnexen:get_path_fbsd_upd, r=joboet 9f5ddf851cb Auto merge of #126557 - GrigorenkoPV:vec_track_caller, r=joboet 4d78345d6a7 Implement file_lock feature 469184e0084 Auto merge of #131662 - matthiaskrgr:rollup-r1wkfxw, r=matthiaskrgr 9f11af15cad rename rcbox in other places as per review comments 09919513672 core/net: use hex for ipv6 doctests for consistency. b045a6f208e core/net: add Ipv[46]Addr::from_octets, Ipv6Addr::from_segments 03cc1683ef2 Rollup merge of #131646 - RalfJung:unix-miri-fallbacks, r=joboet 217d57810dc Rollup merge of #131644 - RalfJung:win-miri, r=joboet 13787d52cb1 library: xous: mark alloc as `FIXME(static_mut_refs)` b58bef8b56f xous: ffi: correct syscall number for adjust_process 06302230b8c net: fix dead code warning 172906d1244 std: xous: add support for args and env 53056640ba8 Auto merge of #125679 - clarfonthey:escape_ascii, r=joboet 61ba917726d unwind: update unwinding dependency to 0.2.3 7130cb04662 sys/unix: add comments for some Miri fallbacks 37ea10805b7 remove outdated comment now that Miri is on CI eff05c2648a sys/windows: remove miri hack that is only needed for win7 2f1188de0ed switch unicode-data back to 'static' 27a3d389839 merge const_ipv4 / const_ipv6 feature gate into 'ip' feature gate c9eb153ca0d Rollup merge of #131418 - coolreader18:wasm-exc-use-stdarch, r=bjorn3 3767d89db83 Rollup merge of #131120 - tgross35:stabilize-const_option, r=RalfJung 38e34691614 Fix bug where `option_env!` would return `None` when env var is present but not valid Unicode eb444660fb4 Fix typo thing->thin referring to pointer 3d929189f04 Stabilize `const_option` d19d2dc02e7 Rollup merge of #131617 - RalfJung:const_cow_is_borrowed, r=tgross35 0d9a0725252 Rollup merge of #131503 - theemathas:stdin_read_line_docs, r=Mark-Simulacrum 2a8644291bb remove const_cow_is_borrowed feature gate d35a2429237 Rollup merge of #131233 - joboet:stdout-before-main, r=tgross35 822585d056e Rollup merge of #130954 - workingjubilee:stabilize-const-mut-fn, r=RalfJung 2636ac84e64 std: fix stdout-before-main 5e3d1361eb4 library: Stabilize `const_replace` 246f0ee47d2 library: Stabilize `const_ptr_write` 9eed67a6072 library: Stabilize `const_intrinsic_forget` 1a910bda92e Rollup merge of #131289 - RalfJung:duration_consts_float, r=tgross35 701bb94c431 Rollup merge of #130962 - nyurik:opts-libs, r=cuviper c1db3f1d7e4 Rollup merge of #124874 - jedbrown:float-mul-add-fast, r=saethlin 4d3aa6db78d Avoid superfluous UB checks in `IndexRange` 863a08c7481 Rollup merge of #131463 - bjoernager:const-char-encode-utf8, r=RalfJung 3452f68e756 Rollup merge of #131287 - RalfJung:const_result, r=tgross35 ed96df733d0 Rollup merge of #131109 - tgross35:stabilize-debug_more_non_exhaustive, r=joboet ca46419b9c8 Rollup merge of #131065 - Voultapher:port-sort-test-suite, r=thomcc 2070a0c5fe1 intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semantics 3f5a4fa850c Single commit implementing the enzyme/autodiff frontend 008ed04ec21 stabilize const_result af2e4a097f4 stabilize duration_consts_float 3de6adac1d3 Rollup merge of #131512 - j7nw4r:master, r=jhpratt fec0476f53b rename RcBox in other places too 716177a42a3 rename RcBox to RcInner for consistency 76c3460aaf2 Fixing rustDoc for LayoutError. 5ec94425f3e Rollup merge of #130741 - mrkajetanp:detect-b16b16, r=Amanieu 43628260110 Rollup merge of #130538 - ultrabear:ultrabear_const_from_ref, r=workingjubilee 9c3df471abd uefi: process: Add args support 4f3aecd600c Use with_capacity(0) because we're reading the capacity later on c9de20418c2 Prefer `target_vendor = "apple"` on confstr c7512684e8f use `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)` as a `TMPDIR` fallback on darwin e4c4ebc9655 More clearly document Stdin::read_line 8b72e64161e Stabilise 'const_char_encode_utf8'; 5f60b1638d5 allocate before calling T::default in >::default() 01b5e9fd55c allocate before calling T::default in >::default() 8af0ed587c8 rustc_target: Add sme-b16b16 as an explicit aarch64 target feature e20f1cc5adc stdarch: Bump stdarch submodule 237bedf7257 Clean up is_aligned_and_not_null bf190e01c36 Add more precondition check tests e163b913c8b Allow zero-size reads/writes on null pointers 76f9c3921f5 Optimize escape_ascii 8ee8044a99e Rollup merge of #131462 - cuviper:open_buffered-error, r=RalfJung b50aaa173fe Rollup merge of #131449 - nickrum:wasip2-net-decouple-fd, r=alexcrichton 3e3b4192b39 Rollup merge of #131383 - AngelicosPhosphoros:better_doc_for_slice_slicing_at_ends, r=cuviper 10f749c6151 Rollup merge of #130827 - fmease:library-mv-obj-save-dyn-compat, r=ibraheemdev 6270825387e Add "not guaranteed to be equal" cc9d063c437 Mention allocation errors for `open_buffered` fd04dd405a1 Apply suggestions from code review 8e614175759 Expand `ptr::fn_addr_eq()` documentation. 4df03dcb005 Library: Rename "object safe" to "dyn compatible" ca8f684fba8 Decouple WASIp2 sockets from WasiFd ca5bbbc060d stabilize `{slice,array}::from_mut` f0e31c2766e Update library/std/src/sys/pal/unix/process/process_vxworks.rs d060a4a44dd fix ref in process_vxworks.rs d1852dfeb7a Update library/std/src/sys/pal/unix/process/process_unix.rs 9da14e4dcd5 Change a few `&Option` into `Option<&T>` 62476191a94 Use throw intrinsic from stdarch in wasm libunwind b049e9ddeed Stabilize Pin::as_deref_mut 09e3893086d Stabilize `isqrt` feature 1b597cc2622 Add LowerExp and UpperExp implementations 388d7c71e03 Add docs about slicing slices at the ends f9b4be957aa cfg out checks in add and sub but not offset efc8ee9867d Add precondition checks to ptr::offset, ptr::add, ptr::sub 8b9db2431a9 Rollup merge of #131308 - mati865:gnullvm-f16-f128, r=tgross35 684c8be6c10 Rollup merge of #128399 - mammothbane:master, r=Amanieu,tgross35 76941e933a9 liballoc: introduce String, Vec const-slicing d45ccba4487 Auto merge of #128651 - folkertdev:naked-asm-macro-v2, r=Amanieu 3be05d7cfd2 Expand set_ptr_value / with_metadata_of docs bd870b46b85 Rollup merge of #131335 - dacianpascu06:fix-typo, r=joboet 410102368be Rollup merge of #131307 - YohDeadfall:prctl-set-name-dbg-assert, r=workingjubilee 1e5ba45fe71 grammar fix f2e69ac1a8c disallow `asm!` in `#[naked]` functions 79609468c7e implement `naked_asm` macro 20f8bc90a61 Rollup merge of #131316 - programmerjake:patch-4, r=Noratrieb dca432db239 Auto merge of #131314 - tgross35:update-builtins, r=tgross35 4b40e1deeb7 Fix typo in primitive_docs.rs 4912a5657f3 Auto merge of #130540 - veera-sivarajan:fix-87525, r=estebank 56563ccb070 Update `compiler-builtins` to 0.1.133 28d391bd5a6 enable f16 and f128 on windows-gnullvm targets 747dae43712 Auto merge of #131302 - matthiaskrgr:rollup-56kbpzx, r=matthiaskrgr 78de7e0693f Unbreak tidy 18ee01d06c5 Stabilize `std::io::ErrorKind::QuotaExceeded` c47ef21d941 Android: Debug assertion after setting thread name fa8c3d41f7e Rollup merge of #131281 - RalfJung:const-cell, r=Amanieu 9ad5a82a519 Auto merge of #131221 - XrXr:bump-compiler-builtins, r=tgross35 1883f6608a9 library: Stabilize const `MaybeUninit::assume_init_mut` 759bd0b11d1 Add a Lint for Pointer to Integer Transmutes in Consts fb6fae5f6da Rollup merge of #131256 - RalfJung:f16-f128-const, r=ibraheemdev a59386da0bf Rollup merge of #131094 - joboet:lazy_once_box, r=ibraheemdev 9b47afe2eb7 make Cell unstably const 7ad048a73db move f16/f128 const fn under f16/f128 feature gate 1048c03347a Stabilize `const_slice_split_at_mut` and `const_slice_first_last_chunk` 8736f8d6c69 Rollup merge of #131267 - okaneco:bufread_skip_until, r=tgross35 cbf95571fa8 Rollup merge of #131105 - slanterns:literal_c_str, r=petrochenkov e74f47181d2 Rollup merge of #130403 - eduardosm:stabilize-const_slice_from_raw_parts_mut, r=workingjubilee 42efc077457 Update compiler-builtins to 0.1.132 2e26222ebf1 Rollup merge of #131177 - workingjubilee:stabilize-const-mut-referees, r=tgross35 38dd201a6b1 Rollup merge of #130518 - scottmcm:stabilize-controlflow-extra, r=dtolnay 04a9e0c6a2c Stabilize `BufRead::skip_until` 359a4b3acf2 Auto merge of #130157 - eduardosm:stabilize-const_float_classify, r=RalfJung 99599e7099c Stabilize UnsafeCell::from_mut e27b1b6bbab update libc version 8f4ac445630 std::fs::get_path freebsd update. 634c15d2ffc control libunwind linkage mode via `crt-static` on gnullvm targets 0d1fed1a247 Rollup merge of #131197 - EFanZh:avoid-emptyness-check-in-peekmut-pop, r=Amanieu 5597724bcd4 Avoid emptiness check in `PeekMut::pop` 722ce76e0c8 Rollup merge of #131163 - JakenHerman:master, r=Nadrieril 9eb9385f373 Auto merge of #128711 - clarfonthey:default-iters-hash, r=dtolnay 9a40af9276e Add `get_line` confusable to `Stdin::read_line()` 550e59b7bd1 impl Default for Hash{Map,Set} iterators that don't already have it c3827fc8c29 Auto merge of #127912 - joboet:tls_dtor_thread_current, r=cuviper 8925707c68f Auto merge of #131148 - Urgau:hashbrown-0.15, r=Amanieu 35731d00240 library: Stabilize `const_slice_first_last` e36901c8758 library: Stabilize `const_unsafecell_get_mut` 2fa1cf60b89 library: Stabilize `const_ptr_as_ref` 4a5ca22fb39 library: Stabilize `const_str_as_mut` f646becc5bc library: Stabilize `const_str_from_utf8_unchecked_mut` b1f637e5c04 std: make `thread::current` available in all `thread_local!` destructors 1e51c4018ac Rollup merge of #131141 - RalfJung:mpmc-test, r=Amanieu 81adc374a44 Update hashbrown to 0.15 and adjust some methods adede467860 mpmc doctest: make sure main thread waits for child threads 5348d41de0b Auto merge of #130829 - Urgau:option_array_transpose, r=ibraheemdev ba4978d419f Auto merge of #128204 - GuillaumeGomez:integers-opti, r=workingjubilee 6974d0e2673 std: replace `LazyBox` with `OnceBox` 17b32ee17f5 Stabilize `const_slice_from_raw_parts_mut` 61e86dcd82c Auto merge of #131111 - matthiaskrgr:rollup-n6do187, r=matthiaskrgr ca31e5178d2 Rollup merge of #130773 - bjoernager:master, r=thomcc 3ccffc2efe8 Rollup merge of #130229 - RalfJung:ptr-offset-unsigned, r=scottmcm 42ba5d69ae9 Implemented FromStr for CString and TryFrom for String 43dc04c038c Stabilize `debug_more_non_exhaustive` c5cbb1df0d9 update `Literal`'s intro cd708bfe42e Auto merge of #131098 - GuillaumeGomez:rollup-kk74was, r=GuillaumeGomez 1c5a213198f Rollup merge of #131085 - RalfJung:miri-slow-test, r=tgross35 31d9af723e9 Auto merge of #126839 - obeis:mpmc, r=Amanieu 3076a7e10f8 Remove the need to provide the maximum number of digits to `impl_Display` macro 156e5e68dd6 Simplify `impl_Display` macro 2d6cbe4bf19 Small optimization for integers Display implementation b208f9f53ce make test_lots_of_insertions test take less long in Miri 92293337aea Enable `f16` tests on non-GNU Windows b98e332a200 Rollup merge of #130966 - RalfJung:ptr-metadata-const-stable, r=scottmcm 319e114a284 Rollup merge of #130961 - tgross35:f16-x86-apple, r=thomcc eeb21e8c514 Rollup merge of #130914 - compiler-errors:insignificant-dtor, r=Amanieu 40e17593468 Rollup merge of #129638 - nickrum:wasip2-net, r=alexcrichton 8217137597a Win: Add test cases for renaming a directory while the target file is opened and for renaming over a non-empty directory 46902ac7271 Win: Use `FILE_RENAME_FLAG_POSIX_SEMANTICS` for `std::fs::rename` if available 04814b366fd Add multi-producer, multi-consumer channel (mpmc) 1e186689c30 Port sort-research-rs test suite Rust stdlib tests b61f74bec09 Rollup merge of #130972 - RalfJung:const_cell_into_inner, r=dtolnay 8ade397d994 Rollup merge of #129003 - Voultapher:improve-ord-docs, r=workingjubilee 6fb48e34a2b Rollup merge of #123932 - adamse:global-alloc-safety-preconds-positive, r=tgross35 5589344d2de Rollup merge of #130931 - GuillaumeGomez:standalone-crate, r=notriddle b516533fd9c Rename doctest attribute `standalone-crate` into `standalone_crate` for coherency 2e476eea605 Rollup merge of #130743 - YohDeadfall:net-nonblocking-doc, r=Mark-Simulacrum 2257f15b529 Rollup merge of #130416 - BatmanAoD:130122-sort-by-docs, r=Mark-Simulacrum 133b73139e2 Remove duplicate section 081612a46f8 Auto merge of #128321 - BatmanAoD:catch-unwind-doc-update, r=Mark-Simulacrum 5c7e47c3284 Fix std tests for wasm32-wasip2 target cd31eb9e0a7 Hook up std::net to wasi-libc on wasm32-wasip2 target 13ea9fc681c Auto merge of #123778 - jhorstmann:optimize-upper-lower-auto-vectorization, r=the8472 9b0ffcfbc03 Enable `f16` tests on x86 Apple platforms 8b6c7865f28 Auto merge of #129385 - tgross35:more-platforms-enable-f16, r=Mark-Simulacrum 8c194ef35b6 Auto merge of #130792 - tgross35:update-builtins, r=Amanieu 3441592f7b9 Rename `standalone` doctest attribute into `standalone-crate` 30596b11e95 Update compiler_builtins to 0.1.130 2ba96b0f970 Rollup merge of #128778 - RalfJung:atomic-read-read-races, r=Mark-Simulacrum 4c989ffeeb8 Auto merge of #130964 - matthiaskrgr:rollup-suriuub, r=matthiaskrgr 5706ffa5756 Further clarificarion for atomic and UnsafeCell docs: 26048c4781a allow mixed-size atomic reads 61e77b5e612 atomics: allow atomic and non-atomic reads to race 5226488fcc8 stabilize const_cell_into_inner 004ae0c87d5 make ptr metadata functions callable from stable const fn 1858def1d21 Auto merge of #130897 - workingjubilee:dump-hexes-with-class, r=thomcc 79c763fb945 Rollup merge of #130922 - tyilo:udp-unspecified, r=ibraheemdev 868de994f1f Rollup merge of #125404 - a1phyr:fix-read_buf-uses, r=workingjubilee d5cbe5a01e3 Update Unicode escapes; b119ba7e38f Enable `f16` on platforms that were missing conversion symbols 47ee775c135 Auto merge of #130946 - matthiaskrgr:rollup-ia4mf0y, r=matthiaskrgr 9245ed063a2 Rollup merge of #130926 - ChrisDenton:cc-1-1-22, r=tgross35 df36ee7467b Rollup merge of #129087 - slanterns:option_get_or_insert_default, r=dtolnay fe873e64849 Mark some more smart pointers as insignificant 10d482cee5e Mark some more types as having insignificant dtor 5fe7c464b34 Add 'from_ref' and 'from_mut' constructors to 'core::ptr::NonNull'; 9d42b7b020e Update Cargo.lock 6e219b444c9 Apply review feedback 22605fda8a1 Apply round 1 of review comments 21ec25b0e7a Fix mistake in example 52ff81d0931 Improve Ord docs f768419c01c Reference UNSPECIFIED instead of INADDR_ANY in join_multicast_v4 9e5cb64b07e Rollup merge of #130892 - tgross35:library-cargo-update, r=Noratrieb bc31633867e Rollup merge of #130875 - folkertdev:naked-asm-bootstrap, r=tgross35 20da2aea0b1 Rollup merge of #130846 - ChrisDenton:revert-break, r=Noratrieb 2defdd0f9c6 Rollup merge of #130313 - c410-f3r:unlock-rfc-2011, r=thomcc 6826f44d56d Rollup merge of #130880 - RalfJung:const-hack, r=scottmcm baa09d46b52 Rollup merge of #130861 - cuviper:sun-path-offset, r=ibraheemdev 400a8d3ecdc Rollup merge of #130845 - RalfJung:utf8chunk, r=tgross35 6788e956917 Rollup merge of #130279 - theemathas:manually-drop-docs, r=thomcc,traviscross 7dea8b88fa1 library: Compute `RUST_EXCEPTION_CLASS` from native-endian bytes 79c904fd935 Partially update `library/Cargo.lock` 9d1ea586178 Add `sun_path` to the fake doc `sockaddr_un` 87eb506e5b3 add missing FIXME(const-hack) 24c8de60250 Add `[Option; N]::transpose` 0615f339dc3 update `compiler_builtins` to `0.1.126` 522f441f76f add a bootstrap variant of `naked_asm` d8b6975fbda Stabilize the `map`/`value` methods on `ControlFlow` 3b0b6a58dc3 Use `&raw` in the standard library 0c31f8b9c69 Use `mem::offset_of!` for `sockaddr_un.sun_path` 9ca8383a8d0 Rollup merge of #130842 - Noratrieb:tracking-issue-inprogress, r=jieyouxu a3a29b14d2a Rollup merge of #130832 - RalfJung:sort-cfg-mess, r=workingjubilee 934774c8a3b Rollup merge of #130819 - bjoernager:char-must-use-len-utf, r=Noratrieb eeede3acb1e Rollup merge of #130811 - RalfJung:random, r=joboet 301dc49efc7 Revert Break into the debugger on panic (129019) 1c4ad660c6a Utf8Chunks: add link to Utf8Chunk eb291d1749e Add tracking issue for io_error_inprogress eb3c07b4f23 fix some cfg logic around optimize_for_size and 16-bit targets 487b867c620 Auto merge of #130816 - matthiaskrgr:rollup-jy25phv, r=matthiaskrgr 983a28b0b57 Add 'must_use' attribute to 'char::len_utf8' and 'char::len_utf16'; 685ede6d972 Rollup merge of #130810 - kromych:master, r=workingjubilee 81aed06c30f Rollup merge of #130595 - no1wudi:master, r=ibraheemdev 446b61b8867 Rollup merge of #130549 - biabbas:riscv32_wrs_vxworks, r=nnethercote 1db8772e2f0 add link from random() helper fn to extensive DefaultRandomSource docs 699cadb13d8 Auto merge of #130803 - cuviper:file-buffered, r=joshtriplett f73355adbd1 Don't trap into the debugger on panics under Linux 021860b5244 Rollup merge of #130789 - aviramha:add_inprogress, r=Noratrieb 11eaaf10fe9 Rollup merge of #130788 - tgross35:memchr-pinning, r=Noratrieb,Mark-Simulacrum d6b6804d159 Add a tracking issue for `file_buffered` 64028f8a8a8 Dogfood `feature(file_buffered)` f1dad0ba2e4 Mark 'get_mut' and 'set_position' in 'std::io::Cursor' as const; 9bb5d5c0d69 Pre-allocate buffers in `File::open_buffered` and `create_buffered` 719ec285b99 Add `File::open_buffered` and `create_buffered` 5e703cdd4bf Auto merge of #129587 - Voultapher:opt-for-size-variants-of-sort-impls, r=cuviper 26f2dfb5380 add InProgress ErrorKind gated behind io_error_inprogress feature 0fa09c5bf5c Pin memchr to 2.5.0 in the library rather than rustc_ast e176082d26e Auto merge of #130738 - bjoernager:const-make-ascii, r=jhpratt d2475bd52f1 Initial std library support for NuttX 60f55997183 Mark and implement 'make_ascii_uppercase' and 'make_ascii_lowercase' in '[u8]' and 'str' as const; 804e353ac60 Rollup merge of #130762 - RalfJung:const_intrinsic_copy, r=dtolnay 64d3397b55c Rollup merge of #129545 - notriddle:notriddle/toolbar-v2, r=GuillaumeGomez 7493bac7cf0 Add a comment to `Read::read_buf` a163ddb0293 Add tests 5ba34ac966f Fix `io::default_read_to_end` uses of `read_buf` 983045b08e4 Fix `io::BufReader` uses of `read_buf` bad8e7a6503 Fix `io::Take::read_buf` 37748d58689 stabilize const_intrinsic_copy dc724d6e9a1 Add fast path for ascii to ascii in str::replace 4f0dc756ac0 Fix up standard library intro 80158e75f6e Clarifications for set_nonblocking methods f6c77c14525 Improve autovectorization of to_lowercase / to_uppercase functions dc421c7786f random: add tracking issue, address other comments 0572bf807b2 std: switch to faster random sources on macOS and most BSDs c119015fd1a std: implement the `random` feature d310beb64c9 Rollup merge of #130723 - D0liphin:master, r=workingjubilee 0599791b334 Rollup merge of #130713 - bjoernager:const-char-make-ascii, r=Noratrieb 2717e4cabb6 Rollup merge of #130659 - bjoernager:const-char-encode-utf16, r=dtolnay 8adb56a7e41 Rollup merge of #129550 - kornelski:boxasstr, r=joshtriplett,dtolnay 96fe0c5e4a2 Reformat using the new identifier sorting from rustfmt 488a0c0c04f reword edge-conditions documentation on all slice 'sort' functions; resolves #130122 ee40144803e Add test for `available_parallelism()` b49bbc5f883 Mark 'make_ascii_uppercase' and 'make_ascii_lowercase' in 'u8' as const; Rename 'const_char_make_ascii' feature gate to 'const_make_ascii'; 2be3384fae9 Rollup merge of #130692 - RalfJung:result-flatten, r=Noratrieb d5bdce08884 Rollup merge of #130670 - the8472:read-to-end-heuristics, r=ChrisDenton d401a085a65 Rollup merge of #130658 - EqualMa:patch-1, r=scottmcm 81c80c09bae Auto merge of #130697 - bjoernager:const-char-make-ascii, r=dtolnay 4f2398bf1b0 Mark 'make_ascii_uppercase' and 'make_ascii_lowercase' in 'char' as const; 320330254df make unstable Result::flatten a const fn 321affc571a Rollup merge of #130653 - RalfJung:result-abi-compat, r=traviscross 0503385a52d Rollup merge of #130408 - okaneco:into_lossy_refactor, r=Noratrieb a77a43af29c wait for two short reads before uncapping the max read size 3e4193b70ac Mark and implement 'char::encode_utf16' as const; Rewrite 'encode_utf16_raw'; 7ee642d52b3 Fix docs of compare_bytes bda50d206bf ABI compatibility: mention Result guarantee 71fc82a112a Reword ManuallyDrop+Box interaction 9f9894e9d3b Rollup merge of #129718 - lolbinarycat:remove_dir-docs, r=Noratrieb 02d62ceaa46 Avoid re-validating UTF-8 in `FromUtf8Error::into_utf8_lossy` a2b20ec8840 Auto merge of #130631 - GuillaumeGomez:rollup-jpgy1iv, r=GuillaumeGomez 96f00edd3ca Remove double spaces 5461a3a0df7 Rollup merge of #130624 - theemathas:vec_as_non_null, r=Noratrieb c6023a86728 Rollup merge of #130611 - bjoernager:const-char-encode-utf8, r=dtolnay 4b3e4b2e9b7 Rollup merge of #130526 - eholk:pin-reborrow, r=compiler-errors 0cb0d034858 Rollup merge of #128209 - beetrees:no-macos-10.10, r=jieyouxu 9214da5884c Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errors da0a227c557 Add `Vec::as_non_null` 08c072e53be Address diagnostics regression for 'const_char_encode_utf8'; efd0016ffcb Allow unused unsafe for vxworks in alligned_malloc to resolve build errors 3d59943ff2b [Clippy] Remove final std paths for diagnostic item e10e44803b9 Allow shortening reborrows f9ce89da475 Add `#[track_caller]` to allocating methods of `Vec` & `VecDeque` 9828d0e71c0 Rollup merge of #130554 - ShE3py:unsupported-exitcode, r=Noratrieb 74e2be259ff Rollup merge of #130553 - GnomedDev:remove-clippy-paths, r=compiler-errors 685c146e3b2 Rollup merge of #128001 - Krappa322:master, r=scottmcm 7ef487d8c69 Add str.as_str() for easy dereferencing of Box 855402d45e4 `pal::unsupported::process::ExitCode`: use an `u8` instead of a `bool` 610a25c1649 [Clippy] Swap `open_options` to use diagnostic items instead of paths 3434ecad9b9 [Clippy] Swap `iter_over_hash_type` to use diagnostic items instead of paths 0fdcd48ec35 [Clippy] Swap `non_octal_unix_permissions` to use diagnostic item instead of path baebd20afdd [Clippy] Swap `unnecessary_owned_empty_strings` to use diagnostic item instead of path 0da129c4149 [Clippy] Swap `manual_strip` to use diagnostic items instead of paths 6e6d2ff6f5b [Clippy] Swap `unnecessary_to_owned` to use diagnostic item instead of path 5ab60563a29 [Clippy] Swap `instant_subtraction` to use diagnostic item instead of path 56ee1c3b021 [Clippy] Swap `waker_clone_wake` to use diagnostic item instead of path a69ff649239 [Clippy] Swap `filter_map_bool_then` to use diagnostic item instead of path caf51ced61b [Clippy] Swap `manual_while_let_some` to use diagnostic items instead of paths ddfeb3aa365 [Clippy] Swap `repeat_vec_with_capacity` to use diagnostic item instead of path eaf8a76d8ce [Clippy] Swap `VecArgs::hir` to use diagnostic items instead of paths 4b63fc1b8b2 [Clippy] Swap `single_char_add_str`/`format_push_string` to use diagnostic items instead of paths 83c6928561d [Clippy] Swap `manual_main_separator_str` to use diagnostic item instead of path 0a2c7dd52d6 [Clippy] Swap `redundant_clone` to use diagnostic items instead of paths eabd234f5fa [Clippy] Swap `float_equality_without_abs` to use diagnostic items instead of paths a795e057be7 [Clippy] Swap `option_as_ref_deref` to use diagnostic items instead of paths 89ee629643e [Clippy] Swap `lines_filter_map_ok` to use a diagnostic item instead of path b2c1c68d009 [Clippy] Swap `map_entry` to use diagnostic items instead of paths 575e77d5628 Auto merge of #130547 - workingjubilee:rollup-tw30khz, r=workingjubilee 54ae6b4a29d Auto merge of #130511 - bjoernager:const-char-encode-utf8, r=dtolnay 540e75acd92 run `x.py fmt` 4f2ee89ef6d remove feature attributes as const_maybe_uninit_as_mut_ptr is stabilized 249118a6392 stabilize `const_maybe_uninit_as_mut_ptr` 4dabc82b0e3 Mark and implement 'char::encode_utf8' as const. 4f5ff0d5e57 Rollup merge of #130522 - GnomedDev:clippy-manual-retain-paths, r=compiler-errors b078926b41f Rollup merge of #130513 - shekhirin:fs-write-doc-comment, r=cuviper 018ff34ab8f Rollup merge of #130487 - cuviper:min-llvm-18, r=nikic 7c77887bc6b Rollup merge of #130476 - workingjubilee:more-lazy-methods-take-2, r=Amanieu 1290846054e Rollup merge of #129934 - ChrisDenton:remove-dir-all3, r=Amanieu 8e37ff5f17b Rollup merge of #97524 - ibraheemdev:thread-raw, r=ibraheemdev 50604826555 Revert "Add a hack to prevent proc_macro misopt in CI" 4d3549cb004 Begin experimental support for pin reborrowing 8c23a5b8a53 library: Call it really_init_mut to avoid name collisions f83d78af2d2 library: Destabilize Lazy{Cell,Lock}::{force,deref}_mut d254ba2e962 [Clippy] Swap `manual_retain` to use diagnostic items instead of paths fa638604fe2 Auto merge of #130497 - saethlin:alloc-zeroed-is-unstable, r=bjorn3 5f30788106a Clarify docs for std::fs::File::write fb33dc11ecc Auto merge of #129491 - StackOverflowExcept1on:master, r=m-ou-se dcbdb3016d5 Auto merge of #129845 - scottmcm:redo-layout, r=Noratrieb 977970bad69 Take more advantage of the `isize::MAX` limit in `Layout` 7c53704cbc0 read_volatile __rust_no_alloc_shim_is_unstable in alloc_zeroed b43d5088150 add `Thread::{into_raw, from_raw}` 044e394a58f Rollup merge of #130481 - krtab:clamp_partial_ord, r=cuviper da159849363 Auto merge of #130483 - matthiaskrgr:rollup-q1r0g0y, r=matthiaskrgr e60fa7c4e9a Remove uneeded PartialOrd bound in cmp::Ord::clamp e1476107956 Rollup merge of #130467 - RalfJung:miri-sync, r=RalfJung 49734812149 Rollup merge of #129674 - matthewpipie:rc-arc-new-cyclic-in, r=dtolnay 37c3ec8d802 Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut` 8f095da9723 Rollup merge of #128535 - mmvanheusden:master, r=workingjubilee 829c0bb89d0 Auto merge of #130145 - fee1-dead-contrib:repeatn, r=lcnr,workingjubilee 6b21b5a8ae8 Merge from rustc 8debc5c7059 Rollup merge of #130448 - alilleybrinker:master, r=workingjubilee 13a81535cb3 Update library/alloc/src/sync.rs 8b9948031e8 Auto merge of #127633 - SamuelMarks:eq-exit-code, r=dtolnay dc3dadb8d5a fix: Remove duplicate `LazyLock` example. cd16514dd7a Rollup merge of #127879 - kornelski:bad-pointer-printf, r=workingjubilee 9ae8ec9583e Merge from rustc 415dbcbb6f9 Auto merge of #130220 - RalfJung:float-classify, r=workingjubilee 28bee745ae5 update docs for `catch_unwind` & related funcs 318890a8c05 Rollup merge of #130339 - CAD97:unwind-choice, r=dtolnay fa7412b8633 simplify abort_unwind 4500781cbfe Rollup merge of #129439 - okaneco:vec_string_lossy, r=Noratrieb 6cd412b20a8 Rollup merge of #130381 - workingjubilee:sometimes-code-really-is-self-descriptive, r=Noratrieb 14e6aea6989 Rollup merge of #130118 - RalfJung:unwrap_unchecked, r=Noratrieb 081aac1341e Rollup merge of #129195 - RalfJung:const-mut-refs, r=fee1-dead 13e7b7c72d8 also stabilize const_refs_to_cell d17754a162a const_refs_to_cell: dont let mutable references sneak past the interior mutability check 5a6a7c1152c stabilize const_mut_refs 2f31502877c library: Compute Rust exception class from its string repr b3678aebec7 Rollup merge of #130214 - RalfJung:zeroed, r=Mark-Simulacrum f711021875e Rollup merge of #130061 - theemathas:box_vec_non_null, r=MarkSimulacrum,workingjubilee b4b1c900cb5 Rollup merge of #130042 - lolbinarycat:bufreaker_peek_eof, r=Amanieu 8a125db153c Add tracking issue number for `box_vec_non_null` 2f166450ebd std::net: Solaris supports `SOCK_CLOEXEC` as well since 11.4. 5862a8a5cf7 Rollup merge of #130290 - passcod:stabilise-entry-insert, r=ChrisDenton e154a53ec16 Rollup merge of #130268 - RalfJung:simd-shuffle-idx-vector, r=compiler-errors ca9bad97bcd simd_shuffle: require index argument to be a vector ec888301df7 Rollup merge of #130053 - glowcoil:next_if-docs, r=jhpratt 35e673983d1 add std::panic::abort_unwind fc34e086af5 add core::panic::abort_unwind a30f892e20c Merge from rustc 8ea5f87594f Rustfmt 0e574641750 [`cfg_match`] Generalize inputs 726aa2913ea Fix awkward wording. cce64249186 Address WaffleLapkin's comments d96e2fabcaf Update tests for hidden references to mutable static 17c6de8781a Rollup merge of #130245 - RalfJung:miri-alloc-backtrace, r=Amanieu 6a1ae78920f Stabilize entry_insert 808ed102311 Auto merge of #130281 - matthiaskrgr:rollup-1b2ibs8, r=matthiaskrgr 5008d2c8225 Rollup merge of #130101 - RalfJung:const-cleanup, r=fee1-dead 1f198574e5a Document subtleties of `ManuallyDrop` 6e8924266e6 Stabilize `const_float_classify` d3bb95bde20 Auto merge of #129992 - alexcrichton:update-compiler-builtins, r=tgross35 ca8011160d4 also update the wrapping_ docs to use similar wording 15a96948255 Rollup merge of #130160 - Scripter17:fix-slice-first_mut-doc, r=Amanieu 6f2f07ce1fa Rollup merge of #125060 - ChrisJefferson:pathbuf-doc, r=workingjubilee f728d10b69f simplify float::classify logic 20bd95433c9 Fixup docs for PathBuf 83c4188c018 Expand PathBuf documentation e33b994058e Merge from rustc c922e61e145 Auto merge of #130183 - Marcondiro:unicode-16.0.0, r=Manishearth 71c4dfe1af9 Rollup merge of #130248 - nyurik:fix-129895, r=workingjubilee a83b89e7d2a Rollup merge of #130168 - juliusl:pr/fix-win-fs-change-time-links, r=ChrisDenton cfb76db3028 Rollup merge of #130077 - madsmtm:watchos-arm-unwind, r=workingjubilee 43e088cf2ef Rollup merge of #129835 - RalfJung:float-tests, r=workingjubilee e755a0bf21a Rollup merge of #129696 - RalfJung:stdarch, r=Amanieu b91fa30233f Limit `libc::link` usage to `nto70` target only, not NTO OS 1286b91e558 various updates based on review 653f5c04682 make basic allocation functions track_caller in Miri for nicer backtraces ef1e130588d chore: remove struct details 9b3d8b296bf Rollup merge of #130207 - GrigorenkoPV:ERROR_CANT_RESOLVE_FILENAME, r=ChrisDenton 1bfb406ce87 Rollup merge of #130206 - GrigorenkoPV:WSAEDQUOT, r=ChrisDenton 80608f87a79 Rollup merge of #129866 - root-goblin:patch-1, r=workingjubilee 994dcbd4f6d docs: remove struct info 14c90229516 ptr::add/sub: these are *not* equivalent to offset(count as isize) 3e0efeff682 update stdarch a4b78a35ecc MaybeUninit::zeroed: mention that padding is not zeroed 694ae80c8e6 clean up internal comments about float semantics bedc508604a these tests seem to work fine on i586 these days b4982cd54ba Auto merge of #129403 - scottmcm:only-array-simd, r=compiler-errors 5011dce3ea4 Stabilize `std::io::ErrorKind::CrossesDevices` dec6aa6adc6 Clarify docs for std::collections 2f1da8f9c04 Map `ERROR_CANT_RESOLVE_FILENAME` to `ErrorKind::FilesystemLoop` f006b818f2b Map `WSAEDQUOT` to `ErrorKind::FilesystemQuotaExceeded` 652090976e1 Auto merge of #130025 - Urgau:missing_docs-expect, r=petrochenkov ee2d5a74faa Bump unicode printable to version 16.0.0 3120e49d456 Bump unicode_data to version 16.0.0 ec4bcd8fdea Auto merge of #130179 - workingjubilee:rollup-l78cv44, r=workingjubilee ddeeec94f31 Ban non-array SIMD 5964013efe7 Rollup merge of #130164 - RalfJung:const_ptr_as_ref, r=dtolnay 6c0d8748c9b Rollup merge of #130146 - folkertdev:bootstrap-naked-asm, r=Amanieu c603fca78dd Rollup merge of #130132 - sunshowers:illumos-sigsegv, r=Noratrieb 80be4077fa0 Rollup merge of #128316 - GrigorenkoPV:io_error_a_bit_more, r=dtolnay 14fd320395c Auto merge of #129778 - RalfJung:interp-lossy-typed-copy, r=saethlin 55be9ad0ad7 chore: removing supporting links in favor of existing doc-comment style dd64b58e1cb maint: update docs for change_time ext and doc links 6806ccfc1dc Rollup merge of #130154 - okaneco:stabilize_char_min, r=cuviper 2f27188b571 Rollup merge of #130067 - madsmtm:clean-up-fs-test, r=ChrisDenton 75905345337 move const fn with a null check into const_ptr_is_null gate 76d50e683a5 move some const fn out of the const_ptr_as_ref feature ffc67f99eb2 Fix slice::first_mut docs pointer -> reference 50537f36760 Stabilize `char::MIN` 6127321b16c fix UB in a test 530568d0883 Add missing `#[allow(missing_docs)]` on hack functions in alloc 056258c24dc `RepeatN`: use MaybeUninit 0c59be0640c bootstrap `naked_asm!` for `compiler-builtins` 02a1dad78fe Rollup merge of #130115 - eduardosm:needless-returns-libs, r=workingjubilee 91f2b3cb3af Rollup merge of #130107 - RalfJung:const-ptr-is-null, r=oli-obk 304f26b2c16 Rollup merge of #130090 - RalfJung:result-copied, r=Noratrieb 9996b2a1159 Rollup merge of #130087 - RalfJung:option-const-iter, r=workingjubilee 8f398d2dd68 [illumos] enable SIGSEGV handler to detect stack overflows 92fd62600c1 remove const_slice_index annotations, it never had a feature gate anyway 00991173d40 add FIXME(const-hack) 8579656e71a move Option::unwrap_unchecked into const_option feature gate 2a7e0db64c8 Remove needless returns detected by clippy in libraries 8c9bffb81e2 const: make ptr.is_null() stop execution on ambiguity 222c4b495f4 Option, Result: put the &mut variants of 'copied' under the same feature as the '&' variants 5eea2f9715d Auto merge of #130002 - orlp:better-div-floor-ceil, r=thomcc fa00d6bb430 Auto merge of #129019 - kromych:master, r=workingjubilee 297c3d4fc00 Fix linking error when compiling for 32-bit watchOS 9a4c7801a8e remove pointless rustc_const_unstable on trait impls 027ba00eb4b add some FIXME(const-hack) 2a525c713d6 Auto merge of #130091 - matthiaskrgr:rollup-kalu1cs, r=matthiaskrgr c601619b722 Rollup merge of #130047 - ChrisDenton:win-dbghelp, r=wesleywiser e50a342ee8e Rollup merge of #130046 - RalfJung:const_str_as_mut, r=dtolnay 775876bfb98 Rollup merge of #129555 - RalfJung:const_float_bits_conv, r=dtolnay e4154269224 Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68 d52105b93b1 make Result::copied unstably const 36a8a6ef3de remove 'const' from 'Option::iter' 287bba962e4 str: make as_mut_ptr and as_bytes_mut unstably const 6cac4eb62c0 restate GlobalAlloc method safety preconditions in terms of what the caller has to do for greater clarity cd67f72bb4f Remove now redundant check in symlink_hard_link test 0501c268cb4 Add `NonNull` convenience methods to `Vec` 7444d68e573 Add `NonNull` convenience methods to `Box` dbc3687ad19 fix doc comments for Peekable::next_if(_eq) 3396adea7f5 Remove duplicate impl e208fc465ea remove the Clone requirement 5fe8431b86e Win: Add dbghelp to the list of import libraries 7a1114be9a6 properly handle EOF in BufReader::peek ec1e2ae4e1f [library/std/src/process.rs] Remove `Eq` `derive` 0f66aa38300 Adjust doc comment of Condvar::wait_while 011b3a0924c Rollup merge of #129963 - rjooske:fix/inaccurate_to_string_lossy_doc, r=workingjubilee 2a17fe081ae Auto merge of #129999 - matthiaskrgr:rollup-pzr9c8p, r=matthiaskrgr 00779994b42 Break into the debugger (if attached) on panics (Windows, macOS, Linux, FreeBSD) db3a823ed83 better implementation of signed div_floor/ceil 6367df535df Rollup merge of #129947 - LiterallyVoid:duration-docs-digit-separators, r=tgross35 3175bd01bb8 Rollup merge of #129653 - RalfJung:addr-of-read-only, r=scottmcm b753331ffec Rollup merge of #129938 - chancancode:patch-1, r=thomcc 40b5ac72b26 [library/std/src/process.rs] Update docstring with @joshtriplett's replacement text 964eed641d1 Update compiler-builtins to 0.1.125 6aa87635d7e update cfgs 0d249297962 Rollup merge of #129919 - kevinmehall:waker-getters, r=dtolnay 2048f07cdeb Rollup merge of #127021 - thesummer:1-add-target-support-for-rtems-arm-xilinx-zedboard, r=tgross35 2bbbc1906ee Rollup merge of #101339 - the8472:ci-randomize-debug, r=Mark-Simulacrum c074731e164 Use non-overlapping swap for inner heapsort loop 5f4b5233ff3 Select tiny sorts for 16-bit platforms 243b9752c6c Shrink heapsort further by combining sift_down loops 644eadc0a13 Drop bubble_sort b6e1e4308ea fix: correct {Path,OsStr}::to_string_lossy() docs 9ce11701d9b Remove macOS 10.10 dynamic linker bug workaround f28271726b7 docs: add digit separators in `Duration` examples 5b178320938 replace placeholder version eb3c39363b4 Update marker.rs 2aa7ca420e0 Update marker.rs 1ef4eae0e47 Update marker.rs ca8d3476f7b Update marker.rs 5102003925c Elaborate on deriving vs implementing `Copy` 658443edc7f Win: Open dir for sync access in remove_dir_all 2fe792b97e9 More robust extension checking a7a584e50c1 Port std library to RTEMS 03a42a1280f Rollup merge of #129916 - tshepang:basic-usage, r=ChrisDenton 64665ed1731 Rollup merge of #129913 - saethlin:l4re-read-buf, r=Noratrieb 43fceea2892 Rollup merge of #129885 - cuishuang:master, r=scottmcm 4744ba8d6d7 Rollup merge of #129800 - ChrisDenton:remove-dir-all2, r=Amanieu b4ff1296ac2 Add `Waker::new` and `LocalWaker::new` c5c983825dd Stabilize waker_getters d4f49982f1d Move the `data` and `vtable` methods from `RawWaker` to `Waker` bf7a0d78554 process.rs: remove "Basic usage" text where not useful 9aaba52cb5b Rollup merge of #129907 - saethlin:solid-io-error, r=WaffleLapkin 0cd893fe688 Rollup merge of #129892 - oskgo:clarify-slice-from-raw, r=RalfJung 277bcbb8c6e Rollup merge of #129890 - alex:patch-1, r=workingjubilee dd276b9ebc1 Rollup merge of #129856 - RalfJung:compiler_fence, r=thomcc 2a6ebcb3047 Rollup merge of #129748 - RalfJung:box-validity, r=workingjubilee fca8dc539d3 Add missing read_buf stub for x86_64-unknown-l5re-uclibc 7b67f3bb013 Fix compile error in solid's remove_dir_all 373c1393bae clarify language around non-null ptrs in slice::raw 69414d79f36 Remove stray word in a comment d651c5abc81 Auto merge of #129873 - matthiaskrgr:rollup-bv849ud, r=matthiaskrgr 0b251c8d7e5 chore: remove repetitive words 73d9ea2b77b Rollup merge of #129804 - ranger-ross:fixed-documentation-typos, r=Noratrieb 33282045d4f Rollup merge of #129793 - lolbinarycat:doc-missing-newlines, r=workingjubilee 20a2be48afd Auto merge of #129063 - the8472:cold-opt-size, r=Amanieu 9861ca7d21e add extra linebreaks so rustdoc can identify the first sentence ac5ff376b47 compiler_fence documentation: emphasize synchronization, not reordering 4b25e625a67 stabilize const_float_bits_conv 2aef21e4333 tweak wording regarding Box validity c1a80e44185 Auto merge of #127897 - nyurik:add-qnx-70-target, r=saethlin 83a615e3288 Rollup merge of #129832 - eduardosm:stray-dot, r=jhpratt 1478da45476 Rollup merge of #129207 - GrigorenkoPV:elided-is-named, r=cjgillot af16853eb47 Rollup merge of #128641 - Konippi:standardize-duplicate-processes-in-parser, r=scottmcm d2c9ededb67 Rollup merge of #128495 - joboet:more_memcmp, r=scottmcm 5f99e2ab81b when -Zrandomize-layout is enabled disable alloc test testing internal struct sizes 6858fd9e32c Auto merge of #129831 - matthiaskrgr:rollup-befq6zx, r=matthiaskrgr c6851402ad3 Remove stray dot in `std::char::from_u32_unchecked` documentation 390ec823299 Rollup merge of #129826 - Alcaro:patch-1, r=workingjubilee fcfe49103c1 Rollup merge of #129650 - Zalathar:profiler-builtins, r=Mark-Simulacrum 55554072c04 Update mod.rs 2dbd4c854bb Rollup merge of #129785 - RalfJung:miri-sync, r=RalfJung c9a22277746 Rollup merge of #129730 - RalfJung:float-arithmetic, r=workingjubilee f06790bfc7a Fix `elided_named_lifetimes` in code 00f20fff9b4 Improve documentation for ::from_str_radix a70268bbd70 Move remove_dir_all impl into a module 064ade6e1be Rollup merge of #129754 - alexcrichton:fix-wasi-long-sleep, r=workingjubilee 8423db1f900 Rollup merge of #129675 - lolbinarycat:bufreader_peek_unsized, r=workingjubilee 38ab46d7b77 Rollup merge of #129642 - workingjubilee:bump-backtrace-fc37b22, r=workingjubilee 3dcfdb9b0a3 Rollup merge of #129640 - saethlin:unignore-android-in-alloc, r=tgross35 665b9590c93 Fixed more typos in library/core 242239ee59c Fixed typos in btree map docs c8d5cf997f0 Fixed some typos in the standard library documentation/comments 88841d2c6b6 enumerate the two parts of the NaN rules 992d4f1a95e add hyphen in floating-point 7e237e5c023 Squashed `aarch64_unknown_nto_qnx700` support 2f29b061d4c Merge from rustc eaa15ca8fb2 add new_cyclic_in for Arc 58523b9c624 improve comments b3205ca535a fix new_cyclic_in for rc 4a60bb035fb fix fmt ef9462885b0 Try latest backtrace 36e8c7c3336 wasi: Fix sleeping for `Duration::MAX` d73c872bdea Rollup merge of #128166 - ChaiTRex:isqrt, r=tgross35 e2a5b0bbb8b Rollup merge of #123940 - kornelski:remove-derived-debug, r=Urgau 740e795e67a Box validity: update for new zero-sized rules 4c93191fa87 Use simpler branchy swap logic in tiny merge sort eddf6d5f919 f32 docs: define 'arithmetic' operations 4b291d6f069 Merge from rustc 166b68c10f5 Speed up `checked_isqrt` and `isqrt` methods 6087f69529b Improve `isqrt` tests and add benchmarks 54d1f9253fb Rollup merge of #129715 - Amjad50:update-compiler-builtins, r=tgross35 7cbc4948be0 Rollup merge of #129683 - RalfJung:copysign, r=thomcc d311606f688 Rollup merge of #129673 - matthewpipie:arc-weak-debug-trait, r=dtolnay 9e38b025d38 Rollup merge of #129401 - workingjubilee:partial-initialization-of-stabilization, r=dtolnay,joboet 6b6b3f22ef1 Rollup merge of #129378 - goffrie:patch-3, r=ChrisDenton 2cb3a9c2227 Rollup merge of #128192 - mrkajetanp:feature-detect, r=Amanieu 124d50c3e3b add guarantee about remove_dir and remove_file error kinds 1469c6580b5 Update `compiler_builtins` to `0.1.123` 7f10ca4cfd1 fmt-debug option 93d40ff68c0 allow BufReader::peek to be called on unsized types 130a3ca6dbf Auto merge of #129691 - matthiaskrgr:rollup-owlcr3m, r=matthiaskrgr a66c791f20a Rollup merge of #129668 - coolreader18:fix-pin-set-regr, r=dtolnay 644ff62467a Rollup merge of #129657 - jswrenn:transmute-name, r=compiler-errors 384329f8c78 Rollup merge of #129551 - RalfJung:ub-checks-fallback, r=saethlin 7cfdba273b7 Rollup merge of #129480 - lolbinarycat:euclid-docs, r=joboet 750f42f1c0f Enable some ilog2 tests as well 3f3e230c893 Re-enable android tests/benches in alloc 38d85b8d20f Auto merge of #129589 - saethlin:improve-panic-immediate-abort, r=tgross35 b0d0b0ab75d copysign with sign being a NaN is non-portable 652fa925944 addr_of on places derived from raw pointers should preserve permissions 4793c829a66 add new_cyclic_in for rc 236a9686348 Add fmt::Debug to sync::Weak 7a42c65341c Fix Pin::set bounds regression a662ff342f8 library: Stabilize new_uninit for Box, Rc, and Arc 5b984073c88 Rollup merge of #129652 - RalfJung:ptr-to-ref, r=traviscross 1a705e551de Rollup merge of #129645 - beetrees:fix-float-docs, r=tgross35 3ef7c4d46d5 Rollup merge of #129581 - RalfJung:exit, r=joshtriplett a57503fa3c1 safe transmute: Rename `BikeshedIntrinsicFrom` to `TransmuteFrom` 5f151e3963b Auto merge of #128134 - joboet:move_pal_alloc, r=cupiver e2a44a10682 fix Pointer to reference conversion docs 948f5e4c8b1 clarify that addr_of creates read-only pointers 6d95f002ecb rustc_target: Add SME aarch64 features 744216ccbc5 rustc_target: Add various aarch64 features 4cc9c2cc5f4 std: move allocators to `sys` b400f1d3bb5 Use last swap optimization in bubblesort d6b5750c5f2 Don't skip nonexistent source files a422642973b Add `cargo::rerun-if-changed` directives for source directories 8e5a2edfc3c Always include `WindowsMMap.c` in the list of source files 46b8b094dc1 Sort the list of source files 248e17f6a25 Remove `InstrProfilingBiasVar.c` from the list of source files 91f21a615e9 Use helper functions to read environment variables 9e12fe4ca24 Rollup merge of #129559 - RalfJung:float-nan-semantics, r=thomcc 16b9979a6b5 Rollup merge of #128731 - RalfJung:simd-shuffle-vector, r=workingjubilee 68374cf1509 Update old comment referring to `libcompiler_builtins` c1ac3cbf2e3 Reflow a couple of paragraphs in floating-point primitive docs a03301b4a89 Fix typos in floating-point primitive type docs 0315ee48274 Bump backtrace to rust-lang/backtrace@fc37b22 82c0fdc4fb8 Rollup merge of #129032 - jswrenn:transmute-method, r=compiler-errors b1d91a12835 Rollup merge of #128157 - lolbinarycat:unify-ptr-ref-docs, r=cuviper 47597bc454f Apply suggestions from code review 07f1f4caf6d Rollup merge of #129592 - saethlin:core-cfg-test, r=tgross35 3712a4bdf71 Rollup merge of #129588 - hermit-os:sleep-micros, r=workingjubilee 1940245ff49 Rollup merge of #129539 - oconnor663:poll_link, r=tgross35 3eba097623b Rollup merge of #129377 - chorman0773:unbounded-shifts-impl, r=scottmcm 21cbeb01641 also update copysign docs 57fbf9f156f move per-target NaN info into a table e059c218c60 float types: document NaN bit pattern guarantees 4fa6beeaa7a Convert cfg blocks to cfg_if 913e71d30a2 Reduce code duplication by moving partition_lomuto_branchless_simple into quicksort module 70c2c74c564 Auto merge of #129595 - matthiaskrgr:rollup-4udn7nn, r=matthiaskrgr c8e13fa37da Remove cfg(test) from library/core 26826b66c2a Rollup merge of #129544 - mu001999-contrib:dead-code/clean, r=compiler-errors a4b0c3fb88a Rollup merge of #129525 - notriddle:notriddle/fake-variadic-tuple-array, r=GuillaumeGomez b4f49879725 Auto merge of #129488 - saethlin:alignment-precondition, r=workingjubilee 82410543b7a pal/hermit: saturate `usleep` microseconds at `u64::MAX` 2437672cac9 Auto merge of #129563 - matthiaskrgr:rollup-t6bai2d, r=matthiaskrgr 76738378de5 Tweak some attributes to improve panic_immediate_abort e4c312e8085 pal/hermit: correctly round up microseconds in `Thread::sleep` ee398c8ba44 Add binary-size optimized variants for stable and unstable sort as well as select_nth_unstable af17f11698e exit: explain our expectations for the exit handlers registered in a Rust program ab7bbc7a73a link to Future::poll from the Poll docs 3772dfa06ac Rollup merge of #129487 - GrigorenkoPV:repr_transparent_external_private_fields, r=compiler-errors d312144ea04 Rollup merge of #129416 - workingjubilee:partial-move-from-stabilization, r=dtolnay a34b2e29293 Rollup merge of #129091 - RalfJung:box_as_ptr, r=Amanieu 88a77b4ddaf Auto merge of #129295 - Zalathar:profiler-builtins, r=Kobzol 7026c00e21b ub_checks intrinsics: fall back to cfg(ub_checks) 5ada832513c Auto merge of #129521 - matthiaskrgr:rollup-uigv77m, r=matthiaskrgr 096bc19aad8 Removes dead code from the compiler 9370acb6644 Rollup merge of #129481 - scottmcm:update-cb, r=tgross35 1df7ca331c9 Rollup merge of #129449 - coolreader18:pin-as_deref_mut-signature, r=dtolnay 6fe2feae5f2 Rollup merge of #128735 - jieyouxu:pr-120176-revive, r=cjgillot e09bc4f913b rustdoc: clean up tuple <-> primitive conversion docs 055f7543a3f Rollup merge of #129501 - RalfJung:miri-rust-backtrace, r=Noratrieb 3d096ea19b2 Rollup merge of #129500 - fee1-dead-contrib:fxrel, r=compiler-errors 191ab151c49 Rollup merge of #129323 - Urgau:ptr_fn_addr_eq, r=Mark-Simulacrum 9b45a4aae30 Rollup merge of #128596 - RalfJung:const_fn_floating_point_arithmetic, r=nnethercote 1e1096adb3f New `#[rustc_pub_transparent]` attribute d174ffe31a5 panicking: improve hint for Miri's RUST_BACKTRACE behavior 1e0c44e7873 Build `library/profiler_builtins` from `ci-llvm` if appropriate 4c9421463b9 remove invalid `TyCompat` relation for effects fc22430dd0a library: Move unstable API of new_uninit to new features 9c5e62922b8 Pass `fmt::Arguments` by reference to `PanicInfo` and `PanicMessage` dfd85e409c1 Enable Alignment::new_unchecked precondition check 05be4c0c413 Change `f16` doctests in core to run on x86-64 linux 6d4bbc82118 Update `compiler_builtins` to `0.1.121` 9a2e222d783 Enable `f16` tests on x86 and x86-64 68691d074f0 docs: correct panic conditions for rem_euclid and similar functions 53944870798 Move into_inner_unchecked back to the bottom of the impl block 626990860ca Put Pin::as_deref_mut in impl Pin dbe265f7b9f document & impl the transmutation modeled by `BikeshedIntrinsicFrom` 939808dccc6 Auto merge of #129464 - GuillaumeGomez:rollup-ckfqd7h, r=GuillaumeGomez b72f81d354f Rollup merge of #129276 - eduardosm:stabilize-char_indices_offset, r=Amanieu e519e9571b2 Rollup merge of #129400 - Amjad50:update-compiler-builtins, r=tgross35 50fe9bd67b2 Rollup merge of #127623 - lolbinarycat:fix_remove_dir_all, r=Amanieu 3b474caac66 Implement feature `string_from_utf8_lossy_owned` 0b9876d757b Check that `library/profiler_builtins` actually found some source files 9853f38e165 fix typos in new pointer conversion docs 6d1903e84f0 fix: fs::remove_dir_all: treat ENOENT as success fe13c4226e5 Update chown help with a link and adding cap warning 8f948b18416 Expand std::os::unix::fs::chown() doc with a warning 2324fc912f8 feat(core): Make `unbounded_shl{l,r}` unstably const and remove `rustc_allow_const_fn_unstable` c260d53ab7c Auto merge of #129398 - matthiaskrgr:rollup-50l01ry, r=matthiaskrgr 8340ebba171 Update `compiler_builtins` to `0.1.120` d1968df3ce5 stabilize const_fn_floating_point_arithmetic b7e75fe4bd6 Rollup merge of #129382 - tgross35:once-cell-const-into-inner, r=Noratrieb 38a5f44ec09 Rollup merge of #129376 - ChaiTRex:assert_unsafe_precondition_check_language_ub, r=workingjubilee,the8472 408a5880403 Rollup merge of #129374 - ChaiTRex:digit_unchecked_assert_unsafe_precondition, r=scottmcm 8bb85912c52 Rollup merge of #128432 - g0djan:godjan/wasi_prohibit_implicit_unsafe, r=tgross35 53e5cea543b Auto merge of #129365 - matthiaskrgr:rollup-ebwx6ya, r=matthiaskrgr 4890dc20359 fix(core): Use correct operations/values in `unbounded_shr` doctests 59ff965ddbc chore: `x fmt` cbd3f431a10 fix(core): Add `#![feature(unbounded_shifts)]` to doctests for `unbounded_shr`/`unbounded_shl` 27257fdb520 Add `const_cell_into_inner` to `OnceCell` 56015b438e5 format 3eccf63bb06 chore: `x fmt` and hopefully fix the tidy issue 48c9ba5dc3c Clean up cfg-gating of ProcessPrng extern 9051cf40628 Change `assert_unsafe_precondition` docs to refer to `check_language_ub` 3a17a9c8bb2 chore: Also format the control flow db432259ae3 Manually format functions and use `rhs` instead of `v` from my CE testing f38408179c9 feat(core): Add implementations for `unbounded_shl`/`unbounded_shr` 0c2922107d3 Use `assert_unsafe_precondition!` in `AsciiChar::digit_unchecked` 5e89712b0cd Rollup merge of #129321 - krtab:float_sum, r=workingjubilee 9e0eb8284ca Rollup merge of #129232 - ivmarkov:master, r=workingjubilee 95f63db9ef0 Rollup merge of #127945 - tgross35:debug-more-non-exhaustive, r=Noratrieb f1f1930ea2e Rollup merge of #129332 - cuviper:cstr-cast, r=compiler-errors a83c0af5ee7 Rollup merge of #129312 - tbu-:pr_str_not_impl_error, r=Noratrieb 9a9bf528f16 Fix stability attribute of `impl !Error for &str` 351253ba4eb Auto merge of #126556 - saethlin:layout-precondition, r=joboet 27e8ab60483 Auto merge of #128866 - scottmcm:update-stdarch, r=tgross35 cf2fa1e089d Update stdarch submodule bce4bc9074f Try to golf down the amount of code in Layout 6e5a426c8c3 Avoid extra `cast()`s after `CStr::as_ptr()` 38ee2990dab Rollup merge of #129294 - scottmcm:stabilize-repeat-n, r=Noratrieb 6dfae02cea1 Implement `ptr::fn_addr_eq` d0d6a28886d Change neutral element of to neg_zero e448032a82d Stabilize `iter::repeat_n` 504177bdde8 Auto merge of #129226 - RalfJung:libc, r=Mark-Simulacrum c6f84d9089b Add a precondition check for Layout::from_size_align_unchecked 75a82da830c Stabilize feature `char_indices_offset` 93259c6b2e4 docs: Mention `spare_capacity_mut()` in `Vec::set_len` 80763169efb library: bump libc dependency 4b33e84dd93 Rollup merge of #128902 - evanj:evan.jones/env-var-doc, r=workingjubilee a2778332a62 Document futility of printing temporary pointers dfbb13d07bd soft-deprecate the addr_of macros 8494214eee5 code review improvements 378915b33f4 Fix for issue #129212 for the ESP-IDF e47671b28c9 Auto merge of #126877 - GrigorenkoPV:clone_to_uninit, r=dtolnay 3c2e362e116 Auto merge of #128598 - RalfJung:float-comments, r=workingjubilee bb176166959 Auto merge of #106943 - mina86:exact_size_take_repeat, r=dtolnay 9a8383abdf8 Auto merge of #116528 - daxpedda:stabilize-ready-into-inner, r=dtolnay 4991f26b321 Rollup merge of #129161 - dtolnay:spawnunck, r=Noratrieb 17758faec87 Rollup merge of #129086 - slanterns:is_none_or, r=dtolnay 9b19a764c8d Stabilize std::thread::Builder::spawn_unchecked 0c3e6c73e9b Refer to other docs 5812090f368 float to/from bits and classify: update comments regarding non-conformant hardware 50dd73fa5a2 Rollup merge of #128064 - ijackson:noop-waker-doc, r=workingjubilee 8de2e77d014 Add cautionary paragraph about noop wakers. 07e5a84e984 Add unordered list with possible values for each const 54af1bb5262 Format std::env::consts docstrings d627900b320 Rollup merge of #128946 - orlp:faster-ip-hash, r=joboet 1e5b80f2923 Rollup merge of #128925 - dingxiangfei2009:smart-ptr-helper-attr, r=compiler-errors 789187f75ba Rollup merge of #125970 - RalfJung:before_exec, r=m-ou-se 5bac39aeeff size-optimize some of the panic dependencies fc448173fff apply #[optimize(size)] to #[cold] ones and part of the panick machinery 5675912e948 Rollup merge of #128954 - zachs18:fromresidual-no-default, r=scottmcm 1c4fc5fe0ba Rollup merge of #128570 - folkertdev:stabilize-asm-const, r=Amanieu d5156f97a37 add Box::as_ptr and Box::as_mut_ptr methods ef3f7046749 CommandExt::before_exec: deprecate safety in edition 2024 3fcf0015f0c stabilize `option_get_or_insert_default` 7cce06da658 stabilize `is_none_or` db6b6755226 Auto merge of #129060 - matthiaskrgr:rollup-s72gpif, r=matthiaskrgr 318ac5bc733 Rollup merge of #129001 - cblh:fix/128713, r=Noratrieb 4ef186e792f Rollup merge of #128873 - ChrisDenton:windows-targets, r=Mark-Simulacrum b81bb4200d8 Rollup merge of #128759 - notriddle:notriddle/spec-to-string, r=workingjubilee,compiler-errors 55f877ee9b4 Make `std::os::darwin` public 66fa19a8adf stabilize `asm_const` f2af1e69112 Rollup merge of #129034 - henryksloan:coroutine-must-use, r=joboet bac5c9819fb Rollup merge of #127857 - tbu-:pr_deprecated_safe_todo, r=petrochenkov 082ad2571e2 Rollup merge of #122884 - mzabaluev:pow-remove-exit-branch, r=Amanieu ca63f50f5ba Reduce merged doctest source code size ab9f180f02e Mark location doctest as standalone since file information will not work in merged doctest file dfef63484be Auto merge of #129046 - matthiaskrgr:rollup-9x4xgak, r=matthiaskrgr bdf3f2c47bc Rollup merge of #128745 - dtolnay:spawnunchecked, r=workingjubilee e55dda652fc Rollup merge of #128655 - joboet:play_with_the_dice, r=ChrisDenton 640245a4b24 `#[deprecated_safe_2024]`: Also use the `// TODO:` hint in the compiler error 383ad0170ba Allow to customize `// TODO:` comment for deprecated safe autofix f757e4b92f1 Auto merge of #128962 - devnexen:fs_get_mode_haiku, r=workingjubilee 1102a86a7ba simd_shuffle intrinsic: allow argument to be passed as vector (not just as array) f85ba7f626b Revert to original loop for const pow exponents 009fff79778 Auto merge of #128742 - RalfJung:miri-vtable-uniqueness, r=saethlin 990928b56df Add must_use attribute to Coroutine trait cdbcac03b2d chore(lib): fmt core::fmt::Formatter's write_fmt method ec6136d8504 trying common codepath for every unixes b66a34e7232 std::fs: get_mode implementation for haiku. 298a9f89c08 Rollup merge of #129017 - its-the-shrimp:core_fmt_from_fn, r=Noratrieb 564284f3e1d derive(SmartPointer): register helper attributes bdd680e91bd Explicitly specify type parameter on FromResidual impls in stdlib. 18e2fecb1b0 std::fmt::FormatterFn -> std::fmt::FromFn 232ae7c397d Rollup merge of #128632 - joboet:dont_overwrite_style, r=Amanieu c7084c356ed Rollup merge of #128149 - RalfJung:nontemporal_store, r=jieyouxu,Amanieu,Jubilee 6fba985a0c8 chore(lib): Enhance documentation for core::fmt::Formatter's write_fmt method 8a7e1f688ef ignore some vtable/fn ptr equality tests in Miri, their result is not fully predictable 7f6f1c6e3b1 std: use `/scheme/rand` on Redox 8b10b89d729 core: make documentation clearer, rename slice comparison specialization trait 4842d4a191f std: do not overwrite style in `get_backtrace_style` 22f885e18fe Auto merge of #128862 - cblh:fix/128855, r=scottmcm 8ea3420cee7 Auto merge of #126793 - saethlin:mono-rawvec, r=scottmcm ccdf75f5a02 Do not use unnecessary endian conversion. 8e6a2ca71e7 Rollup merge of #128882 - RalfJung:local-waker-will-wake, r=cuviper 89b41120469 Rollup merge of #120314 - mina86:i, r=Mark-Simulacrum 0c6abd61628 Fix stability annotation and expand comment 60a3231f02c Hash Ipv*Addr as an integer 3683073939d Auto merge of #128927 - GuillaumeGomez:rollup-ei2lr0f, r=GuillaumeGomez f8bb3e4c600 Rollup merge of #128273 - Voultapher:improve-ord-violation-help, r=workingjubilee 29a37e1ffb1 Update std and compiler 93755995548 Stabilize `min_exhaustive_patterns` 64f7a30fec5 Add an optimizer hint for the capacity that with_capacity_in returns 4a310c1e0b1 Hoist IS_ZST check out of RawVecInner::from_*_in 96a10680eba Polymorphize RawVec a2f75bd0ed7 core: optimise Debug impl for ascii::Char f6a04de0005 doc: std::env::var: Returns None for names with '=' or NUL byte 6ce1a878a5d Rollup merge of #128859 - MinxuanZ:mips-sig, r=Amanieu c8146e7e3b2 Rollup merge of #128817 - biabbas:vxworks_update, r=tgross35 391a4a43b76 make LocalWaker::will_wake consistent with Waker::will_wake d42ac671dbe Fix linkchecker issue d1be82044fe Exclude windows-targets from the workspace ac5c797c49d Add windows-targets crate to std's sysroot d584b6005f4 Rollup merge of #128824 - GuillaumeGomez:update-compiler-builtins, r=Amanieu 695dc79b8db VxWorks: Add safety comment for vxCpuEnabledGet d7657f31ebd fix: Ensure `Guard`'s `drop` method is removed at `opt-level=s` for `Copy` types f1fc8aca6de delete space aede520b667 fix format 5812e7c73dc [SPARC] fix the name of signal 19 in sparc arch 4db4f5c818e [MIPS] fix the name of signal 19 in mips ca23d80169f Rollup merge of #128818 - RalfJung:std-miri-floats, r=tgross35 1d01add8859 Rollup merge of #128640 - RalfJung:rwlock-macos-miri, r=joboet 2aa0b372f70 Rollup merge of #128749 - tgross35:float-inline, r=scottmcm f42422ac9a2 Rollup merge of #128306 - WiktorPrzetacznik:WiktorPrzetacznik-nonnull-alignoffset-update, r=Amanieu db9f3626010 Update compiler-builtins version to 0.1.118 d97fcb86588 std float tests: special-case Miri in feature detection fe69a039f6b Vxworks: Extern taskNameSet and fix build errors 45b1a4ccec6 rwlock: disable 'frob' test in Miri on macOS 40efa3caeba Fix VxWorks available parallelism: Move nonzero::uncheked into unsafe block d4d699dfd82 Rollup merge of #128800 - clarfonthey:core-pattern-type, r=compiler-errors 5275bfbf454 Rollup merge of #128691 - tgross35:update-builtins, r=Amanieu 62df599774b Add tracking issue to core-pattern-type 7410ef4cdf7 Stabilize `Ready::into_inner()` 837cdd2e74d Rollup merge of #128261 - clarfonthey:iter-default, r=dtolnay 9c418125961 alloc: make `to_string_str!` a bit less complex 48ed22f77cb Mark `{f32,f64}::{next_up,next_down,midpoint}` inline 34350f22609 Rollup merge of #128766 - Monadic-Cat:patch-1, r=tgross35 5aaa30287af Rollup merge of #128417 - tgross35:f16-f128-math, r=dtolnay 2572d6a4c11 Trivial grammar fix in const keyword docs 24dabb2746e Update `compiler-builtins` to 0.1.117 b54455a9aa4 Rollup merge of #128751 - devnexen:vxworks_set_thread_name, r=tgross35 bca1984f17c Rollup merge of #128539 - biabbas:deny_unsafe, r=workingjubilee 49d37c63087 Rollup merge of #128406 - lolbinarycat:bufreader_peek, r=Mark-Simulacrum 0f8f0f9eb97 Rollup merge of #125048 - dingxiangfei2009:stable-deref, r=amanieu fcd7bf5d734 alloc: add ToString specialization for `&&str` 74ea6ac2c72 std::thread: set_name implementation proposal for vxWorks. 94b127d1d83 Remove unused lifetime parameter from spawn_unchecked a4f2bc92ed4 Add a special case for CStr/CString in the improper_ctypes lint 646810c846d implement BufReader::peek 4e6e285df31 custom MIR: add support for tail calls ee5a14d1372 nontemporal_store: make sure that the intrinsic is truly just a hint 0da17e44b6a WASI fixing unsafe_op_in_unsafe_fn for std::{os, sys} 77dcb66a1c8 Auto merge of #128673 - matthiaskrgr:rollup-gtvpkm7, r=matthiaskrgr 4533bb39a30 Rollup merge of #128619 - glandium:last_chunk, r=scottmcm 0f501cca760 Rollup merge of #128609 - swenson:smaller-faster-dragon, r=Amanieu 30b5ff6730c Rollup merge of #128026 - devnexen:available_parallelism_vxworks, r=Mark-Simulacrum 9a51930633c Rollup merge of #128309 - kmicklas:btreeset-cursor, r=Amanieu 8503f57ea9b Correct the const stabilization of `<[T]>::last_chunk` 44d7086189b Auto merge of #128534 - bjorn3:split_stdlib_workspace, r=Mark-Simulacrum 5ee82a8fe10 std: refactor UNIX random data generation bbb348fec2f refactor: standardize duplicate processes in parser 17c4f9de7dd Rollup merge of #128526 - tshepang:patch-1, r=Amanieu 748940a9f91 Auto merge of #128466 - sayantn:stdarch-update, r=tgross35 90c10b9a0c1 Update stdarch 197cca13f0a Chore: add `x86_amx_intrinsics` feature flag to `core/lib.rs` and remove `issue-120720-reduce-nan.rs` 0cf3ba5cf16 Rollup merge of #128551 - Konippi:refactor-backtrace-style-in-panic, r=tgross35 da53468e595 Rollup merge of #128530 - scottmcm:repeat-n-unchecked, r=joboet 4e37707e619 Remove unnecessary constants from flt2dec dragon 38d2ca67f28 Apply review comments to PartialOrd section 10fc7d9df39 Auto merge of #128404 - compiler-errors:revert-dead-code-changes, r=pnkfelix c7d11466dbd Suppress new false-negatives that were masked by dead code analysis changes 34534415ef5 Revert "Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix" 53ab49074b4 Rollup merge of #128368 - nnethercote:rustfmt-tweaks, r=cuviper f7fd2123efc Rollup merge of #128303 - NobodyXu:specialise-for-pipe, r=cuviper ca78e2f7ac4 Rollup merge of #127586 - zachs18:more-must-use, r=cuviper da968e365f6 Rollup merge of #126704 - sayantn:sha, r=Amanieu 6c10336c215 Forbid unsafe_op_in_unsafe_fn in vxworks specific os and sys files 882086e7001 chore: refactor backtrace style in panic 2105bc1de1b Auto merge of #128528 - workingjubilee:you-dont-need-to-see-this-cpuid-move-along, r=Amanieu d08943bb5ef Move the standard library to a separate workspace bb0b11bbf40 Auto merge of #128254 - Amanieu:orig-binary-search, r=tgross35 deaecb5e3ec Implement `UncheckedIterator` directly for `RepeatN` 67c58aba0c2 Rollup merge of #128491 - c410-f3r:unlock-rfc-2011, r=workingjubilee 3b0dd8b9d8a Rollup merge of #128453 - RalfJung:raw_eq, r=saethlin e0fe54a3f95 std: Remove has_cpuid 940dce52031 time.rs: remove "Basic usage text" b908f13615c Dogfood c4757c898ed Add the `sha512`, `sm3` and `sm4` target features 9f46164a1ba Fix mutability in doc tests for `BTreeSet` cursors ec52fa2cbad Add a disclaimer about x86 `f128` math functions 7d9ec76e97f Update comments for `{f16, f32, f64, f128}::midpoint` 7f5ccd3172c Add `core` functions for `f16` and `f128` that require math routines 0200c30f81f Add math functions for `f16` and `f128` 1a98cbc5b21 Add math intrinsics for `f16` and `f128` 7ad436c050b Introduce `Cursor`/`CursorMut`/`CursorMutKey` thrichotomy for `BTreeSet` like map API e4851a25149 Fix some uses of "map" instead of "set" in `BTreeSet` cursor API docs f4f744d7a99 Share `UnorderedKeyError` with `BTReeMap` for set API 6d076653d58 Rollup merge of #128499 - Konippi:refactor-backtrace-formatting, r=tgross35 ccdbe22b348 Rollup merge of #128497 - Bryanskiy:fix-dropck-doc, r=lcnr 382e244c2d7 Rollup merge of #128433 - hermit-os:hermit-unsafe_op_in_unsafe_fn, r=joboet 6de0161280e Hide internal sort module 116a6a914f8 chore: refactor backtrace formatting 80b42b90f68 fix dropck documentation for `[T;0]` special-case 12bca4aadc8 core: use `compare_bytes` for more slice element types 6a030b07dc5 fix(os/hermit): `deny(unsafe_op_in_unsafe_fn)` b0c5a5f013f fix(pal/hermit): `deny(unsafe_op_in_unsafe_fn)` 3a941d589b0 refactor(pal/hermit): make `ENV` a non-mutable static f7a50821485 Rollup merge of #128416 - maurer:remove-android-hack, r=tgross35 8e869502574 Auto merge of #128461 - matthiaskrgr:rollup-3dpp11g, r=matthiaskrgr 3b43fe2ecf8 Rollup merge of #128162 - ChrisDenton:cleanup, r=joboet 07d2b8a2247 Rollup merge of #127567 - joboet:once_wait, r=Amanieu cb0b6a8f583 Fix docs for OnceLock::get_mut_or_init 6d978f4edaf raw_eq: using it on bytes with provenance is not UB (outside const-eval) 1ad84c8efd0 std: fix busy-waiting in `Once::wait_force`, add more tests 3aa6906f18b std: implement the `once_wait` feature c34a096f9e1 Remove unneeded `pub(crate)` b7cad9c901c Rollup merge of #128388 - beetrees:f16-f128-slightly-improve-windows-abi, r=tgross35 3c10157e7da Rollup merge of #128387 - liigo:patch-14, r=tgross35 37e0f33d876 refactor(pal/hermit): use default impl of `GlobalAlloc::alloc_zeroed` 2c01d42cc0f refactor(pal/hermit): return `!` to satisfy rust-analyzer 93111f7e6eb Apply review comments 33c3a666dfb PinCoerceUnsized trait into core 4feaf9f4644 android: Remove libstd hacks for unsupported Android APIs 41adb2c6d77 Move Windows implementation of anon pipe 06f0aec1cde Match LLVM ABI in `extern "C"` functions for `f128` on Windows 556c703171a Cleanup sys module to match house style 5c20021a5f1 Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68 d8547a65b70 Rewrite binary search implementation a4bec120e38 More detailed note to deprecate ONCE_INIT d51303ea5c6 Auto merge of #128378 - matthiaskrgr:rollup-i3qz9uo, r=matthiaskrgr ab8dc22f6b5 Auto merge of #128250 - Amanieu:select_unpredictable, r=nikic 5d89e4c0f57 Rollup merge of #128315 - zetanumbers:psvita-unsafe-in-unsafe, r=workingjubilee bbf5c3911e4 Auto merge of #128234 - jcsp:retain-empty-case, r=tgross35 08267292531 Insert some blank lines. 5c57394173d Move a comment. 652a819060d CloneToUninit: use a private specialization trait e5db7269d17 Sparkle some attributes over `CloneToUninit` stuff 0d61ebe02e8 impl CloneToUninit for Path and OsStr 18d828bf02d impl CloneToUninit for str and CStr 55b2a172c34 Stabilize offset_of_nested b8b1c593294 Auto merge of #128334 - matthiaskrgr:rollup-nhxdt0c, r=matthiaskrgr 99ec69bc710 Rollup merge of #128333 - RalfJung:miri-sync, r=RalfJung e63feb65414 Rollup merge of #128307 - ojeda:unescaped_backticks, r=GuillaumeGomez dee90f6f64d Optimize empty case in Vec::retain 1faa8fcbca5 Auto merge of #125016 - nicholasbishop:bishop-cb-112, r=tgross35 6f1e415072e Rollup merge of #128310 - kmicklas:btree-map-peek-next-docs, r=tgross35 c0ac8385d2a Rollup merge of #128055 - workingjubilee:deny-unsafe-ops-in-sys-personality-dwarf-eh, r=Amanieu 424e134edf3 Rollup merge of #109174 - soerenmeier:cursor_fns, r=dtolnay 22e2457bc54 Update compiler_builtins to 0.1.114 24e17f65c84 Warn on `rustdoc::unescaped_backticks` for `core/alloc/std/test/proc_macro` 3f7dd7fc625 Remove spurious backticks detected by `rustdoc::unescaped_backticks` 39005801f19 Reformat `use` declarations. 14b783300be Replace `io::Cursor::{remaining_slice, is_empty}` with `io::Cursor::{split, split_mut}` 695c7811718 Partially stabilize `io_error_more` e8a1953c058 step cfg(bootstrap) 62c28fc511b Update CURRENT_RUSTC_VERSION 4b78dc0f678 Add forbid(unsafe_op_in_unsafe_fn) 70284c77861 Rollup merge of #128240 - mbrubeck:patch-3, r=joboet 5e0da54401f Rollup merge of #128228 - slanterns:const_waker, r=dtolnay,oli-obk 8864086e484 Rollup merge of #128103 - folkertdev:unsigned-int-is-multiple-of, r=Amanieu 61ae611c116 Rollup merge of #127765 - bitfield:fix_stdlib_doc_nits, r=dtolnay 2b8d22a6622 fix: psvita's std code 8a3edf0e078 Force LLVM to use CMOV for binary search bf6aa407847 stabilize const_waker 553d1e2dce9 Add missing periods on `BTreeMap` cursor `peek_next` docs a78b7c12f64 Implement cursors for `BTreeSet` b8d2ffbdce7 Update NonNull::align_offset quarantees 0b0eb6ee9cf Enable `std::io::copy` specialisation for `std::pipe::{PipeReader, PipeWriter}` 01d9664ad73 Rollup merge of #128282 - pitaj:nonzero_bitwise, r=workingjubilee 9d307a1054f Rollup merge of #128279 - slanterns:is_sorted, r=dtolnay 1c00c4fe102 stabilize `is_sorted` 08555175b7f bitwise and bytewise methods on `NonZero` da4bbcd4b23 Rollup merge of #128259 - sunshowers:msg-nosignal, r=Mark-Simulacrum b0afcdbd02f Rollup merge of #125897 - RalfJung:from-ref, r=Amanieu fb038e0828f Improve panic sections for sort*, sort_unstable* and select_nth_unstable* 72b741fe12f Improve panic message and surrounding documentation for Ord violations 519235182a4 Auto merge of #128255 - stepancheg:doc-shl, r=scottmcm 05163fd0402 Okay, I guess I have to give these a different feature name b0aaf511e1a impl Default for collection iterators that don't already have it 3e3f8e18dc7 Merge from rustc 215a3f2eb8e Auto merge of #127946 - tgross35:fmt-builders-set-result, r=cuviper 398ae34bbb4 [illumos/solaris] set MSG_NOSIGNAL while writing to sockets 572eedabde1 Document int.checked_shl(BITS - 1) 29e01c6858d Rollup merge of #128235 - harryscholes:fix-iterator-filter-docs, r=tgross35 a7c86eacaa4 Rollup merge of #124941 - Skgland:stabilize-const-int-from-str, r=dtolnay 6756cbccdf1 Add links from `assert_eq!` docs to `debug_assert_eq!`, etc. edcee6743a9 Always set `result` during `finish()` in debug builders e9c5cc2594e Fix docs ac41e3731d1 Auto merge of #128165 - saethlin:optimize-clone-shims, r=compiler-errors 058bb5b3a6a Fix doc nits 1a4695dec3b Rollup merge of #128170 - saethlin:clone-fn, r=compiler-errors 5cecfaccc37 Merge from rustc 63b1a9ea1b4 Rollup merge of #128211 - juliusl:pr/align-change-time, r=tgross35 7ee9455a698 Rollup merge of #128150 - BoxyUwU:std_only_sized_const_params, r=workingjubilee cadc5b8e922 Rollup merge of #127950 - nnethercote:rustfmt-skip-on-use-decls, r=cuviper f40b3df7f60 Make Clone::clone a lang item 60a979a1fca fix: compilation issue w/ refactored type 7b3d4cffe55 Let InstCombine remove Clone shims inside Clone shims ed5ce8bb52f Stop using `unsized_const_parameters` in core/std 90d66146bb9 Auto merge of #128195 - matthiaskrgr:rollup-195dfdf, r=matthiaskrgr 3dcf55698f4 Rollup merge of #128137 - GrigorenkoPV:cstr-derive, r=dtolnay e6a32a95dad Rollup merge of #127999 - ChrisDenton:arm32, r=Amanieu 326e9e9b664 clarify interactions with MaybeUninit and UnsafeCell e54faa08934 remove duplicate explanations of the ptr to ref conversion rules 857378a438e create a new section on pointer to reference conversion 0b51e11685a Rollup merge of #128158 - workingjubilee:unsafe-wrap-personality-gcc, r=ChrisDenton 1ca0c324d9b Rollup merge of #127300 - biabbas:fix_connect_timeout, r=tgross35 34f49c48beb CStr: derive PartialEq, Eq; add test for Ord a4b6ac88ba3 In connect timeout, read readiness of socket for vxworks. Check pollhup or pollerr for refused connections in linux 05af1248799 Merge from rustc 422c70aa11e Implement `mixed_integer_ops_unsigned_sub` 3c72a9dcc51 std: update comments on gcc personality fn 26575053811 std: unsafe-wrap gcc::rust_eh_personality and impl 0f28e6a3627 Rollup merge of #128135 - joboet:reduplicate_tls, r=tgross35 a919e31a1ad Rollup merge of #128046 - GrigorenkoPV:90435, r=tgross35 4fa21d58135 Rollup merge of #126548 - rik86189:issue-88264-fix, r=tgross35 d8bf068b7aa Rollup merge of #126042 - davidzeng0:master, r=Amanieu eefa80a3d3c Rollup merge of #128131 - ChrisDenton:stuff, r=workingjubilee f32fc76a157 Rollup merge of #128120 - compiler-errors:async-fn-name, r=oli-obk d2c6fe62679 Rollup merge of #127733 - GrigorenkoPV:don't-forget, r=Amanieu 9d638369a39 Rollup merge of #127480 - biabbas:vxworks, r=workingjubilee 3e33cf6b352 Rollup merge of #127252 - fitzgen:edge-cases-for-bitwise-operations, r=m-ou-se 2fc95e33834 Rollup merge of #126152 - RalfJung:size_of_val_raw, r=saethlin 4c780081ca7 Improved clarity of documentation for std::fs::create_dir_all b4bb4fcb615 std: use duplicate thread local state in tests a5c07d371d8 Forbid unsafe_op_in_unsafe_fn in sys/pal/windows a68e62ab892 Import `core::ffi::c_void` in more places 118cb61f6dc Merge from rustc 32fbce9abe0 Add chroot unsupported implementation for VxWorks 6357fd8001f Rollup merge of #128106 - hallfox:patch-1, r=ChrisDenton 586d01cc983 Rollup merge of #128092 - ChrisDenton:wrappers, r=workingjubilee 68d5173d212 Rollup merge of #128043 - safinaskar:primitive, r=workingjubilee 40cfd39fead Rollup merge of #127481 - a1phyr:pattern_gat, r=Amanieu a22181dbf69 Rollup merge of #126770 - wr7:master, r=Amanieu 94df38c36d4 Rollup merge of #125962 - Coekjan:const-binary-heap, r=Amanieu 0c80ce7ce43 Auto merge of #127153 - NobodyXu:pipe, r=ChrisDenton 0998d4c7534 Gate AsyncFn* under async_closure feature faad9cd9e2e Add elem_offset and related methods ce12ad0a61d library/core/src/primitive.rs: small doc fix 5b515cbe49e Fix return type of FileAttr methods on AIX target 73884f55a7b add `is_multiple_of` for unsigned integer types ab97c5fb9db Initial implementation of anonymous_pipe 1371c4f1e74 Update process vxworks, set default stack size of 256 Kib for vxworks. User can set the stack size using RUST_MIN_STACK, with min size of libc::PTHREAD_STACK_MIN(4kib) 15eba5e5252 Rollup merge of #128089 - workingjubilee:commonly-wrapped-to-make-safe, r=ChrisDenton 67f400f8fd4 Rollup merge of #125834 - workingjubilee:weaken-thir-unsafeck-for-addr-of-static-mut, r=compiler-errors b4113cb35bd Remove wrapper functions from c.rs 158bb08bfda std: Unsafe-wrap backtrace code held in-common 4bf2ab173f9 std: Unsafe-wrap alloc code held in-common 97d4885b2fd Cfg disable on_broken_pipe_flag_used() for vxworks 472193b3b40 Disable dirfd for vxworks, Return unsupported error from set_times and lchown for vxworks 81d3ce70ee8 Allow unused unsafe for vxworks in read_at and write at ce6765c1689 Docs for core::primitive: mention that "core" can be shadowed, too, so we should write "::core" 13dfb066177 library: vary unsafety in bootstrapping for SEH 55dc597da6b std: unsafe-wrap personality::dwarf::eh 4f500067c8d LocalWaker docs: Make long-ago omitted but probably intended changes 73612ebeca9 Docs for Waker and LocalWaker: Add cross-refs in comment 58b42f8f9bc Rollup merge of #128008 - weiznich:fix/121521, r=lcnr 975117ec22b Rollup merge of #127996 - ian-h-chamberlain:fix/horizon-warnings-unsafe-in-unsafe, r=tgross35 2d09117b602 Rollup merge of #127415 - AljoschaMeyer:master, r=dtolnay 747b94e29a7 Use given allocator instad of Global 595199356ea Start using `#[diagnostic::do_not_recommend]` in the standard library 037d6f52aea Rollup merge of #127583 - Nilstrieb:invalid-utf8, r=joboet 1c966496a4a Fix warnings when checking armv6k-nintendo-3ds fb2eeb3fd50 Fix some `#[cfg_attr(not(doc), repr(..))]` a4b345bba40 Implement `debug_more_non_exhaustive` 98321beba2a Make use of raw strings in `core::fmt::builders` 19f48e4b8a6 Deal with invalid UTF-8 from `gai_strerror` d78dd6e93e9 std::thread: available_parallelism implementation for vxWorks proposal. 3e295354a32 Auto merge of #127722 - BoxyUwU:new_adt_const_params_limitations, r=compiler-errors a9cd750b430 Rollup merge of #128005 - ChrisDenton:msvc-include, r=joboet 01f3a465fde Rollup merge of #127734 - ChrisDenton:netc, r=Mark-Simulacrum e6767beefee Remove _tls_used hack 75e7a97d8e9 Rollup merge of #127873 - workingjubilee:forbid-unsafe-ops-for-kmc-solid, r=Amanieu 9236135d33a Rollup merge of #127843 - workingjubilee:break-up-big-ass-stack-overflow-fn, r=joboet f7084ff4ee9 Inject win arm32 shims into metadata generation 33bf5c4c383 Rollup merge of #127918 - ChrisDenton:thread-name-string, r=joboet 938070fa7bb Rollup merge of #123196 - Ayush1325:uefi-process, r=joboet f9d02e2b394 std: forbid unwrapped unsafe in unsupported_backslash 252eafbce17 kmc-solid: forbid(unsafe_op_in_unsafe_fn) d2d4ff915f8 Auto merge of #127982 - matthiaskrgr:rollup-nzyvphj, r=matthiaskrgr 64a37504e69 Rollup merge of #127978 - nyurik:lib-refs, r=workingjubilee 0074e8d3cb8 Avoid ref when using format! for perf cc2885cb227 Rollup merge of #126199 - ivan-shrimp:nonzero_isqrt, r=tgross35 4193083b07b Rollup merge of #112328 - juliusl:pr/windows-add-change-time, r=ChrisDenton 1730be921dd uefi: process: Fixes from PR 06202196d7d uefi: process: Final Touchups a73e8880f14 uefi: process: Add CommandArgs support d2483103791 uefi: process: Add support for args 54282d3d9a1 uefi: process Implement inherit 83a77dadac4 uefi: process: Add null protocol d399ef2ce81 uefi: process: Add stderr support c9a04f7766a uefi: process: Add support to capture stdout 95c5c09d730 uefi: Add process 1882b4e1476 improve safety comment b9c364117a0 add `NonZero::isqrt` ee918dc9ec3 Use `#[rustfmt::skip]` on some `use` groups to prevent reordering. f060bfa4a45 unix: acquire-load NEED_ALTSTACK f181756cb9e unix: Unsafe-wrap stack_overflow::{drop,make}_handler a77379c8328 unix: Unsafe-wrap stack_overflow::cleanup 722c55a5e8c unix: lift init of sigaltstack before sigaction cf028383000 unix: Unsafe-wrap stack_overflow::signal_handler b0902e7b8bb Rollup merge of #127594 - c6c7:fuchsia-status-code-match-arm, r=tmandry 0cc70b94629 Move ThreadName conversions to &cstr/&str 92c4fd8bf20 Style change f98df105119 Make `Thread::new_inner` a safe function 40ea8bbd18d Rollup merge of #127748 - scottmcm:option_len, r=joboet e4c58dd50ed Rollup merge of #124881 - Sp00ph:reentrant_lock_tid, r=joboet cd6fa3d1467 Update `ReentrantLock` implementation, add `CURRENT_ID` thread local. 9605bcce7c0 Safely enforce thread name requirements de5c6bb536d Rollup merge of #127077 - tbu-:pr_doc_fd_to_owned, r=workingjubilee b299458496b Rollup merge of #127861 - Kriskras99:patch-1, r=tgross35 e82629e5b55 Rollup merge of #127859 - RalfJung:ptr-dyn-metadata, r=scottmcm 3e83535c870 Rollup merge of #127845 - workingjubilee:actually-break-up-big-ass-stack-overflow-fn, r=joboet ebfaa193dee Auto merge of #127865 - matthiaskrgr:rollup-8m49dlg, r=matthiaskrgr a0a6d7ecd4b feat: adding ext that returns change_time for Windows f9f8a9012ad Auto merge of #125942 - timokroeger:windows-once-futex, r=ChrisDenton ff795f2c11a Rollup merge of #127337 - celinval:intrinsics-fallback, r=oli-obk 33cfbf670c9 Mention how you can go from `BorrowedFd` to `OwnedFd` and back 355be124ca4 Make language around `ToOwned` for `BorrowedFd` more precise 7bf7aab2167 Document the column numbers for the dbg! macro 5eb778607cb ptr::metadata: update comment on vtable_ptr work-around 9118e2ccd65 ptr::metadata: avoid references to extern types 6e8570c134a Split part of `adt_const_params` into `unsized_const_params` b96195f06c1 Forbid `!Sized` types and references be3e81f2e6e Rollup merge of #127813 - ChrisDenton:win-futex, r=joboet 8668a68bc6e Rollup merge of #127763 - ChrisDenton:safe-unsafe-unsafe, r=tgross35 9234d529452 unix: unsafe-wrap install_main_guard_default 10c6ade5c18 unix: clean up install_main_guard_freebsd ac8525bf4d2 unix: stack_start_aligned is a safe fn 4679e5c39d4 unix: split stack_overflow::install_main_guard by os 59024f74c49 Prevent double reference in generic futex 84b20695293 Narrow the scope of the ReadFile unsafe block 931cc716661 forbid(unsafe_op_in_unsafe_fn) in sys/os_str 9e888c82f6b Rollup merge of #127836 - workingjubilee:forbid-unsafe-ops-in-xous-uefi, r=tgross35 7b250908fcb Rollup merge of #127833 - risc0:erik/zkvm-deny-unsafe, r=workingjubilee 98be97a3343 Rollup merge of #127807 - ChrisDenton:win-parking, r=joboet 144c8838abe Rollup merge of #127792 - workingjubilee:read-unaligned-is-dwarfier, r=joboet f284ae2638b Rollup merge of #127444 - Sky9x:cstr-bytes-iter, r=dtolnay f2c9a6ed8e3 Rollup merge of #126776 - nnethercote:rustfmt-use-pre-cleanups-2, r=cuviper 506d768375a Rollup merge of #126271 - diondokter:dec2flt-skip-fast-path, r=tgross35 d53f551c4ea Rollup merge of #125206 - mgeisler:simplify-std-env-vars, r=jhpratt,tgross35 2440d417348 uefi: Forbid unwrapped unsafe in platform modules c73075cfb9d Cfg nit 847bf9a024a xous: Forbid unwrapped unsafe in platform modules 36f0b6abd74 zkvm: add `#[forbid(unsafe_op_in_unsafe_fn)]` in `stdlib` 000989f25f3 Adjust some comments on individual `use` declarations. e7b9cc3b154 Avoid comments that describe multiple `use` items. 5cba8a25014 Merge some `core::iter` entries. d24610d8946 Add unsafe blocks in unsafe Thread::new 50f8d68c6f9 Remove `slice_to_end` 92f8434f1cd std: unwrapped unsafe is VERBOTEN! ddb5950fe34 Rollup merge of #127789 - Sword-Destiny:master, r=petrochenkov fa8dc3ba94a Use futex.rs for Windows thread parking f9f0dbf8967 std: Use read_unaligned for reading DWARF 257c696b8fb Rollup merge of #127047 - tspiteri:f128-aconsts-lsd, r=tgross35 a4e49d0cc8f deny unsafe_op_in_unsafe_fn for teeos 0255a5cf020 clean unsafe op in unsafe fn cb21bf2a84d clean unsafe op in unsafe fn 853f81f365d clean unsafe op in unsafe fn ba34adaac5f delete #![allow(unsafe_op_in_unsafe_fn)] 46fcd449a31 `impl Send + Sync` and override `count` for the `CStr::bytes` iterator bdb012cbbc4 Update name of Windows abort constant to match platform documentation 7cc7ac46884 Add match arm for Fuchsia status code upon an abort in a test c3ea9f80b8f Auto merge of #127777 - matthiaskrgr:rollup-qp2vkan, r=matthiaskrgr 65dcaf899bf Rollup merge of #124921 - RalfJung:offset-from-same-addr, r=oli-obk 7e9e8447b17 lib: replace some `mem::forget`'s with `ManuallyDrop` 8e37f8535db Auto merge of #127020 - tgross35:f16-f128-classify, r=workingjubilee 37102d273bb allow(unsafe_op_in_unsafe_fn) on some functions 3f678c766a2 Some Windows functions are safe 66756c49334 Deny more windows unsafe_op_in_unsafe_fn d041a34b0fe Windows: move BSD socket shims to netc abbea950b07 Remove generic lifetime parameter of trait `Pattern` 0267ff99c5e Rollup merge of #127750 - ChrisDenton:safe-unsafe-unsafe, r=workingjubilee 9284b75a5c1 Rollup merge of #127744 - workingjubilee:deny-unsafe-op-in-std, r=jhpratt 8ee03cf299f Rollup merge of #127712 - ChrisDenton:raw-types, r=workingjubilee 085ac0fd5b0 Mark some `f16` and `f128` functions unstably const 77831a6bac6 Use Option's discriminant as its size hint 6678e4bed6e Move safety comment outside unsafe block d085f2cd1da Make os/windows default to deny unsafe in unsafe 7856eaa0973 Make pal/windows default to deny unsafe in unsafe 3c1db5c7d05 Fix Windows 7 bdc402ec69f Auto merge of #127719 - devnexen:math_log_fix_solill, r=Amanieu 0682758164b Don't re-export `c_int` from `c` fd088452871 Remove DWORD 28989496e99 Remove ULONG 8ce93fb317c Remove PSRWLOCK 9ab569ed19a Remove LPVOID 57cdcebb030 Remove LPSECURITY_ATTRIBUTES a51a46145f2 Remove LPOVERLAPPED 538a8a547ca Remove LPCVOID d5d81371f5e Remove SIZE_T 5bae7be5892 Remove CHAR 885b38bd992 Remove USHORT ebb0a5805df Remove LPWSTR 0b9b3115273 Remove UINT b8c784bbfbe Remove LONG 6dbe993ba56 Remove LARGE_INTEGER 6577a7210f9 Remove NonZeroDWORD a71192b17a9 Auto merge of #127732 - GrigorenkoPV:teeos-safe-sys-init, r=Amanieu f79270a93c4 std: Unsafe-wrap std::sync e6a229e626d std: Unsafe-wrap in Wtf8 impl 5f1a946ed1d std: Unsafe-wrap std::io fe30fe1da0b std: Directly call unsafe {un,}setenv in env 65fcc39ec34 std: Unsafe-wrap OSStr{,ing}::from_encoded_bytes_unchecked 91645f2f947 std: Unsafe-wrap HashMap::get_many_unchecked_mut 9b38b601cc9 std: deny(unsafe_op_in_unsafe_fn) but allow sites 50be6f2f098 Add `classify` and related methods for `f16` and `f128` a9d9907014b std: removes logarithms family function edge cases handling for solaris. 8655dea43d5 Auto merge of #127728 - matthiaskrgr:rollup-ercdbjd, r=matthiaskrgr 09d37b7acf5 sys::init is not unsafe on teeos 66344c2842f Rollup merge of #127592 - tesuji:patch-1, r=Mark-Simulacrum b32347b11d5 Auto merge of #125935 - madsmtm:merge-os-apple, r=workingjubilee 747b97ab9f3 Merge Apple `std::os` extensions modules into `std::os::darwin` 8ec41106c4f Rollup merge of #127704 - workingjubilee:fixup-better-than, r=ChrisDenton 684b5549a89 Auto merge of #127706 - workingjubilee:rollup-d07ij30, r=workingjubilee 0f30ddf66c8 Rollup merge of #127659 - saethlin:manually-drop-bufwriter, r=joboet 2b6cd91787a Rollup merge of #127446 - zachs18:miri-stdlib-leaks-core-alloc, r=Mark-Simulacrum 68ed70657b3 Rollup merge of #127370 - ChrisDenton:win-sys, r=Mark-Simulacrum ec476ee4a27 doc: Suggest `str::repeat` over `iter::repeat().take().collect()` 054e91c0993 Fix minor typos in std::process doc on Win argv bdb2b06844c Auto merge of #126958 - dtolnay:u32char, r=Mark-Simulacrum 3695522d952 std::unix::fs: removing, now useless, layers predating macOs 10.10. 45479749bb8 Auto merge of #127674 - jhpratt:rollup-0dxy3k7, r=jhpratt c00fea106e9 Rollup merge of #127668 - spencer3035:improve-slice-doc, r=jhpratt 2f2bb12c2a8 Rollup merge of #127661 - eduardosm:stabilize-io_slice_advance, r=cuviper ad2fa699869 Auto merge of #127397 - jyn514:multi-thread-panic-hook, r=workingjubilee 92275d2f1a0 Auto merge of #126606 - zachs18:patch-2, r=joboet c9804a15613 Updated slice documentation 184eda62e0c Use ManuallyDrop in BufWriter::into_parts 02fa7fba8fb Use is_val_statically_known to optimize pow a3935c8afa8 Stabilize io_slice_advance dbd7118bea4 Rename the internal `const_strlen` to just `strlen` b1f1404e893 fix interleaved panic output 77abff30030 Rollup merge of #127433 - dtolnay:conststrlen, r=workingjubilee 5c412e43552 Rollup merge of #126827 - the8472:pidfd-spawn, r=workingjubilee 5045dce9c23 Rollup merge of #124980 - zachs18:rc-allocator, r=Amanieu 9d35aaf70dc Add instability attribute on private const_strlen function b8b164df3a6 Rollup merge of #127422 - greaka:master, r=workingjubilee 0a00ff36ea7 [library/std/src/process.rs] `PartialEq` & `Eq` for `ExitCode` d5183ce1d4b Explicitly unroll integer pow for small exponents 06b5b4870ca Optimize integer pow by removing exit branch 7d94070d124 Rollup merge of #127599 - tgross35:lazy_cell_consume-rename, r=workingjubilee 338c2d0951a Rollup merge of #127588 - uweigand:s390x-f16-doctests, r=tgross35 989b2bd439e Rollup merge of #127572 - tbu-:pr_debug_event_nonpacked, r=jhpratt 2008df447e5 Rollup merge of #124599 - estebank:issue-41708, r=wesleywiser 157c1f9b04a Rename `lazy_cell_consume` to `lazy_cell_into_inner` 153cc4cdf7f Explicitly ignore `into_raw_handle()` using `let _ =` in sys/pal/windows. 2a34374f5aa core: Limit remaining f16 doctests to x86_64 linux 53cc868c4c4 Add `must_use` to IntoRawFd/IntoRawSocket/IntoRawHandle's methods. cb4b60812ca Clarify/add `must_use` messages for more `into_raw*` functions of `alloc` types. 2a54aa73f92 size_of_val_raw: for length 0 this is safe to call 9e9aceefa16 Rollup merge of #127554 - ferrocene:tshepang-add-missing-attribute, r=pietroalbini 9ee084314e7 Don't mark `DEBUG_EVENT` struct as `repr(packed)` 9627ed4a11d Auto merge of #126690 - andyolivares:feature/show_window, r=dtolnay 83d71ac7836 Rollup merge of #127091 - Sky9x:fused-error-sources-iter, r=dtolnay 0dfb9871e8d Fixed doc links ba8ea1ace90 Few changes to doc comments. Added tracking issue number. abd51b74e24 Exposing STARTUPINFOW.wShowWindow in CommandExt (show_window function) to control how a new process should display its window (normal, minimized, maximized, etc) 8df70288773 do not run test where it cannot run 74a5f6bb08e Auto merge of #127235 - martn3:no-mips-f16, r=tgross35,scottmcm 8027da34770 Rollup merge of #127460 - Borgerr:clarify-drop-comment, r=jhpratt f229c489f60 Rollup merge of #127355 - aceArt-GmbH:126475, r=oli-obk 49ca8e78475 Rollup merge of #120248 - WaffleLapkin:bonk-ptr-object-casts, r=compiler-errors,oli-obk,lnicola 1488d9ef286 Attempt to fix CI f9a3c8b5ead Reset sigpipe not supported for vxworks 2ac8b330127 Rollup merge of #127367 - ChrisDenton:run-sync, r=Nilstrieb 3b2e8cb10e8 Rollup merge of #126921 - workingjubilee:outline-va-list, r=Nilstrieb cebc261a227 Auto merge of #127454 - matthiaskrgr:rollup-k3vfen2, r=matthiaskrgr 536ef4d9d53 Move/change declaration of `mod exit_guard;` f70192f84a7 clarify `sys::unix::fd::FileDesc::drop` comment (#66876) 32a16f4efc7 Rollup merge of #127447 - RalfJung:once_lock_miri, r=joboet e6f601e7eef Rollup merge of #127354 - nicholasbishop:bishop-sized-doc, r=Nilstrieb 1136433aabe Rollup merge of #127297 - the8472:path-new-hash, r=Nilstrieb 7265681c7a1 Rollup merge of #127189 - GrigorenkoPV:linkedlist-cursor-list, r=Nilstrieb cf66b6d4352 Rollup merge of #127179 - tgross35:typeid-debug-hex, r=Nilstrieb 352e199a778 once_lock: make test not take as long in Miri ef03fac4445 Remove non-focused memory leak in `std` doctest for Miri. 8b9d5436526 Specialize `TrustedLen` for `Iterator::unzip()` e4add73fdfd Mitigate focused memory leaks in `core` doctests for Miri. 09a184df9e3 Remove non-focused memory leaks in `core` doctests for Miri. 95d9e903c17 Mitigate focused memory leaks in `alloc` doctests for Miri. e1280ef513a Remove non-focused memory leaks in `alloc` doctests for Miri. 24ce82ad6ca Stabilize const_cstr_from_ptr (CStr::from_ptr, CStr::count_bytes) 6f1ed1b4c7a Fix them doc examples some more 932748a7afe Fix doc examples 43feb917185 offset_from intrinsic: always allow pointers to point to the same address bf5bec4b723 Run formatter on alloc/src/boxed.rs 403df118b6b Mark format! with must_use hint 9d5571a185c as_simd: fix comment to be in line with 507583a (#121201) fa48bd4cf6e Rollup merge of #127275 - RalfJung:offset-from-isize-min, r=Amanieu f1007283910 Add missing try_new_uninit_slice_in and try_new_zeroed_slice_in 006e2b9aced Rollup merge of #125751 - pitaj:new_range_api, r=jhpratt 29036a883d2 Rollup merge of #127363 - GuillaumeGomez:improve-fmt-code-readability, r=Amanieu d990425dc3d Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix 1339ef6b203 Rollup merge of #123600 - tisonkun:path_with_extension, r=dtolnay 80b7f5f4e1c Attempt to fix CI 4ad7d759dec add `new_range_api` for RFC 3550 7163069dd67 Move exit guard from sys::common::exit_guard to sys::exit_guard. 1b4fc3b9047 Update library/std/src/sys/pal/common/exit_guard.rs 7169173df94 add unit tests for extra extension feature 3d4a918aa1d update comments 89cf5735cda Add experimental raw-dylib feature to std d82772e4199 Use windows_targets macro for alloc 916e30f6b61 Run alloc sync tests 265d90af889 Improve readability of some fmt code examples ca74d4e92d6 Rollup merge of #127320 - ChrisDenton:win-sys, r=Mark-Simulacrum ce358cd998f Rollup merge of #127214 - bjorn3:miri_native_unwind, r=oli-obk ae7a288ffe7 Describe Sized requirements for mem::offset_of e63d868254f impl FusedIterator and a size hint for the error sources iter fcac92c174d core: erase redundant stability attrs in va_list de99de00125 library: outline VaList into ffi::va_list baf467accc2 Auto merge of #126171 - RalfJung:simd_bitmask_multibyte, r=workingjubilee 3e75a1932f3 Document safety of a few intrinsics a5309b38e4b Move a few intrinsics to use Rust abi fd744d56bf9 mark `can_not_overflow` as `#[rustc_const_stable(...)]` f4e8a100c5a stabilize `const_int_from_str` 8086e0df2b4 Add more checks for pointers with vtable meta 9f463a5e3cb Improve dead code analysis af09a922f43 Add comments to windows_targets.rs 84fe61cf16e Update windows-bindgen to 0.58.0 2210917aba6 also remove redundant requirements from offset() 969a34ddab7 offset_from: "the difference must fit in an isize" is a corollary 7a3c560007b Rollup merge of #127303 - cuishuang:master, r=jhpratt 18fbc18e9ad Rollup merge of #127195 - biabbas:vxworks_cleanup, r=jhpratt 838f4903035 Rollup merge of #126792 - wooden-worm:master, r=Mark-Simulacrum dfa52c82ca5 chore: remove repeat words 3e9b0120993 impl PathBuf::add_extension and Path::with_added_extension 122927f1b9e Auto merge of #127226 - mat-1:optimize-siphash-round, r=nnethercote 42c7c1d6b45 stir the hash state a little to avoid prefix collisions 0a44d7af1c6 Add more test cases for path comparisons 288be93543e Add test case demonstrating equality of paths "foo/bar" and "foobar" dbca9c30a99 Move unique_thread_exit call to lang_start_internal so it is not in a generic function, and wrap it in `catch_unwind` 5dfa2b66fe0 Remove Miri special-case fb6b5a09406 Use pthread_t instead of numeric thread id 96dcfeefbe9 Use libc::pause instead of std::thread::park in wait-for-exit loop 3cf5e4c368c core: Limit four f16 doctests to x86_64 linux c4b530b9770 std: Set has_reliable_f16 to false for MIPS targets in build.rs 9631f365aa6 library/std/build.rs: "powerpc64le" is not a target_arch 208f1c398fa Rollup merge of #127204 - dimpolo:stabilize_atomic_bool_fetch_not, r=jhpratt a93f7de61b3 Rollup merge of #123588 - tgross35:stabilize-assert_unchecked, r=dtolnay 4145347cf4d Fall back on remove dir implementation for vxworks 4696256fd81 Add edge-case examples to `{count,leading,trailing}_{ones,zeros}` methods 15c9f97d36b Rollup merge of #127230 - hattizai:patch01, r=saethlin fd57de97226 chore: remove duplicate words 204d92d8dbc Optimize SipHash by reordering compress instructions 10076b85125 Rollup merge of #127128 - elomatreb:elomatreb/stabilize-duration_abs_diff, r=joboet c91a18520be Rollup merge of #126732 - StackOverflowExcept1on:master, r=m-ou-se 1ae3713161d Use the native unwind function in miri where possible d773010dcb1 Avoid MIR bloat in inlining ea88eef8665 Stabilize atomic_bool_fetch_not c37fba6993b Rollup merge of #127182 - danielhuang:patch-4, r=Nilstrieb a16cf291f1c Remove unqualified import io:: Error for vxworks as all Error references are qualified in process_vxworks.rs c069c636cd0 Auto merge of #127026 - Urgau:cleanup-bootstrap-check-cfg, r=Kobzol 6fd9c99db62 LinkedList's Cursor: method to get a ref to the cursor's list 3f985f65988 Update ip_addr.rs 91530bc0444 Print `TypeId` as hex for debugging 6e0b1261844 Rollup merge of #127069 - Sky9x:fmt-pointer-use-addr, r=Nilstrieb 356c1d63fdf Rollup merge of #126895 - betelgeuse:improve_simd_gather_documentation, r=Amanieu 6e689628539 Rollup merge of #127134 - tgross35:typeid-debug, r=Nilstrieb 35a36f40b0e Rollup merge of #126906 - GrigorenkoPV:fixme-split_at_first, r=Mark-Simulacrum a63279057b9 Rollup merge of #126705 - safinaskar:panic, r=Mark-Simulacrum 7d23be1bb24 Auto merge of #127133 - matthiaskrgr:rollup-jxkp3yf, r=matthiaskrgr f532345e155 Print `TypeId` as a `u128` for `Debug` d3d04285720 Rollup merge of #127122 - TDecking:div_ceil, r=Nilstrieb 2c542ccc070 Auto merge of #120639 - fee1-dead-contrib:new-effects-desugaring, r=oli-obk 9d4a0421167 Stabilize `duration_abs_diff` 3520a44d5e0 small correction to fmt::Pointer impl c2f8e94eefb Auto merge of #127121 - GuillaumeGomez:rollup-xjjjckn, r=GuillaumeGomez 493932f74f8 Remove uneccessary condition in `div_ceil` 93d24268d45 Updated docs on `#[panic_handler]` in `library/core/src/lib.rs` 19d7513c45e Rollup merge of #127073 - Sky9x:unnecessary-seqcst, r=Nilstrieb d959db41df5 Rollup merge of #127072 - Sky9x:docs-includes-vs-does-include, r=scottmcm ef25edf8842 Auto merge of #127119 - RalfJung:miri-sync, r=RalfJung e4e3bddd935 Rollup merge of #126953 - joboet:lazy_key, r=jhpratt 262c88af741 Merge from rustc 8d8ec0a5305 Rollup merge of #127071 - Sky9x:remove-ptr-to-from-bits, r=scottmcm bec477fe20a Rollup merge of #127070 - Sky9x:unit-const-param-ty, r=BoxyUwU 330ad8a8b0f Rollup merge of #127055 - shepmaster:hash-finish-must-use, r=dtolnay 2579ad64293 address review comments cdbe83790bb general fixups and turn `TODO`s into `FIXME`s 6974db04c05 Implement `Min` trait in new solver 4cf11f48bd7 implement new effects desugaring 164fd1a761b std: add safety comments e1d4a3c08bf Rollup merge of #126970 - DaniPopes:simplify-str-clone_into, r=cuviper d7def6add68 Rollup merge of #126956 - joboet:fmt_no_extern_ty, r=RalfJung bf4ddfadc0d Merge from rustc cbb853d963b Remove unnecessary SeqCst in `impl fmt::Pointer for AtomicPtr` bc7594ffaf5 docs: say "includes" instead of "does include" b54c3ba56f8 Remove (deprecated & unstable) {to,from}_bits pointer methods 039f9549056 add () to the marker_impls macro for ConstParamTy 066dd611275 Mark `Hasher::finish` as #[must_use] 799c880ae54 fix least significant digits of f128 associated constants 654058bee46 core: improve comment 7c334fd211b Cleanup bootstrap check-cfg 08c3c474510 Rollup merge of #126980 - Borgerr:fix-extendfromslice-check, r=workingjubilee 54a35b58efb Rollup merge of #126929 - nnethercote:rm-__rust_force_expr, r=oli-obk 91b06706f55 Merge from rustc dede324fb7e Auto merge of #126608 - tgross35:f16-f128-library, r=Mark-Simulacrum 8f06327943d std: test a variety of ways to extend a Wtf8Buf 58f058c709c set self.is_known_utf8 to false in extend_from_slice 3d37330433d Rollup merge of #126879 - the8472:next-chunk-filter-drop, r=cuviper 4689a1fb46a core: avoid `extern` types in formatting infrastructure d14f72aa355 fix UI test, simplify error message 24564f6cef6 regression test for leaks in the the Filter::next_chunk implementation f395a5f2924 add comments explaining optimizations for Filter::next_chunk bac3bef3e9f fix Drop items getting leaked in Filter::next_chunk 1a003050503 Simplify `str::clone_into` af3573c9997 Rollup merge of #126946 - cyrgani:patch-1, r=compiler-errors 902ce014ed0 Rollup merge of #126927 - workingjubilee:vaargsafe-is-unsafe, r=joboet 03614e0c4d3 Rollup merge of #126885 - Borgerr:rm_internal_pathbuf_asmutvec, r=workingjubilee 4ac24a5a7f1 Rollup merge of #126302 - mu001999-contrib:ignore/default, r=michaelwoerister 1ffdba93e08 Stabilize const unchecked conversion from u32 to char 30a20119f86 std: separate TLS key creation from TLS access d0782d74efe Detect unused structs which derived Default fb4c9f0414d `PathBuf::as_mut_vec` removed and verified for UEFI and Windows platforms #126333 f7b25ae878f remove references to `PathBuf::as_mut_vec` in `PathBuf::_set_extension` 26778655f5d inner truncate methods for UEFI platforms 09fee772f71 #126333 remove `PathBuf::as_mut_vec` reference at top of `PathBuf::_push` a0e02683c27 simd_bitmask intrinsic: add a non-power-of-2 multi-byte example 86ab26aef87 Add missing slash in const_eval_select doc comment 8f9b5a2df45 Add tests for `f16` and `f128` 76720a953c1 Add more `f16` and `f128` library functions and constants 6f48fc00b4e Add doctests to existing `f16` and `f128` functions b34fa8c5a79 Add build.rs config for reliable `f16` and `f128` 4ae77dc2900 Remove `__rust_force_expr`. 4a76a607a45 core: VaArgSafe is an unsafe trait 83a6a353922 Auto merge of #126852 - scottmcm:more-checked-math-tweaks, r=Amanieu 932098a7b67 Check that we get somewhat sane PIDs when spawning with pidfds 292e10e96a8 more fine-grained feature-detection for pidfd spawning 306c13ed566 document safety properties of the internal Process::new constructor c9e0bf708cb use pidfd_spawn for faster process creation when pidfds are requested 40afdf7ecd9 document the cvt methods 45a05452d96 Rollup merge of #126904 - GrigorenkoPV:nonzero-fixme, r=joboet 52355caf7e4 Rollup merge of #125575 - dingxiangfei2009:derive-smart-ptr, r=davidtwco aceb8d8e9bb Rollup merge of #125082 - kpreid:const-uninit, r=dtolnay 416fbb2e53b Replace `MaybeUninit::uninit_array()` with array repeat expression. df9659a1e35 Auto merge of #126523 - joboet:the_great_big_tls_refactor, r=Mark-Simulacrum b82df8ca728 Small fixme in core now that split_first has no codegen issues 675297b5e4c Small fixme in core now that NonZero is generic 91259f7d78a std: fix wasm builds fcc9d259977 Rollup merge of #126213 - zachs18:atomicbool-u8-i8-from-ptr-alignment, r=Nilstrieb 935ca4888d1 Fix simd_gather documentation f74f0da996c wasm64 build with target-feature=+simd128,+atomics 9b06d8ac540 Reword docs for `f32` and `f64` 3aa55d0aa01 Extract repeated constants from `f32` and `f64` source b51ce1bf4fb Rollup merge of #126854 - devnexen:std_unix_os_fallback_upd, r=Mark-Simulacrum ba7317453d5 Rollup merge of #126807 - devnexen:copy_file_macos_simpl, r=Mark-Simulacrum b524b0ba3ff Implement `unsigned_signed_diff` 14fe97ec9a2 Also get `add nuw` from `uN::checked_add` 8142b2f8ba7 SmartPointer derive-macro f36d7599e0b fix build 48a140164af Rollup merge of #126783 - tguichaoua:fix_tcplistener_into_incoming_issue_number, r=workingjubilee 65ed80408a5 std::unix::os::home_dir: fallback's optimisation. b80f35b8a3e Auto merge of #126838 - matthiaskrgr:rollup-qkop22o, r=matthiaskrgr 54066cd7b86 Rollup merge of #126552 - fee1-dead-contrib:rmfx, r=compiler-errors 74c499d7096 Rollup merge of #126140 - eduardosm:stabilize-fs_try_exists, r=Amanieu 679277dabee Auto merge of #116113 - kpreid:arcmut, r=dtolnay 0f831f68a9e Generalize `{Rc,Arc}::make_mut()` to unsized types. 0538ea0a0b5 Replace `WriteCloneIntoRaw` with `CloneToUninit`. 8cf7daa34c2 Add `core::clone::CloneToUninit`. 47109884ff9 Auto merge of #126750 - scottmcm:less-unlikely, r=jhpratt 29ccad70f9b Auto merge of #124101 - the8472:pidfd-methods, r=cuviper 31e799d5f56 to extract a pidfd we must consume the child 02b4908ad5c Add PidFd::{kill, wait, try_wait} e8ab3a419aa std::unix::fs: copy simplification for apple. 077f445270d Auto merge of #125853 - tesuji:promote-fail-fast, r=cjgillot 34794794811 update intrinsic const param counting 5aebedb38c8 Remove `feature(effects)` from the standard library 7f9b25aa8f3 Auto merge of #126781 - matthiaskrgr:rollup-5u4pens, r=matthiaskrgr 066ef755675 fix issue number c4866649013 Rollup merge of #126613 - tgross35:log-test-update, r=cuviper 470dcf9bb0d Stop using `unlikely` in `strict_*` methods 324444cb586 [GVN] Add tests for generic pointees with PtrMetadata 523ffe407a5 Don't perform mitigation for thread-unsafe libc::exit under Miri. 95a2f5feb94 fix rustdoc URL a4806eaba1b On `target_os = "linux"`, ensure that only one Rust thread calls `libc::exit` or returns from `main`. 3fa6bc73103 Auto merge of #126578 - scottmcm:inlining-bonuses-too, r=davidtwco 8626b3089b8 Auto merge of #124032 - Voultapher:a-new-sort, r=thomcc 52dfbd0ceae Rollup merge of #126737 - fee1-dead-contrib:rm-const-closures, r=compiler-errors 7766cb3f680 Fix wrong big O star bracing in the doc comments da3be972ca1 Remove `feature(const_closures)` from libcore 27cde30f605 Auto merge of #126736 - matthiaskrgr:rollup-rb20oe3, r=matthiaskrgr cb6f09ff69e Rollup merge of #126717 - nnethercote:rustfmt-use-pre-cleanups, r=jieyouxu 0450dd3f05b Rollup merge of #126711 - GKFX:const-option-as-slice, r=oli-obk 8d1d0d36bc4 Auto merge of #116088 - nbdd0121:unwind, r=Amanieu,RalfJung daa1a9fb30d Stabilize `PanicInfo::message()` and `PanicMessage` 7e87a67e84c Rollup merge of #126703 - the8472:on-blackbox-crypto-use, r=scottmcm 99c9aefe7a6 Shrink some slice iterator MIR 8fcebe32eae Stabilize `hint_assert_unchecked` f0ba3a73d8f Update documentation for `hint::assert_unchecked` 6f201722754 Add blank lines after module-level `//` comments. 48d228dccaf Add blank lines after module-level `//!` comments. 7c9aaf56d63 Convert some module-level `//` and `///` comments to `//!`. d47a1f8e5c5 Make Option::as_[mut_]slice const 24ecd7494fc reword the hint::blackbox non-guarantees 3a0cc5ec78f core: add tracking issue for `array::repeat` 63480d3ea42 core: simplify implementation of `array::repeat`, address other nits 5dbd21ffd70 core: implement `UncheckedIterator` for `RepeatN` 9c2bd232052 core: implement `array::repeat` 0f16280a750 Add a hack to prevent proc_macro misopt in CI 637feabbea0 Stabilise c_unwind f00197be240 Rollup merge of #125787 - Oneirical:infinite-test-a-novel, r=jieyouxu 698093262a5 try implementing suggestions e7435a0d0a9 run_make_support nm implementation + bin-emit-no-symbols rmake rewrite 284cf8d74ca Replace `move||` with `move ||` in `compiler/` and `library/` 9757d56024b Auto merge of #126330 - m-ou-se:panic-message-type, r=Amanieu ba606897af1 Print the tested value in int_log tests a7433c2041f Add missing CopyMarker impl 90cbb354300 Revert panic_safe test changes 7dd2fb7869f Add PanicMessage type for PanicInfo::message(). c5997618be2 Add tracking issue to async_drop API a65fc69e992 std: rename module for clarity 0902870d766 std: update TLS module documentation a4023d0cbba std: use the `c_int` from `core::ffi` instead of `libc` 7f9fa46c8eb std: simplify `#[cfg]`s for TLS c55336f08ef Fix unintended regression for Freeze + Copy types 7ac84d0858c Auto merge of #126569 - jieyouxu:rollup-1uvkb2y, r=jieyouxu 9729a056a8c Rollup merge of #126531 - slanterns:error_provider, r=workingjubilee 9d588d536b1 Rollup merge of #126468 - RalfJung:euclid, r=Mark-Simulacrum 51c2669a51d Rollup merge of #126346 - hermit-os:fd, r=Amanieu 7f7cc9d1f0e Rollup merge of #126288 - x4exr:patch-1, r=dtolnay 7fd3a35cb85 Auto merge of #125720 - folkertdev:optimize_for_size-ptr-rotate, r=Amanieu 4b12c095cdf doc: Added commas where needed ddd779d493e Fix doc-link issue 9b6eefea07f Remove reliance on const_trait in sort implementations 7f444eb9650 std: move `sys_common::backtrace` to `sys` c4a08908907 use rustc-dep-of-std in panic_unwind e5994901286 Rollup merge of #126539 - lukaslueg:patch-1, r=jhpratt f5c739d00ad Rollup merge of #125112 - tbu-:pr_create_dir_all_empty, r=dtolnay 5a0221f0f7a Update `Arc::try_unwrap()` docs c4995ef794e Apply review comments a00b0438506 Auto merge of #126299 - scottmcm:tune-sliceindex-ubchecks, r=saethlin aecf31c66e9 Redo SliceIndex implementations cd5a84ce85e update comment 4411a6ce8f3 Rollup merge of #126229 - ChrisDenton:bindgen, r=Mark-Simulacrum 2eb33457911 std: refactor the TLS implementation f569df5db50 Auto merge of #126518 - matthiaskrgr:rollup-wb70rzq, r=matthiaskrgr 43917508057 std: suggest OnceLock over Once 87e1b6bda4d Polish `std::path::absolute` documentation. fc77999c16a Auto merge of #126473 - matthiaskrgr:rollup-8w2xm09, r=matthiaskrgr 81a66267f8a Rollup merge of #126285 - kpreid:unique-rc, r=dtolnay 107b31658b2 Rollup merge of #126266 - tbu-:pr_doc_alloc_default_system, r=jhpratt 0351d77782e Rollup merge of #126135 - hermit-os:fuse, r=jhpratt ef53d89f607 Rollup merge of #123769 - dtolnay:literal, r=fee1-dead 306b3daa114 div_euclid, rem_euclid: clarify/extend documentation 997a8ba3440 Rollup merge of #126351 - devnexen:to_sol11_upd, r=ChrisDenton 919e4526462 Rollup merge of #126402 - firefighterduck:fix-unsafe-precon-copy, r=Nilstrieb 3c5a9f70bb8 Rollup merge of #126390 - Kriskras99:master, r=Nilstrieb c011a6e8652 Rollup merge of #126360 - compiler-errors:uplift-structural-traits, r=lcnr 6a08c5def89 Rollup merge of #123726 - jieyouxu:command-new-docs, r=Nilstrieb ce84b2c36c9 Remove superfluous escaping from byte, byte str, and c str literals 36a084a7117 LangItem-ify Coroutine trait in solvers 74d7e6ac66d fix wrong assert_unsafe_precondition message for core::ptr::copy b94ec8a921a Rollup merge of #126384 - RalfJung:is_none_or, r=workingjubilee 6383285d78a Rollup merge of #126347 - slanterns:try_simplify, r=scottmcm ff2a9ee004d Fix wording in {checked_}next_power_of_two 9aa82ab7594 add tracking issue for is_none_or 08dadd9f678 std::unix::fs::link using direct linkat call for Solaris and macOs. 9940020d20d Rollup merge of #126328 - RalfJung:is_none_or, r=workingjubilee c5569b089be Simplify `try_*` on `Iterator` 7240e0fd54b export std::os::fd module on HermitOS cda553f3be8 Auto merge of #126273 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum b0f9ca3f313 add is_none_or bd80e777d67 Rollup merge of #126322 - m-ou-se:panicinfo-and-panicinfo-2, r=RalfJung 48e10f15ab4 Rollup merge of #126242 - yaahc:simplify-provider, r=jhpratt 1bda88847ad Rollup merge of #126039 - dpaoliello:arm64ecbuild, r=davidtwco f377c8ff3fa Fix deprecated version. 2299eee4ca6 Update doc comment on PanicInfo::message(). a3f9fabdcbd Use payload_as_str instead of two downcasts. e6e8b9755e8 Fix deprecation version. 50a660b6cf2 Clarify doc comment. 5c1ce74a6f4 Auto merge of #126319 - workingjubilee:rollup-lendnud, r=workingjubilee 3907ccc5c33 Rollup merge of #126305 - workingjubilee:fix-os-string-to-string-utf8-invariant, r=joboet 8ffddfdc881 Rollup merge of #126287 - nnethercote:reformat-cranelift-patch, r=bjorn3 b882c942a6a Rollup merge of #126281 - ChrisDenton:env, r=jhpratt b4e2c76c100 Rollup merge of #126249 - workingjubilee:simplify-try-map-signature, r=scottmcm 2e8c1655e05 Rollup merge of #126210 - lolbinarycat:ptr_doctest_assert, r=workingjubilee 587d4f5d663 Rollup merge of #123374 - mgeier:doc-slice-from-raw-parts, r=scottmcm 16125ad221e Require any function with a tait in its signature to actually constrain a hidden type 85ac8b6d4cd Revert "Rollup merge of #125362 - joboet:tait_hack, r=Nilstrieb" ccc58effdb8 Make PathBuf less Ok with adding UTF-16 then `into_string` 10a00911d19 Update a cranelift patch file for formatting changes. c573969ca5f `UniqueRc`: support allocators and `T: ?Sized`. 6600f0c440b set_env: State the conclusion upfront dfd25c600c2 Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_exists cd262a4e991 Unify guarantees about the default allocator 3dd528d4a6d remove cfg(bootstrap) 8dec3ebec27 replace version placeholder f0b11b10b94 Formatting. 288aebfaead Bump deprecation of std's PanicInfo alias to 1.82.0. f3d15580d8f Add PanicHookInfo::payload_as_str(). 8b150655c14 Fix display of panic message in recursive panic. a39c4c6ec19 Mention core's PanicInfo in error.md. 7868480d429 Add note on panic payload type. 1123b75d62c Downcast panic payload to String too in example. b68315054df Move deprecation of std::panic::PanicInfo to 1.80.0. 562bfb8ac49 Fix deprecation version. 65cf92c1bfb Rename std::panic::PanicInfo to PanicHookInfo. 8f1f2885bf6 Formatting. 41f82b53e7c Fix invalid markdown/html. 546a470d479 Reorder body of begin_panic for consistency. 1ac6cdd8e5a Impl Display for PanicPayload to simplify things. af2963a6434 Use unnamed lifetimes for [..]Payload impl blocks. 9a3a3e7b3f7 Move downcasting panic payload to str to a function. f8074565c12 Mark some PanicInfo methods as #[inline] for consistency. 387fc066725 Remove std::panic::PanicInfo::internal_constructor+set_payload. d5c786a2f9b Remove core::panic::PanicInfo::internal_constructor. 91f91a6e119 Update doc comment about core::panicking. b92bb6ab00d Fix doc link. 4abd4fb4cb7 Add core::panic::PanicInfo::payload() for compatibility. 49e31f7ea89 Document difference between core and std's PanicInfo. 0ed7bee605e Split core's PanicInfo and std's PanicInfo. ece384d8028 Skip fast path for dec2flt when optimize_for_size bf7dc5ca0e3 Simplify `[T; N]::try_map` signature 3496d40180e Simplify provider api to improve llvm ir 4ab76b95f6d Rollup merge of #126212 - SteveLauC:fix/haiku, r=joboet d2fabcaa5dd Rollup merge of #126191 - ivan-shrimp:nonzero_doc, r=scottmcm 8fe987aa5b2 Bump windows-bindgen to 0.57 c0f606cd134 Clarify `Command::new` behavior if passed programs with arguments 4b3de285124 Remove some unused crate dependencies. 750a7a9a0aa Update docs for AtomicU8/I8. 6e94f4a0a67 fix: build on haiku c11e58e8e22 Update safety docs for AtomicBool::from_ptr. 1f5f8e028d5 docs(core): make more const_ptr doctests assert instead of printing 7ae1d17dfd9 Auto merge of #126205 - jieyouxu:rollup-s64z5ng, r=jieyouxu 1e33673e2a7 Rollup merge of #125253 - sunsided:feature/FRAC_1_SQRT_PI, r=Mark-Simulacrum def252f07f2 Auto merge of #126193 - RalfJung:miri-sync, r=RalfJung 83a1fedeb82 Migrate more things to WinError 3b324c67705 fix `NonZero` doctest inconsistencies 5689a59dafd Rollup merge of #126168 - devnexen:current_exe_haiku_simpl, r=ChrisDenton 49fdb5008d3 Rollup merge of #126146 - devnexen:signal_fbsd, r=ChrisDenton e3078e1d130 Merge from rustc 7c0df9aad1b std::unix::os current_exe implementation simplification for haiku. 3a3e514a13e Auto merge of #125966 - schvv31n:impl_os_string_pathbuf_leak, r=workingjubilee 507a75e3619 std::unix::process adding few specific freebsd signals to be able to id. 78b619b0569 Rollup merge of #126138 - wbk:patch-1, r=lqd e9ca035b0b6 Rollup merge of #125998 - devnexen:get_mode_illumos, r=Nilstrieb 1dac0e5b432 Rollup merge of #125951 - slanterns:error_in_core_stabilization, r=Amanieu 2f5004a18da Fix typo in docs for std::pin 6abc786403c add HermitOS support of vectored read/write operations c9540c1cfd1 Rollup merge of #126089 - wutchzone:option_take_if, r=scottmcm 4583baae233 Rollup merge of #126030 - ChrisDenton:update-wingen-readme, r=Mark-Simulacrum 604352262d3 Rollup merge of #124012 - slanterns:as_slice_stabilize, r=BurntSushi 818c5bfb61e Auto merge of #126110 - workingjubilee:backtrace-0.3.73, r=workingjubilee 8a401193a9e Update backtrace to 0.3.73 fdf911c2909 Merge from rustc c0fcc4f86bc Rollup merge of #125606 - diondokter:opt-size-int-fmt, r=cuviper b276a7a941d fix doc comments about `error_generic_member_access` 943ef864080 Stabilize `error_in_core` 5f17e735daa fixed memory leaks in PathBuf::leak & OsString::leak tests ad39ca5cb70 Rollup merge of #126096 - c410-f3r:tests-tests-tests, r=jhpratt 99f487e0b80 [RFC-2011] Allow `core_intrinsics` when activated 50e46d7868a Stabilize Option::take_if 71906e89cc5 less garbage, more examples 66375515cca Raise `DEFAULT_MIN_STACK_SIZE` to at least 64KiB 809542cd554 Auto merge of #126038 - matthiaskrgr:rollup-h4rm3x2, r=matthiaskrgr 4c5c6c05e77 Promote `arm64ec-pc-windows-msvc` to tier 2 ef23c571493 Rollup merge of #126032 - ChrisDenton:update-docs, r=joboet e4557df4571 Rollup merge of #125800 - fortanix:raoul/rte-99-fix_mut_static_task_queue, r=jethrogb 81ffb599dfb Rollup merge of #125940 - devnexen:unix_fs_netbsd_get_path, r=cuviper 4b6a2cd2f0c Update description of the `IsTerminal` example eee58d67f31 Update `./x fmt` command 492b3aaccf3 Rollup merge of #125995 - kpreid:const-uninit-stable, r=Nilstrieb 4342ff4cf67 Rollup merge of #125982 - xTachyon:fix-linked-list, r=jhpratt a823bf7b240 Rollup merge of #123168 - joshtriplett:size-of-prelude, r=Amanieu a7a8c605a86 std::unix::fs::get_mode implementation for illumos/solaris. 867c0b227e4 Use inline const instead of unsafe to implement `MaybeUninit::uninit_array()`. e4793fef60b Use inline const instead of unsafe to construct arrays in `MaybeUninit` examples. f30fb5b20c1 Rollup merge of #125932 - schvv31n:patch-1, r=lqd 604c511c85c Rollup merge of #125927 - ferrocene:lw-alloc-unwind-test, r=pietroalbini af54ace200a Rollup merge of #125696 - workingjubilee:please-dont-say-you-are-lazy, r=Nilstrieb 2fb3a2f14fe Rollup merge of #106186 - rossmacarthur:ft/iter-chain, r=Amanieu 861aba518fd Make deleting on LinkedList aware of the allocator 5c295d3ea18 impl OsString::leak & PathBuf::leak 9b9d6fe48b7 Add function `core::iter::chain` 9406136b4cf update tracking issue for `const_binary_heap_new_in` 977e99ac664 Rollup merge of #125919 - tbu-:pr_fix_typo, r=lqd a005c23f36d Rollup merge of #125504 - mqudsi:once_nominal, r=cuviper 84973f6fdbc Let compiler auto impl `Send` for `Task` 318126dcdee Store `Task::p` as `dyn FnOnce() + Send` 0c147d4af6b Pass function for `Thread` as `Send` to `Thread::imp` c14c3f4ffcd more explicitly state the basic rules of working with the obtained raw pointers 7da1a7a51cf Windows: Use futex implementation for `Once` f8214a69cec Auto merge of #125525 - joboet:tls_accessor, r=cuviper 3f0e45dfa75 std::unix::fs::get_path: using fcntl codepath for netbsd instead. ebf9fd1ac9f Fix typo in the docs of `HashMap::raw_entry_mut` 63894f20658 Ignore `vec_deque_alloc_error::test_shrink_to_unwind` test on non-unwind targets aceaa8c41c4 Auto merge of #125912 - nnethercote:rustfmt-tests-mir-opt, r=oli-obk 89fa1ffcfad Remove stray "this" 31c04650f49 Add "OnceList" example to motivate OnceLock b31986638d9 Move first OnceLock example to LazyLock 4f097a8a3f8 Differ LazyLock vs. OnceLock in std::sync overview 87d0368a86f Explain LazyCell in core::cell overview 14f187b5ad8 Reformat `mir!` macro invocations to use braces. ef21b7c89c2 Rollup merge of #125898 - RalfJung:typo, r=Nilstrieb 485efb879ba Rollup merge of #125884 - Rua:integer_sign_cast, r=Mark-Simulacrum 36060d57430 Rollup merge of #121062 - RustyYato:f32-midpoint, r=the8472 0032edf89b9 Wording of the documentation abc09823451 typo: depending from -> on 0348d5b629c Auto merge of #125577 - devnexen:netbsd_stack_min, r=joboet 9733e3290fd from_ref, from_mut: clarify domain of quantification 61035c23bc0 Implement feature `integer_sign_cast` de612b85605 Change f32::midpoint to upcast to f64 a0f25840eff Auto merge of #124294 - tspiteri:ilog-first-iter, r=the8472 7727b3cc189 stablize `const_binary_heap_constructor` & create an unstable feature `const_binary_heap_new_in` for `BinaryHeap::new_in` 2ccc662f0f0 Rollup merge of #125730 - mu001999-contrib:clippy-fix, r=oli-obk 2867670d6ef Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk f3571efc5c8 Avoid `mut` and simplify initialization of `TASK_QUEUE` a6fc259cbf7 Auto merge of #124636 - tbu-:pr_env_unsafe, r=petrochenkov 3b859314d6d Rollup merge of #125746 - jmillikin:duration-from-weeks-typo, r=lqd 8dcc4434295 Rollup merge of #125739 - RalfJung:drop-in-place-docs, r=workingjubilee a382a70f5a6 Rollup merge of #125342 - tbu-:pr_doc_write, r=ChrisDenton 0cd6df6aa46 explain what the open questions are, and add a Miri test for that fe99419c4af Apply x clippy --fix and x fmt 77088fd2f04 Fix copy-paste error in `Duration::from_weeks` panic message. cfdce7c0b45 Rollup merge of #125733 - compiler-errors:async-fn-assoc-item, r=fmease a43c068916d Elaborate about modifying env vars in multi-threaded programs 7e3b595f411 Add note about safety of `std::env::set_var` on Windows 39a2967c628 Make `std::env::{set_var, remove_var}` unsafe in edition 2024 a4f0ff535cd drop_in_place: weaken the claim of equivalence with drop(ptr.read()) bea4a4cb7c9 Add lang item for AsyncFnKindHelper::Upvars 8fed1e50b1f Add lang item for Future::Output c98bffd0010 Add lang items for AsyncFn's associated types b4fd95a88f3 [ACP 362] genericize `ptr::from_raw_parts` baded47bc06 Add FRAC_1_SQRT_2PI doc alias to FRAC_1_SQRT_TAU a60fbd67b9a make `ptr::rotate` smaller when using `optimize_for_size` e08e40b4778 Add safety comment to fix tidy eff370b0afa Optimize async drop glue for some old types 15962620757 Add FRAC_1_SQRT_2PI constant to f16/f32/f64/f128 3d830bb7635 Rollup merge of #125226 - madsmtm:fix-mac-catalyst-tests, r=workingjubilee b17a3d62c7b Rollup merge of #124251 - scottmcm:unop-ptr-metadata, r=oli-obk a29557d6d02 Add custom mir support for `PtrMetadata` 4b9ec7c2d00 Add an intrinsic for `ptr::metadata` d09996c5dc3 Rollup merge of #125637 - nnethercote:rustfmt-fixes, r=GuillaumeGomez 6ddf3572030 Make more of the test suite run on Mac Catalyst 96dbcf14d83 Disable stack overflow handler tests on iOS-like platforms f9662063c36 Don't format `tests/run-make/*/rmake.rs`. 6beda7389f6 Rollup merge of #125647 - tspiteri:track-lazy_cell_consume, r=workingjubilee 19feca79a9d Rollup merge of #125551 - clarfonthey:ip-bits, r=jhpratt 5968ab25f55 update tracking issue for lazy_cell_consume 0bf9fbfd379 Auto merge of #125636 - workingjubilee:bump-backtrace-0.3.72, r=workingjubilee 3ed6c6da22d Sync libstd deps with backtrace f140be97be2 Bump backtrace to 0.3.72 2aba5ec85cc Auto merge of #125609 - diondokter:opt-size-char-count, r=thomcc 41e8439f79c Rollup merge of #124870 - Lokathor:update-result-docs, r=dtolnay 894df37f245 Always use the general case char count 2e9f33af4fb Size optimize int formatting 0ab02b36e88 Rollup merge of #125559 - scottmcm:simplify-shift-ubcheck, r=workingjubilee b7f86dde59b Auto merge of #122079 - tbu-:pr_copy_file_range_probe, r=the8472 c252d9ac883 std::pal::unix::thread fetching min stack size on netbsd. afd42d561e5 Auto merge of #125574 - matthiaskrgr:rollup-1oljoup, r=matthiaskrgr 1dbac70789f Rollup merge of #125571 - tesuji:dummy-pi, r=Nilstrieb 7ea07089843 Rollup merge of #125561 - Cyborus04:stabilize-slice-flatten, r=scottmcm c7357f61f74 Auto merge of #125570 - tesuji:stdout-handle, r=Nilstrieb 3920b3fa9f1 f32: use constants instead of reassigning a dummy value as PI 8dbdd42e9ad use proper name instead of magic number 95bbaa71f31 Stabilize `slice_flatten` f9180afe70f Auto merge of #125070 - tbu-:pr_set_extension_panic, r=jhpratt fc18300e378 Auto merge of #125518 - saethlin:check-arguments-new-in-const, r=joboet 7f33ff153b3 It seems that anchor names are implicitly all lowercase a90ac95ab88 Simplify the `unchecked_sh[lr]` ub-checks a bit 4b076a7c564 Fix URL target, it's in the module not the type. 99a99759264 github showed that weird. 634580b9b36 correct for copy paste errors when fixing wrapping. e0450cadeaa Resolve https://github.com/rust-lang/rust/pull/124870#issuecomment-2128824959 8680dcf4fef revert to the inconsistent paragraph wrapping. 5e26cc8f07f Rollup merge of #124667 - newpavlov:stabilize_div_duration, r=jhpratt 01fc44d236c Rollup merge of #123803 - Sp00ph:shrink_to_fix, r=Mark-Simulacrum 61ce65046f4 Rollup merge of #122986 - taiki-e:aix-c-char, r=Mark-Simulacrum fd330b05e4b Rollup merge of #121377 - pitaj:lazy_cell_fn_pointer, r=dtolnay e7e5c05d6b7 Stabilise ip_bits feature 4b3f492836c Auto merge of #121571 - clarfonthey:unchecked-math-preconditions, r=saethlin a408038b7b4 Rollup merge of #125527 - programmerjake:patch-2, r=workingjubilee c4b1c90bf12 Rollup merge of #125498 - zmodem:avx512er, r=workingjubilee cfe0fe76042 Rollup merge of #125478 - Urgau:check-cfg-config-bump-stage0, r=Mark-Simulacrum 1b4d18a698d Rollup merge of #125271 - RalfJung:posix_memalign, r=workingjubilee 75d82d33767 Move the checks for Arguments constructors to inline const 011200bde9d Add manual Sync impl for ReentrantLockGuard 5da1d44dc0c std: make TLS accessors closures that return pointers cc3a0ceb499 Rollup merge of #125497 - meesfrensel:patch-1, r=calebzulawski fc65db224eb Auto merge of #125499 - matthiaskrgr:rollup-84i5z5w, r=matthiaskrgr 2eb5a2152d6 Stop using the avx512er and avx512pf x86 target features 88cf3b42318 Change pedantically incorrect OnceCell/OnceLock wording 9f91dd87840 Rollup merge of #125477 - nnethercote:missed-rustfmt, r=compiler-errors fcc3d2fc488 Rollup merge of #125455 - blyxyas:opt-clamp, r=joboet 5e47d481c5b Fix some SIMD intrinsics documentation 4efe3120ea3 Auto merge of #122494 - joboet:simplify_key_tls, r=m-ou-se 6f5c618d2ec Auto merge of #121150 - Swatinem:debug-ascii-str, r=joboet f9bda5f723b std: clean up the TLS implementation 21391bc69ab std: simplify key-based thread locals 0231122bd0d Auto merge of #125479 - scottmcm:validate-vtable-projections, r=Nilstrieb 68eeb877379 Validate the special layout restriction on DynMetadata 133d5f5a228 Remove now outdated comment since we bumped stage0 f00265c53b4 Run rustfmt on files that need it. 6d0fea46946 Auto merge of #125463 - GuillaumeGomez:rollup-287wx4y, r=GuillaumeGomez ae9cd9e49fe Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods 3eb90d8d327 Auto merge of #123724 - joboet:static_tls, r=m-ou-se 5f490f3b46c Rollup merge of #125452 - Urgau:check-cfg-libraries-cleanup, r=bjorn3 a2db14be953 Rollup merge of #125362 - joboet:tait_hack, r=Nilstrieb fe29bcd1163 Auto merge of #125456 - fmease:rollup-n8608gc, r=fmease 3ad97de6d6a Process a single not-ASCII-printable `char` per iteration c685c5fda61 Rollup merge of #124389 - CensoredUsername:master, r=petrochenkov 51ef73bbd2a Auto merge of #117804 - saethlin:no-recursive-panics, r=joboet d325d4e59c8 Make clamp inline fe5152d157a Copy core/alloc check-cfg message also in std 150b21ce560 Move some expected cfgs to std build.rs as per Cargo recommandation 81732f5ef41 Replace fake "restricted-std" Cargo feature by custom cfg 2dbbe367d0b panic_nounwind in Arguments::new* instead of recursing bb82cddf520 Expect any feature cfg in core and std crates f918d7fa1cd std: rewrite native thread-local storage 94c1a812650 core: use `Copy` in TAIT to fix clippy lint 60cde3c1798 Rollup merge of #125392 - workingjubilee:unwind-a-problem-in-context, r=Amanieu 9c8dc4ab410 Rollup merge of #125156 - zachs18:for_loops_over_fallibles_behind_refs, r=Nilstrieb 72ec742a080 Auto merge of #125423 - fmease:rollup-ne4l9y4, r=fmease 69c5564884e Rollup merge of #125043 - RalfJung:ref-type-safety-invariant, r=scottmcm 873d719253d Rollup merge of #125296 - tesuji:checkcfg-buildstd, r=Nilstrieb,michaelwoerister 0b7c890298c Rollup merge of #124896 - RalfJung:miri-intrinsic-fallback, r=oli-obk 47c15a43fa9 Auto merge of #117329 - RalfJung:offset-by-zero, r=oli-obk,scottmcm 6054140e5af Wrap Context.ext in AssertUnwindSafe e6adfe24e44 improve comment wording e9d4507ba04 tidy alphabetica 6787d64838c addresss reviews 752b9d857a1 Update check-cfg lists for std 68c878bad18 Update check-cfg lists for alloc de13917c4cb Update check-cfg lists for core 12046d16f46 core: actually use TAIT instead of emulating it 96027532912 Simplify environment variable examples c2ad88f819e Auto merge of #125358 - matthiaskrgr:rollup-mx841tg, r=matthiaskrgr 72db6123e73 Rollup merge of #125348 - tbu-:pr_doc_path_absolute, r=jhpratt 2efc312eda1 Rollup merge of #125266 - workingjubilee:stream-plastic-love, r=RalfJung,nikic 87e3f3904c5 Rollup merge of #125225 - madsmtm:ios-crt_externs.h, r=workingjubilee 81fd4ae3a57 Rollup merge of #125011 - diondokter:opt-for-size, r=Amanieu,kobzol d43c84ff9ac Auto merge of #124097 - compiler-errors:box-into-iter, r=WaffleLapkin bd0f39f86e9 Document behavior of `create_dir_all` wrt. empty path 8db22399d11 Implement BOXED_SLICE_INTO_ITER ba55f264340 Add the impls for Box<[T]>: IntoIterator eaef8a1f6e3 Rollup merge of #125333 - hermit-os:fuse, r=workingjubilee 15cedddb99f Rollup merge of #125123 - a1phyr:fix-read_exact, r=workingjubilee 451619a3c32 Rollup merge of #124050 - saethlin:less-sysroot-libc, r=ChrisDenton 57c2f8509af Small fixes to `std::path::absolute` docs e1cc64e52ab switch also the default implementation for read_vectored b3d26bf32de Document platform-specifics for `Read` and `Write` of `File` 316d7b55c7f switch to the default implementation of `write_vectored` 5bb57649945 Remove Windows dependency on libc 07d3484d32f Address review comments a3d78fa3fb8 Fix c_char on AIX 16d727df15a Rollup merge of #125283 - zachs18:arc-default-shared, r=dtolnay c3f54826df7 Switch to primarily using `&str` 461d966f78d Introduce printable-ASCII fast-path for `impl Debug for str` 8bffa8b80a4 Add a fast-path to `Debug` ASCII `&str` 7b643af0f28 Write `char::DebugEscape` sequences using `write_str` 4c035b27f4a Auto merge of #125313 - matthiaskrgr:rollup-65etxv0, r=matthiaskrgr 7e7bb42f5d5 Rollup merge of #125093 - zachs18:rc-into-raw-with-allocator-only, r=Mark-Simulacrum d5cafcccad5 Auto merge of #124560 - madsmtm:update-libc, r=Mark-Simulacrum c48b8403982 Make NULL check in argument parsing the same on all unix platforms 19896b21592 Auto merge of #123878 - jwong101:inplacecollect, r=jhpratt 10754da67d9 Rollup merge of #124992 - foresterre:example/is-terminal, r=ChrisDenton 1ac1917a30b Rollup merge of #124948 - blyxyas:remove-repeated-words, r=compiler-errors 06a9a23637b fix typo ba159a255aa Fix typo in assert message 3b0d7dd0264 cfg-out unused code under no_global_oom_handling 384f038779a fmt 04721832c89 Add example to IsTerminal::is_terminal d1266c020d0 Auto merge of #123786 - a1phyr:cursor_unsafe, r=joboet 7863dc042a4 Fix stacked borrows violation 21c11bd5b61 Use a single static for all default slice Arcs. c679ab1950f Rollup merge of #125252 - beetrees:patch-1, r=joboet b3f781f2643 Rollup merge of #124304 - hermit-os:fuse, r=joboet 98bffed5fed Rollup merge of #123709 - tgross35:windows-cmd-docs-update, r=ChrisDenton 2142227aac1 use posix_memalign on most Unix targets 9f8d3ea2dc2 Auto merge of #124640 - Billy-Sheppard:master, r=dtolnay bf12abc8f50 Add NULL check in argument parsing on Apple platforms 646bb352533 Auto merge of #99969 - calebsander:feature/collect-box-str, r=dtolnay 7bc106a346a compiler: add simd_ctpop intrinsic 55c28feaeb9 use `Result::into_ok` on infallible result. 482bb890808 specialize `Iterator::fold` for `vec::IntoIter` df07c1b88c6 optimize in_place_collect with vec::IntoIter::try_fold db9d6a3b395 optimize in-place collection of `Vec` c2c219f6152 Rollup merge of #125251 - jonhoo:patch-1, r=Nilstrieb a88f3b4e375 Clarify how String::leak and into_boxed_str differ fb4bd2606e3 Fix typos (taking into account review comments) 1592914f1e5 Add `#[inline]` to float `Debug` fallback used by `cfg(no_fp_fmt_parse)` e45d57432b8 android: use posix_memalign for aligned allocations 999555af636 Add a warning to Delimiter::None that rustc currently does not respect it. 0b0e2d364e2 Inline Duration construction into Duration::from_{millis,micros,nanos} 4eda65b0a39 Update libc to 0.2.155 53d59c073ab Use `_NSGetArgc`/`_NSGetArgv` on iOS/tvOS/watchOS/visionOS b40c1d0c1ee Use `_NSGetEnviron` instead of `environ` on iOS/tvOS/watchOS/visionOS af75a82c685 Don't call Duration::new unnecessarily in Duration::from_secs 7a1a8f8c91e Auto merge of #125188 - tgross35:f16-f128-powi, r=Nilstrieb 71bd73b4e28 Rollup merge of #125186 - Colepng:master, r=lqd 86db585bdd7 Rollup merge of #125171 - scottmcm:rename-flatten, r=jhpratt 0723341d800 Access alloc field directly in Arc/Rc::into_raw_with_allocator. 73fdfc16789 Auto merge of #125163 - ssukanmi:stdarch_arm_crc32, r=Amanieu fd06d10c9e6 Add `powi` to `f16` and `f128` 6954e6f2d04 Add doctests for f16 and f128 library functions where possible 141c381f15c Remove duplicate word from addr docs 408d5023dfb Auto merge of #124728 - beetrees:from-f16-for-f64, r=BurntSushi e183d5dc565 Fix linkchecker doc errors 31ce4e41a6a Turn bare links into automatic links f8a6ecd62b0 Move BufGuard impl outside of function 52f196b770d Fix tidy errors c75c5ef8225 Replace sort implementations 4482b420146 Auto merge of #124959 - prorealize:update-result-documentation, r=joboet 52a4fdb7380 Rename `flatten(_mut)` → `as_flattened(_mut)` ccff9ad5d50 Rollup merge of #125003 - RalfJung:aligned_alloc, r=cuviper 60a8c252f7c feat: update stdarch submodule for intrinsics on ARM 5c3fa3c2d51 Allow for_loops_over_fallibles in test that tests &mut Result as IntoIterator. 69fd96dbc9b Rollup merge of #125038 - ivan-shrimp:checked_sub, r=joboet 7ca6ba6e2a4 Rollup merge of #124307 - reitermarkus:escape-debug-size-hint-inline, r=joboet 2375574036e Update library/core/src/result.rs a532cda5189 Divide float nanoseconds instead of seconds 6a891073736 avoid using aligned_alloc; posix_memalign is better-behaved 2624267cf3d Fix `read_exact` and `read_buf_exact` for `&[u8]` and `io:Cursor` 0798b25080b Rollup merge of #116675 - joshlf:patch-10, r=scottmcm 72bdb6b7446 Add fn into_raw_with_allocator to Rc/Arc/Weak. ceb3a78d2ea Forward alloc features to core 8d29d37cb6d Rollup merge of #123817 - slanterns:seek_relative, r=dtolnay 4c411ef6ef4 [ptr] Document maximum allocation size 807d22fa137 Don't use `T` with both Result and Option, improve explanation. 79d0ece58c5 Add `size_of`, `size_of_val`, `align_of`, and `align_of_val` to the prelude 4960c053565 Panic if `PathBuf::set_extension` would add a path separator 02ade56bb85 offset, offset_from: allow zero-byte offset on arbitrary pointers 1403be6f4be Use shared statics for the ArcInner for Arc::default, and for Arc<[T]>::default where alignof(T) <= 16. b39298294a4 Add note about possible allocation-sharing to Arc/Rc::default. 5435cf411a3 added Default impls 359535200d1 Auto merge of #125045 - GuillaumeGomez:rollup-em6qdzw, r=GuillaumeGomez 1fc83b8ab2a Rollup merge of #125021 - joshlf:patch-11, r=RalfJung b65daec8c1c Auto merge of #124798 - devnexen:illumos_memalign_fix, r=RalfJung 919ca69ecb0 Auto merge of #125012 - RalfJung:format-error, r=Mark-Simulacrum,workingjubilee 552160619ef reference type safety invariant docs: clarification 91112b552ba reverse condition in `uN::checked_sub` 4d7a55490d5 Rollup merge of #124981 - zachs18:rc-allocator-generalize-1, r=Mark-Simulacrum 7b2e82fbb1d References must also be non-null 9ae766cff1a Relax slice safety requirements 21153fd0ef7 std::alloc: using posix_memalign instead of memalign on solarish. 5d6bbf95861 Auto merge of #124213 - rust-lang:cargo_update, r=Mark-Simulacrum dca8574b8f0 Pin libc back to 0.2.153 0da557faa1f io::Write::write_fmt: panic if the formatter fails when the stream does not fail 1e1820bf730 Add flag to sysroot ec05b81fb91 Add flag to std and alloc too a7648816290 Add opt-for-size core lib feature flag c34a96d7170 Rollup merge of #124954 - kpreid:fmterr, r=Nilstrieb 9658f52e230 Rollup merge of #124928 - okaneco:trim_ascii, r=workingjubilee 9b2a572d62e Rollup merge of #124991 - Infinixius:patch-1, r=Nilstrieb 09d0b87d2f3 Rollup merge of #124766 - devnexen:getrandom_solarish, r=Mark-Simulacrum e95fd11379a Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str` faf86f458d3 Fix typo in ManuallyDrop's documentation 30d2b9f85d4 Relax A: Clone requirement on Rc/Arc::unwrap_or_clone. 059b47516cc Relax allocator requirements on some Rc APIs. c897a150389 Add fn allocator method to rc/sync::Weak. Relax Rc/Arc::allocator to allow unsized T. 87770453f4c Auto merge of #124863 - DaniPopes:from-str-radix-panic, r=Amanieu b2047f53694 Fix assert ce6e62e0717 Auto merge of #124774 - the8472:subnanosecond-benches, r=jhpratt 92ad0ad9c85 Rollup merge of #124551 - Swatinem:debug-str-bench, r=cuviper c6cb72d98ea Refactor examples and enhance documentation in result.rs dfe8c04bc3d Document proper usage of `fmt::Error` and `fmt()`'s `Result`. d3cbab52aeb Suggest borrowing on fn argument that is `impl AsRef` f5d5642aa91 Auto merge of #124773 - Marcondiro:master, r=joboet 10b75ae3e5c Improve escape methods. d26045c5664 Auto merge of #124793 - scottmcm:simplify-as-chunks, r=Nilstrieb cdfd52f9561 Auto merge of #124910 - matthiaskrgr:rollup-lo1uvdn, r=matthiaskrgr 30a8013fa23 Rollup merge of #124892 - jfgoog:update-cc, r=workingjubilee b7aea296a87 Avoid panicking branch in `EscapeIterInner`. 9b6ca097493 Inline `EscapeDebug::size_hint`. 0d2c0161f16 Auto merge of #124795 - scottmcm:simplify-slice-from-raw-parts, r=joboet 74676bb1f02 Use generic `NonZero`. 1ccbab8eb0d Use generic `NonZero` in examples. 534cb35406c miri: rename intrinsic_fallback_checks_ub to intrinsic_fallback_is_spec 6bc6b210d97 Update cc crate to v1.0.97 658c718fcc9 fix #124714 str.to_lowercase sigma handling 49d088835f4 Rollup merge of #124838 - RalfJung:next_power_of_two, r=scottmcm 4a5702cf9f0 Rollup merge of #124788 - madsmtm:reduce-target_os-macos, r=workingjubilee 7f1e64a2146 Rollup merge of #124782 - anatawa12:docs-create-new-already-exists, r=workingjubilee d1f537346eb Rollup merge of #124470 - devnexen:no_sigpipe_fbsd, r=workingjubilee d6eb94325fe use teletype on the attribute name 13a2f8054c0 Some Result combinations work like an Option. b0688cf1363 from_str_radix: outline only the panic function e50b848129a Move `test_shrink_to_unwind` to its own file. dc1de5c9667 Fix `VecDeque::shrink_to` UB when `handle_alloc_error` unwinds. adb3b4fbd7e Auto merge of #124836 - tgross35:const-slice-last-chunk, r=BurntSushi fa556034e31 next_power_of_two: add a doctest to show what happens on 0 1ec7090aac7 Correct the const stabilization of `last_chunk` for slices 4597918ee61 f16::is_sign_{positive,negative} were feature-gated on f128 a23252a2b33 Auto merge of #124811 - matthiaskrgr:rollup-4zpov13, r=matthiaskrgr 1be824fb86d Rollup merge of #124520 - tbu-:pr_create_dir_all_doc, r=Amanieu 44cd79782e4 Auto merge of #123850 - tspiteri:f16_f128_consts, r=Amanieu de185b1097c std::rand: adding solaris/illumos for getrandom support. d76a6f229c4 Auto merge of #124497 - rytheo:move-std-tests-to-library, r=workingjubilee ea455b34d88 Avoid a cast in `ptr::slice_from_raw_parts(_mut)` 329b23a907a Implement `as_chunks` with `split_at_unchecked` db05c1dbad9 iOS/tvOS/watchOS/visionOS: Improve File Debug impl 48214e074dc iOS/tvOS/watchOS/visionOS: Fix reading large files 508f761f338 iOS/tvOS/watchOS: Fix alloc w. large alignment on older versions 04d7793d621 iOS/tvOS/watchOS/visionOS: Set the main thread name 4dafc79c48c Apply suggestions from code review d98b0e4697e iOS/tvOS/watchOS/visionOS: Default to kernel-defined backlog in listen bc59da56bba add note about `AlreadyExists` to `create_new` 1e6ab2df8d4 emit fractional benchmark nanoseconds in libtest's JSON output format 624a8b312d9 print walltime benchmarks with subnanosecond precision 307861fbe3c alloc: implement FromIterator for Box 21d45f91024 Rename test for issue 21058 ab087fb3408 Rollup merge of #124750 - ultrabear:ultrabear_softfloatdoc, r=workingjubilee ec49fda04e4 Rollup merge of #124749 - RossSmyth:stable_range, r=davidtwco 4a0b7a4bc7b Fix unwinding on 32-bit watchOS ARM 0234560e26c Re-add `From for f64` 98c101f8c95 Make f128 docs mention lack of any normal platform support 657932157d1 Make f16 and f128 docs clearer on platform support f05660e8199 Tgross feedback tweaks d7900d1b4ba Rollup merge of #124721 - ids1024:netbsd-32-bit-ulong, r=workingjubilee 36df34289c6 library/std: Fix build for NetBSD targets with 32-bit `c_long` 2811501f695 Rollup merge of #124699 - scottmcm:split_at_unchecked_should_use_unchecked, r=Nilstrieb 6b60a38c6b6 Rollup merge of #122441 - a1phyr:improve_read_impls, r=ChrisDenton 77a48b10b1f Rollup merge of #124701 - scottmcm:unchecked_sub_docs, r=Nilstrieb 3e716c4034f Rollup merge of #124700 - scottmcm:unneeded_cast, r=Nilstrieb 4ef43e26b98 Rollup merge of #124293 - oli-obk:miri_intrinsic_fallback_body, r=RalfJung 78a5278be71 Rollup merge of #124159 - joboet:move_pal_thread_parking, r=ChrisDenton 1574d7d24bb Rollup merge of #123356 - joboet:set_current_size, r=ChrisDenton 4bf91226263 Docs: suggest `uN::checked_sub` instead of check-then-unchecked 550b5b91afb Remove an unnecessary cast 359e778bed9 Use `unchecked_sub` in `split_at` a2f9f2d8d9e mark const_(de)allocate intrinsics as suitable for Miri 893e586671b Rollup merge of #124681 - risc0:erik/fix-test, r=joboet 2341d824b70 Rollup merge of #124678 - UserIsntAvailable:feat/stabilize-split-at-checked, r=jhpratt b6c000947eb Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxu f0e66c4ea57 zkvm: fix run_tests 040e68f1326 feat: stabilize `split_at_checked` 13c7c9fd50f Rollup merge of #124593 - GKFX:cstr-literals-in-api-docs, r=workingjubilee 222bf9a7d9f Rollup merge of #124059 - RalfJung:default_alloc_error_hook, r=workingjubilee 25e6b74caa9 Rollup merge of #123815 - trueb2:patch-1, r=workingjubilee 0e3a7461eaa Rollup merge of #122492 - GrigorenkoPV:ptr_as_ref_unchecked, r=workingjubilee 56de4e2aec5 default_alloc_error_hook: explain difference to default __rdl_oom in alloc f9694632249 Use `CURRENT_RUSTC_VERSION` 8da93dee8a1 Stabilize `div_duration` fa4d2212f4c Rollup merge of #124649 - Meziu:master, r=ChrisDenton a1ee8894715 Ensure miri only uses fallback bodies that have manually been vetted to preserve all UB that the native intrinsic would have f666075c95c Horizon OS: dirfd unavailable 185cb92d4c0 Rollup merge of #124626 - RalfJung:const_eval_select, r=joboet 3b10d428db6 Rollup merge of #124609 - RalfJung:float-precision, r=cuviper 343be6d840a Rollup merge of #124604 - Enselic:std-gimli-symbolize, r=workingjubilee 9c7cd7db364 Rollup merge of #124441 - bravequickcleverfibreyarn:string.rs, r=Amanieu b53858bc782 Rollup merge of #124412 - RalfJung:io-safety, r=Amanieu 9e5845152d9 Rollup merge of #123480 - Nadrieril:impl-all-derefpures, r=compiler-errors ecd925f7dac Stabilize exclusive_range d56e6540e43 Update based on review 3d8e0bdda73 Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` 04fcf674873 variable-precision float operations behave non-deterministically 3c43945ffad const_eval_select: add tracking issue 54356820213 add constants in std::f128::consts b2d32718de7 add constants in std::f16::consts 8efa49a759c add f128 associated constants 22fdff01c7b add f16 associated constants 31dbf86082e Auto merge of #124419 - WaffleLapkin:never-type-fallback-docs, r=workingjubilee 17ed628747c std: move thread parking to `sys::sync` bf106d74466 library/std: Remove unused `gimli-symbolize` feature b5c5c6110bf fixup links in never type docs 7f6e81a67db Workaround rustfmt bug replacing type ascription 08bc91361aa Slightly reformat !'s docs after applying github suggestions c7e03711044 Step bootstrap cfgs 15e4a002340 Apply suggestions from code review 6491fe80182 Replace version placeholders for 1.79 b3c62888afe Describe and use CStr literals in CStr and CString docs 75873fd1649 Rollup merge of #124542 - CBSpeir:diagnostic-item-enumerate-method, r=scottmcm d430e208c87 Add benchmarks for `impl Debug for str` 6d7e5471bc1 Auto merge of #124491 - madsmtm:target_vendor-apple, r=workingjubilee 7d9a9081caa std: rewrite TLS on platforms without threads 9e2da1e8b00 Add diagnostic item for std::iter::Iterator::enumerate 8141cd924f6 Rollup merge of #124530 - djkoloski:fuchsia_dirfd, r=tmandry 49b3c98805a Document that `create_dir_all` calls `mkdir`/`CreateDirW` multiple times ff14fb43486 Rollup merge of #124484 - GKFX:offset_of_must_use, r=jieyouxu c97f6ac1813 Fix Fuchsia build broken by #124210 212638ff73b Fix ESP IDF build broken by #124210 1efef70a68a Auto merge of #124502 - NCGThompson:statically-known-docs, r=jhpratt f10848082a6 Update is_val_statically_known docs c97dc382051 Run tidy on tests 7cb823d6cf9 Stabilize `non_null_convenience` 2a3e9b954a6 Fix posix_spawn not being used on iOS and visionOS 0c1b948ff6c Move various stdlib tests to library/std/tests 7e648dfbf57 Fix va_list on watchOS and visionOS 75d1b1f4f5e Fix SIGEMT and SIGINFO parsing on watchOS and visionOS 405ae05fd32 Fix available_parallelism on watchOS and visionOS 0c59f55a8ad Fix #124478 - offset_of! returns a temporary 6b48700cd49 std::net: Socket::new_raw set to SO_NOSIGPIPE on freebsd/netbsd/dragonfly. ff09ce6350a Use `target_vendor = "apple"` instead of `target_os = "..."` cc30ef962e7 Auto merge of #124210 - the8472:consign-ebadf-to-the-fire, r=Mark-Simulacrum efa7b9f7ac2 put FD validity behind late debug_asserts checking e06c29891fd Rollup merge of #124447 - workingjubilee:set-argv-twice-on-gnu, r=ChrisDenton 74ee689b493 Unconditionally call really_init 105bea3aea5 Lift the probe code of `copy_file_range` into a function 4be9873ee4d Elaborate in comment about `statx` probe eeb8c9fc39f WS fix. cee06e1dfe0 String.truncate calls Vec.truncate, in turn, and that states "is greater or equal to". Beside common sense. 8f6d6e960de Auto merge of #124432 - zetanumbers:non_copy_into_raw_with_alloc, r=Nilstrieb d4a1b9ac306 Relax `A: Clone` bound for `rc::Weak::into_raw_and_alloc` a120b7081da io safety: update Unix explanation da2d7acb5f2 Rollup merge of #124387 - workingjubilee:use-raw-pointers-in-thread-locals, r=joboet 799d16fc799 thread_local: refine LazyKeyInner::take safety doc 0000310c6a2 Rollup merge of #124410 - RalfJung:path-buf-transmute, r=Nilstrieb 1803bf4b2a2 Apply suggestions from code review 7e431b0b8dc Add missing .into_iter() 7202be92220 Extend the example code and assert the result 1c2c6615bb3 Document never type fallback in `!`'s docs 89d8d2ab999 Add "safety" comment 6b60118c704 Auto merge of #123909 - dtolnay:utf8chunks, r=joboet 23d191f5df6 PathBuf: replace transmuting by accessor functions 81231b9a7d9 Auto merge of #124393 - scottmcm:do-the-macros-still-matter, r=joboet c431a872696 Convert some iter macros to normal functions 79a7647eacf Rollup merge of #124076 - NobodyXu:patch-1, r=dtolnay 74828691a1f thread_local: split refs to fields of Key 6cfc0c42536 thread_local: use less &mut T in LazyKeyInner::take 17a73fbb844 remove trivial bounds 20077f268e7 Stabilize Utf8Chunks bc4ed78ba08 Rollup merge of #124351 - Treeniks:master, r=workingjubilee fa213e00882 Rollup merge of #124335 - ChrisDenton:stabilize-absolute, r=dtolnay aaace1a07a4 Rollup merge of #124322 - whosehang:master, r=Nilstrieb 46069b7152a fix typo in binary_heap docs c9ddab4fe95 Auto merge of #124330 - fmease:rollup-a98y7jf, r=fmease 956cbb80587 Fix cannot usage in time.rs 70f9d87e1eb Stabilize `std::path::absolute` 640e03832a5 Add `cfg_attr(bootstrap)` to doc tests 702117a3bdb Stabilise `inline_const` 77c5af7bb9e Rollup merge of #124308 - CBSpeir:diagnostic-item-enumerate, r=compiler-errors 953477272ba Rollup merge of #124282 - RalfJung:fill_utf16_buf, r=ChrisDenton 0acced3e908 Rollup merge of #124281 - RalfJung:win-tls, r=joboet b63e8ad970a Error on using `yield` without also using `#[coroutine]` on the closure b9414eec571 chore: fix some typos in comments f2c314b9363 Add diagnostic item for std::iter::Enumerate c3107644f41 increase the readability by using the unique name for the hermit-abi ec896c3cf40 Auto merge of #124302 - matthiaskrgr:rollup-2aya8n8, r=matthiaskrgr 1d0ce986cf8 Rollup merge of #124003 - WaffleLapkin:dellvmization, r=scottmcm,RalfJung,antoyo 3f34e012bad revise the interpretation of ReadDir 8e0b95646b0 Rollup merge of #123048 - RalfJung:layout, r=dtolnay 70e33800f6c unroll first iter of checked_ilog loop to save one multiplication 626512ae93e Rollup merge of #123050 - RalfJung:panic_str, r=m-ou-se cf9f5255c8d fix weak memory bug in TLS on Windows f895cd6ebc0 windows fill_utf16_buf: explain the expected return value abf53322bf8 Rollup merge of #124266 - RalfJung:no-answer, r=joboet cc00effa321 Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obk 1de1d3e96f8 Rollup merge of #124230 - reitermarkus:generic-nonzero-stable, r=dtolnay d8883110b87 Rollup merge of #115913 - FedericoStra:checked_ilog, r=the8472 c06f3148471 remove an unused type from the reentrant lock tests 546340b598f export assert_unsafe_precondition macro for std-internal use 38d9c0d2871 Stabilize generic `NonZero`. 8522a186fa1 Rollup merge of #124246 - gurry:add-comma-in-abs-doc, r=jhpratt ca99f717d54 Add comma at one place in `abs()` documentation 7cab83af40a Update stdarch submodule 327bbcc1c0b Address more PR feedback 7e6742d86ee Use it in the library, and `InstSimplify` it away in the easy places 45aa399cf23 Add an intrinsic that lowers to AggregateKind::RawPtr 31c01278216 Rollup merge of #124184 - gurry:124152-suggest-unsigned-abs-in-abs-doc, r=jhpratt 607f2ae795f Rollup merge of #124089 - simlay:fix-preadv64-and-pwritev64-link-for-watchos-and-visionos, r=workingjubilee d9f365666d7 Fix watchOS and visionOS for pread64 and pwrite64 calls 13b211a8c18 Auto merge of #123930 - Mark-Simulacrum:vec-length-invariant, r=jhpratt adf6c6935ac Avoid reloading Vec::len across grow_one in push 020aa089cf9 Auto merge of #124208 - jieyouxu:rollup-gbgpu4u, r=jieyouxu 99a861f3b58 Abort a process when FD ownership is violated 62529450c0f Rollup merge of #124103 - dtolnay:metadatadebug, r=Mark-Simulacrum 1d5b1b01e99 Rollup merge of #123976 - ChrisDenton:no-libc-in-std-doc-tests, r=Mark-Simulacrum d696bb8c251 Rollup merge of #123967 - RalfJung:static_mut_refs, r=Nilstrieb df3821115e7 Auto merge of #122013 - Swatinem:unicode-gen-fastpath, r=scottmcm 9284fe0d3c9 Add a lower bound check to `unicode-table-generator` output b3d7a1e6508 Suggest using `unsigned_abs` in `abs` documentation 438a2fa30fb Auto merge of #124114 - scottmcm:better-checked, r=workingjubilee 0c8dc9808fe Rollup merge of #124116 - RalfJung:miri-rust-backtrace, r=Nilstrieb e85b21b6138 Rollup merge of #124019 - ChrisDenton:futex-raw-dylib, r=joboet f26cb8428f0 Rollup merge of #123406 - krtab:fix_remainder_iterchunk, r=scottmcm 4d322c866fa Make `checked` ops emit *unchecked* LLVM operations where feasible ded7bdb64d6 Auto merge of #123144 - dpaoliello:arm64eclib, r=GuillaumeGomez,ChrisDenton,wesleywiser 6491a04d3fd when suggesting RUST_BACKTRACE=1, add a special note for Miri's env var isolation e6e2c6da919 Improve std::fs::Metadata Debug representation 0f6609a7649 fix: make `str::from_raw_parts_mut` mut fc86ae97179 Rollup merge of #124049 - slanterns:const_io_structs_stabilize, r=jhpratt 494ab509e86 Rollup merge of #122201 - coolreader18:doc-clone_from, r=dtolnay ac04e230d4a Stablise io_error_downcast a240ce9257a Address comments 4056b28a4a1 Rollup merge of #124051 - dtolnay:emptyset, r=compiler-errors 53f06f2b506 Fix empty-set symbol in comments 3257e50899b Stabilize `const_io_structs` bd485bd0d05 Rollup merge of #124013 - RalfJung:box-to-raw, r=oli-obk a6b0dabfc88 Rollup merge of #123859 - krtab:uneeded_clone, r=cuviper 59b060738b7 Rollup merge of #123811 - joboet:queue_em_up, r=ChrisDenton 270382c6c25 Add simple async drop glue generation f7053801c02 Use raw-dylib for Windows futex APIs 1d14988f5dd std: fix lint on SGX fb2360a0cd1 Remove uneeded clones now that TrustedStep implies Copy ba9434b485a Rollup merge of #123721 - madsmtm:fix-visionos, r=davidtwco db726d84f20 Stabilize `BinaryHeap::as_slice` d7466ca6fbd Box::into_raw: make Miri understand that this is a box-to-raw cast 06e68632f38 Update usage note on OpenOptions::append() c7a980c115e Change intrinsic types to use `u32` instead of `T` to match stable reexports 1ea6b1b79e0 Add support for Arm64EC to the Standard Library 00c74c77f1a Rollup merge of #123970 - risc0:erik/zkvm-fix-os-str, r=joboet dd2f1ad185e Use fake libc in core test 8e0a8631619 Auto merge of #123968 - jieyouxu:rollup-1pnkxor, r=jieyouxu 14d801314dd static_mut_refs: use raw pointers to remove the remaining FIXME 79f5a782b5e zkvm: fix references to `os_str` module 6bfea369341 Rollup merge of #123957 - RalfJung:create_dir_all_bare, r=joboet 85bfbddad3a Rollup merge of #123548 - RalfJung:what-is-time, r=joboet a48060e8cb7 Auto merge of #123937 - RalfJung:miri-link-section, r=oli-obk de5053694ab Auto merge of #123851 - NobodyXu:patch-1, r=BurntSushi 9ce66a0f262 Update doc for std::io::Error::downcast ff69673d680 Remove bound checks from `BorrowedBuf` and `BorrowedCursor` methods 2df703cc1ba disable create_dir_all_bare on all(miri, windows) 83b02c38628 libtest: also measure time in Miri 6dd0bedd26e Auto merge of #123928 - tbu-:pr_statx_enosys, r=workingjubilee ccdb524485b Add vec_deque::Iter::as_slices and friends 3bc0a433e72 Rollup merge of #123915 - shenawy29:patch-1, r=Nilstrieb 3b654646088 Rollup merge of #120900 - marcospb19:std-use-seek-stream-position, r=joshtriplett 5bcc7cb2376 Miri: run .CRT$XLB linker section on thread-end d9cc1e00845 `statx` probe: `ENOSYS` might come from a faulty FUSE driver 9f1235ba062 Auto merge of #122268 - ChrisDenton:no-libc, r=Mark-Simulacrum 8968ce8f754 improve documentation slightly regarding some pointer methods 68fa46c2f37 Move msvc libs to core 2cfb7e74b30 Replace libc::c_int with core::ffi::c_int d66d9404a87 Rollup merge of #123879 - beetrees:missing-unsafe, r=Mark-Simulacrum 2891f2b4ac0 Rollup merge of #123875 - Ghamza-Jd:master, r=joboet 3b471f32f8e Rollup merge of #123779 - semarie:notgull-openbsd-socket, r=Mark-Simulacrum f214c7c1ba5 Rollup merge of #123651 - tgross35:thread-local-updates, r=Mark-Simulacrum f11a682ce65 Auto merge of #107462 - WaffleLapkin:from_iterator_for_tuple, r=dtolnay 680169ad823 Auto merge of #123819 - joboet:fmt_usize_marker, r=Mark-Simulacrum 47812561dba Rollup merge of #123876 - dpaoliello:backtrace, r=ChrisDenton cb1a90d9c8c Rollup merge of #123716 - Kriskras99:patch-2, r=Mark-Simulacrum c677db543ee doc note that f16 and f128 hardware support is limited f1ac5c4681d Rollup merge of #123868 - eduardosm:stabilize-slice_ptr_len, r=jhpratt 3001449034c Rollup merge of #123835 - saethlin:vec-from-nonnull, r=the8472 572c3513277 Add missing `unsafe` to internal `std::thread::Thread` creation functions 1d1d67e8554 Add missing `unsafe` to internal function `std::sys::pal::unix::thread::min_stack_size` 03413289fc5 Update backtrace submodule 64e05f86c5a chore: replace x with y for hexa-decimal fmt e43f8fcb496 Avoid more NonNull-raw-NonNull roundtrips in Vec b07a1385244 Rollup merge of #123867 - eduardosm:unsafe-fns, r=ChrisDenton c901cebeedf Rollup merge of #123858 - marijanp:fix-zkvm-cmath-path, r=joboet c35f5490b18 Rollup merge of #123857 - devnexen:tcp_listener_update_backlog, r=ChrisDenton 2048e8c2a99 Rollup merge of #123807 - joboet:sys_common_thread, r=jhpratt 81e3e8c38a4 Stabilize (const_)slice_ptr_len and (const_)slice_ptr_is_empty_nonnull fb3299b8567 Add `unsafe` to two functions with safety invariants c878b78d0e7 zkvm: remove cmath 902a6f6cdce std::net: TcpListener shrinks the backlog argument to 32 for Haiku. 380e449e625 Rollup merge of #123852 - kamaboko123:fix_typo_in_std_lib_rs, r=lqd 78066a3e9e8 Rollup merge of #123833 - dpaoliello:stdarch, r=Amanieu c3c01c1253e Rollup merge of #123825 - saethlin:report-nounwind-panics, r=petrochenkov fea18247399 Auto merge of #123846 - matthiaskrgr:rollup-85y28av, r=matthiaskrgr 760285b70ac Update document for std::io::Error::downcast c8eb4e064ae fix typo in library/std/src/lib.rs f3fd3a1e95f Rollup merge of #123842 - ShockYoungCHN:master, r=scottmcm c9065b3dc4d Rollup merge of #123830 - tgross35:f16-f128-from-inference-fix, r=Nilstrieb ccafde8389b Auto merge of #123783 - tgross35:f16-f128-debug-impl, r=Amanieu 5ca8154728f core: get rid of `USIZE_MARKER` ef8ccea711a Avoid panicking branch in `append_to_string` f6e93dfe373 `VecDeque::read_to_string`: avoid making the slices contiguous c58aea7a7ae Improve several `Read` implementations af310eb148f Auto merge of #123490 - niluxv:strict_prov_unwind_seh, r=Amanieu 0397bfdba17 fix pin.rs typo 1c30855a3e0 Rollup merge of #123826 - kornelski:one-in-a-quintillion, r=Amanieu 925e3a87e1e Auto merge of #120092 - zetanumbers:pin_in_static_allocator, r=Amanieu 5a8ba6fe184 Update stdarch submodule 754d557214d Remove `From` impls for unstable types that break inference e1e4698acb2 Auto merge of #123823 - matthiaskrgr:rollup-8zdtggx, r=matthiaskrgr 05b173bcb69 Call the panic hook for non-unwind panics in proc-macros 1d4505681a0 Move rare overflow error to a cold function 9f8bc2ec7c1 Rollup merge of #123806 - joboet:advanced_overflow, r=Amanieu 556acdb6a18 Rollup merge of #123798 - tniessen:patch-1, r=workingjubilee cd88bf619c4 Rollup merge of #122882 - Zoxc:panic-output-panic, r=Amanieu cf6591dda9f Auto merge of #123814 - matthiaskrgr:rollup-lxn0t4t, r=matthiaskrgr be54c0581b4 Add a `Debug` impl and some basic functions to `f16` and `f128` b97359da5f1 Refactor `panic_unwind/seh.rs` pointer use; x86 now conforms to strict-provenance d0fcce25f61 Stabilize `Seek::seek_relative` 87b824cc6a5 Auto merge of #123732 - a1phyr:io_error_factor, r=cuviper 125843050e8 std: use queue-based `RwLock` on Windows 7 305477898e5 std: use queue-based `RwLock` on Xous 620d2332fa0 std: use queue-based `RwLock` on SGX ec19cc38e0b std: remove `sys_common::thread` 3f3042417b5 core: panic on overflow in `BorrowedCursor` 4a042479dd6 Avoid invalid socket address in length calculation 3a7f7b002eb OpenBSD fix long socket addresses 130ec552c2e Factor some common `io::Error` constants 5e61f72c88b Correct broken link in core::pin doc 1ab495236ec Rollup merge of #123756 - lukas-code:file-sync, r=jhpratt d536d22206a Rollup merge of #123661 - tgross35:stabilize-cstr_count_bytes, r=dtolnay 16aa29dec5e Rollup merge of #123360 - adamgemmell:dev/adagem01/restricted-std, r=ehuss 7a35beff5df Rollup merge of #122470 - tgross35:f16-f128-step4-libs-min, r=Amanieu cd19f686ef7 clean up docs for `File::sync_*` 21dfd6a4e65 Add primitive documentation for `f16` and `f128` 207b90a00af Add basic f16 and f128 modules 1aed39a4127 Add basic library support for `f16` and `f128` 245eb08f951 Revert "Put basic impls for f16 and f128 behind cfg(not(bootstrap))" e7317d75899 Auto merge of #123725 - GuillaumeGomez:rollup-gk2bbrg, r=GuillaumeGomez b563a5852a4 Rollup merge of #123534 - ChrisDenton:name, r=workingjubilee d37b9bb3a21 visionOS: Fix unused import warning 0d854c85914 Rework Path::ancestors documentation to remove unwraps 1dc750b5b43 Auto merge of #122393 - a1phyr:specialize_read_buf_exact, r=joboet ddb2666b3bf Bring documentation of Path::to_path_buf in line with the rest of Path/PathBuf bd065cf35e3 Auto merge of #122812 - dtolnay:mode, r=workingjubilee b01be2b0fc6 Update documentation related to the recent cmd.exe fix 42c80e035a8 Rollup merge of #123633 - bjorn3:unsupported_command_data, r=jhpratt 87f90907701 Show mode_t as octal in std::fs Debug impls 6e06d838577 Add comment on UTF-16 surrogates 45601f73ad6 Windows: set main thread name without reencoding c1ef053f045 Add const UTF-8 to UTF-16 conversion macros bdd3d24d340 Auto merge of #123683 - pietroalbini:pa-cve-2024-24576-nightly, r=pietroalbini 16232a669c8 Auto merge of #123485 - madsmtm:use-libc-copyfile, r=joboet 89a5de27a32 Fix dead code warning fd07874be7a Rollup merge of #123665 - Jules-Bertholet:patch-1, r=lqd 292e83b59b8 Rollup merge of #123254 - stepancheg:thin-box-0-const-alloc, r=oli-obk 58f8858cce4 Fix typo in `Future::poll()` docs a038522a24b Stabilize `cstr_count_bytes` 7c274be766d Document Windows argument splitting a059e90c7bf Disallow or quote all specials in bat args 953457f1948 Change method calls to using the method directly d983724915d Add `SAFETY` comments to the thread local implementation e3acccfde28 Update thread local docs with idiomatic cell type use 1f91bc229d7 Rollup merge of #123564 - scottmcm:step-by-div-zero, r=joboet 8b991cc1bca Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errors a939022f473 Store all args in the unsupported Command implementation 074d81fa153 Rollup merge of #123595 - balaganesh102004:master, r=joboet 18c2dccb959 Rollup merge of #123089 - Philippe-Cholet:vecdeque_pop_assume_cap, r=Nilstrieb 07f863d0301 Rollup merge of #115984 - hermit-os:fuse, r=m-ou-se 50491cece71 Add pattern types to parser a64ca4d640c std: update abort message in `thread::set_current` 8604cb6231c Add invariant to VecDeque::pop_* that len < cap if pop successful e83fe3c2255 Auto merge of #123506 - RalfJung:miri-test-libstd, r=Mark-Simulacrum 9b317179421 Auto merge of #123597 - Gbd199:patch-1, r=jhpratt 7b5ff907756 Fix typo in library/core/src/iter/traits/iterator.rs 21f4c993994 Made changes in documentation 4dfb615c9ac Auto merge of #123592 - matthiaskrgr:rollup-3k1pq8s, r=matthiaskrgr 6b67f47d83a Auto merge of #123561 - saethlin:str-unchecked-sub-index, r=scottmcm 922cec4ae8a sys_common::thread_local_key: make a note that this is not used on Windows 25325820480 make a doctest less slow in Miri 941e33f8f60 also test parts of std 1833b7bb8b6 disable benches in Miri 3fa5151ffe7 Rollup merge of #123522 - dtolnay:constatomicintoinner, r=Nilstrieb 23aa17468f3 Rollup merge of #123411 - saethlin:ub-checks, r=Urgau,RalfJung c8b6cd2bcd6 Rollup merge of #119224 - Duckilicious:test_main_memory_leak, r=cuviper 18b300f0b54 Don't emit divide-by-zero panic paths in `StepBy::len` 60a5a350f92 Use unchecked_sub in str indexing 536637f6c23 Drop panic hook after running tests 44b4aa0af7c Rollup merge of #123541 - RalfJung:remove-old-hacks, r=Mark-Simulacrum f724f67344a Put checks that detect UB under their own flag below debug_assertions 0404c382dc5 Rollup merge of #122291 - lilasta:stabilize_const_location_fields, r=dtolnay 2fefa97605b Rollup merge of #114788 - tisonkun:get_mut_or_init, r=dtolnay 603b6524b59 remove miri-test-libstd hacks that are no longer needed f764c8501e0 Rollup merge of #123528 - dtolnay:asyncgeninternals, r=compiler-errors fcfb76ba9a7 Hide async_gen_internals from standard library documentation a9e50dc35bc Auto merge of #123433 - GnomedDev:remove-threadname-alloc, r=joboet e7f9043a152 Stabilize const Atomic*::into_inner eb0f10bb9d2 Rollup merge of #123505 - ChrisDenton:revert-121666, r=workingjubilee 49199a825a1 Rollup merge of #121419 - agg23:xrOS-pr, r=davidtwco d5150c2e327 Do not allocate for ZST ThinBox attempt 2 (using const_allocate) 2649657d75c Auto merge of #123317 - RalfJung:test-in-miri, r=m-ou-se,saethlin,onur-ozkan 21c433767b7 Revert #121666 e896a990b0e macOS: Use `libc` definitions for copyfile 623d5365a66 Rollup merge of #123206 - stepancheg:pointee-metadata-freeze, r=Amanieu 5cfca8b2a99 Remove rt::init allocation for thread name 519a037b000 Impl `DerefPure` for more std types 4a8a2c86c38 Rollup merge of #123431 - slanterns:literal_byte_character_c_string_stabilize, r=dtolnay 4961fce1a0b Rollup merge of #123389 - ChrisDenton:dont-panic-on-startup, r=joboet e16914e0b23 Add comments about using debug_assert 3c86646a51c force exhaustion in iter::ArrayChunks::into_remainder 998f9e33bd2 Rollup merge of #122356 - devnexen:dfbsd_build_fix, r=jhpratt f47dc6908c0 Stabilize `Literal::c_string` fff32d9ae08 Stabilize `Literal::byte_character` 76ee2cec506 Rollup merge of #122964 - joboet:pointer_expose, r=Amanieu dbab18a2cc5 add 'x.py miri', and make it work for 'library/{core,alloc,std}' bf1ea2d8f2f Add docs for `FromIterator<(AE, BE)> for (A, B)` cee53a057bb Implement `FromIterator<(AE, BE)>` for `(impl Default+Extend, impl Default+Extend)` 4a97fb5fc5a rename `expose_addr` to `expose_provenance` 15edc22ad08 std: add comment about abort motivation cc45df8dc56 Auto merge of #123390 - tgross35:f16-f128-libs-basic-impls-bootstrap, r=jhpratt 55a35287b35 Rollup merge of #123388 - tshepang:consistency, r=jhpratt 7afddf3ff73 Rollup merge of #122411 - alexcrichton:wasm32-wasip2-cabi-realloc, r=m-ou-se 0f3895aaf81 Rollup merge of #123203 - jkarneges:context-ext, r=Amanieu d0eb8279f96 Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=Amanieu 71a7c8d7f3e set tracking issue c921e8ef293 Auto merge of #123385 - matthiaskrgr:rollup-v69vjbn, r=matthiaskrgr 34f651a90c1 Put basic impls for f16 and f128 behind cfg(not(bootstrap)) 6232c988a2b Avoid panicking unnecessarily on startup b6a7990d933 use a consistent style for links 4958b21105f Rollup merge of #123226 - scottmcm:u32-shifts, r=WaffleLapkin 319f295e79f Rollup merge of #123198 - krtab:build_hasher_default_const_new, r=Amanieu f93c8a31f7f Auto merge of #118310 - scottmcm:three-way-compare, r=davidtwco 1b601f94285 DOC: Add FFI example for slice::from_raw_parts() 5d124e52758 Document restricted_std 48308a4e2e2 std: reduce code size of `set_current` e0ec6c2f83b style: fmt b1363228b7e fix: build on haiku by adding missing import e61e64ae63d Auto merge of #122945 - andy-k:sorted-vec-example, r=jhpratt 2ae49a19d78 Rollup merge of #123323 - devnexen:thread_set_name_solaris_fix, r=workingjubilee b6ed4f90267 std::thread: set_name change for solaris/illumos. 35b9a2dcb52 Auto merge of #123315 - devnexen:thread_get_name_solaris, r=ChrisDenton 980cd5ee873 Auto merge of #123265 - joboet:guardians_of_the_unix, r=ChrisDenton 486be3ad465 update comment 336d558a970 std::thread: adding get_name implementation for solaris/illumos. 2b62a8e9dd5 Fix error message for `env!` when env var is not valid Unicode 57ed947cacf Auto merge of #123270 - JaniM:janim/string-alloc-doc, r=workingjubilee c1251576537 doc: mention heap allocation earlier in String docs 49aae14cabe Auto merge of #123299 - workingjubilee:rollup-2z8amaj, r=workingjubilee 487424e1b4e Rollup merge of #123271 - JaniM:janim/sliceindex-doc, r=Nilstrieb 4813f7c921d Rollup merge of #123268 - RalfJung:dont-freeze, r=Nilstrieb 83536e9dab1 warn against implementing Freeze c925d7a354f std::thread: adding get_name haiku implementation. 20c6f6e7663 doc: describe panic conditions for SliceIndex implementations 2fa01b5f30e catch_panic: warn about panicking payload drop dcb7e4763ca std: move `thread::current` TLS variable out of `thread_info` f125e84d394 std: move UNIX stack overflow guard page handling into `stack_overflow.rs` 59278aa3d14 Auto merge of #123233 - devnexen:thread_get_name_bsd, r=joboet 9289f4d648e Require Pointee::Metadata to be Freeze 3ea09f2a6bd Auto merge of #123181 - stepancheg:pointee-metadata-debug, r=the8472,Amanieu 88e12679e5f Auto merge of #123085 - tgross35:f16-f128-step4.0-libs-basic-impls, r=Amanieu 572b49adf09 Auto merge of #99322 - GKFX:const-int-parse, r=Mark-Simulacrum 0173e167683 std::thread: adding freebsd/netbsd to the linux's get_name implementation. 4f6eb57bba6 Rollup merge of #123201 - Wilfred:patch-2, r=Nilstrieb a7cb248611d Make {integer}::from_str_radix constant 97176797e6e De-LLVM the unchecked shifts [MCP#693] 1b2a662bc48 Auto merge of #121948 - Gankra:stab-align, r=dtolnay 88cb6e240f3 Auto merge of #122976 - caibear:optimize_reserve_for_push, r=cuviper 97e4a368605 stabilize ptr.is_aligned, move ptr.is_aligned_to to a new feature gate 41f625cd886 Auto merge of #122520 - scottmcm:stabilize_unchecked_math_basics, r=jhpratt 03ed9bb505d rustfmt 6a297e8fcf0 Auto merge of #121268 - Urgau:improve_ambi_wide_ptr_cmps, r=Nadrieril e59384e0164 Add `Context::ext` 02425ff5214 Improve wording in std::any explanation 5f6549d0e09 Add fn const BuildHasherDefault::new c490d47aabe Add detection of [Partial]Ord methods to the ambiguous wide ptr cmp lint e8380639b84 Add diagnostic items for Ord and PartialOrd methods c41bdd60dfd Auto merge of #122616 - Jules-Bertholet:casemappingiter-layout, r=Nilstrieb a88de2766aa Require Debug for Pointee::Metadata 6c7b3b1b393 Auto merge of #122975 - DianQK:simplify_ub_check, r=saethlin 0eaf3a173ec Auto merge of #122671 - Mark-Simulacrum:const-panic-msg, r=Nilstrieb df4650828f8 Rename reserve_for_push to grow_one and fix comment. a2fad1ecba7 Fix previous. c9a31d100d2 Remove len argument from RawVec::reserve_for_push because it's always equal to capacity. Also make Vec::insert use reserve_for_push. 7340193b0f9 Add basic trait impls for `f16` and `f128` 6132d9c6c4c Rollup merge of #123164 - Marcondiro:unicode15-1, r=Manishearth 7768f13d276 Bump Unicode printables to version 15.1, align to unicode_data 2a61f6b0970 Rollup merge of #123139 - scottmcm:simpler-nonzero-get, r=jhpratt 9ca94a815cb Rollup merge of #123136 - Vagelis-Prokopiou:fix/docs, r=ChrisDenton 88543c7af8f Rollup merge of #123133 - xiaoxiangxianzi:master, r=fmease 8ebe94db28f Rollup merge of #121943 - joshlf:patch-11, r=scottmcm ebbe84a8a34 `num::NonZero::get` can be 1 transmute instead of 3 a36de4c123b Less generic code for Vec allocations cca3bf4a926 Some wording improvement 6bc9c91c910 chore: fix some comments 737ed636a15 Eliminate `UbCheck` for non-standard libraries 949b301dd88 Auto merge of #123128 - GuillaumeGomez:rollup-3l3zu6s, r=GuillaumeGomez 335c0b712cc Rollup merge of #123083 - klensy:clippy-me, r=workingjubilee d11e5dd3230 impl get_mut_or_init and get_mut_or_try_init for OnceCell and OnceLock c97c4f2bc06 Auto merge of #116016 - jhpratt:kill-rustc-serialize, r=ehuss 2cb1405b975 Rollup merge of #123118 - tgross35:rwlock-docs, r=workingjubilee 64a799b4fa2 Rollup merge of #123107 - avandesa:vec_pop_if, r=joboet 69be57d45c5 Rollup merge of #123084 - a1phyr:unixstream_read_buf, r=workingjubilee 3751e77aa71 Rollup merge of #123038 - he32:netbsd-ilp32-fix, r=workingjubilee 78af43f3bf2 Rollup merge of #122880 - a1phyr:preadv_more_platform, r=workingjubilee ff3708bd416 Update `RwLock` deadlock example to not use shadowing 94e1e8e7c99 Implement `Vec::pop_if` 40cb2751aea Rollup merge of #123057 - sthibaul:systemtime, r=jhpratt 999ff5e7625 Rollup merge of #122835 - compiler-errors:deref-pure, r=Nadrieril 2642ef31972 Rollup merge of #123086 - ding-young:fix-ref-to-BufWriter, r=the8472 f9ed598e40e unix fs: Make hurd and horizon using explicit new rather than From c8426243412 Auto merge of #122939 - joboet:proc_macro_bridge_state, r=petrochenkov 79201b09ba4 Unix: Support more platforms with `preadv` and `pwritev` 8cfabcf89d3 `UnixStream`: override `read_buf` 2df939c4c51 Fix link to BufWriter 21b55af8b58 std library unix/thread.rs: fix NetBSD code for ILP32 CPUs. b5dca8400e4 panic_str only exists for the migration to 2021 panic macros 55f44f00d78 Extract helper, fix comment on DerefPure 526df9e15c4 Require DerefPure for patterns 54a7b1e9cfd Rollup merge of #123042 - dpaoliello:prelude, r=Nilstrieb 9406d0107e3 Rollup merge of #122896 - dpaoliello:stdarch, r=Amanieu 52a110e7037 Rollup merge of #122707 - reedwoodruff:string_docs_typo, r=workingjubilee 2ffaffdda7e lib: fix some unnecessary_cast clippy lint 55377612b5e Import the 2021 prelude in the core crate b2ccf22e65b alloc::Layout: explicitly document size invariant on the type level 7d2e86eebc0 Rollup merge of #122990 - SkiFire13:transmute-may-copy, r=jhpratt 1aa0310ef43 Address PR feedback 60876b97dd4 Amended wording f646e435435 Slightly simplify the `iN::partial_cmp` MIR 7141085b5d0 Rollup merge of #122992 - devnexen:available_parallelism_sol_upd, r=Amanieu 21419e2f1fd Rollup merge of #122984 - RalfJung:panic-in-hook, r=Amanieu 8f8c4ca4cd8 Rollup merge of #122983 - taiki-e:bsd, r=workingjubilee 6fd16a0d96c Rollup merge of #122977 - cuviper:as_statically_known_str, r=RalfJung 828ae6011eb fix build. f2d3b862f77 std::thread: refine available_parallelism for solaris/illumos. d44c62825ea Clarify transmute example 283b5a94d66 panic-in-panic-hook: formatting a message that's just a string is risk-free e6a31aa29c2 Fix build failure on ARM/AArch64/PowerPC/RISC-V FreeBSD/NetBSD f610834d000 Add+Use `mir::BinOp::Cmp` 92d5fbe3b22 Rollup merge of #122797 - alexcrichton:fix-compile-wasm64, r=Mark-Simulacrum 26bdca38ca1 Rollup merge of #122762 - RoboSchmied:RoboSchmied-typo, r=workingjubilee 5036c277e12 Rollup merge of #120419 - Ayush1325:uefi-sys-os, r=nicholasbishop,workingjubilee 93f61e356e1 Rename `Arguments::as_const_str` to `as_statically_known_str` 3be20daff19 Auto merge of #122966 - matthiaskrgr:rollup-20k8nsm, r=matthiaskrgr 356d7aa395e clarify equivalency of binary_search and partition_point cc4e8db070e Rollup merge of #122963 - RalfJung:core-panicking, r=m-ou-se 6b0d6512c1d Rollup merge of #122379 - RalfJung:int2ptr-transmute, r=m-ou-se 63c43e33942 Auto merge of #122905 - dpaoliello:sync-portable-simd-2024-03-22, r=workingjubilee fd55276deea Fixed builds with modified libc db9c32c943f also rename the SIMD intrinsic 5bf9c0c8186 Auto merge of #122629 - RalfJung:assert-unsafe-precondition, r=saethlin a7e2eb3aa8c core/panicking: fix outdated comment 823a6351ed6 try adding a test that LowerHex and friends don't panic, but it doesn't work 2c645cf6e33 refactor check_{lang,library}_ub: use a single intrinsic, put policy into library 3c455fd3bb2 move assert_unsafe_preconditions to its own file 51159e89818 Auto merge of #122947 - matthiaskrgr:rollup-10j7orh, r=matthiaskrgr f0186024cb3 Rollup merge of #122931 - herobs:patch-1, r=joboet ada902d97bd Rollup merge of #122930 - RalfJung:panic-in-panic-fmt, r=Amanieu 8d8d982d5ef Rollup merge of #122916 - MultisampledNight:docs-sync-typo, r=jhpratt 06c9a5adf45 Rollup merge of #120577 - wutchzone:slice_split_at_unchecked, r=m-ou-se 27893739293 Auto merge of #122582 - scottmcm:swap-intrinsic-v2, r=oli-obk 7396da5497a improve example on inserting to a sorted vector to avoid shifting equal elements 8bbd344b3b2 rename ptr::from_exposed_addr -> ptr::with_exposed_provenance 952d5fdb787 proc_macro: simplify bridge state a6db29c9653 Fix some typos in the pin.rs 3b7c3f9f5eb add panic location to 'panicked while processing panic' 2220e84d098 Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlin 79777421ee1 Merge commit 'cff979eec1ac0473fc4960ee6cde462c6aeda824' into sync-portable-simd-2024-03-22 9def51c250b docs(sync): normalize dot in fn summaries 3ec17b1896a Remove RustcEncodable/Decodable from 2024 prelude b9ce1810061 Soft-destabilize `RustcEncodable`/`RustcDecodable` f213523ad1f Update stdarch submodule ac5eace8e8c `swap_simple` no longer needs to be a separate function b7137a8bc8b Avoid a panic in `set_output_capture` in the default panic handler c061d5f4ddc Codegen const panic messages as function calls 5f24cd47da1 Rollup merge of #122800 - zachs18:nonnull-slice-is_empty, r=Amanieu 05bf33ce73a Auto merge of #122024 - clubby789:remove-spec-option-pe, r=jhpratt 6f7e6955cc9 Rollup merge of #122829 - ShoyuVanilla:gen-block-impl-fused-iter, r=compiler-errors 4b8f860f039 Rollup merge of #122817 - ultrabear:ultrabear_btreedoc, r=Nilstrieb 36ba87bd95a Rollup merge of #121881 - devnexen:bsd_acceptfilter, r=Amanieu 8a5b28bc34b Not insta-stable 3e3015ef197 Auto merge of #122785 - the8472:const-select-specialized-impl, r=Amanieu f6be344d7c8 Implement `FusedIterator` for `gen` block 057ddb9bb5f Implement macro-based deref!() syntax for deref patterns 761ad301279 Stabilize `const_caller_location` and `const_location_fields` e233f1b2730 Rollup merge of #122806 - compiler-errors:type-ascribe, r=fmease de3c6bc13ac document into_iter in top level docs iterator ordering guarantees 57f3a839944 document iteration ordering on into_iter method instead of IntoIterator implementation d4aa974368e BTree(Set|Map): Guarantee that `IntoIter` will iterate in sorted by key order e3880e000b0 Make type_ascribe! not a built-in db738feffbe Rollup merge of #122765 - workingjubilee:test-for-vec-handling-usize-max, r=Nilstrieb d182d5abf7c Rollup merge of #122729 - m-ou-se:relax, r=Amanieu 51364b387cc Add `NonNull::<[T]>::is_empty` as insta-stable. 206bbdb1949 Fix compile of wasm64-unknown-unknown target bc5c83e8991 Auto merge of #122761 - jwong101:fix/vec-insert, r=workingjubilee,Nilstrieb 70218cf5290 select Vec::from_iter impls in a const block to optimize compile times 8788cc74f12 std::net: adding acceptfilter feature for netbsd/freebsd. a748754e178 Update target.rs alloc.rs event.rs simd.rs de9032f3cc3 SeqCst->Relaxed in condvar test. 17202a70e4f SeqCst->Relaxed in thread local test. a647ff1f554 SeqCst->Relaxed in std::net::test. 67f7f610895 Use less restricted memory ordering in xous::thread_local_key. 2898b0a0145 Auto merge of #122754 - Mark-Simulacrum:bootstrap-bump, r=albertlarsan68 9e9eaec3a4f step cfgs 15cb013aae6 Auto merge of #120717 - compiler-errors:cap-closure-kind, r=oli-obk ded8a8d283a improve codegen of fmt_num to delete unreachable panic a4d2cb6f01e Add usize::MAX arg tests for Vec 8e8cddc03e2 Rollup merge of #122739 - Sky9x:insert-put, r=jhpratt 6aefe1bfd53 Rollup merge of #122730 - ferrocene:hoverbear/qnx-ucred-cfgs, r=Amanieu 41957a97582 Rollup merge of #121543 - onur-ozkan:clippy-args, r=oli-obk 583657a0ee0 fix OOB pointer formed in Vec::index 3a30ee0b586 branch 1.78: replace-version-placeholder f92412dc4b6 resolve clippy errors f26f8d217d2 Only split by-ref/by-move futures for async closures 7f5b7074059 Add "put" as a confusable for insert on hash map/set 257c94f9943 Rollup merge of #122720 - heisen-li:offset_of, r=workingjubilee 6cbc3a072e4 Manually implement `PartialOrd`/`Ord` for `Option` ee1ce62f1ca Remove `SpecOptionPartialEq` bb747a3e50b Expose ucred::peer_cred on QNX targets to enable dist builds 7ca36f28696 SeqCst->Relaxed for xous set_nonblocking. 465fff4bf3d SeqCst->{Release,Acquire} for xous DropLock. 43d50414ecd SeqCst->Relaxed in pal::windows::pipe. 48687efd33e SeqCst->{Release,Acquire} for wasm DropLock. d17e2965e29 SeqCst->{Release,Acquire} in sys_common::thread_local_key. cc4d152906a Use less restricted memory ordering in thread_parking::pthread. 0dadc4d6d92 SeqCst->{Release,Acquire} in xous mutex. 458541e8e7a SeqCst->Relaxed for FIRST_PANIC. 6ff2463889a SeqCst->{Release,Acquire} for alloc error hook. fbd6a41ce8b SeqCst->Relaxed for proc_macro bridge counter. ad5476f66d3 SeqCst->Relaxed in panic_unwind/emcc. a99221ad71a SeqCst->Relaxed in doc examples. 823be162418 [doc]:fix error code example 5b479f8e72d Make ptr_guaranteed_cmp a rustc_intrinsic and favor its body over backends implementing it da9d0053ea8 Make `vtable_align` a rustc_intrinsic 00e972eb3d7 Make `const_eval_select` a rustc_intrinsic 1050e1713b1 add notes on how to store 'ptr or int' a816fc862f3 Support for visionOS 77b07c87770 Reimplement `CaseMappingIter` with `core::array::IntoIter` 722681d4acc Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obk 5cc0bd225b4 Rollup merge of #122675 - tmfink:doc-clarify, r=scottmcm 606cbbbb47a Rollup merge of #122642 - pallix:improve-wording-for-vec-swap_remove, r=Amanieu c02c84df128 Fix a typo in the alloc::string::String docs d556613c12c remove retag_box_to_raw, it is no longer needed 764fff48eae add_retag: ensure box-to-raw-ptr casts are preserved for Miri 8243ae55c22 Let codegen decide when to `mem::swap` with immediates d8b47afa9f3 Improve wording of `Vec::swap_remove` 452861e888b Expand sys/os for UEFI 0009e856c5c chore(121952): echo comments on the `*_assign` methods 8b1d183815c chore(121952): remove redundant comments 94f32dbd7be feat: implement `{Div,Rem}Assign>` on `X` 2dab65de534 Rollup merge of #119411 - yotamofek:array-ptr-get, r=Nilstrieb 7f04e7685a8 core: document default attribute stabilization ecb8a821c74 Optimize `core::char::CaseMappingIter` layout 19443a7ef1e Auto merge of #121885 - reitermarkus:generic-nonzero-inner, r=oli-obk,wesleywiser 13ea67e434c Rollup merge of #122601 - joboet:ptr_replace, r=workingjubilee 117bcdd2552 Add as_(mut_)ptr and as_(mut_)slice to raw array pointers 677c6c14959 Rollup merge of #122583 - Zoxc:tls-non-mut, r=joboet 83c4f67ed90 Rollup merge of #122390 - ChrisDenton:bindgen, r=Mark-Simulacrum c4208116135 core: optimize `ptr::replace` f22efff1c50 Use `UnsafeCell` for fast constant thread locals 61345e5e3a8 Rollup merge of #122562 - Wilfred:break_keyword_docs, r=workingjubilee b96a08018b0 Workaround issue 122566 9e23a2408ff Mention labelled blocks in `break` docs 82cbcca5b0e Rollup merge of #122512 - baitcode:2024-03-14-buffer-documentation-fix, r=Nilstrieb 5cc327e0a83 Stabilize `unchecked_{add,sub,mul}` da3ff8ccf8f Auto merge of #122511 - matthiaskrgr:rollup-swzilin, r=matthiaskrgr 4ec55f8a9ae Use rust-lang/backtrace-rs@6fa4b85 857c0821a36 Rollup merge of #122498 - jfgoog:update-cc-crate-version, r=workingjubilee 6cd231d00c3 Rollup merge of #122479 - GrigorenkoPV:duration_millis_float, r=scottmcm 31f1effd269 Rollup merge of #121650 - GrigorenkoPV:cap_setgid, r=Amanieu 9198af6288a Fix minor documentation issue. Code outside the test would fail. Seek documentation clearly states that negative indexes will cause error. Just making the code in the example to return Result::Ok, instead of Result::Error. 26bd3587ce7 Update version of cc crate 50ef24066ca Hide implementation details for `NonZero` auto traits. 88bf02ffc40 Rollup merge of #119029 - dylni:avoid-closing-invalid-handles, r=ChrisDenton ba8b2e98eea Implement ptr_as_ref_unchecked (#122034) 417b9b0f3f4 Auto merge of #122483 - matthiaskrgr:rollup-n07dsh5, r=matthiaskrgr d4255285d35 Rollup merge of #122461 - the8472:fix-step-forward-unchecked, r=Amanieu 708b6064e09 Rollup merge of #122421 - CAD97:step-trait-docs, r=jhpratt decd6c04ff5 Rollup merge of #104353 - clarfonthey:cstr-bytes-iter, r=cuviper 668f32c92eb Auto merge of #114038 - Stargateur:108277, r=ChrisDenton 32a339b9d61 fix unsoundness in Step::forward_unchecked for signed integers 64efcf42050 Implement `Duration::as_millis_{f64,f32}` 2402ef71612 Provide `cabi_realloc` on `wasm32-wasip2` by default d1be94ab625 Get wasm32-wasip2 compiling with its custom pal implementation b99c1260bbd Rollup merge of #122386 - joboet:move_pal_once, r=jhpratt 5857db48778 Rollup merge of #122255 - Nadrieril:min_exh_pats-libs, r=scottmcm 843c6c14e91 Improve Step docs 3f3c5905c0c Reduce unsafe code, use more NonNull APIs per @cuviper review 656a8c68e61 Specialize many implementations of `Read::read_buf_exact` 29ecec3a8f2 transmute: caution against int2ptr transmutation d56fdb394cf Convert [u8] to [i8] in test 8bc4b38ec34 Bump windows-bindgen to 0.55.0 967d8bbcfa0 Bump windows-bindgen to 0.54.0 19c07168b55 std: move `Once` implementations to `sys` 33342bf8505 Fix typo in lib.rs of proc_macro d07cce7bf98 Allow dead code in sys/pal 307388f1c6e Allow dead code in thread local dtor 4b8bc550b46 Remove unused fields in some structures ad8a5f5bcae Use `min_exhaustive_patterns` in core & std fdf85d66a57 std::rand: fix dragonflybsd after #121942. 1c647fa2075 Auto merge of #122036 - alexcrichton:test-wasm-with-wasi, r=oli-obk 41b60e63e0e libtest: Print timing information on WASI 840465c8e62 Rollup merge of #121438 - coolreader18:wasm32-panic-unwind, r=cuviper 4b847da54fc Auto merge of #122331 - jhpratt:rollup-cbl8xsy, r=jhpratt e443b539b19 Rollup merge of #122326 - Zoxc:win-alloc-tweak, r=ChrisDenton 3a3e4e2cc56 Rollup merge of #122298 - RalfJung:raw-vec-into-box, r=cuviper f656f9aa674 Rollup merge of #122002 - devnexen:thread_stack_netbsd_fix, r=workingjubilee,riastradh 41931b0921f Rollup merge of #121840 - oli-obk:freeze, r=dtolnay 1f2fbec62f2 Rollup merge of #121633 - ChrisDenton:precise, r=Nilstrieb 2caf3f7104c Rollup merge of #121148 - clarfonthey:try-range, r=dtolnay 28d054c9613 Auto merge of #117156 - jmillikin:os-unix-socket-ext, r=Amanieu,dtolnay 2c902a09064 Optimize `process_heap_alloc` d645cfd493e Auto merge of #122312 - matthiaskrgr:rollup-0p8y7gg, r=matthiaskrgr 5c451edf14e Rollup merge of #122302 - ratmice:issue122234, r=cuviper af538a64ecb Rollup merge of #122277 - RalfJung:BorrowedCursor, r=cuviper 2e65cc0a581 Rollup merge of #122276 - RalfJung:io-read, r=Nilstrieb debbd39c35a Rollup merge of #122275 - RalfJung:std-oom, r=workingjubilee 52dce3d881b Add CStr::bytes iterator 62e135e6745 Update backtrace submodule to 0.3.70 65d864b923b docs: Correct ptr/ref verbiage in SliceIndex docs. cb58e3d9577 RawVec::into_box: avoid unnecessary intermediate reference ce9e56149e7 Fix lint. 085cbdd15a4 Move generic `NonZero` `rustc_layout_scalar_valid_range_start` attribute to inner type. 929a52b348b Rollup merge of #122271 - pitaj:diag_items-legacy_numeric_constants, r=Nilstrieb 0c7cc4f21ca Rollup merge of #122244 - tvallotton:local_waker_leak_fix, r=Nilstrieb 8a31d3e715a Rollup merge of #121942 - devnexen:getrandom_for_dfbsd, r=joboet d33236cd1f2 Rollup merge of #113525 - workingjubilee:handle-dynamic-minsigstksz, r=m-ou-se 51e6111fc81 Rollup merge of #112136 - clarfonthey:ffi-c_str, r=cuviper e6f7e52492f BorrowedCursor docs clarification 72f451ff184 io::Read trait: make it more clear when we are adressing implementations vs callers c06f02c1d53 disable OOM test in Miri d1e0f315f9a fix legacy numeric constant diag items 5da734f8b6d Auto merge of #121662 - saethlin:precondition-unification, r=RalfJung d5ec6d7b13f Rollup merge of #121711 - ChrisDenton:junction, r=Mark-Simulacrum 24b4db1fbcb Rollup merge of #121403 - kornelski:io-oom, r=dtolnay 55dbe44814e Rollup merge of #121280 - ajwock:maybeuninit_fill, r=Amanieu 428e485f3f3 Rollup merge of #120504 - kornelski:try_with_capacity, r=Amanieu e1370c0d6a1 Rollup merge of #114655 - nbdd0121:io-safety, r=dtolnay f26c2204518 Rollup merge of #99153 - Dajamante:issue/95622, r=dtolnay d9ee3ade4b9 Explain why we don't use intrinsics::is_nonoverlapping e601d1b4adb fix: remove memory leak due to missing drop implementation for local waker. Also, fix some of the stability attributes of LocalWaker's methods. 7707b4678b8 NonZero::from_mut_unchecked is library UB 2fa6f39a9be Avoid closing invalid handles 1c070b3de54 Improve docs c1894b1292e Rollup merge of #122233 - RalfJung:custom-alloc-box, r=oli-obk 90c892c7350 Rollup merge of #122232 - RalfJung:misc, r=jhpratt fb734bb8fa1 Rollup merge of #121358 - GnomedDev:lower-align-typeid, r=Mark-Simulacrum 42e57d7eaa4 miri: do not apply aliasing restrictions to Box with custom allocator 8043559aab7 fn is_align_to: move some comments closer to the cast they refer to 15d027c8e45 fix warning when building libcore for Miri 5be1f4bf5ef Auto merge of #122095 - lukas-code:windows-shutdown-test, r=ChrisDenton 276c7f9d9c4 Distinguish between library and lang UB in assert_unsafe_precondition 9b8f2ac2d25 further changes from feedback e0afcda6cc4 Stabilize associated type bounds 735f8e288bb Rollup merge of #121201 - RalfJung:align_offset_contract, r=cuviper b5cb278869e Document overrides of `clone_from()` 1cb78a4d4f7 align_offset, align_to: no longer allow implementations to spuriously fail to align 1bff9d0ac69 Rollup merge of #122099 - Urgau:btreemap-inline-new, r=Amanieu 24347de1af0 Rollup merge of #121938 - blyxxyz:quadratic-vectored-write, r=Amanieu dd6990a9183 Rollup merge of #120608 - kornelski:slice-ptr-doc, r=cuviper 4186f5a7bde Rollup merge of #118623 - haydonryan:master, r=workingjubilee b0d0478d100 Auto merge of #122059 - nyurik:with-as-const-str, r=cuviper e507088ee00 Rollup merge of #122147 - kadiwa4:private_impl_mods, r=workingjubilee c509dfe4841 Rollup merge of #119888 - weiznich:stablize_diagnostic_namespace, r=compiler-errors dacc719a7fe make `std::os::unix::ucred` module private 9f793333ebc Rust is a proper name: rust → Rust 876471f5905 Auto merge of #122113 - matthiaskrgr:rollup-5d1jnwi, r=matthiaskrgr 13dbe439434 Rollup merge of #122088 - ChrisDenton:fixme, r=workingjubilee 1113bd26d9f Rollup merge of #122072 - KonradHoeffner:patch-1, r=cuviper f70d9158fe2 Rollup merge of #122091 - ChrisDenton:comment, r=RalfJung 10ef01be263 Rollup merge of #122074 - KonradHoeffner:patch-2, r=jhpratt b1eb51c5c00 Rollup merge of #113518 - jyn514:streaming-failures, r=cuviper 26b0c7a21bf Document and test minimal stack size on Windows 695a9123f3f Add #[inline] to BTreeMap::new constructor 84344fe28fc Dynamically size sigaltstk in std 125ed220c83 fix `close_read_wakes_up` test a59a1460f29 Note why we're using a new thread in a test 2bb823695c0 Remove unnecessary fixme ed01a049db8 Be stricter with `copy_file_range` probe results b5eea9ff8d2 Auto merge of #121956 - ChrisDenton:srwlock, r=joboet 7e42a6162ee Less syscalls for the `copy_file_range` probe 9607411d5fa add missing PartialOrd impl doc for array e8bad064486 Refer to "slice" instead of "vector" in Ord and PartialOrd trait impl of slice a7b7d9df510 unix time module now return result 9e0f5270d71 Optimize write with as_const_str for shorter code b80fe5590cf Rollup merge of #122018 - RalfJung:box-custom-alloc, r=oli-obk a553631b382 Rollup merge of #122016 - RalfJung:will_wake, r=dtolnay 84b6bb886a4 Rollup merge of #121894 - RalfJung:const_eval_select, r=oli-obk 0ae6320f80d Rollup merge of #121065 - CAD97:display-i18n, r=cuviper 99f17fd58d6 Add `Waitable` trait 8543b4553d6 Implement MaybeUninit::fill{,_with,_from} b6613449d96 Auto merge of #121428 - okaneco:ipaddr_parse, r=cuviper 8079a3df105 only set noalias on Box with the global allocator e69ed7e7466 Auto merge of #121138 - Swatinem:grapheme-extend-ascii, r=cuviper f57980c51fc will_wake tests fail on Miri and that is expected a3910673e64 Auto merge of #122012 - matthiaskrgr:rollup-bzqjj2n, r=matthiaskrgr 6e8625c3b6e Rollup merge of #121826 - estebank:e0277-root-obligation-2, r=oli-obk 2005594b367 Rollup merge of #121287 - zachs18:rc-into-raw-must-use, r=cuviper 0a4a98caaca Rollup merge of #121262 - 20jasper:add-vector-time-complexity, r=cuviper c08b6e9fcf0 Rollup merge of #121213 - Takashiidobe:takashi/example-for-rc-into-inner, r=cuviper d86610e97a9 Auto merge of #121001 - nyurik:optimize-core-fmt, r=cuviper 17c9c50e313 libtest: Print the names of failed tests eagerly dca1c983a42 doc wording improvements d5fdf9b16f7 Explain use of display adapters 0f268282c75 Windows: Implement mutex using futex f3d4ecae933 Auto merge of #120675 - oli-obk:intrinsics3.0, r=pnkfelix 5574148db47 Add benches for `net` parsing e5488ecb57b net: Add branch to Parser::read_number for parsing without checked arithmetic 6d8fb0eb1b4 std::threads: revisit stack address calculation on netbsd. 0aee466df1e Rollup merge of #121977 - Lee-Janggun:master, r=WaffleLapkin 102cba312e3 Rollup merge of #121968 - roblabla:fix-win7, r=jhpratt 9048edb97f3 Rollup merge of #121939 - jonaspleyer:patch-typo-core-From-descr, r=workingjubilee 998a00ff9f2 Rollup merge of #121732 - Voultapher:improve-assert_matches-documentation, r=cuviper faa37b2d88d Rollup merge of #120976 - matthiaskrgr:constify_TL_statics, r=lcnr 327b010c4fe Add a scheme for moving away from `extern "rust-intrinsic"` entirely 7318a3502e3 Fix comment in Atomic{Ptr,Bool}::as_ptr. 41c1726c9a8 include feedback from workingjubilee 060f2eb96e9 Don't run test_get_os_named_thread on win7 b6ae7bf5760 Rollup merge of #121935 - RalfJung:ptr-without-prov, r=scottmcm 5af77f8e41b Be more lax in `.into_iter()` suggestion when encountering `Iterator` methods on non-`Iterator` 2739e4810ac Use root obligation on E0277 for some cases 10e95beb24c Update library/core/src/sync/atomic.rs 9cd74986b82 Update library/core/src/sync/atomic.rs 890bc292d33 Use "size and alignment" rather than layout a4621e7af8d Document AtomicPtr bit validity fc9829267d1 Clarify bit validity for AtomicBool 72165ab6988 Clarify atomic bit validity 13fd7a81578 std::rand: enable getrandom for dragonflybsd too. 3e7b7a5a461 Apply suggestions from code review 63aac65d9c6 Small enhancement to description of From trait c0d36a06bce Fix quadratic behavior of repeated vectored writes 6b794d9e9af library/ptr: mention that ptr::without_provenance is equivalent to deriving from the null ptr 4124f4a624b Add missing get_name for wasm::thread. 59c5aef0931 Auto merge of #121856 - ChrisDenton:abort, r=joboet ee84abd91bd Auto merge of #121914 - Nadrieril:rollup-ol98ncg, r=Nadrieril 96622d7dac4 Rollup merge of #121622 - dtolnay:wake, r=cuviper bb174bc869f Cleanup windows abort_internal ff8b963adc0 typo fefc6e560cd Rollup merge of #121888 - cppcoffee:style, r=Nilstrieb 52ff10be6cd Rollup merge of #121759 - RalfJung:addr_of, r=the8472 f1e948a995a Rollup merge of #121758 - joboet:move_pal_thread_local, r=ChrisDenton 64fa9d12b8d Rollup merge of #121666 - ChrisDenton:thread-name, r=cuviper 0cdbbbc808b const_eval_select: make it safe but be careful with what we expose on stable for now 67cdbd93d80 Apply review comments 264b620c37d attempt to further clarify addr_of docs d53dd95eda6 Rollup merge of #121861 - tbu-:pr_floating_point_exact_examples, r=workingjubilee 872cfaab045 Rollup merge of #121847 - shamatar:btreemap_fix_implicits, r=cuviper dc21b251532 Rollup merge of #121835 - nnethercote:mv-HandleStore, r=bjorn3 dbbe22b5fdd Rollup merge of #109263 - squell:master, r=cuviper c7c51c513ec style library/core/src/error.rs 82de3fecabe Rollup merge of #121730 - ecnelises:aix_pgo, r=wesleywiser f8436a7f104 Rollup merge of #121634 - RavuAlHemio:slice-prefix-suffix-docs, r=cuviper 0c8ac0fc840 Add `get_name` placeholder to other targets cc39393eb60 Move capacity_overflow function to make ui tests change less 01bd949a2ce try_with_capacity for Vec, VecDeque, String 9bfd5cb51f6 try_with_capacity for RawVec c738b137502 Use the guaranteed precision of a couple of float functions in docs e3ee3fc56cf Rollup merge of #121850 - reitermarkus:generic-nonzero-unsafe-trait, r=Nilstrieb 1f1d8a34c96 Rollup merge of #121736 - HTGAzureX1212:HTGAzureX1212/remove-mutex-unlock, r=jhpratt 2f47d2060af Make `ZeroablePrimitive` trait unsafe. 5e3e0469c21 remove hidden use of Global f2f8e5add62 revise interface to read directory entries 3403eb8afc1 Extending filesystem support for hermit-os fb819c2c7fb Move `HandleStore` into `server.rs`. 60f6b89a3ef Auto merge of #114016 - krtab:delete_sys_memchr, r=workingjubilee 2c9002f7799 Rollup merge of #121809 - tgross35:suggest-path-split-fixup, r=Amanieu a00722a6a93 Rollup merge of #121753 - mu001999:core/add_cfg, r=cuviper 006b4375955 Rollup merge of #121681 - jswrenn:nix-visibility-analysis, r=compiler-errors 0af17bae454 Remove doc aliases to PATH f3727698341 Rollup merge of #121596 - ChrisDenton:tls, r=joboet 24629388092 Forbid implementing `Freeze` even if the trait is stabilized 9800850ca11 Expose `Freeze` trait again 82da63da20c Rollup merge of #121793 - tbu-:pr_floating_point_32, r=Amanieu 543e113b8c8 Rollup merge of #121765 - hermit-os:errno, r=ChrisDenton eb5bdaf26f1 Rollup merge of #118217 - tbu-:pr_floating_point, r=Amanieu e86bd4ac250 Document which methods on `f32` are precise d4028ac9503 Document the precision of `f64` methods a3f17573c49 Rollup merge of #121778 - ibraheemdev:patch-19, r=RalfJung a58eb41ac81 Rollup merge of #121768 - ecton:condvar-unwindsafe, r=m-ou-se 8e939aea343 Rollup merge of #120291 - pitaj:string-sliceindex, r=Amanieu 69e0848ae25 Rollup merge of #119748 - tgross35:suggest-path-split, r=Amanieu dd92108f221 Drop link to matches macro and link matches macro to assert_matches. c53446727e1 fix typos f4153b33d23 document potential memory leak in unbounded channel de1d0ffe7bf Add proper cfg c9e88b061e1 Rollup merge of #110543 - joboet:reentrant_lock, r=m-ou-se 0f8d424f9e0 Implement unwind safety for Condvar 144c310427e add platform-specific function to get the error number for HermitOS d3f2bc207af std: move thread local implementation to `sys` 62737bbb94d Rollup merge of #121691 - janstarke:handle-missing-creation-time-as-unsupported, r=cuviper a691105117c Rollup merge of #120051 - riverbl:os-str-display, r=m-ou-se 313556c4a33 remove Mutex::unlock 5a08ff92ebd Improve assert_matches! documentation 085fa1a41de Add profiling support to AIX a6d9437cc0b Implement junction_point 83f7857e86e Auto merge of #119616 - rylev:wasm32-wasi-preview2, r=petrochenkov,m-ou-se d73fcd52692 handle unavailable creation time as `io::ErrorKind::Unsupported` 175372ec50b have `String` use `SliceIndex` impls from `str` 5d82a2b7fe1 safe transmute: revise safety analysis d7d1ec8a3b1 Auto merge of #119636 - devnexen:linux_tcp_defer_accept, r=m-ou-se 608e3326336 Rename wasm32-wasi-preview2 to wasm32-wasip2 f481aa3d51f Add the wasm32-wasi-preview2 target a45f66b050a Test getting the OS thread name b212daeeb7a Use the OS thread name by default for the current thread 690ca231142 intrinsics.rs: add some notes on unwinding 77789f82322 Stabilize the `#[diagnostic]` namespace and `#[diagnostic::on_unimplemented]` attribute 3ca4238992a Generate original vtable and clone's vtable in the same CGU bb21aad9be5 Auto merge of #121655 - matthiaskrgr:rollup-qpx3kks, r=matthiaskrgr ecdff5a0ff7 Rollup merge of #121648 - jieyouxu:from-into-raw-parts-docs, r=Nilstrieb 96a2dce6b09 Rollup merge of #121598 - RalfJung:catch_unwind, r=oli-obk d704aaa1c26 Auto merge of #121516 - RalfJung:platform-intrinsics-begone, r=oli-obk 7b4e73aea9a change std::process to drop supplementary groups based on CAP_SETGID a205da52d83 Document args returned from `String::into_raw_parts` eeb1805ecf8 Document args returned from `Vec::into_raw_parts{,_with_alloc}` 7cd87e165cd Rearrange `String::from_raw_parts` doc argument order to match code argument order 6f61a4f211f Rearrange `Vec::from_raw_parts{,_in}` doc argument order to match code argument order 0d8dc0308d0 fix race between block initialization and receiver disconnection df57613bbaf Don't codegen wasm.throw unless with -Zbuild-std e6d579c80f4 Remove _tls_used trickery unless needed 9e7adf8ea4a Clarify behavior of slice prefix/suffix operations in case of equality 6131e1f5712 Use volatile to make `p_thread_callback` used a23102d01c2 Win10: Use GetSystemTimePreciseAsFileTime directly 23054572f7b miri: rename miri_start_panic → miri_start_unwind 9e43ea879d5 rename 'try' intrinsic to 'catch_unwind' b8715e816b7 Fill in Read::read_buf for &Stdin 34217840622 Fix stable feature name and stabilization version of Read for &Stdin a132fcd55b2 Auto merge of #121317 - ChrisDenton:win10-sync, r=Mark-Simulacrum 6de6f403a1a Add Waker::will_wake tests 3c761a00d3a Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkin 65a5261f192 Auto merge of #121591 - matthiaskrgr:rollup-8wfhh3v, r=matthiaskrgr 1f21ac30a18 Rollup merge of #121513 - nshyrei:fix_tests_module, r=cuviper 603e959d96e Rollup merge of #119590 - ChrisDenton:cfg-target-abi, r=Nilstrieb 4c0da0acb72 Fix Hash impl affba7ace34 Windows: Use ProcessPrng for random keys f7dd9d5a27c Make push docs more vague a142c9012d8 remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics 4d6e0ad96d6 Auto merge of #117107 - zachs18:mapped-mutex-guard, r=Amanieu f4732dd7b9b Auto merge of #121114 - Nilstrieb:no-inline!, r=saethlin 2f790c0919a Auto merge of #121569 - matthiaskrgr:rollup-awglrax, r=matthiaskrgr 26ae504dc2f Rollup merge of #121556 - GrigorenkoPV:addr_of, r=Nilstrieb 5f130b3f2dc Rollup merge of #121551 - nbdd0121:ffi_unwind, r=RalfJung 4c770e1fc5a Rollup merge of #121530 - wgslr:master, r=Mark-Simulacrum bf3309a94eb Rollup merge of #121343 - Takashiidobe:takashi/examples-for-slice, r=Mark-Simulacrum ecf9aa915ff Stabilize `cfg_target_abi` a5282dd7d94 Add `#[rustc_no_mir_inline]` for standard library UB checks adfe9d5de8a Forbid use of `extern "C-unwind"` inside standard library 57f6ae66032 library: use `addr_of!` c97059fc4b3 update stdarch 2d3e6ab2d2d Apply suggestions from code review 6106d75db3c Fix incorrect doc of ScopedJoinHandle::is_finished bf3738a4c0a Auto merge of #119536 - Jules-Bertholet:const-barrier, r=dtolnay f43da90e8af std: make `ReentrantLock` public 09b59ad4c3f Auto merge of #121303 - GrigorenkoPV:static_mut_refs, r=oli-obk,RalfJung e40dea71a1a Auto merge of #121514 - matthiaskrgr:rollup-5f0vhv7, r=matthiaskrgr 9e0c8cfa4d2 Rollup merge of #121498 - flba-eb:make_timespec_capping_public, r=Nilstrieb bc950c55f57 moved tests file 0097735e353 Get rid of some `#[allow(static_mut_refs)]` fcdfe8b3d08 Auto merge of #121454 - reitermarkus:generic-nonzero-library, r=dtolnay ed8910ea17e Make timespec capping public to crate::sys dbeb780e184 remove repetitive words cb7482078db Auto merge of #120730 - estebank:confusable-api, r=oli-obk 342b9e79729 Use Itanium ABI for thrown exceptions d24907ec3cc Unconditionally pass -wasm-enable-eh 0a194b9b4e2 std support for wasm32 panic=unwind 85b58d08d31 Add `flatmap`/`flat_map` -> `and_then` suggestions 956829cf649 On type error of method call arguments, look at confusables for suggestion 6fe7e332687 Add `rustc_confusables` annotations to some stdlib APIs 560ba95e439 Rollup merge of #121439 - jrudolph:patch-1, r=bjorn3 57877bc1fe8 Fix example. 6445564417c Use generic `NonZero` everywhere else. 85f2c96d46e Use generic `NonZero` everywhere in `alloc`. 1fc9f9fe322 Use generic `NonZero` everywhere in `std`. 4dfee70f50a Use generic `NonZero` everywhere in `core`. fe0f50c8a7b Auto merge of #121309 - Nilstrieb:inline-all-the-fallbacks, r=oli-obk 28bf550d98d remove potentially misleading sentence about libc::access c67d12588cf Fix typo in metadata.rs doc comment 1782ff86ac0 Add std::ffi::c_str modules 479f78e26cf Auto merge of #117174 - Ayush1325:uefi-stdio-improve, r=workingjubilee 3477a502c00 Auto merge of #121223 - RalfJung:simd-intrinsics, r=Amanieu 1af6c69f1ed Auto merge of #118634 - Jules-Bertholet:box-allocator-static, r=Amanieu aeeb4b79b54 Always use WaitOnAddress on Win10+ 990fe8b9c9c os::net: expanding TcpStreamExt for Linux with `tcp_deferaccept`. 78e572f52ed remove simd_reduce_{min,max}_nanless 6d838a11170 rename ptr::invalid -> ptr::without_provenance d017f5fd891 Remove unnecessary map_err d3c7790ccf1 TryReserveError to ErrorKind::OutOfMemory f5618a53d0a make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all fast-math flags afaa36e7e3e intrinsics::simd: add missing functions 9133435a62c Auto merge of #121383 - Dylan-DPC:rollup-735p4u4, r=Dylan-DPC a757ccb4352 Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercote 85e5bbd6c94 Rollup merge of #121361 - pitaj:diag_items-legacy_numeric_constants, r=Nilstrieb 71f053e3e20 Stabilize `LazyCell` and `LazyLock` (`lazy_cell`) ee3c556822a Delete architecture-specific memchr code in std::sys 0d35f7dd681 diagnostic items for legacy numeric modules 549695ebe36 Add extra detail to field comment a32048a40a2 Reduce alignment of TypeId to u64 alignment e98de99f21a Rollup merge of #121352 - malobre:patch-1, r=Nilstrieb 5ac57c7ba41 Rollup merge of #121277 - reitermarkus:generic-nonzero-convert-num, r=dtolnay 3d72e765eb2 Rollup merge of #119203 - farnoy:simd-masked-intrinsic-docfix, r=RalfJung 301804951f4 Add "algebraic" versions of the fast-math intrinsics 2930a172011 docs: add missing "the" to `str::strip_prefix` doc a2638dd4824 Auto merge of #121345 - Nilstrieb:rollup-reb0xge, r=Nilstrieb a6bfc90583e Correct the simd_masked_{load,store} intrinsic docs 45a07887658 Add examples for some methods on slices 27f2a1385a9 Rollup merge of #121302 - GrigorenkoPV:refmutl, r=bjorn3 4b607ed9ef9 Rollup merge of #121241 - reitermarkus:generic-nonzero-traits, r=dtolnay 218dd3e8bed Rollup merge of #121196 - Nilstrieb:the-clever-solution, r=saethlin 5b5f49a76cc Auto merge of #120863 - saethlin:slice-get-checked, r=the8472 67ade55712a fix doc link 86cd151ba66 Rollup merge of #121311 - Nilstrieb:is-it-overlapping, r=saethlin 6a8944243f6 Rollup merge of #121310 - GrigorenkoPV:doc-smallfix, r=Nilstrieb b2da523763f A much simpler version of write 244358f1b4d remove const 5b8f5f1d216 add safety text a3ff5ac9a7d Fix inlining issue for non-const case 151f05a49ce Use intrinsic 18918bdd45c perf: improve write_fmt to handle simple strings f15012d7250 Add more inline(always) to fix opt-level=z test on wasm32 7086428543b Convert debug_assert_nounwind to intrinsics::debug_assertions fa527c66a51 Auto merge of #121185 - GuillaumeGomez:update-stdarch, r=Amanieu 04b15866885 Make `is_nonoverlapping` `#[inline]` ff6ad8e299b Make intrinsic fallback bodies cross-crate inlineable f7999a94602 Remove an old hack for rustdoc ca7c9058a35 Auto merge of #121177 - joboet:move_pal_locks, r=ChrisDenton 95208b84278 Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions) 92ccbdfd8b6 Remove `RefMutL` hack in `proc_macro::bridge` 7538542bbdf Rollup merge of #121272 - pitaj:diag_items-legacy_numeric_constants, r=Nilstrieb 50f385b9ea6 Rollup merge of #121041 - Nilstrieb:into-the-future-of-2024, r=Mark-Simulacrum d43cdc66cf6 Rollup merge of #119808 - GnomedDev:encode-charsearcher-size-in-type, r=Mark-Simulacrum 0b79fa43f08 Update stdarch submodule 3c6c15c0dc1 Refactor trait implementations in `core::convert::num`. 98ecb6d9139 Auto merge of #105917 - a1phyr:read_chain_more_impls, r=workingjubilee 11e8d05010a Clarify/add `must_use` message for Rc/Arc/Weak::into_raw. 85e82e854d4 Auto merge of #121269 - calebzulawski:sync-portable-simd-2024-02-18, r=Mark-Simulacrum 9f66a306e14 Fix error in push docs 57caa721db6 Auto merge of #121101 - GnomedDev:dyn-small-c-string, r=Nilstrieb aac615c0629 Add `Future` and `IntoFuture` to the 2024 prelude 9e54a93e07d diagnostic items for legacy numeric constants 9b768be2e18 Dyn erase at call site ad0f3aac05e Add some comments to prevent regression c98ff44dba1 Reduce monomorphisation bloat in small_c_string c868e93853a Rollup merge of #121266 - SabrinaJewson:easy-syscall-aliases, r=Mark-Simulacrum 76fc9899c59 Rollup merge of #121224 - hi-rustin:rustin-patch-unit-binding, r=Mark-Simulacrum aa95c8671b4 Rollup merge of #118569 - blyxxyz:platform-os-str-slice, r=Mark-Simulacrum 352fcd07573 Merge commit '649110751ef4f27440d7cc711b3e07d11bf02d4a' into sync-portable-simd-2024-02-18 4035b020858 Add uncontroversial syscall doc aliases to std docs edf450b06e8 Auto merge of #117772 - surechen:for_117448, r=petrochenkov 7ce585ce62e fix typo in push documentation 6ef2481fa9a intradoc link for vec fde5eeb2173 time complexity for insert e649cb12a29 time complexity for pop 450d82a92ca time complexity for push_within_capacity 471d42ed55f time complexity for push 51e36f70f59 By tracking import use types to check whether it is scope uses or the other situations like module-relative uses, we can do more accurate redundant import checking. 902426b94d5 Auto merge of #121034 - obeis:improve-static-mut-ref, r=RalfJung 7945217639a Improve wording of static_mut_ref d72326006a5 Auto merge of #118264 - lukas-code:optimized-draining, r=the8472 b694ff5b0f1 Implement `NonZero` traits generically. 82be26bb2fe Auto merge of #121204 - cuviper:flatten-one-shot, r=the8472 09a3c54a0f7 Rollup merge of #121149 - SebastianJL:patch-1, r=Mark-Simulacrum af70184e5ad Rollup merge of #120952 - saethlin:vec-into-iter, r=the8472 7ec45920554 Auto merge of #121232 - RalfJung:miri, r=RalfJung 72fad62f7c9 Allow newly added non_local_definitions in std 7c47c5beb89 Rollup merge of #121192 - oli-obk:intrinsics2.0, r=WaffleLapkin 842f6284db1 Rollup merge of #121187 - Takashiidobe:takashi/examples-for-quickselect, r=Nilstrieb b8128dae039 Rollup merge of #119032 - smmalis37:patch-1, r=ChrisDenton 47bbf911086 Remove unnecessary unit binding 5e9adcb554c Merge from rustc b5a8a1f644f Auto merge of #120563 - reitermarkus:generic-nonzero-get, r=dtolnay 9952241bd3f Add an example to demonstrate how Rc::into_inner works 6bf6037a6b4 Auto merge of #120741 - a1phyr:safe_buffer_advance, r=m-ou-se c651a7cedff Clarify the flatten specialization comment 3cc83124059 Remove cfg_attr b316e715a16 Use a hardcoded constant instead of calling OpenProcessToken. 8db6fc4f92d Give the (`un`)`likely` intrinsics fallback bodies 388f77480a0 Give the `assume` intrinsic a fallback body 0685d24adaa Specialize flattening iterators with only one inner item 964e38cf685 Don't use mem::zeroed in vec::IntoIter 5cf8dc131f9 Add examples to document the return type of `select_nth_unstable`, `select_nth_unstable_by`, and `select_nth_unstable_by_key`. 56b5d355929 Auto merge of #116385 - kornelski:maybe-rename, r=Amanieu 736e4ff109b address review comments db50af2cbda outline large copies 595f3312a7a reduce branchiness 593db1d7eb0 reduce amount of math 544f6a98f4b simplify codegen for trivially droppable types eb19a9373fa Auto merge of #120538 - kornelski:read-not-exact, r=m-ou-se 1b8ed545ded std: move locks to `sys` on platforms without threads a91af9ba8af std: move locks to `sys` on xous bca24efebc2 std: move locks to `sys` on Windows aecbc86b7bd std: move locks to `sys` on UNIX and other futex platforms 0db065cc253 std: move locks to `sys` on teeos 6e5d11f38ff std: move locks to `sys` on SGX 443bba7dfc2 std: move locks to `sys` on µITRON ed81f978688 Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkin ffa68410d41 Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnay 91ac10ed019 Merge from rustc e2872ee1118 Auto merge of #120889 - Ayush1325:uefi-instant, r=joshtriplett ab53d88bd10 Rollup merge of #121155 - tspiteri:strict-doc-overflow, r=Nilstrieb 01365e0f0bd Rollup merge of #120971 - PizzasBear:patch-1, r=Nilstrieb 064b67d628e Rollup merge of #120777 - Marcondiro:unicode15-1, r=Manishearth 2fa7798526a doc: panicking division by zero examples for unsigned strict div ops b5e6f9bb13b doc: add note before panicking examples for strict_overflow_ops 73cd635a51f Auto merge of #121142 - GuillaumeGomez:rollup-5qmksjw, r=GuillaumeGomez 156a47c9768 Fix typo in VecDeque::handle_capacity_increase() doc comment. 9b162baa43e Add slice::try_range e7ef96e09ec Auto merge of #119863 - tmiasko:will-wake, r=m-ou-se 92ddab31f70 Update library/std/src/fs.rs c31307eff6b Update library/std/src/fs.rs f4c2acbaee5 Rollup merge of #121120 - nnethercote:LitKind-Err-guar, r=fmease a36a878ee6c Rollup merge of #120672 - devnexen:update_thread_stack_guardpages_fbsd, r=m-ou-se c2f6b0094da Rollup merge of #120505 - Amanieu:fix-btreemap-cursor-remove, r=m-ou-se 073cf80260f Rollup merge of #120449 - udoprog:document-unsized-rc-arc-from-raw, r=m-ou-se 3c317573fa4 Add ASCII fast-path for `char::is_grapheme_extended` 407302548a2 Rollup merge of #121098 - ShoyuVanilla:thread-local-unnecessary-else, r=Nilstrieb b6b1314d9f5 Rollup merge of #121082 - peterjoel:atomic-docs, r=cuviper ee104ffaf4f Rollup merge of #118749 - ChrisDenton:winsys, r=cuviper 60c7bea1cac Rollup merge of #111106 - Stargateur:doc/format_args, r=m-ou-se 6a00d4eabaa Replace `NonZero::<_>::new` with `NonZero::new`. b6d1ba4a991 Use generic `NonZero` internally. dd3b76dafb0 Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`. f1929f25ad6 Clarified docs on non-atomic oprations on owned/mut refs to atomics ed17ada31f5 Merge from rustc 327501d6389 Remove unnecessary else block from `thread_local!` expanded code 10446e727b1 Auto merge of #121078 - oli-obk:rollup-p11zsav, r=oli-obk 71f84bfe71b Rollup merge of #121073 - IgorLaborieWefox:patch-1, r=workingjubilee f7f78f4dfe2 Rollup merge of #121024 - joseluis:feat-asciichar-default, r=scottmcm 24ab11833f1 Rollup merge of #118890 - Amanieu:allocator-lifetime, r=Mark-Simulacrum f721ca69a6d Rollup merge of #118738 - devnexen:netbsd10_update, r=cuviper 39b3ede01a9 Rollup merge of #116387 - kpreid:wake-doc, r=cuviper 94d25fc4749 Auto merge of #100603 - tmandry:zst-guards, r=dtolnay f1afa0b03a2 Automatically sort windows_sys bindings 77de1468d72 Add windows_sys readme dd72f361db9 Move windows_sys.lst to bindings.txt 9896f7fdfea Fix typos in `OneLock` doc 3320feeaab6 Fix incorrect use of `compile_fail` 82500bec748 Store core::str::CharSearcher::utf8_size as u8 188480b30b8 Add information about allocation lifetime to Allocator::allocate 58ca7e0959b implement `Default` for `AsciiChar` cb45e2c9073 Implement Instant for UEFI ba3980ce4e4 Auto merge of #121003 - matthiaskrgr:rollup-u5wyztn, r=matthiaskrgr b49049bffad Rollup merge of #120986 - tshepang:extraneous, r=cuviper 45edd693e60 Rollup merge of #120967 - LeoDog896:master, r=cuviper 74c2b165723 Merge from rustc 9e5683588a1 Auto merge of #120938 - Ayush1325:uefi-thread, r=joboet,Nilstrieb 460049c0f52 docs: use correct link, use secondary example 428468db3f2 iterator.rs: remove "Basic usage" text 98c8eaac401 Support safe intrinsics with fallback bodies ff787b46713 Give const_deallocate a default body 6853013b6f3 Teach llvm backend how to fall back to default bodies 01a21fbc4d3 Check signature of intrinsics with fallback bodies 8c152af6425 Rollup merge of #120936 - ripytide:master, r=Amanieu b218083f121 constify a couple thread_local statics 45acd65c17c style: fmt 60b1d20fff6 Clarify the lifetimes of allocations returned by the `Allocator` trait 669e05f0588 Fix comment in core/src/str/validations.rs 5a57c929f64 docs: mention round-to-even in precision formatting a5c4da34360 Merge from rustc 5d222f0d8d3 Auto merge of #110211 - joboet:queue_lock, r=Amanieu e1f7382d8ba Implement intrinsics with fallback bodies 4d0a8a6c467 Rollup merge of #120888 - saethlin:unsafe-precondition-cleanup, r=RalfJung d0a9dfa74d8 Rollup merge of #120880 - RalfJung:vtable-fnptr-partialeq, r=cuviper b0b8be51cf3 Rollup merge of #120740 - ChrisDenton:cmaths, r=Mark-Simulacrum c1f76833075 Rollup merge of #110483 - tleibert:thin-box-try-new, r=dtolnay d46acc6c4fb std: use `stream_position` where applicable 92e6daad9ed add comparison warning to RawWakerVTable as well 16fb9eb1cbf fix intra-doc links da30bc1e998 Address ThinBox::try_new PR review 04f27c6599f Implement sys/thread for UEFI d598b74dd19 Auto merge of #120903 - matthiaskrgr:rollup-tmsuzth, r=matthiaskrgr e27777f67d6 Cleanup around the new assert_unsafe_precondition 52ea954a322 fix incorrect doctest eade7aa48b3 improve `btree_cursors` functions documentation 8236914356a add doc-comment to `unlock_queue` 834ab897378 std: enabling new netbsd (10) calls. 236a70aff37 Rollup merge of #120459 - rytheo:handle-conversion-docs, r=Mark-Simulacrum 5409288f5f5 Rollup merge of #120307 - djc:duration-constructors, r=Mark-Simulacrum 3521a4cc7b3 Rollup merge of #119449 - Nilstrieb:library-clippy, r=cuviper d8d69806038 Rollup merge of #119242 - BenWiederhake:dev-from-nanos, r=joshtriplett 048c00d040d Rollup merge of #118307 - scottmcm:tuple-eq-simpler, r=joshtriplett ac8cf5d15b0 Rollup merge of #117740 - majaha:format_docs, r=joshtriplett 63a69288cfc Remove the link. ae2c9bc34ed URL-encode chars in fragment. 97b1a8aac51 Additional doc links and explanation of `Wake`. 6a192fbb371 Merge from rustc 6f351f30c4b Fix typo 9c7dd30cc6d Auto merge of #120232 - c272:json-buildstd, r=Mark-Simulacrum e7a5fddc792 Rollup merge of #119213 - RalfJung:simd_shuffle, r=workingjubilee 6165b19e3cb add note on comparing vtables / function pointers 8d77824a96b Rollup merge of #120823 - LegionMammal978:clarify-atomic-align, r=RalfJung 313acd87972 Rollup merge of #120764 - Alfriadox:master, r=m-ou-se 3d0584d7705 various docs tweaks 89f419cfdc9 simd_scatter: mention left-to-right order 909ce8fd9a8 add more missing simd intrinsics 3aac308c4da simd intrinsics: add simd_shuffle_generic 0fab82c02e7 Stabilize slice_split_at_unchecked df03d99e0e1 Auto merge of #120712 - compiler-errors:async-closures-harmonize, r=oli-obk 611a0e953dc Merge from rustc deda7d484b5 Change wording 6afc3a8496a Auto merge of #120852 - matthiaskrgr:rollup-01pr8gj, r=matthiaskrgr 39d03bace29 std::thread update freebsd stack guard handling. 4b1201b9438 Rollup merge of #120815 - camsteffen:inspect-docs, r=m-ou-se 2c4428ee693 Rollup merge of #120776 - joboet:move_pal_path, r=ChrisDenton 466be020dc7 Rollup merge of #120351 - Ayush1325:uefi-time, r=m-ou-se 8d1395a3a52 Auto merge of #120676 - Mark-Simulacrum:bootstrap-bump, r=clubby789 d9727e8be19 address review comments 83e98b44656 Bump Unicode to version 15.1.0, regenerate tables 838bcd00091 be more explicit about why adding backlinks eagerly makes sense effee9200ec Improve Option::inspect docs cbe1f52929d Auto merge of #120843 - matthiaskrgr:rollup-med37z5, r=matthiaskrgr c819cff9181 format using latest rustfmt 62286cf2e47 inline some single-use functions, add documentation 11e43a0eee9 queue_rwlock: use a separate `QUEUE_LOCKED` bit to synchronize waiter queue updates 4ee023b2c48 use exponential backoff in `lock_contended` 6074a2e7d15 immediately register writer node if threads are queued 246e9f8ff2c avoid unnecessary `Thread` handle allocation e487522e348 use braces to make operator precedence less ambiguous 469c40f6d1c adjust code documentation c9c2e239457 std: replace pthread `RwLock` with custom implementation inspired by usync 2b1ac346387 Rollup merge of #120809 - reitermarkus:generic-nonzero-constructors, r=Nilstrieb 0d1254ee7da Rollup merge of #120308 - utkarshgupta137:duration-opt, r=m-ou-se da6607a9d23 Auto merge of #120594 - saethlin:delayed-debug-asserts, r=oli-obk 1462d8b4db8 Auto merge of #120238 - joboet:always_confirm_lock_success, r=Mark-Simulacrum 7578b62f849 Clarify that atomic and regular integers can differ in alignment 34edb0c2484 Add and use Unique::as_non_null_ptr 55913b0f137 Make `NonZero::get` generic. 30fd5a76348 Use `transmute_unchecked` in `NonZero::new`. 25b408decfa Implement SystemTime for UEFI b2f89d3b354 Reduce use of NonNull::new_unchecked in library/ 7df88ed9bf3 Remove a now-obviated debug_assert! 0aeac8075d0 Rewrite assert_unsafe_precondition around the new intrinsic abf66bcbf28 Add a new debug_assertions intrinsic 159a1ed6771 Step all bootstrap cfgs forward b81b78bdd98 Bump version placeholders 40af49e1719 std: move path into `sys` 5dec1a96cb0 Auto merge of #120558 - oli-obk:missing_impl_item_ice, r=estebank 51802b91802 Fix whitespace issues that tidy caught 45c078fe67a Add documentation on `str::starts_with` 30dc45b7c3d Auto merge of #120521 - reitermarkus:generic-nonzero-constructors, r=dtolnay a08c906fdd5 Auto merge of #120381 - fee1-dead-contrib:reconstify-add, r=compiler-errors 2163b18245d Make `io::BorrowedCursor::advance` safe f9b0b50af8d Make cmath.rs a single file 261fe5d0b38 Replace `transmute_copy` with `ptr::read`. 2e9c5c156a4 Don't use `assert_unsafe_precondition` twice. 7ca2b3b4a5f Auto merge of #120527 - GnomedDev:atomicu32-handle, r=petrochenkov 58c30c7fa17 Make `NonZero` constructors generic. 8c1ebbd0e03 Simplify `impl_zeroable_primitive` macro. 6992332a634 Update tests 91ccb962fb6 Auto merge of #117905 - RalfJung:no-const-mut, r=lcnr 281ab704242 Harmonize blanket implementations for AsyncFn* traits 680f89b9cf0 Auto merge of #120361 - compiler-errors:async-closures, r=oli-obk 17273afbdda Auto merge of #120326 - tmandry:abort-in-tests, r=cuviper 51be3f22f9c Bless tests, add comments cc8d3b7444a Teach typeck/borrowck/solvers how to deal with async closures b0ad428907d revert stabilization of const_intrinsic_copy 3622612e371 Auto merge of #117372 - Amanieu:stdarch_update, r=Mark-Simulacrum 29418828930 Add support for custom JSON targets when using build-std. 931c0ae2952 Remove some invalid cfg(doc) code 9fc538bef64 Rollup merge of #120657 - mu001999:clean, r=Nilstrieb db14a7c6038 Rollup merge of #120384 - wackbyte:array-equality-generics, r=Mark-Simulacrum 28465664329 Rollup merge of #118960 - tvallotton:local_waker, r=Mark-Simulacrum 8df9aa8baef Rollup merge of #115386 - RalfJung:partial-eq-chain, r=dtolnay 0002c527f4d Rollup merge of #113833 - WiktorPrzetacznik:master, r=dtolnay 1035fa188f3 Rollup merge of #120607 - conradludgate:fix-120603, r=dtolnay 661b40e3b45 Rollup merge of #120572 - pheki:update-libc, r=Mark-Simulacrum a21298ece3c Rollup merge of #120458 - rytheo:cstr-conversion-doc, r=Mark-Simulacrum 0a41a92a36a Rollup merge of #119481 - romanows:fix-doc-select-nth-unstable, r=Mark-Simulacrum 8674ccc27a3 Remove unused struct 756152e9060 Auto merge of #120624 - matthiaskrgr:rollup-3gvcl20, r=matthiaskrgr cda4dbfe6d8 Document various I/O handle conversions ac76ef6b498 Reconstify `Add` 317d5d68e46 Rollup merge of #120528 - GnomedDev:atomicu8-backtrace-style, r=cuviper ff855289099 Rollup merge of #120523 - a1phyr:improve_read_buf_exact, r=the8472 4baec7e9376 add another test to make sure it still works with full reads e5bb567d05b fix #120603 by adding a check in default_read_buf fa3eaca9384 Docs for std::ptr::slice_from_raw_parts da8779f4623 fix typo c7882a62523 Update libc to 0.2.153 6f6ac11fed5 Revert unsound libcore changes of #119911 99d533c0058 Make File::read_to_end less special 688f252b4ac Store SHOULD_CAPTURE as AtomicU8 c93169d4c1a Switch OwnedStore handle count to AtomicU32 4466096d9cb Rollup merge of #120430 - devnexen:fix_tls_dtor_fbsd, r=cuviper a745afc2392 Rollup merge of #120355 - the8472:doc-vec-fromiter, r=cuviper e43d92198be Improve `io::Read::read_buf_exact` error case 981cfce08a6 Actually abort in panic-abort-tests 9c98826b78a Apply suggestions from code review 61c80460c9b document `FromIterator for Vec` allocation behaviors 9dbad22b158 Fix BTreeMap's Cursor::remove_{next,prev} 3e4275f9eca Rollup merge of #120485 - chenyukang:yukang-add-query-instability-check, r=michaelwoerister fb244f939ec Rollup merge of #120445 - Nemo157:arc-plug, r=Mark-Simulacrum e64cca93e05 Rollup merge of #120434 - fmease:revert-speeder, r=petrochenkov 526ce490588 Rollup merge of #120295 - reitermarkus:remove-ffi-nonzero, r=dtolnay 46e3e25c7b7 Rollup merge of #120452 - alexcrichton:update-windows-seek-write-docs, r=ChrisDenton 2a394b5c681 Rollup merge of #120424 - RalfJung:raw-ptr-meta, r=Nilstrieb ceb8169f7a5 Rollup merge of #119991 - kornelski:endless-read, r=the8472 c80498f6f4a Auto merge of #117925 - kornelski:read-to-oom, r=Amanieu 1aec5817c2e Disable conversions between portable_simd and stdarch on big-endian ARM 3acd82a65eb add missing potential_query_instability for keys and values in hashmap f4d6a902a43 Add stdarch_wasm_atomic_wait feature in std 03bf2e8a39a Update feature names for new stdarch 570a7202c0b Update stdarch submodule 4826f3d9b50 Handle out of memory errors in fs::read/read_to_string 0ef5cd5c925 Handle out of memory errors in io:Read::read_to_end() c68598052b2 Remove `raw_os_nonzero` feature. 9cfec44e68a std: always check the result of `pthread_mutex_lock` 5dae83930f2 Rollup merge of #120462 - mu001999:clean, r=Nilstrieb f92a5210c1c Rollup merge of #120373 - HTGAzureX1212:HTGAzureX1212/issue-120040, r=ChrisDenton 5b910416621 Rollup merge of #120266 - steffahn:a_rc_into_inner_docs, r=Mark-Simulacrum 40536b7ce19 Rollup merge of #116677 - joshlf:patch-11, r=RalfJung 87e61cb5aa3 Auto merge of #120165 - reitermarkus:nonzero-switch-alias-direction, r=dtolnay 874b47a76a4 raw pointer metadata API: data address -> data pointer cd9651888ff Auto merge of #120451 - RalfJung:miri, r=RalfJung 7c1bdfe5ce0 Clean dead code db6cb289753 Make `impl` impl take `?Sized` 3d550775116 Make `impl` impl take `?Sized` 1dca4033ffe Document From<&CStr> for CString dcc342c7766 std: Update documentation of seek_write on Windows 4d0cc60df30 Fix some `Arc` allocator leaks 4a4ce98fa46 Fix doctest 48d6c11f54b Replicate documentation in {Rc,Arc}::from_raw_in a885471464a Fix doctest 6d54e11f3cd Tidy up 481c2fc3561 Add examples for unsized {Rc,Arc}::from_raw 47df524eca7 Document requirements for unsized {Rc,Arc}::from_raw b0207c3e73e Revert "Add the wasm32-wasi-preview2 target" b31e826be5c std: thread_local::register_dtor fix proposal for FreeBSD. d98b2df832f Reject infinitely-sized reads from io::Repeat c0c39167f0f Update primitive_docs.rs 7d6c88fc36d Switch `NonZero` alias direction. 8ee8d6a062a Auto merge of #120417 - matthiaskrgr:rollup-5rszkmd, r=matthiaskrgr 131fbf6aba3 Rollup merge of #119641 - eopb:std-unused-ip-feature, r=ChrisDenton b3888f5a6aa Auto merge of #111379 - nyurik:intersperse-speed-up, r=cuviper 1022b59f644 add extra check for invalid handle in ReadDir::next cbcb9cfdbf0 make modifications as per reviews fe139749762 Rollup merge of #120366 - RalfJung:is_val_statically_known, r=cuviper 435637c4b9e Rollup merge of #120311 - mina86:h, r=cuviper c483022aef7 Rollup merge of #120205 - Berrysoft:windows-alloc-init, r=ChrisDenton a8af2a0b5f5 Rollup merge of #119562 - LegionMammal978:rename-pin-pointer, r=Amanieu,dtolnay eca6ff5b8f3 Rollup merge of #113489 - tguichaoua:cow_from_array, r=dtolnay ab3e01e9abd Rollup merge of #103522 - Dylan-DPC:76118/array-methods-stab, r=dtolnay dad34b52fec Use `` for array/slice equality `impl`s 43c0150894c Rollup merge of #120372 - bjorn3:fix_outdated_comment, r=Nilstrieb 80d9fd8449a Rollup merge of #120117 - NobodyXu:99262/update-api-and-doc, r=m-ou-se 165f4e51d41 Rollup merge of #119917 - Zalathar:split-off, r=cuviper e1bde8a38fe Rollup merge of #117678 - niklasf:stabilize-slice_group_by, r=dtolnay a43b329bc75 fix 936531d24ba remove redundant call to Error::last_os_error 594e6f3ab8e Fix outdated comment on Box 24dc916b1de fix issue 120040 7352fb98873 mark a doctest with UB as no_run 33d5a18b726 Rollup merge of #120053 - AldanTanneo:specialize-stdinlock-bytes, r=the8472 44eb7685495 Rollup merge of #119466 - Sky9x:str_from_raw_parts, r=dtolnay 8cd6230a240 Rollup merge of #107464 - WaffleLapkin:all_that_remains_of_lines, r=dtolnay 8cdf6caea0d Merge from rustc c3927bc8f72 Export core::str::from_raw_parts{,_mut} into alloc::str and std::str ac864406181 use checked_add for upper bound daaa0f09703 Update library/core/src/iter/adapters/intersperse.rs b2fb12acd3c Auto merge of #116167 - RalfJung:structural-eq, r=lcnr 7052f2c51df fmt 560ab4fbd3b Postpone .next() call until iteration dbc438de9ba Boost intersperse(_with) performance 70bdaaa396a Rollup merge of #120338 - steffahn:provenance_links, r=Nilstrieb 0134763efd8 Rollup merge of #120332 - mu001999:cleanup/dead_code, r=Nilstrieb 6b63a94e3d9 Rollup merge of #120306 - safinaskar:clone3-clean-up, r=petrochenkov 49bcf4526e7 Rollup merge of #118208 - Amanieu:btree_cursor2, r=dtolnay 4e62529070a core: add `From` implementations ff1615601db Update primitive_docs.rs c3569b5ca1f Fix links to [strict|exposed] provenance sections of `[std|core]::ptr` 6d961e17c85 Rollup merge of #119305 - compiler-errors:async-fn-traits, r=oli-obk 614a94d9c93 Auto merge of #119911 - NCGThompson:is-statically-known, r=oli-obk bec4b744f06 Rollup merge of #119616 - rylev:wasm32-wasi-preview2, r=petrochenkov,m-ou-se 470c5bc8d4f Rollup merge of #118326 - WaffleLapkin:nz_count_ones, r=scottmcm 820ec42f64b Finishing clone3 clean up a92ac0080cf This commit is part of clone3 clean up. Merge tests from tests/ui/command/command-create-pidfd.rs to library/std/src/sys/pal/unix/process/process_unix/tests.rs to remove code duplication 55123360814 core: add Duration constructors 778270381a4 This commit is part of clone3 clean up. As part of clean up we will remove tests/ui/command/command-create-pidfd.rs . But it contains very useful comment, so let's move the comment to library/std/src/sys/pal/unix/rand.rs , which contains another instance of the same Docker problem 5fe47656918 std/time: avoid divisions in Duration::new 12196b53afc remove StructuralEq trait 06ade5ca2db Merge from rustc 6b18d353106 Add `NonZero*::count_ones` f8ec171ead8 Auto merge of #120283 - fmease:rollup-rk0f6r5, r=fmease 636cd086ba2 Rollup merge of #120183 - Zalathar:test-closure, r=compiler-errors 7687c3f6405 Rollup merge of #120171 - cjgillot:jump-threading-assume-assert, r=tmiasko f74a6c87dae Rollup merge of #120160 - reitermarkus:nonzero-traits, r=dtolnay 0bcc31288c2 Rollup merge of #120244 - reitermarkus:nonzero-self, r=dtolnay f4b743949b3 Rollup merge of #120188 - devnexen:update_bsd_compiler_base_specs, r=wesleywiser 82255082d12 Wrap `HeapAlloc` and never inline 82e7eac4383 Further Implement Power of Two Optimization 00c84753f86 Further Implement `is_val_statically_known` 4bf8274ce86 Auto merge of #119433 - taiki-e:rc-uninit-ref, r=Nilstrieb 949453c3e44 Add the wasm32-wasi-preview2 target cdf72e3e7ce Improve documentation for [A]Rc::into_inner 85e2113de2e Auto merge of #117958 - risc0:erik/target-triple, r=davidtwco,Mark-Simulacrum 06e19c6fcb7 Auto merge of #119892 - joboet:libs_use_assert_unchecked, r=Nilstrieb,cuviper 578a23c904a Merge from rustc 780fe663604 Add Assume custom MIR. f2e7cbd458a fixing build for the BSD b838035cd2a Rollup merge of #120233 - oli-obk:revert_trait_obj_upcast_stabilization, r=lcnr 1238f599af9 Rollup merge of #120220 - nnethercote:TokenStream-Display-docs, r=petrochenkov d8ce6375d9d Rollup merge of #120143 - compiler-errors:consolidate-instance-resolve-for-coroutines, r=oli-obk ed15d90aa92 Rollup merge of #120109 - joboet:move_pal_cmath, r=ChrisDenton 2d382f1de11 Rollup merge of #119664 - ChrisDenton:mingw-pty, r=thomcc 52ccc4dbbff Use `Self` in `NonZero*` implementations. 9365c9194ac Auto merge of #120242 - matthiaskrgr:rollup-a93yj3i, r=matthiaskrgr 238d4b9bad5 zkvm: add partial std support 26907a9bd24 rustc: implement support for `riscv32im_risc0_zkvm_elf` c02d5b334f8 Rollup merge of #120181 - dtolnay:tlconst, r=thomcc 91f7824cb1d Rollup merge of #119801 - zachs18:zachs18-patch-1, r=steffahn,Nilstrieb 4bcc5b884e6 Rollup merge of #117910 - madsmtm:msg-send-no-clashing, r=thomcc e9b1f97f898 Rollup merge of #119943 - devnexen:listener_update3, r=thomcc dcd09b645c9 Rollup merge of #119408 - betrusted-io:xous-fixes-add-network, r=Mark-Simulacrum a407034bc6a Rollup merge of #118578 - mina86:c, r=dtolnay 397fbe7b52d std: move cmath into `sys` d21a1f35386 Revert "Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkin" ad4aa4e1db5 Fix msys2 tty detection for /dev/ptmx e9812ca3707 Auto merge of #120226 - matthiaskrgr:rollup-9xwx0si, r=matthiaskrgr e6ec163537b Auto merge of #120196 - matthiaskrgr:rollup-id2zocf, r=matthiaskrgr 02aaee46a9b Rollup merge of #120194 - HTGAzureX1212:HTGAzureX1212shorten-option-must-use, r=Nilstrieb 4b42d62d4b8 Rollup merge of #119726 - NCGThompson:div-overflow-doc, r=Nilstrieb c91c54b486d Rollup merge of #118714 - The-Ludwig:explain_ord_derive_enum_field, r=Nilstrieb fe5b61fa1f3 Document `Token{Stream,Tree}::Display` more thoroughly. 042fdf29d31 review 4f339a2262d Move `OsStr::slice_encoded_bytes` validation to platform modules bfcf56b4c15 Manually implement derived `NonZero` traits. 8f0ef3bc949 Auto merge of #119807 - Emilgardis:track_caller_from_impl_into, r=Nilstrieb a9120025c30 Remove unused struct bf2508967f4 Fix `clippy::correctness` in the library b3b57808e23 Add `#[coverage(off)]` to closures introduced by `#[test]`/`#[bench]` 1802f63df5c Rollup merge of #120180 - Zalathar:vec-split-off-alternatives, r=dtolnay bcf1c6fdfb2 Rollup merge of #120145 - the8472:fix-inplace-dest-drop, r=cuviper 8999fd8d258 Rollup merge of #120045 - scottmcm:unhide-repeat-n, r=Mark-Simulacrum ba11046246f Auto merge of #85528 - the8472:iter-markers, r=dtolnay 983c695c086 chore: suggest wrapping in an `assert!()` instead 915514f02e7 Merge from rustc 9719d7e86df Rollup merge of #119996 - joboet:move_pal_os_str, r=ChrisDenton d3007c7bd74 Rollup merge of #119081 - jstasiak:is-ipv4-mapped, r=dtolnay ed7b7a9e63a Rollup merge of #118811 - EbbDrop:is-sorted-by-bool, r=Mark-Simulacrum 2d8112fa020 Rollup merge of #116090 - rmehri01:strict_integer_ops, r=m-ou-se 2cc43b6da25 Add test of thread_local containing multiline const block 17f65285201 Revert example change from PR 116392 c7d5b7b74d9 Allow any expression blocks in `thread_local!` 5533a6d90b8 Document some alternatives to `Vec::split_off` 07f2ac637bd Auto merge of #111803 - scottmcm:simple-swap-alternative, r=Mark-Simulacrum 780456d6a47 Use bool instead of PartiolOrd in is_sorted_by 74f61c82a40 Auto merge of #120170 - GuillaumeGomez:rollup-edqdf30, r=GuillaumeGomez 6130265dd53 Rollup merge of #120169 - sunrosa:patch-1, r=ChrisDenton 3955954ecc0 Rollup merge of #120116 - the8472:only-same-alignments, r=cuviper 6dd14378831 Spelling fix d24a7fcf1f3 Auto merge of #117756 - a1phyr:hashmap_fold, r=the8472 9e6708299df core: introduce split_at{,_mut}_checked 16c1ba65f20 doc: fix some doctests after rebase 5cee6449fa9 refactor: make waker mandatory. 61e83b422ba chore: make method order consistent with waker b3a20e10283 docs: remove recommendations to use LocalWaker in stable API documentation 7a0a7099f6e fix: Apply suggestions from code review 051b84666e6 doc: update thread safety explanation for RawWakerVTable and RawWaker. b981b3e354a chore: add and !Sync impls for LocalWaker as a stability guarantee. 34179f6d127 fix: change issue number of waker_getters from #87021 to #96992. 7b18ba4a0c5 chore: fix ci failures e23b463a57f feat: impl AsRef for Waker. 31843427561 chore: add tracking issue number to local waker feature 360fb0ed498 fix: make LocalWake available in targets that don't support atomics by removing a #[cfg(target_has_atomic = ptr)] ab3ba5c5c9d feat: add try_waker and From<&mut Context> for ContextBuilder to allow the extention of contexts by futures 7caff6cced0 refactor: remove in favor of and to make the API infallible. a5559396d9e perf: move null check from local_wake() to build() b477584b020 feat: add LocalWaker type, ContextBuilder type, and LocalWake trait. f1947af0de4 Rollup merge of #120150 - Jules-Bertholet:stabilize-round-ties-even, r=cuviper 9411ce115ae Rollup merge of #118799 - GKFX:stabilize-simple-offsetof, r=wesleywiser 16c3abcfd09 Rollup merge of #113142 - the8472:opt-cstr-display, r=Mark-Simulacrum a23e922f147 Rollup merge of #103730 - SOF3:nonzero-from-mut, r=Mark-Simulacrum,dtolnay c2655ebc3f7 Tweak the threshold for chunked swapping c62eba3f436 Stabilize `round_ties_even` 00f06d2e88e fix: Drop guard was deallocating with the incorrect size 8e4d749c054 Assign tracking issue number for feature(nonzero_from_mut) a41a5930165 Added assert_unsafe_precondition! check for NonZeroXxx::from_mut_unchecked d8b0aa0b6e7 Added NonZeroXxx::from_mut(_unchecked)? df3e1293cb2 Consolidate logic around resolving built-in coroutine trait impls 2d9bc657064 Remove feature(offset_of) from tests 458c762db07 Stabilize simple offset_of c759a297f49 Clarify Panicking Behavior in Integer Division Docs ba1701524c1 Make `saturating_div` Docs Consistent with Others a2245ca541e Adjust Attributes of Integer Division Methods 6183aa2fec4 Fixes from PR 4e582620d56 Use heap for stdout and stderr c9b51857a03 Improve UEFI stdio fb129a91448 Add new intrinsic `is_constant` and optimize `pow` 60727cebe21 Rollup merge of #119984 - kpreid:waker-noop, r=dtolnay b84d93e444c Rollup merge of #117561 - tgross35:split-array, r=scottmcm 5d58c1b67fe Rollup merge of #120110 - invpt:patch-1, r=the8472 6a9c487ae55 Rollup merge of #120107 - shepmaster:dead-code-repr-transparent, r=Nilstrieb 37643b84f1d Rollup merge of #119907 - asquared31415:fn_trait_docs, r=Nilstrieb 091df25b5b1 Rollup merge of #119138 - AngelicosPhosphoros:use_proper_atomics_in_spinlock_example, r=Nilstrieb 8b992fee925 Rollup merge of #118798 - GnomedDev:use-atomicu8-backtrace, r=Nilstrieb e0bfe840dbe Rollup merge of #118665 - dtolnay:signedness, r=Nilstrieb acab991501f Clarify docs for Vec::into_boxed_slice, Vec::shrink_to_fit ed99b329662 Update `std::io::Error::downcast` return type 501553d91d6 remove alignment-changing in-place collect d9f8d721502 update internal ASCII art comment for vec specializations a1c48460949 Add `display` method to `OsStr` b6d5f4556e4 Remove no-longer-needed `allow(dead_code)` from the standard library 70672690826 Add `A: 'static` bound for `Arc/Rc::pin_in` 3c025b28314 Remove unnecessary `let`s and borrowing from `Waker::noop()` usage. a335250dd00 Change return type of unstable `Waker::noop()` from `Waker` to `&Waker`. 2d35d75e9f3 Rollup merge of #120044 - Storyyeller:patch-2, r=lqd f2d83e2f8c6 Rollup merge of #119855 - rellerreller:freebsd-static, r=wesleywiser 7ae5901f58f specialize `Bytes` on `StdinLock<'_>` by using the underlying `BufReader` 1502347afeb Un-hide `iter::repeat_n` 488a2b80016 Auto merge of #119651 - novafacing:proc_macro_c_str_literals, r=Amanieu 58ec0ca50c2 Fix typo in comments (in_place_collect) 30dbe001013 Auto merge of #120019 - lcnr:fn-wf, r=BoxyUwU 772872fe827 proc_macro_c_str_literals: Implement Literal::c_string constructor 5f3edf3695e Suggest less bug-prone construction of Duration in docs a4e88bb3c58 Rename `pointer` field on `Pin` 582ddee56c7 Auto merge of #120025 - matthiaskrgr:rollup-e9ai06k, r=matthiaskrgr 282e337a19d Rollup merge of #119990 - reitermarkus:nonzero-type-alias, r=dtolnay e4ba2034d92 Rollup merge of #118361 - Dylan-DPC:80626/stab/bound-map, r=Amanieu 8ed07b39d7d Auto merge of #119954 - scottmcm:option-unwrap-failed, r=WaffleLapkin b9e06184dc5 borrowck: use implied bounds from impl header 177fe3b9a32 borrowck: wf-check fn item args 7129120796d Revert unrelated changes from PR 119990 af504e5edfe Auto merge of #119987 - matthiaskrgr:rollup-f7lkx4w, r=matthiaskrgr 4e711722e79 std: move OS String implementation into `sys` 7a9c432f27f Add private `NonZero` type alias. 628a5730d67 Auto merge of #119878 - scottmcm:inline-always-unwrap, r=workingjubilee ffd85db749c Rollup merge of #119870 - behnam-oneschema:lazylock-blocking-1, r=tgross35,ChrisDenton 7accd0b0c14 std::net: bind update for using backlog as `-1` too. f68b1fbf707 Auto merge of #119970 - GuillaumeGomez:rollup-p53c19o, r=GuillaumeGomez 28b8686d662 Unbreak tidy's feature parser 5ea1434710a Move BITS into omnibus impl block 6a55f253afa Move signed MIN and MAX into signedness_dependent_methods 0426f806e8b Move unsigned MIN and MAX into signedness_dependent_methods cdb6a670484 Move is_power_of_two into unsigned part of signedness_dependent_methods e701a89af4c Move nonzero_unsigned_signed_operations methods into the omnibus impl block c3c7fca2753 Work around rustfmt doc attribute indentation bug d1f0977e001 Unindent nonzero_integer_signedness_dependent_methods macro body 2be6eb9b37c Move signedness dependent methods into the omnibus impl block 4cb5598c381 Move Neg impl into the macro that generates Div and Rem db4e5380567 Split out `option::unwrap_failed` like we have `result::unwrap_failed` 01102c1cc0e Move leading_zeros and trailing_zeros methods into nonzero_integer macro 124a2621fe2 Unindent nonzero_integer_impl_div_rem macro body 22072fada24 Move impl Div and Rem into nonzero_integer macro 0f28b56c707 Move 'impl FromStr for NonZero' into nonzero_integer macro c89ebf0e60e Format nonzero_integer macro calls same way we do the primitive int impls 123029d2737 Unindent nonzero_integer macro body 9ea46abad17 Define only a single NonZero type per macro call 1a616ac85d9 Move nonzero_integers macro call to bottom of module 19ada1b7f52 Rollup merge of #119742 - Meziu:armv6k-nintendo-3ds, r=Mark-Simulacrum e005d35a6a1 Auto merge of #119796 - androm3da:bcain/compiler_builtins_0_1_105, r=Mark-Simulacrum f6204e6c371 std: Doc blocking behavior of LazyLock methods d8bda997fec Rollup merge of #119949 - clubby789:spec-newtype-comment, r=nnethercote 0bffcd3bebb Merge from rustc c19b57eadc0 Add note on SpecOptionPartialEq to `newtype_index` 9d4f903a63d Rollup merge of #119935 - joboet:move_pal_personality, r=ChrisDenton 6fba59c3cf9 libs: use `assert_unchecked` instead of intrinsic ac03ae79582 Refactor uses of `objc_msgSend` to no longer have clashing definitions 6ca1d4eed06 xous: thread: mark thread_main() as divergent ce0462cc73a std: xous: use constants for stdout and stderr 5b9db78414e std: xous: mark stdio structs as `repr(C)` 2303a296914 xous: net: initial commit of network support ebcc601dc7e std: move personality implementation out of PAL ab053f48272 std: xous: share allocator symbol in tests b8b436ddfa1 std: xous: fix thread_local_key under tests f51157e1873 std: once: use queue implementation on Xous 7a25b4b66a0 std: xous: rewrite rwlock to be more robust c5c17162929 std: xous: use blocking_scalars for mutex unlock ad5b2b1f2c2 std: xous: pass entire memory range to flag updater 0d8934a61ae std: xous: rework condvar to fix soundness issues 57ccb50d871 xous: std: thread_parking: fix deadlocks aa75d9fe473 xous: ffi: correct size of freed memory 6c37d38f811 xous: ffi: fix lend_impl() return values 8c0ba58346b Auto merge of #119927 - matthiaskrgr:rollup-885ws57, r=matthiaskrgr 00fa4ca380c Auto merge of #117285 - joboet:move_platforms_to_pal, r=ChrisDenton 35238e69a2b Rollup merge of #119902 - asquared31415:patch-1, r=the8472 582e1411faa don't break a good link 6b8a4fcbff6 Remove special-case handling of `vec.split_off(0)` c0cfa04c782 Merge from rustc dc4f7819f75 update fn pointer trait impl docs c00822dd862 fix typo in `fn()` docs d8a1defae6b Auto merge of #119452 - AngelicosPhosphoros:make_nonzeroint_get_assume_nonzero, r=scottmcm da691183517 Tune the inlinability of `Result::unwrap` 4856a47c213 Auto merge of #118548 - Enselic:bench-padding, r=thomcc,ChrisDenton 71d0c344608 Auto merge of #119430 - NCGThompson:int-pow-bench, r=cuviper 8fcf9058ddc update paths in comments 46ef1903dd0 std: fix module references on Windows 95b74ec59d3 std: fix module references on UNIX c3234a4adf6 std: fix module references on UEFI 0b768e77c68 std: fix module reference on SGX 0e8a1818057 std: fix module references on hermit 81725f484cc std: begin moving platform support modules into `pal` 37b38b6d5d5 Reduced amount of int_pow benches 76783b0bb06 Rollup merge of #119853 - klensy:rustfmt-ignore, r=cuviper ed296f65813 Rollup merge of #119845 - RalfJung:rint, r=nagisa 82d12616938 Rollup merge of #119836 - hi-rustin:rustin-patch-docs-blank-line, r=ChrisDenton 7fc55147c01 Waker::will_wake: Compare vtable address instead of its content 6b893067630 Edited int_pow micro-benchmarks 7699675be55 Added int_pow micro-benchmarks 5a5ccfbaaf4 removed nonfunctioning benchmark 32cc80ea26f Enable Static Builds for FreeBSD 731dea2c7f8 rint: further doc tweaks 95e59b906db apply fmt 67fb0bc3a76 Merge from rustc 1a9025ee8e5 Rollup merge of #119804 - tmccombs:stabilize-unpoison, r=cuviper 7ee21385c2f chore: remove unnecessary blank line 5532e5e6c4e Make is_global/is_unicast_global special address handling complete bf893cfbde0 Implement in-place iteratation markers for iter::{Copied, Cloned} 58cca3c2fdc bench trustedrandomaccess specialization in zip 115001ffcd6 implement TrustedRandomAccess and TrustedLen for Skip 1f7f0f66352 implement TrustedLen for StepBy d5809ab2524 Stabilize mutex_unpoison feature afa6a00709e Add `#[track_caller]` to the "From implies Into" impl 5dc0212e11a Fix deallocation with wrong allocator in (A)Rc::from_box_in 2787d39c02a Stabilize `slice_first_last_chunk` b2f2ddfd171 Rollup merge of #119782 - RalfJung:rint, r=cuviper 131bc3fc8ca Update compiler_builtins to 0.1.105 8c4a4b200c2 rint intrinsics: caution against actually trying to check for floating-point exceptions e22f0f5426b Auto merge of #116846 - krtab:slice_compare_no_memcmp_opt, r=the8472 15319d964dc Rollup merge of #119768 - ojeda:panic-link, r=Nilstrieb 82bee8e2534 Rollup merge of #118645 - Patryk27:bump-compiler-builtins, r=Nilstrieb,dtolnay 373ca54cdbe Rollup merge of #118241 - fortanix:raoul/gh-530-make_userspace_types_send, r=Nilstrieb,dtolnay d6a0cff2f6f core: panic: fix broken link a63758904ce Rollup merge of #118748 - devnexen:fbsd_getrandom_simpl, r=Nilstrieb,dtolnay c153fc11fd0 Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwco 70ade214873 Backlog for HorizonOS UnixListener c84928e86a8 Rollup merge of #119632 - ivmarkov:master, r=Nilstrieb,dtolnay 783049ee92a Rollup merge of #118979 - ChrisDenton:unwrap-const, r=Nilstrieb,dtolnay b99d67aeac1 Rollup merge of #119598 - Laura7089:fix/deref-typo, r=Nilstrieb 2332cd2af29 Increase visibility of `join_path` and `split_paths` f05e3be9ac6 A more efficient slice comparison implementation for T: !BytewiseEq 1f1f7dba451 Rollup merge of #116129 - fu5ha:better-pin-docs-2, r=Amanieu f33329e4e17 link b8571a8b249 Update library/core/src/pin.rs a4d73b895ad clean up structural pinning d77dc516878 footnote on dropping futures ce2ba324a79 valid 976b10ccb42 punctuation in parens ebdf83d0053 Apply suggestions from code review 9a514b47fcb Clean up guarantees wording 61758e15176 lifetime -> lifespan where relevant. improve docs on as_ref() afc88517748 Rephrase unpin docs in terms of pinning-agnosticness 14f66c31b93 trim section on managed-box model cb45a7a0e4b improve `Pin::new_unchecked` docs 9999f90d96d fix broken link f092d6be4fd justify motivation of `Unpin` better 6180d00051a improve `Pin` and `Pin::new` docs 0bbe4bda153 `Pin

` -> `Pin` 3b01bb8f777 fix typos and edit prose 54a76ac9848 edit new section for typos and better wording 0c1cb8c5203 fix imports 594eca02960 fix typos 7b6d5aae66e add section on manual owning ptr managed solution via @kpreid 641367255fb improve structural Unpin + formatting 2f278e2777f reword unpin auto impl section 8bf830e4dd3 fix link in footnote 5d9a7742aad improve `Pin` struct docs and add examples 9cfaf7e5444 improve intro and discussion of pinning as library contract 514431964a9 improve intro and `Unpin`-related discussion ebbd9286ed7 update doubly linked list commentary and fix links fdf909c30db fix one more broken link 279e434ab2c fix broken links 5f2761093a6 Fix examples, finish polishing 9ff47290a64 mostly done a986fa650e8 Rewrite `Pin

` docs to clarify guarantees and uses 809db49e3f7 rc,sync: Do not create references to uninitialized values 27e42ff67d1 Update test for `E0796` and `static_mut_ref` lint fb71279c358 Auto merge of #114205 - the8472:vec-iter-nonnull, r=scottmcm 93988f2e2de Rollup merge of #119657 - cls:slice_split_once-typo, r=ChrisDenton e3afebba5dd Rollup merge of #119656 - RalfJung:round-docs, r=Mark-Simulacrum 4b6fd614da9 mark vec::IntoIter pointers as `!nonnull` 5630651f67c typo fix 698cbc1a1e5 Auto merge of #119599 - marthadev:position, r=the8472 37122622283 Rollup merge of #119624 - petrochenkov:dialoc4, r=compiler-errors f6bf8c0b885 Rollup merge of #119595 - mbbill:patch-1, r=Mark-Simulacrum ea0d74a7777 Rollup merge of #118781 - RalfJung:core-panic-feature, r=the8472 9d803ac8a78 Add assume into `NonZeroIntX::get` d96c678b7c0 document rounding behavior of rint/nearbyint for ties e9b9a3afdab Fix typo in docs for slice::split_once, slice::rsplit_once 1acabc87cc4 Rollup merge of #119642 - petrochenkov:winstdtest, r=ChrisDenton 89a2e452664 Rollup merge of #119640 - petrochenkov:rtstartup, r=Mark-Simulacrum 065cc1e866d Rollup merge of #119216 - weiznich:use_diagnostic_namespace_in_stdlib, r=compiler-errors 76efa1d4f71 library: Fix a symlink test failing on Windows 3d89e1a73f4 Remove feature not required by `Ipv6Addr::to_cononical` doctest 112fac48900 library: Fix warnings in rtstartup e6e55c1829a Fix broken build for ESP IDF due to #119026 036714fd56b library: Add `allow(unused_assignments)` to custom MIR doctest 836b043ab4a Rollup merge of #119583 - AngelicosPhosphoros:const_assume, r=RalfJung bf068c1057c Fix #119551: Rewrite Iterator::position default impl, storing the accumulating value outside of the fold in an attempt to improve code generation 63249a4cb78 Replace some usage of `#[rustc_on_unimplemented]` with `#[diagnostic::on_unimplemented]` 4ba31a4293d Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkin 4fd6bea9561 Fix a typo in core::ops::Deref's doc b7c9c8ff079 Fixed ambiguity in hint.rs a792fc42a9f Auto merge of #119569 - matthiaskrgr:rollup-4packja, r=matthiaskrgr 40db6b4db38 Make `intrinsics::assume` const stable c3b564ba50b Rollup merge of #119532 - GKFX:offset-of-parse-expr, r=est31 39fb918913b Rollup merge of #119475 - saethlin:remove-libtest-dylib, r=cuviper 2e7b487f86e Rollup merge of #119325 - RalfJung:custom-mir, r=compiler-errors 0aa42401fa1 Rollup merge of #119026 - devnexen:listener_upd, r=Mark-Simulacrum 23ee6ed2411 Rollup merge of #119534 - tgross35:thread-local-example-updates, r=JohnTitor f41e2b92ade Rollup merge of #119434 - taiki-e:rc-is-dangling, r=Mark-Simulacrum 041bb50e7cd Rollup merge of #119319 - chfogelman:buffered-file-doc, r=the8472 505a0ad45b7 Update `thread_local` examples to use `local_key_cell_methods` 4a67e2b6e11 Make `Barrier::new()` const 08031df2336 Make offset_of field parsing use metavariable which handles any spacing 6fe6fb3110e Adjust library tests for unused_tuple_struct_fields -> dead_code 11e97894239 Document that File does not buffer reads/writes, refer to BufReader/BufWriter 008903334f0 Clarify ambiguity in select_nth_unstable docs e986fb78d3b Remove libtest's dylib dc2b0c5293c Initial implementation of `str::from_raw_parts[_mut]` 7a86f4453b2 Auto merge of #119436 - semarie:openbsd-available_parallelism, r=Mark-Simulacrum f9e6776a625 Rollup merge of #119424 - ojeda:send-sync, r=est31 43d6df55b48 Rollup merge of #119386 - Emilgardis:typo-ipaddr-canonical-doc, r=est31 377c3a5d3fc Rollup merge of #119158 - JohnTheCoolingFan:arc-weak-clone-pretty, r=cuviper efde601f464 openbsd: available_parallelism: use the right API 00796869dd5 rc: Take *const T in is_dangling 7a8e24d2954 Primitive docs: fix confusing `Send` in `&T`'s list 6691e6f83cf Italicise "bytes" in the docs of some `Vec` methods 3bab3130d04 fix typo cb60d47837d custom mir: better type-checking 02deaac3660 custom mir: make it clear what the return block is fe602dc8d23 explain what crates should do when adding comparison with foreign types 4883392225b PartialOrd: transitivity and duality are required only if the corresponding impls exist fb7ef3387ae PartialEq: handle longer transitive chains 3cc058379f4 Rollup merge of #119235 - Urgau:missing-feature-gate-sanitizer-cfi-cfgs, r=Nilstrieb 6bd0ab498bb Auto merge of #119133 - scottmcm:assert-unchecked, r=thomcc 034e848aa8e Auto merge of #119313 - matthiaskrgr:rollup-41x48j6, r=matthiaskrgr 33f77ef6923 select AsyncFn traits during overloaded call op f8b01dbb463 We do not need impl_trait_in_assoc_ty 3c3731d931a Add AsyncFn family of traits 946a1441718 Fix doc typo for read_exact_at 2b75947775c Documented unsafe blocks b4d6acd6c20 Removed redundant bounds checking at Split's next and next_mut methods 880653eae1c Stabilize ip_in_core feature 9270f52b5fc std::net::bind using -1 for openbsd which in turn sets it to somaxconn. f6404f34ad4 Rollup merge of #119205 - mumbleskates:vecdeque-comment-fix, r=Mark-Simulacrum 5cf9199e065 Rollup merge of #119153 - rursprung:stabilize-file_create_new, r=dtolnay b6710f59967 Rollup merge of #119222 - eholk:into-async-iterator, r=compiler-errors,dtolnay 42746f7bc2b Auto merge of #119211 - rust-lang:pa-master-1.77, r=Mark-Simulacrum 7256e8d09c8 Adjust the std library for sanitizer_cfi cfgs changes 6a76e0cc30f Use `IntoAsyncIterator` in `for await` loop desugaring 5659b659977 Add IntoAsyncIterator 09514f4ec4d Auto merge of #118847 - eholk:for-await, r=compiler-errors 7f1eb902298 update cfg(bootstrap)s 28a91e6aedc update version placeholders 1e5c2c35027 fix minor mistake in comments describing VecDeque resizing e6de110cdc9 Auto merge of #119037 - RalfJung:repr-c-abi-mismatch, r=scottmcm a3064fdba9d Cleaned up alloc::sync::Weak Clone implementation ae745ba4713 stabilize `file_create_new` d0ef5cf7505 Auto merge of #106790 - the8472:rawvec-niche, r=scottmcm f8cfeaadba7 Add `hint::assert_unchecked` d27bf831830 Docs: Use non-SeqCst in module example of atomics a50159972a6 Desugar for await loops a914ba026d7 Auto merge of #118853 - calebzulawski:simd-intrinsics, r=RalfJung 67725cf2574 Disable new intrinsics for bootstrap f6b43a37faf Add Ipv6Addr::is_ipv4_mapped a26a089af1f Rollup merge of #119051 - ChrisDenton:wine, r=workingjubilee 129de57bad8 Add new intrinsics 4c80c2b6e00 Further explain semantics 737cc2d546d Apply suggestions from code review bdc3ada1384 Improve simd_bitmask documentation and other minor fixes dd542705044 State type requirements first 9360c3ce773 Clarify UB and improve grammar b1455888f93 Add core::intrinsics::simd 24e0f506e69 Auto merge of #114962 - darklyspaced:debug, r=est31 cf03cdc11a7 Use FileEndOfFileInfo, not FileAllocationInfo 834dece360c do not allow ABI mismatches inside repr(C) types 094d3f68dbf Auto merge of #118830 - GuillaumeGomez:env-tracked_env, r=Nilstrieb 9d8ff2fee68 Rollup merge of #118851 - bzEq:std-xcoff, r=Mark-Simulacrum 77896d2f4e1 Rollup merge of #118523 - okaneco:trim_ascii, r=Mark-Simulacrum 8ae31d0e92e Rollup merge of #118998 - jstasiak:improve-doc, r=workingjubilee 360129bdf09 Rollup merge of #118956 - danielhuang:patch-2, r=workingjubilee 01e5ec0c75d Rollup merge of #118396 - compiler-errors:ast-lang-items, r=cjgillot 7bcf2ab93cb Add link to is_benchmark from the Ipv6Addr::is_global documentation 3e0a7c7fcd7 Rollup merge of #118234 - tgross35:type_name_of_value, r=dtolnay a193b7c605b Stabilize `ptr::{from_ref, from_mut}` b4afed2590f Cfg remove lang items in doctest 68480357d9e Use assert_unsafe_precondition for char::from_u32_unchecked 4301c249865 Auto merge of #118966 - matthiaskrgr:rollup-sdvjwy6, r=matthiaskrgr c65c551565a Rollup merge of #116888 - tbu-:pr_unsafe_env, r=Amanieu 5347e60bf70 Auto merge of #118770 - saethlin:fix-inline-never-uses, r=nnethercote b90f1fdb33c Update c_str.rs 5ed9b035932 Update c_str.rs 0b262843a6d Fix target_feature config in portable-simd 3af87482b1b Fix cases where std accidentally relied on inline(never) e31887aea5f Auto merge of #118566 - klensy:cstr-new, r=WaffleLapkin 32a39b278bd Reformulate `std::env::{set,remove}_env` as safety note e23a100181a Auto merge of #117050 - c410-f3r:here-we-go-again, r=petrochenkov a264b43b03b Auto merge of #118900 - workingjubilee:rollup-wkv9hq1, r=workingjubilee 354731f1ed7 Rollup merge of #118873 - lukas-code:fix_waker_getter_tracking_issue_number, r=workingjubilee c5014230ed9 Rollup merge of #118858 - mu001999:dead_code/clean, r=cuviper f8c1cd4c602 Auto merge of #116438 - ChrisDenton:truncate, r=thomcc 6e438c842ac Use different cfg for AIX e6d304bc907 Add ASCII whitespace trimming functions to `&str` eb420c7fdb2 fix `waker_getters` tracking issue number e65018434f4 added column number to dbg!() cf8b0c3bc8d Remove dead codes in core b748da17297 Add xcoff support 70204e83c92 add comment to RawVec::cap field ddb024f5e06 add more niches to rawvec a81c1cbcc2f Updating fs::read example to remove SocketAddress f204a7d7cfa fixing error std::fs::read_to_string example documentation 532c180d300 Add support for `--env` on `tracked_env::var` 2c9087a7e48 Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwco e5e5bc6978b Auto merge of #118823 - GuillaumeGomez:rollup-6v51gxv, r=GuillaumeGomez fedb37b98e0 Rollup merge of #118807 - SUPERCILEX:allo, r=the8472 3f97f2cf673 Auto merge of #118661 - fee1-dead-contrib:restore-const-partialEq, r=compiler-errors fbf4b9a9036 Auto merge of #118032 - RalfJung:char-u32, r=Mark-Simulacrum cae5eb368e7 Improve `print_tts` by changing `tokenstream::Spacing`. 9351312333a Remove an allocation in min_stack bd9be87dbdf Auto merge of #118692 - surechen:remove_unused_imports, r=petrochenkov 2504c01535d Use AtomicU8 instead of AtomicUsize in backtrace.rs 5e35bce385a Restore `const PartialEq` 19116af9475 Auto merge of #118792 - naglis:fix-mutex-doc-typo, r=workingjubilee e5ea697b54c Auto merge of #116949 - hamza1311:stablize-arc_unwrap_or_clone, r=dtolnay 987fd98c6b4 remove redundant imports 6a1281cf15d Fix typo in `std::sync::Mutex` example 736536530f3 merge core_panic feature into panic_internals 0c2b701b02f Auto merge of #117873 - quininer:android-emutls, r=Amanieu 1f94db9aa1f Auto merge of #114136 - TennyZhuang:linked-list-retain, r=thomcc 4ca29a27095 Implement `async gen` blocks eda792c6339 std: getrandom simplification for freebsd. daac4f72be8 Rollup merge of #118581 - ianrrees:add-drop-note-to-once_lock, r=workingjubilee bc580eee9de Rollup merge of #118505 - CLEckhardt:update_ip_addr_bits_docs, r=cuviper 731c07c16c6 OnceLock: Rework example, statics aren't dropped ff8225caf1e libtest: Fix padding of benchmarks run as tests 130981b4684 Introduce explanation about fields being used in ordering aad75d74c3f Elaborate on ip_addr bit conversion endianness a4200786602 Auto merge of #116565 - Sword-Destiny:master, r=Amanieu 9981efabbbb add teeos std impl a745774d1f9 Auto merge of #117960 - zhiqiangxu:dry, r=workingjubilee af2abb9c464 Rollup merge of #118669 - klensy:comment-fix, r=workingjubilee 212f7731415 Rollup merge of #117563 - 0xalpharush:docs/into-raw, r=workingjubilee e7b87a711cb Add emulated TLS support 29ca6e3aa62 library: fix comment about const assert in win api fd78c4428fa Auto merge of #118460 - the8472:fix-vec-realloc, r=saethlin 81f1fa6df7e Adjust tests for newly added ambiguous_wide_pointer_comparisons lint 2ed669f92be Allow ambiguous_wide_pointer_comparisons lint for std methods 2ab744f4997 Auto merge of #118655 - compiler-errors:rollup-vrngyzn, r=compiler-errors d92b735419e Auto merge of #117072 - betrusted-io:unwinding-crate-support, r=cuviper 1c94427538f std: xous: take eh_frame address from main args a7f6f030095 Don't repeat yourself 6d9ffac0332 fmt 77d12a8dc58 Auto merge of #118547 - alexcrichton:invert-common-net-inclusion, r=workingjubilee df63d00f7fc Specify behavior if the closure passed to *Guard::*map panics. 584f33a4897 fix MappedMutexGuard::(try_)map doc typo. 925591fe266 Add MappedMutexGuard and MappedRwLock*Guard tests. 835772dd1af Fix Condvar typo, add public re-exports of Mapped*Guard. f70aedc1308 Add comment about `Mapped(Mutex|RwLockWrite)Guard` variance. 30633d34093 Auto merge of #118273 - AngelicosPhosphoros:dedup_2_loops_version_77772_2, r=the8472 aabcb1feefb Implmement `MappedRwLock(Read|Write)Guard`. ccb4fbb3a60 Implement `MappedMutexGuard`. 036a7bbb770 Allow cloning `poison::Guard`s. adb9f0de90e Split `Vec::dedup_by` into 2 cycles 0687c6e2aef Rollup merge of #118450 - marcin-serwin:master, r=workingjubilee a6dd99ca36a Rollup merge of #118350 - DaniPopes:tuple-default, r=workingjubilee 4152584d4eb Rollup merge of #118123 - RalfJung:internal-lib-features, r=compiler-errors d83007bda09 Rollup merge of #117793 - wdunicornpro:patch-1, r=workingjubilee 54e1f16af6f Stabilize `type_name_of_val` 4dbcd3e810b Fix in-place collect not reallocating when necessary d51baa02ea5 chore: Bump compiler_builtins 772ca3fb4a6 Auto merge of #118362 - RalfJung:panic_nounwind, r=thomcc 267cc0b98e3 Remove useless `'static` bounds on `Box` allocator 2d758f0d134 Rollup merge of #118591 - RalfJung:portable-simd-build-fix, r=workingjubilee,calebzulawski 0b926e624de Specialize `count` too cb9c438f4c3 `HashMap`/`HashSet`: forward `fold` implementations of iterators 040289b77e3 portable-simd: add missing feature gate bfb169782c4 Improve example in `slice::windows()` doc 53e0fc10b22 Auto merge of #116915 - bend-n:unwet, r=saethlin 0cb2767a456 use `assume(idx < self.len())` in `[T]::get_unchecked` 2b9e60c314e move calling miri_promise_symbolic_alignment to a shared helper d3f06275540 miri: support 'promising' alignment for symbolic alignment check 83935ecd23a library: use c string literals 341abd12141 Auto merge of #118487 - RalfJung:exposed-provenance, r=thomcc ab672335bdf Auto merge of #118128 - RalfJung:bad-intrinsics, r=the8472 6dc23c45703 Auto merge of #118484 - blyxxyz:os-str-slice, r=BurntSushi d6dd470bc72 std: Invert logic for inclusion of `sys_common::net` f83c94983c3 Auto merge of #118077 - calebzulawski:sync-portable-simd-2023-11-19, r=workingjubilee 642e340e215 Remove link to core::arch::x86_64 79b70e207ba Add diagnostic item to PartialEq::{eq,ne} 4e08bdc352b Add substring API for `OsStr` 1b01292b93b Attempt to try to resolve blocking concerns 7f9b7da1801 Auto merge of #117248 - ChrisDenton:ci-symlink, r=m-ou-se eab198b4ba8 update addr docs 5c50b0da133 move exposed-provenance APIs into separate feature gate and explain the relationship of Exposed Provenance and Strict Provenance c0fddcf5d33 Remove `{,r}split_array_ref{,_mut}` methods from slices 7ad08fbb0e2 Use OnceCell in cell module documentation 2291371f5fc Auto merge of #118315 - WaffleLapkin:don't-repeat_byte, r=m-ou-se 91c5b321171 Rollup merge of #118231 - RalfJung:const-raw-slice-empty, r=cuviper 0cc6c954a7d Auto merge of #118433 - matthiaskrgr:rollup-fi9lrwg, r=matthiaskrgr a19e7d21f3d Rollup merge of #118383 - shepmaster:unused-tuple-struct-field-cleanup-stdlib, r=m-ou-se 28f7a2ffea3 Rollup merge of #118398 - mu001999:std/add_cfgs, r=thomcc 8385b300657 Rollup merge of #118265 - RalfJung:memcpy, r=cuviper 3603a858596 Rollup merge of #116839 - joboet:xous_thread_parking, r=m-ou-se 490f093da0d Auto merge of #114841 - bvanjoi:fix-114814, r=cuviper bb148e7082c Address unused tuple struct fields in the standard library 0adfacb7f3a reword panic comments and add spaces to unlikely branches 8ab919f0dca Rollup merge of #118222 - the8472:copy-use-vec-write, r=m-ou-se 3f04ca532dc Rollup merge of #118193 - max-heller:command-typo, r=m-ou-se fc86419cf61 Auto merge of #110353 - the8472:in-place-flatten-chunks, r=cuviper f9b6e163bdc Rollup merge of #118397 - Zalathar:nonzero, r=WaffleLapkin 3e5f23faaff Rollup merge of #118314 - WaffleLapkin:rename_collectionstests, r=cuviper f362088f9bd Rollup merge of #118299 - frewsxcv:patch-2, r=cuviper e3e1cab7a07 Rollup merge of #118236 - ksw2000:update_mod_comment, r=cuviper 19b5d73ffa9 Rollup merge of #115331 - the8472:chars_advance, r=cuviper 224db022242 Add proper cfgs 6babb4ff4a7 Fix comments for unsigned non-zero `checked_add`, `saturating_add` 3fef48a438c optimize str::iter::Chars::advance_by a76f71afed5 benchmarks for Chars::advance_by 82ac2057a30 use the usual attributes for panic_misaligned_pointer_dereference 2fef5aa997f make sure panic_nounwind_fmt can still be fully inlined (e.g. for panic_immediate_abort) f89dc1f0127 stabilise bound_map c53360dce15 Auto merge of #118321 - WaffleLapkin:unspace-fn-pointer-fake-variadic, r=notriddle 4e0bf7a0df4 Simplify Default for tuples 068adb0459d Auto merge of #118313 - WaffleLapkin:fixup_comments_in_some_nonzero_ops, r=thomcc a72f11a64c3 Auto merge of #117697 - WaffleLapkin:non-null-convenience-ops, r=Amanieu 538a4227019 unify read_to_end and io::copy impls for reading into a Vec 4d674174132 Add `is_aligned{,_to}` convenience methods to `NonNull` ea8883876b1 Add `align_offset` convenience method to `NonNull` 281c5fdcec1 Add `replace` and `swap` convenience methods to `NonNull` dc0161f0ddf Add `offset_from`-ish convenience methods to `NonNull` a7be95995ff Add offset-ish convenience methods to `NonNull` 515e37919e0 Add read/write/copy convenience methods to `NonNull` 947505e6535 rustdoc: Remove space from fake-variadic fn ptr impls fd905e142c6 Rollup merge of #118302 - mu001999:dead_code/clean, r=cjgillot 411fee8d41d Update std::simd usage and test outputs 31dd00a7e61 Use inner docs to fix links 56544d26f53 Fix library tests e645b19a6d5 Merge commit 'e0e9a4517f9fc021283514da387e70a56061bd3e' into sync-portable-simd-2023-11-19 a1c1b1f10b2 Use `usize::repeat_u8` instead of implementing `repeat_byte` in `memchr.rs` de1d87ac2fa Rename `{collections=>alloc}{tests,benches}` 121f0bca48c Improve some comments for non-zero ops a35b936aa05 Making `User` and `User<[T]>` `Send` 54c74ba29e1 Auto merge of #110303 - nbdd0121:master, r=Mark-Simulacrum 11e0c8a775b Remove an unneeded helper from the tuple library code 69dce6b4103 Clean dead codes 2f9d70e2248 Address review feedback abf4680288c Convert many `assert_unsafe_precondition` to `debug_assert_nounwind` f19ca94ac33 Add `debug_assert_nounwind` 0a1e10d2d57 Rollup merge of #117968 - Urgau:stabilize-ptr-addr-eq, r=dtolnay 1f69bbc5e14 Update `OnceLock` documentation to give a concrete 'lazy static' example, and expand on existing example. 2bf56713206 Add more benchmarks of `Vec::dedup` f2d2175847a Auto merge of #118138 - Nilstrieb:one-previous-error, r=WaffleLapkin 3daf207c325 remove the memcpy-on-equal-ptrs assumption 56ec39c47ed add `#[track_caller]` to improve panic locations 4459659aa19 implement strict_* operations for unsigned integer types 3df3df1b205 implement strict_* operations for signed integer types abfad4a272b Show number in error message even for one error 78e0c4679b8 Rollup merge of #118238 - RalfJung:memcpy, r=Mark-Simulacrum 9ee5b636ce2 Auto merge of #118228 - Mark-Simulacrum:alloc-opt, r=scottmcm 01545b0140d memcpy assumptions: update GCC link 8da4a582849 correct grammar 8dbcebb527d Auto merge of #118232 - matthiaskrgr:rollup-x8crvm0, r=matthiaskrgr 23e3d5e7993 Update comment for consistent context logic. 5a9efe84287 also add is_empty to const raw slices 9b17f67ef7a Rollup merge of #118060 - ChrisDenton:abs-device-path, r=thomcc 3e9b928e384 Rollup merge of #118028 - Jules-Bertholet:dyn-any-doc, r=thomcc c05a7fd4247 Rollup merge of #117940 - zhiqiangxu:remove_redundant_drop, r=thomcc 1cb5c6d5082 Rollup merge of #117656 - ChrisDenton:invalid, r=thomcc b6ec4c7799f Rollup merge of #116807 - seanlinsley:patch-2, r=thomcc e5248d1c136 Auto merge of #117722 - okaneco:binarysearch, r=thomcc a1d462ca37c Indicate that multiplication in Layout::array cannot overflow 7d21b760c6e Auto merge of #98943 - WilliamVenner:feat/bufread_skip_until, r=dtolnay 88aa68450ba Fix tracking issue of Windows ExitCodeExt 2c66f70283d add track_caller for arith ops 6175bdf3cc3 Add UnorderedKeyError 701b596d8fb Update library/alloc/src/collections/btree/map.rs ae70ce8f43f Rewrite the BTreeMap cursor API using gaps 7c925ed9077 Auto merge of #115159 - solid-rs:patch/kmc-solid/io-safety, r=workingjubilee 81afd1b15eb add missing period in `std::process::Command` docs bcb948bec51 Auto merge of #118154 - ChrisDenton:win-clippy, r=scottmcm bec8f5c3986 also make 'core_intrinsics' internal 911148b3e5a warn against using intrinsics that leave the scope of our memory model 45a33a5e47c x fmt library/std d371b943424 redundant_slicing 4f293cc5f4e cmp_null 4410a011921 manual_range_contains 9422ac71eb4 op_ref be7c19193cc manual_map 80b7277cf8d unnecessary_lazy_evaluations b897df5894e redundant_closure c3f39a515f4 duration_subsec 47fa832295f unnecessary_cast ffe129d41ab needless_borrow c5cb57047ae needless_borrows_for_generic_args d8b91804b33 manual_slice_size_calculation 27ecafce377 unnecessary_mut_passed f585467846f useless_conversion 71567a8aebb needless_return 2c49775cb13 Stabilize RFC3324 dyn upcasting coercion 4f4cc2876ba allow clippy style in windows/c.rs fbb5ead3af1 Update backtrace submodule 3ca634d2079 Auto merge of #117619 - elomatreb:add-duration-abs-diff, r=thomcc 6d761833fe9 Rollup merge of #118094 - JarvisCraft:SpecFromElem-for-empty-tuple, r=thomcc 65b2c97f8b0 Rollup merge of #117790 - rcvalle:rust-cfi-fix-000000, r=workingjubilee b39c33e073b docs(GH-118094): make docs a bit more explicit fddae36be76 chore(GH-118094): explicitly mark `_elem` as unused 544e8b9849e feat: specialize `SpecFromElem` for `()` 106195908ec Rollup merge of #117957 - the8472:pidfd-wait, r=Mark-Simulacrum 826c700ab43 Use an absolute path to the NUL device 83346fa63c6 Don't set cmsg fields in msghdr if we have no cmsg to send 05cf7568e61 Auto merge of #117895 - mzohreva:mz/fix-sgx-backtrace, r=Mark-Simulacrum 31295d46c77 Rollup merge of #116750 - fintelia:seek_seek_relative, r=Mark-Simulacrum f194f9d890b Auto merge of #117525 - GKFX:remove_option_payload_ptr, r=petrochenkov a82ea4989b5 Update based on petrochenkov's review 08716c340a7 Auto merge of #115412 - eswartz:docs/total_cmp-test-result-in-docs, r=scottmcm 9853d041332 guarantee that char and u32 are ABI-compatible d3bb64813d5 Auto merge of #115249 - clarfonthey:alignment, r=scottmcm 54ee57d01a9 impl more traits for ptr::Alignment, add mask method 96aed5c2c37 Auto merge of #117825 - fee1-dead-contrib:corefx, r=petrochenkov feb4573dfdf Auto merge of #117138 - zachs18:rwlock_guard_debug_unsized, r=dtolnay 90dda90e193 Document behavior of `::type_id()` 846d82cd4de Rollup merge of #118006 - lcnr:discriminant-docs, r=compiler-errors b5276347daf Rollup merge of #117549 - DaniPopes:more-copied, r=b-naber 1ad39401e2e Rollup merge of #117338 - workingjubilee:asmjs-meets-thanatos, r=b-naber 90476fe3569 Use ptr::invalid_mut for SGX image base 5496bb95dba Auto merge of #111922 - vaporoxx:feat-searcher, r=dtolnay 1920da67715 Update windows-bindgen 1516463ea82 Define `INVALID_HANDLE_VALUE` ourselves 1cf8ab07b11 Improve slice_group_by doc wording 89644c53dd4 only free lifetimes may get erased da66368cfaa Rollup merge of #115476 - RalfJung:abi-compat-docs, r=Mark-Simulacrum b42f64e2191 linking in general has more pitfalls than just call ABI 672db474346 Rollup merge of #117946 - RalfJung:miri-libcore-test, r=Mark-Simulacrum 795bc3ad2a9 Remove option_payload_ptr; redundant to offset_of 7cf12a63185 Stabilize ptr_addr_eq library feature b05438e0cd1 std: personality: support gcc personality on Xous a1f1d2d33bb panic_unwind: support unwinding on xous a7693cc52a5 unwind: add support for using `unwinding` crate 18625de4917 Re-format code with new rustfmt f9fc47fb824 if available use a Child's pidfd for kill/wait c7f8e283e48 Bump cfg(bootstrap)s 74c22e80837 Substitute version placeholders 0c208e242f9 update comment, we're currently using a different syscall 99a7254fc03 set CLOEXEC on pidfd received from child process 448a62ed4a5 avoid exhaustive i16 test in Miri f1e509919db remove unnecessary drop 34f510263f4 Move SGX-specific image base logic to sys_common 1f10b56cda4 Adjust frame IP in backtraces relative to image base for SGX target 0f2f310ce95 Auto merge of #117330 - tmiasko:custom-mir-cleanup-blocks, r=cjgillot bca8e5a9313 Custom MIR: Support cleanup blocks 63b904158d1 Auto merge of #116301 - mj10021:issue-115737-fix, r=cuviper b49c8f3f82d Auto merge of #116866 - slanterns:inspect-stabilize, r=BurntSushi 648e2041e81 Reenable effects in libcore 76b47f90a02 Rename MaybeUninit::write_slice 9dc9e69fe79 round to even 54cadc37bff fix rounding issue with exponents in fmt 25b3c8d90f6 Auto merge of #115694 - clarfonthey:std-hash-private, r=dtolnay 5eda90f9108 clarify ABI compatibility of fn ptr types and ptr types 6622b03ff04 Update variable name to fix `unused_variables` warning c71459409ee add 'import functions' to the list of situations where ABI compatibility comes up 6ee9fef3252 CFI: Add missing use core::ffi::c_int 36bc999d8b2 Auto merge of #117572 - RalfJung:addr_of, r=cuviper d124ea843c0 mention null explicitly b4daab4764f Rollup merge of #117730 - jmillikin:fmt-debug-helper-fns, r=cuviper 63433830f3f Rollup merge of #117039 - scottmcm:clarify-get-unchecked, r=cuviper 0ba03dd9ac3 Closure-consuming helper functions for `fmt::Debug` helpers b6d3da5039b Remove trailing whitespace 1cc3e03578f Add note on how 0 flag overrides fill character 16412667b8e Rollup merge of #117694 - jmillikin:core-io-borrowed-buf, r=m-ou-se 4be6cf5939e Rollup merge of #116762 - WaffleLapkin:fixup_fromptr_docs, r=RalfJung 4f8640b96a3 Move `BorrowedBuf` and `BorrowedCursor` from `std:io` to `core::io` a5574ea8302 Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwco 90d17587c91 Refactor `binary_search_by` to use conditional moves 213f620089c Add link to Formatting traits from alternate forms d1d8fba24bb Auto merge of #115460 - zachs18:borrowedcursor_write_no_panic, r=dtolnay 9ef0ede0aed Fix addition formatting b2be5bbd612 kmc-solid: Re-export `{As,Borrowed,Owned}Fd` in `std::os::solid::prelude` 302b4f13f9e kmc-solid: Reimplement `AsFd` etc for `{TcpStream,TcpListener,UdpSocket}` by delegating to inner `Socket` 4f97d7694a3 kmc-solid: Implement `{From,Into}Inner` for `Socket` d376a845abc kmc-solid: Remove `FileDesc` 2ed6a920d30 kmc-solid: Replace `{From,Into}Inner` impls with `*RawFd` for `Socket` 32f56b25e1a kmc-solid: Implement `AsFd` for `{Arc,Rc,Box}` 0fbeb671fa8 kmc-solid: Implement `AsFd` and conversion to/from `OwnedFd` for `{TcpStream,TcpListener,UdpSocket}` 9038c400a5f kmc-solid: Document I/O safety in `std::os::solid::io` e2a1853bac4 kmc-solid: Add `std::os::solid::io::{BorrowedFd,OwnedFd,AsFd}` afb839f0104 Document how rust atomics work wrt mixed-sized and non-atomic accesses cb9e8a9d84c Auto merge of #117617 - Urgau:bump-libc-0.2.150, r=Mark-Simulacrum 144b646c570 Stabilize `slice_group_by` 6238648ba9f Rollup merge of #117631 - smarnach:error-request-doc-fix, r=ChrisDenton 37279b0a149 Auto merge of #116988 - RalfJung:null, r=WaffleLapkin 311dcae7cb7 Documentation cleanup for core::error::Request. 043bd1ec6a2 Auto merge of #117576 - the8472:fix-io-copy-vec, r=Mark-Simulacrum eef56dccd34 Auto merge of #96979 - SabrinaJewson:waker-update, r=workingjubilee 20487e2de15 Add `Duration::abs_diff` c932856c674 Auto merge of #117179 - Voultapher:fix-useless-comp-in-partition-equal, r=Mark-Simulacrum f296577deaf libc: bump dependency to 0.2.150 c245983e791 Auto merge of #117537 - GKFX:offset-of-enum-feature, r=cjgillot bf90b232b22 Auto merge of #117608 - matthiaskrgr:rollup-g9fagmv, r=matthiaskrgr 1b9bbfad3c5 Rollup merge of #117596 - thomcc:core_macro_diag_items, r=Nilstrieb 098ffd8c1ac update and clarify addr_of docs b072086f04c Auto merge of #117504 - pcc:android-link-libunwind, r=Mark-Simulacrum 72c66ad4902 Auto merge of #116218 - tgross35:const-maybe-uninit-zeroed, r=dtolnay b182b30088d Auto merge of #117581 - nicholasbishop:bishop-update-cb, r=Mark-Simulacrum 50e5e2b274a Auto merge of #117503 - kornelski:hint-try-reserved, r=workingjubilee a8e2981e302 Add diagnostic items for a few of core's builtin macros 8c1693af403 Improve documentation 304a05fc7bb Rollup merge of #117534 - RalfJung:str, r=Mark-Simulacrum 91daa7beacb Rollup merge of #116894 - joshlf:patch-12, r=RalfJung fbb305631d7 Rollup merge of #110340 - jmaargh:jmaargh/deref-docs, r=Mark-Simulacrum b0ae6de9eba Stabilize `const_mem_zeroed` 43bb938c2ae Stabilize `const_maybe_uninit_zeroed` 33fa5e3bda3 Draft fleshed-out deref docs 287f19b69e4 Bump compiler_builtins to 0.1.103 960e6c9eef3 detect EOF earlier a0c55a6cf93 avoid excessive initialization when copying to a Vec 85feb7d49a8 avoid acronyms when we don't really need them 7d6a6c89bd7 document ABI compatibility 253230853d4 docs: clarify explicitly freeing heap allocated memory ce48fd803fd Make documentation of `slice_first_last_chunk` more consistent c667725d54e Reverse ordering of `split_{first,last}_chunk` to be `(preceding, last)` f832443401e Auto merge of #116412 - nnethercote:rm-plugin-support, r=bjorn3 5f6051524a0 Remove support for compiler plugins. 3aa28ed5006 Auto merge of #115333 - joshlf:patch-5, r=RalfJung 59174fb18ab library: use `copied` instead of manual `map` 6070557db2a cfg_attr offset_of_enum feature in doctest 2aa01d77322 Update primitive_docs.rs ca894807f79 Feature gate enums in offset_of 00e76580229 Rollup merge of #117434 - BugenZhao:box-error-provide, r=cuviper 16383cca799 Auto merge of #117510 - elichai:patch-3, r=cuviper 650b39560b5 clarify that the str invariant is a safety, not validity, invariant b46bf8f1053 Remove obsolete support for linking unwinder on Android 8f0740dc2af Add insta-stable std::hash::{DefaultHasher, RandomState} exports 945081ec5a4 Move RandomState and DefaultHasher into std::hash, but don't export for now 7d58eaeb33f Pretty print Fn traits in rustc_on_unimplemented 561e4cb6cf9 Rollup merge of #117512 - joshlf:patch-8, r=dtolnay cd32837fd2e Rollup merge of #117495 - compiler-errors:unsize-docs, r=lcnr 945306adaab Update mod.rs e1202884159 Update mod.rs bd70d401cf0 Remove trailing space b12e5df3b88 Expand mem::offset_of! docs 490c57d6e10 Add track_caller to transmute_copy 82d34419889 Auto merge of #117386 - roblabla:fix-switch-stdio-win7, r=ChrisDenton f3076504bf1 fixes: typo in `std::cmp::Ord` trait docs 5ae20580af2 Hint optimizer about reserved capacity cf4f2e04666 Rework unsize documentation a3cbf247dfe Remove a false statement from Unsize docs, add a test c76182bcad1 Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiser 207f8284b1c Rollup merge of #115626 - clarfonthey:unchecked-math, r=thomcc 294471d090d Auto merge of #115356 - devnexen:haiku_set_name_use_return, r=thomcc 87551a86d92 Auto merge of #117422 - joshtriplett:stabilize-file-times, r=workingjubilee 7eaa1798cb5 Update based on wesleywiser review a365d19d08b Update MIR tests for offset_of 84cd250b67f Enums in offset_of: update based on est31, scottmcm & llogiq review 87a913535a6 Auto merge of #117459 - matthiaskrgr:rollup-t3osb3c, r=matthiaskrgr 2e4a38fac14 Add support for pre-unix-epoch file dates on Apple platforms (#108277) 4b4a5aec171 Accept less invalid Rust in rustdoc 2bbea5704ed Fix switch_stdout_to on Windows7 44cd6f24c44 delegate box error provide 6714d188b00 Stabilize `file_set_times` fa17679ac48 Rollup merge of #117205 - weiznich:multiple_notes_for_on_unimplemented, r=compiler-errors 3fdf54d4b9e Rollup merge of #117177 - Ayush1325:uefi-alloc-type, r=workingjubilee d42384f8b2c Use ImageDataType for allocation type 1b3cddaa7e7 Add tracking issue 63cb5473364 Auto merge of #117332 - saethlin:panic-immediate-abort, r=workingjubilee f03ecefba8a Auto merge of #117089 - wesleywiser:update_backtrace, r=Mark-Simulacrum 6e28ce56940 Increase the reach of panic_immediate_abort 12b4688352f Rollup merge of #117312 - RalfJung:memcpy-assumptions, r=Mark-Simulacrum 203c36d4f8a Rollup merge of #115968 - git-bruh:master, r=workingjubilee c18e982aa00 Remove asmjs from library fcb193e52ae Don't use LFS64 symbols on musl d1810723683 Rollup merge of #117316 - Coekjan:const-binary-heap-constructor, r=dtolnay 07525bc3f60 Rollup merge of #117162 - c410-f3r:try, r=workingjubilee 088a035ecf5 Auto merge of #116240 - dtolnay:constdiscriminant, r=thomcc 7eeb06128dd make pointer_structural_match warn-by-default 4f1343efd87 mark constructor of `BinaryHeap` as const fn 5a922752288 Auto merge of #117038 - saethlin:inline-range-methods, r=workingjubilee 81ffa2b07a2 Auto merge of #116609 - eduardosm:bump-stdarch, r=workingjubilee 1fd36ea9584 memcpy assumptions: link to source showing that GCC makes the same assumption 91a5f079c49 Rollup merge of #116816 - ChrisDenton:api.rs, r=workingjubilee d1efa40d168 Rollup merge of #117281 - RalfJung:thread-safety, r=thomcc 85850f70d98 Rollup merge of #117270 - jhpratt:hide-print-internals, r=ChrisDenton 4b74928ad23 std::thread: add SAFETY comment ec75a49b9e9 Allows `#[diagnostic::on_unimplemented]` attributes to have multiple notes 80a1321b196 Auto merge of #117272 - matthiaskrgr:rollup-upg122z, r=matthiaskrgr 300913aaffc Rollup merge of #117266 - RalfJung:cast-not-transmute, r=thomcc 2e08dd5b66f Rollup merge of #117240 - trueNAHO:docs-std-iter-Iterator-collect-into-fix-typo, r=the8472 ce1d52b2173 Hide internal methods from documentation a065bdfec19 Auto merge of #116205 - WaffleLapkin:stabilize_pointer_byte_offsets, r=dtolnay 7b2c981dc07 replace transmute by raw pointer cast 61fd4af4852 Auto merge of #117260 - okaneco:ascii_branchless, r=thomcc 9d824ffbc95 Refactor some `char`, `u8` ascii functions to be branchless dde445c934c Rollup merge of #117243 - chfogelman:replace-not-swap-comment, r=thomcc 84286afe756 Error if symlinks not supported in CI b958caacb13 Add comment to mem::replace to explain why it's not implemented via mem::swap e52c63cdf5f Fix documentation typo in std::iter::Iterator::collect_into 76c64396e97 Auto merge of #112875 - compiler-errors:negative-coherence-rework, r=lcnr a5ef8bbf775 Stabilize `[const_]pointer_byte_offsets` fb174238e4b Auto merge of #117180 - matthiaskrgr:rollup-rxhl6ep, r=matthiaskrgr b649982e48e Avoid unnecessary comparison in partition_equal d3711917ff8 Make `Iterator` a lang item f2a362f5af3 Add the missing word 26c909b6d53 Update library/core/src/primitive_docs.rs d5cb78cd8b5 Fix some coroutine sentences that don't make sense anymore. 29d675e6fe8 Remove `cfg_match` from the prelude 50524e65687 Auto merge of #117102 - devnexen:dfbsd_stack_overflow_upd, r=thomcc 85510aeea3b Convert `Unix{Datagram,Stream}::{set_}passcred()` to per-OS traits a304d6e8499 Add T: ?Sized to RwLock*Guards' Debug impls. 1fbe6fdc148 Auto merge of #117135 - matthiaskrgr:rollup-zdh18i6, r=matthiaskrgr bc73188ccf6 Rollup merge of #116714 - WaffleLapkin:order-the-order, r=joshtriplett 418ba9efd2d Auto merge of #117126 - matthiaskrgr:rollup-8huie8f, r=matthiaskrgr 4fb109d22a8 Rollup merge of #117081 - GoodDaisy:master, r=wesleywiser fedb8395952 Auto merge of #116773 - dtolnay:validatestable, r=compiler-errors 42917485f59 Auto merge of #116461 - ChrisDenton:sleep, r=thomcc 30708179581 Auto merge of #116319 - BlackHoleFox:apple-rand-take-2, r=thomcc 4644e4fee2d Auto merge of #116238 - tamird:gettimeofday, r=thomcc 2a8db6dca37 Remove Apple RNG fallbacks and simplify implementation 258692d3e1c Remove FnPtr hack from trait_ref_is_knowable b47de9a1fd8 Auto merge of #117103 - matthiaskrgr:rollup-96zuuom, r=matthiaskrgr 0bbe478cf61 stack_overflow: get_stackp using MAP_STACK flag on dragonflybsd too. 9e2e080c2e2 Rollup merge of #107159 - devnexen:random_fbsd_update, r=workingjubilee 8939dfcd7a8 Auto merge of #116033 - bvanjoi:fix-116032, r=petrochenkov f34a2a8e6ef Fix invalid stability attribute features in standard library 2d0d9a921d9 Update backtrace submodule 7050895ff56 fix typos in comments 0c25d0621f5 Auto merge of #116606 - ChrisDenton:empty, r=dtolnay 384826190aa use visibility to check unused imports and delete some stmts 13140f9ad43 Rollup merge of #116989 - ChrisDenton:skip-unsupported, r=Mark-Simulacrum faecc8294ea Clarify UB in `get_unchecked(_mut)` 9608bf802b5 Add #[inline] to some recalcitrant ops::range methods e6dca219b83 Update boxed.rs dbbe96691dd Rollup merge of #114521 - devnexen:std_fbsd_13_upd, r=cuviper c6782769f1c changes from feedback f7836072a0c Fix stage0 core tests 85943757098 s/generator/coroutine/ b577f84860d s/Generator/Coroutine/ 60095876604 Skip test if Unix sockets are unsupported ffbc82725aa document that the null pointer has the 0 address ed0df4003af Auto merge of #116966 - clarfonthey:atomic-docs-typo, r=workingjubilee 3cca2c16e9a std: freebsd build update. 75f921e6528 Fix typo in atomic docs 39f1a179cce Auto merge of #116785 - nnethercote:spec-Bytes-read, r=the8472 61a2db53e5b Specialize `Bytes::next` when `R` is a `BufReader`. 5799d217a27 Stablize arc_unwrap_or_clone 933d6749eb9 Auto merge of #116132 - darthunix:connect_poll, r=cuviper 3fe56a8bae3 Auto merge of #116923 - fmease:rollup-ev7q387, r=fmease 21a856b2e10 Rollup merge of #116795 - DaniPopes:track-caller-option, r=cuviper ec5e4c1e415 Auto merge of #114534 - niluxv:strict_prov_unwind, r=cuviper,workingjubilee 1b639a38f7c Auto merge of #116402 - joboet:global_alloc_tls_unsoundness, r=thomcc,workingjubilee 3e2ee77bfbd Guarantee that `char` has the same size and alignment as `u32` 133993f051c std: send free message when xous thread parker is dropped f5bd162a790 std: implement thread parking for xous 4d6805bbfb3 Add discussion that concurrent access to the environment is unsafe 27823c9d5a7 Rollup merge of #116856 - oli-obk:no_effects, r=compiler-errors f48b17dd8bc Automatically enable cross-crate inlining for small functions dd87c5de04d Stabilize `result_option_inspect` 165acd3b541 Disable effects in libcore again 268d70b722e Auto merge of #115577 - RalfJung:atomic-load, r=Amanieu 93cf0a1aa70 Auto merge of #116518 - vita-rust:vita, r=workingjubilee c64438b83f9 Updated libc and doc for Vita target 1e5ec4bdd0b remove 128bit atomics, they are anyway not exposed on those targets 9823db83a51 Auto merge of #116820 - GuillaumeGomez:rollup-l54ri5q, r=GuillaumeGomez 0f300141c60 Create `windows/api.rs` for safer FFI d4ab0008fb8 Improve rewind documentation ec1cc3e5ce6 Make `rustc_onunimplemented` export path agnostic 2356b12845d use target-arch based table 4213e0fa243 Add invariant to Vec::pop that len < cap if pop successful 22704b36fca Add `#[track_caller]` to `Option::unwrap_or_else` a10552f2d2d Auto merge of #116782 - matthiaskrgr:rollup-t3yrgku, r=matthiaskrgr 9d9045647b2 Rollup merge of #115955 - tgross35:ip-to-canonical, r=dtolnay c356cf546cc Auto merge of #116775 - nnethercote:inline-Bytes-next, r=the8472 046f483a7b9 Auto merge of #114589 - ijackson:exit-code-default, r=dtolnay 3fc00ac8f42 Auto merge of #113747 - clarfonthey:ip_bitops, r=dtolnay 23c686f10ba Auto merge of #116772 - matthiaskrgr:rollup-mpff3lh, r=matthiaskrgr af9bd2ab5eb Inline `Bytes::next` and `Bytes::size_hint`. e48a80942ef Rollup merge of #116760 - Nilstrieb:triviality, r=oli-obk df4eeb7910b Rollup merge of #116341 - Ayush1325:uefi-args, r=Mark-Simulacrum c63bdb7b515 Rollup merge of #116172 - joboet:recursive_tls_initialization, r=dtolnay 2ec70e83a36 Auto merge of #110604 - a1phyr:vecdeque_buf_read, r=dtolnay d12b76b1b83 Deduplicate std::process Default impl feature names 45352a8ba81 Auto merge of #110729 - ColinFinck:decode-utf16-fused-iterator, r=dtolnay 18e9a524012 acquire loads can be done as relaxed load; acquire fence 2baa2b8e393 only guarantee for Relaxed; add ptr-size fallback d35a2bad8d3 wording 1135c4f215a define 'read-only memory' d6f711bde3f add general powerpc64le bound c302d15a1aa add ARM and RISC-V values 3c91ff90555 document when atomic loads are guaranteed read-only c44f85a1cba Auto merge of #116527 - sthibaul:libc, r=Mark-Simulacrum 947b1057a9c Implement args for UEFI 63a6e1e2d7b Add tests for `SocketAddrV6` ordering with scope_id and flowinfo e901388e524 Remove trivial cast in `guaranteed_eq` ddf88731900 Make File::create work on Windows hidden files 054b89efc0b Rollup merge of #116594 - tae-soo-kim:convert-tryfrom-doc, r=scottmcm ecb01a628d6 Auto merge of #116683 - ChrisDenton:exists, r=Mark-Simulacrum 09f5fb19e12 Auto merge of #115515 - the8472:zip-for-arrays, r=scottmcm b3bc756f722 Add Seek::seek_relative e74f82815ac Rollup merge of #116540 - daxpedda:once-cell-lock-try-insert, r=Mark-Simulacrum d7395b47bba Rollup merge of #116723 - ivmarkov:master, r=dtolnay d3337bf5da9 Rollup merge of #115653 - joshlf:patch-9, r=dtolnay a282e9c1240 Fix broken build on ESP-IDF caused by #115108 721d3368132 Auto merge of #116407 - Mark-Simulacrum:bootstrap-bump, r=onur-ozkan 2131b024207 Guarantee representation of None in NPO b8f67bc6fdc Auto merge of #115719 - tgross35:atomic-from-ptr, r=dtolnay e73926f8dfa Derive `Ord`, `PartialOrd` and `Hash` for `SocketAddr*` c0ddc185a12 Stabilize 'atomic_from_ptr', move const gate to 'const_atomic_from_ptr' 7730018ebbd Correct documentation for `atomic_from_ptr` 8b423cf17f1 Revert "Invoke `backtrace-rs` buildscript in `std` buildscript" fd8dca868e0 Auto merge of #116233 - DaniPopes:stabilize-const_maybe_uninit_assume_init_read, r=dtolnay c74b8a453e1 Update primitive_docs.rs c12d55b8610 Update library/core/src/primitive_docs.rs 4c7474b66b1 Auto merge of #115108 - ijackson:broken-wait-status, r=dtolnay cde5d28c91f Add some optimizations f0eac524bda Implement `OnceCell/Lock::try_insert()` bef9eeb3427 Make TCP connect() handle EINTR correctly 63145cdaaad Clean up unchecked_math, separate out unchecked_shifts b6ef37ab759 Remove Not for IpAddr ecf02dd1e2a impl Not, Bit{And,Or,Xor}{,Assign} for IP addresses dfe2e65699f Test that unix sockets exist on Windows eae7df27fb6 Make try_exists return Ok(true) for Windows UDS 470fba5ce63 Update primitive_docs.rs bb788cb1522 Update library/core/src/alloc/layout.rs 33b345fd694 References refer to allocated objects 629105d8daa Bump stdarch submodule 36221ed372f Auto merge of #116506 - Wilfred:remove_tmp_var, r=workingjubilee cfd5978ae62 Auto merge of #112818 - Benjamin-L:add-slice_split_once, r=cuviper 5933c0e21f5 Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease e0c274826cb Rollup merge of #95967 - CAD97:from-utf16, r=dtolnay ba1e3438b31 On Windows make readdir error on the empty path 358509fff0b Rollup merge of #116559 - Kritzefitz:btree-new-in-const, r=Amanieu a8483163b2e Rewrite `read_encoded_pointer` conforming to strict provenance 11d332a86cc Use pointers instead of `usize` addresses for landing pads bb897a7867d Update mod.rs 4c99ce477d4 std: explain unconventional choice of let-else binding over while-let loop b56383a0999 Make BTreeSet::new_in const c07c9884eeb Make BTreeMap::new_in const 238587f137e Support AIX in Rust standard library 9b4de27ce04 rustdoc: remove rust logo from non-Rust crates 37dab7083d5 Bump to latest beta 4f1922cb5ff Bump libc dependency 48321ffd2fb Auto merge of #100806 - timvermeulen:split_inclusive_double_ended_bound, r=dtolnay dbd1c17b379 Expose tests for {f32,f64}.total_cmp in docs, along with comment 1d002c369bb std: fix registering of Windows TLS destructors 0e353d49059 Auto merge of #109214 - tosti007:std_collection_hash_new_rework, r=workingjubilee f82486a00c9 Remove unnecessary tmp variable in default_read_exact dca1263f001 Auto merge of #116318 - pitaj:android-backtrace-build, r=workingjubilee cc0c818e28a Auto merge of #116501 - workingjubilee:rollup-fpzov6m, r=workingjubilee 9c1b6018c39 Rollup merge of #116500 - simlay:tvos-support-for-register_dtor, r=workingjubilee fce556646fa Auto merge of #114709 - ShE3py:wasi-io-error-more, r=workingjubilee 2634376ca57 Add tvOS to target_os for register_dtor 8244b9a1257 Rollup merge of #116484 - peterjoel:once-doc-clarify, r=cuviper 83617a438a4 Rollup merge of #116481 - scottmcm:tweak-combinators, r=cuviper e2aeef184e6 Rollup merge of #114564 - scottmcm:when-to-from, r=dtolnay 4b2937c3e17 Use `io_error_more` on WASI a11236922ab optimize zipping over array iterators 0c35b267b83 Auto merge of #116483 - GuillaumeGomez:rollup-z65pno1, r=GuillaumeGomez 62164a9ccef Minor doc clarification in Once::call_once 67cd5098c3a Rollup merge of #116329 - RalfJung:swap-comments, r=scottmcm d1f0d33e502 Rollup merge of #116198 - Jarcho:diag_items, r=WaffleLapkin cacd951151a Rollup merge of #115588 - tifv:fix-comment-successors, r=scottmcm 7778eea738a Rollup merge of #115522 - joshlf:patch-8, r=scottmcm f46aa3f84c1 Rollup merge of #115454 - vwkd:patch-1, r=scottmcm fd6372dd062 Auto merge of #111595 - fortanix:raoul/waitqueue_clarifications, r=workingjubilee e4fceb02891 Reuse existing `Some`s in `Option::(x)or` e5829d75bac Elaborate some caveats to lossless b54bca9f611 Don't mention "recover the original" in `From` docs b8eb257db28 Attempt to describe the intent behind the `From` trait further dd0346a43eb Windows: Support sub-millisecond sleep e21e7d6edbc Auto merge of #116463 - ChrisDenton:nlibc, r=workingjubilee 11eab5af1a8 Auto merge of #101150 - jethrogb:jb/cleanup-sgx-user-memory-copies, r=workingjubilee 07eac25e087 Remove libc cf580e9de2b Add more diagnostic items for clippy 63558cd5484 Auto merge of #116455 - matthiaskrgr:rollup-p226a5u, r=matthiaskrgr 4acda23e2a5 Rollup merge of #116220 - llogiq:stabilize-option-as-slice, r=BurntSushi 092c7b6bb9b Auto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee 39d9aa5a65e Auto merge of #114042 - liushuyu:ubuntu/i586-fpmath, r=workingjubilee a453ca46900 docs: Correct terminology in std::cmp e23baf140b2 Auto merge of #104153 - tspiteri:doc-float-constants, r=workingjubilee 0ccedba8c15 Rollup merge of #116223 - catandcoder:master, r=cjgillot 05bad655118 Disable CFI for core and std CFI violations 9d21b334a9d std: abort instead of panicking if the global allocator uses TLS 847535e05d8 Auto merge of #116408 - matthiaskrgr:rollup-hmolg4m, r=matthiaskrgr 7b3cf02fd67 Rollup merge of #116363 - Colonial-Dev:issue-116130-fix, r=thomcc 6e73aefba4d Rollup merge of #116146 - Milo123459:milo/clarify-arg-documentation, r=thomcc 2e9cd1d9392 Rollup merge of #115961 - Kriskras99:master, r=thomcc 650fc339de4 Auto merge of #116386 - elichai:patch-2, r=thomcc f9372155f2c Bump version placeholders 39a5ead112e Auto merge of #116367 - scottmcm:more-addr-eq, r=workingjubilee ce725082288 Fix misuses of a vs an f3dab3de27d std: panic when the global allocator tries to register a TLS destructor f8e24135986 Auto merge of #105394 - Patiga:improve-udpsocket-docs, r=workingjubilee 03e89f8499f Add missing inline attributes to Duration trait impls 0a8240d1d06 Rollup merge of #116282 - rustaceanclub:master, r=davidtwco 2bfef402092 Rollup merge of #116361 - eduardosm:bump-stdarch, r=Amanieu 44b77598647 Rollup merge of #116355 - orlp:signed-zero-rounding-mode, r=thomcc 4e89004f975 Rollup merge of #116351 - asquared31415:ptr_eq_must_use, r=workingjubilee 022be7407b7 Invoke `backtrace-rs` buildscript in `std` buildscript 02952f9bea5 Use `addr_eq` in `{Arc,Rc}::ptr_eq` 2d787e165e2 Appease tidy f5eb6c03bd9 Adapt `todo!` documentation to mention displaying custom values e50f0e03669 Bump stdarch submodule c2eeb526765 Rollup merge of #116350 - Nilstrieb:in-situ, r=Dylan-DPC 77e808a28ec Rollup merge of #116289 - linkmauve:patch-1, r=the8472 1643593d67e Clarify float rounding direction for signed zero b5f74e0dcde Improve wording of `hint::black_box` docs b2e34c680d6 add must_use on pointer equality functions 0c1d6a923aa Rollup merge of #116326 - Colonial-Dev:issue-116165-fix, r=joshtriplett 7dda4c35f64 MIRI -> Miri 8b5a45713ae update some comments around swap() b295cac5ff9 Auto merge of #116325 - scottmcm:addr_eq, r=dtolnay ac25ce981d0 Correct misleading std::fmt::Binary example 31cd27b8b46 Auto merge of #116317 - ravenclaw900:track-caller-unwrap-or-else, r=Mark-Simulacrum 7c718ee460f Add `ptr::addr_eq` 5fdf9f333fa Auto merge of #116207 - Ayush1325:uefi_stdio, r=Mark-Simulacrum dc4c411c13e Stdio for UEFI 046f5707314 Add track_caller attribute to Result::unwrap_or_else 9a63448b2f2 Rollup merge of #116295 - asquared31415:mem_drop_docs, r=WaffleLapkin 1d185d9359a Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum f62a3d058d6 Auto merge of #116157 - the8472:doc-monotonoic-suspend, r=Mark-Simulacrum 77325ebbf3e mem::drop docs f85e54e9f9d Add missing #[inline] on AsFd impl for sys::unix::fs::File 4a5f62dc47d Fix broken links f2a6ceb20ce Auto merge of #115546 - SUPERCILEX:patch-2, r=Amanieu 7d9ae97f752 Rollup merge of #116241 - dtolnay:exclusivefwd, r=Amanieu 13886446539 Auto merge of #113797 - RalfJung:offset_from_docs, r=workingjubilee 71c8fb786a0 Auto merge of #116176 - FedericoStra:isqrt, r=dtolnay dc2cd12378c fix char imports 65c133422a3 add str_from_utf16_endian tracking issue ed02555f304 style nits 697c17b547a Add feature(str_from_utf16_endian) 89e52acbe8e time: use clock_gettime on macos 9c1a02b1685 time: use clock_gettime on macos bcd69f6a365 Const stabilize mem::discriminant c180b7a9dd9 Add Exclusive forwarding impls (FnOnce, FnMut, Generator) 5d77ec1ae19 time: cfg(any(x)) is the same as cfg(x) 59860d40465 isqrt: disable long running tests in Miri b0031f5f567 Auto merge of #116230 - matthiaskrgr:rollup-hi1ciwy, r=matthiaskrgr 3de96bb7224 Stabilize `const_maybe_uninit_assume_init_read` 147c45d61e6 Rollup merge of #116221 - ArchUsr64:patch-1, r=ChrisDenton e2205b2d84a Auto merge of #114882 - ChrisDenton:riddle-me, r=dtolnay f2d2593405f isqrt: `assume` that `isqrt` takes half as many bits 9a8c818b6ef Auto merge of #114428 - ChaiTRex:master, r=dtolnay 25a265152a1 fixup! isqrt: fix stability ba8f0617afd isqrt: cite source and rename variables to match original C code b51bd980476 Auto merge of #98704 - vthib:impl-from-raw-for-childstd-structs, r=dtolnay d3779ca6a0a isqrt: fix stability 41971f92595 fixup! isqrt: initial implementation f4eda8cf6c1 Auto merge of #116222 - matthiaskrgr:rollup-dnag90q, r=matthiaskrgr 90d138df0f7 Rollup merge of #115888 - RalfJung:assert_receiver_is_total_eq, r=dtolnay 018faffa81d Rollup merge of #115535 - tshepang:patch-2, r=dtolnay eaf4019276a Rollup merge of #112959 - tbu-:pr_fmt_error_wording, r=dtolnay 884967e93eb Update stability attribute for child stream From impls ed63883bb77 stabilize `Option::as_`(`mut_`)`slice` a587dcfc50d changed 'rotate' to 'rotating' 6a809ed1d6d Auto merge of #114041 - nvzqz:nvzqz/shared_from_array, r=dtolnay dd034969363 Fix "unresolved link to std::fmt::Error" d4c4f4a1d9a Auto merge of #111278 - EFanZh:implement-from-array-refs-for-vec, r=dtolnay 1db0e0ec936 take more clarifying text from Gankra's PR 852b59a7335 isqrt: add more tests f9552008a4b isqrt: remove duplication by delegating to unsigned integers 6c71d170abc std: broaden the allowed behaviour for recursive TLS initialization 1baf67d6d62 Auto merge of #116125 - RalfJung:const-param-ty-eq, r=compiler-errors 63c765aa0a3 Auto merge of #116124 - WaffleLapkin:fix-proc-macro-literal-to-string, r=compiler-errors 18e311672f1 Auto merge of #116070 - eduardosm:IoSlice-advance_slices-checked_add, r=Mark-Simulacrum f268764595a Document that Instant may or may not include system-suspend time 0009a387ee7 update other place f17dd316cfc clarify documentation about variable substituion e30bd6ebc81 Auto merge of #116074 - fzs111:clarify-pin-docs, r=Mark-Simulacrum a8c7157ef63 Auto merge of #116057 - RalfJung:io-safety, r=Mark-Simulacrum f6b2be51017 ConstParamTy: require Eq 0b036974fcf Fix `.to_string()` of `proc_macro::Literal` (properly print cstr literals) 763cfef15c6 Auto merge of #105861 - Ayush1325:uefi-std-minimial, r=workingjubilee be8f319ebf0 Auto merge of #116075 - Colonial-Dev:issue-116063-fix, r=Mark-Simulacrum 3923b007e2f Auto merge of #115416 - c410-f3r:match_cfg, r=Amanieu 80b772c05ea Auto merge of #104385 - BlackHoleFox:apple-minimum-bumps, r=petrochenkov 3a283e4944f Raise minimum supported iOS version to 10.0 ec7e1604395 Raise minimum supported macOS to 10.12 a72ce78982b implement Literal::byte_character 839ffb97533 Add the `cfg_match!` macro 58c5277fac8 Clarify example in `Pin::new_unchecked` docs cb3fc375530 Avoid overflow in `IoSlice::advance_slices` 9b53c42c902 Extend fix to wrapping_div, wrapping_div_euclid and wrapping_rem_euclid 1f364c27bbf Resolve rust-lang/rust#116063 1ca9b41224e Fixes from PR 3dd0258e819 isqrt: add tests 8cbdb9fef70 isqrt: initial implementation 512207833d0 checked_ilog: remove duplication by delegating to unsigned integers 240c8cdf6d0 checked_ilog: add benchmarks 119681f2b51 checked_ilog: add comments explaining the correctness of the 128 bit optimization 2ff57e8403b checked_ilog: set `n` and `r` directly avoiding arithmetic operations daacfc26383 checked_ilog: improve performance fd390b11484 Rebase to master 92d53a20f52 Use RawOsError for UEFI 8d4c97ebaae Fixes from PR 48a9985414b Add support for building `std::os::uefi` docs 8602671501e Handle ExitBootServices 8a95f0949dc Fixes from PR 8226547fd92 Add Minimal Std implementation for UEFI f57a2220019 fix OS-specific I/O safety docs since the io_safety feature is stable 596f278a3b2 Auto merge of #116054 - matthiaskrgr:rollup-3pusno6, r=matthiaskrgr 4a836cdc127 Rollup merge of #116038 - the8472:panic-on-sched_getaffinity-bug, r=cuviper 92813264897 Rollup merge of #114379 - RalfJung:command-removed-env-vars, r=m-ou-se 9d5224f57b5 Auto merge of #114780 - RalfJung:io-safety, r=Amanieu 299aae79c53 Auto merge of #114776 - fee1-dead-contrib:enable-effects-in-libcore, r=oli-obk 3538ad50644 Auto merge of #115230 - Vtewari2311:mod-hurd-latest, r=b-naber 745b61ef71d Fall back to _SC_NPROCESSORS_ONLN if sched_getaffinity returns an empty mask 2b200b8861a added support for GNU/Hurd e80f1b42e0a Rollup merge of #116007 - m-ou-se:const-panic-fmt-panic-display, r=oli-obk 8df5201bd09 avoid talking about inverses 623734fea8e consistent wording ddfb69b0b6f documentation tweaks 5de1eab38bf offset_from: docs improvements e1acc6c8e09 Auto merge of #116013 - matthiaskrgr:rollup-mv5i4fd, r=matthiaskrgr 4138a88103a Rollup merge of #116008 - m-ou-se:boxmeup, r=oli-obk a9d049e0f1f Auto merge of #115542 - saethlin:fileencoder-is-bufwriter, r=WaffleLapkin 3bd032ea7ee PR feedback e55b7589a1d Fix typo. 3c486eea395 Rename BoxMeUp to PanicPayload. c3d30211400 Call panic_display directly in const_panic_fmt. ad5ec48a953 Auto merge of #115753 - tgross35:threadinfo-refactor, r=thomcc f4b7471b480 fix rustdoc tests 2e3149dde6f Enable effects for libcore 05cfa474d16 Auto merge of #114443 - tgross35:cstr-len, r=dtolnay 12c4bca16e7 Auto merge of #115979 - GuillaumeGomez:rollup-06ujzgh, r=GuillaumeGomez 358320be8a8 Rollup merge of #115958 - RalfJung:mystery-plus, r=Mark-Simulacrum,notriddle 36fcaba4712 explain mysterious addition in float minimum/maximum 42858855d6a Auto merge of #115627 - compiler-errors:icedump-no-std, r=m-ou-se 6ab3241a15e Replace 'mutex' with 'lock' in RwLock documentation 0c1379e5284 Rollup merge of #115946 - the8472:panic-on-sched_getaffinity-bug, r=Mark-Simulacrum c19dbe8de88 Rollup merge of #115839 - Dirreke:bump-libc, r=dtolnay 9fd391f80a8 Auto merge of #104101 - betrusted-io:xous-libstd-initial, r=bjorn3 b0388bc13ca Stabilize `{IpAddr, Ipv6Addr}::to_canonical` dce8acd3280 panic when encountering an illegal cpumask 746ca488b73 Rollup merge of #115494 - RalfJung:primitive_docs, r=Mark-Simulacrum e70fc63f172 Rollup merge of #109409 - WaffleLapkin:progamer, r=dtolnay 5e52530715b Fill-in tracking issue for `feature(cmp_minmax)` 8aa674f506b Add `minmax*` functions to `core::cmp` d6fc59b9333 get rid of duplicate primitive_docs 9c8c930dcd5 Auto merge of #108043 - a1phyr:string_write_fmt, r=workingjubilee d5d2d6cbd97 Auto merge of #115547 - WaffleLapkin:spin_looping, r=Mark-Simulacrum 55e88bacd53 Specialize `fmt::Write::write_fmt` for `Sized` types af97478ebb7 Rollup merge of #115477 - kellerkindt:stabilized_int_impl, r=dtolnay ad04e303c73 Rollup merge of #115434 - soqb:ascii-char-manual-debug, r=dtolnay a2eaac67b84 Rollup merge of #114965 - benschulz:mpsc-drop, r=dtolnay 5d1cda1b1a7 Auto merge of #113748 - clarfonthey:ip-step, r=dtolnay 4ee84253df6 Auto merge of #115782 - a1phyr:improve_pad_adapter, r=dtolnay 6c71b86b437 Auto merge of #113753 - dvdsk:master, r=dtolnay 8e8d8e4eb70 Rollup merge of #115895 - 52:patch-docs-vec-truncate, r=dtolnay dbccea011f5 Rollup merge of #115560 - ShE3py:format-results, r=dtolnay c7b06db94b4 Rollup merge of #115487 - ModProg:patch-1, r=dtolnay 8691b865165 Rollup merge of #115329 - xzmeng:fix-std-doc, r=dtolnay be4e76a9ec4 Rollup merge of #115247 - the8472:life-before-main, r=dtolnay 94bfd09e009 Auto merge of #112229 - clarfonthey:range-iter-count, r=dtolnay fed17201ec2 edit `std::collections::VecDeque` docs a4634279781 edit `std::vec::Vec::truncate` docs 36e89c79625 Rollup merge of #115607 - RalfJung:safe-traits-unsafe-code, r=dtolnay 76703fbb90f fix a comment about assert_receiver_is_total_eq 7018714bffd Specialize count for range iterators d2e9ff70505 impl Step for IP addresses 17192b9d2b4 Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726 86b4bd92add Auto merge of #115520 - Finomnis:const_transmute_copy, r=dtolnay 5a9c7d5cf60 Bump libc to 0.2.148 7b0b3a26d7c Auto merge of #114656 - bossmc:rework-no-coverage-attr, r=oli-obk 0e049f650ff Disabled socketpair for Vita 4c1d91dd01a Improve `PadAdapter::write_char` 57f10f94845 Refactor `thread_info` to remove the `RefCell` b4d3044f10e Auto merge of #114967 - japaric:ja-gh114966, r=Mark-Simulacrum 289087e6aed Auto merge of #114590 - ijackson:stdio-stdio-2, r=dtolnay 7bd59e75b83 std::process (unsupported): Implement From etc. for imp::Stdio 3e39c7a4630 Rollup merge of #115201 - notriddle:notriddle/type-alias-impl-list, r=GuillaumeGomez ae6804ee761 Rollup merge of #104299 - mkrasnitski:discriminant-transmute-docs, r=oli-obk f9b5a76e12d Partially outline code inside the panic! macro 99fc492dbe0 Rename the feature, but not the attribute, to `coverage_attribute` c8a90479b2f Rework no_coverage to coverage(off) cef05024e69 Auto merge of #114299 - clarfonthey:char-min, r=dtolnay,BurntSushi aa877c2b056 Guarantee that Layout::align returns a non-zero power of two edeec5bf9c7 Auto merge of #115617 - coastalwhite:bump-stdarch-riscv-intrinsics, r=Amanieu b6062289d04 Don't modify libstd to dump rustc ICEs 6c107e0e04f Auto merge of #115166 - Urgau:invalid_ref_casting-invalid-unsafecell-usage, r=est31 5fb44750e76 Auto merge of #115580 - eduardosm:stdarch-intrinsics, r=davidtwco,bjorn3 7d6a26998d1 Bump: Include RISC-V intrinsics for stdarch 21d1ca1d87b Fix minor grammar typo 739d12f1e7e fix typo e51f70c7003 clarify that unsafe code must not rely on our safe traits 49e6733d74a Update doc for `alloc::format!` and `core::concat!` 6d3b26d61a7 Auto merge of #115453 - ibraheemdev:patch-16, r=joshtriplett ef2c94f15d5 Rollup merge of #114794 - RalfJung:swap-safety, r=m-ou-se b1311f6e891 Bump stdarch submodule 5e6f5356dcb fix a comment in std::iter::successors a71bed73737 if -> when 50888a7846e Rollup merge of #115540 - cjgillot:custom-debuginfo, r=oli-obk 9bd2b86cd79 Rollup merge of #114813 - RalfJung:fpu-control, r=Amanieu fd2b0a9ef0a Rollup merge of #114412 - RalfJung:libc-symbols, r=pnkfelix 0a8a2418179 Rollup merge of #113510 - ink-feather-org:const_ptr_transmute_docs, r=RalfJung 7f72864f571 Weaken needlessly restrictive orderings on Arc::*_count 9a1d47d0af3 Simplify `core::hint::spin_loop` e81d79baabd "what would rustfmt do" 1ee0e151eec Auto merge of #115493 - Ayush1325:raw-os-error, r=workingjubilee 05c95b05c40 Clarify ManuallyDrop bit validity 037be24eb1e Auto merge of #115491 - Zoxc:refcell-tweak, r=Mark-Simulacrum 70bc0fb0dde Stabilize const_transmute_copy c4aa7e9ae90 Rollup merge of #115512 - Fulgen301:startupinfow, r=ChrisDenton 49c016b6a8a Rollup merge of #115489 - saethlin:is-interrupted, r=thomcc a36a8030e98 Rollup merge of #115279 - schuelermine:patch/doc/RangeFull/remote-parens, r=Mark-Simulacrum 82845a75ae9 unchecked layout calculations when shrinking during in-place collect 0a4f063d89e relax size and alignment requirements for in-place iteration 63204a60080 support in-place collecting additional FlatMap shapes c79ec636b98 update in-place-iteration module docs c4af0b69ccb don't leak items if alloc::shrink panics 1cd3ce37dde Expand in-place iteration specialization to Flatten, FlatMap and ArrayChunks 6b9c9f64043 Command::spawn: Fix STARTUPINFOW.cb being initialized with the address of size_of 6fd6785d600 Use std::io::Error::is_interrupted everywhere 51ce2344856 Merge from rustc 0da244278a6 Move RawOsError defination to sys 0ec22be96fa Outline panicking code for `RefCell::borrow` and `RefCell::borrow_mut` 5eab28e6590 Stabilize the Saturating type (saturating_int_impl, gh-87920) 0bb40735252 Unimpl Shl, ShlAssign, Shr and ShrAssign for Saturating 36358339772 Improve documentation on when signes are printed by default e57be419a12 Auto merge of #115273 - the8472:take-fold, r=cuviper 1d9f92e3dfb Rollup merge of #115449 - scottmcm:stable-const-is-ascii, r=ChrisDenton ce74c932716 Rollup merge of #115443 - epage:os_str, r=cuviper a0a95e907bd Rollup merge of #115427 - solid-rs:patch/kmc-solid/is-interrupted, r=cuviper cb94ade430d Rollup merge of #114845 - scottmcm:npo-align, r=WaffleLapkin d72469ca398 don't panic in BorrowedCursor::write 7c8d318157a Merge from rustc 4b3bd1b0cc4 fix(std): Rename os_str_bytes to encoded_bytes 1a28c3659ac Auto merge of #113295 - clarfonthey:ascii-step, r=cuviper a75df1370b6 stabilize `io_error_other` feature b98ccb6a69c Update mod.rs eb465ea5ea8 Const-stabilize `is_ascii` 5a56d7e2f8f Support bootstrap. a25da5de1f1 Support debuginfo for custom MIR. 835bbb37ba5 feat(std): Stabilize 'os_str_bytes' feature 80d9bb39a74 Auto merge of #114065 - lukas-code:u16_from_char, r=dtolnay 5d5e301e003 fix `Debug` impl for `AsciiChar` 98e8a62bee3 [`clippy`] Use symbols intended for `arithmetic_side_effects` 709372a3bb0 Auto merge of #114448 - SteveLauC:std_fs_read_doc, r=Mark-Simulacrum 70c10efcc8c kmc-solid: Refactor `is_interrupted` to avoid integer overflow 9eb8e49516f docs: improve std::fs::read doc 58c40ebc6b7 kmc-solid: Directly delegate to `net::is_interrupted` in `std::sys::solid::is_interrupted` f85ad457c76 std::thread::set_name exploit the return on haiku c0e705c8e36 further expand on Arc and Box analogy 1067de0dd7a Implement `CStr::count_bytes` 63d7ac875b6 Refactor the const `strlen` implementation to `const_strlen` 23d593b23ed rewording after comments by @thomcc ac98ae84d71 Auto merge of #114795 - RalfJung:cell-swap, r=dtolnay babada7ad42 Auto merge of #113859 - Manishearth:vec-as-mut-ptr-stacked-borrow, r=dtolnay 9176b56970d Auto merge of #115312 - hermitcore:hermit-is_interrupted, r=thomcc 4032924ced6 Auto merge of #115309 - hermitcore:hermit-net-init, r=cuviper f8389726435 fix std::primitive doc: homogenous -> homogeneous 3427e56dfe9 fix a doc typo at std::os::unix::fs::FileExt::write_at 3bbfe80f4a4 Remove old bindings that have been moved 1b9fa893c64 Add GetActiveProcessorCount and process attributes 227659c9521 Abstract over internal `SOCKET` type ff7890a6488 Update windows ffi bindings f8265e786a7 Rollup merge of #115311 - dtolnay:usearcself, r=compiler-errors c7f629f2ee1 Rollup merge of #115310 - RalfJung:panic-and-format, r=scottmcm c66cf78f3e2 reduce indirection in for_each specialization 93f33e9adef Auto merge of #114848 - michaelvanstraten:spawn_with_attributes, r=ChrisDenton 4fa39398f48 fix(sys/hermit): add is_interrupted be169918829 fix(sys/hermit): remove obsolete network initialization 430b4798f6b Revert "Suggest using `Arc` on `!Send`/`!Sync` types" 6be47d1c2e4 Revert "Make `rustc_on_unimplemented` std-agnostic for `alloc::rc`" 6a1680d62ac improve panic.md edition disucssion, and nits c1e332e1f0f format, format_args: Make xref to std::fmt much more prominent 6960fc4d17e panic macro: Link directly to format syntax, not to format! edf547f27fd print macros: add xrefs to format syntax documentation 1a26d9edaf5 panic macro: Document edition differences c343fde42da Auto merge of #103836 - H4x5:extra-float-constants, r=thomcc 802547b944d Rollup merge of #115280 - RalfJung:panic-cleanup-triple-backtrace, r=Amanieu 3ddf80cfa13 Rollup merge of #114512 - devnexen:fix_tests_fbsd, r=thomcc 5ab3c707273 Rollup merge of #114238 - jhpratt:fix-duration-div, r=thomcc 6d21aa068a9 Rollup merge of #109660 - ijackson:leap, r=thomcc 62af598aec7 Auto merge of #115254 - cuviper:aligned_alloc-size, r=thomcc 42779ed909e avoid triple-backtrace due to panic-during-cleanup b5b4428e574 Remove parens around .. in documentation snippet 25e6017225f Optimize Take::{fold, for_each} when wrapping TrustedRandomAccess iterators 3621f7bcea1 Auto merge of #115263 - matthiaskrgr:rollup-taqu2h0, r=matthiaskrgr aee947fe458 Rollup merge of #115007 - kpreid:alloc, r=Mark-Simulacrum b883c5fd5a4 Auto merge of #114969 - kpreid:dropdoc, r=Mark-Simulacrum 7f29fab9fd5 wasi: round up the size for `aligned_alloc` 09be3dc6ff7 Document std limitations before/after main 4ff6251cabe Rollup merge of #115210 - DogPawHat:std-agnostic-rustc_on_unimplemented-for-alloc-rc, r=WaffleLapkin d8b9a44d680 Rollup merge of #115197 - tbu-:pr_simpler_ipv6_addr_display, r=joshtriplett d5f1459838c Auto merge of #115228 - saethlin:is-interrupted, r=thomcc f6c779fc2dd Add a new helper to avoid calling io::Error::kind 3ff2e05c13a Make `rustc_on_unimplemented` std-agnostic for `alloc::rc` 4aebc48ee4d Auto merge of #115133 - coderwithcat:master, r=cuviper 8244f748d5d Added option to set ProcThreadAttributes for Windows processes 9291915e084 Auto merge of #115045 - RalfJung:unwind-terminate-reason, r=davidtwco 47405cd3737 use the correct link 76a48d5c112 Rollup merge of #114754 - workingjubilee:gamma-ray-logger, r=thomcc aee0ff39f7e Fix intra-doc links from pointer appearing in windows HANDLE type alias 610b224e6f2 Remove special cases that are no longer needed due to #112606 1cfe8712a2a Rollup merge of #115124 - solid-rs:patch/kmc-solid/import-poison-error-in-os, r=cuviper d1f6892f3a7 Lint on invalid UnsafeCell::raw_get with invalid_reference_casting lint fc44de2a8e4 document more things as needing to stay in sync 74a1f253d45 when terminating during unwinding, show the reason why ce6545914d0 Auto merge of #115094 - Mark-Simulacrum:bootstrap-update, r=ozkanonur baa31c01d0d also use 'env' for printing unsetting 8470530c95b also print clearing the environment entirely c45c144254a fix a typo in env_clear docs 58190321298 make unsetting env vars print as executable command 15778f932b0 Command: also print removed env vars 4e3a497b053 Bump cfg(bootstrap) 7353e846258 Auto merge of #115112 - tmandry:backtrace-0369, r=compiler-errors 3770ddb0aa7 Rollup merge of #114696 - g0djan:godjan/fix_114610, r=Mark-Simulacrum e4c2323acd6 Rollup merge of #115100 - Urgau:invalid_ref_casting-ptr-writes, r=est31 eb3b48d1041 Rollup merge of #115053 - waywardmonkeys:augment-type-keyword-docs, r=cuviper df1a0728f77 kmc-solid: Import `std::sync::PoisonError` in `std::sys::solid::os` 46aa3b530fe Bump backtrace to 0.3.69 c0ca498b5b1 std: unix process_unsupported: Provide a wait status emulation (tidy) b816c372398 fixup! std: unix process: Test exit statuses / wait statuses 1d085fcfa99 std: unix process_unsupported: Provide a wait status emulation (fmt) fffc78293d9 fixup! std: unix process_unsupported: Provide a wait status emulation 67b8a8d401a std: unix process: Test exit statuses / wait statuses b9a42d4c7a2 std: unix process_unsupported: Provide a wait status emulation e0abc3dd2ee Improve UdpSocket documentation 26a167a8bf3 Add support for ptr::write for the invalid_reference_casting lint d215c6cd37a std: enable feature(slice_ptr_len) on xous 4fc7f646bd8 std: xous: add support for locks b4d117f9aff std: xous: add thread_local_key 0dca5b1ff3f std: xous: add thread support 8aa146d8057 std: xous: add support for time d22d2d4b89d std: xous: add output support for stdio be58df40dfc std: xous: add services support be02136f4b8 panic_abort: call __rust_abort on xous 6ccf2b69fae std: xous: add alloc support 8abfe386066 std: process: skip tests on xous 5e64015f280 std: fs: skip fs tests on xous 0ae73f51702 std: net: skip tests on xous 3004176e187 std: xous: the basics of `os` 605bf2bd3ab std: xous: add os-specific ffi calls cf57e500fca Replace version placeholders with 1.73.0 321701dd649 clarify what you cannot do e9b150e8e48 typos and wording b8a7bceda9e libstd: add xous to libstd 583ec0d4059 Auto merge of #113365 - dima74:diralik/add-deprecated-suggestions, r=workingjubilee e3e8b25fe8e docs: add alias log1p to ln_1p e25cca0093e docs: Add example, reference link for `type` keyword. 8fa3b2f455d try to clarify wording 4999a002b3e Add `suggestion` for some `#[deprecated]` items 10c65efe92e Add data race test to `std::env::{get, set}` 3be9af1c907 Rollup merge of #115000 - RalfJung:custom-mir-call, r=compiler-errors,JakobDegen 0d398fef19f Rollup merge of #114968 - ShE3py:unix-getsetenv-ub, r=thomcc 7030d421789 Auto merge of #113167 - ChAoSUnItY:redundant_explicit_link, r=GuillaumeGomez 9679aabf8c2 Rollup merge of #114983 - crlf0710:formatmsg, r=ChrisDenton a330984d8ab Rollup merge of #114973 - shepmaster:std-provide-value, r=Amanieu 84207c50027 Rollup merge of #114950 - xfix:inline-cstr-from-ptr, r=cuviper 20b6235a2f1 Rollup merge of #114605 - Easyoakland:hash-collection-doc, r=thomcc b6e228ce17c custom_mir: change Call() terminator syntax to something more readable 18cd85283f5 Correct and expand documentation of `handle_alloc_error` and `set_alloc_error_hook`. cc6d3d8e11e Usage zero as language id for FormatMessageW() 2420cf84b19 Rollup merge of #114977 - kpreid:modulo, r=thomcc 945db63bb27 Rollup merge of #114971 - kpreid:trig, r=joshtriplett 47d051e2be6 Add `modulo` and `mod` as doc aliases for `rem_euclid`. 716d99cefab Auto merge of #114591 - joboet:thread_parking_ordering_fix, r=thomcc 8aa986f1e1c Expose core::error::request_value in std 36e4dbb0baf Add doc aliases for trigonometry and other f32,f64 methods. d414b2b2915 Go into more detail about panicking in drop. 8035b41ded3 Fix UB in `std::sys::os::getenv()` b250f13d6e7 QNX: pass a truncated thread name to the OS e085cbd2193 Remove Drop impl of mpsc Receiver and (Sync)Sender 1595d607951 resolve conflicts 7b40136cf62 relax redundancy constraint 6cfde051149 resolve conflicts d2bbea67af4 resolve conflicts df35ed8957a tidy doc link a65e9a25660 lint links 40df111aed5 Inline strlen_rt in CStr::from_ptr c0e1ad8ac13 Rollup merge of #114897 - joshtriplett:partial-revert-ok-0, r=m-ou-se 16e68a8e470 Auto merge of #114799 - RalfJung:less-transmute, r=m-ou-se 580cfec9eea Rollup merge of #114881 - RalfJung:cstr, r=cuviper 210696ac279 Rollup merge of #114749 - gurry:issue-114722, r=thomcc 595e99a7000 Update library/alloc/src/vec/mod.rs d2576f24eaa Auto merge of #114905 - matthiaskrgr:rollup-uxhhr7p, r=matthiaskrgr 25156b3eddd Update library/alloc/src/vec/mod.rs 519694a2621 Rollup merge of #114784 - Urgau:many-improve-invalid_reference_casting-lint, r=est31 c12f964371d Auto merge of #114617 - petrochenkov:docspacing, r=Mark-Simulacrum e8550b8875c Partially revert #107200 fd5e9680b57 proc_macro: Update docs for `Spacing` 5b99d58bdd5 address comments 8a4e3e4a473 Fix a pthread_t handle leak #114610 b415790c0cc clarify CStr lack of layout guarnatees c91d5194f27 use mem::swap instead of ptr::swap_nonoverlapping 2bbf4025999 Rollup merge of #114871 - schvv31n:fix-link-in-docs, r=scottmcm 5f5c450c6ac Rollup merge of #114867 - ttsugriy:ttsugriy-patch-1, r=scottmcm f5a1ee99f61 Rollup merge of #114861 - RalfJung:no-effect, r=wesleywiser 2ee3e1fb375 Rollup merge of #114721 - danflapjax:bool-ord-optimization, r=cuviper cacb05059ec Auto merge of #114689 - m-ou-se:stabilize-thread-local-cell-methods, r=thomcc 170a21944ce Auto merge of #111071 - nyurik:simpler-issue-94005, r=m-ou-se 08d8b078a38 other elements 10e9815be69 Update the link in the docs of `std::intrinsics` 043e113a2aa Cleaner assert_eq! & assert_ne! panic messages f3ab908fd97 [nit] Fix a comment typo. 1e8a976ea26 Rollup merge of #114837 - RalfJung:error_in_core, r=cuviper 973b62ebbe1 Rollup merge of #114619 - g0djan:godjan/fix_#114608, r=m-ou-se 51fd8628cde Rollup merge of #114588 - ijackson:exit-status-default-2, r=m-ou-se 86f4f4c2c3d fix typo: affect -> effect 7844e8155ff Auto merge of #114852 - GuillaumeGomez:rollup-vjagxjr, r=GuillaumeGomez 116bbb6c7c4 Update library/alloc/src/vec/mod.rs 90799e71f7f Update library/alloc/src/vec/mod.rs eef0bb12092 Document Default for ExitStatus 92b0e9f9dd8 Auto merge of #112387 - clarfonthey:non-panicking-ceil-char-boundary, r=m-ou-se 53905c6dac3 Fix typo. 65fcd213b08 Rollup merge of #114800 - RalfJung:transparent, r=cuviper 772e4378dd7 clarify that these assumtpions are for us, not all Rust code 9ad3bcea848 Add alignment to the NPO guarantee 35a34782c29 Add diagnostic items for `<*const _>::cast` and `<*mut _>::cast_const` 955caa175ca add missing feature(error_in_core) e71afbe07e1 Auto merge of #113658 - Dirreke:csky-unknown-linux-gunabiv2, r=bjorn3 9d54f07db91 actually this doesn't even affect doctests. nice. d3eaa392655 Auto merge of #113464 - waynr:remove-provider-trait, r=Amanieu 8f87d9cccf2 Upgrade Object and related deps 39e86573a93 add a csky-unknown-linux-gnuabiv2 target aae5a4642db reference-counting analogy 28341cf2925 explain why we can mutate the FPU control word 4ae3d799bcb reword the paragraph on file description ownership 2a7c453df3f don't link to RFCs, they are not up-to-date docs 7992f8db4ef std: add some missing repr(transparent) b450ca8c4b3 avoid transmuting Box when we can just cast raw pointers instead e410e432b47 simplify is_nonoverlapping a bit bc8c2ddfbc6 make Cell::swap panic if the Cells partially overlap e0ee6d59a23 clarify safety documentation of ptr::swap and ptr::copy ddd179d2118 mention /proc/self/fd with /proc/self/mem fddbdd51cd6 wording; and explain some of the possible consequences of violating io-safety c764c3b1fff typos b25161eb530 sync the various FromRawFd trait docs, and remove 'valid' a921d861b4b Implement Step for AsciiChar ab338082c0f core/any: remove Provider trait edb9fd90222 Rollup merge of #114069 - cuviper:profiler-path, r=Mark-Simulacrum e3938db92c9 Rollup merge of #94667 - frank-king:feature/iter_map_windows, r=Mark-Simulacrum f977b41f558 add more explicit I/O safety documentation f6fd471d4d6 aliasing guarantee 31197a25fca Rollup merge of #114132 - tamird:better-env-debug-impls, r=Amanieu a6c9e81685d Name what ln_gamma does 57f839c3602 Remove unnecessary feature gates 8ee3d703349 Partially stabilize #![feature(int_roundings)] a7addaffb11 Update Sender documentation for Sync cd6fcf49e66 Auto merge of #114720 - scottmcm:better-sub, r=workingjubilee e97bb2f624b Auto merge of #113432 - klensy:ms-cut-backtrace, r=ChrisDenton b4583fe2568 Tell LLVM that the negation in `<*const T>::sub` cannot overflow 7747d78a8e5 Optimized implementations of max, min, and clamp for bool f158c63961a Rollup merge of #114402 - tifv:tifv-fix-rc-doc, r=cuviper ba2ee910fdf Rollup merge of #114359 - ttsugriy:barrier-simpl, r=cuviper eda564d4529 Rollup merge of #114257 - rytheo:linked-list-avoid-unique, r=cuviper dc931591b32 Rollup merge of #114194 - thomcc:flushinline, r=cuviper 882c191f643 Add Iterator::map_windows e2462d48d50 Stabilize thread local cell methods. aaa8f568641 Rollup merge of #114377 - Enselic:test_get_dbpath_for_term-utf-8, r=thomcc c6564fe0f61 Suggest using `Arc` on `!Send`/`!Sync` types d333a6a2f1a Auto merge of #114646 - matthiaskrgr:rollup-xf7qnmn, r=matthiaskrgr cd69b2428f4 Rollup merge of #114641 - kupiakos:ascii-char-to-not-as, r=scottmcm ba6af597d81 Rollup merge of #113939 - the8472:pidfd-from-child, r=Mark-Simulacrum efbd22d9c15 Auto merge of #99747 - ankane:float_gamma, r=workingjubilee afbb811c184 Rename copying `ascii::Char` methods from `as_` to `to_` 7bc0cda3919 open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSG 75dd3288161 Rollup merge of #106425 - ijackson:exit-status-default, r=dtolnay 1e638d16375 Fix #114608 fda30c6ab00 Increase clarity about Hash - Eq consistency in HashMap and HashSet docs 1f2bf90437e Bump compiler_builtins to 0.1.100 3cd88ce0d2a core: Remove #[macro_export] from `debug_assert_matches` 1eba227be4b std: synchronize with all calls to `unpark` in id-based thread parker f6c39b09a61 Better Debug for Vars and VarsOs 6c1c42601c9 impl Default for ExitCode 63937397ab6 Rollup merge of #114562 - Trolldemorted:thiscall, r=oli-obk 524dccf82ff Adjust the duration_since(UNIX_EPOCH) docs 5f6414b8e2a impl Default for ExitStatus 30c46f2c4d1 std::process: impl From (etc.) for Stdio f846b8481a4 std::process (windows): Implement From etc. for imp::Stdio aab4f73194e std::process (windows): refactor Stdio::to_handle slightly 5d1c459f6aa std::process (unix): Implement From etc. for imp::Stdio c5429d38f61 stabilize abi_thiscall bc455cef313 Rollup merge of #114382 - scottmcm:compare-bytes-intrinsic, r=cjgillot fda36f46e5e Rollup merge of #114365 - tshepang:patch-6, r=Mark-Simulacrum ff2b327a558 Rollup merge of #114362 - tshepang:patch-1, r=Mark-Simulacrum 88dac1b1096 Rollup merge of #98935 - kellerkindt:option_retain, r=Mark-Simulacrum 30c71de6a6f Add a new `compare_bytes` intrinsic instead of calling `memcmp` directly 3194be1ec73 Rollup merge of #114519 - the8472:dirent-offset-of, r=dtolnay 5e734f8f03c Remove ptr_from_mut diagnostic item decd3b49e4d Add #[rustc_never_returns_null_ptr] to std functions 0ca96b0c79b Auto merge of #111200 - a1phyr:spec_sized_iterators, r=the8472 155104c14c7 use offset_of! to calculate dirent64 field offsets dac56eeb152 Rollup merge of #114029 - Enselic:clone-doc, r=scottmcm 5548796b8e7 std/tests: disable ancillary tests on freebsd since the feature itself is. 9f5de3d26d5 document our assumptions about symbols provided by the libc f18de93edfe Rollup merge of #114373 - xstaticxgpx:dev, r=the8472 1e41314f6fc unix/kernel_copy.rs: copy_file_range_candidate allows empty output files db7a0ad556b Auto merge of #108955 - Nilstrieb:dont-use-me-pls, r=oli-obk 40b2f3e047c Convert `Into for ExitStatusError` to `From for ExitStatus` in `std::process` df710e31853 Rollup merge of #113657 - Urgau:expand-incorrect_fn_null_check-lint, r=cjgillot 538e941057c Add `internal_features` lint b91f31db0af Add assertion to test `skip_until` return value 4ebdc79068f Fix documentation of Rc as From> 869900b6e4c Implement Option::take_if 16744733268 Auto merge of #113220 - tgross35:cstr-bytes-docs, r=workingjubilee 7f52b469216 test_get_dbpath_for_term(): handle non-utf8 paths 870236f4ebc test_get_dbpath_for_term(): Use assert_eq!() 1470b609442 Document soundness of Integer -> Pointer -> Integer conversions in ` const` contexts. 9ad5b18b820 Auto merge of #112431 - Urgau:cast_ref_to_mut_improvments, r=Nilstrieb 8aa8af79166 str.rs: remove "Basic usage" text c5098885f80 string.rs: remove "Basic usage" text 48c4f4a7446 Clarify documentation for `CStr` 053cca5a0e7 [library/std] Replace condv while loop with `cvar.wait_while`. cbe79a8570d Auto merge of #112922 - g0djan:godjan/wasi-threads, r=wesleywiser 6e92e8c2959 Add diagnostic items for `<*const _>::cast` and `ptr::from_mut` 95e31900ce4 Auto merge of #114331 - matthiaskrgr:rollup-rnrmwcx, r=matthiaskrgr 0085271c30a Rollup merge of #100455 - xfix:backtrace-ref-unwind-safe, r=dtolnay bb9f1dbed86 Auto merge of #112849 - m-ou-se:panic-message-format, r=thomcc f91ebbf083a Aborting when `before_wait` function panics bec772651ff Rollup merge of #111081 - mattfbacon:master, r=workingjubilee 748ca1a3794 Auto merge of #114308 - matthiaskrgr:rollup-m64bkm7, r=matthiaskrgr 2aa5dd6f5d3 Rollup merge of #113701 - aswild:std-ffi-frombytesuntilnul, r=dtolnay fcc5b6fc36d Rollup merge of #109318 - joboet:better_fmt_placeholder, r=dtolnay 10c338ef0e0 Rollup merge of #114111 - allaboutevemirolive:add-test-case-string, r=Mark-Simulacrum 9d6319cb36b Rollup merge of #113717 - cuishuang:master, r=Nilstrieb 2d8f1ce1ecd Rollup merge of #112858 - chriswailes:riscv64-android, r=Mark-Simulacrum 8828322c90b I'm mathematically challenged f23f73a5143 Work around missing <*str>::len ef85210ef4a impl SliceIndex for (Bound, Bound) 7e3a8bcc038 Can't compare usize and u32 765504267e7 Use u32::from for MIN/MAX examples a7a60a96291 Add note on gap for MIN/MAX 05914a35b19 Add char::MIN 60a8ba1b279 Add gamma and ln_gamma functions to f32 and f64 e8b50ffedee Clean up SGX user memory copies 242b335eed0 `waitqueue` clarifications for SGX platform 780b59291a0 Implement UnwindSafe and RefUnwindSafe for Backtrace 67ed2da9f05 remove repetitive words 34cff7c9e07 Rollup merge of #114268 - SUPERCILEX:empty, r=workingjubilee 18635ce99e2 Rollup merge of #109075 - joboet:lazylock_backtrace, r=workingjubilee b6c7cc2a33b Rollup merge of #95965 - CAD97:const-weak-new, r=workingjubilee ca39ed7ffe9 Stabilize const-weak-new 6c06c7cbd5e Auto merge of #112843 - chenyukang:yukang-more-on-backtrace, r=workingjubilee 7571e65a54c Fix empty_write since rust version attribute d170682f685 Rollup merge of #102198 - lukas-code:nonnull_as_ref, r=Amanieu 80c413b925e Rollup merge of #98154 - vidhanio:master, r=workingjubilee 6f596b3229c Explain more clearly why `fn() -> T` can't be `#[derive(Clone)]` 995e7a62d91 Avoid using ptr::Unique in LinkedList code 0db350fc0cd Rollup merge of #114223 - ryanoneill:vec-indexing-doc-language, r=workingjubilee f86675ee358 Rollup merge of #112655 - WaffleLapkin:must_use_map_or, r=workingjubilee 69fd36b0af6 Rollup merge of #110056 - chenyukang:yukang/fix-110045, r=workingjubilee 05acd9c20cc Mark `map_or` as `#[must_use]` b53ffa621c7 rand use getrandom for freebsd (available since 12.x) ccfe5720da7 Fix the example in document for WaitTimeoutResult::timed_out 4c20edf01e1 Fix implementation of `Duration::checked_div` 549b42bf368 Auto merge of #114236 - fee1-dead-contrib:rollup-m92j7q1, r=fee1-dead a5992818566 Rollup merge of #113512 - vallentin:lines-doc, r=workingjubilee 2f37abf958b Rollup merge of #112151 - chloekek:patch-1, r=workingjubilee 5a38ae8cfff Auto merge of #112280 - zica87:master, r=workingjubilee 30b1a4a7d9b Documentation: Fix Stilted Language in Vec->Indexing 2ec33594f36 Add wasm32-wasi-threads target + WASI threads 138f99c9e5a print omitted frames count for short backtrace mode 3321fae777b Adjust some tests for invalid_reference_casting improvements 2371ffb02d1 Change default panic handler message format. d8c738ab217 Auto merge of #113099 - bvanjoi:fix-112713-2, r=petrochenkov 3a4612d0498 Auto merge of #114197 - matthiaskrgr:rollup-iluf7u4, r=matthiaskrgr d6fc49c98d1 Rollup merge of #114174 - tshepang:patch-6, r=workingjubilee b8c2715c99b Rollup merge of #114173 - tshepang:patch-1, r=workingjubilee e3a782f15ad Rollup merge of #114172 - fortanix:raoul/fix_process-spawning_test, r=workingjubilee c5fd5841789 Rollup merge of #114171 - fortanix:raoul/fix_switch-stdout_test, r=workingjubilee 84f9a8f2071 Auto merge of #111916 - fee1-dead-contrib:noop-method-call-warn, r=compiler-errors d6fe7b1bfd1 inline trivial (noop) flush calls a3b2dcb7d8e Rollup merge of #114128 - estebank:delayed-span-bug-dump, r=davidtwco d5d4b979fe0 library: allow `ambiguous_glob_reexports` for `core_arch` d8bfda696b8 Fix issue_15149 test for the SGX target 16e559932b6 doc: replace wrong punctuation mark 366ac1a4323 btree/map.rs: remove "Basic usage" text 2a79f38a898 Fix switch-stdout test for none unix/windows platforms 70ee63c807e reduce deps for windows-msvc targets for backtrace 6a9f97ae06d Auto merge of #112390 - MoskalykA:move-two-tests-from-library-to-tests, r=workingjubilee 6efeaf54d32 add LinkedList::{retain,retain_mut} 22bd1529863 Override `Waker::clone_from` to avoid cloning `Waker`s unnecessarily c5d735cae95 When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist ad17ea7550d Rollup merge of #114109 - veera-sivarajan:fix-str-docs, r=GuillaumeGomez 4ed07755edf Rollup merge of #114091 - waywardmonkeys:doc-fmt-finish-comments, r=GuillaumeGomez 3a51d926bdc Auto merge of #114034 - Amanieu:riscv-atomicbool, r=thomcc fac9b87d436 Fix URL for `rmatches` 821d6997c41 Improve test case for experimental API remove_matches in library/alloc/tests/string.rs 6e107e54815 Add tests and comments about `read_to_string` and `read_line` specializations 790c62fc1d7 `io::Chain`: specialize some `BufRead` methods 37463a3c11b `io::Chain`: specialize some `Read` methods 91cf6d52cd9 Rollup merge of #101994 - devnexen:rand_fbsd_update, r=workingjubilee 517bb4106c4 Add definitions for riscv64_linux_android target 105982f98bd Have a better file name than just the issue id ad0765bf972 docs: fmt::Debug*: Fix comments for finish method. cfdd3d069e6 std: add auto traits to TAIT bound a11dd165eef Auto merge of #102757 - pcc:android-std-tests, r=workingjubilee 0a33f7c3a63 Auto merge of #113928 - nicholasbishop:bishop-update-cb-4, r=workingjubilee ba580377767 Optimize `AtomicBool` for target that don't support byte-sized atomics 8cfc659dad8 Allow using external builds of the compiler-rt profile lib dce5f5649c8 Add note that Vec::as_mut_ptr() does not materialize a reference to the internal buffer a4875ff8eca `impl TryFrom for u16` 480f839a1db Rollup merge of #114043 - cathaysia:doc_lazy_lock, r=thomcc 127f4eb760d Auto merge of #112646 - vn971:document-thread-names-for-sgx-target, r=m-ou-se e32774d60b9 Auto merge of #114020 - steffahn:hide-specialized-ToString-impls, r=thomcc 8a924732361 docs(LazyLock): add example pass local LazyLock variable to struct 829dd9011d8 Auto merge of #113411 - unikraft:unikraft, r=wesleywiser be1c4c195a2 core library: Disable fpmath tests for i386 ... 8e17dfce821 Implement `From<[T; N]>` for `Rc<[T]>` and `Arc<[T]>` 12379ac8155 Auto merge of #111362 - mj10021:issue-74838-update, r=cuviper 931b31c84e9 remove additional [allow(unused_unsafe)] f173af81fa2 Auto merge of #113687 - saethlin:inline-assertion-helpers, r=cuviper 2b7bbb975b6 delete [allow(...)] from issue #74838 6d727ad39ef `unix::init`: Don't use `signal` on Unikraft. ed0954a1fbf `unix::init`: Handle `ENOSYS` from `poll` on Unikraft. 3f9a9540e9a Hide `ToString` implementations that specialize the default ones eafe6c2c618 Auto merge of #113975 - matthiaskrgr:clippy_07_2023, r=fee1-dead 7f4ef1dd152 fix 7c1a0dbab00 fix couple of clippy findings: f5f545d9eae match on chars instead of &strs for .split() or .strip_prefix() 20d4d86d1bf Add #[inline] to core debug assertion helpers e1736f48bb6 Auto merge of #113746 - clarfonthey:ip_bits, r=thomcc b2d64a7501b Auto merge of #113954 - matthiaskrgr:rollup-e2r9suz, r=matthiaskrgr 4fdd25a4fc2 Rollup merge of #113934 - ajtribick:string-pop-remove-multibyte, r=thomcc dd2257b7d15 Rollup merge of #113898 - ajtribick:encode_utf16_size_hint, r=cuviper c9d9c44b927 Rollup merge of #113876 - darklyspaced:master, r=cuviper 4f19b8cdec7 Rollup merge of #113442 - epage:osstring, r=cuviper 4649e5303f8 Rollup merge of #113252 - tgross35:const-cstr-from-ptr-tracking-issue, r=ChrisDenton 19b3523d350 Rollup merge of #112490 - Alexendoo:c-char-cfg-all, r=cuviper 18d8cba0c9e Auto merge of #113224 - zachs18:vec_extend_remove_allocator_lifetime, r=cuviper ae46f243abd Auto merge of #113033 - JohnTitor:stabilize-unix-chown, r=cuviper 899bffe9914 Auto merge of #112699 - bluebear94:mf/more-is-sorted-tests, r=cuviper af8faad76bd Clarify logic on bytes:code units ratio 31c7536125a Demonstrate multibyte character removal in String::pop and String::remove doctests d80134d0f31 Bump compiler_builtins to 0.1.98 7dd755741e1 Auto merge of #113911 - matthiaskrgr:rollup-wk6cr7v, r=matthiaskrgr ed09f68396c Rollup merge of #113907 - ChrisDenton:tls, r=thomcc 45f2bb14749 Rollup merge of #113810 - glandium:allocator-fn, r=Amanieu ee2c08b9aa3 Auto merge of #113106 - marcospb19:improve-path-with-extension-function, r=thomcc e40f2ebf970 Auto merge of #105571 - kadiwa4:remove_atomic_init_consts, r=Amanieu 78e7bf28692 Minor improvements to Windows TLS dtors 97848d055f3 Fix size_hint for EncodeUtf16 70cea7e9322 Get `!nonnull` metadata consistently in slice iterators, without needing `assume`s c23f240d33b Auto merge of #113861 - ibraheemdev:mpsc-tls-bug, r=Mark-Simulacrum 96c374520ea added a problematic example de8b04dcb88 Rollup merge of #113787 - sanchopanca:process-command-windows-docs, r=ChrisDenton 0594581072a fix docs & example for FileExt::write_at a748655cf6f avoid tls access while iterating through mpsc thread entries aa933e11266 On nightly, dump ICE backtraces to disk 7d5a05296d2 Link methods in From impls c41ff74ba49 std::error::Error -> Trait Implementations: lifetimes consistency improvement 7212eed0ad7 support for mips32r6 as a target_arch value 3ca21bbee57 support for mips64r6 as a target_arch value 5e070c351dd Update documentation for std::process::Command's new method a2a7ae5d723 remove the unstable `core::sync::atomic::ATOMIC_*_INIT` constants bbd9a8d8dba Make {Rc,Arc}::allocator associated functions afff115b9cf Auto merge of #89132 - Cyborus04:rc_allocator_support, r=Amanieu 025b737b116 Rollup merge of #113762 - alexpovel:master, r=Nilstrieb 6103555a9d3 Rollup merge of #113750 - nipzu:italicize-sort-complexity, r=workingjubilee 89312b5eafb adds crate attribute to examples so they compile 4e42eaa8d45 Fix typo 459cc8aade7 Implement `From<{&,&mut} [T; N]>` for `Vec` e7926dca186 fix examples add tracking issue ad714f0aaac fixes sleep_until examples 35f005a4be9 Fix sort_unstable_by_key italicization 381df480ac9 Add BITS, from_bits, to_bits to IP addresses 05e633e3daf collect.rs: remove "Basic usage" text where not useful dc868804884 Adds thread::sleep_until, tracking issue TODO d0da464d05c Rollup merge of #113662 - pedroclobo:vec-deque-rotate, r=thomcc 0768f302e22 std: add tests for `Path::with_extension` ca8d7541f1f Re-export core::ffi::FromBytesUntilNulError in std::ffi b3656569c91 Auto merge of #113113 - Amanieu:box-vec-zst, r=Mark-Simulacrum 40d8532bd60 Rollup merge of #113618 - tshepang:patch-1, r=jyn514 75b1e0b6da2 Rollup merge of #112525 - hermitcore:devel, r=m-ou-se 565598fc004 Fix VecDeque's rotate_left and rotate_right panic tests 3e67e9e2cb4 Rename VecDeque's rotate_left and rotate_right parameters 52ac54cd235 Eliminate ZST allocations in `Box` and `Vec` 271729226d8 Re-format let-else per rustfmt update 6354e174d02 Flip cfg's for bootstrap bump a06c2850439 Replace version placeholder to 1.72 41210764b32 avoid ambiguous word bc9c64a5f8c use latest version of hermit-abi 519907723f7 fix usage of Timespec om the target hermit ba31040e27c define hermit_abi as public depedenceny 076872a62ae add support of available_parallelism for target hermit ab61d0569bb update ancient note 08a5855b2c6 Auto merge of #103754 - SUPERCILEX:filled-mut, r=m-ou-se 140a2ae9b9c Auto merge of #113175 - bryangarza:safe-transmute-rustc-coinductive, r=compiler-errors d97f0f99ff4 Auto merge of #113130 - chriswailes:android-library-defs, r=Amanieu 9e47feaacbc Auto merge of #111717 - Urgau:uplift_fn_null_check, r=oli-obk 4b42c526fb3 Correct the Android stat struct definitions 31bb1714968 Auto merge of #94748 - tbu-:pr_file_arc, r=Amanieu 1a6a416c27c Auto merge of #108796 - devsnek:personality-pal-exception, r=workingjubilee b75d9f74d9e move personality to sys 71fbf43be6b Auto merge of #108485 - devsnek:float-pat-exception, r=workingjubilee f42ce1db88b move pal cfgs in f32 and f64 to sys 5e8d61df030 Updated lines doc to include trailing carriage return note 542a506ab28 Rollup merge of #113493 - the8472:spec-iocopy-slice, r=Mark-Simulacrum 4db176af966 Rollup merge of #113469 - JohnTitor:rm-default-free-fn, r=Amanieu 39536b02257 additional io::copy specializations ba1734bc994 Rollup merge of #113064 - marcospb19:add-note-in-vec-swap-docs, r=Mark-Simulacrum 9bce354ddde mark as stable 51ce9f1dff5 impl `From<&[T; N]>` for `Cow<[T]>` 18bf3bdff4e Remove `default_free_fn` feature 909d38c0c0c Allow limited access to `OsString` bytes eb340f2ad7c Sync portable-simd to 2023 July 07 ea0f3766cd4 Rollup merge of #113318 - tgross35:113283-allocator-trait-eq, r=m-ou-se 662c1292547 Rollup merge of #112008 - intruder-kat:master, r=Nilstrieb 6eafe889114 Auto merge of #113269 - jyn514:update-compiler-builtins, r=Amanieu a54732abcff Rollup merge of #113334 - fmease:revert-lexing-c-str-lits, r=compiler-errors d44db733828 Auto merge of #113287 - RalfJung:miri-test-libstd, r=JohnTitor 5823d765779 Rollup merge of #113356 - he32:netbsd-riscv64, r=oli-obk f862a1ab592 Update compiler-builtins to 0.1.95 94162c03a9c Add support for NetBSD/riscv64 aka. riscv64gc-unknown-netbsd. 9352154bd4e Revert "use c literals in library" 919efb76606 Revert "fix ptr cast" 8b9167b3244 Auto merge of #112594 - ChrisDenton:process=-kill, r=Amanieu 894d262311c Workaround for old android not having echo 7dd2479bb49 Revert "alloc: Allow comparing `Box`s over different allocators" f69c522b1c0 Test Child::kill behaviour on exited process dc3900e0620 Add diagnostic items for `<*mut _>::is_null` and `<*const _>::is_null` 54f4f9a442f enable test_join test in Miri 271509a8b5c Auto merge of #113271 - matthiaskrgr:rollup-2ik4vaj, r=matthiaskrgr db66070ce49 Update std to backtrace 0.3.68 e7e73cc6310 Rollup merge of #113253 - nurmukhametdaniyar:rc_from_cstr_doc_fix, r=Nilstrieb 1e967e61ab8 downgrade compiler_builtins 2fe654a93df Rollup merge of #113202 - guilliamxavier:patch-1, r=workingjubilee 02d96e3bad5 Rollup merge of #113147 - lizhanhui:fix_vec_from_raw_parts_doc_example, r=Mark-Simulacrum c12cbfa95a4 fixed documentation of from for Rc: Arc -> Rc 920cf16aa5d Update the tracking issue for `const_cstr_from_ptr` 3e1f1ee576c Remove lifetime bound for A for `impl Extend<&'a T> for Vec`. 55c871833ce Auto merge of #111992 - ferrocene:pa-panic-abort-tests-bench, r=m-ou-se 199efbc55b6 Auto merge of #113194 - lu-zero:intrinsics-inline, r=thomcc 6bbf6436ba1 Return `Ok` on kill if process has already exited 52caed2e167 Rollup merge of #113153 - tshepang:patch-6, r=cuviper 4467cab9df6 Rollup merge of #113072 - tshepang:patch-1, r=cuviper 64233609299 Add support for allocators in `Rc` and `Arc` e412b83c520 Add support for allocators in `Rc` and `Arc` 216f7236668 std docs: factorize literal in Barrier example b4669109c56 Mark wrapped intrinsics as inline(always) 89e7b435a1a Rollup merge of #107624 - tgross35:const-cstr-methods, r=dtolnay a4d2dd6c0ee Enable co-induction support for Safe Transmute 5125040ebbb make HashMap::or_insert_with example more simple 9fb2e039d3d Fix document examples of Vec::from_raw_parts and Vec::from_raw_parts_in 3c60099c402 Rollup merge of #113054 - Rageking8:make-`rustc_on_unimplemented`-std-agnostic, r=WaffleLapkin b781874afa2 Rollup merge of #112670 - petrochenkov:typriv, r=eholk 0e5dd3629e0 optimize Cstr/EscapeAscii display 78e25eaf846 Rollup merge of #111571 - jhpratt:proc-macro-span, r=m-ou-se 1efb69a8e02 std: remove an allocation in `Path::with_extension` 2d611fee8b5 std: edit [T]::swap docs 96671ad6f1c Rollup merge of #112628 - gootorov:box_alloc_partialeq, r=joshtriplett d020b002430 Change the wording in `std::fmt::Write::write_str` 30816285fd7 Make `rustc_on_unimplemented` std-agnostic 7aff9aae892 str docs: remove "Basic usage" text where not useful c19c620fcfa Rollup merge of #112677 - the8472:remove-unusued-field, r=JohnTitor f390f217068 Auto merge of #113024 - Jerrody:master, r=thomcc 921fd310781 Auto merge of #111850 - the8472:external-step-by, r=scottmcm e03462f3bbc Mark the StepBy specialization as unsafe 2bd484df740 StepBy> can be TrustedLen c9ef790dab0 doccomments for StepBy specializations 26ab85a4707 Stabilize chown functions (`unix_chown`) bb0df445f00 Auto merge of #113001 - ChrisDenton:win-arm32-shim, r=thomcc b7881fa85dc Always inline primitive data types. ef61ba94cd2 Rollup merge of #113009 - ChrisDenton:remove-path, r=workingjubilee ab5a143c806 Rollup merge of #112956 - Amanieu:weak-intrinsics, r=Mark-Simulacrum 5f9d523e9d5 Rollup merge of #112950 - tshepang:patch-4, r=Mark-Simulacrum 03a40730684 Remove unnecessary `path` attribute d2f8ff41f54 Move arm32 shim to c.rs af5b1866044 Rollup merge of #112763 - Patryk27:bump-compiler-builtins, r=Amanieu c7863c9ed22 Rollup merge of #111087 - ibraheemdev:patch-15, r=dtolnay 4009a0673de Add `Read`, `Write` and `Seek` impls for `Arc` where appropriate f00fbc60593 Forward `io::{Read,Seek,Write}` impls of `File` to `&File` d7fb8ede773 Rollup merge of #112704 - RalfJung:dont-wrap-slices, r=ChrisDenton 9b803c76973 Expose `compiler-builtins-weak-intrinsics` feature for `-Zbuild-std` a31bb350576 DirEntry::file_name: improve explanation 859728008a4 add inline annotation to concrete impls 160bd5d5a02 Specialize StepBy> e9bf3c2fe29 Actually save all the files a4b665200d3 Update tvOS support elsewhere in the stdlib 6754ad9858b Avoid fork/exec spawning on tvOS/watchOS, as those functions are marked as prohibited 415d90c45bd Finish up preliminary tvos support in libstd 2da3d473d6c wip: Support Apple tvOS in libstd 76db884a6ff Auto merge of #111684 - ChayimFriedman2:unused-offset-of, r=WaffleLapkin 4d3a360f721 Add known issue of let binding to format_args doc aab2c86381a Rollup merge of #112863 - clubby789:stderr-typo, r=albertlarsan68 2b101a3f08a Rollup merge of #99587 - ibraheemdev:park-orderings, r=m-ou-se 5f7b867587b "Memory Orderings" -> "Memory Ordering" 80c5d84629f Warn on unused offset_of!() result 9f77b74d14f Auto merge of #112877 - Nilstrieb:rollup-5g5hegl, r=Nilstrieb 1fb1214f70d Rollup merge of #112632 - gootorov:vec_alloc_partialeq, r=dtolnay 37e97b941c7 Auto merge of #106450 - albertlarsan68:fix-arc-ptr-eq, r=Amanieu 094c972cb35 Fix typo in `eprintln` docs b0125ba491d relaxed orderings in `thread::park` example 807049cb5fa Merge proc_macro_span_shrink and proc_macro_span eaa570e93e3 Add `Span::{line, column}` d11cafe558b `Span::{before, after}` → `Span::{start, end}` 9cfaf4b00b0 Remove `LineColumn`, `Span::start`, `Span::end` a60eeee1571 Rollup merge of #112464 - eval-exec:exec/fix-connect_timeout-overflow, r=ChrisDenton 25eefb457d3 Remove useless unit tests fc7c7b19f26 Ignore `connect_timeout` unit test on SGX platform 0cea2e890f8 Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr 2c3ef771871 Merge attrs, better validation 19240af70d6 Add rustc_do_not_implement_via_object 4ced0dbbc85 Auto merge of #112817 - compiler-errors:rollup-0eqomra, r=compiler-errors e974f96fa55 Implement slice::split_once and slice::rsplit_once 18084d3f794 Rollup merge of #112606 - clarfonthey:ip-display, r=thomcc 318e4f47aee Rollup merge of #112499 - tgross35:py-ruff-fixes, r=Mark-Simulacrum 90ccddeb1b0 Auto merge of #111849 - eholk:uniquearc, r=Mark-Simulacrum cde50a746bb Introduce `alloc::::UniqueRc` 59b4cfa345d Rollup merge of #112757 - Danvil:patch-1, r=Mark-Simulacrum c53f8971892 Rollup merge of #109970 - danielhenrymantilla:add-poll-fn-pin-clarifications, r=thomcc dd2426bb79e Document thread names for SGX compilation target 2c4ff4b9e3b Auto merge of #112724 - scottmcm:simpler-unchecked-shifts, r=Mark-Simulacrum 94f0b7fba98 Bump compiler_builtins efa0adfff94 [doc] poll_fn: explain how to pin captured state safely d8f30c93049 Same for BorrowRef 0cfbba0fbb7 Add unit test to connect to an unreachable address 58e17061502 Use BorrowFlag instead of explicit isize bb1242e90b1 Rollup merge of #112685 - cuviper:wasm-dlmalloc, r=Mark-Simulacrum e80ddbdfc73 Rollup merge of #107200 - mina86:c, r=Amanieu a4f62c136bc alloc: Allow comparing `Box`s over different allocators 7d912809636 alloc: Implement PartialOrd for `Vec`s over different allocators a0b101595a2 Auto merge of #112599 - saethlin:cleaner-panics, r=thomcc 0aee420ca16 Auto merge of #112595 - hargoniX:l4re_fix, r=Mark-Simulacrum 3e170978dce Auto merge of #112746 - matthiaskrgr:rollup-se59bfd, r=matthiaskrgr 127d41bf569 Add unit test for `TcpStream::connect_timeout` 80bde61d50b Fix windows `Socket::connect_timeout` overflow 6b8d9a1c7c2 Rollup merge of #112610 - scottmcm:update-stdarch, r=Amanieu 88cc9c455b8 Auto merge of #100036 - DrMeepster:box_free_free_box, r=oli-obk a50755608d3 Auto merge of #112739 - matthiaskrgr:rollup-8cfggml, r=matthiaskrgr 7fff2fbf5cc Rollup merge of #112644 - zica87:nonZeroTypes, r=Mark-Simulacrum ad9c1eda2c3 Rollup merge of #112352 - dankm:fbsd_doc_fix, r=thomcc a1f5cf5b1d2 Extend io::copy buffer reuse to BufReader too ac28463a040 Apply changes to fix python linting errors 7dbc4b553eb [libs] Simplify `unchecked_{shl,shr}` da973f341d2 remove box_free and replace with drop impl 8522c99952b Rollup merge of #112662 - Vanille-N:symbol_unique, r=RalfJung 98c855f483f Rollup merge of #112226 - devnexen:netbsd_affinity, r=cuviper 4705cb771c4 Rollup merge of #111074 - WaffleLapkin:🌟unsizes_your_buf_reader🌟, r=Amanieu e27e48ece0f `#[lang_item]` for `core::ptr::Unique` 74983dfa336 Launch a non-unwinding panic for misaligned pointer deref 95a51096bd6 slice::from_raw_parts: mention no-wrap-around condition f49d0666994 Remove `#[cfg(all())]` workarounds from `c_char` c7fa9487008 Rollup merge of #112579 - MikaelUrankar:freebsd_docs, r=cuviper 5dece96407f Rollup merge of #112535 - RalfJung:miri-test-libstd, r=cuviper c10057e68fc Add more comprehensive tests for is_sorted and friends 5e995c6dc11 std: only depend on dlmalloc for wasm*-unknown 25dc23fa00d Rollup merge of #112529 - jieyouxu:block-expr-unused-must-use, r=oli-obk 25579ce4afb remove unused field 77035712a17 privacy: Do not mark items reachable farther than their nominal visibility bce6a1e2060 Rollup merge of #112621 - GrigorenkoPV:env, r=jyn514 ccae000e3eb Extend `unused_must_use` to cover block exprs 65185fd9f71 Auto merge of #106343 - the8472:slice-iter-fold, r=scottmcm 2a77450a052 Correct types in method descriptions of `NonZero*` types 63eb03e5733 Auto merge of #104455 - the8472:dont-drain-on-drop, r=Amanieu 81b9bc68292 use indexed loop instead of ptr bumping a97a36bb43c Auto merge of #112625 - matthiaskrgr:rollup-jcobj3g, r=matthiaskrgr 30e39e229c4 Fix `SocketAddrV6: Display` tests 6450d3d446a Fix `Ipv6Addr: Display` tests 5c0063827ba Auto merge of #112624 - matthiaskrgr:rollup-db6ta1b, r=matthiaskrgr 1d8b037357f Rollup merge of #111974 - Sp00ph:update_guarantees, r=Amanieu 82fbf33cca2 Rollup merge of #109814 - est31:stabilize_string_leak, r=Amanieu 313930c2298 Rollup merge of #107619 - stepancheg:hash-set-insert, r=Amanieu e26a082c93b Rollup merge of #98202 - aticu:impl_tryfrom_osstr_for_str, r=Amanieu 2d28a050c22 Mention `env!` in `option_env!`'s docs 8078c06594c Fix typo 328a2c60519 Auto merge of #112418 - ferrocene:pa-mir-opt-panic, r=ozkanonur,saethlin 488d6fb40ce Auto merge of #110662 - bryangarza:safe-transmute-reference-types, r=compiler-errors dd45af558df update hashbrown and replace Hash{Set,Map}::DrainFilter with ExtractIf da72f4d1b8f s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedList 4546a0f20e4 remove drain-on-drop behavior from linked_list::DrainFilter and add #[must_use] b366d82be24 remove drain-on-drop behavior from BTree{Set,Map}::DrainFilter and add #[must_use] d094cac456b remove drain-on-drop behavior from vec::DrainFilter and add #[must_use] a9c64abf30e Bump stdarch 7e631d94b28 Alter `Display` for `Ipv6Addr` for IPv4-compatible addresses e7d5bdb16b0 fix: get the l4re target working again b8ded012203 Auto merge of #112314 - ferrocene:pa-core-alloc-abort, r=bjorn3 d7da4c702a9 ignore core, alloc and test tests that require unwinding on panic=abort 904b67b85ee Fix building the documentation on FreeBSD. 30985389f7d Auto merge of #112575 - matthiaskrgr:rollup-7a8d7tg, r=matthiaskrgr 10d8d6552e2 Rollup merge of #112558 - eltociear:patch-21, r=thomcc 438f0a60bf7 Auto merge of #99339 - yanchith:binary-heap-ta, r=Amanieu 06ca78a58d6 Fix typo in mod.rs 6b059bad6bd Add comment for arm_shim in generate-windows-sys 99a3e4e5a43 Add windows_sys typedef for Win ARM32 301349540d6 optimize slice::Iter::fold bc5c28bac28 add benchmark 3ebb916718b Revert "Fix intra-doc links from pointer appearing in windows HANDLE type alias" 05ce5637506 Implement `TryFrom<&OsStr>` for `&str` 88f40f93b63 make sure the standard library compiles properly with synthetic targets 8c890ecd688 Impl allocator function for iterators 7e2343c1f3c Remove explicit lifetimes 4e723737a30 reorder attributes to make miri-test-libstd work again a9335e6ff01 Rollup merge of #112497 - icecream17:patch-1, r=Mark-Simulacrum 94012b71263 Rollup merge of #112484 - bdbai:fix/uwpntdll, r=ChrisDenton e0d8ab7e707 implement `Sync` for `mpsc::Sender` fa87a06ca13 abs_sub: fix typo 0[-:][+.]0 4d20360c4e8 Auto merge of #111818 - Urgau:uplift_cmp_nan, r=cjgillot bf0ce40fa52 Keep uwp specific code in sync with windows-sys ea2eda1a5fa Lazy load ntdll functions on UWP 8233b7bc64d Add diagnostic items for `f32::NAN` and `f64::NAN` f8219a16d85 Auto merge of #112465 - GuillaumeGomez:rollup-gyh5buc, r=GuillaumeGomez 6d5aea00889 Auto merge of #111530 - Urgau:uplift_undropped_manually_drops, r=compiler-errors 1d1aa9e8d95 Don't explicitly name Global 4bed1c156aa Pass tidy again b956b7755a4 Add allocator function 27dbe22d566 Reallocatorize after merge 000abd3f980 Merge branch 'master' into binary-heap-ta cb04ed7c392 Fix intra-doc links from pointer appearing in windows HANDLE type alias 32d59d0b4ae Fix test 245e9437003 Rollup merge of #109953 - thomcc:thomcc/typeid128, r=WaffleLapkin 33dd8503a6a Allow undropped_manually_drops for some tests be56e372e43 Auto merge of #112292 - thomcc:tls-ohno, r=m-ou-se 98d163aa13b Fix typo e903574db72 Make Unix or Windows mandatory for the `switch-stdout.rs` test e60aff6f734 Move two tests from `tests/ui/std` to `library/std/tests` 4ef46951199 Safe Transmute: Disable coinduction support d74afc3c73e Don't panic in ceil_char_boundary f44a45f466c Auto merge of #96875 - SabrinaJewson:noop-waker, r=m-ou-se 4114564e63b Auto merge of #111819 - nikarh:vita-improved, r=Amanieu ad01cebf671 Fix documentation build on FreeBSD c4f895f71b8 Bumped libc version 60f1d2656c7 std: available_parallelism using native netbsd api first before falling back to existing code paths like FreeBSD does. 29c993c0f24 Simplified bool to int conversion be80639e1db Std support improvement for ps vita target cdc2fb7fa79 Rollup merge of #112263 - GrishaVar:remove-extend-element, r=scottmcm 8f98cd4edc4 Avoid unwind across `extern "C"` in `thread_local::fast_local.rs` 1542d10b391 Remove redundant example of `BTreeSet::iter` 2b7d4e19732 Use 128 bits for TypeId hash fa343f2b601 Remove ExtendWith and ExtendElement c5614ad4425 Rollup merge of #112172 - tshepang:patch-1, r=Mark-Simulacrum 158a5a30502 Rollup merge of #109093 - Dante-Broggi:patch-2, r=joshtriplett 2705f441029 Rollup merge of #111702 - cgwalters:option-map-or-else-with-result, r=Mark-Simulacrum 93528b07e12 Auto merge of #109432 - flba-eb:108594_forkspawn_exponential_backoff, r=workingjubilee d58d25b2844 Rollup merge of #112206 - k0ur0x:typo, r=Nilstrieb 5a5f7dab299 Rollup merge of #111647 - klensy:cstr, r=oli-obk 06684cf638d Only determine clock res once; give up before sleeping more than 1 second 2ecbb7b8162 Retry to fork/spawn with exponential backoff 8ae6e91d0a1 Fix typo in `std::cell` module docs e5eb6eedae3 fix ptr cast 382df5b2062 Rollup merge of #111670 - compiler-errors:const-param-ty, r=BoxyUwU 76d07a28fe4 Stabilize 'const_cstr_methods' 2df522b83a7 Rollup merge of #112154 - ShaneEverittM:zero-len-utf16, r=thomcc a2a44c73e56 Impl ConstParamTy for tuples, make PartialStructuralEq a supertrait too c1a5952f3d3 Require that const param tys implement ConstParamTy 7ba94f727ea doc: improve explanation 52e03b0e7ae Rollup merge of #112141 - anna-singleton:issue-111655-fix, r=thomcc 260830a10fe Auto merge of #111567 - Urgau:uplift_cast_ref_to_mut, r=b-naber 79b8506c29a Fix bug in utf16_to_utf8 for zero length strings e3aa75894e4 Clarify behavior of inclusive bounds in BTreeMap::{lower,upper}_bound 9910c0ba6f4 use c literals in library cdb309dceec remove reference to Into in ? operator core/std docs, fix 111655 7a4d4b7a6e2 Auto merge of #111076 - notriddle:notriddle/silence-private-dep-trait-impl-suggestions, r=cjgillot 4aed002771d Add diagnostic items for `ptr::cast_mut` and `ptr::from_ref` 09776f93630 Rollup merge of #112103 - Mark-Simulacrum:bootstrap-update, r=clubby789 2bdc2e1b289 Auto merge of #112127 - matthiaskrgr:rollup-77pt893, r=matthiaskrgr 56f9796d9e8 Rollup merge of #112096 - workingjubilee:array-unzip, r=scottmcm f4eb58707a3 Auto merge of #112120 - weihanglo:update-cargo, r=ehuss 8c3405d2d7c Explicit set `workspace.resolver = "1"` 4993dfbea54 Auto merge of #109698 - epage:wtf, r=Amanieu c9813771746 add doc on From impl for ChildStd* 1adc376d588 add FromOwnedFd/FromOwnedHandle for ChildStdin/out/err a17a1b48f9f Bump to latest beta compiler 831254ff2d0 Swap out CURRENT_RUSTC_VERSION to 1.71.0 0bd4012b282 Rollup merge of #111543 - Urgau:uplift_invalid_utf8_in_unchecked, r=WaffleLapkin 461728aa90f Rollup merge of #107916 - reez12g:issue-107040, r=Amanieu e6401ec36e3 Remove array_zip 3fac858e23a fix comment on Allocator trait a75efa7e86b Make `TrustedStep` require `Copy` 19619d010ae Rollup merge of #112045 - Sp00ph:update_current_impl, r=Amanieu cb0c6449f53 Update current impl comment for `select_nth_unstable_by_key` 61df5bcc37b Update runtime guarantee for `select_nth_unstable` 226b66384fa Stabilize String::leak 7bfa434da84 Rollup merge of #111656 - finnbear:string_leak_unbounded_lifetime, r=Amanieu 4111af1c2cc Rollup merge of #108630 - overlookmotel:realloc-docs-fix, r=Amanieu 01cab20b568 Auto merge of #110975 - Amanieu:panic_count, r=joshtriplett 6b4b877a146 Rework handling of recursive panics 3bf18c4c341 Auto merge of #112016 - GuillaumeGomez:rollup-fhqn4i6, r=GuillaumeGomez 2d3ad4769c2 Rollup merge of #111966 - saethlin:inline-slice-tryfrom, r=thomcc 653f1b4c10b Auto merge of #111934 - scottmcm:stabilize-hash-one, r=Amanieu fbf47eb954b Auto merge of #111928 - c410-f3r:dqewdas, r=eholk 67c90c17d83 Auto merge of #111348 - ozkanonur:remove-hardcoded-rustdoc-flags, r=albertlarsan68,oli-obk 27ff7b40fd3 Rollup merge of #111973 - Sp00ph:update_current_impl, r=Amanieu 9e33689448a Allow newly uplifted invalid_from_utf8 lint a5203541ff3 Add invalid_from_utf8 analogous to invalid_from_utf8_unchecked 14e457b804d Uplift clippy::invalid_utf8_in_unchecked as invalid_from_utf8_unchecked 35d9fc66de5 Fix incorrect documented default bufsize in bufreader/writer e0e9c0682b0 Auto merge of #103291 - ink-feather-org:typeid_no_struct_match, r=dtolnay 6779b0dcf5c convert benches to tests in subprocess if we're not benchmarking d2b14c08afe add StaticBenchAsTestFn and DynBenchAsTestFn to convert benches to tests 3b6d7bbcae2 remove nested function from run_test fc7bd95d1be refactor executing tests to centralize actually invoking tests 5b3ea018cc8 Rollup merge of #111940 - zirconium-n:io-read-doc-change, r=thomcc 83bc56aa5f9 Update current implementation comments for `select_nth_unstable` 971cacba6df Add #[inline] to array TryFrom impls 2d7bf116a29 Rollup merge of #107522 - Sp00ph:introselect, r=Amanieu 5448c6e142c Remove structural match from `TypeId`. fba2c39bb1a Auto merge of #86844 - bjorn3:global_alloc_improvements, r=pnkfelix 7dd721c89a9 std: make `fortanix-sgx-abi` a public depedenceny 5d59f5cf26e std: make internal-only items `pub(crate)` 2c66b62d650 std: mark common functions in test crate `pub(crate)` e5934168550 bootstrap: enable Cargo `public-dependency` feature for `libstd` 8ed9cf0ba57 Clarify safety concern of `io::Read::read` is only relevant in unsafe code c8662677431 Stabilize `BuildHasher::hash_one` 3b73b015f76 Rollup merge of #95198 - clarfonthey:get_chunk, r=scottmcm e4e6f36592d [RFC-2011] Expand more expressions 61d421ec9a3 Rollup merge of #111915 - jyn514:libtest-errors, r=thomcc 31157d3b2cc Safe Transmute: Enable handling references, including recursive types 7107c7cacff feat: implement `DoubleEndedSearcher` for `CharArray[Ref]Searcher` 591ba9b2428 Use helper functions for min/max_idx 3fe5cb5c8c7 libtest: Improve error when missing `-Zunstable-options` 049947675e0 Add Median of Medians fallback to introselect b3f3c9e2c66 Roll compiler_builtins to 0.1.92 d8610143fce const stabilize `NonNull::as_ref` 86d5b0f9b13 Auto merge of #111807 - erikdesjardins:noalias, r=oli-obk 0cbfba0f73b Rollup merge of #111756 - Urgau:rename_drop_forget_copy_ref_lints, r=fee1-dead 8663f19b207 Rollup merge of #111612 - ChayimFriedman2:collect-into-slice-ref, r=petrochenkov ac713873032 Rollup merge of #111609 - LegionMammal978:internal-unsafe, r=thomcc 3f862419d77 Auto merge of #111634 - marc0246:arc-new-uninit-bloat, r=thomcc 5c7a990b051 Auto merge of #111711 - Jules-Bertholet:document-pin-layout, r=thomcc 434d2748cfa Auto merge of #111835 - matthiaskrgr:rollup-qd4b2vu, r=matthiaskrgr 8a97aa1522d Rollup merge of #111810 - compiler-errors:less-macro, r=thomcc b279998e61a Auto merge of #111781 - the8472:filter-map-chunk, r=thomcc 1d43db3f7e5 drop_in_place docs: remove pseudocode-ish implementation details d1f07035d96 Rename `drop_copy` lint to `dropping_copy_types` 1c1ec2518b4 Don't use inner macro in marker_impls 69cd8c75ee9 Auto merge of #111696 - lukas-code:offset-of-erase-regions-harder, r=compiler-errors 5c07febee33 improve drop_in_place docs 428f4877535 Add missing "unsafe" to fix doctest 4523071c0e1 Update documentation for `drop_in_place()` 62dc6cf75bb Auto merge of #111646 - Voultapher:restore-branchless-code-gen-for-merge, r=cuviper 9c126e53dd2 don't skip inference for type in `offset_of!` 82a5aa5e763 derive `Default` trait for `compiletest::common::Config` 15d11240400 Auto merge of #111778 - Dylan-DPC:rollup-107ig9h, r=Dylan-DPC 4db43998728 optimize next_chunk impls for Filter and FilterMap 28cc1e092a4 Rollup merge of #111715 - juntyr:const-param-ty-derive-fix, r=Nilstrieb 4662508f0f7 Rollup merge of #111665 - est31:offset_of_tests, r=WaffleLapkin 36190052181 Auto merge of #111524 - scottmcm:escape-using-ascii, r=cuviper c9960d41d02 docs: Add missing period 04e4eb76e79 Auto merge of #111453 - scottmcm:constify-as-slice, r=Mark-Simulacrum 4a3e417fc14 Add slice::{split_,}{first,last}_chunk{,_mut} c49c2aebd74 Auto merge of #109773 - beetrees:set-file-time-improvements, r=Amanieu 2b36420d7fb tidy 3da84b75348 remove unstable `Poll::ready` 3ecbf2811ff constify `slice_as_chunks` (unstable) b46c7d1043b Auto merge of #111590 - dtolnay:panictemporaries, r=bjorn3 bcdb1fb0d68 Add tracking issue ID for `bufread_skip_until` feature gate a0c4d5de8d2 Move `BufRead::skip_until` test to a more appropriate location 126696f0fee Add `BufRead::skip_until` test 309e3fc0ce4 Option::map_or_else: Show an example of integrating with Result 5d0132643bb Add more tests for the offset_of!() macro b000731f761 Fix doc comment for `ConstParamTy` derive 7b63d1b5a13 Auto merge of #111710 - Dylan-DPC:rollup-eutrx54, r=Dylan-DPC 242071ac42d Document `Pin` memory layout dbc676ad7cf Rollup merge of #111527 - knickish:bind_port_0_documentation, r=Mark-Simulacrum 4c6edf92089 Rollup merge of #111168 - DaniPopes:arguments-to-string, r=Mark-Simulacrum 0e6087cce57 docs: Clarify OsStr is self-synchronizing 4d7dd47760b Fix #107910, Shorten backtraces in ICEs d2fd97aa633 Rollup merge of #111654 - JoJoJet:unsafe-cell-from-mut-lib, r=joshtriplett 2a2fd7dbd82 Rollup merge of #111649 - Nilstrieb:derive-const-param-ty, r=BoxyUwU 575d26eb5f9 Rollup merge of #111043 - jmillikin:cstr-is-empty, r=dtolnay 0f53b8dbd74 docs: Add examples of OsStr safety violation d8128544088 Use an unbounded lifetime in String::leak. a3104ded21b add `UnsafeCell::from_mut` 398aac38a97 Rollup merge of #111592 - Nemo157:fix-vec-capacity-examples, r=joshtriplett 94a60c542fd Add derive for `core::marker::ConstParamTy` b0c160ac3b0 Hide repr attribute from doc of types without guaranteed repr a755e2e3948 Use code with reliable branchless code-gen for slice::sort merge 30f6410ac26 Rollup merge of #111617 - kesleta:master, r=Dylan-DPC 4f402d17f4f Fix duplicate `arcinner_layout_for_value_layout` calls 1c2269bc9f9 Auto merge of #111134 - GilShoshan94:remove-send-bound-on-error, r=dtolnay b65f6c58577 Auto merge of #111044 - jmillikin:nonzero-negation, r=dtolnay ac58e03d73e Fixed typo a8d0a191d2e Mark internal functions and traits unsafe b34b5dcd7dc Give better error when collecting into `&[T]` 4cba220f085 Rollup merge of #111587 - cbeuw:copy-for-deref, r=oli-obk 69e493b7e0d Rollup merge of #110049 - SkiFire13:localkey-with-docs-fix, r=workingjubilee c6d536d557a Rollup merge of #108356 - gftea:master, r=workingjubilee fff5d85a841 Rollup merge of #108291 - chenyukang:yukang/fix-benchmarks, r=workingjubilee e58c865e1f0 Add test for `FileTimes` e27be9ceebc Add creation time support to `FileTimes` on apple and windows aeadf1dcfbd Change Vec examples to not assert exact capacity except where it is guaranteed 990426893ef Shorten lifetime of even more panic temporaries b1a03891c2f Documentation f155ca1c829 Add CopyForDeref to custom MIR 754cb82029a Rollup merge of #111582 - Vagelis-Prokopiou:fix/wanting, r=workingjubilee b988675d4ed Rollup merge of #111581 - scottmcm:fix-pattern-comment, r=workingjubilee 1e64e85390f Rollup merge of #102673 - lukas-code:infered-lifetimes, r=ehuss f841a309d46 wanting => want a6953c88c64 Fix some misleading and copy-pasted `Pattern` examples 59138b5f04c Auto merge of #108273 - tspiteri:const_slice_split_at_not_mut, r=dtolnay 7333c4893ec Auto merge of #108196 - sunfishcode:sunfishcode/windows-as-socket-impls, r=dtolnay c1c72cdec1f Auto merge of #92048 - Urgau:num-midpoint, r=scottmcm adb81b441eb explain that `PhantomData<&'a T>` infers `T: 'a` 7d9bbd896bf Shorten lifetime of panic temporaries in panic_fmt case d23060463a0 Auto merge of #111425 - Bryanskiy:privacy_ef, r=petrochenkov dd4595812fe refactor: Remove bespoke from_os_str_bytes_unchecked 879b1d3e592 refactor: Remove redundant, private OsStr::bytes 6b017aa8c5a add examples of port 0 binding behavior a673ad93d17 Auto merge of #111447 - scottmcm:remove-more-assumes, r=thomcc 2424ba119da `ascii::Char`-ify the escaping code ee952b8e7dc Remove useless `assume`s from `slice::iter(_mut)` 99c90bf535c Auto merge of #103413 - RalfJung:phantom-dropck, r=lcnr fe3295d9fa8 hedge for future changes 523086930c6 Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwco f072c7849d0 Auto merge of #111475 - workingjubilee:sync-simd-2023-may-10, r=workingjubilee a84f56af2f4 Correct swizzle_dyn cfg for armv7 neon 8205b7c4074 Auto merge of #111395 - scottmcm:slice-iter-zst-experiment, r=the8472 ec83d89fa64 Sync portable-simd to 2023 May 10 0ffb2328382 Prevent insta-stable no alloc shim support cebaa52ddf8 Auto merge of #111454 - RalfJung:miri, r=RalfJung 71ded9af637 Populate effective visibilities in rustc_privacy ceca3193903 Improve code around SGX waitqueue 065f3e1095b Simplify the implementation of iterators over slices of ZSTs e89d53575d3 Allow the drop_copy lint in some library examples 225e014581f Remove useless drop of copy type f96425f6f48 Remove and fix useless drop of reference de0d979411b Auto merge of #111401 - ChrisDenton:no-windows-allowed, r=workingjubilee f8e279f90c4 Merge from rustc ebde74da746 Rollup merge of #111408 - TomMD:patch-1, r=workingjubilee 462fd98c47f Fix incorrect implication of transmuting slices 7df9fb665f5 Rollup merge of #111282 - scottmcm:remove-unneeded-assumes, r=workingjubilee 34e600e830f Rollup merge of #110770 - m-ou-se:fmt-temp-lifetime, r=oli-obk 67f8faf3f1d Rollup merge of #97320 - usbalbin:stabilize_const_ptr_read, r=m-ou-se 33d998c7584 Don't force include Windows goop when documenting c11e5db9bc1 Auto merge of #111371 - compiler-errors:revert-110907, r=petrochenkov 53efae6481c Limit lifetime of format_args!() with inlined args. a6d602775ce Auto merge of #110285 - KisaragiEffective:sync-stdarch, r=Amanieu 7bb5bb3ad49 Auto merge of #111380 - Dylan-DPC:rollup-xiptbhn, r=Dylan-DPC 491172b233f Rollup merge of #110694 - est31:builtin, r=petrochenkov 37df388fefa Auto merge of #110152 - ChrisDenton:windows-sys, r=thomcc 85cc53265fd Auto merge of #110027 - nbdd0121:dieting, r=m-ou-se 4244a4db980 Auto merge of #111296 - Sp00ph:const_gcd, r=nagisa,Mark-Simulacrum 9f0d28d8f76 Revert "Populate effective visibilities in `rustc_privacy`" 5be9cc5c4a0 Rollup merge of #104070 - nbdd0121:unwind, r=Amanieu cf3404da887 Rollup merge of #111315 - Swatinem:rm-identitiy-future, r=Mark-Simulacrum 83097f291ed Rollup merge of #110638 - nikarh:vita, r=Mark-Simulacrum 7b598729fa7 std: remove test for arm's crypto feature please see https://github.com/rust-lang/rust/pull/110285#issuecomment-1521201953 for more details 072956088ec stdarch: update submodule, take 5 b48925251cd Auto merge of #106621 - ozkanonur:enable-elided-lifetimes-for-doctests, r=Mark-Simulacrum f5a2b38137e Auto merge of #111306 - Urgau:hashbrown-std-0.13, r=Amanieu 78e93e3cce9 Merge from rustc d1b015e9721 PS Vita std support 8a56818d225 Auto merge of #111222 - scottmcm:constify-is_ascii, r=thomcc d8aacb81da9 Add `#[inline]` to functions that are never called 4d4823ae801 Prevent aborting guard from aborting the process in a forced unwind 36a467a2ab7 Parse catch filter in personality function 897d1b06fd0 Remove `identity_future` from stdlib a89105a59fe Auto merge of #111125 - xfix:inline-socketaddr-methods, r=Mark-Simulacrum 6505c0d6019 Tune the `is_ascii` implementation used for short slices 2010456a478 Rollup merge of #111301 - JohnBobbo96:cleanup_option_insert_methods, r=scottmcm 3d97a655b2a Rollup merge of #110094 - lukas-code:less-transmute, r=thomcc 9972c35abd4 Update hashbrown from 0.12.3 to 0.13.1 for std b5f3340e667 Remove unneeded calls to `mem::forget` and `mem::replace` in `Option::get_or_insert_with`. 99a18df5f3d enable `rust_2018_idioms` for doctests 367d2c48e9f Auto merge of #110907 - Bryanskiy:privacy_ef, r=petrochenkov b68483987da Always const-eval the gcd in `slice::align_to_offsets` cce461d3e25 clean up transmutes in core 238e62cc7a2 Remove some `assume`s from slice iterators that don't do anything a2a1d01d6bc Rollup merge of #111139 - fortanix:raoul/fix_mxcsr_configuration_dependent_timing, r=thomcc 669ba005d06 Rollup merge of #110830 - Freaky:freebsd-cpuset, r=thomcc 0bded623a83 Sort windows_sys.lst alphabetically 22d68534c0f Use new bindings 8e13fc908b6 Generate windows-sys bindings 7f315a64844 Migrate offset_of from a macro to builtin # syntax 205c836598f Stabilize const_ptr_read e79b2f76b76 Auto merge of #111248 - Dylan-DPC:rollup-lbp0ui3, r=Dylan-DPC bcc359a9fe0 Populate effective visibilities in `rustc_privacy` 6ed5350b19b feat: merge functionality of `io::Sink` into `io::Empty` 3bd5ffaddf9 Rollup merge of #111238 - workingjubilee:fix-btree-cursormut-peek-prev, r=Amanieu 6f181338262 Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors 909c3b094a4 Rollup merge of #103056 - beetrees:timespec-bug-fix, r=thomcc f7c1ab78f32 Auto merge of #111113 - scottmcm:assume-align-offset, r=thomcc 395cd42153d `assume` the runtime range of `align_offset` c04935b8eb0 btree_map: `Cursor{,Mut}::peek_prev` must agree 8ba3b34d054 Rollup merge of #111213 - WaffleLapkin:fixup_dates, r=scottmcm 284db606dad Rollup merge of #110946 - RalfJung:tls-realstd, r=m-ou-se e56f05ec3e1 Stabilize feature `nonzero_negation_ops` 7150173bf00 Add an example that depends on `is_ascii` in a `const` 236b94210f6 Constify `[u8]::is_ascii` (unstably) 4c8ba849b35 Fixup "since" dates for `array_tuple_conv` feature 100b0948a78 Rollup merge of #111186 - jmillikin:nonzero-is-positive, r=dtolnay 9c963a4f155 Rollup merge of #111009 - scottmcm:ascii-char, r=BurntSushi d3f9c86e366 Rollup merge of #110651 - durin42:xunit-stdout, r=cuviper 5dd54346774 Rollup merge of #108865 - Zoxc:library-dummy-crate, r=jyn514 29c3b9b19ec Optimize `Iterator` implementation for `&mut impl Iterator + Sized` f8a81d2899e Add `is_positive` method for signed non-zero integers. 9fed418cbca Add the basic `ascii::Char` type 515e0fd07a4 stdarch: update submodule, take 4 31fa27dcfb5 Rollup merge of #111127 - xfix:const-slice-flatten, r=scottmcm e54a7ba73af Rollup merge of #105695 - joboet:remove_generic_parker, r=m-ou-se 06ede3baea0 Rollup merge of #105452 - rcvalle:rust-cfi-3, r=bjorn3 629a0d88b4a Rollup merge of #97594 - WaffleLapkin:array_tuple_conv, r=ChrisDenton 09560825b07 Specialize ToString implementation for fmt::Arguments 291a32ce48b Add cross-language LLVM CFI support to the Rust compiler ed00a26185a Mention array<->tuple convs in docs 6458bc4cb6b Fix MXCSR configuration dependent timing 3cfce321f9c Remove unnecessary Send bound 1b4097a8eff Constify slice flatten method d6469530f5a Use `from_wide_to_user_path` in `read_link` 6d20628c4f1 Inline SocketAddr methods 9b8a3cb8086 Correctly convert an NT path to a Win32 path d4795aafbab Auto merge of #109729 - fortanix:raoul/bugfix_libtest_json_synchronization, r=pietroalbini ea925716517 Remove `[]` <-> `()` `From` convertions 403f66008b2 Use metavar `${count(x)}` instead of reimplementing it 3aeeacb569e implement tuple<->array convertions via `From` bea49c2c5a4 rm diag item, use lang item 2b5aa891559 fix TODO comments 64882d73cfd initial step towards implementing C string literals 33c93cd679e Rollup merge of #110955 - fee1-dead-contrib:sus-operation, r=compiler-errors d80444642fb Rollup merge of #110895 - Ayush1325:thread-local-fix, r=thomcc 3e90228ba13 Rollup merge of #108161 - WaffleLapkin:const_param_ty, r=BoxyUwU 24b35f11778 Rollup merge of #105076 - mina86:a, r=scottmcm 142c0bd0860 Auto merge of #106075 - nbdd0121:ffi-unwind, r=joshtriplett f1cbf8346fd Relax implicit `W: Sized` bound on `LineWriter` 6221dba80ad Relax implicit `W: Sized` bound on `BufWriter` 5e7a721ed98 Relax implicit `R: Sized` bound on `BufReader` 7534c2bb026 Auto merge of #111066 - matthiaskrgr:rollup-4k6rj23, r=matthiaskrgr 05a96fa4967 Rollup merge of #111065 - est31:send_mut_ref, r=m-ou-se aabd6311c50 Rollup merge of #111057 - xfix:tcpstream-as-raw-fd-inline, r=m-ou-se b0ef9a39831 Rollup merge of #110987 - infdahai:wasi_clock_time, r=m-ou-se 8cf39e243cf Rollup merge of #110093 - beetrees:set-times-32-bit, r=joshtriplett 138547aabde Rollup merge of #109540 - marcospb19:edit-Path-with_file_name-example, r=m-ou-se 22bc720bffc Explicitly document how Send and Sync relate to references 8f878c57cd4 Auto merge of #111010 - scottmcm:mem-replace-simpler, r=WaffleLapkin 9920a559684 Fix `StructuralEq` impls for `&T`, `[T]` and `[T; N]` cc66382be84 Inline AsRawFd implementations 2a075237fbc Inline socket function implementations ecc5ae6b9bb Inline AsInner implementations 6ffb970dc7f Auto merge of #111036 - RalfJung:miri, r=RalfJung c3f0eaab8a7 Ensure test library issues json string line-by-line 0677d9b8809 Codegen fewer instructions in `mem::replace` 3d519cd6df0 Stabilize feature `cstr_is_empty` 4e4fcf44884 Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naber e0dd3029275 Merge from rustc 19b500b5b9e Auto merge of #111017 - matthiaskrgr:rollup-yy9updi, r=matthiaskrgr 5ff603fd97c Rollup merge of #111000 - JohnBobbo96:core_option_unneeded_function, r=jyn514 164ee62befe Auto merge of #103406 - Jules-Bertholet:from_clone_slice_to_box, r=dtolnay 424beaf18b0 a bit more usize::from ad477f2b87d Auto merge of #110935 - scottmcm:always-ord, r=Mark-Simulacrum cad64f8e344 review 413bcfa036e Rollup merge of #110997 - scottmcm:slice-iter-comments, r=the8472 fe6d01444c7 Remove unneeded function call in `core::option`. a52f712e6cf `cfg`-gate `BoxFromSlice` trait 518ccaabaa5 Improve internal field comments on `slice::Iter(Mut)` 3a97399a6dd Partial stabilisation of `c_unwind` 62814e565f5 update wasi_clock_time_api ref. a01de857808 fix rustdoc and core test 7714830ff7a Rollup merge of #110958 - compiler-errors:stdlib-refinement, r=cuviper 5406acbb973 junit: fix typo in comment and don't include output for passes when not requested f7548f3e050 Make sure that signatures aren't accidental refinements 2c0c678fd77 handle cfg(bootstrap) 31547081b29 replace version placeholders b47f4199568 avoid duplicating TLS state between test std and realstd c6e9aabef5b Merge from rustc e65794c5b7c Auto merge of #110837 - scottmcm:offset-for-add, r=compiler-errors ac06b0e33b9 `inline(always)` for `lt`/`le`/`ge`/`gt` on integers and floats 81e1703a048 Auto merge of #110924 - matthiaskrgr:rollup-jvznpq2, r=matthiaskrgr 6622d4601b7 Also use `mir::Offset` for pointer `add` c363f8f1f67 Rollup merge of #110918 - ChrisDenton:on-error-resume-next, r=cuviper 77eee257ca6 Rollup merge of #110766 - m-ou-se:fmt-rt, r=jyn514 d4d692d4e30 Rollup merge of #110898 - m-ou-se:remove-unused-thread-local-key, r=cuviper 99e8e0f5ff4 Rollup merge of #110620 - Nilstrieb:document-the-undocumented, r=thomcc 4a5bbacdb73 remove_dir_all: delete directory with fewer perms 6bb8e401a44 Rollup merge of #106599 - MikailBag:patch-1, r=jyn514 5a18b5af980 Rollup merge of #106456 - kadiwa4:std-prelude-comment, r=jyn514 bee7240b9cb Rollup merge of #105745 - philpax:patch-1, r=jyn514 92afeb956b5 Document `const {}` syntax for `std::thread_local`. d9a15064877 Don't call await a method 8267a818f6a Fix some marker impls 82eed998b57 Add FIXMEs a16ee12c5d2 Impl `StructuralEq` & `ConstParamTy` for `str`, `&T`, `[T; N]` and `[T]` 740726d9600 Add a macro to conveniently implement marker traits c109bec9045 Remove `feature(const_param_ty_trait)`, use `adt_const_params` instead edcebef6953 Add a `ConstParamTy` trait 721435ae882 pub -> pub(super). fb8692b34e6 Implement `StructuralEq` for integers, `bool` and `char` 37940206283 correct `std::prelude` comment 5260ac5cb84 Update test. 661d290be05 Remove unused std::sys_common::thread_local_key::Key. d99ac2d5ea1 Rollup merge of #110804 - cuishuang:master, r=jyn514 991ab75c222 Remove all in target_thread_local cfg cf2cc8374d3 std: use `LazyLock` to lazily resolve backtraces a40991dc6ee Loosen `From<&[T]> for Box<[T]>` bound to T: Clone ac28b2f78a7 Auto merge of #110562 - ComputerDruid:riscv, r=tmandry 7237d5bc677 docs(std): clarify `remove_dir_all` errors 3e6d34cc803 Auto merge of #110861 - m-ou-se:thread-local-restructure, r=workingjubilee d7d1b67fd0d Restructure and rename thread local things in std. d7af8e2bd65 Rollup merge of #110819 - tamird:flattencompat-trustedlen, r=the8472 b5b2bcc0f19 Rollup merge of #110419 - jsoref:spelling-library, r=jyn514 a1a60d880d3 Remove repeated definite articles 21e9227871c Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadata 5e8578ab39a Implement midpoint for all unsigned NonZeroU{8,16,32,64,128,size} cb5b7c15416 Implement midpoint for all floating point f32 and f64 0d82967f0c2 Implement midpoint for all signed and unsigned integers 61f2fe9d27f Merge from rustc 7f6ae09ee22 Rollup merge of #110587 - tomaka:fix-109727, r=jyn514 802484b563b Rollup merge of #110266 - tgross35:try-exists-wording, r=jyn514 5c8103dbd76 Rollup merge of #108416 - pat-nel87:Issue-107957-black_box_docs, r=jyn514 3612dd37f81 rewrite: line_long_tail_not_flushed description df6fff42cdc rewrite: long_line_flushed description 77736ff8beb Spelling library/ a15ca5cae7f Add definitions for riscv64gc-unknown-fuchsia eac092bb17e Add FreeBSD cpuset support to std::thread::available_concurrency c16e295b33c Rollup merge of #110796 - madsravn:wake-example, r=Mark-Simulacrum ac41ab67ee6 Rollup merge of #110649 - arlosi:fix_no_global_oom_handling, r=Mark-Simulacrum 78f78bb3a19 simplify TrustedLen impls 07f0cd0da3e Updating Wake example to use new 'pin!' macro 3f0ab848c53 Add a `sysroot` crate to represent the standard library crates 9cb68fabbf4 Auto merge of #103093 - rytheo:linked-list-alloc-api, r=Mark-Simulacrum 103b7aa3c03 Auto merge of #110389 - mazong1123:add-shortcut-for-grisu3, r=Mark-Simulacrum e9fd0be9351 Rollup merge of #110782 - matthiaskrgr:revert_panic_oom, r=Amanieu 5428620ab11 Add shortcut for Grisu3 algorithm. 30a72221bc3 Add support for allocators in LinkedList eb03f74fb90 Auto merge of #106152 - SUPERCILEX:lazycell, r=Amanieu 573f3c98cae Revert "Report allocation errors as panics" f19e104d09d Revert "Remove #[alloc_error_handler] from the compiler and library" a474399a8fb Revert "Rename -Zoom=panic to -Zoom=unwind" 3330146cba0 stdarch: update submodule, take 3 24b34c419fb Restructure std::fmt::rt a bit. 773da86cd0c Remove "V1" from ArgumentsV1 and FlagsV1. 4bfe15fb351 Implement FusedIterator for DecodeUtf16 when the inner iterator does a25e9b539e9 Merge from rustc 8125915a0f4 Rollup merge of #110706 - scottmcm:transmute_unchecked, r=oli-obk 9af76589434 stdarch: update submodule, take 2 02cb0719b3c Rollup merge of #110689 - Spartan2909:fix-grammar, r=JohnTitor 98f7795530b Auto merge of #110655 - ChrisDenton:read-to-end, r=joshtriplett 768e2e65936 Add `intrinsics::transmute_unchecked` c0896c7154a Fix grammar 6fbfee9da23 Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwco bac978afd47 Merge from rustc 80d4c44adb9 Auto merge of #110666 - JohnTitor:rollup-3pwilte, r=JohnTitor 7146e69aa8b Rollup merge of #110635 - scottmcm:zst-checks, r=the8472 e6c28a30276 Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin 3b380b7a908 More `IS_ZST` in `library` d81ebfc1cb7 Limit read size in `File::read_to_end` loop c71594324f2 junit: also include per-case stdout in xml e3474708757 Fix no_global_oom_handling build 586fe8c65c0 Rollup merge of #110633 - scottmcm:more-take, r=thomcc 904c2c5f7ba Rollup merge of #110608 - a1phyr:specialize_io_methods, r=thomcc d6404af4f10 Auto merge of #109002 - michaelvanstraten:master, r=petrochenkov 3f0d13ee73a major test improvements 51b30e5b06b minor tweaks f615972bcbc fmt 352f3b6d6ad fix incorrect param env in dead code lint 293cb857fc6 test improvements ac77d0095c0 offset_of ee41eeee428 More `mem::take` in `library` 852fbc04c1e Add reason to #![unstable] tag. 83d73a739a9 Remove doc link to private item. 62fc7c897bb Get rid of core::fmt::FormatSpec. 735d92b7a17 Rename fmt::rt::Argument to Placeholder. 24042b631fb Turn core::fmt::rt::v1 into a private module. c173e93bf55 Use fmt::Alignment instead of fmt::rt::v1::Alignment. aea08df7f8d Don't reexport core::fmt::rt from alloc::fmt. d3d9f945982 Specialize some `io::Read` and `io::Write` methods for `VecDeque` and `&[u8]` 7868993b91a Implement `BufRead` for `VecDeque` a69fb561c40 Fix `std` compilation error for wasi+atomics 90fe61039da Rollup merge of #110448 - ripytide:master, r=cuviper 09faacad2df Implement `Neg` for signed non-zero integers. 56451b6048c Auto merge of #106704 - ecnelises:big_archive, r=bjorn3 dfd8cb766cc Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obk 8a2188e2cdc std: make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent with `Mutex` and `RwLock` 9cf295dd288 Bump version of object and related crates 7bee7576fa0 Rollup merge of #110432 - compiler-errors:unsatisfied-index-impl, r=cjgillot 2b8b8b87a73 Use a diagnostic item instead of filtering for Index::Output 62996a449b1 Rollup merge of #110441 - kadiwa4:typos, r=thomcc e38228893cf Create try_new function for ThinBox 1a79abee861 cmp doc examples consistency improvements 41876e3bcc6 fix codegen difference 85cbc81bc80 Merge from rustc e93ce8da536 typos 0dafc7012b2 Rollup merge of #110433 - ChrisDenton:notfound, r=thomcc d0983043a08 Rollup merge of #110388 - JohnBobbo96:remove-intrinsic-unwrap, r=the8472 430ac580e45 Windows: map a few more error codes to ErrorKind b7d285e4ffd Rename -Zoom=panic to -Zoom=unwind 7844f0e19dd Remove #[alloc_error_handler] from the compiler and library cb8ccde490b Report allocation errors as panics b71ec317fbf Add a message indicating overflow in `core::intrinsics::is_nonoverlapping`. 0fe38b560a0 fix library and rustdoc tests 81e60e7be12 readd `const_trait` to `Drop`, `Destruct`, and `Fn*` 1519ac55582 fix tidy b280a60871e fix alloc cd64fd1188f core is now compilable c789d024263 more hacks d92856f0f81 hack cstr is_empty 9a876393141 hack signum as well a150fc7a64b memchr hack c85c78a0108 rm const traits in libcore da19ff957f5 Remove unused unused_macros 85efc8b3375 Use a `saturating_mul` instead of a `checked_mul` and `unwrap` in `core::intrinsics`. be4e5d738f6 Rollup merge of #110347 - est31:size_of_links, r=jyn514 06709330c67 Add intra-doc links to size_of_* functions b64f10db4e8 edit docs of `PathBuf::set_file_name` e0f4f695e22 Add Lazy{Cell,Lock}::into_inner f8038c7ee8a Rollup merge of #110244 - kadiwa4:unnecessary_imports, r=JohnTitor dec76d43678 Rollup merge of #110154 - DaniPopes:library-typos, r=JohnTitor 5b331527623 Rollup merge of #110110 - lukas-code:display-panic-info, r=JohnTitor c9bb43bdc3e Rollup merge of #109947 - clubby789:cmp-macro-crosslink, r=JohnTitor 89798c2742d Rollup merge of #109272 - schneems:schneems/add-docs-to-command-env-methods, r=Amanieu 7acd09dce57 Rollup merge of #110292 - scottmcm:sort-features-2, r=jyn514 750f4a9a9b3 Rollup merge of #110269 - scottmcm:sort-features, r=jyn514 bbb7da4b259 Rollup merge of #110047 - skaunov:patch-1, r=ChrisDenton f58f158331a Auto merge of #101959 - Xaeroxe:clamp-better-assert, r=ChrisDenton 492797ffb62 Add links to docs to `Iterator` 5c77bddb26b Auto merge of #110311 - matthiaskrgr:rollup-kn2k5bq, r=matthiaskrgr 0f50e956c45 Rollup merge of #110298 - jmaargh:jmaargh/hypot-docs-edge-cases, r=thomcc 8a5b2ea6b57 Rollup merge of #110158 - TDecking:obsolete_test, r=ChrisDenton 49079ecb151 Rollup merge of #109800 - bryangarza:safe-transmute-improved-errors, r=compiler-errors 70f6946d529 Rollup merge of #109225 - seanlinsley:patch-1, r=ChrisDenton 3f7c2069e78 Auto merge of #105007 - dlaugt:solaris-fs-link, r=ChrisDenton 92862ec39e1 Update documentation wording on path 'try_exists' functions 15f18790a95 Improve safe transmute error reporting 915673d49ea Cover edge cases for {f32, f64}.hypot() docs ee8e6460305 Rollup merge of #110259 - ndrewxie:issue-109964-fix-gitstuff, r=cjgillot 933b21a692e Rollup merge of #110233 - nbdd0121:intrinsic, r=tmiasko f83cfec803f Add `tidy-alphabetical` to features in `alloc` & `std` 6ff3bb4cb63 stdarch: update submodule 27a8e24b203 Document catch_fn in r#try cannot unwind b45ecd627c7 Rollup merge of #110262 - justincredible:patch-1, r=ChrisDenton 77152dca567 Rollup merge of #110234 - marc0246:btree-insert-after-fix, r=cuviper bd79faed8ef Rollup merge of #110072 - joshtriplett:stabilize-is-terminal, r=Mark-Simulacrum 0b766f03298 Add `tidy-alphabetical` to features in `core` d2207f569fd Auto merge of #108283 - the8472:remove-splice-into-pipe, r=ChrisDenton 78ade13385e Update unwind_safe.rs 15f68a66639 Added diagnostic for pin! macro in addition to Box::pin if Unpin isn't implemented d6fb893c45a Rollup merge of #110089 - petrosagg:mpsc-ub, r=m-ou-se 5a79919a5f9 remove some unneeded imports e9bf3b4efda Fix btree `CursorMut::insert_after` check 9f743437d3d Rollup merge of #110190 - cbeuw:mir-offset, r=oli-obk f34341921f0 Make rust-intrinsic ABI unwindable 4269d71f979 Rollup merge of #110173 - solid-rs:patch/kmc-solid/socket-read-buf, r=cuviper 07eef5b80ea Rollup merge of #110104 - kormosi:todo_typo, r=cuviper 23deeb2ff9d Rollup merge of #109894 - fleetingbytes:109893-var_os-never-returns-an-error, r=cuviper 9bc5632e403 Rollup merge of #96971 - zhaixiaojuan:master, r=wesleywiser 3b2e67e4ba3 clarify wording around spurious wakeups from `thread::park` 50181028c15 Reword the docstring in todo! macro definition bc7ed453f5b Add Offset binary op to custom mir f39214738d2 Rollup merge of #110070 - scottmcm:wrapping-neg, r=cuviper f1adc425880 kmc-solid: Implement `Socket::read_buf` 7c5527f47dc Break up long first paragraph 11001a3c537 remove obsolete test 1ae91d7cfce Fix typos in library 1a559f13e8d Auto merge of #107007 - TDecking:float_parsing_improvments, r=Mark-Simulacrum 6bf0f1c3578 Rollup merge of #110044 - scottmcm:more-size-of-val, r=ChrisDenton 3de3269b97b Stabilize IsTerminal 8ab8fa2a7de Improve the floating point parser in `dec2flt`. dfe78193a31 Auto merge of #109684 - fee1-dead-contrib:rv_const_range, r=Mark-Simulacrum d4840c7f007 Apply suggestions from code review c14f6a5378e Auto merge of #109500 - petrochenkov:modchainld, r=oli-obk 15daf7206cf Use `Display` in top-level example for `PanicInfo` 410f155633b Fix typo in todo! macro docstring 081b5f97e37 Auto merge of #110101 - JohnTitor:rollup-ol20aw7, r=JohnTitor cea005758ac Rollup merge of #110060 - WaffleLapkin:sync_refs, r=jyn514 253c94a9e91 Enforce that PointerLike requires a pointer-like ABI 41f20b2ed32 Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times` b891583bf5b sync::mpsc: synchronize receiver disconnect with initialization bab49b939fa std: Mark two reexports that should be inlined as `doc(inline)` b6eb219b6b3 Auto merge of #110076 - Nilstrieb:rollup-22yp01c, r=Nilstrieb cce364485aa Revert "Make the `Step` implementations const." 5c14c0da89e Revert "Mark DoubleEndedIterator as #[const_trait] using rustc_do_not_const_check, implement const Iterator and DoubleEndedIterator for Range." 2efc3525e3a Auto merge of #109995 - enkron:u/enkron/substitute-hardcoded-port-num-in-listen-on-fn, r=the8472 c7c897a6dba The `wrapping_neg` example for unsigned types shouldn't use `i8` 21c63fe360c fix(tcp): remove redundant `format!` macro call 65dd8cc8c6a Fix wrong type in docs: i16 -> u16 adad077de2b Document that `&T` and `&mut T` are `Sync` if `T` is 9e441ce6544 Define UNWIND_DATA_REG for loongarch64 60a845467ef Inline try_from and try_into d4fa0ea79b6 Don't claim LocalKey::with prevents a reference to be sent across threads 5a8200b7786 Avoid some manual slice length calculation 0af52fda3aa Auto merge of #110019 - jplatte:jplatte/stabilize-is-some-and, r=Amanieu 0d0c54efb32 Auto merge of #109990 - gwy15:remove-bufwriter-useless-mut-pointer, r=jyn514 ac5347ff177 Rollup merge of #109960 - thomcc:symlink-junction-buffer-overrun, r=ChrisDenton e60b5d5e0e0 Rollup merge of #109806 - Zoxc:gnu-tls, r=pnkfelix d736bc4caf9 Stabilize is_some_and c6664d7d37e chore(tcp): change the hardcoded port number to `port` var 3a8d87c9c00 Remove an unnecessary `mut` in `BufWriter::into_parts`. 281c92d0dd2 Derive String's PartialEq implementation b30b98bf2ed Refactor core::char::EscapeDefault and co. structures 7af25649267 Fix buffer overrun in (test-only) symlink_junction c85d3ce51b9 Auto merge of #94786 - joshlf:patch-5, r=dtolnay ea7ae727240 Add links from `core::cmp` derives to their traits 4c7636f6a7c library/unwind: Add definitions for loongarch64 501f1f6762d library/std: Add support for loongarch64 3f4c0c9b93b Rollup merge of #109883 - skaunov:patch-1, r=thomcc 40209e8be84 avoid zero-copy ops for File->Pipe and File->Socket in io::copy 3c3bf803f7d test that modifications to the source don't become visible after io::copy 07fdf9dbccd Preserve potential mood for equal or NUL sign 1a76418596e Remove redundant empty line 9705a125725 remove self-reference in var_os doc 893f1ad3f00 add situation where var_os returns None 076b9149962 Update env.rs 37f081c42f0 Auto merge of #109756 - cr1901:msp-shift, r=Mark-Simulacrum 019e312b170 Auto merge of #108448 - ishitatsuyuki:binary-heap, r=Mark-Simulacrum 3eb6fd1e5d6 Rollup merge of #109722 - hermitcore:read, r=Mark-Simulacrum 74ff0790991 Add links to a168900798a Auto merge of #109852 - Nilstrieb:rollup-g3mgxxw, r=Nilstrieb a34c4821c28 Rollup merge of #109840 - taiki-e:typo, r=ChrisDenton 37046509034 Rollup merge of #109839 - sartak:iter-grammar, r=scottmcm ea6d25cc119 Auto merge of #109701 - Amanieu:binaryheap_retain, r=ChrisDenton 60deec6ddce Auto merge of #109483 - joboet:optimize_lazycell, r=Mark-Simulacrum 5c282c0d0f9 Fix typo in std/src/os/fd/owned.rs e557cbab990 Improve grammar of Iterator.partition_in_place b9535c0b7d6 Auto merge of #109801 - aliemjay:test-implied-normalization, r=petrochenkov 4209a25fe61 Rollup merge of #109443 - GuillaumeGomez:doc-primitive-hard-error, r=notriddle b958608ba34 Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obk c35e9d29811 Workaround #109797 on windows-gnu 85a00337447 Rollup merge of #109793 - lukas-code:negative-impl-comment, r=scottmcm 6f8b516999c Rollup merge of #109784 - beetrees:riscv32-time64, r=cuviper 37452187876 Rollup merge of #109598 - veera-sivarajan:improve-wording, r=thomcc 6ad29dee1db Replace doc(primitive) with rustc_doc_primitive 76c2b300b19 add comment to `impl !Error for &str` 86ebebdf825 Refactor glibc time64 support, riscv32 always has 64-bit `time_t` b1c9b4b70de fix typo and adjust comment 84b7271451b core: use `pointer::write` to cleanup `LazyCell` initialization d14b70c548e core: improve code documentation for `LazyCell` deb72231896 core: optimize `LazyCell` size 51e21d80614 Auto merge of #109769 - JohnTitor:rollup-7n2bnpg, r=JohnTitor 1d368e02362 Rollup merge of #106985 - jofas:106746-fix, r=ChrisDenton 47d0faa52c7 Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se 12686e73a0e removed deprecated markdown links from documentation 825e7cb489b Update compiler-builtins to 0.1.91 to bring in msp430 shift primitive fixes. f211bf0827f Auto merge of #107221 - kleisauke:getentropy-emscripten, r=ChrisDenton 93edb69959b Em dashes are cooler than hyphens. 55c8a03f61c Documentation updates to better share the purpose of OnceCell/OnceLock 1b35880c30f Stabilize a portion of 'once_cell' 07e264092ed Rollup merge of #109693 - workingjubilee:maybe-unconstify-alloc, r=fee1-dead 36f8d670dc8 Rollup merge of #107387 - joboet:hermit_random, r=ChrisDenton 94baa158d71 Auto merge of #108089 - Zoxc:windows-tls, r=bjorn3 5eeaa0f1246 Implement read_buf for RustHermit 69b9632570b Use with_capacity_and_hasher instead of using base 3a9b001941d enhanced documentation of binary search methods for slice and VecDeque for unsorted instances 5102d1b0ea0 std: use `cvt` to handle errors from `read_entropy` on Hermit 34e08f9960a Auto merge of #108792 - Amanieu:ohos, r=petrochenkov 4e9da42ce99 Use #[inline] on Windows for thread local access 15d30759150 Auto merge of #108095 - soc:drop-contains, r=Amanieu 6f0547f1fb2 Remove ~const from alloc 129b4c08d81 Stabilize `binary_heap_retain` c114ab04e27 Auto merge of #109692 - Nilstrieb:rollup-hq65rps, r=Nilstrieb 408fb8dcc33 Add OpenHarmony targets c5cf5e9f4ce Auto merge of #108080 - oli-obk:FnPtr-trait, r=lcnr d79693e35ae Rollup merge of #92284 - the8472:simplify-advance-by, r=scottmcm 54c71b14558 Rollup merge of #91793 - devnexen:anc_data_fbsd, r=ChrisDenton 9714e0da241 Rollup merge of #109687 - joshtriplett:document-windows-isterminal-heuristics, r=BurntSushi c1f40f67fbf Rollup merge of #109682 - clubby789:c-str-inline, r=scottmcm 3de51959fea Allow access to `OsStr` bytes a7c886b2a23 Add "Platform-specific behavior" heading and link to changes disclaimer e712c7b2334 Document the heuristics IsTerminal uses on Windows 0b4bfe22654 Add `#[inline]` to CStr trait implementations 5afa0c9349b socket ancillary data implementation for FreeBSD (from 13 and above). 61586952c82 Fix ASCII case comment 2464e99a690 fix advance_by impl for vec_deque and add tests 433de52246c update documentation 4999adb0eff replace advance_by returning usize with Result<(), NonZeroUsize> 9c5be9560b7 Use the FnPtr trait to avoid implementing common traits via macros 7fcd15071f6 Add a builtin `FnPtr` trait 9e3138028bf Change advance(_back)_by to return `usize` instead of `Result<(), usize>` c930c55f286 Document that SystemTime does not count leap seconds a404135191d Add note about clone-and-hack to the two UNIX_EPOCH definitions fbbb76e19f9 Rollup merge of #102742 - bjorn3:cleanup_rust_start_panic, r=ChrisDenton f98d61170a1 Rollup merge of #98651 - mattfbacon:master, r=ChrisDenton 778a61625e6 Rollup merge of #97506 - JohnTitor:stabilize-nonnull-slice-from-raw-parts, r=m-ou-se,the8472 98f26363c9a Auto merge of #109357 - saethlin:inline-as-deref, r=thomcc 279bf39571c Remove unnecessary raw pointer in __rust_start_panic arg 272480ed2f7 Merge branch 'master' into Issue-107957-black_box_docs c027c9d863a Rollup merge of #109620 - eievui5:patch-1, r=compiler-errors 77a411fdf60 Auto merge of #105096 - LegionMammal978:copied-allocators, r=Amanieu 1fac386c71e Correct typo (`back_box` -> `black_box`) bc51b2734cb Improve documentation for str::replace() and str::replacen() bcb4728b922 Auto merge of #99929 - the8472:default-iters, r=scottmcm 3ac8829b2cf Auto merge of #109546 - saethlin:inline-into, r=scottmcm 152ae308659 Add #[inline] to the Into for From impl 97e11f45fe6 Auto merge of #109216 - martingms:unicode-case-lut-shrink, r=Mark-Simulacrum 8e490f8cf08 Rollup merge of #109406 - WaffleLapkin:🥛, r=cuviper 6507874ab7b Rollup merge of #109368 - hermitcore:typo, r=cuviper 6d67e3bff0e Rollup merge of #109142 - the8472:mutex-block-docs, r=cuviper b0e3c0a4776 Rollup merge of #108924 - tmiasko:panic-immediate-abort, r=thomcc 1c95c954010 A MIR transform that checks pointers are aligned c3e91ae7c8c Auto merge of #109538 - matthiaskrgr:rollup-ct58npj, r=matthiaskrgr c80ac4a1905 Rollup merge of #106964 - workingjubilee:crouching-ioerror-hidden-documentation, r=ChrisDenton 9832e136b07 Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obk 6b6c91c7c3d Auto merge of #109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgr c1029fface0 Rollup merge of #109504 - steffahn:stabilize_a_rc_into_inner, r=joshtriplett bcec554725d Auto merge of #109503 - matthiaskrgr:rollup-cnp7kdd, r=matthiaskrgr f494d2f62c2 Stabilize `arc_into_inner` and `rc_into_inner`. f982d753887 Add `CastKind::Transmute` to MIR c63583f4114 Rollup merge of #109359 - Nilstrieb:bump-stdarch, r=Amanieu 11f0dcae948 Auto merge of #109497 - matthiaskrgr:rollup-6txuxm0, r=matthiaskrgr d649fa8f547 Rollup merge of #109392 - cbeuw:composite-ret, r=JakobDegen 4fd4e68f8c7 Rollup merge of #109179 - llogiq:intrinsically-option-as-slice, r=eholk d29aae40b2b Rollup merge of #100311 - xfix:lines-fix-handling-of-bare-cr, r=ChrisDenton e3a1223fcae Check the presence of linkat() on Solaris (not available in version 10, available in version 11) 3ac8e517be4 Rollup merge of #108164 - joboet:discard_messages_mpmc_array, r=Amanieu e07102bf76b Rollup merge of #96391 - ChrisDenton:command-non-verbatim, r=joshtriplett fa9812a58ad Rollup merge of #108326 - tmiasko:read-buf, r=thomcc 3794d7510d8 Rollup merge of #106434 - clubby789:document-sum-result, r=the8472 060eb20001e Use hex literal for INDEX_MASK 8bc33124911 Auto merge of #106967 - saethlin:remove-vec-as-ptr-assume, r=thomcc ce91411097c Auto merge of #108717 - TDecki:dec2flt-inline, r=thomcc 1f4821647d2 Auto merge of #108262 - ChrisDenton:libntdll, r=Mark-Simulacrum d85b02c9a6d Remove outdated comments e17c705c233 Add example for `Option::product` and `Result::product` 93f38f20ae9 Add documentation for `type RET = ...` 4523192d3e0 Allow optional RET type annotation 6e833ea4ec0 Apply suggestions from code review b32fc046a0f Add block-based mutex unlocking example 4b1eb822945 Rollup merge of #109273 - WaffleLapkin:slice_is_sorted_by_array_windows, r=scottmcm 9a558065485 Rollup merge of #109353 - Nilstrieb:rustc-mir-building, r=compiler-errors 4b05a697ac8 Rollup merge of #109337 - frengor:collect_into_doc, r=scottmcm e395d477678 Auto merge of #108148 - parthopdas:master, r=oli-obk 72cbe6400b2 fix typo in the creation of OpenOption 13dcd32e4a6 Add `#![feature(generic_arg_infer)]` to core for stdarch 6c9114a353e Update stdarch 72c3d1679a9 Add #[inline] to as_deref 67e5adaa32e Fix wrong crate name in custom MIR docs 6b255e9efac Rollup merge of #109022 - tmiasko:read-buf-exact, r=dtolnay f1fd18f84be Rollup merge of #108973 - est31:pin_docs, r=Mark-Simulacrum eeef80696c0 Rollup merge of #108829 - xfix:use-edition-2021-pat-in-matches, r=Mark-Simulacrum ae7b16c33a8 Rollup merge of #108798 - devsnek:panic-pal-exception, r=workingjubilee 65a16451fbe Rollup merge of #104100 - ink-feather-org:const_iter_range, r=the8472,fee1-dead fb0735002f6 Improve collect_into documentation 8c614e4a4bc Rollup merge of #109288 - jmillikin:linux-abstract-socket-addr, r=joshtriplett b368d8c4f31 Rollup merge of #109287 - scottmcm:hash-slice-size-of-val, r=oli-obk 38f938ca955 Mark DoubleEndedIterator as #[const_trait] using rustc_do_not_const_check, implement const Iterator and DoubleEndedIterator for Range. addf9312df7 move Option::as_slice to intrinsic 51f083b6fd1 review fee2275a93a move default backtrace setting to sys 8bddb5f315f Stabilise `unix_socket_abstract` 6a1701efa6d Use `size_of_val` instead of manual calculation b6fadf3bd7c Rollup merge of #109235 - chaitanyav:master, r=ChrisDenton 26bff961734 Rollup merge of #109102 - compiler-errors:ambig-assoc-in-non-lt-binder, r=jackh726 e3d2e734cc0 Make the `Step` implementations const. f8dfbd716a2 Remove irrelevant docs on error kinds 80f7ad8cde3 Auto merge of #108862 - Mark-Simulacrum:bootstrap-bump, r=pietroalbini 51a9bd7dccd Switch impls of `is_sorted_by` between slices and slice iters 1657dc4f590 Make `slice::is_sorted_by` impl nicer 98e065a44e2 Add Command environment variable inheritance docs 11b9a122a64 Modify code style as per comments c8f376629fe Update mod.rs ae058d7054d fix typo in documentation for std::fs::Permissions 8a3a0958620 run rustfmt on changes 498ad5aa3b5 fallback to lstat when stat fails on Windows 757a68caaae Merge from rustc 7e301454782 Improve case mapping encoding scheme 0596149d5b9 Beautify pin! docs ec2bb822c87 Clarify that RUST_MIN_STACK is internally cached 7b5d108fb82 Auto merge of #106824 - m-ou-se:format-args-flatten, r=oli-obk 7baae18de69 Split unicode case LUTs in single and multi variants 53b59e4efd8 Don't allow new const panic through format flattening. 83c00584d95 Update format_args!() test to account for inlining. ddd869a60ab unequal → not equal 5ba87fe08ce Implementing " --list --format json" #107307 #49359 d65f5f2a788 Skip serializing ascii chars in case LUTs 54739a13103 Bump to latest beta 3f2d6e79244 Bump version placeholders 86452964218 Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen 87cc16aac2a Improved implementation and comments after code review feedback a293a604730 Merge from rustc 6f6638f8d8f std: leak remaining messages in bounded channel if message destructor panics 3ab1ab474c9 Update libc dependency of std to 0.2.140 0e2ea652b77 Use getentropy() instead of /dev/urandom on Emscripten 07a7bec5800 Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errors c23fdf85c3b Rollup merge of #108507 - hermitcore:new, r=m-ou-se cc4c98197d7 Rollup merge of #108419 - tgross35:atomic-as-ptr, r=m-ou-se c2954b6a222 add `#[doc(alias="flatmap")]` to `Option::and_then` 140cc753d46 Auto merge of #108623 - scottmcm:try-different-as-slice-impl, r=the8472 6ed2c31729d Clarify stability guarantee for lifetimes in enum discriminants 30fa1b8ade8 Clarify the text of some comments a14d9fb0233 Add a better approach comment in `ptr::read` to justify the intrinsic ef9bbe05ca0 Rollup merge of #109026 - joshtriplett:rc-into-inner, r=dtolnay 86c461d2b6d Fix formatting of new Rc::into_inner test 785ca7d2408 Move `Option::as_slice` to an always-sound implementation cbea962d842 `MaybeUninit::assume_init_read` should have `noundef` load metadata 9d403a376b1 Introduce `Rc::into_inner`, as a parallel to `Arc::into_inner` c18514d3391 Auto merge of #109019 - matthiaskrgr:rollup-ihjntil, r=matthiaskrgr ddb33686d29 read_buf_exact: on error, all read bytes are appended to the buffer ce22e7e880c Rollup merge of #108708 - noamtashma:issue-108706-fix, r=m-ou-se 669abbccaec Rollup merge of #106633 - c410-f3r:stabilize-nonzero_bits, r=dtolnay 7ce8bc5ffe5 Rollup merge of #104363 - WaffleLapkin:bonk_box_new, r=Nilstrieb cf3c7f91206 Rollup merge of #108927 - Ayush1325:pal-cleanup, r=workingjubilee f23b2b377a2 Rollup merge of #106276 - Sp00ph:unify_slice_ranges, r=the8472 c60814ac7e6 Renamed to byte_range and changed Range generics [skip ci] 6d84d36ddde Auto merge of #109001 - matthiaskrgr:rollup-a3agnwp, r=matthiaskrgr fa65ad29381 Merge from rustc 4f8e85e532d added byte position range for proc_macro::Span ef99b1553ca added byte position range for proc_macro::Span ce739a97694 Rollup merge of #105962 - zertosh:stabilize_path_as_mut_os_str, r=dtolnay cc3cf32599c improve doc test for UnsafeCell::raw_get and fix docs error d924658c1a3 Rollup merge of #106921 - madsmtm:cell-memory-layout, r=dtolnay 202715cd518 Moved thread_local implementation to sys::common 1d59e6b5d15 Split __thread_local_inner macro 40fbca08869 Move __thread_local_inner to sys a60c309238a Rollup merge of #108964 - majaha:ptr_metadata_doc, r=workingjubilee 0796357c920 Rollup merge of #108956 - Raekye:master, r=scottmcm 9b2db5db29c Fix docs for ptr method with_metadata_of() b9bc93cb820 Make ptr::from_ref and ptr::from_mut in #106116 const. 3c10e11a462 Add examples section which demonstrates the behaviour (specifically the sign positive aspect) f3bec17942e Add missing comment for f64 f0fba91ab1e Indicate that `0.0` refers to positive `0.0` c31970530d8 Document the resulting values produced when using `From` on floats 8e986a8fc75 Auto merge of #108920 - matthiaskrgr:rollup-qrr9a0u, r=matthiaskrgr 6a0b377594d panic_immediate_abort requires abort as a panic strategy f2ce8998219 Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiasko 0e8fa3b673d rand: freebsd update, using getrandom. cf5024891a2 Remove `identity_future` indirection 870573eff0c may not => cannot 7288a485c7c black_box hint - Adjust for improved readability e8e1d6ccc8d Remove DropAndReplace terminator 533206ac244 Auto merge of #108763 - scottmcm:indexing-nuw-lengths, r=cuviper eb069969e7b Auto merge of #95317 - Jules-Bertholet:round_ties_to_even, r=pnkfelix,m-ou-se,scottmcm e5bceb612d4 Use Edition 2021 :pat in matches macro 56e817a1f0b issue-108706-fix 862c7517043 Implement read_buf for a few more types 24f5168ef09 Use `nuw` when calculating slice lengths from `Range`s 316ddda59b9 Auto merge of #108157 - scottmcm:tuple-gt-via-partialcmp, r=dtolnay 6631ef62724 Auto merge of #105117 - pitaj:debug_asserts, r=the8472 0666bc435e5 Merge from rustc 59e035bff82 Comment for why char boundaries aren't checked ca811b1ac26 Rollup merge of #108660 - xfix:remove-ne-method-from-str, r=thomcc 9fd20d6a39c Auto merge of #89518 - a1phyr:unix_file_vectored_at, r=workingjubilee f2c74330052 Update comment. cc86409a75b typo 20d2445e928 Add inlining annotations cf0c10a2b60 Rollup merge of #108688 - est31:backticks_matchmaking_library, r=jyn514 681028051fd Rollup merge of #108540 - WaffleLapkin:atomic_thingy_from_thingy_pointer, r=m-ou-se cffc40d9458 fix an alloc test 3e795776e05 Make `unused_allocation` lint warn against `Box::new` 09ae7c6e6de Use weak linkage for `preadv` and `pwritev` on MacOS and iOS c27f9b4e371 Update library/std/src/io/mod.rs 093559b9ca6 Match unmatched backticks in library/ 213b9483b20 Make std tests pass on newer Android f7f4dcc6c59 Remove manual implementation of String::ne 99942945831 Remove manual implementation of str::ne ee40c7df33f Revert "Stabilize `#![feature(target_feature_11)]`" d8aa69d2e03 Fill-in tracking issue for `feature("atomic_from_ptr")` 567183ba81e Add basic tests 9fd7e081ad0 Take shared references as parameter 0c1b6b8c149 Use weak linkage on Android edb017ae58b Auto merge of #106673 - flba-eb:add_qnx_nto_stdlib, r=workingjubilee d6962c957fc Fix docs for `alloc::realloc` 31730c5c22d Auto merge of #108483 - scottmcm:unify-bytewise-eq-traits, r=the8472 0c1e58f8660 Merge two different equality specialization traits in `core` c38e8c36477 Rollup merge of #108462 - pommicket:fix-vecdeque-zst-overflow, r=Amanieu db2dc7edac2 Auto merge of #105871 - llogiq:option-as-slice, r=scottmcm b478f13ee22 Auto merge of #108476 - saethlin:remove-library-rustc-box, r=thomcc c9521cdf336 Update library/std/src/os/nto/mod.rs 0c1955eae1d Update library/std/src/io/mod.rs 1685b0f408d Rollup merge of #108558 - RalfJung:core-tests, r=thomcc 401e6affdbf Rollup merge of #108531 - Coca162:rustdoc-repeat-const-array, r=thomcc 587802df391 Add `Option::as_slice`(`_mut`) ae4d68cbe6d relax bounds on iterator adapter Default impls 183911f34aa Support allocators in various Default for IntoIter impls c451b0d97a4 rewrite iterator `Default` tests as doctests c1ed7a50a4e Implement Default for some alloc/core iterators aac43499cf7 Retry to spawn/fork up to 3 times when it failed because of an interruption e838893a404 Add QNX Neutrino support to libstd 1da55ff9045 Auto merge of #107987 - EFanZh:inline-poll-methods, r=Mark-Simulacrum d6e4dd671fb add missing feature in core/tests f38bfdb8d82 Auto merge of #106774 - Nugine:master, r=Amanieu 12d3233f77d Remove or justify use of #[rustc_box] 322a1d37df6 Auto merge of #99767 - LeSeulArtichaut:stable-target-feature-11, r=estebank 3ff8f425f28 Add `Atomic*::from_ptr` 1df7eedda8f Rollup merge of #107110 - strega-nil:mbtwc-wctmb, r=ChrisDenton 30d2ce2709e Rollup merge of #104265 - faern:move-ipaddr-to-core, r=joshtriplett 9facaa4fda8 Clarify that Copy is a trait in array docs 24f671c4db6 Update docs to show [expr; N] can repeat const expr 39a340efd95 Add vectored positioned I/O on Unix d1a8a37702a use `as_ptr` to determine the address of atomics 75dba60d666 remove unused imports cb211571b58 Merge from rustc a132d13237b Add tracking issue 6fb1b9f3f58 Move IpAddr and SocketAddr to core f277cd42d0c Rollup merge of #108484 - Nilstrieb:˂DiagnosticItem˂FromFn˃ as From˂˂LangItemFromFn˃˃˃꞉꞉from, r=cjgillot 5f67c631f27 Rollup merge of #108475 - Sp00ph:fix_shrink_to, r=thomcc 177228ccb17 Rollup merge of #108299 - scottmcm:literal-bits, r=Nilstrieb e312930f59c std: disconnect senders before discarding messages 359148d75e7 std: use random HashMap keys on Hermit edb9a6c0faa Remove `from_fn` lang item b4b6d70fa36 Disambiguate comments 42dee3681c0 Fix `VecDeque::shrink_to` and add tests. a90cc5e9acc Rollup merge of #108432 - klensy:test-deps, r=Mark-Simulacrum 6550598374b Rollup merge of #107890 - obeis:mapping-to-unit, r=cjgillot 8189e5d4af5 Auto merge of #107405 - hermitcore:bsd, r=bjorn3 43cf6f3e534 [stdio][windows] Use MBTWC and WCTMB 2c0a5b54fcf Add test for VecDeque::append ZST capacity overflow 7a4dd0b6706 Auto merge of #108450 - matthiaskrgr:rollup-rqvfgu3, r=matthiaskrgr 526fd336d5f Use checked_add in VecDeque::append for ZSTs to avoid overflow bb8881dda1e Rollup merge of #108407 - notriddle:notriddle/vec-get-mut, r=thomcc fddd2156ab2 Auto merge of #108233 - ChrisDenton:move-std-tests, r=thomcc bda8f1abe01 binary_heap: Unify Extend implementation. f0ae6647a62 binary_heap: Make RebuildOnDrop a common helper. 55e2afe8faa Auto merge of #107638 - zhangyunhao116:pdqsort-rand, r=cuviper 66fe24a9a2a test: drop unused deps b93457aebec avoid the usage of libc during the creation of documentation 78e137c68ab remove code duplications b791d18c230 move IO traits to std/src/os/hermit dbda81a0364 add support of RustyHermit's BSD socket layer 4f955fc5c1e Rollup merge of #108391 - sunfishcode:sunfishcode/is-terminal-file-length, r=ChrisDenton fa6f3352736 Rollup merge of #108370 - fbq:time-doc-fix, r=thomcc 193848fa291 Rollup merge of #106918 - dtolnay:heapretain, r=the8472 e6edd576397 Rollup merge of #106541 - fee1-dead-contrib:no-const-check-no, r=thomcc a168a5ef470 Stabilize atomic_as_ptr 3f6acf1ccd4 black_box doc corrections - Issue #107957 d5fa27bec54 docs: use intra-doc links for `Vec::get(_mut)` 79893cd59ef Fix `is_terminal`'s handling of long paths on Windows. 48a19658a18 Add lint against `Iterator::map` receiving a callable that returns `()` 0e0a5fa7419 Require `literal`s for some `(u)int_impl!` parameters 5b6319f77bf Rollup merge of #108218 - ChrisDenton:cmd-escape, r=cuviper eea033645e3 std: time: Avoid to use "was created" in elapsed() description 12610a39d90 Rollup merge of #107736 - tgross35:atomic-as-ptr, r=m-ou-se 30fc41d94e5 Optimize break patterns dbc8166f79b Quote more batch file arguments 20ab48ca432 Exclude SGX from create_dir_all_bare test 5135ff2cdc4 Make `create_dir_all_bare` an std integration test ae1efe6e648 Move `rename_directory` from ui-fulldeps to std 4e9f0634741 Remove unused FileDesc::get_cloexec 125ae2db66f Merge from rustc 9b3cb8e515b Rollup merge of #108272 - MrNossiom:master, r=thomcc 814586c199b Rollup merge of #108105 - majaha:patch-1, r=cuviper 1424758fb3a fix more benchmark test with black_box 561a18b41f6 Explain the default panic hook better 8739f19ba92 use UpperCamelCase a3bf25ce7cb Changes according to review 79cc6e8e924 Rollup merge of #108279 - Nilstrieb:int, r=scottmcm e56bd6756f4 Use named arguments for `int_impl` macro 62eef732fb6 Use named arguments for `uint_impl` macro aaecc362dd0 Stabilize const slice::split_at e4bd0e157ef docs: wrong naming convention in struct keyword doc bcaba37d8f3 Rollup merge of #108124 - kornelski:cstr_c_char, r=thomcc de3dccdbab6 Merge from rustc af3623d422c Distribute libntdll.a with windows-gnu toolchains d7e714348fb Remove the assume(!is_null) from Vec::as_ptr 99549ea75b5 Use custom implementation of read_buf in Read for &'a FileDesc d5bf81bf986 Rollup merge of #108130 - tshepang:just-one-example, r=workingjubilee f9fc59330ee Rollup merge of #106933 - schuelermine:fix/doc/102451, r=Amanieu 603dfa1bbec Rollup merge of #104659 - tshepang:reflow, r=workingjubilee 73f05d6c715 Auto merge of #106241 - Sp00ph:vec_deque_iter_methods, r=the8472 958d52802c6 Merge from rustc 5f69f8d599b Update documentation of select_nth_unstable and select_nth_unstable_by and select_nth_unstable_by_key to state O(n log n) worst case complexity 72063b0d84a Auto merge of #107329 - joboet:optimize_lazylock, r=m-ou-se 7ebc291d622 Implement `AsHandle`/`AsSocket` for `Arc`/`Rc`/`Box` on Windows bd1759c06eb Add a slightly-contrived tuple comparison benchmark e37435535ff std: add regression test for #107466 5e5871c1c67 std: drop all messages in bounded channel when destroying the last receiver 85df60ca816 Use `partial_cmp` to implement tuple `lt`/`le`/`ge`/`gt` 923a4bd61a7 Rollup merge of #104068 - yancyribbens:partial-cmp-doc-update, r=scottmcm f91b12ef10c rustdoc: Update the description to include PartialOrd elements 8f23b7e42ba "Basic usage" is redundant for there is just one example 084b67fc25b Document that CStr::as_ptr returns a type alias 5c4d762de75 std: replace generic thread parker with explicit no-op parker b601ff4957f Merge from rustc 812139a4feb Rollup merge of #108084 - ink-feather-org:const_range, r=dtolnay d173b04c040 Rollup merge of #106372 - joboet:solid_id_parking, r=m-ou-se f7509f293e2 Rollup merge of #108094 - kornelski:fsdocs, r=cuviper 6c5c8ef050f Remove `#![feature(option_result_contains)]` from library/core/tests/lib.rs d140e83ca05 Suggest simpler fs helper methods in File::{open,create} 4c2cf0b2304 Drop unstable `Option::contains`, `Result::contains`, `Result::contains_err` b2b35bb28cb Demonstrate I/O in File examples 7fd5af8f2a8 clarify correctness of `black_box` 023807cbb7c Constify `RangeBounds`, `RangeX::contains` and `RangeX::is_empty`. c307aa0b904 Use libc which supports QNX Neutrino 926a77323af Merge from rustc 46055fdac0d Rollup merge of #108060 - ChrisDenton:rtlgenrandom, r=thomcc c9a1bcdde1f Auto merge of #108056 - matthiaskrgr:rollup-oa6bxvh, r=matthiaskrgr c833a954c41 Revert to using `RtlGenRandom` d6d31568719 Rollup merge of #108033 - lcnr:coinductive-attr, r=compiler-errors f21c4227953 Rollup merge of #107573 - cuviper:drop-llvm-13, r=nagisa a2a60453078 Rollup merge of #108023 - JulianKnodt:smaller_benchmark, r=workingjubilee 97a70051774 Rollup merge of #108016 - tshepang:just-one-example, r=thomcc d8bf76be1a4 add a `#[rustc_coinductive]` attribute e66343cf901 Shrink size of array benchmarks 8f4d697e2bc "Basic usage" is redundant for there is just one example b7749afdc6d Rollup merge of #107985 - alesito85:master, r=ChrisDenton 36542503aab fix and extend dropck documentation 423c100fe24 Add another error to Windows file open fallback e4d1819c41f Auto merge of #107634 - scottmcm:array-drain, r=thomcc cadf0bcf62c Auto merge of #107980 - Dylan-DPC:rollup-u4b19bl, r=Dylan-DPC a6382807255 Inline `Poll` methods 0d05057450c Rollup merge of #107970 - hermitcore:hermit-rm-floor, r=thomcc a6eff8105bb Rollup merge of #107962 - scottmcm:why-not-exact, r=Mark-Simulacrum 81a3b890abd Rollup merge of #107961 - scottmcm:unify-ilog-panics, r=Mark-Simulacrum 5222338d109 Rollup merge of #107915 - JulianKnodt:array_benches, r=Mark-Simulacrum 9b1dd82b10e Rollup merge of #107654 - pitaj:reword-integral-modules, r=thomcc 6bcfb750b6c Auto merge of #107191 - Voultapher:reverse-timsort-scan-direction, r=thomcc 9b84f81bfa5 Hermit: Remove floor symbol 09317cc78e4 Rollup merge of #107954 - RalfJung:tree-borrows-fix, r=m-ou-se b9d25352f91 Rollup merge of #107943 - compiler-errors:document-pointer-like, r=jyn514 86ed6c8f836 Add a doc note about why `Chain` is not `ExactSizeIterator` 2f1104a0749 avoid mixing accesses of ptrs derived from a mutable ref and parent ptrs 758cba68edc Auto merge of #105671 - lukas-code:depreciate-char, r=scottmcm 7929dc521ae Auto merge of #107894 - Voultapher:improve-heapsort-fallback, r=scottmcm 3986678ced7 Document PointerLike 0fe58642d2d Auto merge of #106677 - tbu-:pr_less_doc_hidden_pub, r=scottmcm 2ace0ef8617 Auto merge of #107167 - the8472:rawvec-simpler-layout, r=thomcc dc3b211b41a Split branches in heapsort child selection 15095ac01e6 Rollup merge of #107900 - ChrisDenton:zero-header, r=thomcc 5e0c13d0fea Rollup merge of #107878 - workingjubilee:new-size-means-bytes, r=scottmcm ddb2472d7af Rollup merge of #106001 - sdroege:glibc-skip-over-null-argv, r=ChrisDenton 7667de0a9ee Add array::map benchmarks 0943894c6b1 Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref #66893) 2fe790f6a75 Drop llvm14-builtins-abi with compiler_builtins 0.1.87 8ad10634607 Have a function for the `log(0)` panic, rather than copy-pasting the string constant 3caabb2f9bb Zero the `REPARSE_MOUNTPOINT_DATA_BUFFER` header 063c58aca9e Speedup heapsort by 1.5x by making it branchless 6f60a6d998e Clarify `new_size` for realloc means bytes 800bcf54f7b Remove a couple of `#[doc(hidden)] pub fn` and their `#[feature]` gates 236f3754e72 Allow wasi-libc to initialize its environment variables lazily. 8053824267f Rollup merge of #107655 - notriddle:notriddle/small-url-encode, r=GuillaumeGomez f6c509e88cd Merge from rustc 8f23e5db6e4 Rollup merge of #107429 - tgross35:from-bytes-until-null-stabilization, r=dtolnay fc92aa6fee8 Rollup merge of #107317 - ids1024:asfd-rc, r=dtolnay 911d8bee3f3 Rollup merge of #107793 - joboet:raw_os_error_ty_tracking, r=Dylan-DPC 341363076a9 Rollup merge of #105641 - Amanieu:btree_cursor, r=m-ou-se 88ca9345c61 std: add tracking issue for `RawOsError` e47e0213e61 Rollup merge of #107776 - dbrgn:docs-string-reserve-headings, r=cuviper a73c7ece532 Rollup merge of #107769 - compiler-errors:pointer-like, r=eholk 3d298ecd09d Docs: Fix format of headings in String::reserve 0f5a13aabbd Rename PointerSized to PointerLike a7f0d87ee91 Rollup merge of #107706 - tgross35:atomic-as-mut-ptr, r=m-ou-se 6e79dd0c64f Merge from rustc d5a9cb5b723 Rollup merge of #107720 - tshepang:consistency, r=Mark-Simulacrum fb11c023ad9 Rollup merge of #107714 - Wilfred:round_docs, r=m-ou-se 4e8d1223350 Auto merge of #103761 - chenyukang:yukang/fix-103320-must-use, r=compiler-errors c37f63be212 end entry paragprah with a period (.) ba8f5094b58 Clarify wording on f64::round() and f32::round() b793159f896 Mark 'atomic_mut_ptr' methods const a4b71108db0 Fix typo in HashMap::with_capacity 54de123a762 Add `slice_ranges` safety comment 8f405841408 Allow canonicalizing the `array::map` loop in trusted cases d9f0ac89d77 Stop forcing `array::map` through an unnecessary `Result` 615ddca8a39 Stop using `into_iter` in `array::map` 4bafb868ef3 docs: update fragment for Result impls 4002f953573 reword descriptions of the deprecated int modules bcce14a0c62 Rollup merge of #107632 - ameknite:issue-107622-fix, r=jyn514 58a4805e068 Rollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obk 7fb5d513dbc Rollup merge of #107519 - joboet:raw_os_error_ty, r=Amanieu 5fdc4baed80 nit fixed b836501db2e Clarifying that .map() returns None if None. 95852f1bf65 Update library/std/src/io/mod.rs 74ab736970c Fix #103320, add explanatory message for [#must_use] 2f298e57265 Replace `ConstFnMutClosure` with const closures a49eade5199 Rollup merge of #107598 - chenyukang:yukang/fix-core-bench, r=thomcc f1230d031c3 Specify behavior of HashSet::insert 96af80aeacd fix #107590, Fix benchmarks in library/core with black_box d128772940a Merge from rustc 943da796e64 Stabilize `#![feature(target_feature_11)]` 03f77223b8a Change 'from_bytes_until_nul' to const stable 7e65ea4fa53 Stabilize feature 'cstr_from_bytes_until_nul' e1dd4e07342 Rollup merge of #107442 - lukas-code:slice-panics, r=cuviper c588f44b964 Rollup merge of #107389 - zvavybir:master, r=estebank f2df1f38b81 Stabilize cmpxchg16b_target_feature 85b08e3c44b BTreeMap: Add Cursor and CursorMut 4533e2c04d1 BTreeMap: Change internal insert function to return a handle 0f22885075d improve panic message for slice windows and chunks f83308d3a97 Rollup merge of #107535 - dcompoze:tcp-doc-unwrap, r=cuviper 6fc34fd5355 Replace unwrap with ? in TcpListener doc f6dabc7848d Auto merge of #107297 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini 49ad96db37b implement const iterator using `rustc_do_not_const_check` 4a94caa0fbf std: add type alias for raw OS errors a25fe47a7e8 Fix `vec_deque::Drain` FIXME 4cb7f4be1ba Rollup merge of #107494 - lebensterben:patch-1, r=JohnTitor f6a35722853 Rollup merge of #107445 - Swatinem:rm-genfuture, r=cuviper 6d11ae10bfe fix link in std::path::Path::display() a2f47a932a9 Improved wording of error messages of missing remainder implementations fdbc02e3723 Merge from rustc 28584649bcb stage-step cfgs 95748857718 Rollup merge of #107424 - bpeel:clone-into-from-share-code, r=scottmcm bab99e0b76f Auto merge of #107080 - Urgau:cleanup-bootstrap-extra-check-cfgs, r=Mark-Simulacrum 45db03d608d Add `str::Lines::remainder` 12479e69e9c Rollup merge of #107459 - tshepang:cosistency, r=WaffleLapkin 20a7cbad607 Rollup merge of #107452 - y21:get-mut-unchecked-typo, r=Mark-Simulacrum bd44d80f4be Rollup merge of #101569 - m-ou-se:alloc-no-rexport-argumentv1, r=thomcc a20e34fd5dc end entry paragraph with a period (.) a2b9fe9aa9b Don't re-export private/unstable ArgumentV1 from `alloc`. 1633072eb4d fix typo in {Rc, Arc}::get_mut_unchecked docs 02a872f6742 Rollup merge of #107431 - notriddle:notriddle/colon, r=thomcc f181686bdc4 Rollup merge of #106798 - scottmcm:signum-via-cmp, r=Mark-Simulacrum 2c30178ffa0 Rollup merge of #106769 - lenko-d:libtest-print_why_a_test_was_ignored_if_its_the_only_test_specified, r=Mark-Simulacrum 8ebb6d4247d Remove `GenFuture` from core 2ad864b4cd7 Auto merge of #106253 - nbdd0121:upcast, r=compiler-errors 2d0d054e474 Rollup merge of #107154 - glaubitz:m68k-alloc, r=JohnTitor dfd4179f645 Rollup merge of #106618 - jmillikin:os-net-rustdoc-wasm32, r=JohnTitor 3f5fe0f1174 docs: remove colon from time header d43b4f74ce0 vec: Use SpecCloneIntoVec::clone_into to implement Vec::clone_from 4805aa6dacb slice: Add a specialization for clone_into when T is Copy 759d64309fd Reintroduce multiple_supertrait_upcastable lint fc6bcd1b319 Rollup merge of #107398 - scottmcm:its-their-funeral, r=dtolnay 3ed749436a2 Rollup merge of #105524 - Ayush1325:libc-free, r=ChrisDenton 6f0e0596082 Rollup merge of #104252 - faern:stabilize-const_socketaddr, r=JohnTitor 1bb5ef7fec2 Replace libc::{type} with crate::ffi::{type} 70838277eee Rollup merge of #107022 - scottmcm:ordering-option-eq, r=m-ou-se 009290c53b6 Remove `ControlFlow::{BREAK, CONTINUE}` e36c998bcdb Link to the LLVM issue from a comment on `SpecOptionPartialEq` 4c4f08319bc Fixed confusement between mod and remainder 683926b6cf8 std: add safety comment in `LazyLock::get` e81d569de99 std: fix `Debug` implementation on `LazyLock` 6a0910ffe46 Rollup merge of #106856 - vadorovsky:fix-atomic-annotations, r=joshtriplett c84340a91c9 Rollup merge of #105784 - yanns:update_stdarch, r=Amanieu fa5c2396ef3 Implement `AsFd` and `AsRawFd` for `Rc` 4b3f2354805 Auto merge of #107328 - matthiaskrgr:rollup-lfqwo0o, r=matthiaskrgr b9364004c1a std: optimize `LazyLock` size 961812b969d Rollup merge of #107322 - JakobDegen:custom-mir, r=tmiasko 8bbc29d4762 Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obk ce6f611a15b Custom mir: Add support for some remaining, easy to support constructs 5c33de40b56 fix alphabetical sort 6d904a162a8 remove avx512 prefix for gfni, vaes and vpclmulqdq 8bb6d779dfc Auto merge of #107318 - matthiaskrgr:rollup-776kd81, r=matthiaskrgr 3b39e7f42fd Rollup merge of #106946 - dtolnay:hashlinecolumn, r=m-ou-se e6b6f1e9402 Rollup merge of #106836 - ibraheemdev:sync-sender-spin, r=Amanieu 19ebf7fba73 Rollup merge of #106779 - RReverser:patch-2, r=Mark-Simulacrum 54a1576de6e Rollup merge of #97373 - dimpolo:cell_dispatch_from_dyn, r=dtolnay c66589b7125 Rollup merge of #106407 - mejrs:attr_check, r=compiler-errors 899047255e5 Stabilize the const_socketaddr feature 82bf372f8b9 Rollup merge of #106944 - Nilstrieb:there-once-was-a-diagnostic, r=WaffleLapkin b8db66073f1 Set version placeholders to 1.68 b612b8acc3f Remove outdated cfg on `le32` f8172e15a66 Rollup merge of #107223 - ChayimFriedman2:patch-5, r=WaffleLapkin 543453d2025 Rollup merge of #106823 - m-ou-se:format-args-as-str-guarantees, r=dtolnay fe468538a43 Rollup merge of #106767 - chbaker0:disable-unstable-features, r=Mark-Simulacrum 8c8ab2d76d2 core: Support variety of atomic widths in width-agnostic functions 8834e7ca663 Guarantee the memory layout of `Cell` 193fe9a7890 impl DispatchFromDyn for Cell and UnsafeCell f6814f1d1b2 io: soften ‘at most one write attempt’ requirement in io::Write::write 9b5f463e42d `sub_ptr()` is equivalent to `usize::try_from().unwrap_unchecked()`, not `usize::from().unwrap_unchecked()`. eab25e1110e Rollup merge of #107109 - est31:thin_box_link, r=Mark-Simulacrum 7f437022f37 Merge from rustc e6065571f33 Document missing unsafe blocks 44c71bdb776 Rollup merge of #106854 - steffahn:drop_linear_arc_rebased, r=Mark-Simulacrum 5d2b7210168 Merge from rustc c0c54014405 Auto merge of #106981 - joboet:std_remove_box_syntax, r=thomcc 84dcf9ecdbe Print why a test was ignored if it's the only test specified. ab86bb66858 simplify layout calculations in rawvec 018e50556dd Flip scanning direction of stable sort 6cdaa6557c4 Unify insertion sort implementations 205f65e2454 Rollup merge of #107180 - nvzqz:rm-fmt-ref, r=joshtriplett f0a3f2791fc Rollup merge of #107114 - Erk-:add-absolute-note-to-path-join, r=m-ou-se ef4014b0cce Rollup merge of #106144 - tgross35:patch-1, r=Mark-Simulacrum 4b7293db9e3 Remove unnecessary `&format!` 98211f2321f debug assertions for `slice::split_at_unchecked`, `str::get_unchecked` 13c64e38e47 Add Arc::into_inner for safely discarding Arcs without calling the destructor on the inner type. eb8174b0950 library/std/sys_common: Define MIN_ALIGN for m68k-unknown-linux-gnu 02184ccb211 Use NonNull in merge_sort e9ed5db6192 Rollup merge of #104672 - Voultapher:unify-sort-modules, r=thomcc 0292d0aec96 add example of joining with a absolute path 7042efd20bd Add note about absolute paths to Path::join 5332e730011 ThinBox: Add intra-doc-links for Metadata 6eba2a2ba6b Rollup merge of #107067 - tmiasko:custom-mir-storage-statements, r=oli-obk 0802a477c22 Rollup merge of #107053 - devnexen:sigstringrepr_haiku, r=thomcc 7be43aa8ef9 Add `rustc_on_unimplemented` on `Sync` for cell types 0a5e5000ec7 Add `OnceCell: !Sync` impl for diagnostics e4ac13ae6ae Auto merge of #107064 - GuillaumeGomez:rollup-pbgu6r3, r=GuillaumeGomez 599a4948dd3 Custom MIR: Support storage statements ba7da687f58 Auto merge of #106989 - clubby789:is-zero-num, r=scottmcm d331145779b Transform async ResumeTy in generator transform c3083d1c869 Implement `SpecOptionPartialEq` for `cmp::Ordering` f1f31c96575 signal update string representation for haiku. 2f23b6af0e4 Update `IsZero` documentation b3ad54b282a Implement `alloc::vec::IsZero` for `Option<$NUM>` types ba48b3904bd Rollup merge of #106950 - the8472:fix-splice-miri, r=cuviper 804f87a4039 Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett 34b24e35288 Rollup merge of #103702 - WaffleLapkin:lift-sized-bounds-from-pointer-methods-where-applicable, r=m-ou-se 34c28f5667f Rollup merge of #106997 - Sp00ph:introselect, r=scottmcm 8d5a514d263 Rollup merge of #106992 - joboet:alloc_remove_box_syntax, r=thomcc ad6d0ac70d6 Add `vec_deque::IntoIter` benchmarks 0975f154663 Don't do pointer arithmetic on pointers to deallocated memory d29714930ff Rollup merge of #106889 - scottmcm:windows-mut, r=cuviper c31811acb8a Add heapsort fallback in `select_nth_unstable` 5e952e0afa3 refactor[alloc]: remove unused box syntax feature 0112d649068 Rollup merge of #106922 - ChayimFriedman2:patch-5, r=workingjubilee a768ebdcfdc Rollup merge of #106148 - chenyukang:yukang/fix-105061-unused, r=lcnr b5a8f6e9a18 refactor[std]: do not use box syntax 670c6493d0b Explain the "no-error" io::Error case 9153a349c67 Constify `TypeId` ordering impls 46173e427d9 implement Hash for proc_macro::LineColumn 22256d22849 Implement DoubleEnded and ExactSize for Take and Take 8e39a4adf32 Avoid unsafe code in `to_ascii_[lower/upper]case()` d570c134402 Rebuild BinaryHeap on unwind from retain 5c473d20e47 Add test showing broken behavior of BinaryHeap::retain bde4ba13b01 Auto merge of #106393 - the8472:use-ptr-sub, r=scottmcm 6847e1e2bc0 replace manual ptr arithmetic with ptr_sub da50dc37130 Auto merge of #105851 - dtolnay:peekmutleak, r=Mark-Simulacrum 2ba8f36bf4a Rollup merge of #106880 - tspiteri:borrowing-sub-typo, r=cuviper 611a4ea8275 Rollup merge of #106867 - sunfishcode:sunfishcode/std-os-fd-stable-version, r=m-ou-se e0d313f5741 Mention the lack of `windows_mut` in `windows` ebaecc1bb30 Document guarantees about BinaryHeap invariant 31cca48cadb Leak amplification for peek_mut() to ensure BinaryHeap's invariant is always met c28416fad17 Add test of leaking a binary_heap PeekMut fb964a7c5c4 doc: fix typo c4463b08e97 Fix the stability attributes for `std::os::fd`. 2aa418d11d9 Rollup merge of #106860 - anden3:doc-double-spaces, r=Dylan-DPC 1ab44ea776d Rollup merge of #106661 - mjguzik:linux_statx, r=Mark-Simulacrum 42db313065c Rollup merge of #105526 - Xiretza:iter-from-generator-derive, r=scottmcm 771e9dad7da Fix some missed double spaces. 6793f40a67d Remove various double spaces in source comments. 845813c74ca Re-add #[allow(unused)] attr db49ceb75ad Use associated items of `char` instead of freestanding items in `core::char` 4d24da8f1a8 fix issues in unused lint c35ae972704 remove optimistic spinning from `mpsc::SyncSender` 96a6436f6c8 Rollup merge of #106799 - scottmcm:remove-unused-generics, r=cuviper 0c2f26d066b Rollup merge of #106762 - WaffleLapkin:atomicptr+as_mut_ptr, r=m-ou-se 04c35bc6737 Rollup merge of #106692 - eggyal:mv-binary_heap.rs-binary_heap/mod.rs, r=Mark-Simulacrum 1610bdea33a Rollup merge of #105172 - alexs-sh:issue-98861-fix-next, r=scottmcm 5b4f36f4935 Rollup merge of #104965 - zacklukem:p-option-as_ref-docs, r=scottmcm ce43e690ecf Allow fmt::Arguments::as_str() to return more Some(_). 4f54c69c86a Rollup merge of #106701 - ibraheemdev:sync-sender-spin, r=Amanieu e5ade48610c Stop having unused lifetimes on some `impl`s ddbcccb6206 Implement `signum` with `Ord` c6b9a19f5d5 Auto merge of #106004 - fee1-dead-contrib:const-closures, r=oli-obk 28841ea1f11 Rollup merge of #106740 - petar-dambovaliev:float-iterator-hint, r=Nilstrieb 0eb7e45e3f4 Rollup merge of #106446 - bzEq:fix-unwind-lsda, r=Amanieu 0862efdb21a Avoid __cxa_thread_atexit_impl on Emscripten 414d31c346c add note for float iterator 636d03db2fd Auto merge of #106760 - compiler-errors:rollup-0bogyco, r=compiler-errors d332ba1a526 Allow setting CFG_DISABLE_UNSTABLE_FEATURES to 0 b1551d08efd Make `// SAFETY` comment part of the doctest, and not surrounding code 2e0628442e4 Remove unused `mut` from a doctest b6e6cdd7ab4 Add `AtomicPtr::as_mut_ptr` 275d6f26507 Rollup merge of #106323 - starkat99:stabilize-f16c_target_feature, r=petrochenkov de87187772b Rollup merge of #103800 - danielhenrymantilla:stabilize-pin-macro, r=dtolnay f3c9fd1ecd3 Rollup merge of #103236 - tspiteri:redoc-int-adc-sbb, r=m-ou-se c04ae9700db Rollup merge of #106638 - RalfJung:realstd, r=thomcc 518f6115035 rework and document backoff behavior of `sync::mpsc` 0a38a1b35f3 test use in libcore c1f1b2a3663 Make core::fmt::rt::v1::Argument::new const+inline. 759633f0e9b Improve proc macro attribute diagnostics e8368f6de51 Stabilize `::{core,std}::pin::pin!` e732ce12f42 Add new fn to core::fmt::rt::v1::Argument. 148d3ff2061 Turn format arguments types into lang items. dbcabce5f0d Stop probing for statx unless necessary 72dd6481124 Rollup merge of #106664 - chenyukang:yukang/fix-106597-remove-lseek, r=cuviper 704613905a2 Rollup merge of #106570 - Xaeroxe:div-duration-tests, r=JohnTitor 450793de570 Change `src/test` to `tests` in source files, fix tidy and tests eb11301212d Rollup merge of #106662 - Ezrashaw:specialize-bool-tostring, r=cuviper 4be43dc7611 Rollup merge of #106635 - RalfJung:std-test-nits, r=thomcc d6c68047eaf add `SyncSender::send_timeout` test 9d4c71bc763 fix `SyncSender` spinning behavior 0c5b007ff6c mv binary_heap.rs binary_heap/mod.rs 28fffdc44f1 use with_capacity in read read_to_string 1be62288c3d impl: specialize impl of `ToString` on `bool` 604652abf8a Rollup merge of #105034 - HintringerFabian:improve_iterator_flatten_doc, r=cuviper d093a683075 std tests: use __OsLocalKeyInner from realstd 026610e98ab Add comment 3159706db32 Move to intepret_cs_action 87528e2830a Add comments 9658f1d558a std test: better type name, clarifying comment fb10b7f87c2 Also check ttype_index when using SJLJ 0afbc5d17aa Remove unstable feature 72ec8adf417 Stabilize `nonzero_min_max` 2964e7b01a6 Relocate changes 7281f549277 Disable `linux_ext` in wasm32 and fortanix rustdoc builds. aacfe2b86f6 Rollup merge of #106584 - kpreid:vec-allocator, r=JohnTitor 366c1b7fece Rollup merge of #104163 - H4x5:once-repeat-with-debug, r=dtolnay f062d30ae13 Auto merge of #90291 - geeklint:loosen_weak_debug_bound, r=dtolnay 56f94124a1e Change memory ordering in System wrapper example fae01f793fb Rollup merge of #106562 - clubby789:vec-deque-example, r=Mark-Simulacrum eb4f40667e6 Rollup merge of #103104 - SUPERCILEX:sep-ref, r=dtolnay 97156f4eabe Auto merge of #104658 - thomcc:rand-update-and-usable-no_std, r=Mark-Simulacrum 31f29ca35a8 Document that `Vec::from_raw_parts[_in]` must be given a pointer from the correct allocator. c33c24335b5 Remove unnecessary lseek syscall when using std::fs::read 51aaf7d76ca Improve the documentation of `black_box` 25d4df6c909 Rollup merge of #106564 - Folyd:feat-repeatn, r=scottmcm aa0b8dc1002 Rollup merge of #106553 - Ezrashaw:fix-hashset-doctest, r=JohnTitor 6a67a2df20a Rollup merge of #105128 - Sp00ph:vec_vec_deque_conversion, r=dtolnay 20669e703a0 Rollup merge of #104081 - joshlf:patch-6, r=dtolnay 93fdd9bee30 Don't derive Debug for `OnceWith` & `RepeatWith` 252d1892d52 add tests for div_duration_* functions f550beb8baa Change to immutable borrow when cloning element of RepeatN ad2c86f98ce Clarify examples for `VecDeque::get/get_mut` b820059cbdc docs: make `HashSet::retain` doctest more clear a7e64420cc0 Rollup merge of #106453 - coastalwhite:master, r=GuillaumeGomez ca47a593ab3 Remove HTML tags around warning e46fb0e3eff Better phrasing for hygiene of include macro 7d7a5e3db86 Update rand in the stdlib tests, and remove the getrandom feature from it 0d1fa2306f0 Rollup merge of #106461 - notriddle:notriddle/window-searchstate-focus, r=GuillaumeGomez 9000b4df9db Rollup merge of #106398 - jyn514:fix-clippy, r=thomcc 7be07a137b1 docs: fix broken link "search bar" 3b54cbba958 Link to Option/Result for `Iterator::sum/product` fe3e005caf8 Tidy up whitespace c7b8e270eb6 Improve include macro documentation d98b91aad54 Auto merge of #106239 - LegionMammal978:thin-box-drop-guard, r=Amanieu 0eaf29aeeba [LSDA] Take ttype_index into account when taking action 5282cdb8849 Rollup merge of #106327 - gimbles:dbg, r=jyn514 06f5f5ef244 Rollup merge of #106200 - compiler-errors:suggest-impl-trait, r=estebank 5598d1864b9 relax reference requirement on from_abstract_name 1973e29a36c Rollup merge of #106045 - RalfJung:oom-nounwind-panic, r=Amanieu 9e90828b6fe Suggest more impl Trait on `-> _` bf5e13c5ecd Make ExitStatus an inhabited type on all platforms 8a93609ce2d Fix a few clippy lints in libtest 0a83e399ecc Added error documentation for write_fmt 13539facf01 Auto merge of #95644 - WaffleLapkin:str_split_as_str_refactor_take2, r=Amanieu a528483adfc Rollup merge of #104298 - tbu-:pr_set_extension_caveats, r=m-ou-se d2db6f15ef3 Remove test of static Context 18b44a63e5a Add PhantomData marker to Context to make Context !Send and !Sync 9f828ff4580 default OOM handler: use non-unwinding panic (unless -Zoom=panic is set), to match std handler ae33c6f880c improve wording of `thread::park` docs 97600536d39 Deallocate ThinBox even if the value unwinds on drop 475c14e030c Document a way to limit read_line length 207490a8991 Document read_line gotcha c2a42d6abcc Rollup merge of #106280 - Ezrashaw:path-join-docs-better, r=thomcc fb8cc6bc513 Auto merge of #106275 - Nilstrieb:const-eval-select-me-some-compile-time, r=thomcc 79aba39ffb9 Add tidy check for dbg 39cd7161e8c std: use id-based thread parking on SOLID 1842f181e33 Rollup merge of #106248 - dtolnay:revertupcastlint, r=jackh726 32319e32eda Rollup merge of #105903 - joboet:unify_parking, r=m-ou-se 390f2505fb0 Stabilize f16c_target_feature 20448a88e62 Add notes and examples about non-intuitive `PathBuf::set_extension` behavior 3f396f8f43b Auto merge of #105651 - tgross35:once-cell-inline, r=m-ou-se dc0ff892fbf Auto merge of #106296 - matthiaskrgr:rollup-ukdbqwx, r=matthiaskrgr 3b5af66a120 Rollup merge of #104182 - gabhijit:ipv6-in6addr-any-doc-fix, r=m-ou-se 70c16644935 Rollup merge of #103707 - jonathanCogan:master, r=m-ou-se a8de02a48ec Rollup merge of #99244 - gthb:doc-improve-iterator-scan, r=m-ou-se 0cf4ca03d6c Use some more `const_eval_select` in pointer methods for compile times dde783f8724 std: remove unnecessary `#[cfg]` on NetBSD 06df9c46988 std: rename `Parker::new` to `Parker::new_in_place`, add safe `Parker::new` constructor for SGX 76ef6290ef4 Update paths in comments. 985605ad690 Replace libstd, libcore, liballoc in line comments. 29949f0a2b8 Replace libstd, libcore, liballoc in docs. fd7bd831d33 Auto merge of #105426 - flba-eb:fix_tls_destructor_unwinding, r=m-ou-se 7f4bb408287 docs: add link to `Path::join` in `PathBuf::push` 948126bc1c7 Auto merge of #106210 - fee1-dead-contrib:const-closure-trait-method, r=compiler-errors b1975d36e5a std: pass hint to id-based parking functions 7a26383b378 std: unify id-based thread parking implementations 79b6df74f7f update stdarch 447e47e02aa Revert "Implement allow-by-default multiple_supertrait_upcastable lint" f50187cd5d9 Auto merge of #105590 - solid-rs:patch/kmc-solid/thread-lifecycle-ordering, r=m-ou-se bf41b3a0c28 Implement more methods for `vec_deque::IntoIter` 4896e4313ae Auto merge of #105741 - pietroalbini:pa-1.68-nightly, r=Mark-Simulacrum 8a544d1ea02 Rollup merge of #106161 - meithecatte:iter-find-position, r=Mark-Simulacrum 73be084d889 Rollup merge of #105998 - RalfJung:no-unwind-panic-msg, r=thomcc e9f070aa0a3 Rollup merge of #105497 - albertlarsan68:doc-panic-hook-and-catch-unwind, r=m-ou-se 710e36991f6 Rollup merge of #105359 - flba-eb:thread_local_key_sentinel_value, r=m-ou-se 126aab3bb02 Rollup merge of #104493 - adamncasey:cgroupzeroperiod, r=m-ou-se 1ff475d8afe Rollup merge of #104402 - joboet:sync_remutex, r=m-ou-se bfea0b46ccd Catch panics in destruction of TLS values 991b6a3fc90 Clarify catch_unwind docs about panic hooks faf4063e583 fix custom mir doc tests 1a73229ce02 fix documenting private items of standard library 9abf139ed96 delete more `cfg(bootstrap)` 5bd0c6c0b1b Update bootstrap cfg b5b383bd7fa update stabilization version numbers 54709de6acf Rollup merge of #106172 - estebank:suggest-impl-trait, r=compiler-errors a17a776a138 Auto merge of #106209 - fee1-dead-contrib:rollup-47ysdcu, r=fee1-dead 3d025c3dc7f adjust message on non-unwinding panic bd023a4a6c7 Allow trait method paths to satisfy const Fn bounds 1142dc65059 Rollup merge of #106184 - albertlarsan68:docs-106154, r=Nilstrieb 9fc5326fe80 Rollup merge of #105484 - nbdd0121:upcast, r=compiler-errors 82d6d9467df Rollup merge of #104708 - jonasspinner:fix-backoff-doc-to-match-implementation, r=compiler-errors 38c2ba2f875 Rollup merge of #104024 - noeddl:unused-must-use, r=compiler-errors 91a90d36fed Rollup merge of #103945 - H4x5:remove-iter-empty-hack, r=compiler-errors 5c8c602cef3 Rollup merge of #94145 - ssomers:binary_heap_tests, r=jyn514 61f88fd4de2 Auto merge of #103881 - ChayimFriedman2:patch-2, r=compiler-errors d4f96b1c591 Auto merge of #100539 - joboet:horizon_timeout_clock, r=thomcc b384b093a18 Auto merge of #106193 - compiler-errors:rollup-0l54wka, r=compiler-errors cb411b87ce4 Fix `core::any` mod-level docs aea4f346a75 Rollup merge of #106189 - alexhrao:master, r=Nilstrieb 391690170ed Rollup merge of #106187 - ChayimFriedman2:patch-4, r=compiler-errors f5a5bb72823 Rollup merge of #106179 - RetroSeven:typo_fix, r=compiler-errors 523b1f96798 Rollup merge of #103718 - matklad:infer-lazy, r=dtolnay 4d7ae944ea3 Fix UnsafeCell Documentation Spelling Error ccba47d0eed Auto merge of #97176 - kraktus:cmd_debug, r=the8472 bfac8f6650d Update the documentation of `Vec` to use `extend(array)` instead of `extend(array.iter().copied())` 18d0d199952 Fix a formatting error 3eeb949c721 More verbose `Debug` implementation of `std::process:Command` 766cc6658db Suggest `impl Iterator` when possible for `_` return type a22826aea3c Iterator::find: link to Iterator::position in docs for discoverability 0ca3d511770 Auto merge of #105997 - RalfJung:immediate-abort, r=eholk ff69352cd11 Auto merge of #106112 - RalfJung:into-iter, r=thomcc 71a3cc0048e Auto merge of #104977 - RalfJung:ptr-from-ref, r=dtolnay 1905fec3f91 Auto merge of #106111 - matthiaskrgr:rollup-nnpoe5h, r=matthiaskrgr 9656c90b826 add tracking issue, fix typo e0a0ec5d984 add lib tests for vec::IntoIter alignment issues 8a50b8694d4 Rollup merge of #106032 - mcha-forks:lfs-musl-fix, r=thomcc 29332cf6259 Auto merge of #106081 - mina86:c, r=Mark-Simulacrum 08bebae2aed fix one more unaligned self.ptr, and add tests 8b12727a3f2 fix IntoIter::drop on high-alignment ZST 107d01d0af6 char: µoptimise UTF-16 surrogates decoding 21e91903c2e Stop at the first `NULL` argument when iterating `argv` 60aa8409dbd abort immediately on bad mem::zeroed/uninit e9577096023 std: only use LFS function on glibc 3b409161746 Auto merge of #106025 - matthiaskrgr:rollup-vz5rqah, r=matthiaskrgr 75f997bd248 Auto merge of #106023 - JohnTitor:rollup-k8mettz, r=JohnTitor 636c9c5d75b Rollup merge of #106012 - JakobDegen:retag-raw, r=RalfJung a228b9c8120 Rollup merge of #105960 - oli-obk:effect_cleanup, r=fee1-dead a452e34266e Rollup merge of #105980 - goffrie:waker-drop, r=thomcc f8b7235eceb Rollup merge of #105824 - zacchiro:patch-1, r=JohnTitor 82725ed7bcf Rollup merge of #105584 - raffimolero:patch-1, r=JohnTitor 187c0d3c192 Auto merge of #105613 - Nilstrieb:rename-assert_uninit_valid, r=RalfJung 287816c120e Clarify that raw retags are not permitted in Mir 05971cc4f5c Auto merge of #100390 - jhpratt:float-from-bool, r=dtolnay 39fe1654f09 less specific wording baa3226f321 Refer to "Waker" rather than "RawWaker" in `drop` comment b5b25ad8d49 Auto merge of #105127 - Sp00ph:const_new, r=dtolnay b8c5fcbd93c Auto merge of #105381 - uweigand:s390x-ffi-vaarg, r=nikic 11c66c1f43e Stabilize path_as_mut_os_str 6a112a5e479 Fix some `~const` usage in libcore aa9bf5675a9 Update coerce_unsized tracking issue from #27732 to #18598 ee69187481f Implement va_list and va_arg for s390x FFI af92c1904d2 Rollup merge of #105915 - andrewpollack:revert-105250-async-rm-resumety, r=tmandry 53ac79b40ba Rollup merge of #105902 - vincenzopalazzo:macros/pin_docs, r=eholk 4719ffed3f6 Rollup merge of #105801 - zertosh:path_mut_os_str_doc_test, r=dtolnay a6ecf451365 Revert "Replace usage of `ResumeTy` in async lowering with `Context`" 5b2e57fbfb0 Auto merge of #105698 - joboet:unsupported_threads_once, r=thomcc 63adc7bc2f4 docs: improve pin docs 31521053508 Rollup merge of #105889 - Nilstrieb:fmt-libtest, r=thomcc 940bdffd10b Rollup merge of #105682 - thomcc:expose-ptr-fmt, r=RalfJung 0e66d488e6e Fix `uninlined_format_args` in libtest 469daa33d86 Rollup merge of #105858 - scottmcm:extra-as-chunks-example, r=the8472 f0dc6ec07a8 Auto merge of #105638 - tavianator:fix-50619-again, r=Mark-Simulacrum 24ddcbf7abd Another `as_chunks` example 0341cb6ee4b Rollup merge of #105836 - evanj:fmt-doc-use-variables, r=Mark-Simulacrum 9011f5e4383 Rollup merge of #105814 - JakobDegen:custom-mir-terms, r=oli-obk 7ffc2382ac9 Rollup merge of #105458 - Ayush1325:blocking_spawn, r=Mark-Simulacrum 493822813c6 std::fmt: Use args directly in example code f610be3b744 str.lines() docstring: clarify that line endings are not returned 198acf9d1c0 Auto merge of #105794 - ChrisDenton:internal-doc, r=jyn514 9083618b9e4 Support call and drop terminators in custom mir 3b99d98bd02 Realistic `Path::as_mut_os_str` doctest 9d56a907e54 Fix intra-doc link d51e5a55e9c Auto merge of #105018 - zertosh:path_buf_deref_mut, r=dtolnay 4313f2a9df9 Replace `Split*::as_str` with `remainder` 6894fcefb76 Rollup merge of #105748 - hakoerber:master, r=Dylan-DPC ebd3e51940b SplitInternal: always set `finished` in `get_end` e098b6ecc3d Auto merge of #105356 - JakobDegen:more-custom-mir, r=oli-obk 921bee11f27 doc: Fix a few small issues e4abcec3e67 Implement `From` for f32, f64 ecdb2326fe5 Rollup merge of #105598 - RalfJung:more-comments, r=the8472 9cfc52974f1 Rollup merge of #105399 - mikebenfield:lfs, r=thomcc d4c322f8cb2 fs/tests: Fail fast on duplicate errors rather than looping indefinitely 98ecf95a4e9 fs/tests: Explicitly kill the zombie rather than sleeping until it dies 141c87915d6 std: use a more efficient `Once` on platforms without threads f3ee441e5ea Auto merge of #105690 - matthiaskrgr:rollup-khtq97k, r=matthiaskrgr e203d2fe11c Rollup merge of #105642 - uberFoo:master, r=Dylan-DPC 57c12af466c Rollup merge of #105523 - estebank:suggest-collect-vec, r=compiler-errors 8b3df382c36 Address documentation suggestions 56cfbd6a8c5 Add documentation for custom mir 5696a3186bf Support more projections in custom mir 15fcdf8d2ea Support common enum operations in custom mir 866885db058 Use `expose_addr()` in `fmt::Pointer` 04f42ea0b73 Improve wording for Option and Result 0d2962b67f1 Add docs for question mark operator for Option 289bea66a8b Suggest `collect`ing into `Vec<_>` f687ef43b27 Rename `assert_uninit_valid` intrinsic 41378c9db68 Add result example + rewording 8d80f15580f Add #[inline] marker to OnceCell/LazyCell/OnceLock/LazyLock 32bf00b7226 Minor grammar nit. be7cc3ef247 fs: Fix #50619 (again) and add a regression test fb4ced0a6d4 explain mem::forget(env_lock) in fork/exec 6f08e1b959f Rollup merge of #105616 - est31:add_the, r=Dylan-DPC 654f1d6d21e Add a "the" to proc_macro documentation c0645768a78 Correct typos in `core::sync::Exclusive::get_{pin_mut, mut}` 8353eae7fca kmc-solid: Synchronize with the read when sending a joining task ID to a joinee 3acc75094c4 kmc-solid: Synchronize the first update of `ThreadInner::lifecycle` with the second one on detach 8108d725eb7 add assert messages if chunks/windows are length 0 e2d5076bf61 Rollup merge of #101648 - Timmmm:home_dir_docs, r=joshtriplett 6dceb2287ae Auto merge of #105508 - eduardosm:ptr-methods-inline-always, r=Mark-Simulacrum e537c83ea24 Remove some `cfg(not(bootstrap))` 94c54a5ea69 Use rint instead of roundeven d15a262929f Add tracking issue c5381347be9 Add `round_ties_even` to `f32` and `f64` 5b69942844d Implement blocking output 2c8235f24c3 Rollup merge of #105460 - mkroening:compiler-builtins-0.1.85, r=Mark-Simulacrum f876c90195f Rollup merge of #103146 - joboet:cleanup_pthread_condvar, r=Mark-Simulacrum bd29ad4fdb1 Rollup merge of #105239 - gh2o:no-heap-alloc-on-thread-start, r=cuviper c9d32524e46 libcore: make result of iter::from_generator Clone 9dc1129ae0b libcore: make result type of iter::from_generator concrete 8f444644612 Rollup merge of #105522 - est31:remove_or_and_note, r=scottmcm 6e3bd6626a4 Rollup merge of #104901 - krtab:filetype_compare, r=the8472 83538eae29f Rollup merge of #98391 - joboet:sgx_parker, r=m-ou-se f08a25c992d Correct wrong note for short circuiting operators 60bc37f01ac Rollup merge of #105453 - scottmcm:vecdeque_from_iter, r=the8472 e93da135683 Rollup merge of #105265 - aDotInTheVoid:sum-product-on-unimplemented, r=estebank 79e8632f82b Make `<*{const,mut} T>::{,wrapping_}sub` methods `#[inline(always)]` 0b26f3dddf5 Auto merge of #105262 - eduardosm:more-inline-always, r=thomcc 84cfa4d86f3 Replace hand-made masking by call to masked() method in FileType 1b27f35a356 Rollup merge of #105474 - RalfJung:typo, r=dtolnay 3d2a0aad8a8 Rollup merge of #105245 - RalfJung:align_to, r=Amanieu af17dd99761 Apply review feedback; Fix no_global_oom_handling build 28310216599 Implement allow-by-default multiple_supertrait_upcastable lint 89dcb5cba58 Add `rustc_on_unimplemented` to `Sum` and `Product` trait. 7fe85e85589 lib docs: fix typo 26c722d28c2 Bump compiler-builtins to 0.1.85 9053bcf3bde Add read_to_end for AnonPipe d564f540198 Rollup merge of #105434 - nbdd0121:lib, r=thomcc 5c8f7074445 Rollup merge of #105120 - solid-rs:patch/kmc-solid/maintainance, r=thomcc 33ed23eba99 Make `VecDeque::from_iter` O(1) from `vec(_deque)::IntoIter` 4c099be22ea Fix warning when libcore is compiled with no_fp_fmt_parse 3156648aa7a Avoid heap allocation when truncating thread names 57b7c895bc5 Use more LFS functions. 782fb4a0901 Make some trivial functions `#[inline(always)]` 623cfa47647 Auto merge of #103459 - ChrisDenton:propagate-nulls, r=thomcc ab833ebef61 Auto merge of #104799 - pcc:linkage-fn, r=tmiasko 402d6061e1f Auto merge of #105271 - eduardosm:inline-always-int-conv, r=scottmcm 6f96ddbd436 Don't set `STARTF_USESTDHANDLES` if none are set 8568dec8cf8 Rollup merge of #105250 - Swatinem:async-rm-resumety, r=oli-obk 9f45ac230a3 Rollup merge of #105243 - RalfJung:no-op-let, r=Mark-Simulacrum 526c82afb81 Implement masking in FileType hashing on Unix f30f63d2e67 Replace usage of `ResumeTy` in async lowering with `Context` 610314f8957 Make sentinel value configurable 5a53a12d9f5 Rollup merge of #105289 - Rageking8:fix-dupe-word-typos, r=cjgillot 92789631afe Reimplement weak! using Option. 4c3e924d8f8 Rollup merge of #105222 - devnexen:fbsd_update_img, r=petrochenkov 993c51301fb Rollup merge of #104912 - RalfJung:per, r=Mark-Simulacrum 84c77ef1ca0 Add O(1) `Vec -> VecDeque` conversion guarantee 3d20df34ac3 attempt to clarify align_to docs 7a84e1c0ca3 Auto merge of #105046 - scottmcm:vecdeque-vs-vec, r=Mark-Simulacrum a873080b889 fix dupe word typos d3a99bc6d62 Make integer-to-integer `From` impls `#[inline(always)]` 3a4b65fa1ae remove no-op 'let _ = ' a0375080bad Auto merge of #101514 - nvzqz:nvzqz/stabilize-nonzero-bits, r=thomcc 54e79fbf286 std update libc version and freebsd image build dependencies fda07dd8b07 Rollup merge of #105153 - oli-obk:fail_faster, r=compiler-errors f0bda0c1170 Rollup merge of #105100 - jhpratt:fix-docs, r=JohnTitor efa1b4db0ad Rollup merge of #105032 - HintringerFabian:improve_docs, r=JohnTitor 25fc8cfc63b Auto merge of #104999 - saethlin:immediate-abort-inlining, r=thomcc 011f6746214 Windows: make Command prefer non-verbatim paths 607073dab37 std: cleanup timeouts in pthread condvar c820cdeb548 kmc-solid: Don't do `Box::from_raw(&*(x: Box) as *const T as *mut T)` 50e321d7d35 Rollup merge of #105137 - yjhn:patch-1, r=Dylan-DPC e65e4573afd Rollup merge of #105126 - Sp00ph:const_new_in, r=dtolnay 7eca7febd85 Rollup merge of #104614 - Nilstrieb:type-ascribe!, r=TaKO8Ki 306c766eee8 Create a hacky fail-fast mode that stops tests at the first failure 400dcf89afb Add tracking issue for file_create_new 1f67f7b82b9 Fix typo in comment 2af5eac80c1 Make `VecDeque::new` const 826e84627e3 Make `VecDeque::new_in` unstably const d3f1a85d42c Auto merge of #104975 - JakobDegen:custom_mir_let, r=oli-obk e6185dc8bae Gate macros behind `#[cfg(not(bootstrap))]` 0e59f38d312 kmc-solid: Address compiler warnings 5df39e16db5 kmc-solid: Add a stub implementation of `is_terminal` aac5cbfb9b1 kmc-solid: Use `expose_addr` and `from_exposed_addr` for pointer-integer casts cf6847c2855 Auto merge of #104160 - Ayush1325:windows-args, r=m-ou-se 0d7699b01fb Add test for regression for FileType equality 414eaf6f885 Add missing intra-doc link c55cbb5c912 Clarify that copied allocators must behave the same 6b98f66bc36 Rollup merge of #104811 - haraldh:feat/wasm32_wasi_shutdown, r=joshtriplett 92dead6e75a Support statics in custom mir 174ee2f02b3 Support most constant kinds in custom mir 60ee62d9cc1 Support arbitrary `let` statements in custom mir a3245c9eacc Add in the comment that solaris lacks also the 'linkat' e5f79ba64c4 Rollup merge of #105049 - mkroening:hermit-fixes, r=jyn514 1b20ec97e4d Rollup merge of #105002 - zertosh:acp-140, r=dtolnay 9ab53ab7282 Rollup merge of #104436 - ismailmaj:add-slice-to-stack-allocated-string-comment, r=Mark-Simulacrum 75b7f6c590d Adjust inlining attributes around panic_immediate_abort 4f0bbefbea4 hermit: Remove unused exports 28e25ce3f89 hermit: Fix fuzzy_provenance_casts 8fb07995026 Send `VecDeque::from_iter` via `Vec::from_iter` 2f7354ad37a Add example for iterator_flatten 28f90f0eb15 improve doc 8112625f27d Add `as_mut_os_string` to `&mut PathBuf` and `as_mut_os_str` to `&mut Path` 34156057073 Implement DerefMut for PathBuf 9138bfdc1e7 Extract WStrUnits to sys_common::wstr 2efe92fb0ca Auto merge of #102991 - Sp00ph:master, r=scottmcm 3221f2e1334 linkat() not available in the system headers of Solaris 10 fdb9f1f78ad Rollup merge of #104934 - ChrisDenton:all-anybody-wants, r=thomcc ac74dc3ef61 Rollup merge of #104892 - lukas-code:discriminant, r=scottmcm 203b2d99c0d add ptr::from_{ref,mut} 34023f7c8d8 add link for string to as_ref docs 1631dd56ec6 Auto merge of #104818 - scottmcm:refactor-extend-func, r=the8472 45bb408d0b0 reword Option::as_ref and Option::map examples 053e206751f Add second test case in `make_contiguous_head_to_end` 30f5a9aaa6c Improve slow path in `make_contiguous` 1deb64681fd fix broken link fragment fba6c0e5b3e explain how to get the discriminant out of a `#[repr(T)] enum` f0718f86971 Auto merge of #104935 - matthiaskrgr:rollup-nuca86l, r=matthiaskrgr 7e75987d644 Rollup merge of #104839 - HintringerFabian:docs_array_from_fn, r=scottmcm cd1056d989f Remove redundant `all` in cfg dd98d8e43bf Auto merge of #103556 - clubby789:specialize-option-partial-eq, r=scottmcm 6415c4ef784 Don't use `Take` in `SpecExtend` impl 40711ddd804 PERs are homogeneous caa87c6078a Implement masking in FileType comparison on Unix 9b5d6495c3e Rollup merge of #104873 - RalfJung:therefore, r=Dylan-DPC 8dfeb688744 Rollup merge of #104654 - thomcc:alloc-tests-unsafe_op_in_unsafe_fn, r=Mark-Simulacrum fa137a0aec5 change example of array_from_fn to match suggestion c05388612f1 RefCell::get_mut: fix typo 73e372d895e Auto merge of #104855 - thomcc:revert-noinline-wintls, r=ChrisDenton 1220f5d4fd1 Tune RepeatWith::try_fold and Take::for_each and Vec::extend_trusted 7785fb5d4c0 Changes according to code review 1612e2796f6 Revert "Forbid inlining `thread_local!`'s `__getit` function on Windows" 8f0787a155e Rollup merge of #104774 - vojtechkral:doc-str-empty-split-whitespace, r=thomcc df4d64d17e3 improve array_from_fn documenation 63b223adb71 Document split{_ascii,}_whitespace() for empty strings 8efe86f3085 Stop peeling the last iteration of the loop in `Vec::repeat_with` 8f61452332d Extract the logic for `TrustedLen` to a named method that can be called directly e09d786d7ab feat: implement TcpStream shutdown for wasm32-wasi b6f32a6fb9e Avoid `GenFuture` shim when compiling async constructs c05acc03139 Add `#![deny(unsafe_op_in_unsafe_fn)]` in liballoc tests 8c1972c807e Rollup merge of #104647 - RalfJung:alloc-strict-provenance, r=thomcc 87a9bbc610a Auto merge of #104743 - JohnTitor:rollup-9z9u7yd, r=JohnTitor 60f87920acd Rollup merge of #101368 - thomcc:wintls-noinline, r=ChrisDenton 47d101c1d14 fix OOB access in SIMD impl of str.contains() 4670f77ee35 add test for issue 104726 832f7ae5993 Rollup merge of #104710 - RalfJung:doc-strict-provenance, r=thomcc dafcbd7cb67 Rollup merge of #104464 - mati865:reduce-eh-overallocation-amd64, r=thomcc bcb7603e3d0 disable strict-provenance-violating doctests in Miri 3c9f2e38baa Forbid inlining `thread_local!`'s `__getit` function on Windows 7d345e9c1ee rustdoc: Fix backoff doc to match implementation 59bb77e1768 Rollup merge of #103193 - krasimirgg:sysonce, r=Amanieu 91d1d0fafe9 Rollup merge of #102207 - CraftSpider:const-layout, r=scottmcm c15cc5983a7 Rollup merge of #101655 - dns2utf8:box_docs, r=dtolnay ab38fd5f45f Rollup merge of #95583 - scottmcm:deprecate-ptr-to-from-bits, r=dtolnay e572c18a44e Rollup merge of #83608 - Kimundi:index_many, r=Mark-Simulacrum c001af9c8cd Touch up Box one-liner 80157fb652c Rustc_deprecated attribute superseded by deprecated 0dd0129fc2e Bump ptr_to_from_bits deprecation to Rust 1.67 87563cc3c62 Rollup merge of #104692 - chbaker0:libtest-cfg-if, r=thomcc ba2c6ad4c5e Rollup merge of #103396 - RalfJung:pinning-closure-captures, r=dtolnay e31acdd0b21 Update test's cfg-if dependency to 1.0 2dc30c1857c dont attempt strict provenance in SGX 53fcb5573b7 Document all unsafe blocks d92addacddb Remove debug unused 462be640c36 Rollup merge of #104420 - TethysSvensson:master, r=JohnTitor f2840c9e283 type annotate &str when stack allocating a string 8eb541f17bd reflow the stack size story 5c9d694cb3f Rollup merge of #104643 - pnkfelix:examples-for-chunks-remainder, r=scottmcm 4bf866a16b8 Rollup merge of #104641 - tshepang:grammar, r=Mark-Simulacrum e5903632bf7 Rollup merge of #104634 - RalfJung:core-arch, r=Mark-Simulacrum 40ce1868589 Rollup merge of #104632 - RalfJung:core-test-strict-provenance, r=thomcc ea37006bafa Rollup merge of #104461 - mati865:gnullvm-aarch64-fixup, r=Mark-Simulacrum 99e3b42d26c Rollup merge of #101310 - zachs18:rc_get_unchecked_mut_docs_soundness, r=Mark-Simulacrum c4877fd2ee8 Only one feature gate needed 6e85d777e68 Use ? instead of match 4db67b2353c Fix issue number f4a9db9b92c Add derive_const feature 39c5fbb4b18 Update with derive_const 8833ca74226 Add stability for alignment 184a0ab45ee constify remaining layout methods 1ee206aa17b Unify stable and unstable sort implementations in same core module 3c574a20ce3 enable fuzzy_provenance_casts lint in libstd a8afa611ac7 enable fuzzy_provenance_casts lint in liballoc 203a4c879c9 Rollup merge of #104568 - RalfJung:realloc, r=Amanieu 75f16153d37 Rollup merge of #104558 - thomcc:unalign-diriter, r=ChrisDenton c9f29322d87 Rollup merge of #104537 - HintringerFabian:docs_default_min_stack_size, r=the8472 f806dd9ede3 add examples to chunks remainder methods. Also fixed some links to rchunk remainder methods. ef39bfd81fc Add get_many_mut methods to slice 7eb777c9fe2 replace unusual grammar 79f0dfb2512 enable fuzzy_provenance_casts in libcore+tests 801296e197f Update VecDeque implementation a5ec2ec610c Auto merge of #104617 - RalfJung:miri, r=RalfJung 820b5f86e98 Incorporate review feedback 0f46475d769 cfg(miri) no longer needed in sys/unix/time.rs 7c3dd2b51c5 move core::arch into separate file 5b66995efa6 Improve documentation of Stack size bd08a0b5d79 avoid non-strict-provenance casts in libcore tests 805f47ef7bb Auto merge of #98914 - fee1-dead-contrib:min-deref-patterns, r=compiler-errors be7cc2b0f49 Rollup merge of #104435 - scottmcm:iter-repeat-n, r=thomcc 9dc1973375c Rollup merge of #104112 - yancyribbens:add-copy-to-repeat-description, r=JohnTitor 5fc99d6aacf Rollup merge of #103901 - H4x5:fmt-arguments-as-str-tracking-issue, r=the8472 4210966e067 Add unstable `type_ascribe` macro bb5f89e3d6c Auto merge of #102795 - lukas-code:constify-is-aligned-via-align-offset, r=oli-obk 970a6d74595 update provenance test fb5a4a4fd83 Update comment on pointer-to-usize transmute dcc8eedd00c Revert "don't call `align_offset` during const eval, ever" 4e62b3077fc fix const `align_offset` implementation cfc06b3baf8 docs cleanup 44acb3e6887 always use `align_offset` in `is_aligned_to` + add assembly test f9617f3b5a4 Schrödinger's pointer 5952ef0df90 address more review comments 5340a83f209 document `is_aligned{,_to}` f2dfe166d1e don't call `align_offset` during const eval, ever 4743fca4ba5 mark `align_offset` as `#[must_use]` 8cf0270a225 add coretests for `is_aligned` 7488a20c65e constify `pointer::is_aligned{,_to}` f5ca3b88c33 add coretests for const `align_offset` 321f0154806 Auto merge of #104607 - matthiaskrgr:rollup-9s589me, r=matthiaskrgr ff37704098e make const `align_offset` useful 65fb5984af4 constify `exact_div` intrinsic 0bcb388c619 Rollup merge of #103989 - arlosi:arm32-panic, r=Amanieu 8c93b480873 Auto merge of #104571 - clubby789:remove-vec-rc-opt, r=the8472 de073b23d3e Rollup merge of #104553 - mwillsey:asinh-acosh-accuracy, r=thomcc 7470aa07e87 Rollup merge of #104528 - WaffleLapkin:lazy_lock_docfix, r=matklad 9005f7d0533 Hide the items while waiting for the ACP 0e9ca1ad592 Auto merge of #104591 - Manishearth:rollup-b3ser4e, r=Manishearth 92905ba3293 Rollup merge of #104338 - compiler-errors:pointer-sized, r=eholk 81b6cbf11a6 Rollup merge of #103701 - WaffleLapkin:__points-at-implementation__--this-can-be-simplified, r=scottmcm c3f7048455f Rollup merge of #103456 - scottmcm:fix-unchecked-shifts, r=scottmcm 80d599cafcc Rollup merge of #103378 - nagisa:fix-infinite-offset, r=scottmcm 5d0a622e6ad Rollup merge of #102977 - lukas-code:is-sorted-hrtb, r=m-ou-se 79f49f4951d Change undefined-behavior doctests from ignore to no_run. 8807914e620 Apply suggestions from code review 16c037b9375 Add examples to show when `{Arc,Rc}::get_mut_unchecked` is disallowed. 969167c4e2d Clarify and restrict when `{Arc,Rc}::get_mut_unchecked` is allowed. b387e26909d Enforce that dyn* casts are actually pointer-sized ad4617d4a8b Rollup merge of #103594 - maniwani:fix-issue-91417, r=thomcc d540ecd66a6 Remove Vec/Rc storage reuse opt 5a89c414350 clarify that realloc refreshes pointer provenance even when the allocation remains in-place bcc8b37c862 Handle the case that even the filename array is unaligned. c7aad1ba6fa Rm diagnostic item, use lang item 298c2a15bd8 Don't assume `FILE_ID_BOTH_DIR_INFO` will be aligned 948e503851f Improve accuracy of asinh and acosh 1dcfd66c95d Readd the matches_macro diag item a65a7b515cc Auto merge of #104219 - bryangarza:async-track-caller-dup, r=eholk c628379661a Minimal implementation of implicit deref patterns 9505a3f61f2 Properly link `{Once,Lazy}{Cell,Lock}` in docs 68b7fe9aa3f Auto merge of #104205 - clubby789:grow-rc, r=thomcc 459343f5bea Auto merge of #103779 - the8472:simd-str-contains, r=thomcc 04aac2fc0f3 available_parallelism: Handle 0 cfs_period_us ba537c18e2b Auto merge of #104481 - matthiaskrgr:rollup-hf8rev0, r=matthiaskrgr 57bdd87081d Rollup merge of #104401 - RalfJung:mpsc-leak, r=Amanieu 3e60b9daf30 Rollup merge of #103489 - WaffleLapkin:byte_offset_from_you, r=scottmcm 842165dfc21 Auto merge of #102935 - ajtribick:display-float-0.5-fixed-0, r=scottmcm ecec302f3d1 Reduce exceptions overallocation on non Windows x86_64 75057a37ff4 Fix building of `aarch64-pc-windows-gnullvm` 3c9eb22f504 Auto merge of #104054 - RalfJung:byte-provenance, r=oli-obk 8385d082777 - convert from core::arch to core::simd - bump simd compare to 32bytes - import small slice compare code from memmem crate - try a few different probe bytes to avoid degenerate cases - but special-case 2-byte needles 2bf824ac6a6 generalize str.contains() tests to a range of haystack sizes d6fa59cbcf9 Rollup merge of #104339 - compiler-errors:rustc_deny_explicit_impl, r=cjgillot 8fdddaa9576 Rollup merge of #104241 - bjorn3:smaller_unwind_build_script, r=Mark-Simulacrum 55f1a444b44 Rollup merge of #103734 - Mark-Simulacrum:fix-version-stabilized, r=JohnTitor cbb3b83ee47 `VecDeque::resize` should re-use the buffer in the passed-in element fdd88cc3de6 Auto merge of #104428 - matthiaskrgr:rollup-jo3078i, r=matthiaskrgr 0e209cec45b Rollup merge of #104383 - WaffleLapkin:rustc_undiagnostic_item, r=compiler-errors b15a49dea3d Rollup merge of #104372 - Ayush1325:compiler-builtins, r=JohnTitor e1666195fef Rollup merge of #104354 - lukas-code:blank-lines-2, r=JohnTitor 0a5d659a989 x86_64 SSE2 fast-path for str.contains(&str) and short needles 4cef70c615f update str.contains benchmarks c93f98d81b9 black_box test strings in str.contains(str) benchmarks 7403dc9a058 Fix doc example for `wrapping_abs` 3c9efababfe Rollup merge of #104332 - Elarcis:maybe_uninit_doc_fix, r=m-ou-se acf558052e6 Rollup merge of #102470 - est31:stabilize_const_char_convert, r=joshtriplett 0603560d1eb Rollup merge of #101967 - jmillikin:linux-abstract-socket-addr, r=joshtriplett 7ad74c4b38a macos, aarch64, and not(miri) 0709068c5cf Move most of unwind's build script to lib.rs 955360762ef rustdoc: Add copy to the description of repeat c34e5c51ead std: move `ReentrantMutex` to `sync` cc385449fbc avoid memory leak in mpsc test 254b8a9848c Auto merge of #104387 - Manishearth:rollup-9e551p5, r=Manishearth 1b1aa0756c4 Add rustc_deny_explicit_impl 76297b7a606 Rollup merge of #104300 - tbu-:pr_path_parent_caveats, r=Mark-Simulacrum 53ed52ee942 Rollup merge of #103744 - palfrey:unwind-upgrade-cc, r=Mark-Simulacrum 868362c5bb9 Add `Vec` storage optimization to `Arc` and add tests 6df8e617549 Reuse `Vec` backing storage for `Rc<[T]>` 18fc032b7a8 Auto merge of #103858 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini 406d351c2f4 Fix clippy and rustdoc f2a24a47140 Auto merge of #103894 - mati865:gnullvm-libunwind-changes, r=thomcc 9bcf4d0da1f just use `libc::clockid_t` 18cf15a22d1 Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targets 635dd7d9a92 Remove unused diagnostic items 27a211e1f48 Update compiler-builtins 3727223e67e Rollup merge of #104320 - fee1-dead-contrib:use-derive-const-in-std, r=oli-obk 805e43e09c7 Rollup merge of #103996 - SUPERCILEX:docs, r=RalfJung e654e368039 Auto merge of #93563 - ibraheemdev:crossbeam-channel, r=Amanieu 13268a706a6 remove leading newlines from `NonZero*` doc examples 10e706fc692 avoid using channels in thread-local tests aff95fe7914 avoid calling `thread::current` in channel destructor 861290c6db9 Auto merge of #103913 - Neutron3529:patch-1, r=thomcc e687308acf6 Fixed some `_i32` notation in `maybe_uninit`’s doc f07513f2e4d Rollup merge of #104308 - scottmcm:no-more-validalign, r=thomcc b5d1c2f4f19 Rollup merge of #104263 - albertlarsan68:add-ilog2-to-leading-zeroes-docs, r=scottmcm 29e906106b4 Use `derive_const` and rm manual StructuralEq impl 9e893d7725b Use correct EH personality on `*-windows-gnu-*` fa59c93be9f Bump unwinder private data size for AArch64 Windows 247353929d5 Rollup merge of #102049 - fee1-dead-contrib:derive_const, r=oli-obk 92cc741af5c Remove the old `ValidAlign` name 49301f033fd Auto merge of #103150 - joboet:remove_lock_wrappers, r=m-ou-se 640de9e1522 Document `Path::parent` behavior around relative paths 94177950c18 Try another way f36122eca15 Apply suggestions 8fa856f78cc Add a reference to ilog2 in leading_zeros integer docs 907268c8dd5 Rollup merge of #104060 - ink-feather-org:const_hash, r=fee1-dead 318269ce9b1 tidy a3dad600f5a spin less in `mpsc::SyncSender::send` 5d155e80ea3 remove extra spinning from `mpsc` parker 357f1e3fc0b `sync::mpsc`: quadratic backoff 7cc57fc2c3b `sync::mpsc`: reload state after spinning on CAS failure 7dc1384a0c3 remove extra spinning from `mpsc::Receiver::recv` 559d595e1c6 remove mention of rust-lang#39364 from mpsc docs 0b64868b356 add test case for rust-lang#39364 ea8d3954f16 implement `sync::mpsc` as a wrapper around `sync::mpmc` ccd49623a1b initial port of crossbeam-channel 2116481c8de Allow and add `track_caller` to generators 2b9ac9756e2 Upgrade cc to 1.0.76 a799528065b Rollup merge of #104015 - alex:remove-kernel, r=oli-obk ec2dc0ddc2a Rollup merge of #103464 - JakobDegen:mir-parsing, r=oli-obk f27182f5105 Rollup merge of #103307 - b4den:master, r=estebank 311a680d7ff Rollup merge of #104125 - ink-feather-org:const_cmp_tuples, r=fee1-dead cb202f9396a Rollup merge of #104111 - yancyribbens:add-mutable-to-the-description-for-as-simd-mut, r=scottmcm 00fe22e581a Rollup merge of #103694 - WaffleLapkin:mask_doc_example, r=scottmcm 374fcf98f42 Rollup merge of #103570 - lukas-code:stabilize-ilog, r=scottmcm bf6b23065d3 const Compare Tuples 18dc9c4db18 Add support for custom MIR parsing 8102fcfcad8 `IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` documentation. c86c2951ef1 Rollup merge of #104139 - ferrocene:pa-channel-licensing, r=pnkfelix e80880ad201 Rollup merge of #104113 - ink-feather-org:fix_const_fn_ref_impls, r=compiler-errors 3e97e639492 Rollup merge of #104109 - yancyribbens:add-mutable-to-comment-for-align-to-mut, r=thomcc a6af2459019 Rollup merge of #104097 - RalfJung:miri-alloc-benches, r=thomcc 5b42c5d3420 Rollup merge of #104093 - RalfJung:test-sizes, r=thomcc 312050dc2c6 Test const `Hash`, fix nits 3c5c26a3934 doc: expand description for f32 and f64 associated constants cda65051f46 clarify licensing situation of mpsc and spsc queue 8f85fac0be8 Rollup merge of #103446 - the8472:tra-array-chunks, r=Mark-Simulacrum 72034a1054d document and improve array Guard type b1a882952bc simplification: do not process the ArrayChunks remainder in fold() a5cbad46c4f specialize iter::ArrayChunks::fold for TrustedRandomAccess iters 478eb85155c make the array initialization guard available to other modules 8a357ac5588 add benchmark for iter::ArrayChunks::fold specialization a5d531e9be5 Auto merge of #103934 - notriddle:notriddle/backtrace-deps, r=Mark-Simulacrum 23a202f676f Fix `const_fn_trait_ref_impl`, add test for it 36fa29154ba rustdoc: Add mutable to the description 35572a5069d rustdoc: Add mutable to the description f238e13428d Removed unnecessary Trait bound 73b3474fb4c fmt caa0e23e2f2 Rollup merge of #104090 - wanghaha-dev:master, r=Dylan-DPC d1842b01f9c Lift `T: Sized` bounds from some `strict_provenance` `NonNull` methods be1c46477b1 run alloc benchmarks in Miri and fix UB 2096332a116 disable btree size tests on Miri f30e90cb1aa Modify comment syntax error eb26a93b4cd Rollup merge of #104074 - yancyribbens:add-example-to-round, r=Mark-Simulacrum 090e1feba23 Rollup merge of #104056 - ripytide:patch-1, r=Mark-Simulacrum e798f2e9ef1 PhantomData layout guarantees cbdac0acf61 Fix rebase errors fabd76c5318 Fix rustdoc lints 7752095a491 cfg-step code 82a8dd8543b Bump version placeholders to release 8368dc84959 rustdoc: Add an example for round that is different from truncate 3c0713aa23e Add small clarification around using pointers derived from references 8b364cfe5a9 Auto merge of #99943 - compiler-errors:tuple-trait, r=jackh726 cc9f31982b9 Added `const_hash` tracking issue id 9150ad4232c Made `Sip` const `Hasher` 81eb0d4e20a Vec: IntoIterator signature consistency 5c3513524e9 std: fix double-free of mutex 734576f7ff0 std: remove lock wrappers in `sys_common` 67d45a76b0a remove no-longer-needed work-arounds from the standard library bcce53133a7 Rollup merge of #104002 - RalfJung:unsafecell-new, r=JohnTitor 4e202ad2dc0 Fix unused_must_use warning for Box::from_raw 727e4237aa5 Merge conflicts and rebase onto master 37d9f9feee4 Enforce Tuple trait on Fn traits 81768f352ff Remove linuxkernel targets 75d9aefe2b4 fix a comment in UnsafeCell::new ea2c4d0338d Rollup merge of #103995 - SUPERCILEX:typos, r=Dylan-DPC a3670cfe861 Small round of typo fixes b56454f3f27 Fix build of thumbv7a-pc-windows-msvc b78a3f56645 Make `BuildHasher` const_trait 0175763a2df Made `Hash` and `Hasher` const_trait b2db0c84dda Rollup merge of #103681 - RalfJung:libtest-thread, r=thomcc 02dd5f17bcd Rollup merge of #103367 - chbaker0:update-std-getrandom, r=thomcc a00cbb1f6e2 Rollup merge of #103941 - douweschulte:patch-1, r=jyn514 d4667c1e97f Rollup merge of #103680 - RalfJung:cstr-links, r=JohnTitor ef0af4a5093 update comment f9183d7d7ec Remove `iter::Empty` hack 32670b4bea5 Fixed typos 2f93ad3ee65 std: sync "Dependencies of the `backtrace` crate" with `backtrace` 01d6249e242 fix the overflow warning. b663b632741 Optimize the code to run faster. 53b85a66130 Remove std's transitive dependency on cfg-if 0.1 d7fa40f39aa Add tracking issue for `const_arguments_as_str` 67487a4a98d Rollup merge of #103807 - H4x5:string-extend-from-within-tracking-issue, r=Dylan-DPC 5a5e64f090a Rollup merge of #103774 - compiler-errors:dyn-trait-in-type-name, r=eholk 67fe4829c06 Add additional float constants 28e2d809e46 Clarify docs of `RefCell` e9266efcbbc Rollup merge of #103637 - ChrisDenton:stdio-uwp, r=thomcc 3f3878f4ce4 Rollup merge of #103084 - inquisitivecrystal:control-flow, r=scottmcm 247d41e2376 Format dyn Trait better in type_name intrinsic 0fe76f4214a Change the way libunwind is linked for `*-windows-gnullvm` targets 9e902ac4cec Rollup merge of #103809 - tyggja:patch-1, r=JohnTitor e9a7f81251e Rollup merge of #103729 - RalfJung:align-of-val-packed, r=oli-obk 63c616b7eb2 Rollup merge of #103061 - Amanieu:rewrite_alloc_error_handler, r=bjorn3 7d22190bd99 Use `allow_internal_unstable` and add unstable reason a189156c94d Auto merge of #103795 - thomcc:untest, r=Mark-Simulacrum 0f162675966 Specialize PartialEq for Option and Option b92c76d89cb Rewrite implementation of `#[alloc_error_handler]` 5a87175efdb Update mod.rs 75bf02100b5 Add tracking issue for `string_extend_from_within` 0d4377125b9 Rollup merge of #103766 - lukas-code:error-in-core, r=Dylan-DPC 25290dfd8b7 Include both benchmarks and tests in the numbers given to `TeFiltered{,Out}` 9421ec8b9aa Add tracking issue to `error_in_core` c7aa61615b0 Rollup merge of #103689 - saethlin:libtest-startup, r=thomcc a0d8d86752f Add BorrowedBuf::filled_mut 48c6ba5674c Rollup merge of #103715 - tshepang:consistency, r=Dylan-DPC de222ddea60 Rollup merge of #100006 - jyn514:update-copy, r=dtolnay a91d3302faf Upgrade cc for working is_flag_supported on cross-compiles 4ad15fe1b8b Adjust stabilization version to 1.65.0 for wasi fds 6a69db6f0b3 interpret: fix align_of_val on packed types dc1e9548915 Rollup merge of #103719 - joseluis:fix-typos-try-reserve, r=the8472 8d77270dc70 Rollup merge of #102721 - nbdd0121:panic, r=Amanieu 681107366d9 fix typo in hashmap and hashset try_reserve method d5a0df7d466 More inference-friendly API for lazy 5f2fd42ba16 use consistent terminology eeca8b7c168 Rollup merge of #102961 - reitermarkus:const-cstr-from-ptr, r=oli-obk 05859fa38e3 Auto merge of #102737 - RalfJung:poll_fn_pin, r=Mark-Simulacrum e4898b1f25d Lift `T: Sized` bounds from some `strict_provenance` pointer methods 5db49b14371 Simplify implementation of various pointer methods 84defed7763 Make `pointer::with_metadata_of` const (+simplify implementation) 26fac33db07 Add examples for `pointer::mask` a8d68fb3cfd Remove unneeded attribute. 3eb98aaac76 libtest: run all tests in their own thread, if supported by the host ac5a552e32c CStr: add some doc links ae6d1a173b2 Do fewer passes and generally be more efficient when filtering tests 0d3c443d7be Use stdio in UWP apps bec51756de5 Rollup merge of #103394 - Pointerbender:unsafecell-docs, r=Amanieu 72a3f46880c Rollup merge of #103110 - RalfJung:manual-send, r=thomcc f1fe0f7ed5a Rollup merge of #103564 - RalfJung:miri-unused, r=thomcc f3199a6b4b4 Rollup merge of #103106 - saethlin:from_exposed_docs, r=thomcc 4a52108dce1 Rollup merge of #103035 - saethlin:assert_unsafe_precondition3, r=thomcc 88d2c530e96 add "Memory layout" subsection to documentation of `UnsafeCell` for additional clarity 4e681d20557 Print the precondition we violated, and visible through output capture 4449ea4f70b Rollup merge of #103596 - RalfJung:thread-setname, r=cuviper 54752068f28 Rollup merge of #103580 - lukas-code:guaranteed_ne, r=GuillaumeGomez 3458c20a9e8 Rollup merge of #103567 - RalfJung:ptr-eq-dyn-trait, r=dtolnay e4ecee25484 Rollup merge of #103526 - Rageking8:more-dupe-typos-again, r=Mark-Simulacrum 0e20f0a9461 thread::set_name: debug-assert that things went well 47cd28d7a39 Fix typo in docs for `guaranteed_ne` 79787f55c27 Update library/core/src/ptr/mod.rs 9fa82892f71 explicitly mention that both components of wide prts are compared d36fde349c9 stabilize `int_log` 9f75ea58ab5 ptr::eq: clarify that comparing dyn Trait is fragile f87f36630e8 library: allow some unused things in Miri a428844153f Rollup merge of #103287 - saethlin:faster-len-check, r=thomcc dcdd1aded96 Try to say that memory outside the AM is always exposed 9900c0a3e45 more dupe typos again cca07fa890a stabilise array methods 1d47b8aacd1 Auto merge of #103392 - RalfJung:miri, r=oli-obk 0c2bbcec539 Rollup merge of #103482 - aDotInTheVoid:vec-cap-docs, r=thomcc f4717df0e5c Rollup merge of #103379 - cuviper:truncate-thread-name, r=thomcc f14825fc23b Rollup merge of #98204 - Kixiron:stable-unzip, r=thomcc 648fcc6a320 Make `pointer::byte_offset_from` more generic e133e5d92f4 Clairify Vec::capacity docs 2c75e704e64 Rollup merge of #103466 - jruderman:patch-2, r=Dylan-DPC cbf5849d31c Rollup merge of #103277 - thomcc:bump-libc-135, r=Mark-Simulacrum 4b83892303b Rollup merge of #102766 - thomcc:remove-resolv, r=Mark-Simulacrum b7dab4f2fcc Rollup merge of #102271 - lopopolo:lopopolo/stabilize-duration-try-from-secs-float, r=dtolnay 90064e9b905 Rollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726 ab37f217b27 Rollup merge of #99578 - steffahn:remove_redundant_bound, r=thomcc d432dbd5a36 Fix grammar in docs for std::io::Read 238611ec8d7 Auto merge of #100848 - xfix:use-metadata-for-slice-len, r=thomcc 8afc1b91d3d fix typos 0040abbc9f4 Pass on null handle values to child process 2a98db7498e `unchecked_{shl|shr}` should use `u32` as the RHS 7d5c6d694a4 Rollup merge of #103447 - ajtribick:maybe_uninit_doc_update, r=scottmcm e18850177db Rollup merge of #103005 - solid-rs:patch/kmc-solid/readdir-terminator, r=m-ou-se b44afb37ce2 Rollup merge of #101644 - Timmmm:file_permissions_docs, r=thomcc e2531f403ce Rollup merge of #100462 - zohnannor:master, r=thomcc 765b0fe81ca Fix alloc size b024fe71916 Apply suggestion d11b97dd475 Implement Rust foreign exception protection for EMCC and SEH d794976ff9e Prevent foreign Rust exceptions from being caught d2fdbfb8995 Auto merge of #103137 - dtolnay:readdir, r=Mark-Simulacrum a87b4317a89 Only test pthread_getname_np on linux-gnu b31431667e0 MaybeUninit: use assume_init_drop() in the partially initialized array example ac8c02f2643 Fix typo in docs of `String::leak`. d634989311e Pin::new_unchecked: discuss pinning closure captures 237c8236b24 Rollup merge of #103360 - ChrisDenton:isterm-filetype, r=thomcc 0bb751697ba Rollup merge of #103346 - HeroicKatora:metadata_of_const_pointer_argument, r=dtolnay 282dfe34e83 Rollup merge of #103329 - saethlin:nonnull-precondition, r=thomcc 52e7eda8f85 Rollup merge of #103280 - finnbear:impl_string_leak_2, r=joshtriplett 606f473c6da Move truncation next to other thread tests for tidy ffb47eee810 Fix mod_inv termination for the last iteration 876f53aa3dc Truncate thread names on Linux and Apple targets c46b86cfd4e Auto merge of #103375 - matthiaskrgr:rollup-4xrs7f2, r=matthiaskrgr 27af3e4d45b Rollup merge of #103359 - WaffleLapkin:drain_no_mut_qqq, r=scottmcm 7887e3ddddd Rollup merge of #103340 - RalfJung:winconsole, r=thomcc aaf576231d7 Auto merge of #101263 - lopopolo:lopopolo/c-unwind-fn-ptr-impls, r=thomcc ca8d4bd0206 Auto merge of #101077 - sunshowers:signal-mask-inherit, r=sunshowers b4d57d276a4 Reduce false positives in msys2 detection d76763298b7 Remove incorrect comment in `Vec::drain` 8ac096dbae9 Reduce mutability in std-use of with_metadata_of a5bf23dd219 Argument type for mutable with_metadata_of (#75091) 905eced7223 WinConsole::new is not actually fallible 3b4a4411aed merge rustc history 9944dcef633 Auto merge of #103308 - sunfishcode:sunfishcode/wasi-io-safety, r=joshtriplett 60fbd5be4b6 Add a missing precondition check 8eb1a7929e2 Change process spawning to inherit the parent's signal mask by default 98dd06e49bc Make the whole `std::os::wasi::io` module stable. ae840ac01b7 Rollup merge of #103288 - johnmatthiggins:master, r=thomcc 014363b5bbc Rollup merge of #103281 - thomcc:long-overdue, r=jyn514 0b0e64fbb85 Add tests for rounding of ties during float formatting 533fce05bf2 Update tests to match error message changes 6eff980b093 Mark `std::os::wasi::io::AsFd` etc. as stable. dcd980de334 Skip C-unwind fn pointer impls with the bootstrap compiler c3fc7dc1f0a clarify documentation about the memory layout of `UnsafeCell` 856965fb750 Rollup merge of #103272 - clubby789:extra-spaces, r=thomcc 36cd173f5f1 Rollup merge of #103197 - est31:stabilize_proc_macro_source_text, r=petrochenkov b8b810acbe4 Adjust `transmute{,_copy}` to be clearer about which of `T` and `U` is input vs output b76c747382f Fixed docs typo in `library/std/src/time.rs` 90eb7bb8083 Use a faster allocation size check in slice::from_raw_parts e4f00f3634e Update stability annotations on fnptr impls for C-unwind ABI 51564ff9e4c Add default trait implementations for "c-unwind" ABI function pointers c84733882c2 Put fn in the right place. 74ed5cfbaef Copy of #102941. 5474b348b96 Update libstd's libc to 0.2.135 cc291934ce7 Remove extra spaces 5c8fdfac6d3 Derive `Eq` and `Hash` for `ControlFlow` 18e67b193e5 doc: rewrite doc for signed int::{carrying_add,borrowing_sub} 6ee674e642b Rollup merge of #103153 - ChrisDenton:leak-oom, r=m-ou-se 6fc50b2c05c Rollup merge of #103127 - SUPERCILEX:inline-const-uninit, r=scottmcm dfc2203e957 Auto merge of #103225 - matthiaskrgr:rollup-1zkv87y, r=matthiaskrgr 90d30fcf9c7 Rollup merge of #103166 - the8472:copied-next-chunk, r=m-ou-se 9140f625d31 specialize slice_iter.copied().next_chunk() a2fd0d53b2b Rollup merge of #102507 - scottmcm:more-binary-search-docs, r=m-ou-se 9c4b222540a Rollup merge of #101889 - tspiteri:redoc-uint-adc-sbb, r=m-ou-se c4d9ef6511a Stabilize proc_macro::Span::source_text 5f8fd38e5fc mark sys_common::once::generic::Once::new const-stable 9570e7f3760 Auto merge of #103188 - JohnTitor:rollup-pwilam1, r=JohnTitor 169cfd6a98c Rollup merge of #103163 - SUPERCILEX:uninit-array-assume2, r=scottmcm feac59533a6 Rollup merge of #103159 - cuviper:check_pow-final-try_opt, r=Mark-Simulacrum 143cded23a6 Rollup merge of #103154 - H4x5:reverse-searcher-typo, r=Mark-Simulacrum 70b7f34eb51 Rollup merge of #103142 - fmease:fix-103052, r=oli-obk b2aa1bcc35a Auto merge of #103075 - SUPERCILEX:miri-metadata, r=thomcc b75f6bb3b7e add a benchmark for slice_iter.copied().array_chunks() 0c9efafe442 Remove all uses of array_assume_init 80a55fdbb3a Auto merge of #101837 - scottmcm:box-array-from-vec, r=m-ou-se 2f776da9611 Remove the redundant `Some(try_opt!(..))` in `checked_pow` a8b16c8fe2e Fix typo in `ReverseSearcher` docs 24a6f834695 Allow `Vec::leak` with `no_global_oom_handling` cbe72690cdd Make diagnostic for unsatisfied Termination bounds more precise 6c73f05b2fd Eliminate 280-byte memset from ReadDir iterator ada11c85646 Fix types in documentation for Alignment::as_usize and Alignmnet::as_nonzero f59c82558d2 Make transpose const and inline 96cf0b54dae Rollup merge of #103109 - RalfJung:phantom-data-impl, r=thomcc 3b5c9ea3a77 Rollup merge of #103102 - H4x5:len_utf16_docs, r=scottmcm 69972db9042 Rollup merge of #103087 - phimuemue:btreemap_append_doc, r=Mark-Simulacrum 812e11b2981 Support DirEntry metadata calls in miri 98c18ff5747 Clarify the possible return values of len_utf16 6e0bd9c2ba4 remove redundant Send impls for references d17f3cf37b5 PhantomData: inline a macro that is used only once fc7527c1220 Rollup merge of #102023 - SUPERCILEX:maybeuninit-transpose, r=scottmcm e5e88435c90 Rollup merge of #101717 - Pointerbender:unsafecell-memory-layout, r=Amanieu 18d0e246783 Stabilize `main_separator_str` 4421bdf10d3 Add MaybeUninit array transpose impls 8a6362c2d82 Auto merge of #100579 - joboet:sync_mutex_everywhere, r=thomcc f58a72267d6 More slice::partition_point examples 79c3df98fc6 Stabilize `duration_checked_float` 31fc00f700e Documentation BTreeMap::append's behavior for already existing keys 503ef9af0a0 Rollup merge of #102773 - joboet:apple_parker, r=thomcc 9675d75d3da Auto merge of #98033 - joshtriplett:is-terminal-fd-handle, r=thomcc 18b2833fe4a Use Align8 to avoid misalignment if the allocator or Vec doesn't align allocations 199ba749d4f Rewrite FILE_NAME_INFO handling to avoid enlarging slice reference 890339e3007 Make is_terminal fail fast if a process has no console at all 2e6f405bfea Add `IsTerminal` trait to determine if a descriptor or handle is a terminal 4de8238cba2 Auto merge of #103069 - matthiaskrgr:rollup-xxsx6sk, r=matthiaskrgr 9f2d858bcdc Rollup merge of #103067 - Nilstrieb:tidy-likes-the-alphabet, r=jackh726 cd8fbc8f1d4 Rollup merge of #103059 - beetrees:duration-from-negative-zero, r=thomcc 9998c3e4746 Rollup merge of #103045 - lukas-code:blank-lines, r=GuillaumeGomez 0ca102407f9 Rollup merge of #103017 - fortanix:raoul/sgx_tls_fix, r=ChrisDenton e6c7a227eef Rollup merge of #102781 - StackOverflowExcept1on:master, r=joshtriplett 68d277d9843 Auto merge of #101030 - woppopo:const_location, r=scottmcm 1d3bb69a751 Sort target features alphabetically 5ae7256b262 Add some tidy-alphabetical 1f62bbcfb87 Auto merge of #102783 - RalfJung:tls, r=thomcc 7598b3b4bfa Bugfix: keep TLS data in sync f880221d956 Fix `Duration::{try_,}from_secs_f{32,64}(-0.0)` f8ff2563604 Fix `checked_{add,sub}_duration` incorrectly returning `None` when `other` has more than `i64::MAX` seconds f73578be8e1 Auto merge of #102529 - colinba:master, r=joshtriplett ab4ede96c1e Tweak grammar 5139c8a68f4 Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8Ki f5206b658a4 Rollup merge of #102847 - joshtriplett:bugfix-impl-fd-traits-for-io-types, r=m-ou-se afbba432af1 remove leading newlines from integer primitive doc examples 66ce0905581 more dupe word typos a72325fb933 Auto merge of #103009 - Dylan-DPC:rollup-9c2tng6, r=Dylan-DPC b4d8ac582ad Rollup merge of #102854 - semarie:openbsd-immutablestack, r=m-ou-se ad09a25c3ae smarter way to avoid 'unused' warning when building for tests ec3ef88ccb4 sync thread_local key conditions exactly with what the macro uses c2ff519bd2c Auto merge of #102919 - luojia65:update-stdarch, r=Amanieu b489b2d6d04 std: use `sync::Mutex` for internal statics 15382ea2f8c Auto merge of #102655 - joboet:windows_tls_opt, r=ChrisDenton be4fe62b081 kmc-solid: Handle errors returned by `SOLID_FS_ReadDir` 692be6b7d85 Auto merge of #102995 - JohnTitor:rollup-yomkwge, r=JohnTitor c9b38d38c1a library: update stdarch submodule ee46b8621f8 Rollup merge of #102974 - Rageking8:fix-small-word-dupe-typos, r=JohnTitor 075606ae2df Auto merge of #102372 - abrown:issue-102157, r=thomcc 892fb4b3994 expand documentation on type conversion w.r.t. `UnsafeCell` 442896d8508 merge rustc history 9fbaa1be383 fix small word dupe typos ab48d94df41 remove HRTB from `[T]::is_sorted_by{,_key}` d650d91c2a3 Auto merge of #102732 - RalfJung:assert_unsafe_precondition2, r=bjorn3 19452fb9439 Update docs for `CStr::from_ptr`. 8a3f20a8892 Make `CStr::from_ptr` `const`. a968cc9a3e9 Auto merge of #102460 - flba-eb:fix_85261_prevent_alloc_after_fork, r=thomcc 86514dbd0ac Auto merge of #102948 - Dylan-DPC:rollup-j8h74rb, r=Dylan-DPC b1d026b013b Rollup merge of #102811 - the8472:bufread-memset, r=m-ou-se f52bd1d43b7 Rollup merge of #102578 - lukas-code:ilog-panic, r=m-ou-se 3d0083830b5 Auto merge of #102692 - nnethercote:TokenStreamBuilder, r=Aaron1011 6f461d9ea37 Fix inconsistent rounding of 0.5 when formatted to 0 decimal places 603587614f6 reorder panicking.rs to put main entry points at the top 6e9adb20909 use panic_fmt_nounwind for assert_unsafe_precondition 0312bd7d455 add panic_fmt_nounwind for panicing without unwinding, and use it for panic_no_unwind 63c44bca25b rename rustc_allocator_nounwind to rustc_nounwind 9d91af09bc7 fix: return type of single-threaded dummy lock must be droppable bf2eaa8a7b6 Rollup merge of #102869 - azdavis:master, r=joshtriplett 855f3806f58 Rollup merge of #102685 - nbdd0121:unwind, r=m-ou-se 51e3c8435bf Rollup merge of #102445 - jmillikin:cstr-is-empty, r=Mark-Simulacrum 44f4815ee7d Rollup merge of #102227 - devnexen:solarish_get_path, r=m-ou-se d95e5ac1627 Rollup merge of #101774 - Riolku:atomic-update-aba, r=m-ou-se 9ebb3b07f93 Rollup merge of #101727 - est31:stabilize_map_first_last, r=m-ou-se 2314a84f5c2 Rollup merge of #102625 - Rageking8:fix-backtrace-small-typo, r=m-ou-se 669e1bcb936 Rollup merge of #102589 - RalfJung:scoped-threads-dangling, r=m-ou-se d4318648532 Rollup merge of #102412 - joboet:dont_panic, r=m-ou-se 74de0ca14d0 Rollup merge of #102277 - mgeisler:rwlock, r=m-ou-se 9e901496dd3 Rollup merge of #102258 - cjgillot:core-kappa, r=m-ou-se 7cf05741308 Change tracking issue from #76156 to #102911 b530a00ed94 Do not alias for fs 8f2599d0d33 Auto merge of #102596 - scottmcm:option-bool-calloc, r=Mark-Simulacrum 39480680705 Implement `env_lock` with `RwLock` bd31e81a267 Allow compiling the `wasm32-wasi` std library with atomics b74891ece9a merge rustc history 26262f700a3 Consolidate AsFd instances for stdio types into `library/std/src/os/fd/owned.rs` 8d2f440e6f1 Auto merge of #96711 - emilio:inline-slice-clone, r=nikic 0ff8107ddb3 Rollup merge of #102794 - dtolnay:termination, r=thomcc 2bac0ad5bf8 Rollup merge of #99696 - WaffleLapkin:uplift, r=fee1-dead d5b5d5de7ee Add basename and dirname aliases ad3db79520c Rollup merge of #102862 - scottmcm:more-alignment-traits, r=thomcc 9c2453c5e33 From for usize & NonZeroUsize 7a4ff655b0b Auto merge of #89123 - the8472:push_in_capacity, r=amanieu 517ee993de7 expand documentation on type conversion w.r.t. `UnsafeCell` feb1ecd1005 Auto merge of #102850 - JohnTitor:rollup-lze1w03, r=JohnTitor 8d0966ffed4 impl AsFd for io::{Stdin, Stdout, Stderr}, not the sys versions f052af0ca0a openbsd: don't reallocate a guard page on the stack. 9b886f55a6e Rollup merge of #102072 - scottmcm:ptr-alignment-type, r=thomcc e8dc1877c56 Rollup merge of #101118 - devnexen:fs_getmode_bsd, r=Mark-Simulacrum c530da65dc2 Auto merge of #93668 - SUPERCILEX:path_alloc, r=joshtriplett 885a544240f fixup lint name b6dce5d8fc0 allow `for_loop_over_fallibles` in a `core` test 295137435ea merge rustc history b766edefd87 Rollup merge of #102812 - est31:remove_lazy, r=dtolnay e4e4b608d14 Rollup merge of #99880 - compiler-errors:escape-ascii-is-not-exact-size-iterator, r=thomcc 0136d282ba1 std: optimize TLS on Windows 4035a304838 Auto merge of #102315 - RalfJung:assert_unsafe_precondition, r=thomcc c71b3bc633e Remove empty core::lazy and std::lazy d12193b1ddd use memset to initialize a readbuf 84d81d1eb09 Fix test (location_const_file) bc8013338da Auto merge of #2583 - RalfJung:rustup, r=oli-obk 48f88031fe2 std: do not use dispatch semaphore under miri (yet) d25770a7983 std: remove unused linker attribute 1108d9d685d Auto merge of #99505 - joboet:futex_once, r=thomcc df9c254c3b4 Make tests capture the error printed by a Result return a1d63ceb248 Auto merge of #102091 - RalfJung:const_err, r=oli-obk b8aedde9eef Rollup merge of #102760 - saethlin:dont-reinit-buffer, r=Mark-Simulacrum 5c981e6a1b2 Rollup merge of #102475 - RalfJung:unsafe, r=dtolnay b6918bba8b5 Rollup merge of #102300 - scottmcm:simpler-fold-closures, r=Mark-Simulacrum 2da73fa74b4 make const_err a hard error d45c5323b08 review feedback 6cc2fcd9ffd Improved documentation for `std::io::Error` 3e92a7cf2c0 add a few more assert_unsafe_precondition ce4917dbf7a std: use futex in `Once` eeb6661d4d0 Don't needless link to `libresolv` on Darwin in libstd 765aa52cf85 Avoid defensive re-initialization of the BufReader buffer f031f976ee8 std: add thread parking tests 523332528cc std: use semaphore for thread parking on Apple platforms 77507f59762 Auto merge of #102741 - matthiaskrgr:rollup-63no5tz, r=matthiaskrgr 643bdec21da Fix handling of trailing bare CR in str::lines 2088fcb7374 Rename LinesAnyMap to LinesMap 615f74de87b Rollup merge of #102680 - dtolnay:btreesend, r=thomcc 2de254437b0 Auto merge of #99497 - vladimir-ea:stdlib_os_api_watchos, r=thomcc 13ff3101958 poll_fn and Unpin: fix pinning a8e4bb59878 Fix whitespace 9c497ada179 Prevent UB in child process after calling libc::fork c68f7193ea7 Rollup merge of #102693 - BlackHoleFox:revert-apple-entropy-changes, r=thomcc c06c24829fe tidy 2beb6622441 Fix overconstrained Send impls in btree internals 6d250fe2ca8 Add regression test for lifetimes in alloc internals autotraits b7bd0a774e8 Add missing trailing `)]` 7a3dbd9bcf2 Fix typo (missing `>`) 5bf5908dc15 Update library/core/src/num/nonzero.rs 2517f5ad826 Revert "Use getentropy when possible on all Apple platforms" 3da7f151505 Rollup merge of #102574 - aDotInTheVoid:const_collections_with_hasher, r=oli-obk,fee1-dead 9a3504a217c A tiny fix for `define_client_side`. 9386e5432b1 Interpret EH actions properly 62c8611ed08 Auto merge of #101768 - sunfishcode:sunfishcode/wasi-stdio-lock-asfd, r=joshtriplett bbfa98f9db5 Rollup merge of #102647 - oli-obk:tilde_const_bounds, r=fee1-dead 59d1bdd8f2f Rollup merge of #101642 - SkiFire13:fix-inplace-collection-leak, r=the8472 f3e72ec455f Rollup merge of #101189 - daxpedda:ready-into-inner, r=joshtriplett 7ce1200ae83 Only allow ~const bounds for traits with #[const_trait] 0384fc42056 fix backtrace small typo 8ca74cf6238 Rollup merge of #102628 - H4x5:master, r=scottmcm 3f67062cb5a Auto merge of #99099 - Stargateur:phantomdata_debug, r=joshtriplett f04ef8efca4 Auto merge of #102632 - matthiaskrgr:rollup-h8s3zmo, r=matthiaskrgr a481c5d189e Rollup merge of #101308 - nerdypepper:feature/is-ascii-octdigit, r=joshtriplett 567433b5ce8 Rollup merge of #100470 - reitermarkus:patch-1, r=joshtriplett 8c42269c6fa Rollup merge of #99460 - JanBeh:PR_asref_asmut_docs, r=joshtriplett 1d549b1bcd9 Rollup merge of #99216 - duarten:master, r=joshtriplett 6909ddc647b Rollup merge of #98218 - kpreid:nostdarc, r=joshtriplett f482f0048f5 Clarify documentation f0a5cd4a25a Reduce CString allocations in std as much as possible 2ad3cfd2365 Change the parameter name of From::from to `value` b848fdc67ee Rollup merge of #102607 - WaffleLapkin:docky_docky_slice_from_ptr_range, r=joshtriplett 534c5db4c8b Rollup merge of #102569 - eduardosm:from_str-example, r=joshtriplett 9804dd3dec7 Reword "has no meaning" per suggestion 92a9b84fa43 Add better assert messages for f32/f64 clamps 7439b12ef51 Add SAFETY comments for AsFd implementations on stdin/stdout/stderr ad94625a00f Add stability attributes. 2922bde2b06 scoped threads: pass closure through MaybeUninit to avoid invalid dangling references f636919e568 Sync docs of `slice::{from_ptr_range, from_ptr_range_mut}` e8302245c81 Document when `slice::from_ptr_range[_mut]` panic 4aa512e450b Do the `calloc` optimization for `Option` 0cd34a5ee9f Auto merge of #102586 - Dylan-DPC:rollup-g107h6z, r=Dylan-DPC 25ac3955773 Rollup merge of #102556 - WaffleLapkin:implied_by_btree_new, r=Mark-Simulacrum 543a57cf775 Rollup merge of #102098 - xfix:weak-upgrade-fetch-update, r=Mark-Simulacrum 0d3239621cf Rollup merge of #100451 - hovinen:no-panic-on-result-err-in-test, r=Mark-Simulacrum 03a00188803 remove unneeded attributes d040685b679 Auto merge of #98354 - camsteffen:is-some-and-by-value, r=m-ou-se 63531d5c28f add tests for panicking integer logarithms 0fc9572d350 always panic for invalid integer logarithm bf1826bdc23 Make Hash{Set,Map}::with_hasher unstably const dc124b075b5 Auto merge of #102548 - nikic:inline-cell-replace, r=scottmcm 01a6a1a471a Improve `FromStr` example 9f89b38812b Auto merge of #102535 - scottmcm:optimize-split-at-partition-point, r=thomcc 8d73328e939 Rollup merge of #102405 - hkBst:patch-3, r=Mark-Simulacrum 58bb1ab7519 Rollup merge of #102313 - anirudh24seven:update_sleep_ms_doc, r=Mark-Simulacrum 669cc22ffb3 Make `feature(const_btree_len)` implied by `feature(const_btree_new)` 2a75ed61a0c Change feature name to is_some_and 34f8975cdee Change is_some_and to take by value b9fa9597e2a Mark Cell::replace() as #[inline] 9e9a15e328a Tell LLVM that `partition_point` returns a valid fencepost 1c0347576d5 `SetFileTime` doesn't allow setting the file time to `0xFFFF_FFFF_FFFF_FFFF` a9e72c88a38 Error instead of panicking when setting file times if the passed `SystemTime` doesn't fit into the required type 5d237a63ac7 Detect and reject out-of-range integers in format string literals 3ed7afea555 Auto merge of #102520 - matthiaskrgr:rollup-7nreat0, r=matthiaskrgr 47c6add3230 Add back ConstFnMutClosure::new, fix formatting a8accdc5bf8 Fixed Documentation for wrap_mut_2_imp 66d3289d063 Added more const_closure functionality. 05e0e4a1086 Stabilize map_first_last b0243b28586 Standard library OS support for Apple WatchOS c2e2964adb5 Fix integer overflow in `format!("{:.0?}", Duration::MAX)` 43ef956b6e9 unsafe keyword: trait examples and unsafe_op_in_unsafe_fn update d4c3c78184e Rollup merge of #102452 - granolocks:grammar-tweak, r=thomcc 036570cb8fc Rollup merge of #102435 - GuillaumeGomez:improve-iterator-reduce-example, r=thomcc,vacuus 50f55087daf Rollup merge of #102342 - jmillikin:nonzero-negation, r=scottmcm 7bcaac5eefb Stabilize const_char_convert 2353f1bb96c Split out from_u32_unchecked from const_char_convert 98f31008ba0 Stabilize `nonnull_slice_from_raw_parts` 090f0276c22 fix minor ungrammatical sentence 44f4dae5776 Rollup merge of #102433 - RalfJung:temp-dir-typo, r=thomcc 0b0d5043a96 Rollup merge of #102368 - beetrees:nano-niche, r=joshtriplett 4ac5b8d9805 Rollup merge of #98368 - sunfishcode:sunfishcode/std-os-fd, r=joshtriplett 4e06fa8cec5 Add `is_empty()` method to `core::ffi::CStr`. 4d13b547cb1 Improve example of Iterator::reduce e111025021f nonzero_negation_ops: `inline(always)` -> `inline`. f30d3536083 nonzero_negation_ops: Set `issue = "102443"`. d98880b86fe env::temp_dir: fix a typo e2afb975136 Auto merge of #100719 - CohenArthur:rust-safe-intrinsic-attribute, r=wesleywiser 8b7766634d3 Add a niche to `Duration`, unix `SystemTime`, and non-apple `Instant` 4794dd1b327 std: never panic in `thread::park` and `thread::park_timeout` 85284473d97 Update result.rs d5f94b007f5 Rollup merge of #102288 - mejrs:inner, r=compiler-errors 2f2a6bfe229 Rollup merge of #102232 - Urgau:stabilize-bench_black_box, r=TaKO8Ki cb79b76e9a1 Sort mod dc45b206bcc Rollup merge of #101555 - jhpratt:stabilize-mixed_integer_ops, r=joshtriplett d85e81841ed Address feedback 2fdd71ce8f5 Wrapper suggestions 587daf32089 Fix indent 59c4c5137cd Add newlines ce76990c1bc Add test cases for const `Location` 44a5f0c0f44 Stabilize bench_black_box e760771dfe0 doc: rewrite doc for uint::{carrying_add,borrowing_sub} c38c4afa2f3 core: Mark all safe intrinsics with #[rustc_safe_intrinsic] 3824b4ac03f introduce `{char, u8}::is_ascii_octdigit` 411a6b84c63 Add negation methods for signed non-zero integers. 8fe5ee167f2 Auto merge of #102331 - notriddle:rollup-dmefd2d, r=notriddle c9de6c15d12 Auto merge of #102283 - GuillaumeGomez:option-code-example-unwrap-or-default, r=thomcc d9f0e3c2c9b Rollup merge of #102326 - yancyribbens:splin-mut-doc-change, r=thomcc 5d0e433d5b8 Rollup merge of #102322 - sigaloid:master, r=GuillaumeGomez 3b51dab2cbb Rollup merge of #102283 - GuillaumeGomez:option-code-example-unwrap-or-default, r=thomcc 54a83f498ae Use a macro to not have to copy-paste `ConstFnMutClosure::new(&mut fold, NeverShortCircuit::wrap_mut_2_imp)).0` everywhere cc45c08ba00 rustdoc: Update doc comment for splitn_mut to include mutable in the description 82d802a7b2c Document that Display entails ToString 08cc9de0c45 Update docs so that deprecated method points to relevant method 57a863deebf Improve code example for Option::unwrap_or_default b9fd0edc930 remove cfg(bootstrap) d33a7b3f912 replace stabilization placeholders 1128f748379 fs::get_path solarish version. f5d89cd68ba Auto merge of #102297 - fee1-dead-contrib:rollup-2np0cre, r=fee1-dead 254b256c2d9 Rollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum cd91cb623fe Rollup merge of #102263 - GuillaumeGomez:iterator-rposition-example, r=thomcc 8fec8d2385e Consistently write `RwLock` 0f8731798f7 Rollup merge of #102259 - gimbles:patch-1, r=joshtriplett 21caae623fa Rollup merge of #102245 - ink-feather-org:const_cmp_by, r=fee1-dead 56eff45c0a0 Rollup merge of #102200 - ink-feather-org:const_default_impls, r=fee1-dead 54adbdc5ba3 Rollup merge of #101800 - chriss0612:feat/const_split_at_mut, r=fee1-dead d4fc1cb4cd3 Rollup merge of #98111 - eggyal:issue-97982, r=GuillaumeGomez d27ca6aa8ea Clarify Iterator::rposition code example 8a73d40f154 Update option.rs f2c261f3b87 Remove unused variable. 8700f72e0b6 Auto merge of #99609 - workingjubilee:lossy-unix-strerror, r=thomcc fac25f43e1e Auto merge of #98457 - japaric:gh98378, r=m-ou-se ec63dcefb2a Auto merge of #102169 - scottmcm:constify-some-conditions, r=thomcc c8c0891c88d Constify cmp_min_max_by d93184f1f21 Add some more documentation 28b68a151fe Auto merge of #102234 - matthiaskrgr:rollup-5cb20l1, r=matthiaskrgr e28cad230c5 Rollup merge of #102186 - ink-feather-org:const_try_trait, r=fee1-dead 4cfc3618bfb Rollup merge of #100823 - WaffleLapkin:less_offsets, r=scottmcm b77c98585c3 Auto merge of #102167 - thomcc:exclusive-inline, r=scottmcm 1239ac5781e Auto merge of #102223 - matthiaskrgr:rollup-wb1qdhk, r=matthiaskrgr 96861e07584 Rollup merge of #102188 - flba-eb:doc_missed_at_rename, r=jyn514 938e3425407 Rollup merge of #102044 - ChrisDenton:BCrypt-system-rand, r=thomcc d4b313ac9c5 Put back one of the `use`s for intra-doc mentions fa05c260820 Auto merge of #100845 - timvermeulen:iter_compare, r=scottmcm c781094b5c8 Stabilize const `BTree{Map,Set}::new` 9abc0b27603 Constify Residual behind const_try 1784885bc62 Remove unused `ConstFn(Once)Closure` structs. d638ee15124 Added some spacing in const closure 6fd06734d53 Added const Default impls for Arrays and Tuples. b43d2adea2a Rollup merge of #102177 - inquisitivecrystal:std-doc-typo, r=Dylan-DPC a138990c6a4 Rollup merge of #102115 - Alfriadox:master, r=thomcc a3d73b9cfda Rollup merge of #102094 - GuillaumeGomez:bool-from-str-missing-docs, r=scottmcm 6a850b57599 Fixed Doc-Tests 00635141343 Update doc after renaming fn is_zero 3336beeef61 Constifed Try trait c24d7d58753 Added const_closure 0a0f4bd52be Fix a typo in `std`'s root docs 26a008cb778 rustfmt 6cdcffc2c32 Make ZST checks in core/alloc more readable 1c8805b95fa Add `#[inline]` to trivial functions on `core::sync::Exclusive` 11f29a2cb8e Add `AsFd` implementations for stdio lock types on WASI. 557bb58d9e0 Rollup merge of #102144 - chriss0612:const_convert_control_flow, r=scottmcm 72b2f142d90 Derive Eq/PartialEq instead of manually implementing it d9291d1221c Constify {FormResidual, Try} for ControlFlow a3143c2246f Apply changes proposed in the review 62ab25fda0e Rollup merge of #102131 - orlp:patch-1, r=thomcc f6830029f02 Rollup merge of #102036 - Patiga:remove-io-errorkind-other-use-in-std, r=Mark-Simulacrum d47244bbadb Added which number is computed in compute_float. 7b4dea6e44d Add missing assertion d7ca09d44c5 Auto merge of #100982 - fee1-dead-contrib:const-impl-requires-const-trait, r=oli-obk 52d429f893a Remove trailing whitespace 87d990397f7 Rollup merge of #102102 - GuillaumeGomez:doc-aliases-sized-trait, r=thomcc ea896860203 Add examples to `bool::then` and `bool::then_some` c0b40cf6dd3 Add `rustc_allow_const_fn_unstable` annotations to pre-existing `Layout` methods 29df76c9fac Add doc aliases on Sized trait d6f15a60321 Use fetch_update in sync::Weak::upgrade 5880265ae13 Rollup merge of #102058 - mqudsi:path_extension_docs, r=thomcc d1ff17c7da0 Rollup merge of #101995 - scottmcm:carrying-mul-example, r=Mark-Simulacrum be0f91f83ca Rollup merge of #89891 - ojeda:modular-alloc, r=Mark-Simulacrum 62486f67c48 Add missing documentation for `bool::from_str` 4681840bec1 Auto merge of #100214 - scottmcm:strict-range, r=thomcc da45ea6c01a Auto merge of #100581 - joboet:sync_rwlock_everywhere, r=thomcc 1c1f1ea9a21 Add `ptr::Alignment` type af7ebd5595c Remove `RtlGenRandom` (take two) 10bc7c39953 Clarify Path::extension() semantics in docs abstract e6c35b78f28 Add the `#[derive_const]` attribute 6b461f834c9 Optimize `array::IntoIter` 5fccae110f0 Remove use of `io::ErrorKind::Other` in std e713704790b std: use `sync::RwLock` for internal statics 3ca308ed6c0 Rollup merge of #101798 - y86-dev:const_waker, r=lcnr e0e42d33e7b Rollup merge of #101389 - lukaslueg:rcgetmutdocs, r=m-ou-se 799c1c52f24 Added tracking issue 2a6cf050d78 Document surprising and dangerous fs::Permissions behaviour on Unix dce0d0e86f5 Add another example for `uN::carrying_mul` 3d53cd01dec Auto merge of #101955 - jam1garner:fix-proc-macro-typo, r=petrochenkov 225f5e739f4 Move `unix_socket_abstract` feature API to `SocketAddrExt`. 56b1e13a704 Adjust `tcp_quickack` feature to allow other `os::linux::net` features. c7a8f326872 Auto merge of #101816 - raldone01:cleanup/select_nth_unstable, r=Mark-Simulacrum ea2db9dc75f Fix typo in proc_macro Span::eq a5b52f131a1 Auto merge of #101949 - matthiaskrgr:rollup-xu5cqnd, r=matthiaskrgr fa29a830008 Rollup merge of #101821 - thomcc:unicode-15, r=Manishearth 44784416d08 Add `Box<[T; N]>: TryFrom>` fafcf9f2bc1 Rollup merge of #101861 - wesleywiser:update_stdarch, r=Amanieu 85853b676c8 Rollup merge of #101672 - idigdoug:array_try_into, r=Mark-Simulacrum 4b8da76a24a Auto merge of #101938 - Dylan-DPC:rollup-6vlohhs, r=Dylan-DPC 4dcf44699de Rollup merge of #101931 - msakuta:master, r=thomcc 263b3d864b1 Rollup merge of #93628 - est31:stabilize_let_else, r=joshtriplett fadd2f9dbc0 Auto merge of #101784 - reitermarkus:const-memchr, r=thomcc 65faf2c3555 Fix a typo in docstring 902091dc95a Do not panic when a test function returns Result::Err. 9d002bdd3fd Rollup merge of #101802 - chriss0612:const_fn_trait_ref_impls, r=fee1-dead 07514f8fff6 Add `const_trait` to `Allocator` 501659e9213 append_const_msg for std traits c448404db3d Mark `Drop` with `#[const_trait]` e8537cb4f58 Do not implement `Unpin` as const 2a3e2f8b0d9 Prevent errors for stage0 rustc build ba0e4cc77a1 Add more `const_trait` annotations b14b2c954dc Add `const_trait`s 2e95fbe4c53 Require `#[const_trait]` for `const` `impl`s a0ab0a6750e Only enable the let_else feature on bootstrap 63748181717 Update stdarch da6446cc4bd Rollup merge of #101810 - raldone01:feat/const_partial_eq_ordering, r=fee1-dead c376163f0a6 Rollup merge of #101559 - andrewpollack:add-backtrace-off-fuchsia, r=tmandry e2bee389787 Adding backtrace off option for fuchsia targets a4dd3b9b0c6 Make `core::mem::copy` const 90867fed516 Bump Unicode to version 15.0.0, regenerate tables e87d7c7459f Cleanup closures. 738f314c35f Warn about safety of `fetch_update` 3014aeac0fc Constify `PartialEq` for Ordering. 7797665145f Add const_slice_split_at_mut Feature gate. 86f6ea37f0c Added Tracking Issue number. 5a983f3ced0 Made from_waker, waker, from_raw const a711889928b Constify impl Fn* &(mut) Fn* cc25b5a0ad1 expand documentation on type conversion w.r.t. `UnsafeCell` 29af2a8ff2c Simplify `const` `memchr`. 03026ca7a53 Rollup merge of #101754 - NaokiM03:rename-log-to-ilog, r=Dylan-DPC 464ca09e0c4 Rollup merge of #101745 - jay3332:patch-1, r=JohnTitor 239de9719bc Fix doc of log function 0c061544560 Auto merge of #100640 - reitermarkus:socket-display-buffer, r=thomcc 37e545926a7 Fix typo in concat_bytes documentation b0f207d2325 Rollup merge of #100291 - WaffleLapkin:cstr_const_methods, r=oli-obk e847f7f5609 Simplify `clippy` fix. e7dc719d09e Add `rustc_diagnostic_item` for IP addresses. bad12684439 Flatten `net` module again. 837a72c643c Move `net::parser` into `net::addr` module. bf5391160dd Add tests for `SockAddr` `Display`. 5f95cf46985 Use `DisplayBuffer` for socket addresses. 34c95f7e256 constify `CStr` methods 8925e8c079c Rollup merge of #101671 - LingMan:ieee_754, r=Dylan-DPC fd9db35ad6d Rollup merge of #100767 - kadiwa4:escape_ascii, r=jackh726 8e7758135b4 add description of the memory layout for `UnsafeCell` b70f7429853 Auto merge of #100251 - compiler-errors:tuple-trait-2, r=jackh726 0f151e0eefb Auto merge of #101442 - joboet:null_check_tcs, r=thomcc be261541038 Auto merge of #101299 - saethlin:vecdeque-drain-drop, r=thomcc a745193c60d std: check if TCS is a null pointer 81a317eb171 std: use correct clock in `park_timeout` on Horizon 0c369a77a48 Auto merge of #101482 - joboet:netbsd_parker, r=sanxiyn 7bc1e301d7c array docs - advertise how to get array from slice 940f00cbe25 Fix naming format of IEEE 754 standard 9c925074bc8 Auto merge of #101643 - ChrisDenton:alloc-link-kernel32, r=thomcc 26c76d19606 Alternate approach; just modify Drain 8412d6fa22c Remove &[T] from vec_deque::Drain 5bb94f06f68 std: optimize thread parking on NetBSD f1a98b22745 Make the one-liner more descriptive 85cd6ac2568 Rollup merge of #101606 - akhi3030:patch-1, r=Dylan-DPC b18f3947b84 Better documentation for env::home_dir()'s broken behaviour 927d8511463 Update test 766f77d9bc2 Update documentation 2b4c6ebda69 Explicitly link kernel32.lib from alloc a6a5f3b9a66 Auto merge of #101483 - oli-obk:guaranteed_opt, r=fee1-dead 19bdb0892ba Adapt inplace collection leak test to check for no leaks bac6a2cda6d Fix leaking in inplace collection when destructor panics d8532c18c39 Auto merge of #101617 - Dylan-DPC:rollup-iiy4ipc, r=Dylan-DPC 0f9021942e5 Rollup merge of #101529 - mousetail:patch-2, r=thomcc 9de6dc76d14 Rollup merge of #101366 - ChrisDenton:unc-forward-slash, r=m-ou-se 20d96e8cf83 The `<*const T>::guaranteed_*` methods now return an option for the unknown case a0194a2529d Rollup merge of #101529 - mousetail:patch-2, r=thomcc 7f7ae3565f9 Rollup merge of #101495 - bjorn3:pause-no-sse2, r=Mark-Simulacrum a6c835fc041 std: use futex-based locks and thread parker on Hermit 1cc6f32a2bd doc: fix minor typo a9e01d2f552 Rollup merge of #101556 - compiler-errors:tweak-generator-print, r=jackh726 ae644c1633e Auto merge of #93873 - Stovent:big-ints, r=m-ou-se 265e6d599f6 Rollup merge of #101423 - mkroening:hermit-warnings, r=sanxiyn bba0a49ec59 Rollup merge of #101422 - mkroening:hermit-file-time, r=joshtriplett 1027d99f675 Generator return doesn't need to be a lang item 1849293dfb4 Stabilize `#![feature(mixed_integer_ops)]` a41655b57af Auto merge of #101544 - matthiaskrgr:rollup-4urx917, r=matthiaskrgr 6cc733341af Auto merge of #101476 - ChrisDenton:BCryptRandom-fix, r=thomcc 54b4070536e Typo 10e90c2d60c Use `CURRENT_RUSTC_VERSION` 3ba9830a2f8 Add doctest efdcb6f9809 stdio: Document no support for writing to non-blocking stdio/stderr 7f7d3f0847b Don't break windows/rand for miri 70430d04b36 This example was broken 2edb0f3455b Stabilize `nonzero_bits` 842ec1e765b Rollup merge of #101481 - ChrisDenton:uwp-fix, r=thomcc 4de06977608 Open a BCrypt algorithm handle d43321e8986 Compile spin_loop_hint as pause on x86 even without sse2 enabled dd02742bde4 Auto merge of #100733 - scottmcm:inline-from-from-identity, r=m-ou-se 922c1d049eb Fix compile errors for uwp-windows-msvc targets b6e1978bc0d Rollup merge of #101412 - WaffleLapkin:improve_std_ptr_code_leftovers, r=scottmcm 580a6782ef4 Rollup merge of #101287 - Adam-Gleave:doc_bool_then_some, r=scottmcm 3d4d9a3e3cf Rollup merge of #101426 - beetrees:dup-no-stdio, r=thomcc ae5c4ede3b1 Rollup merge of #101404 - joboet:always_cleanup_stdout, r=joshtriplett a4b6066a1c0 separate the receiver from arguments in HIR under /clippy f352d282ca3 Auto merge of #101439 - Dylan-DPC:rollup-2wf1mtj, r=Dylan-DPC fb66c4015a1 Rollup merge of #101391 - matthiaskrgr:perf0309, r=oli-obk 840fae3085d std: clarify semantics of SGX parker b071fac2281 std: fix cleanup for uninitialized stdout (#101375) e517730806b Auto merge of #101414 - mystor:pm_nested_cross_thread, r=eddyb 2195d8f8d0e Auto merge of #100759 - fee1-dead-contrib:const_eval_select_real_intrinsic, r=oli-obk,RalfJung d6dbdac0f54 Auto merge of #100576 - joboet:movable_const_remutex, r=Mark-Simulacrum 91cf30e8d32 Hermit: Remove unused socklen_t (dead_code) bbde4a93db9 Hermit: Fix unused_imports e49c75d4bc5 Hermit: Add File::set_time stub 3b179c6afb6 Auto merge of #93455 - asquared31415:vec-zero-opts, r=thomcc 11dfff48a5c proc_macro/bridge: use the cross-thread executor for nested proc-macros 2666197c206 Rollup merge of #101401 - mx00s:expand-const, r=fee1-dead 55c4b370d23 Rollup merge of #101394 - CAD97:patch-3, r=Mark-Simulacrum 056493b4b2f Rollup merge of #101385 - BartMassey-upstream:file-doc, r=thomcc 1180b232d1d Rollup merge of #101322 - ChrisDenton:internal-doc, r=Mark-Simulacrum 0366d36df58 replace `as usize` casts with `usize::from` in slice sort 69a9762be33 remove some integer casts from slice iter 2ef79943ceb Address feedback from PR #101401 12dbc837f8e Make `char::is_lowercase` and `char::is_uppercase` const 51a5124c3db Replace `offset` with `add` in `fmt/num.rs` & remove some casts f1a9894fdfe use `pointer::add` in memchr impl 9fb1811ecf8 Make code worling w/ pointers in `library/std/src/sys/sgx/abi/usercalls/alloc.rs` nicer 88e9de7378c Auto merge of #101296 - compiler-errors:head-span-for-enclosing-scope, r=oli-obk c89e440224a Add `inline(always)` to rt functions a421ec154a3 Add `inline(always)` to function generated by macro b013602f19c Make `const_eval_select` a real intrinsic c2cfb057f68 Don't duplicate file descriptors into stdio fds e4096ce225b Auto merge of #100726 - jswrenn:transmute, r=oli-obk 7c867cab62d Address nits, rename enclosing_scope => parent_label 1e048cace4e Forbid mixing `System` with sytem allocator calls 46e7ed6492d more clippy::perf fixes 236b4ab734b Tone down explanation on RefCell::get_mut 9b0e1ed6306 updated description of File struct in std::fs 74e3e9e0b15 Auto merge of #101342 - saethlin:update-backtrace, r=Mark-Simulacrum 6bea92de062 std: make `ReentrantMutex` movable and `const`; simplify `Stdout` initialization f66f5765ad0 Restore old behaviour on broken UNC paths 211c6f59ec8 Rollup merge of #101330 - wkordalski:hashset-drain-doc, r=jyn514 0ffb69a7132 Rollup merge of #101325 - ChrisDenton:BCRYPT_RNG_ALG_HANDLE, r=thomcc 29f33b540b9 Rollup merge of #99736 - lopopolo:lopopolo/gh-80996-partial-stabilization-bounds-as-ref, r=dtolnay c4b6f0dd703 implement IsZero for Saturating and Wrapping 81e9c3a65ce Fix compilation of the doc tests on Windows. 9c2e8cd9282 Auto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplett 892981eeefd Update backtrace 3ff8e15ad91 Rollup merge of #101260 - ChrisDenton:attribute-tag, r=thomcc 8c7c3f0db91 Fix `std::collections::HashSet::drain` documentation 147d5035ff6 Use `BCRYPT_RNG_ALG_HANDLE` by default 6d454d780d6 Fix internal doc link 900d7f877c8 Rollup merge of #99583 - shepmaster:provider-plus-plus, r=yaahc 0cbbcff7398 Rollup merge of #97739 - a2aaron:let_underscore, r=estebank 38a4a5b4996 Auto merge of #100395 - Dylan-DPC:rollup-ajrwo1s, r=Dylan-DPC 0b5525f7dd4 Rollup merge of #101270 - m-ou-se:update-comment, r=joshtriplett 27a1b8863c6 Rollup merge of #101190 - yjhn:patch-1, r=Mark-Simulacrum 174de79194a Remove trailing whitespace 82eb90d0a22 Document eager evaluation of `bool::then_some` argument b4ce91be300 Sort tests at compile time, not at startup cee5509c5f2 Update outdated comment about output capturing in print_to. 676a6976192 Auto merge of #100707 - dzvon:fix-typo, r=davidtwco fe41ad68de4 unix_sigpipe: Make `sigpipe` param docs long-form f39f424d103 Use `FILE_ATTRIBUTE_TAG_INFO` to get reparse tag c135f80d115 Auto merge of #100210 - mystor:proc_macro_diag_struct, r=eddyb ab23fafc031 Rollup merge of #101236 - thomcc:winfs-nozero, r=ChrisDenton 1412ee3f840 Rollup merge of #101229 - mgeisler:link-try-operator, r=thomcc b27551307f2 unix_sigpipe: Add docs for `init()` `sigpipe` param a6a23315046 unix_sigpipe: Inline compiler sigpipe constants in std f144a5810d4 Rollup merge of #101237 - RalfJung:into-iter-zst, r=thomcc 35babb2afc8 fix into_iter on ZST 38e84fe385a Avoid needless buffer zeroing in `std::sys::windows::fs` b1de1801ff1 Correct typo 09ae72d41f2 Fix a bunch of typo 2271a7c775d Link “? operator” to relevant chapter in The Book 44eb4366ff1 Rollup merge of #101171 - thomcc:fix-winfs-ub, r=ChrisDenton 8408bb90d7a Rollup merge of #101011 - BlackHoleFox:apple-random-improvements, r=thomcc a7464a13bd8 Rollup merge of #100984 - ChrisDenton:reinstate-init, r=Mark-Simulacrum 6d94f38a81b Rollup merge of #101193 - thomcc:win-stdio-nozero, r=ChrisDenton 9baa2b4c94e Rollup merge of #101159 - tspiteri:track-const-slice-split_at, r=Mark-Simulacrum 92d88bf1301 Rollup merge of #100892 - sunfishcode:wasi-stdio-asfd, r=joshtriplett 59fe7b3c6bf Auto merge of #98919 - 5225225:stricter-invalid-value, r=RalfJung 613db91f904 Avoid `MaybeUninit::uninit_array()` ce9076b37a9 Fix UB in Windows `DirBuffIter` (provenance and alignment) 8ba5c7f6715 Implement `Ready::into_inner()` c0b49dda27e Avoid zeroing large stack buffers in stdio on Windows 134b1b3f535 Make docs formulation more consistent for NonZero{int} c0de4f94c38 Auto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPC fc94c7f0350 Replace `AlignedAs` with a more specific `Align8` type e968b71739b Fix UWP and use `AlignedReparseBuf` in `symlink_junction_inner` 3485f2d692e Rollup merge of #95376 - WaffleLapkin:drain_keep_rest, r=dtolnay da238b6f5c4 Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrum 3a3ea32e861 Fix some possible UB in std::sys::windows 4074e089079 Auto merge of #101167 - matthiaskrgr:rollup-yt3jdmp, r=matthiaskrgr 8de30cd7388 Rollup merge of #101056 - kpreid:prim-doc, r=JohnTitor d16e6e85b6d add tracking issue number to const_slice_split_at_not_mut 1b1133975e2 Revert let_chains stabilization 59a40a80347 Re-introduce `unstable` attributes. 7c870a58e55 Clarify that the `fd` module is supported on Unix and WASI. 6165554c6e2 Make `std::os::fd` public. ddbb2b98410 Rollup merge of #100934 - a1phyr:improve_fmt_PadAdapter, r=Mark-Simulacrum e5dcd551cf0 Rollup merge of #100819 - WaffleLapkin:use_ptr_byte_methods, r=scottmcm 6a364992615 Rollup merge of #100337 - camelid:stabilize-io_read_to_string, r=JohnTitor 0709c66d605 Rollup merge of #98801 - joshtriplett:file-create-new, r=thomcc 3c1ba8b4dba Auto merge of #100786 - sunshowers:macos-posix-chdir, r=sunshowers 2aa6acbcdab Rollup merge of #96334 - devnexen:socket_mark, r=dtolnay 53afcaa850a Rollup merge of #94890 - marmeladema:ip-addr-try-from-bytes, r=joshtriplett 9724ce76d01 Use posix_spawn for absolute paths on macOS f891245a5b4 Auto merge of #100578 - Urgau:float-next-up-down, r=scottmcm eea4b30ddd6 Stabilize `std::io::read_to_string` 9bca1a597e5 Support `#[unix_sigpipe = "inherit|sig_dfl|sig_ign"]` on `fn main()` adf5e26bae0 Auto merge of #100201 - RalfJung:thread-local-key, r=thomcc a833a9b6b56 fill-in tracking issue for `feature(drain_keep_rest)` 6ac2c2c3090 add examples to `vec::Drain{,Filter}::keep_rest` docs 82cad1da2ab Auto merge of #96324 - berendjan:set_tcp_quickack, r=dtolnay 8ce5bf36417 fs::get_mode enable getting the data via fcntl/F_GETFL on major BSD supporting this flag. 2a31b7597c6 Rollup merge of #100955 - nrc:chain, r=joshtriplett dede103df46 Rollup merge of #100885 - mzohreva:mz/sgx-export-cancel-type, r=Mark-Simulacrum 70f3b423ff9 Rollup merge of #100520 - jakubdabek:patch-1, r=thomcc 22157d6fb05 Rollup merge of #100296 - BlackHoleFox:os-error-aliases, r=thomcc 419ba61b439 Rollup merge of #99570 - XrXr:box-from-slice-docs, r=thomcc 4f60e5af9d5 Rollup merge of #97015 - nrc:read-buf-cursor, r=Mark-Simulacrum e6054301396 Auto merge of #92845 - Amanieu:std_personality, r=Mark-Simulacrum 9dc156ed35b Reinstate preloading of some dll imports 7cde32ed05e Auto merge of #96946 - WaffleLapkin:ptr_mask, r=scottmcm 38bd97e203b Partially stabilize `bound_as_ref` by stablizing `Bound::as_ref` 16921f56e1c Adjust backtrace stabilization version to CURRENT_RUSTC_VERSION 45b08f708b0 Adjust ptr_const_cast stabilization version to CURRENT_RUSTC_VERSION 78340f24c02 Rollup merge of #100953 - joshtriplett:write-docs, r=Mark-Simulacrum a4e3d16998e Rollup merge of #96240 - fee1-dead-contrib:stabilize_const_offset_from, r=Mark-Simulacrum be65537b22c Re-add some justification 5185b6999fb Creating uninitialized integers is UB e7d6b3f2f1b Add the syntax of references to their documentation summary. 1c596a635ea `alloc`: add unstable cfg features `no_rc` and `no_sync` 2b81bc1be35 Support parsing IP addresses from a byte string 763d360d23e Rollup merge of #100128 - kpreid:waker-doc, r=thomcc 6789a25332c Rollup merge of #99742 - sigaloid:master, r=thomcc a15650c7416 Rollup merge of #95005 - ssomers:btree_static_assert, r=thomcc 693ea43c9f3 constify `Location` methods c4af9a13381 Auto merge of #101017 - JohnTitor:rollup-73f2fhb, r=JohnTitor 1b9c488e6b7 Rollup merge of #100933 - a1phyr:cheap_assert_match_failed, r=JoshTriplett 6c57933b61b Rollup merge of #100604 - dtolnay:okorerr, r=m-ou-se bda064ae639 Rollup merge of #100076 - tspiteri:const_slice_split_at, r=oli-obk c57464389b6 Auto merge of #99487 - bmacnaughton:is_whitespace_updates, r=thomcc c11761fd8fb Use getentropy when possible on all Apple platforms 38526660971 Auto merge of #100911 - tmiasko:update-stdarch, r=Amanieu 7c1cfaef53e review 80b80c517fd error::Error: remove some comments c0bc12d151d Do not include `const_ptr_sub_ptr` in this stabilization 74a68109746 Stabilize `const_ptr_offset_from`. 4b3b946723c Rollup merge of #100921 - ChayimFriedman2:and-eager-eval, r=JohnTitor bcf4c069453 Rollup merge of #99332 - jyn514:stabilize-label-break-value, r=petrochenkov 187adea0303 Clarify comment to fit `as _` better 7228644d16c Rollup merge of #100922 - GuillaumeGomez:rewrite-error-index, r=notriddle 2b9700fa537 Rollup merge of #100855 - IsaacCloos:master, r=joshtriplett 5bd5522d9e8 Rollup merge of #100220 - scottmcm:fix-by-ref-sized, r=joshtriplett 2a1f750982d error::Error: rename the Demand arguments from req to demand 2cd202a82b2 error::Error: rename the chain method to sources 33bd8c6691f Expand example to show how to implement qualified trait names 6de35b0700c Update `write!` docs: can now import traits as `_` to avoid conflicts 6e05bfb5fae Remove some documentation duplicated between `writeln!` and `write!` d59285a5a6d Stabilize `#![feature(label_break_value)]` fb5fb9f3c8c Auto merge of #96869 - sunfishcode:main, r=joshtriplett 2edf2cb29e3 Remove a packing branch from `fmt::builders::PadAdapter` 88e40ab5f9f Reduce code size of `assert_matches_failed` cb5cca7b8a4 Auto merge of #99917 - yaahc:error-in-core-move, r=thomcc a7167583c83 Fix links to error codes 9e3846239ed Add a warning about `Option/Result::and()` being eagerly evaluated abbb352c05c Make use of `[wrapping_]byte_{add,sub}` 8433db09e32 Rollup merge of #100835 - devnexen:listener_followups, r=devnexen 86397f07400 Add `Provider::{would_be_satisfied_by_value_of,would_be_satisfied_by_ref_of}` d6450da0eef Remove aliases for old atomic intrinsics names d9020c54595 Use renamed atomic intrinsics in panic_unwind 56be7ce804c Update stdarch submodule d3efa967889 Support eager and lazy methods for providing references and values e79166a086e Update comment about personalities in panic_abort 02b37e87e43 Remove custom frame info registration on i686-pc-windows-gnu beed38f4e9b Move personality functions to std 46a2dc50c27 Auto merge of #100782 - thomcc:fix-android-sigaddset, r=Mark-Simulacrum e018e1d302a Fix comment on the SEH personality function e9b309aafc8 Remove out-of-context comment in `mem::MaybeUninit` documentation 4a36c118ad8 Add `AsFd` implementations for stdio types on WASI. 346552f0e88 Move error trait into core b4f96e34a76 safe transmute: use `Assume` struct to provide analysis options d84bac34da6 Export Cancel from std::os::fortanix_sgx::usercalls::raw f309b846d1c net listen backlog update, follow-up from #97963. b3e666657de Rollup merge of #100872 - JanBeh:PR_vec_default_alloc_doc, r=fee1-dead c97d1e5d77a Rollup merge of #100820 - WaffleLapkin:use_ptr_is_aligned_methods, r=scottmcm c407a95b6a5 Rollup merge of #100331 - lo48576:try-reserve-preserve-on-failure, r=thomcc 9cfa07c8cbf Rollup merge of #99957 - chotchki:ip-globally-reachable_rebase, r=Mark-Simulacrum 3c5bdfcac20 update and extend some comments, and cfg-out some unused code 0976f0bbb5f std: use realstd fast key when building tests a78426a5914 Add guarantee that Vec::default() does not alloc 17e873709df Rollup merge of #99386 - AngelicosPhosphoros:add_retain_test_maybeuninit, r=JohnTitor b921f640c99 Rollup merge of #93162 - camsteffen:std-prim-docs, r=Mark-Simulacrum f1e1dfd9803 Extra documentation for new formatting feature 5f7d1af54b7 Use ptr::metadata in <[T]>::len implementation ebcbb4de734 Rollup merge of #100839 - nelsonjchen:consistent_child_stdin_field_desc, r=thomcc 25425dc256b Rollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcm e1387feb983 Rollup merge of #100821 - WaffleLapkin:ptr_add_docs, r=scottmcm 97de3bd8b40 Rollup merge of #100663 - clarfonthey:const-reverse, r=scottmcm 3a3f0c7e69f Rollup merge of #100556 - Alex-Velez:patch-1, r=scottmcm 0cf2a9f00a6 Make use of `pointer::is_aligned[_to]` 231fb0274d0 Use internal iteration in `Iterator::{cmp_by, partial_cmp_by, eq_by}` b78f99e8bc6 Make doc for stdin field of process consistent 6e115c1c13d Fix redundant comparison 6704f17f7bc fix nitpicks from review 4c0626caa24 fill in tracking issue for `feature(ptr_mask)` ed046c9cc33 Add pointer masking convenience functions 4871fad4924 Make some docs nicer wrt pointer offsets e677f433f66 Replace most uses of `pointer::offset` with `add` and `sub` fc099b9d07d Improve primitive/std docs separation and headers 89325ff9b9e Remove useless pointer cast 81c82e088be Auto merge of #100810 - matthiaskrgr:rollup-xep778s, r=matthiaskrgr 9640d72e5f9 Rollup merge of #100129 - RalfJung:miri-test-libstd, r=thomcc 808831ba620 Rollup merge of #97963 - devnexen:net_listener_neg, r=the8472 8518dcaae53 Rollup merge of #100710 - ChrisDenton:load-library, r=thomcc f4b2ac1b864 Rollup merge of #100642 - mzohreva:mz/update-sgx-abi-cancel-queue, r=Mark-Simulacrum 6ea5bc99faa Rollup merge of #100585 - wooorm:patch-1, r=Mark-Simulacrum 258846a512d Rollup merge of #99544 - dylni:expose-utf8lossy, r=Mark-Simulacrum ea3afb9f343 Expose `Utf8Lossy` as `Utf8Chunks` 5fda8fe4ac7 Fix generic bound of `SplitInclusive`'s `DoubleEndedIterator` impl 34a6faae5e6 Rollup merge of #100729 - thomcc:less-initialized, r=ChrisDenton 7af3df9b6c1 Rollup merge of #100383 - fortanix:raoul/aepic_leak_mitigation, r=cuviper ce026486916 Use const instead of static 980632e8357 Simplify load/store 4d33d0a6f24 Tracking issue for const_reverse 6c89c4f8159 Align android `sigaddset` impl with the reference impl from Bionic 872eb681282 use <[u8]>::escape_ascii instead of core::ascii::escape_default 9c205338b40 Fix comment typo 0c8ca225824 Auto merge of #99541 - timvermeulen:flatten_cleanup, r=the8472 be5a7f61c32 Inline `>::from` df0a1b5df85 clarify lib.rs attribute structure dd75d2b17d1 silence some unused-fn warnings in miri std builds abe56fb423b make many std tests work in Miri 74266f02729 add some Miri-only tests 910afd71dd1 add miri-test-libstd support to libstd a47ea73742b Avoid zeroing a 1kb stack buffer on every call to `std::sys::windows::fill_utf16_buf` e59988e0d75 Auto merge of #98655 - nnethercote:dont-derive-PartialEq-ne, r=dtolnay 49b7b736fc2 Address reviewer comments 25cecfdf0db Windows: Load synch functions together d219f5a06b5 Remove unstable Result::into_ok_or_err c0cb51840f0 Rollup merge of #100661 - PunkyMunky64:patch-1, r=thomcc d6b6e9f761f Rollup merge of #100660 - PunkyMunky64:patch-2, r=thomcc 1a4677a0c97 Rollup merge of #100532 - RalfJung:unwind-miri, r=Mark-Simulacrum 0f3cc3053b0 Mitigate Stale Data Read for xAPIC vulnerability 5b30d80680c Make slice::reverse const 1c0f84831a2 Fixed a few documentation errors 9de13bec444 Fixed a few documentation errors 8608fdc150b Update src/test/assembly/x86_64-floating-point-clamp.rs 76fda41d814 Update fortanix-sgx-abi and export some useful SGX usercall traits f75a5629ffa Simplify `IpDisplayBuffer` API. 761253c70ca Use `MaybeUninit` for `IpDisplayBuffer`. c580e9bf3d9 Move `IpDisplayBuffer` into submodule. 252b69b941b Add `IpDisplayBuffer` helper struct. 58e86fdcfc4 Refactor copying data to userspace 648f735ad2f Rollup merge of #100460 - cuviper:drop-llvm-12, r=nagisa c45a69bfd44 Auto merge of #100007 - ChrisDenton:dtor-inline-never, r=michaelwoerister bf0e6cb0cb7 Optimize poison guards to ZSTs when panic=abort c0f84c93cc2 unwind: don't build dependency when building for Miri e08580c4732 Fix trailing space showing up in example 42eebb5684d Say that the identity holds only for all finite numbers (aka not NaN) 5659e5c8eff Semicolon after macro_rules definition. e430f1e7759 Float biteq macros can be unused if test is skipped. fd546f3270b Skip next_up/down tests entirely on x87. b87881cb7e1 Conditionally do not compile NaN roundtrip tests on x87 fp. 756cc514174 Added tracking issue numbers for float_next_up_down. 48b9e943b76 Ensure NaN references values go through function boundary for next_up/down. 731f159ba25 Fixed float next_up/down 32-bit x87 float NaN roundtrip test case. 74d88d92b1d Added next_up and next_down for f32/f64. 37f0bdc57ba Properly forward `ByRefSized::fold` to the inner iterator e1597b86551 Auto merge of #96350 - austinabell:skip_optimization, r=Mark-Simulacrum 0945be75e79 Update the minimum external LLVM to 13 4619c811b9b Rollup merge of #100249 - Meziu:master, r=joshtriplett ae9efe99e95 fix(iter::skip): Optimize `next` and `nth` implementations of `Skip` 96999f214cb Rollup merge of #100026 - WaffleLapkin:array-chunks, r=scottmcm b002f335b75 Add mention of `BufReader` in `Read::bytes` docs 9478b243b18 Rollup merge of #100501 - RalfJung:miri-from-exposed-addr, r=Mark-Simulacrum 4fe26d1bacc Rollup merge of #100407 - RalfJung:no-int2ptr, r=Mark-Simulacrum 8a4f6aaaf92 nicer Miri backtraces for from_exposed_addr aa66952c18a created tcpstream quickack trait for linux and android e090513bb86 address review comments, add tracking issue 86348d97047 add Vec::push_within_capacity - fallible, does not allocate d4198ebfa5e Tweak `FpCategory` example order. 5bdd59bf374 Apply changes from rustfmt bump 8ebbc28834f Adjust cfgs ab54bb1f786 Clarify `array:from_fn` documentation 59349402ee2 Rollup merge of #100255 - thedanvail:issue-98861-fix, r=joshtriplett d5a3e4e51eb Rollup merge of #100030 - WaffleLapkin:nice_pointer_sis, r=scottmcm 350ad80d664 Rollup merge of #100022 - joboet:faster_threadid, r=joshtriplett f4fe0bc7294 fill-in tracking issue for `feature(iter_array_chunks)` a5448c0db4a address review comments 9204bb05552 Auto merge of #99624 - vincenzopalazzo:macros/unix_error, r=Amanieu 7fc9033fab1 Rollup merge of #100418 - tbodt:stabilize-backtrace, r=dtolnay bbbc2142387 Rollup merge of #100203 - compiler-errors:command-args-size-hint, r=m-ou-se b2716b1e464 Rollup merge of #100112 - RalfJung:assert_send_and_sync, r=m-ou-se 21022afca2e Rollup merge of #99511 - RalfJung:raw_eq, r=wesleywiser 8753625148a Rollup merge of #99421 - Bryanskiy:android-crt-static, r=petrochenkov 9680e0e914e Add stability attributes to BacktraceStatus variants bb13209be6e Rollup merge of #100287 - cuviper:no-linux-prctl, r=Mark-Simulacrum 92d065bab38 Rollup merge of #100184 - Kixunil:stabilize_ptr_const_cast, r=m-ou-se 2f58c63f949 avoid some int2ptr casts in thread_local_key tests 91a964f8be9 more typos 1570246c483 Rollup merge of #100030 - WaffleLapkin:nice_pointer_sis, r=scottmcm cd40cb3391c Rollup merge of #100007 - ChrisDenton:dtor-inline-never, r=michaelwoerister af6ea6db115 Auto merge of #100298 - BlackHoleFox:hashmap_keygen_cleanup, r=Mark-Simulacrum 0e00d51c98b promote debug_assert to assert cd5f89df5dc Auto merge of #99174 - scottmcm:reoptimize-layout-array, r=joshtriplett f4a0a6f2da6 grammar 05850bd5fe7 add crt-static for android fe046944f08 Rollup merge of #100371 - xfix:inline-from-bytes-with-nul-unchecked-rt-impl, r=scottmcm 169f179071c Rollup merge of #100353 - theli-ua:master, r=joshtriplett 07efedb81c0 Stabilize ptr_const_cast c477d801392 std: optimize thread ID generation 5fa7064a964 Inline CStr::from_bytes_with_nul_unchecked::rt_impl cd65140bfa8 Rollup merge of #100345 - vincenzopalazzo:macros/is_number_doc, r=joshtriplett 64fc5803a4f Rollup merge of #100332 - eholk:stabilize-ilog, r=scottmcm bdf4614edfe Rollup merge of #99573 - tbodt:stabilize-backtrace, r=yaahc daab4351dc0 Fix doc links in core::time::Duration::as_secs 08396a2feac Apply suggestions from code review 0a89b8d2341 docs: remove repetition af9b3f81c4a Switching documentation to be more clear about potential errors 1cc45c1ce9d Merge branch 'rust-lang:master' into issue-98861-fix 8862098df08 Rename integer log* methods to ilog* b0e6f0d78f5 move an `assert!` to the right place d4312c51053 Guarantee `try_reserve` preserves the contents on error 779bac3767d Replace pointer casting in hashmap_random_keys with safe code 149f3e45437 Update Duration::as_secs doc to point to as_secs_f64/32 for including fractional part bf295db1d0f Add standard C error function aliases 5e9804bbbcb linux: Use `pthread_setname_np` instead of `prctl` bca9b138344 Adding more verbose documentation for `std::fmt::Write` 06187c8c98f Add Tuple marker trait 87a0729e10b Rollup merge of #100206 - RalfJung:miri-terminfo, r=thomcc 5d7ca655df9 Fix HorizonOS regression in FileTimes eecaa9120fb test: skip terminfo parsing in Miri 33e95667002 Rollup merge of #100175 - fxn:patch-1, r=Mark-Simulacrum 6377370f8fb Rollup merge of #100169 - WaffleLapkin:optimize_is_aligned_to, r=workingjubilee fbf76de0517 Rollup merge of #100127 - ChrisDenton:remove-init, r=thomcc df3ed321c02 proc_macro/bridge: send diagnostics over the bridge as a struct be4b109edd5 provide correct size hint for unsupported platform CommandArgs fc4fa27de2d ascii -> ASCII in code comment e830cbe65a1 non-linux platforms 9142b116768 Optimize `pointer::as_aligned_to` 9f7d27d0ddf improve documentation of `pointer::align_offset` b6a4103b4ba cleanup code w/ pointers in std a little b92a36a3d94 Move `rfold` logic into `iter_rfold` 921e1d93895 Move `fold` logic to `iter_fold` method and reuse it in `count` and `last` 320ad0fb6d6 Move shared logic of `try_rfold` and `advance_back_by` into `iter_try_rfold` 1ede1c5ef02 Move shared logic of `try_fold` and `advance_by` into `iter_try_fold` 5712fa0ebbf Add some docs for BorrowBuf bff77b011e7 std::io: migrate ReadBuf to BorrowBuf/BorrowCursor 5074f8c7e78 Update after code review 7305ba4a461 kmc-solid: Add a stub implementation of `File::set_times` a94090bfd08 Remove self-referential intra-doc links. 4f0e1d1292f Document that `RawWakerVTable` functions must be thread-safe. 716e24a6391 Remove Windows function preloading d493f27847b Add visibility modifier to compat macro 6119ecee4b6 FilesTimes support does not build for ESP-IDF a665f4bc20a actually call assert_send_and_sync dcd6d4d32b8 Auto merge of #100023 - saethlin:send-sync-chunksmut, r=m-ou-se e5d15f4bf16 Rollup merge of #99800 - sandydoo:bugfix/wasm-futex, r=m-ou-se ac43c7e486e Rollup merge of #99614 - RalfJung:transmute-is-not-memcpy, r=thomcc 4ec7cc69431 Rollup merge of #99371 - ChrisDenton:simplify-gen-random-keys, r=thomcc f5cb191f468 wordsmithing 7bd5d25a878 Stabilize backtrace eba0ade3b15 Auto merge of #92268 - jswrenn:transmute, r=oli-obk c40f711b62d make slice::{split_at,split_at_unchecked} const functions e7a9fb8dce9 Auto merge of #99977 - BlackHoleFox:cfte-cstr, r=thomcc 4c8592e5b3e Use `next_chunk` in `ArrayChunks` impl 35c489de6ac Auto merge of #100048 - matthiaskrgr:rollup-agimvm6, r=matthiaskrgr 0055d3c1779 Rollup merge of #100017 - solid-rs:patch/kmc-solid/adapt-to-78802, r=thomcc 6415299ff97 remove fn backtrace e90828eda29 Simplify `ArrayChunks::{,r}fold` impls ef4a03e0cac Simplify `ArrayChunks::is_empty` e173aab22d9 Remove `Fuse` from `ArrayChunks` implementation ec1543b05f5 Use `#[track_caller]` to make panic in `Iterator::array_chunks` nicer 21b5093bc17 Remove incorrect impl `TrustedLen` for `ArrayChunks` 2aebac2775c Add back Send and Sync impls on ChunksMut iterators 6e7357a022a Forward `ArrayChunks::next{,_back}` to `try_{for_each,rfold}` 0bcdd204c11 Remove `array::IntoIter::with_partial` -- an artifact of the past, once used to create an `IntoIter` from its parts cf6989a0984 Use `array::IntoIter` for the `ArrayChunks` remainder 03ebc91364f Add `Iterator::array_chunks()` 450e60a18d7 kmc-solid: Adapt to a recent change in the `IntoInner` impl of `SocketAddr` 1d813f0e11f Auto merge of #98246 - joshtriplett:times, r=m-ou-se dd1934e440a Never inline Windows dtor access 140911af2fb Don't derive `PartialEq::ne`. 2863fe8cdce Rollup merge of #99984 - ChrisDenton:fix-miri, r=Mark-Simulacrum 88a9c41eef3 Rollup merge of #99932 - madsmtm:fix-unwinding-debug-assertions, r=Amanieu 2272f9e832f Add validation to const fn CStr creation 83e691a69dd Make sure `symbol_name` is const evaluated a6f28cc2f1c Auto merge of #78802 - faern:simplify-socketaddr, r=joshtriplett 489f416bead Fix compat.rs for `cfg(miri)` 72d481cf846 typo b4586ce7db7 Auto merge of #99553 - ChrisDenton:lazy-compat-fn, r=Mark-Simulacrum f3557876e2c Rollup merge of #99937 - ChrisDenton:fix-remove-dir-all-win-7, r=joshtriplett 0868f17f2cb Fix warnings in stubbed out set_times 8e66279620c Original branch seems to have missed excluding the benchmark range from the globally reachable change 3681e8e97d0 Reincorporated changes from #87689 dfa9e8466bb Change `Ipv4Addr::is_global` to be in line with `Ipv6Addr::is_global` c8944623f69 Fix `Ipv6Addr::is_global` to check for global reachability rather than global scope 59d8f5082cd Reset directory iteration in remove_dir_all 21d49c31d66 Fix unwinding when debug assertions are enabled a25771fcbc2 Remove socklen_t from platforms where it's no longer used 1f4f4adfccd proc_macro: use crossbeam channels for the proc_macro cross-thread bridge b03e8fd080c Rollup merge of #99781 - workingjubilee:demo-string-from-cstr, r=thomcc 81480f6725e EscapeAscii is not an ExactSizeIterator 942100397e2 Rollup merge of #99689 - dtolnay:write, r=Mark-Simulacrum 4bf328f2c04 Rollup merge of #99628 - vincenzopalazzo:macros/is_number_doc, r=joshtriplett fa2a3cfd001 add more docs regarding ideographic numbers 2979347d5d8 Rollup merge of #99723 - bstrie:wasifd, r=yaahc 7d07dbb0a44 Auto merge of #99182 - RalfJung:mitigate-uninit, r=scottmcm 1b034acb2f4 safe transmute: reference tracking issue 29e16287b86 safe transmute: add `rustc_on_unimplemented` to `BikeshedIntrinsicFrom` 4bea4d3d12a Initial (incomplete) implementation of transmutability trait. b93487fae52 Rollup merge of #94247 - saethlin:chunksmut-aliasing, r=the8472 d0ccdf7c420 Allow using stable os::fd::raw items through unstable os::wasi module 1a3caf7400e Auto merge of #99802 - JohnTitor:rollup-uaklql1, r=JohnTitor 0100d4d3965 Rollup merge of #99704 - fee1-dead-contrib:add_self_tilde_const_trait, r=oli-obk ba35ea07bee Auto merge of #98748 - saethlin:optimize-bufreader, r=Mark-Simulacrum 311704cdeef Fix futex module imports on wasm+atomics 35da7f35140 Auto merge of #99792 - JohnTitor:rollup-20i7ewx, r=JohnTitor 0400b6286dd Rollup merge of #98583 - joshtriplett:stabilize-windows-symlink-types, r=thomcc 4aee2e9291e Clarify safety comments 4f4220747a4 Auto merge of #98553 - the8472:next_chunk_opt, r=Mark-Simulacrum 412e10f3f3d Add Buffer::consume_with to enable direct buffer access with one check 48bf9d96cf5 Explain how *mut [T] helps, and how we rely on the check in split_at_mut a86452865d2 Force the Cow into a String 95a2cffaec3 Use String::from_utf8_lossy in CStr demo 7ea55d1ec42 add test for vec::IntoIter::next_chunk() impl 9a42d1d4496 Auto merge of #99574 - durin42:allocator-patch-redux, r=nikic 4ceb98e273d Optimized vec::IntoIter::next_chunk impl d83e76ef6e1 Rollup merge of #99757 - asquared31415:patch-1, r=Dylan-DPC 67d232be4ca Rollup merge of #99716 - sourcelliu:iomut, r=Mark-Simulacrum ff57e6f5550 Add `Self: ~const Trait` to traits with `#[const_trait]` f8c0d4e78c2 codegen: use new {re,de,}allocator annotations in llvm d57d9a405a2 Rewrite Windows `compat_fn` macro 8a36ad20eeb Make `transmute_copy` docs read better 25d43c6abdd Rollup merge of #99692 - RalfJung:too-far, r=oli-obk d2b1065c089 Rollup merge of #98211 - devnexen:get_path_freebsd, r=Mark-Simulacrum a736bc54190 Add comments about stdout locking 584e4b25c52 Implement `fs::get_path` for FreeBSD. 166c4dce06a Rollup merge of #99703 - dtolnay:tokenstreamsizehint, r=petrochenkov a9679efaab0 Rollup merge of #99084 - RalfJung:write_bytes, r=thomcc 6630f10234f Rollup merge of #98710 - mojave2:string, r=JohnTitor bbda48dc1ca Rollup merge of #92390 - fee1-dead-contrib:const_cmp, r=oli-obk 955183571c1 Rollup merge of #99690 - RalfJung:miri-track-caller, r=Mark-Simulacrum fa5140eb2fc Rollup merge of #95916 - solid-rs:feat-kmc-solid-abort, r=Mark-Simulacrum c646b068253 Rollup merge of #95040 - frank-king:fix/94981, r=Mark-Simulacrum 996394cc8ea remove useless mut from examples 03f836080be Expose size_hint() for TokenStream's iterator a3315bba77e Auto merge of #97581 - AngelicosPhosphoros:improve_calloc_check_in_vec_macro_for_tuples, r=Mark-Simulacrum 3ef87ff8e96 interpret, ptr_offset_from: refactor and test too-far-apart check b7f93cc4c15 Support vec zero-alloc optimization for tuples and byte arrays 3b95b6620a4 add miri-track-caller to some intrinsic-exposing methods b5a2d09e2ce Revert write! and writeln! to late drop temporaries 00b0a5fa1f8 Rollup merge of #99657 - Phosra:patch-1, r=Dylan-DPC ab7713e0652 Rename and document the new BufReader internals 5fdef2e09ce Allow Buffer methods to inline 66cce447f0c Remove some redundant checks from BufReader f9a57563b55 add const hack comment ba4eaccdf95 Add issue numbers 588d3e65e4c Constify a few const `(Partial)Ord` impls 2d37db4af11 Auto merge of #98674 - RalfJung:miri-stacktrace-pruning, r=Mark-Simulacrum 17cc72767bf Remove `mut` 1004051f29f Rollup merge of #99627 - saethlin:lock-once, r=eddyb 85b01c6ed74 Auto merge of #97925 - the8472:cgroupv1, r=joshtriplett f6ee1ff911d say some more things about how transmute is UB 52d38aad069 Auto merge of #93397 - joshtriplett:sort-floats, r=Amanieu 8a04bb868c0 Lock stdout once when listing tests 7c033b2b81e [review] mention that runtime may scale with # of mountpoints 345a815d928 do not claim that transmute is like memcpy 5ce547ceeae adjust UnsafeCell documentation 3037fda8813 Recover error strings on Unix from_lossy_utf8 baac0bbe9db Stub out `set_times` to return unsupported on Redox b3ac237c7f3 Auto merge of #99491 - workingjubilee:sync-psimd, r=workingjubilee 8d0256e628a Rollup merge of #99579 - CleanCut:expect-warning, r=joshtriplett 6adbb3d4da1 Rollup merge of #98174 - Kixunil:rename_ptr_as_mut_const_to_cast, r=scottmcm 559cdb2ad39 document memory orderings of `thread::{park, unpark}` 32f17a1e0eb Auto merge of #99420 - RalfJung:vtable, r=oli-obk 5636c0c38de add same warning to Result::expect as Result::unwrap 84470161593 Remove redundant lifetime bound from `impl Borrow for Cow` ab53076f69f Box::from(slice): Clarify that contents are copied d637531eb33 Rollup merge of #99523 - cuviper:asfd_ptrs-1.64, r=jyn514 86908ea0d74 Rollup merge of #99454 - benluelo:control-flow/continue-combinators, r=scottmcm c1d80c69c63 Rollup merge of #99413 - steffahn:btree_dropck, r=m-ou-se 7f78d2be393 Rollup merge of #98707 - joboet:fuchsia_locks, r=m-ou-se 37b4ad3c2b3 Rename `<*{mut,const} T>::as_{const,mut}` to `cast_` d5c0929cc3c fixup! docs: Improve AsRef / AsMut docs on blanket impls 6f78ea5d240 remove unused import 03adc00b19c Introduce core::simd trait imports in tests 45495759ab3 Sync core::simd up to rust-lang/portable-simd@2e081db92aa3ee0a4563bc28ce01bdad5b1b2efd acd2525578d add #inline 97f14ac097b various nits from review 42bdf0d9eae use extern type for extra opaqueness 18b127e38e0 incorporate some review feedback e9e7cccf365 add intrinsic to access vtable size and align 06d26f3c44f prune raw pointer read and write methods from Miri backtraces e821c2a43ac miri: prune some atomic operation details from stacktrace 40cb5b6b8df Add map_continue and continue_value combinators to ControlFlow 123d73da243 Fix the stable version of `AsFd for Arc` and `Box` d88687ac711 Rollup merge of #99516 - m-ou-se:proc-macro-tracked-tracking-issue, r=Mark-Simulacrum d990d0639f8 Use new tracking issue for proc_macro::tracked_*. c1fa6fdda47 fix typo 9c8260a4022 make raw_eq precondition more restrictive 09fb674d970 owner is not micro (correct typo) b5ecb307011 Rollup merge of #98101 - vladimir-ea:stdlib_watch_os, r=thomcc e9f8f1fd6d0 Library changes for Apple WatchOS 4186b638af6 Rollup merge of #99452 - Stargateur:fix/typo, r=JohnTitor 6af997c51ad Rollup merge of #98916 - ChrisDenton:hiberfil.sys, r=thomcc 633a046de9c generated code 90cb8585844 fixup! docs: Improve AsRef / AsMut docs on blanket impls e3c1c23f215 fixup! docs: Improve AsRef / AsMut docs on blanket impls bead8ee94be Auto merge of #98180 - notriddle:notriddle/rustdoc-fn, r=petrochenkov,GuillaumeGomez f598693da4a Use `T` for all the function primitive docs lists ab90e267f11 Improve the function pointer docs 8fd963e53c2 Auto merge of #99462 - matthiaskrgr:rollup-ihhwaru, r=matthiaskrgr 1ddfe759786 Rollup merge of #99438 - WaffleLapkin:dont_wrap_in_non_zero, r=compiler-errors a4f50815898 Rollup merge of #99419 - yoshuawuyts:stabilize-task-ready, r=Mark-Simulacrum d376f77c1ca Auto merge of #98912 - nrc:provider-it, r=yaahc cbaaff5baa1 docs: Improve AsRef / AsMut docs on blanket impls 0b9751cf271 Auto merge of #99451 - Dylan-DPC:rollup-ceghu18, r=Dylan-DPC 376693723e3 int_macros was only using to_xe_bytes_doc and not from_xe_bytes_doc 32f6ffe7599 Rollup merge of #99434 - timvermeulen:skip_next_non_fused, r=scottmcm 594e9455450 Rollup merge of #99335 - Dav1dde:fromstr-docs, r=JohnTitor 8def670f3d7 Auto merge of #98189 - mystor:fast_ident_literal, r=eddyb 8492214d563 Suggest a fix for `NonZero*` <- `*` coercion error 22ccd97a59c Add note to test about `Unfuse` ed696e617bd Fix `Skip::next` for non-fused inner iterators 12c5ae01a53 proc_macro: Move subspan to be a method on Span in the bridge 5d2e024a667 proc_macro: stop using a remote object handle for Literal f1921d11c72 proc_macro: stop using a remote object handle for Ident a24825eb5cb proc_macro: Specialize Punct::to_string a4662d9eb94 proc_macro: use fxhash within the proc_macro crate 3d5a5ec3376 Rollup merge of #99198 - RalfJung:alloc-null-ptr, r=JohnTitor 604f47d194a Rollup merge of #98839 - 5225225:assert_transmute_copy_size, r=thomcc c7f734f09a9 Ignore `hiberfil_sys` test in CI 04aa463f764 stabilize `core::task::ready!` 88856d1ec0a Add `PhantomData` marker for dropck to `BTreeMap` de287ec3046 Auto merge of #99223 - saethlin:panicless-split-mut, r=Mark-Simulacrum 1dbb7469fe6 std: panic instead of deadlocking in mutex implementation on Fuchsia 0da05fc7dad Use split_once in FromStr docs a16e0cc1235 Rollup merge of #99374 - TethysSvensson:patch-1, r=Dylan-DPC ba9fdda49e6 Rollup merge of #98383 - m-ou-se:remove-memory-order-restrictions, r=joshtriplett 3f2933e144e rustdoc: extend `#[doc(tuple_variadic)]` to fn pointers 60c99a6c2b0 Add tests that check `Vec::retain` predicate execution order. b6e229da60e Fix for `rchunks_exact` doc 2b3a190e69c Simplify Windows `hashmap_random_keys` d6ba0c9a4ad Move SocketAddrCRepr to sys_common 70ecc89c82b Rollup merge of #99306 - JohnTitor:stabilize-future-poll-fn, r=joshtriplett 8516f1022b6 Rollup merge of #99302 - yaahc:gma-tracking-issue, r=joshtriplett 45fc7818ebc Rollup merge of #99088 - niklasf:stabilize-process_set_process_group, r=joshtriplett 79941c9cbae Rollup merge of #97915 - tbu-:pr_os_string_fmt_write, r=joshtriplett abfb410db90 Rollup merge of #94927 - c410-f3r:stabilize-let-chains, r=joshtriplett f615689bfd7 Auto merge of #98866 - nagisa:nagisa/align-offset-wroom, r=Mark-Simulacrum b69af7fe997 Stabilize `let_chains` 9ce7d214082 Add a special case for align_offset /w stride != 1 e8b2330a26c Expand documentation for `process_group` 9750685e20a Update `since` version to 1.64 d55f05be6b1 Rollup merge of #99317 - yanchith:borrow-vec-ta-as-slice-t, r=Mark-Simulacrum 148f0b58ef6 Parametrize a few more things b2d5c7d47dc Mark lifetimes explicitly cf78299f0c9 Parametrize BinaryHeap with Allocator bb896609870 Rearrange slice::split_mut to remove bounds check 7a5e8bf7b21 Borrow Vec as [T] c866766b627 Rollup merge of #99277 - joshtriplett:stabilize-core-cstr-alloc-cstring, r=Mark-Simulacrum d27ebe4208e Rollup merge of #99270 - rhysd:issue-99269, r=Mark-Simulacrum ddf4f614e18 Rollup merge of #99264 - eltociear:patch-14, r=compiler-errors cd2baba4e28 Rollup merge of #98662 - LucasDumont:document_fs_write, r=thomcc 384fbe56874 Rollup merge of #98387 - NobodyXu:feature/std_io_Error_try_downgrade_inner, r=yaahc 72d8e452aab Stabilize `future_poll_fn` 8e74f2a0ba9 add tracking issue to generic member access APIs 8c567991ba8 Apply suggestions from code review 35557719e39 Mark stabilized intrinsics with `rustc_allowed_through_unstable_modules` 66035aa7c8a Stabilize `core::ffi::CStr`, `alloc::ffi::CString`, and friends bec3da479fe Don't fall back to futimes on Android; it needs a newer API level than futimens 069805f3f28 Also use fallback for futimens on Android 5a60f57c7dd Return an error if trying to set a file timestamp to 0 on Windows 47e45661edc Add alias `File::set_modified` as shorthand aee6f85e559 Support setting file accessed/modified timestamps 45d01646f9c add `#[must_use]` to `Box::from_raw` 62d569b5f59 Rollup merge of #99113 - WaffleLapkin:arc_simplify, r=Mark-Simulacrum 1138dd6a16c Fix typo in mod.rs 9dcb8ee87ac Improve example of `downcast` 70d826a7633 lint: remove unnecessary parentheses c706f0804d1 Auto merge of #99242 - Dylan-DPC:rollup-34bqdh8, r=Dylan-DPC 5fee660da2a add missing null ptr check in alloc example 84bc3a026c2 add code examples ec9c6f0bf4f doc: clearer and more correct Iterator::scan d68391c4fb6 Rollup merge of #98072 - yaahc:generic-member-access, r=thomcc aadf490d873 Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillot d95f3f69eab Rollup merge of #98315 - joshtriplett:stabilize-core-ffi-c, r=Mark-Simulacrum a61113cbca4 Stabilize `core::ffi:c_*` and rexport in `std::ffi` 3f3d4a19328 Rename `std::io::Error::try_downcast_inner` to `downcast` b790e4a1a3d rustdoc 50d2d07d638 typo f6921956a42 changes to wording 5225c0edca5 Re-optimize `Layout::array` c18e5a0f3b8 Auto merge of #99136 - CAD97:layout-faster, r=scottmcm 0715cdc7a4f docs: be less harsh in wording for Vec::from_raw_parts 5fd92bd5978 Rollup merge of #99011 - oli-obk:UnsoundCell, r=eddyb b785f2fa7a7 Rollup merge of #99148 - SOF3:clarify-xsize-bound, r=scottmcm 449c2794625 Add a `File::create_new` constructor 6171b4da98e mention mitigation in the docs 62e6829ba51 mem::uninitialized: mitigate many incorrect uses of this function 5a1c21396e0 std: fix issue with perma-locked mutexes on Fuchsia 23b9b9cda4b Remove duplication of layout size check f50b28f201f apply suggestions from code review 3b8558057ad remove a dubious example 5d6ea46a0f5 typo 751fdef5fc5 Add Read Impl for &Stdin 5da64651f38 Auto merge of #97841 - nvzqz:inline-encode-wide, r=thomcc c2a19dde3e8 Add std::fs::write documentation precision ec9f1ca6916 Clarify that [iu]size bounds were only defined for the target arch 99e88fec3b5 Take advantage of known-valid-align in layout.rs 490845b7f9e Rollup merge of #99094 - AldaronLau:atomic-ptr-extra-space, r=Dylan-DPC b2034d630e0 Auto merge of #99112 - matthiaskrgr:rollup-uv2zk4d, r=matthiaskrgr 0fb39730068 Use `byte_sub` in [a]rc impl b0ca55044fb Rollup merge of #99109 - WaffleLapkin:atomic_ti, r=Dylan-DPC d7df0e04fd3 Rollup merge of #99100 - Smittyvb:test-cli-binary-name, r=thomcc b7c1c57cead fill new tracking issue for `feature(strict_provenance_atomic_ptr)` 0463f5cb606 Auto merge of #95295 - CAD97:layout-isize, r=scottmcm 05d43fafd9c Auto merge of #97522 - xfix:stabilize-slice-from-raw-parts, r=dtolnay a35c90e277d Fix binary name in help message for test binaries 857d0ee70fe Auto merge of #98950 - ChrisDenton:getoverlapped-io, r=thomcc 696781d232e Add T to PhantomData impl Debug 34b73cfae5b Partially stabilize const_slice_from_raw_parts 5d1988d50c4 Remove extra space in AtomicPtr::new docs 3e46455d935 add a concrete example 157102e5302 clarify how write_bytes can lead to UB due to invalid values 567febcb2a2 Rollup merge of #99067 - est31:to_owned_link, r=Dylan-DPC e12c042a2b6 Document and stabilize process_set_process_group 480a81dada3 Rollup merge of #99070 - tamird:update-tracking-issue, r=RalfJung 8da240ed70f Update integer_atomics tracking issue 19d1dbb417e add rt flag to allowed internal unstable for RustcEncodable/Decodable 4a445aae84d add opt in attribute for stable-in-unstable items 7afda15674c revert changes to unicode stability a85f9db49f7 Support unstable moves via stable in unstable items d5867261218 Intra-doc-link-ify reference to Clone::clone_from 380221acd76 Rollup merge of #98718 - yoshuawuyts:stabilize-into-future, r=yaahc c6f07ae028d Rollup merge of #97917 - AronParker:master, r=ChrisDenton 6f11086212e Fix doc build on unsupported oses 8d1a0711ac2 `UnsafeCell` now has no niches, ever. a537ce9f3ba changes from feedback 73ff44810e3 doc additions 7c53026afb4 socket `set_mark` addition. 22b94139001 Rollup merge of #98971 - MinnDevelopment:patch-1, r=Dylan-DPC 0fe1cd38074 Rollup merge of #98939 - GuillaumeGomez:rustdoc-disamb-impls, r=notriddle 0b62bdcb3e9 Rollup merge of #96935 - thomcc:atomicptr-strict-prov, r=dtolnay d7432076e85 Tests for unsound Windows file methods db994e487e6 Windows: Fallback for overlapped I/O 36fe6e75823 Use `rtabort!` instead of `process::abort` c03b18a3703 Fix typo in file descriptor docs a07279f9cac Fix links in std/core documentation 75d284502c3 Add `BufRead::skip_until` f6cc5100967 core::any: replace some unstable generic types with impl Trait 5351d7fbba3 Test if `[try_]exists` can find `hiberfil.sys` a5ebfd82b6d Add comment and simplify `hiberfil_sys` test b740bfe5547 Rollup merge of #97712 - RalfJung:untyped, r=scottmcm 9e0a98f18da Windows: Use `FindFirstFileW` if `metadata` fails e928bf7a637 `impl From for FileAttr` cf07048d92d Rollup merge of #97300 - ChayimFriedman2:patch-1, r=dtolnay 737e17ef363 Auto merge of #97437 - jyn514:impl-asrawfd-arc, r=dtolnay 13810eb96ad Add size assert in transmute_copy cb99d243c0d Auto merge of #98755 - nnethercote:faster-vec-insert, r=cuviper 25fdeabdc76 Auto merge of #98673 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum c4886f7bd65 Fix slice::ChunksMut aliasing 3127249c89f Bump std::net::Incoming FusedIterator impl to Rust 1.64 86569efda73 Auto merge of #97235 - nbdd0121:unwind, r=Amanieu fa34a19e478 Adjust for rustfmt order change 4e9927115a4 Rollup merge of #98585 - cuviper:covariant-thinbox, r=thomcc 12e72cbae91 update cfg(bootstrap)s e7dde626819 Rename AtomicPtr::fetch_{add,sub}{,_bytes} 75b8c8b2808 Allow arithmetic and certain bitwise ops on AtomicPtr e82eca3a9e5 Auto merge of #98730 - matthiaskrgr:rollup-2c4d4x5, r=matthiaskrgr 561f6d1fa5d Optimize `Vec::insert` for the case where `index == len`. 297215df106 Rollup merge of #98503 - RalfJung:scope-race, r=m-ou-se cbb282eadad Rollup merge of #97629 - guswynn:exclusive_struct, r=m-ou-se 5c65e3e59f9 clarify that ExactSizeIterator::len returns the remaining length 9efa7348007 Stabilize `into_future` 434e28554cc correct the output of a `capacity` method example a8b320542e6 std: use futex-based locks on Fuchsia 87717b92b4c nit 102883ed616 Revert isize::MAX changes to Layout helpers cc5e9cf394f Rollup merge of #98652 - ojeda:warning-free-no_global_oom_handling, r=joshtriplett 358717f8aee Rollup merge of #98516 - dlrobertson:uefi_va_list, r=joshtriplett 9d14e8cecdb Rollup merge of #98479 - leocth:atomic-bool-fetch-not, r=joshtriplett 0051272954e Only enable new cmpxchg memory orderings in cfg(not(bootstrap)). 1c6fb212779 Remove restrictions on compare-exchange memory ordering. 0ffd98b3ee9 Rollup merge of #97423 - m-ou-se:memory-ordering-intrinsics, r=tmiasko 376dafee4f3 alloc: fix `no_global_oom_handling` warnings 45468acd1ff Follow C-RW-VALUE in std::io::Cursor example 5d762e4be63 Auto merge of #98632 - matthiaskrgr:rollup-peg868d, r=matthiaskrgr 76877cecb0d Rollup merge of #98617 - ChrisDenton:const-unwrap, r=Mark-Simulacrum a22f834f0f2 Auto merge of #98188 - mystor:fast_group_punct, r=eddyb 9c01a27965d review changes 029f51df00a Add a fixme comment 5a41fe7981a Remove feature `const_option` from std 91b4ada0973 Rollup merge of #98595 - cuviper:send-sync-thinbox, r=m-ou-se 9c7c207a270 Rollup merge of #98555 - mkroening:hermit-lock-init, r=m-ou-se 826be81cd18 Rollup merge of #98430 - camsteffen:flatten-refactor, r=joshtriplett bd6d27160d0 Rename/restructure memory ordering intrinsics. 217be2f4ca9 Auto merge of #98324 - conradludgate:write-vectored-vec, r=Mark-Simulacrum ee56f954e4a Implement `Send` and `Sync` for `ThinBox` 2691748236d fix data race in thread::scope 75346323798 Rollup merge of #98587 - RalfJung:core-tests, r=thomcc 83bc4a310a3 Rollup merge of #98579 - RalfJung:alloc-tests, r=thomcc faef96fe156 Seal Windows `FileTypeExt` extension trait to allow adding future methods 18814e9fcf1 libcore tests: avoid int2ptr casts 561e157a39c Make `ThinBox` covariant in `T` 739bf134a1f Stabilize Windows `FileTypeExt` with `is_symlink_dir` and `is_symlink_file` 114d80cfb3e liballoc tests: avoid int2ptr cast a5824a61ec5 make Condvar, Mutex, RwLock const constructors work with unsupported impl d5364235b9a proc_macro: stop using a remote object handle for Group 095fe7cfbbf proc_macro: stop using a remote object handle for Punct c25e3dbe56e Fix spelling in SAFETY comment 6f4f40ac4a9 Auto merge of #98187 - mystor:fast_span_call_site, r=eddyb 26cc7159b4e Hermit: Make Mutex::init a no-op a8303de9f00 Hermit: Fix initializing lazy locks 15a386b4364 Rollup merge of #98541 - Veykril:patch-2, r=Dylan-DPC e029ca840bf Rollup merge of #97908 - iago-lito:stabilize_nonzero_checked_ops_constness, r=scottmcm 5286a6beeed Rollup merge of #97140 - joboet:solid_parker, r=m-ou-se b19a332bfa7 proc_macro: Rename ExpnContext to ExpnGlobals, and unify method on Server trait bc812cefcb2 attempt to optimise vectored write 231d373fd15 Auto merge of #98190 - nnethercote:optimize-derive-Debug-code, r=scottmcm 02abfee1add Update `std::alloc::System` docs e71554bd5f5 Update `since` to 1.64 (since we're after 1.63) b3c52a711db forgot about the feature flag in the doctest 2b98b6be0f9 library: fix uefi va_list type definition 027cf2cc59c proc_macro: remove Context trait, and put span methods directly on Server 781327e6236 temporarily remove tests because I'm not sure if we need them 63beab1b90e Auto merge of #98486 - matthiaskrgr:rollup-u7m508x, r=matthiaskrgr 17a123a16f2 proc_macro: cache static spans in client's thread-local state 7c40416b816 Rollup merge of #98194 - m-ou-se:leak-locked-pthread-mutex, r=Amanieu 7c77f83914d Rollup merge of #98126 - fortanix:raoul/mitigate_stale_data_vulnerability, r=cuviper a17cd7697d8 Rollup merge of #96412 - ChrisDenton:remove-dir-all, r=thomcc 3a7f789450b Auto merge of #96820 - r-raymond:master, r=cuviper 73a6ee2380e Add feature gate `#![atomic_bool_fetch_not]` dda67b68f55 Auto merge of #93700 - rossmacarthur:ft/iter-next-chunk, r=m-ou-se da0626d803a add `fetch_not` method on `AtomicBool` f89f14171c1 scan mountinfo when hardcoded cgroupv1 mountpoints don't work e133d6ce62c Rollup merge of #98039 - tnballo:master, r=thomcc 9b7cd49d198 Optimize the code produced by `derive(Debug)`. 04e0ed44472 Fix BTreeSet's range API panic message, document 3f5c9de4ab2 Rollup merge of #98364 - RalfJung:arc-clone, r=Mark-Simulacrum d613af18392 Rollup merge of #96173 - jmaargh:jmaargh/with-capacity-doc-fix, r=Dylan-DPC 80987f6c02f Remove invalid doc comment on the size of an IP struct 62798e73cd1 Remove `is_known_utf8` checks from more tests where it's no longer set. 1668275e261 Don't eagerly scan for `is_known_utf8` in `to_ascii_lowercase`/`uppercase`. f87e01c60c4 Panic safety. d3bb229d8d0 Optimize `Wtf8Buf::into_string` for the case where it contains UTF-8. 32ffcdbe412 Assign issue number to the new const_socketaddr 683806d1f65 Add IP structural_match tests fd6efa8185e Remove ntohs/htons in favor of to_be/from_be 1eeb5e7af2b Implement IpV{4,6}Addr structs with native Rust encoding 734d3859394 Represent SocketAddrV4 and SocketAddrV6 as Rust native encoding 3cb11a0b4bb add tracking issue for exclusive 673b9512ee5 Use `unwrap` instead of `unwrap_unchecked` 45533e45fbc Refactor iter adapters with less macros d41890e89b1 std: reimplement SGX thread joining to use `Parker` 9ca2e0eea74 std: rewrite SGX thread parker d8f59d84ba6 Add new unit test `test_try_downcast_inner` a8aab1733a0 Add new unstable API `Error::try_downgrade_inner` 970af6b9bf3 Impl `io::error::repr_bitpacked::Repr::new` 1c13f53b570 Impl `io::error::repr_unpacked::Repr::new` 85ef40dec4a Address reviewer comments 8cde18d52f6 Rollup merge of #98363 - RalfJung:btree-test-ref-alloc, r=thomcc ab8ebdc00b9 Rollup merge of #97516 - RalfJung:atomics, r=joshtriplett b0ac1c7f1d3 Rollup merge of #96768 - m-ou-se:futex-fuchsia, r=tmandry ae2fac4faf5 Rollup merge of #95446 - notseanray:master, r=Mark-Simulacrum e71f7e47e6a clarify Arc::clone overflow check comment 6a51d71d746 `impl AsFd for {Arc,Box}` a8ecea1cb18 `impl for {Arc,Box}` 10cd7a420d8 hedge our bets ab4347db1e7 remove use of &Alloc in btree tests 326c3fac7e0 Rollup merge of #98330 - conradludgate:io-slice-mut-docs, r=Dylan-DPC 44fb391d743 Rollup merge of #98313 - m-ou-se:fix-comments, r=joshtriplett 4f2acc7683e Rollup merge of #97269 - RalfJung:transmute, r=m-ou-se 9de4c01f3f3 Rollup merge of #94033 - joshtriplett:documentation-is-running-better-go-catch-it, r=m-ou-se f5b2498e848 Use futex based thread parker on Fuchsia. e166ac6d473 update ioslice docs to use shared slices 0ce6a20effb Add `Iterator::next_chunk` 3952f86a8b8 Auto merge of #98307 - matthiaskrgr:rollup-rb3huha, r=matthiaskrgr ae64cd74521 Add `[f32]::sort_floats` and `[f64]::sort_floats` b343296d7ef Remove lies in comments. 1169cc0517c Improve docs for `is_running` to explain use case 949924f6d69 Rollup merge of #98296 - JohnTitor:generator-unstable-book-link, r=Dylan-DPC c0f29680f4a Rollup merge of #98276 - compiler-errors:const-format-macro, r=oli-obk cfb645d74ea Auto merge of #93765 - zhangyunhao116:heapsort, r=m-ou-se 77b686ac14d Add a link to the unstable book page on Generator doc comment 19cec411308 Rollup merge of #97837 - sunfishcode:sunfishcode/proc-self-mem, r=m-ou-se d87b2ae0bee Rollup merge of #97150 - ChrisDenton:stdio-create_pipe, r=m-ou-se 8153d6c0bd1 Rollup merge of #97149 - ChrisDenton:win_async_pipes, r=m-ou-se 41ce4cd1768 Rollup merge of #96719 - mbartlett21:patch-4, r=Dylan-DPC 8a01013d162 Rollup merge of #96609 - ibraheemdev:arc-downcast-unchecked, r=m-ou-se 65f39f1ef64 Rollup merge of #94855 - m-ou-se:advance-slice-panic-docs, r=kennytm 17b13eaf012 Rollup merge of #93080 - SkiFire13:itermut-as_mut_slice, r=m-ou-se 01662d1af67 Windows: `CommandExt::async_pipes` cb7a7277705 `Stdio::make_pipe` b235a486e88 Add tracking issue for `noop_waker` 458f04a35b2 Optimize heapsort d09bfa862b0 Show #![feature] in example. 16bf0cb522a Leak pthreax_rwlock_t when it's dropped while locked. 859113c5db4 Fix typo in `HashMap::drain` docs 40c97120bfd Mention formatting macros when encountering ArgumentV1::new in const 0f534247feb Rollup merge of #98257 - kadiwa4:into_future_doc_typos, r=Dylan-DPC 0ffc04628da Rollup merge of #97912 - Kixunil:stabilize_path_try_exists, r=dtolnay ed2f4641088 Rollup merge of #95534 - jyn514:std-mem-copy, r=joshtriplett ef005a1cdff Add `core::mem::copy` to complement `core::mem::drop`. 2333b4d322b Fix documentation for with_capacity and reserve families of methods 7b5b4b2ee64 Auto merge of #98224 - eddyb:proc-macro-spurious-repr, r=bjorn3 da8e05fd02f typos in `IntoFuture` docs 35819ab1821 Rollup merge of #98233 - RalfJung:ref-alloc, r=thomcc 5706797389f Auto merge of #97791 - m-ou-se:const-locks, r=m-ou-se de610d6d04a Add comment explaining why we use NonNull ac08928e161 Add safety comments 5cd108b9dfb Documentation typo 472a6a34ade *const to NonNull plus documentation 42465331916 Address comments 7ac1183dbd3 More formatting 42a7b53266b Formatting 65c1f4e2bef Make RwLockReadGuard covariant b1c9aeaa093 Auto merge of #97367 - WaffleLapkin:stabilize_checked_slice_to_str_conv, r=dtolnay 115497ec893 Rollup merge of #98165 - WaffleLapkin:once_things_renamings, r=m-ou-se e51e582f514 Auto merge of #97924 - cuviper:unguarded-poison, r=Mark-Simulacrum 661342d2a40 make std not use &A: Allocator instance e227ce4d091 make btree not use &A: Allocator instance 4658c4bc67c Auto merge of #98004 - paolobarbolini:vecdeque-extend-trustedlen, r=the8472 9424a550b35 proc_macro/bridge: remove `#[repr(C)]` from non-ABI-relevant types. f044d00b22b Auto merge of #98186 - mystor:tokenstream_as_vec_tt, r=eddyb 28dd46b55c2 Auto merge of #98178 - RalfJung:btree-alloc, r=thomcc 47676ca754f Document the conditional existence of `alloc::sync` and `alloc::task`. 6b9813a07a6 review fixups e3bb61641e1 comments explaining why we have and don't have ManuallyDrop 78e4fd0930f Expose iter::ByRefSized as unstable feature and use it 8cb4c17b4ee Add VecDeque::extend from TrustedLen specialization f1972c73aa5 Add VecDeque::extend TrustedLen benchmark aaa130f52ba Impl Termination for Infallible and then make the Result impls of Termination into a blanket 778365e5449 Stabilized Option::unzip() cca158ef3df Move empty final TokenStream handling to server side of bridge b83e9f27cac Rollup merge of #97844 - ChrisDenton:dont-panic, r=JohnTitor b5e42333b63 Rollup merge of #95392 - Xuanwo:stablize_try_reserve_2, r=dtolnay 06786c48e82 btree: avoid forcing the allocator to be a reference b9968928f7d Try to reduce codegen complexity of TokenStream's FromIterator and Extend impls e09dc370650 proc_macro: reduce the number of messages required to create, extend, and iterate TokenStreams b06f5106e04 proc_macro: use macros to simplify aggregate Mark/Unmark definitions 069e149f79c Auto merge of #98143 - cuviper:futex-rwlock-inline, r=thomcc a3b876c0fd0 Rollup merge of #98169 - pierwill:dyn-disp, r=JohnTitor f89f5c78072 Rollup merge of #98118 - steffahn:scoped-threads-nll-test, r=m-ou-se 9e9ab1d6252 Rollup merge of #97675 - nvzqz:unsized-needs-drop, r=dtolnay 8174264fc9e Move/rename `lazy::Sync{OnceCell,Lazy}` to `sync::{Once,Lazy}Lock` 8f1917cd367 Move/rename `lazy::{OnceCell, Lazy}` to `cell::{OnceCell, LazyCell}` 21c6c28143f Keyword docs: Link to wikipedia article for dynamic dispatch 3655a8d0b46 Auto merge of #97842 - notriddle:notriddle/tuple-docs, r=jsha,GuillaumeGomez 0fbb39f0bf5 Leak pthreax_mutex_t when it's dropped while locked. 1569bf18823 Rollup merge of #98125 - KarlWithK:entry_add_modify_doc, r=Dylan-DPC beb3384d618 Auto merge of #98103 - exrook:btreemap-alloc, r=Amanieu 4b7211d6e8f std: Stabilize feature try_reserve_2 fd2f29ad0d5 Auto merge of #98152 - JohnTitor:rollup-osr17j6, r=JohnTitor fb8f22f2e46 Rollup merge of #98059 - tmiasko:inline-const-eval-select, r=Amanieu be1721aaea6 Rollup merge of #97202 - joshtriplett:os-str-capacity-documentation, r=dtolnay 2b3014cf27b Auto merge of #97178 - sunfishcode:ownedfd-and-dup, r=joshtriplett 333f23a6aa5 Add `#[inline]` to small fns of futex `RwLock` d4018406ca8 Add the new stability attributes, for Windows. 1135ca00bad Revise the documentation for `try_clone`. c13782ce819 Add `BorrowedFd::try_clone_to_owned`. 9f16d2f8f55 Document that `BorrowedFd` may be used to do a `dup`. e70d5675787 Auto merge of #95897 - AzureMarker:feature/horizon-std, r=nagisa 1586cc6be9e Test `copy_to_userspace` function 7bf6531b43f std: relax memory orderings in `Parker` 301d9081d50 Test NLL fix of bad lifetime inference for reference captured in closure. a80d9abf28e Ensure userspace allocation is 8-byte aligned c790b812b06 Mitigate MMIO stale data vulnerabilities f12d51c383a change "1" to "c" to pass test d33dded520c Unify copying data from enclave to userspace f150458d827 Add examples using `add_modify` to btree 0eaa1d4bb8a Add examples using `add_modify` to HashMap be07c1afeff proc_macro: support encoding/decoding Vec f679638738e proc_macro: support encoding/decoding structs with type parameters b08775a13ca Add a stability attribute to WASI's `try_clone()`. 812991d639b Implement stabilization of `#[feature(io_safety)]`. 451d41d0a10 Clarify `[T]::select_nth_unstable*` return values ee1a39350a7 rustdoc: change "variadic tuple" notation to look less like real syntax bc65f287dfa btreemap-alloc: fix clear impl b9a1d70e247 BTreeMap: Add alloc param 66ca5502304 Stabilize `Path::try_exists()` and improve doc 3857ec10ff6 Auto merge of #78781 - eddyb:measureme-rdpmc, r=oli-obk eb49269e211 Rollup merge of #98042 - DrMeepster:winfred_std_changes, r=ChrisDenton da0023c27a2 Rollup merge of #97869 - ssomers:btree_comments, r=Dylan-DPC 5d8bc5eda9d Use a private type definition to reduce cfg noise a9c39181f36 Enable thread_local_dtor on horizon OS 8142356adee Update libc::stat field names c69ab287592 Enable argv support for horizon OS e6db3143ce7 Use the right wait_timeout implementation cd75ede91ae Lower listen backlog to fix accept crashes cdf6e250f85 Horizon OS STD support bb92e412323 add inline(always) to option d6e13880944 fix broken doc comment c7f7ab7ecd9 remove outdated references 29bf4e7dfaf Add provider API to error trait 447ff38fe9e [perf] std: add missing `#[inline]` to `DefaultHasher::{new,default}`. ccd2f9e304a Inline `const_eval_select` 2f0870a8ab4 Document an edge case of `str::split_once` 62f3abbfeee proc_macro: bypass RandomState to remove ASLR-like effects. 248e02e103c Auto merge of #98038 - TaKO8Ki:remove-unnecessary-space-in-doc, r=compiler-errors 5254e8b8323 remove an unnecessary space in doc 523429fa589 Rollup merge of #97950 - eggyal:issue-97945, r=Dylan-DPC 057f0a4bd58 Rollup merge of #97992 - m-ou-se:stabilize-scoped-threads, r=joshtriplett 9e463f3dd52 Rollup merge of #97970 - dtolnay:terminate, r=joshtriplett 5248593304c Rollup merge of #97921 - bvanjoi:docs-example-str-replace, r=Dylan-DPC c898d12f44f Add docs to `maybe_tuple_doc!` 8b76224dc76 Update library/core/src/primitive_docs.rs 2e1f2e984de Update library/std/src/primitive_docs.rs bc10cfefc52 fix compat_fn option method on miri b811a5fe1c2 Auto merge of #97996 - matthiaskrgr:rollup-bvbjlid, r=matthiaskrgr ca848aae12c docs: make all the variadic impls use `(T, ...)` exactly 438006a6c6f Add test case for #trait-implementations-1 link c3cb7528728 Re-add explicit list of traits to tuple docs, with limit notes e646673d50a Use relative path for addressing things in rust-lang/rust 70662716342 Fix incorrectly spelled "variadic" 31ce7ffc251 Rollup merge of #97943 - Warrenren:master, r=Dylan-DPC c0c0c51fc19 Rollup merge of #97904 - est31:master, r=Dylan-DPC e889cb45299 Stabilize scoped threads. 927285901eb Rollup merge of #97979 - ben0x539:providerdocs, r=Dylan-DPC 7f30a703187 Rollup merge of #97958 - mkroening:exit-status-docs, r=Dylan-DPC 31fb666d0d9 Fix typos in Provider API docs f7e69c25ccb Update cmp.rs 8aa82bf62fb Do not panic in Termination impl on closed stderr e76f6e0d9aa Rollup merge of #97940 - GuillaumeGomez:relative-link, r=Dylan-DPC 4566978f990 net listen backlog set to negative on Linux. 22c7b1750dd docs: Consistently mark ExitStatus as code d1c61643ea9 docs: Link to ExitCode instead of ExitStatus in ExitStatus c8eed104b80 docs: Fix typo in ExitStatus 1f36a3684d0 Clarify `#[derive(PartialEq)]` on enums d0805f923ab Make "windows_process_exit_code_from" unstable 2b7cfe15c09 Incorporate warning for potential exit code ambiguities c0f11847c14 Fix copy paste error ee7a4f9c4c9 Auto merge of #96837 - tmiasko:stdio-fcntl, r=joshtriplett d5c95cd8d6c line 1352, change self to (*self), other to (*other) 115b6431a91 Use relative links instead of linking to doc.rust-lang.org when possible 2500be60a94 Auto merge of #97939 - JohnTitor:rollup-79pxupb, r=JohnTitor 6e102e4fd87 Rollup merge of #97922 - paolobarbolini:no-vecdeque-extra-reserve, r=the8472 6b5fccf5f22 Rollup merge of #97888 - hoodmane:emscripten-eh-personality, r=Amanieu 979eeea9462 Rollup merge of #97876 - yoshuawuyts:into-future-docs, r=JohnTitor,yaahc b51c592186f Auto merge of #95818 - petrochenkov:stabundle, r=wesleywiser 0452955ad96 Auto merge of #95770 - nrc:read-buf-builder, r=joshtriplett 980b3025b02 Auto merge of #91970 - nrc:provide-any, r=scottmcm 9146251b930 use fcntl fallback for additional poll-specific errors 69b159294e6 Stabilize the `bundle` native library modifier 9f5230367dc add cgroupv1 support to available_parallelism aff19717bc8 Avoid `thread::panicking()` in non-poisoning methods of `Mutex` and `RwLock` 60e4c4f925c Remove redundant calls to reserve in impl Write for VecDeque 6ec04b14cfa Add underscores to rust_eh_personality arguments to mark them as unused ab6c282cff9 additional docs example for replace **all** of str d39e642703c Implement ExitCodeExt for Windows cc8215aeaa7 Auto merge of #97910 - JohnTitor:rollup-gu3k0xl, r=JohnTitor 62be9290a25 Implement `fmt::Write` for `OsString` 4f4c71d506d Grammar fix in the compile_error documentation a418220c0b7 Rollup merge of #95632 - evanrichter:master, r=joshtriplett 2884ca333da Auto merge of #97868 - ssomers:btree_from_sorted_iter, r=the8472 26b47a634d3 Stabilize NonZero* checked operations constness. 797f93c4f56 Partial stabilization of "nonzero_unchecked_ops". 5340b80714c Fix bootstrap attr 38d4bbf5fdd rustdoc: fixed messed-up rustdoc auto trait impls 577ea6923f1 rustdoc: show tuple impls as `impl Trait for (T, ...)` 6d8ab0393a9 Remove __gxx_personality_v0 declaration a77e724474d Fix FFI-unwind unsoundness with mixed panic mode 1d9c3e4880d Rollup merge of #97871 - ChayimFriedman2:vec-iterator-unimplemented, r=compiler-errors b3ef61cc7d7 Rollup merge of #97830 - LucasDumont:add-example-alloc, r=yaahc d64f4a63d8d Fix formatter 3bda3066dcd Don't use __gxx_personality_v0 in panic_unwind on emscripten target 6d1f72d5791 Rollup merge of #97879 - hermitcore:condvar, r=Dylan-DPC d5ff5f2a426 Fix trailing whitespace. 1a19d2296a2 Reword the question in the section header too. 1973ab0c0cd Update library/std/src/os/unix/io/mod.rs 2630804ee48 Reword a question into a statement. 00917747dcd remove unneeded code fe789335f83 update docs for `std::future::IntoFuture` 4480f2f5834 Stabilize `const_intrinsic_copy` 97db6db0da4 Suggest using `iter()` or `into_iter()` for `Vec` f3430dc98d4 BTreeSet: avoid intermediate sorting when collecting sorted iterators 6950973b6f8 BTree: tweak internal comments 0d7853dcbfc Rollup merge of #97851 - saethlin:use-repr-c, r=thomcc 8279ed3bdbd Use repr(C) when depending on struct layout in ptr tests 5005a4460d3 Windows: No panic if function not (yet) available 4d3384484cf [core] add Exclusive to sync 59abb1ac236 docs: show Clone and Copy on () doc pages 6753ad4abda Inline Windows `OsStrExt::encode_wide` 3c222cc6fba rustdoc: show auto/blanket docs for tuple and unit ce7cb3c6eeb docs: clean up trait docs for tuples 74d8bb77e7e Update library/std/src/os/unix/io/mod.rs 62d129d4a78 Update library/std/src/os/unix/io/mod.rs e148ef2dbf9 Update library/std/src/os/unix/io/mod.rs 902aa88a5f4 Update library/std/src/os/unix/io/mod.rs eeb8f634a5e Document Rust's stance on `/proc/self/mem` e01ab5dff97 Rollup merge of #97821 - Nilstrieb:mutex-docs, r=Dylan-DPC c1c8a50a2ac Rollup merge of #95948 - Nilstrieb:improve-cstr-safety-docs, r=RalfJung a3000e0451f Improve the safety docs for `CStr` 413b5958234 Update library/std/src/sync/mutex.rs 5e7fb07c254 Add std::alloc::set_alloc_error_hook example 10d5bde47db Rollup merge of #97771 - rtzoeller:haiku_no_sigio, r=kennytm db7f79619c0 Remove confusing sentence from `Mutex` docs c686a711bfe Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakis 51c77a195e6 Rollup merge of #97700 - nzrq:patch-1, r=dtolnay 062a467a467 Apply suggestions from code review a114a91ab0a Make {Mutex, Condvar, RwLock}::new() const. 47a42f29708 Make all {Mutex, Condvar, RwLock}::new #[inline]. 4f1472e88c1 Address reviewer comments 689a77815c1 Add some more tests 81eec46be9c Add tracking issue number f0489ccecf8 Add examples to docs f4d8cd9b8f4 Update docs 90bd892a490 Modify the signature of the request_* methods so that trait_upcasting is not required 124190c5961 Add the Provider api to core::any 124ee42a77f Rollup merge of #97764 - RalfJung:strict, r=dtolnay dd035049088 Auto merge of #97710 - RalfJung:ptr-addr, r=thomcc d1ab07bfa51 Remove SIGIO reference on Haiku 0f9b7a4720e use strict provenance APIs bb6bd162c94 promise that ptr::copy and ptr::swap are doing untyped copies c3d4a07f7b6 change ptr::swap methods to do untyped copies f3d6fa75694 Add vec::Drain{,Filter}::keep_rest 4cab2abd7c6 std: solve priority issue for Parker c7fa51156b0 Add diagnostic items to MutexGuard and RwLock Guards 2f728451c7f Update library/std/src/collections/hash/set.rs 9753effe553 Auto merge of #97742 - matthiaskrgr:rollup-fr3j0t8, r=matthiaskrgr 661f776cedf Rollup merge of #97688 - RalfJung:test-const-cpy, r=Mark-Simulacrum d863e6637d1 Auto merge of #97191 - wesleywiser:main_thread_name, r=ChrisDenton 9f75a7963db keep using poll as fast path and only use fcntl as fallback 30afb6f4736 Rollup merge of #97647 - m-ou-se:lazy-box-locks, r=Amanieu 838bcee0b3f Rollup merge of #96642 - thomcc:thinbox-zst-ugh, r=yaahc 9422341b948 Auto merge of #97604 - nnethercote:inline-bridge-Buffer-methods, r=eddyb 0b65566761b Update set.rs 3c78d137d76 Fully stabilize NLL 824acd92f3f implement ptr.addr() via transmute fcad013984f Auto merge of #95833 - notriddle:notriddle/human-readable-signals, r=yaahc 324cc3671ce Add note to documentation of HashSet::intersection a5f15ece97e Lazily allocate+initialize locks. 9c770f12c67 Use Drop instead of destroy() for locks. cc0a64c0e80 test const_copy to make sure bytewise pointer copies are working 4446c8621e5 Rollup merge of #97366 - WaffleLapkin:stabilize_array_slice_from_ref, r=dtolnay 9683b2cfb10 Make `std::mem::needs_drop` accept `?Sized` c97bcd7a224 Fix MIPS-specific signal bug b9bb6ffa593 Rollup merge of #97655 - steffahn:better-pin-box-construction-docs, r=thomcc 15ea6d303dd Auto merge of #97654 - Dylan-DPC:rollup-w6zrzxf, r=Dylan-DPC 693640ec5c3 Improve documentation for constructors of pinned `Box`es f9ca0552e7d Rollup merge of #97636 - nnethercote:revert-96682, r=dtolnay a7022057d94 Rollup merge of #97420 - WaffleLapkin:no_oxford_casts_qqq, r=Mark-Simulacrum 0a14b95ed18 Auto merge of #97293 - est31:remove_box, r=oli-obk 817a02af075 Rollup merge of #97635 - rgwood:patch-1, r=ChrisDenton 5509ce7c5c1 Rollup merge of #97603 - ximon18:arc-make-mut-spelling-correction, r=GuillaumeGomez 75e2ae870e4 Rollup merge of #97397 - JohnTitor:stabilize-box-into-pin, r=Mark-Simulacrum 07d4ff7ca09 Auto merge of #97414 - LYF1999:yf/cachealign, r=Mark-Simulacrum 55eea5f8e8d Revert #96682. 5c124827a68 Fix Windows file metadata docs f35626e0e90 Stabilize `box_into_pin` d220e5dc2d5 Rollup merge of #95594 - the8472:raw_slice_methods, r=yaahc ce5f1c44c40 std: show signal number along with name acc49fa3230 Rollup merge of #97611 - azdavis:master, r=Dylan-DPC d669998cd9f Rollup merge of #97498 - ijchen:master, r=Mark-Simulacrum ec99b491cef Rollup merge of #94647 - Urgau:hash-map-many-mut, r=Amanieu b9ee4ff1731 Update sync.rs 7cf6a0787f7 Update sync.rs 0ad76b93e5e Tweak insert docs 8cd5576bf93 Auto merge of #97553 - nbdd0121:lib, r=Mark-Simulacrum 09a35566bc5 use 128 cache align for m1 mac c4acc968c78 Auto merge of #97435 - Patryk27:bump-compiler-builtins, r=Dylan-DPC 46f333e63d0 Use #[rustc_box] in alloc instead of box syntax e5bad9a2e1b Inline `bridge::Buffer` methods. b6c68220da8 Spelling correction. bc0228fe8ed Expose get_many_mut and get_many_unchecked_mut to HashMap 5633b7f11f0 Rollup merge of #97596 - WaffleLapkin:fixup_feature_name, r=compiler-errors 55a68c7ac92 Rollup merge of #97578 - ojeda:checkpatch, r=JohnTitor d91353ca574 Rollup merge of #97316 - CAD97:bound-misbehavior, r=dtolnay eaf1fb3f851 Fixup feature name to be more consistent with others d1036633016 Auto merge of #97419 - WaffleLapkin:const_from_ptr_range, r=oli-obk 255f824c0a8 Auto merge of #97521 - SkiFire13:clarify-vec-as-ptr, r=Dylan-DPC 5169ad834d5 alloc: remove repeated word in comment dbaa7377018 Auto merge of #97526 - Nilstrieb:unicode-is-printable-fastpath, r=joshtriplett bd81ed53abe Add unicode fast path to `is_printable` 62ccfe128a3 Auto merge of #97574 - Dylan-DPC:rollup-jq850l6, r=Dylan-DPC 8be08141173 Rollup merge of #97569 - thomcc:fill_with_isnt_memset, r=Amanieu 3972af6adb8 Rollup merge of #97565 - lukas-code:patch-1, r=thomcc 457ef6b4511 Rollup merge of #97455 - JohnTitor:stabilize-toowned-clone-into, r=dtolnay ec4c77203e3 Rollup merge of #97229 - Nilstrieb:doc-box-noalias, r=dtolnay 699e05c6d25 Auto merge of #96881 - est31:join_osstr, r=dtolnay bd0ce31d9df BTreeSet->BTreeMap (fix copy/paste mistake in documentation) e25270abf57 Fix typo uniqeness -> uniqueness 3b4cfc7a1f7 Remove `memset` alias from `fill_with`. 5b4b0c1be89 Rollup merge of #89685 - DeveloperC286:iter_fields_to_private, r=oli-obk 26a4fedac33 Update mut_ptr.rs dda6608cef7 Update intrinsics.rs 2de7e7f01f0 Remove too long example 4a9ae5ffaf9 Correct signed bit int documentation 912b8db843b Implement carrying_add and borrowing_sub on signed numbers 724751ea5d8 Auto merge of #97480 - conradludgate:faster-format-literals, r=joshtriplett f221e7945f6 Add `#[inline]` to `Vec`'s `Deref/DerefMut` 675f1da9fec Rollup merge of #97545 - thomcc:sip-comment-safety, r=Dylan-DPC 515af9d311d Rollup merge of #97499 - est31:master, r=Dylan-DPC 40f938cb5c6 Rollup merge of #97494 - est31:remove_box_alloc_tests, r=Dylan-DPC 621e065c03c Rename slice_from_ptr_range_const -> const_slice_from_ptr_range 96bb9b13309 Add reexport of slice::from{,_mut}_ptr_range to alloc & std 7c3c4dd7320 Make `from{,_mut}_ptr_range` const bcd45a18fd9 Remove "sys isn't exported yet" phrase 04b5ea9f689 Auto merge of #96964 - oli-obk:const_trait_mvp, r=compiler-errors cfdeb9124e0 Remove `#[default..]` and add `#[const_trait]` 76cfbfc2217 Reword safety comments in core/hash/sip.rs 8133126402e Auto merge of #97514 - WaffleLapkin:panick, r=Dylan-DPC 8fa8c9b4bd7 remove useless cold 0f78e1c292d improve format impl for literals 17ec5aaf88b Auto merge of #97214 - Mark-Simulacrum:stage0-bump, r=pietroalbini 8ac10b7a42c Clarify the guarantees of Vec::as_ptr and Vec::as_mut_ptr when there's no allocation 9ac74888ebb clarify how Rust atomics correspond to C++ atomics 0958cf70422 Fix typo (panick -> panic) f94e58768bb Remove `(fn(...) -> ...)` -> `usize` -> `*const ()` -> `usize` cast 5e1fd89ba76 protect `std::io::Take::limit` from overflow in `read` 81ea92c6891 Use Box::new() instead of box syntax in core tests ff206aec3f8 Use Box::new() instead of box syntax in std tests 0137a5df764 Rollup merge of #97482 - RalfJung:ptr-invalid, r=thomcc d1234d82ee1 Use Box::new() instead of box syntax in alloc tests 1a6d20adb23 Corrected EBNF grammar for from_str 4a48f6401b2 Auto merge of #97207 - RalfJung:backtrace, r=Mark-Simulacrum 26352268817 Auto merge of #97461 - eddyb:proc-macro-less-payload, r=bjorn3 1a9054dc533 note to future self 6fb53ea24fb ptr::invalid is not equivalent to a int2ptr cast d590edb64db Rollup merge of #97448 - Xiretza:os-str-unix-doc, r=joshtriplett 21270e81f77 Rollup merge of #97034 - fee1-dead-contrib:layout-hash, r=dtolnay 5e867c522b9 Rollup merge of #94640 - Pointerbender:issue-71146-partial-stabilization, r=yaahc 9a7d1e0e6b9 Use `pointer::is_aligned` in ThinBox debug assert 4fa10b5d0e9 Avoid zero-sized allocs in ThinBox if T and H are both ZSTs. f5f03a54dbc Rollup merge of #95214 - tbu-:pr_vec_append_doc, r=Mark-Simulacrum fd14cf69f8b proc_macro: don't pass a client-side function pointer through the server. c474893bb69 Stabilize `toowned_clone_into` 3d2eeba093d Call the OS function to set the main thread's name on program init 56f9eb19427 Finish bumping stage0 cb9db78cfc8 docs: Don't imply that OsStr on Unix is always UTF-8 749f27d2cc1 Auto merge of #97004 - nnethercote:proc-macro-tweaks, r=eddyb 20c971f6c2d Cut down `associated_item`. e45738c0508 Remove unnecessary blank line. 627abb07578 Rename `b` as `buf` in several places. 970e87d304c Add some comments about `_marker` fields. e6e5241cf4e Clarify a comment. 5529bfb1f56 Make `Buffer` non-generic. 463b2cb56aa Improve formatting in `associated_item!` definition. 820d933572d Add some comments. b0df8ba84dc Fix a typo in a comment. 203467783e4 Auto merge of #97444 - compiler-errors:rollup-2gvdav6, r=compiler-errors 09078f2cdef Rollup merge of #96051 - newpavlov:duration_rounding, r=nagisa,joshtriplett c1b092ec8c1 fmt 11c2537e5e5 fix nanos overflow for f64 f99f1339b15 add debug asserts 2920823815b libcore: Add `iter::from_generator` which is like `iter::from_fn`, but for coroutines instead of functions 0285dad5220 Document the current aliasing rules for `Box`. ffa4426e040 library/std: Bump compiler_builtins dfc96f8621f Rollup merge of #96033 - yaahc:expect-elaboration, r=scottmcm 4c77c5bf224 Auto merge of #97046 - conradludgate:faster-ascii-case-conv-path, r=thomcc 1d4564f9a49 improve case conversion happy path d6fbf6f478b Allow some internal instability b8254b4fa36 Auto merge of #96742 - m-ou-se:bsd-no-ancillary, r=joshtriplett c72f90a33b4 Disable unix::net::ancillary on BSD. f74aee8310d fix broken doctest c46c4bf8856 update option and result references to expect message docs 32ec3178ffe fix links bfc781f58ad Auto merge of #94954 - SimonSapin:null-thin3, r=yaahc fde8f543b99 Rollup merge of #97233 - c410-f3r:assert-lib, r=scottmcm 2727dd9f2f8 Rollup merge of #97379 - ear7h:master, r=thomcc f5d303ab69f Rollup merge of #97026 - Nilstrieb:make-atomic-debug-relaxed, r=scottmcm 90858829560 add aliases for current_dir ba359edd886 tweak doctests 9248bb10b89 implement tie to even 0d2f75cefdb explained unwrap vs expect 8dd0473a51f Rollup merge of #97364 - notriddle:continue-keyword, r=JohnTitor 089b2350d6c Rollup merge of #97363 - wackbyte:sliceindex-doc-typo, r=JohnTitor 243255f2c92 Rollup merge of #93966 - rkuhn:patch-1, r=tmandry 340e6736f40 Stabilize checked slice->str conversion functions 3c09243e9bf Stabilize `{slice,array}::from_ref` 8122dff4b6d Fix weird indentation in continue_keyword docs 2f82144742b Fix a mistake in `SliceIndex`'s documentation 628c0371876 Rollup merge of #97321 - RalfJung:int-to-fnptr, r=Dylan-DPC 6b59bc96eff Rollup merge of #97308 - JohnTitor:stabilize-cell-filter-map, r=Mark-Simulacrum 507242ab3fb Fix stabilization version of `Ipv6Addr::to_ipv4_mapped` 89c8f64345b sync primitive_docs caaec6ca2fc explain how to turn integers into fn ptrs f980d5a2611 Auto merge of #97315 - Dylan-DPC:rollup-2wee2oz, r=Dylan-DPC 42e12241850 Put a bound on collection misbehavior df4266cf842 Rollup merge of #96129 - mattheww:2022-04_float_rounding, r=Dylan-DPC afafc4412bb Auto merge of #92461 - rust-lang:const_tls_local_panic_count, r=Mark-Simulacrum 0cc191db898 Stabilize `cell_filter_map` 429f25115ea Auto merge of #97304 - Dylan-DPC:rollup-qxrfddc, r=Dylan-DPC 9965d8d0054 Rollup merge of #97294 - jersou:patch-1, r=Dylan-DPC 74f38e1f361 Rollup merge of #97087 - Nilstrieb:clarify-slice-iteration-order, r=dtolnay d681067ee2f Auto merge of #96100 - Raekye:master, r=dtolnay d225d2ff318 Auto merge of #96455 - dtolnay:writetmp, r=m-ou-se 185b85b2e77 Implement `FusedIterator` for `std::net::[Into]Incoming` 5e6d6416af7 Auto merge of #96906 - tbu-:pr_stabilize_to_ipv4_mapped, r=dtolnay 3f121af2933 Make write/print macros eagerly drop temporaries cbaa5faf784 std::time : fix doc variable name f02be2f5a02 small change 9fddc34855a [RFC 2011] Library code 13816e26f46 adjust transmute const stabilization version a194c13223e Auto merge of #97265 - JohnTitor:rollup-kgthnjt, r=JohnTitor b6bfa098680 Rollup merge of #97245 - m-ou-se:rwlock-state-typo, r=JohnTitor d78cacfe370 Rollup merge of #97225 - cuviper:ref-display, r=scottmcm e4359cc479d Rollup merge of #97144 - samziz:patch-1, r=Dylan-DPC 092561ce63e Auto merge of #94119 - c410-f3r:array-again-and-again, r=scottmcm 4bf0f478fae Expand the explanation of OsString capacity 366638801cf Auto merge of #94530 - tmiasko:alignment-impls, r=dtolnay b82f0d374e5 Rollup merge of #97219 - RalfJung:ptr-invalid, r=thomcc 52c3dc6eb3f Rollup merge of #97190 - SylvainDe:master, r=Dylan-DPC 9fc2821f665 Fix typo in futex RwLock::write_contended. 1f18522ca00 Auto merge of #96605 - Urgau:string-retain-codegen, r=thomcc bbdd6c1c7aa Use GRND_INSECURE instead of /dev/urandom when possible 4951915f7ed Update libc dependency of std to 0.2.126 c718ae5192a Fix `Display` for `cell::{Ref,RefMut}` 8c195d01710 Rollup merge of #97215 - AngelicosPhosphoros:add_hashtable_iteration_complexity_note, r=thomcc 30e91a09325 Rollup merge of #97187 - ajtribick:patch-1, r=thomcc 86bab57f758 Add complexity estimation of iterating over HashSet and HashMap 0d10e38b797 make ptr::invalid not the same as a regular int2ptr cast a63eb904dab Stabilize core::array::from_fn bfe46688bdb Rollup merge of #97192 - sunfishcode:sunfishcode/rightmost, r=thomcc 4f9da7515a8 Auto merge of #96422 - tmccombs:mutex-unpoison, r=m-ou-se e1964feddcb update libbacktrace 67893358ffb Remove references to guards in documentation for clear_poison 464afce09d2 Auto merge of #97147 - Mark-Simulacrum:stage0-bump, r=pietroalbini dee0eb60248 OsString: Consolidate all documentation about capacity in top-level docs 1576794f5d0 Auto merge of #97027 - cuviper:yesalias-refcell, r=thomcc 772216d205c Say "last" instead of "rightmost" in the documentation for `std::str::rfind`. ddf9f6ac43d Add implicit call to from_str via parse in documentation fe394db9e99 impl Read and Write for VecDeque dc9d0437408 Reverse condition in Vec::retain_mut doctest 62bfd962c54 Rollup merge of #97170 - benediktwerner:master, r=JohnTitor ff540561945 Rollup merge of #97155 - alygin:patch-1, r=JohnTitor 5f161d2a0a5 std: fix deadlock in `Parker` de301ac252f Remove unnecessay .report() on ExitCode 60b1204cf88 Change clear_poison to take the lock instead of a guard 0a815ef925b Auto merge of #97033 - nbdd0121:unwind3, r=Amanieu e5e28c974b2 Auto merge of #97159 - JohnTitor:rollup-ibl51vw, r=JohnTitor 07ca27bde30 Rollup merge of #97131 - gimbles:patch-2, r=Dylan-DPC 95c9954866d Rollup merge of #97127 - Mark-Simulacrum:revert-96441, r=m-ou-se dfbda3887fe Auto merge of #95643 - WaffleLapkin:ptr_convenience, r=joshtriplett b101c630750 Fix doc typo 8142f16ba41 std: Add capacity guarantees notes for OsString d166c0599b0 Stage-step cfgs ee5c1337c0b Fix rusty grammar in `std::error::Reporter` docs 38ceccd4953 std: use an event flag based thread parker on SOLID 773a82b6f8c Rollup merge of #97101 - coolreader18:exitcode-method-issue, r=yaahc 7fa69165877 Rollup merge of #96917 - marti4d:master, r=ChrisDenton 3237d9c99c4 Update macros.rs e08bcfdcfbe Revert "Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se" 207f89064e6 bump stable version #94640 aad191d5d94 Add tracking issue for ExitCode::exit_process 9fe9bc13ac4 Add a comment for covariant `Ref` 6a14f013a3a Remove outdated references to nll-rfc#40 23f62619324 Improve error message for fallback RNG failure 2e00ac7de7b Clarify slice and Vec iteration order 6d61f6b98cd Allow `unused_macro_rules` in path tests e79a705bd93 Auto merge of #97053 - CAD97:realloc-clarification, r=dtolnay 46899b2f9a6 Auto merge of #97065 - gabriel-doriath-dohler:master, r=joshtriplett 04778c62b12 Rename `eq_ignore_case` to `starts_with_ignore_case` dc5e5025832 Rollup merge of #97060 - bdbai:fix/uwphandle, r=ChrisDenton addef23f9ac Rollup merge of #96947 - sunfishcode:sunfishcode/rustc-nonnull-optimization-guaranteed, r=joshtriplett cdd3191467d fix use of SetHandleInformation on UWP 68c395da62c Remove potentially misleading realloc parenthetical d239fe341ed Auto merge of #94872 - mati865:mingw-llvm-target, r=petrochenkov e99685dcd1a Auto merge of #97035 - JohnTitor:rollup-00ko07z, r=JohnTitor 2da5ac873ef Implement `Hash` for `core::alloc::Layout` 03c784974df Rollup merge of #95365 - mkroening:hermit-alloc-error-handler, r=joshtriplett 43216bd81bb Auto merge of #95602 - scottmcm:faster-array-intoiter-fold, r=the8472 bd5d9ae09a7 Use re-export instead of inline wrapper in libunwind 004a5afdddb Use Rust ABI for `__rust_start_panic` and `_{rdl,rg}_oom` 0ef59fd9a48 Address review feedback 4857a5ffeb8 Auto merge of #97013 - matthiaskrgr:rollup-c1pc6pc, r=matthiaskrgr 022e1955259 Change orderings of `Debug` for the Atomic types to `Relaxed`. ab181d328a0 Use a pointer in cell::RefMut so it's not noalias f5508b9fce4 Use a pointer in cell::Ref so it's not noalias ab970200c64 Auto merge of #95356 - coolreader18:exitstatus-exit-method, r= 3be94c90e2e Guarantee less in docs 52609785bf2 Add ExitCode::exit_process example eb3820aea6f Add LLVM based mingw-w64 targets 3143d6c88f7 Extend ptr::null and null_mut to all thin (including extern) types 4c254f21b13 Rollup merge of #97003 - nnethercote:rm-const_fn-attrs, r=fee1-dead 40af7c68038 Rollup merge of #96154 - lukaslueg:unreachablehint, r=scottmcm a29c7a9a859 Slap #[inline] on all the ByRefSized methods, per the8472's suggestion 817d9ccb67e Remove some unnecessary `rustc_allow_const_fn_unstable` attributes. 7e6148a58ae Rollup merge of #96932 - sunfishcode:sunfishcode/document-borrowed-handle, r=joshtriplett e1e78337f55 Rollup merge of #96860 - semarie:openbsd-futex-time64, r=cuviper 1d8e3737c97 Fill-in tracking issues for features pointer_byte_offsets, const_pointer_byte_offsets and pointer_is_aligned 7a5d7a64011 Optimize `ptr.is_aligned_to()` 7d7dde9b118 Implement `ptr.is_aligned()` in terms of `.is_aligned_to()` 7ec9b3d68b4 Lift the `Sized` requirement from convenience ptr fns 783fdc5ebe8 Add convenience functions to pointers ec5407de22f Fix comment syntax. f7de102aaf4 Relax the wording about the meaning of -1. 6ceb4b31422 Auto merge of #95837 - scottmcm:ptr-offset-from-unsigned, r=oli-obk 653ab1cdec2 Apply CR suggestions; add real tracking issue 548588a6542 Add a debug check for ordering, and check for isize overflow in CTFE 6f39f4f434a Rename `unsigned_offset_from` to `sub_ptr` 5c8ce350989 Add `unsigned_offset_from` on pointers d6c35ee5f10 Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkov c968ec0b33e Fix attribute name. 6fe89a0ab17 RawSocket is unsigned on Windows. cc96d05c0da Fix duplicate import on Windows. 4b746f083b7 Add rustc_nonnull_optimization_guaranteed to Owned/Borrowed Fd/Socket 57848a29952 HandleOrNull can hold null, and HandleOrInvalid can hold INVALID_HANDLE_VALUE. 13af9979374 Use `fcntl(fd, F_GETFD)` to detect if standard streams are open 77baba5e364 Fix incorrect mentions of `OwnedFd` and `BorrowedFd` in Windows docs. aaeba79f7c4 to_timespec could be unused by some targets 404f9b99ad3 avoid using both Some() and ? on linux/android/freebsd code 8ee7ecd71e3 openbsd: convert futex timeout managment to Timespec usage 5a3f178e9a8 Also document that `as_raw_handle` may return NULL. aecef5d36cf Clarify what values `BorrowedHandle`, `OwnedHandle` etc. can hold. ccb7b423485 Auto merge of #96232 - sunfishcode:sunfishcode/io-safety-const-fns, r=joshtriplett 7aee395c353 Also allow unused macro rules in stdarch 8d587c4ce94 Recommend `Ipv6Addr::to_ipv4_mapped` over `Ipv6Addr::to_ipv4` 38bbc2f271b Stabilize `Ipv6Addr::to_ipv4_mapped` c0e4aff28b2 Make HashMap fall back to RtlGenRandom if BCryptGenRandom fails 22971e4b8e4 Rollup merge of #96861 - m-ou-se:std-use-prelude-2021, r=joshtriplett 188301442b5 Rollup merge of #96725 - nico-abram:win_tid, r=ChrisDenton 0e2b3e900a5 Rollup merge of #96674 - bstrie:vardoc, r=thomcc a54d4ce4256 Expose process main_thread_handle on Windows 372acab73ad Implement [OsStr]::join 7faffb4e166 Rollup merge of #96841 - thomcc:revert-osstr-join, r=m-ou-se f8ff5892b2c Rollup merge of #96008 - fmease:warn-on-useless-doc-hidden-on-assoc-impl-items, r=lcnr 05838c7373d Rollup merge of #95483 - golddranks:improve_float_docs, r=joshtriplett 4065d6770cc Add `task::Waker::noop` c497e87d9c9 Use Rust 2021 prelude in std itself. 46a7406734c Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 81a7ada736d Auto merge of #96802 - gimbles:windows_slice, r=thomcc a12e08031ac Auto merge of #96846 - matthiaskrgr:rollup-yxu9ot9, r=matthiaskrgr bbb2c4be2f4 Warn on unused doc(hidden) on trait impl items cab41cffada Rollup merge of #96828 - scottmcm:clarify-hasher-write, r=Amanieu db552361a31 Auto merge of #96302 - Serial-ATA:more-diagnostic-items, r=manishearth cfd39c55cc8 Revert "Implement [OsStr]::join", which was merged without FCP f1e7dccab3f fix panic in Path::strip_prefix c47d8761371 Auto merge of #94206 - PrestonFrom:significant_drop, r=flip1995 93ce47cea84 Further elaborate the lack of guarantees from `Hasher` b05f81e024f Rollup merge of #96671 - mgeisler:current-exe-docstring, r=Mark-Simulacrum 64abbed3ff5 Rollup merge of #96586 - ear7h:master, r=joshtriplett 2521c02a9ac Rollup merge of #96336 - Nilstrieb:link-to-correct-as_mut-in-ptr-as_ref, r=JohnTitor c3da321ef49 Auto merge of #96657 - cuviper:time64, r=joshtriplett 54cca20afea Fix a minor typo in the description of Formatter a8dde5c5dc2 [fix] remove pub(crate) visibility 02985f73409 Rollup merge of #96701 - kraktus:alloc_example_2018_edition, r=Mark-Simulacrum bf1f372841c Mark locks in std lib with clippy::has_significant_drop bbea2e863b1 This is a pretty good start if you ask me 2d959e11f02 Share more unix SystemTime code 04ff72289ae [feat] Make sys::windows::os_str::Slice repr(transparent) 2996d0d0955 Use statx's 64-bit times on 32-bit linux-gnu fb0e9e34307 Use __clock_gettime64 on 32-bit linux-gnu 8b7d1a0ba5d unix: always use 64-bit Timespec 3447ae9a8a6 Auto merge of #95183 - ibraheemdev:arc-count-acquire, r=Amanieu 3eb3a95d9f6 Auto merge of #94598 - scottmcm:prefix-free-hasher-methods, r=Amanieu 702ad51c553 Clarify unreachable_unchecked docs ffadf1ef233 Auto merge of #96510 - m-ou-se:futex-bsd, r=Amanieu 2fab20c29bf For now, don't change the details of hashing a `str` 6c845122228 Add a dedicated length-prefixing method to `Hasher` f7825dd5178 Rollup merge of #96744 - est31:join_osstr, r=thomcc 0933750d435 Rollup merge of #96639 - adpaco-aws:fix-offset-from-typo, r=scottmcm 187026b7171 Rollup merge of #96174 - RalfJung:no-run-transmute, r=scottmcm 7040839ea1d Auto merge of #96520 - lcnr:general-incoherent-impls, r=petrochenkov cde5f42cc37 Implement [OsStr]::join 27ccbcd7908 Remove condvar::two_mutexes test. dc97374b512 Allow unused rules in some places in the compiler, library and tools 08461f0b8f8 Rollup merge of #96682 - nnethercote:show-invisible-delims, r=petrochenkov be65266a032 Rollup merge of #95843 - GuillaumeGomez:improve-new-cyclic-doc, r=m-ou-se 8758d5e3a05 Rollup merge of #95359 - jhpratt:int_roundings, r=joshtriplett 1322a149478 Auto merge of #96649 - tbu-:pr_to_ipv4_loopback_doc, r=m-ou-se 1d3be74aa38 generalize "incoherent impls" impl for custom types e0c64fd35f3 Auto merge of #96630 - m-ysk:fix/issue-88038, r=notriddle dee97a2fad6 Auto merge of #96626 - thomcc:rand-bump, r=m-ou-se c98f39824ef Update `int_roundings` methods from feedback a1327203e56 Rollup merge of #96628 - joshtriplett:stabilize-then-some, r=m-ou-se 2587c093a15 Rollup merge of #96619 - akiekintveld:same_mutex_check_relaxed_ordering, r=m-ou-se af7a71b0e09 Rollup merge of #96616 - akiekintveld:min_stack_relaxed_ordering, r=joshtriplett 6d652c3b037 Fix the generator example for `pin!()` e7d21cf91dd Make it clear that `to_ipv4` returns an IPv4 address for the IPv6 loopback cc6516e8bf4 slice: #[inline] a couple iterator methods. ae1ba3d5d35 Improve Rc::new_cyclic and Arc::new_cyclic documentation ac0540b83d6 update `jemallocator` example to use 2018 edition import syntax 3439ae80423 Stabilize `bool::then_some` 71149050e9b add caveat discussed in #74335 6e7350f2d9f Show invisible delimeters (within comments) when pretty printing. 1ccb5cc8567 Auto merge of #96280 - lygstate:ffi-fixes, r=joshtriplett 5092491bd23 std::io: Modify some ReadBuf method signatures to return `&mut Self` 5aaa7a3e558 docs: add link explaining variance to NonNull docs 5d4760208d5 Remove hard links from `env::current_exe` security example 79b511affdc Round timeouts up to infinite in futex_wait on DragonFlyBSD. 4837d8c8138 Add #[cfg] in cfg_if for linux in unix/futex. 2a0642047ab Don't use futexes on netbsd. ea1937babfa ignore a doctest for the non-exported macro ff797ca3dd6 Update library/core/src/ffi/mod.rs 236b6428e52 This aligns the inline attributes of existing `__iterator_get_unchecked` with those of `next()` on adapters that have both. 3beb5518750 add benchmark 438df5762ca Fix typo in `offset_from` documentation 4ae7f4affef Fix nits dc8c8686f2e Auto merge of #96596 - scottmcm:limited-calloc, r=Mark-Simulacrum 5c70424b928 Test leaking of BinaryHeap Drain iterators cf90f46f8cd Slightly tighten leak-on-panic test cases d71788ca9d6 Share testing utilities with non-btree test cases b5c883e05f3 Avoid use of `rand::thread_rng` in stdlib benchmarks 9da9c85f23e Tweak the calloc optimization to only apply to shortish-arrays e2b9b8747f3 Add comment 80a5880c553 Fix formatting 77d78900319 Rollup merge of #96568 - EliasHolzmann:fmt_doc_fixes, r=joshtriplett 0558d7c2f57 Rollup merge of #96567 - alex-semenyuk:fix_docs_for_logs_func, r=Mark-Simulacrum 0abfdad15c3 Rollup merge of #96222 - jmaargh:john-mark/clarify-from-raw-parts-docs, r=JohnTitor 0ea0dc422f9 Rollup merge of #94126 - ssomers:alloc_prep_1, r=Mark-Simulacrum c6620ffe649 Relax memory ordering used in SameMutexCheck c0f6d4c90ac Relax memory ordering used in `min_stack` 7b23d4cc016 Auto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomez 87a6eaa57a2 add `{Arc, Rc}::downcast_unchecked` 9439685e565 Improve codegen of String::retain method. dedc83eafe1 std::fmt: Improved list of formatting macros ffa90e39936 std::fmt: Removed reference to Formatter::buf and other private fields 97069269222 std::fmt: Fix the grammar documentation 231644bd0a1 std::fmt: Added argument index comments to examples for specifying precision 459467e4382 std::fmt: Fixed documentation for specifying precision via `.*` 4d2c7e2f1e6 Auto merge of #96376 - scottmcm:do-yeet, r=oli-obk cf78e7714db Auto merge of #96078 - udoprog:refcounted-str-to-u8, r=dtolnay b91d3cb369e Bump shared_from_str to Rust 1.62.0 23966b5fdba Auto merge of #96490 - dtolnay:writetmpbackport, r=Mark-Simulacrum 329a57a2735 Auto merge of #95362 - scottmcm:calloc-arrays, r=Mark-Simulacrum 06339bcd70f Add `do yeet` expressions to allow experimentation in nightly 32ce5f340fd Fix some links in the standard library 09bf157434d add aliases for std::fs::canonicalize cf5d745fbb8 Auto merge of #96348 - overdrivenpotato:inline-location, r=the8472 9ec37a16b82 spicy ea7dafedf95 Fix documentation for log functions int f0d4201b5f0 Fix documentation for log functions unsigned int 981a99e9b07 Disable pthread thread parker on futex platforms. d73eb0be184 Always return false in futex_wake on {Free,DragonFly}BSD. 49f3f998702 Update libc dependency of std to 0.2.125. ed491d7e745 Use futex-based locks and thread parker on FreeBSD. fdae7118766 Auto merge of #96489 - shepmaster:revert-vec-from-array-ref, r=yaahc 0c9708aec3a Use futex-based locks and thread parker on DragonFlyBSD. 681c3923167 Use futex-based locks and thread parker on NetBSD. 6e099d7eb90 Use futex-based locks and thread parker on OpenBSD. 8746e65e378 Rollup merge of #96492 - joshtriplett:revert-std-ffi-re-export, r=yaahc d8412e5be0e Rollup merge of #96481 - aDotInTheVoid:hashmap-docs-monospace, r=joshtriplett 8fa8a34a1bf Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se 275bd35801e Auto merge of #96393 - joboet:pthread_parker, r=thomcc a31dd5c3ee8 Add more diagnostic items eb412d22c45 Rollup merge of #96480 - user-simon:patch-1, r=Dylan-DPC 7316d795da4 Rollup merge of #96433 - petrochenkov:delim, r=nnethercote cabdcecf660 Yield the thread when waiting to delete a file 9f8611a541c std: simplify UNIX parker timeouts c6306af994f Auto merge of #95904 - paolobarbolini:vecdeque-specextend, r=the8472 3d2da128b0f rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter` f837cc06281 Add VecDeque::extend from vec::IntoIter and slice::Iter specializations b3c2848c89b Rollup merge of #96466 - compiler-errors:error-collect-array, r=davidtwco 15af63df93b Rollup merge of #96397 - AronParker:issue-96368-fix, r=dtolnay 55e83269661 Revert "Re-export core::ffi types from std::ffi" 02ce4817774 Remove use of reverted std::ffi::c_char 3f17bc6307f Make [e]println macros eagerly drop temporaries (for backport) e9e98c0791a Revert "impl From<&[T; N]> and From<&mut [T; N]> for Vec" 7a291d891b0 Add VecDeque::extend benchmark b5bccc761c9 HashMap doc: Don't use monospace font for 'Entry Api' f0654701f6a Fixed grammatical error in example comment 8c4b1efe7c8 Note the importance of using sync pipes 4fe65f8bb5d Add tracking issue number for mutex_unpoison d4a4c654228 Better error messages when collecting into `[T; n]` e11b8240116 Auto merge of #96195 - sunfishcode:sunfishcode/handle-or-error-type, r=joshtriplett 2aff1064e9b Windows: Make stdin pipes synchronous c812a22609d Add `set_inheritable` for Windows `Handle`s 6f287f46e5f Rollup merge of #96415 - ehuss:git-io, r=bjorn3 bf00f0634f7 Rollup merge of #95949 - SoniEx2:patch-5, r=m-ou-se 3080e6df0b1 Rollup merge of #94022 - jongiddy:cow-into-owned-docs, r=Dylan-DPC 2ce21b2722f Add functions to un-poison Mutex and RwLock bd99f2bb033 Retry deleting a directory f534f19769a Remove references to git.io 64a3a543fe9 Rollup merge of #96149 - est31:remove_unused_macro_matchers, r=petrochenkov fac6a6f5f80 Rollup merge of #90312 - r00ster91:search, r=Dylan-DPC ad112687b41 Windows: Iterative `remove_dir_all` 4928c952e1e Make EncodeWide implement FusedIterator a8836f29f4a std: directly use pthread in UNIX parker implementation 1bdfdbebaa2 Auto merge of #95246 - ChrisDenton:command-args, r=joshtriplett 0385a94b534 Rollup merge of #96107 - Gumichocopengin8:test/vec-deque, r=Mark-Simulacrum 565eb445017 Auto merge of #94609 - esp-rs:esp-idf-stat-type-fixes, r=Mark-Simulacrum 47973e0c507 test: add test cases for VecDeque 1d2f55b762a std: `::fmt` name the signal it died from fa8e0e4068c Inline core::panic::Location methods 33b73a1032f Auto merge of #90602 - mbartlett21:const-intoiterator, r=oli-obk 71c4e54da9a Auto merge of #95971 - workingjubilee:no-weird-fp-in-const, r=oli-obk 09d209f04e0 Link to correct `as_mut` in docs for `pointer::as_ref` 9f053876948 Use const initializer for LOCAL_PANIC_COUNT 338dc63fdb2 Auto merge of #96314 - AronParker:issue-96297-fix, r=thomcc 0c2885b0389 Remove unnecessary const-time x87-related checks db82c1898f9 Fix comments for float classify 68aa96d090e Auto merge of #94887 - dylni:move-normpath-crate-impl-to-libstd, r=ChrisDenton 9939ed65996 Remove redundant type annotation 132a20eaa27 Reduce allocations for path conversions on Windows c9ccbc96b52 library/core: Fixes implement of c_uint, c_long, c_ulong 8dca5fe4a6b Rollup merge of #96228 - mbartlett21:patch-4, r=thomcc 15d8ad0b268 Rollup merge of #96193 - djkoloski:fuchsia_current_exe, r=tmandry cb82769f086 Rollup merge of #96234 - goffrie:eloop, r=thomcc 45db3442898 Rollup merge of #96206 - m-ou-se:wasm-futex-locks, r=alexcrichton 48f83825f08 Rollup merge of #96168 - chris-morgan:AddrParseError-description-improvements, r=joshtriplett 2f447e163c3 Rollup merge of #96167 - CAD97:weak-dlsym-less-ptr-crime, r=thomcc 379ef4950c6 Auto merge of #96135 - petrochenkov:doclink6, r=GuillaumeGomez bf10ce076a8 Change file locations to be links to GitHub 4db08d82503 remove_dir_all_recursive: treat ELOOP the same as ENOTDIR 0e3248761b9 Make `BorrowedFd::borrow_raw` a const fn. 73f4c8933e2 Fix locations for intrinsics impls d658c539394 Rollup merge of #96205 - m-ou-se:emscripten-futex-locks, r=thomcc db8daa3f139 [fuchsia] Add implementation for `current_exe` 715179fcdf8 Clarify docs for from_raw_parts 5a4df4bbb88 proc_macro: Add a workaround for rustdoc 594c596c28f espidf: fix stat 23de2959ee2 Rollup merge of #96089 - ojeda:no-vec-no_global_oom_handling, r=Mark-Simulacrum 5f688ad156e Use futex locks on emscripten. 1f6db6e9c8f Use futex locks on wasm+atomics. 1b51b9a7c6e Make std::sys::wasm::futex consistent with unix::futex. 13c82ce143a Make std::sys::unix::futex consistent on emscripten. d9ce9885e8e Improve AddrParseError description 1333efa5810 Add a comment explaining the `(())` idiom for empty structs. 99e3160254e Split `NotHandle` into `NullHandleError` and `InvalidHandleError`. f107d710d4a Move the `Error` impl for `NotHandle` out of platform-independent code. d5185d9747e Fix an incorrect word in a comment. 4a23e0a52b9 Define a dedicated error type for `HandleOrNull` and `HandleOrInvalid`. 35272826c4c Auto merge of #92287 - JulianKnodt:slice_remainder, r=yaahc 40f94e9b3a7 Update library/core/src/result.rs 0837073a0b0 Update library/core/src/result.rs 9c55694ced6 Remove unused macro rules 1a879d9c75e Rollup merge of #96156 - est31:use_from_le_bytes, r=Dylan-DPC a232f573238 Rollup merge of #96136 - thomcc:lifetime-wording, r=RalfJung fa9e85d8584 mark ptr-int-transmute test as no_run 57438ed7464 Auto merge of #96042 - m-ou-se:one-reentrant-mutex, r=Amanieu 51c0a1f6b68 Remove forgotten reexport of ReentrantMutex in sys::unsupported. 8c91a3d1ead Replace sys/unix/weak AtomicUsize with AtomicPtr dc59501c943 Auto merge of #93530 - anonion0:pthread_sigmask_fix, r=JohnTitor 51637918730 Replace u8to64_le macro with u64::from_le_bytes 4095522a16f Auto merge of #96139 - erikdesjardins:revertinl2, r=Mark-Simulacrum b0c8bae5c85 Expand core::hint::unreachable_unchecked() docs 85459ce7c02 Add slice::remainder 41e92414133 move import to fix warning with emscripten target 513a487900c Revert "Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum" f780b81256a Auto merge of #96010 - eduardosm:Unique-on-top-of-NonNull, r=m-ou-se,tmiasko d6bd9a6f563 Remove unnecessary function 56958ff35b1 Improve Windows path prefix parsing 82660f2c3b5 Reword clarification on lifetime for ptr->ref safety docs 9e3b373dd70 Auto merge of #96002 - nnethercote:speed-up-Vec-clear-2, r=m-ou-se 35ecb89ea30 Document the numeric value returned by string parsing for floats 8fbbf4e85db Document rounding for floating-point primitive operations 9883cb24360 No need to check the assert all the time. 79ad4a4175a Rollup merge of #96081 - eduardosm:masks_usize_size_agnostic, r=yaahc 439f9d2ec7e Rollup merge of #96038 - beyarkay:patch-1, r=m-ou-se d299c99bd80 Use a single ReentrantMutex implementation on all platforms. b70f1ad108f Rollup merge of #96099 - clarfonthey:maybeuninit_array_cleanup, r=dtolnay 3cc72d6c329 Rollup merge of #96070 - Gumichocopengin8:test/btree-map, r=thomcc d7b76e76ffa Rollup merge of #95961 - RalfJung:gather-scatter, r=workingjubilee c72583cf693 `alloc`: make `vec!` unavailable under `no_global_oom_handling` 93d875e9791 Change `as_uninit_*` methods on `NonNull` from taking `self` by reference to taking `self` by value. This is consistent with the methods of the same names on primitive pointers. The returned lifetime was already previously unbounded. 1cd0e1f7241 MaybeUninit array cleanup 68760c193ad Auto merge of #95224 - mjbshaw:patch-1, r=yaahc cece998bfe5 Rollup merge of #96040 - m-ou-se:futex-u32, r=Amanieu 037af5a54c0 Rollup merge of #96034 - Gumichocopengin8:test/btree-set, r=Dylan-DPC bf16a22dcd2 Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelix 71864b72bfd Rollup merge of #94457 - jhpratt:stabilize-derive_default_enum, r=davidtwco ee000c29eb7 update docs for option to crossreference to the result docs c70061cb347 Auto merge of #94079 - petrochenkov:cstr, r=joshtriplett 316ade286ea Make some `usize`-typed masks definition agnostic to the size of `usize` 220ff934f27 Implement str to [u8] conversion for refcounted containers 60123a63cc2 Auto merge of #95841 - ChrisDenton:pipe-server, r=m-ou-se 8e2fc98a30c chore: formatting cccefd1d370 test: add try_insert() test cases for BTreeSet 1644d31224d test: add get_key_value() test cases for BTreeSet 0d5f5785954 test: add pop_first() pop_last() test cases for BTreeSet 8cf01bfc820 add should_panic annotations 9ad853d5116 library: Remove definitions and reexports of `strlen` from libstd 7fa25bbda8d Fix targets not supporting `target_has_atomic = "ptr"` d04f19fff81 library: Use type aliases to make `CStr(ing)` in libcore/liballoc unstable a3aa2533887 library: Move `CStr` to libcore, and `CString` to liballoc 52a1ae17531 add necessary text attribute to code block of panic output 1c795d36e7b Use rounding in float to Duration conversion methods cc09b2d381f Implement `core::ptr::Unique` on top of `NonNull` 0a1e2b803e4 Use u32 instead of i32 for futexes. 0f3fc7b6e5f Remove trailing whitespace 749d8900d80 docs: add link from zip to unzip 7e461a3e3a6 Remove use of `#[rustc_deprecated]` 7395922d890 Bump stdarch ab650afce4d test: add remove() test cases for BTreeSet 82ada4bf297 test: add is_superset test cases for BTreeSet aca9b43713a Add section on common message styles for Result::expect 8cdbe07c933 Auto merge of #95958 - jhpratt:bump-stdarch, r=Dylan-DPC fc35de43b3e Auto merge of #96015 - Dylan-DPC:rollup-vhdprid, r=Dylan-DPC 8402b1c092b Rollup merge of #96006 - hkBst:patch-2, r=Dylan-DPC b9b0421fdcd Rollup merge of #96005 - hkBst:patch-1, r=Dylan-DPC 473d5771b61 Rollup merge of #95962 - sourcefrog:doc-direntry, r=Dylan-DPC b183e97fea3 Auto merge of #95727 - m-ou-se:futex-reentrantmutex, r=Amanieu cb17458d904 Add a missing article 275f8453b77 Add missing article to fix "few" to "a few". 8919de3eaac Speed up Vec::clear(). e6b830c0cc2 Rollup merge of #95984 - wcampbell0x2a:fix-spelling, r=thomcc bd7013ffd24 Rollup merge of #95914 - c410-f3r:meta-vars, r=petrochenkov 6d142eb463c Implement tuples using recursion 426db93d673 Fix spelling in docs for can_not_overflow 35b93bccdf7 portable-simd: use simd_arith_offset to avoid ptr-int transmutation f479036dce3 Rollup merge of #95947 - cuviper:default-box, r=dtolnay 216fd734122 Rollup merge of #95900 - o01eg:fix-wasm-doc, r=Mark-Simulacrum e967ebeb3d5 Ban subnormals and NaNs in const {from,to}_bits 8adeba8957e Rectify float classification impls for weird FPUs 0755d9e7ee8 Add missing unsafe marker. 0c2a8136fad Allow cvt_nz to be unused on some platforms. a53a1ee5763 Add #[deny(unsafe_op_in_unsafe_fn)] to thread_local!(const). d9cf5faf6cf Add debug asserts to futex ReentrantMutex impl. 7667c09ac6a Initialize thread local with const{}. f182dd9628f Move current_thread_unique_ptr to the only module that uses it. 8ac4de4a153 Make current_thread_unique_ptr work during thread destruction. 2ff4da4fabd Add futex-based ReentrantMutex on Linux. 6d4bb346206 Add current_thread_unique_ptr() in std::sys_common. dd23d5ca969 Auto merge of #95399 - gilescope:plan_b, r=scottmcm 1ecc9f449cc Document that DirEntry holds the directory open 8796fa69fee Bump stdarch 4167362acb1 Auto merge of #93408 - liangyongrui:master, r=scottmcm 183e8ea6c5b Implement Default for AssertUnwindSafe 7e0e46a7a60 impl const Default for Box<[T]> and Box 90abc43b3d4 Rollup merge of #95895 - CAD97:patch-2, r=Dylan-DPC 426010dcb3c Rollup merge of #95894 - nyanpasu64:fix-pin-docs, r=Dylan-DPC 5a5a795740f Rollup merge of #95801 - m-ou-se:futex-rwlock, r=Amanieu 2e3ebc67815 Fix documentation for wasm32-unknown-unknown 80ba09607be Use is_ or has_ prefix for pure `-> bool` functions. e09179136b5 Use compare_exchange_weak in futex rwlock implementation. a63da4fdd5d Add comments to futex rwlock implementation. 01898d9c6d4 Add doc comments to futex operations. dd1f4c25ee7 Rollup merge of #95917 - RalfJung:thin-box-test, r=dtolnay ab84560679a Rollup merge of #95743 - yaahc:binary-search-clarification, r=Mark-Simulacrum 9fae6c2c9b4 better def of is signed in tests. 89d9aa86068 fix Layout struct member naming style 31e2310f18f thin_box test: import from std, not alloc 331f93705b4 kmc-solid: Use `abort` to abort a program 8da8c14f36f Clarify str::from_utf8_unchecked's invariants 44a2f78466c Fix formatting error in pin.rs docs b5bad7edddf Rollup merge of #95566 - eduardosm:std_char_consts_and_methods, r=Mark-Simulacrum 2981ba9f922 No need to use Default 979c2f31ce9 Use Add, Sub, Mul traits instead of unsafe 3e7c8584514 Auto merge of #95621 - saethlin:remove-mpsc-transmute, r=RalfJung c08615686e0 Rollup merge of #95831 - redzic:xor-uppercase, r=workingjubilee 2e8c13a4a59 Rollup merge of #95817 - oconnor663:doc_comment2, r=yaahc eb3e76c7bff Rollup merge of #95805 - c410-f3r:meta-vars, r=petrochenkov cecb3571242 Rollup merge of #95361 - scottmcm:valid-align, r=Mark-Simulacrum ae6d6b22cd8 Rollup merge of #94794 - mlodato517:mlodato517-clarify-string-indexing-docs, r=Mark-Simulacrum 343c071f117 Rework String UTF-8 Documentation 5cc90dcaf3f Rollup merge of #95802 - RalfJung:unused-win, r=Dylan-DPC 3115ee26526 Rollup merge of #95308 - bjorn3:more_stable_proc_macro, r=Mark-Simulacrum 188591aab32 Rollup merge of #95787 - yaahc:panic-doc-update-v2, r=dtolnay 2d812d7b14d Remove ptr-int transmute in std::sync::mpsc 4fb721b02b8 Make non-power-of-two alignments a validity error in `Layout` d4266ff8d49 Use bitwise XOR in to_ascii_uppercase 6c855807361 hide another #[allow] directive from a docs example c07dc311903 Add ThinBox type for 1 stack pointer sized heap allocated trait objects 546a83cf550 Fix typo in futex rwlock. 070a0a2d080 Left overs of #95761 a37ce2a6559 fix some unused constant warning on some Windows targets 9c3d996b1bf Add futex-based RwLock on Linux. 37be49f11c1 Auto merge of #95798 - Dylan-DPC:rollup-51hx1wl, r=Dylan-DPC b8e11946e4e Windows: Use a pipe relay for chaining pipes dbcdd3a6bf0 Rollup merge of #95791 - oconnor663:doc_comment, r=thomcc c23d88f9a0c Rollup merge of #95782 - ChrisDenton:pipe-buffer-size, r=thomcc e109a9160ed Rollup merge of #95761 - c410-f3r:meta-var-stuff, r=petrochenkov 46ed398a10c Rollup merge of #95579 - Cyborus04:slice_flatten, r=scottmcm 8afd5c9b037 Auto merge of #95775 - RalfJung:miri-windows-compat, r=ChrisDenton fdcbfbd7901 add `<[[T; N]]>::flatten`, `<[[T; N]]>::flatten_mut`, and `Vec::<[T; N]>::into_flattened` 402e4da33b3 hide an #[allow] directive from the Arc::new_cyclic doc example e529c071688 Add documentation 14b7bf2ad01 Stabilize `derive_default_enum` 4beff172e16 reword panic vs result section to remove recoverable vs unrecoverable framing 8cb80300a18 Windows: Increase a pipe's buffer capacity to 64kb 3e51c761312 do not round-trip function pointer through integer 747f14a3279 make windows compat_fn (crudely) work on Miri 1dc5166bf71 Kickstart the inner usage of macro_metavar_expr c03d130d4a4 Auto merge of #95760 - Dylan-DPC:rollup-uskzggh, r=Dylan-DPC 2ecedac4b49 Return status from futex_wake(). 4c83e4e1abc Rollup merge of #95757 - zofrex:gender-neutral-terms, r=dtolnay 07323678739 Rollup merge of #95753 - ChayimFriedman2:patch-1, r=dtolnay 96a57226253 Use gender neutral terms 8ad0a25dc45 Auto merge of #95678 - pietroalbini:pa-1.62.0-bootstrap, r=Mark-Simulacrum 9c929f3962c Auto merge of #95748 - Dylan-DPC:rollup-t208j51, r=Dylan-DPC a9c6ae49c7a Correct safety reasoning in `str::make_ascii_{lower,upper}case()` 5bf0822bfda Rollup merge of #95725 - hkBst:patch-1, r=Dylan-DPC 64ed5277125 Rollup merge of #95708 - fee1-dead:doc_whitespace_trim, r=Dylan-DPC e5906c575c3 Rollup merge of #95646 - mgeisler:mention-std-env-var, r=Dylan-DPC 13b431d87ef Update library/core/src/slice/mod.rs 267c50015d5 remove exclamation mark af96f31e6ff Auto merge of #95688 - pfmooney:libc-update, r=Mark-Simulacrum 810089390f0 add necessary closure for partition_point 8c3b8fe67ab Rollup merge of #95735 - bjorn3:revert_inline_location_caller, r=compiler-errors 52caf8584b3 Rollup merge of #95709 - nnethercote:improve-terse-test-output, r=Dylan-DPC f698c67c6f2 Rollup merge of #95626 - saethlin:pass-pointer-to-prctl, r=cuviper 22282b34708 Rollup merge of #95185 - m-ou-se:stabilize-stdin-lines, r=Mark-Simulacrum 883fe8baa75 Update binary_search example to instead redirect to partition_point 070a60dfd81 Change trailing prctl arguments to c_ulong f0ad925bec9 Use PhantomData directly in Bridge 5aef892214b Revert "Mark Location::caller() as #[inline]" 19c998a5ab1 Bump stabilization of stdin_forwarders to 1.62.0. eb4d6293cfb Rename RWLock to RwLock in std::sys. 411f975f1bb Mention `std::env::var` in `env!` 4f02f13fe22 Message: Chunks cannot have a size of zero. 58c88f24772 Auto merge of #95711 - Dylan-DPC:rollup-ujss3oi, r=Dylan-DPC fafe90f591f Rollup merge of #95699 - SparkyPotato:master, r=dtolnay 422f20d1615 Rollup merge of #95659 - anp:remove-link-print, r=tmandry 6bad81ada3f Auto merge of #95469 - ChrisDenton:unsound-read-write, r=joshtriplett b29f1bda2e9 Improve terse test output. b37aaaf6b6d Update documentation for `trim*` and `is_whitespace` to include newlines e7a7bd32b89 Auto merge of #95702 - Dylan-DPC:rollup-793rz6v, r=Dylan-DPC 7ba45c6568e trivial cfg(bootstrap) changes 3d695a0cad8 Rollup merge of #95663 - notriddle:notriddle/unsafe-fn-closure, r=compiler-errors a336fa87f18 Rollup merge of #95547 - RalfJung:ptr-int-transmutes, r=scottmcm 8d98603e88b Rollup merge of #88025 - devnexen:netbsd_scm_creds, r=Amanieu dd0c571b42d Auto merge of #95035 - m-ou-se:futex-locks-on-linux, r=Amanieu fe1a4cf2a88 formatting 844b076fd5e cleanup 52e036de73f fix Vec leak with 0 capacity f485ec84fd9 diagnostics: tweak error message to give more rationale to unsafe Fn 8fc4fe0ca8a Update libc to 0.2.121 3714dd8fc1b Reword comment in futex condvar implementation. 4ddde190264 Rollup merge of #95660 - yaahc:panic-docs-update, r=Dylan-DPC 14bf99c8d4a Mark unix::locks::futex::Mutex::new as #[inline]. f17995d692b Use rtabort 9eab9dac5ed Make `synchronous_write` safe to call 7af08890fa1 Document synchronicity 0c74e12f21c Complete reads and writes synchronously or abort 085d0cededc Correct definition of `IO_STATUS_BLOCK` 478318afa14 Fix bogus tidy errors 71d0145265a diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut 11a8e11a154 Rollup merge of #95630 - declanvk:update-nonnull-doc, r=RalfJung b5c2ef4605a Rollup merge of #95588 - RalfJung:strict-provenance, r=scottmcm b945b2c5cd4 Rollup merge of #91873 - estebank:mention-impls-for-unsatisfied-trait, r=davidtwco c466374ba9e Update panic docs to make it clearer when to use panic vs Result 9189860bbff Rely on #[link] attribute for unwind on Fuchsia. bcb635965a3 explicitly distinguish pointer::addr and pointer::expose_addr 6146073115f Mention implementers of unsatisfied trait 2382259b02f Rollup merge of #95467 - ChrisDenton:async-read-pipe, r=joshtriplett 8343b8edc0e Rollup merge of #95438 - m-ou-se:sync-unsafe-cell, r=joshtriplett 2be5f607bef Rollup merge of #95431 - golddranks:stabilize_total_cmp, r=scottmcm a6babb40b37 Rollup merge of #92942 - Xaeroxe:raw_arg, r=dtolnay 2a673783905 Correct calling convention 714ad4f6cc8 Bump windows CommandExt::raw_arg to 1.62 e60b6ae5da9 from_u32(0) can just be default() a9768273a7e Stabilize total_cmp 77c8c2b1607 Update library/std/src/sys/windows/pipe.rs 56eecd59966 Auto merge of #95031 - compiler-errors:param-env-cache, r=Aaron1011 b8f5c2d7bc1 Add doc links referencing raw pointer methods 0cffe8e8bcd ScmCredentials netbsd implementation. efcb0a7e7ec Auto merge of #95619 - bjorn3:inline_location_caller, r=scottmcm a7e3d451596 Rollup merge of #95618 - adamse:master, r=dtolnay 891b39cfa4d Rollup merge of #95617 - saethlin:swap-test-invalidation, r=Dylan-DPC 3f1996a2a54 Don't cast thread name to an integer for prctl 66b76bbed79 Refer to the `exposed` versions of the methods instead 52379ea92b1 Fix &mut invalidation in ptr::swap doctest 1340e5883c6 Auto merge of #95610 - createyourpersonalaccount:derefmut-docfix, r=Dylan-DPC 3b03ded3429 Mark Location::caller() as #[inline] d1faefabd7b core: document that the align_of* functions return the alignment in bytes a5fca8cd844 Auto merge of #92686 - saethlin:unsafe-debug-asserts, r=Amanieu d25fd090486 Update safety comments, make `split_at_mut` unsafe 236e32566f6 Auto merge of #90791 - drmorr0:drmorr-memcmp-cint-cfg, r=petrochenkov 17c6b26c70a Improve doc example of DerefMut 45f7987b7db make memcmp return a value of c_int_width instead of i32 12766b2e89a Fix `array::IntoIter::fold` to use the optimized `Range::fold` f95c9160d6b Rollup merge of #95597 - dtolnay:threadlocalu8, r=Dylan-DPC 066952680ba Rollup merge of #95587 - m-ou-se:std-remove-associated-type-bounds, r=Dylan-DPC 3f818eeec78 Refer to u8 by absolute path in expansion of thread_local dacb56cdd4f add tracking issue 442d4618a51 Additional `*mut [T]` methods ebd611ddc5d refine wording and describe alternatives 81d639581a9 need guidence on testing 7515c7c4537 incorporating feedback 8b6be698057 Create 2024 edition 8e05ad5c549 Deprecate the `ptr_to_from_bits` feature 95d381735a7 Rollup merge of #95557 - niluxv:issue-95533, r=dtolnay 0327ca9a5ef Rollup merge of #95556 - declanvk:nonnull-provenance, r=dtolnay f2d2d941266 Rollup merge of #95354 - dtolnay:rustc_const_stable, r=lcnr cd4b1a3afc3 Auto merge of #95552 - matthiaskrgr:rollup-bxminn9, r=matthiaskrgr 5ab809311be Avoid duplication of doc comments in `std::char` constants and functions. 781c504bf7d Rollup merge of #95546 - autumnontape:allocator-realloc-align-docs, r=Amanieu a899f0b5a8f Rollup merge of #95532 - RalfJung:utf8_char_counts, r=Dylan-DPC ed08e2c1ae6 Rollup merge of #95528 - RalfJung:miri-is-too-slow, r=scottmcm 891afa99a57 Rollup merge of #95516 - RalfJung:ptrs-not-ints, r=dtolnay 3ab608b8e8e Use MaybeUninit for clock_gettime's timespec. 563db8cb074 Don't spin on contended mutexes. 92b1e6a5ba4 Shuffle around #[inline] and #[cold] in mutex impl. e7edbd7b13d Add comment about futex_wait timeout. b78a6d00711 Fix `thread_local!` macro to be compatible with `no_implicit_prelude` 163a0b90275 Remove need for associated_type_bounds in std. 97578eaf481 Implement provenance preserving method on NonNull 1ae8e6322e7 Rollup merge of #95032 - m-ou-se:std-features, r=yaahc ed4acae721f caution against ptr-to-int transmutes 62eb9beee60 add notes about alignment-altering reallocs to Allocator docs 5b3d555eba1 Fix feature name of stable parts of strict_provenance ff548e1e35f Adjust MaybeUninit feature names to avoid changing unstable one fc5511c6537 Adjust feature names that disagree on const stabilization version 5721db576ae make utf8_char_counts test faster in Miri bfe82e989a9 Categorize and sort unstable features in std. 19341ede53f skip slow int_log tests in Miri cde28a425fb Rollup merge of #95520 - rust-lang:ptrtypo, r=lcnr d207aab318f Rollup merge of #95384 - ehuss:doc-target_has_atomic-stabilized, r=Dylan-DPC e6d5c97d5bb Fix typos in core::ptr docs 47f3b249908 ptr_metadata test: avoid ptr-to-int transmutes 10cb93e3abb Rollup merge of #95505 - sunfishcode:sunfishcode/fix-openbsd, r=dtolnay c403b12ec50 match std f32 primitive docs to core f32 primitive docs 140c84d1ac6 Further refine the disclaimer about NaN bit patterns. 1009986f7f0 Re-introduce "propagating NaN" to `maximum`/`minimum`, add "ignoring NaN" to `max`/`min`, add disclaimer about the "propagation". ef47f66c314 Rollup merge of #95491 - faern:stabilize-vec_retain_mut, r=yaahc 27223556e45 Rollup merge of #95130 - workingjubilee:stably-finished, r=m-ou-se b7fb2c42847 Remove antipattern from process::exit docs 10357ae2491 Add ExitCode::exit_process() fc99173b03d Improve wording of "NaN as a special value" top level explanation 7e9898796ed Fix library/std compilation on openbsd. f3049104979 Rollup merge of #95298 - jhorstmann:fix-double-drop-of-allocator-in-vec-into-iter, r=oli-obk d76f18b597d Stabilize native library modifier syntax and the `whole-archive` modifier specifically 002222870a0 Stabilize feature vec_retain_mut on Vec and VecDeque 4c8ea36a8a1 Add references to explanation about portability to f{32,64}::{from,to}_{be,le,ne}_bytes e8eccfa2fe7 Fix: is_sign_positive -> is_sign_negative 6ad1291c824 Improve floating point documentation: e7637fb66ab Auto merge of #94963 - lcnr:inherent-impls-std, r=oli-obk,m-ou-se 1c95868202a Don't stabilize ScopedJoinHandle::is_finished yet. 15ad7115fca Synchronize asynchronous pipe reads and writes b46b47f494b Auto merge of #95241 - Gankra:cleaned-provenance, r=workingjubilee 7d2d4ac4bc8 remove now unnecessary lang items b9ecec0a727 rework implementation for inherent impls for builtin types b6699571582 Rollup merge of #95452 - yaahc:termination-version-correction, r=ehuss f267b319be4 Rollup merge of #95294 - sourcefrog:doc-copy, r=dtolnay 600cfc070a8 Warn that platform-specific behavior may change 6bccd1f20c2 fix unix typedef fb1a29f9e7a fixup feature position in liballoc c1ef05b6e76 clarify that WASM has address spaces 08d7fb9383a fix doc link d2bc59a16f4 refine the definition of temporal provenance 718f3780e4b mark FIXMES for all the places found that are probably offset_from 5a156a0b31d more review fixes to ptr docs ccf5bc99c0c Add even more details to top-level pointer docs 9000ecde9ce cleanup some of the less terrifying library code 7c2e4d36831 clean up pointer docs 78723161d2c revert changes that cast functions to raw pointers, portability hazard 1d39d213044 Make some linux/unix APIs better conform to strict provenance. f9a15b2dccd Make the stdlib largely conform to strict provenance. 3ca639d5dc1 Introduce experimental APIs for conforming to "strict provenance". 957dd22f515 fix since field version for termination stabilization 08e9bc91c77 Rollup merge of #95256 - thomcc:fix-unwind-safe, r=m-ou-se 75e480121ac Rollup merge of #93840 - yaahc:termination-stabilization-celebration-station, r=joshtriplett e737efe3336 Indicate the correct error code in the `compile_fail` block. c8b9bfb96a7 Add tracking issue for sync_unsafe_cell. 9f3b4ec7735 Add SyncUnsafeCell. 3296627f076 Auto merge of #94566 - yanganto:show-ignore-message, r=m-ou-se ec9e9b7cc1c Rollup merge of #94566 - yanganto:show-ignore-message, r=m-ou-se 5c677a170b5 Add debug assertions to some unsafe functions 7ede88d585e Remove unnecessary .as_ref(). f0c5af72ae2 Refactor after review 192ee67e021 Auto merge of #95375 - MarcusCalhoun-Lopez:i686_apple_darwin, r=m-ou-se 63e86238385 Auto merge of #95249 - HeroicKatora:set-ptr-value, r=dtolnay 8a6e3971624 Fix build on i686-apple-darwin systems 8df777d8a83 Fix build on i686-apple-darwin systems 1a4a088cfb3 Rollup merge of #95407 - xfix:inline-u8-is_utf8_char_boundary, r=scottmcm d7578ae4394 Rollup merge of #95397 - dtolnay:disclaimer, r=m-ou-se 6c18d68344d Touch up ExitCode docs a77f83396e0 Inline u8::is_utf8_char_boundary fedb8b3f6af Link to std::io's platform-specific behavior disclaimer 41c712b380b Rollup merge of #95098 - shepmaster:vec-from-array-ref, r=dtolnay 9ea0a52f0e0 Rollup merge of #95016 - janpaul123:patch-1, r=dtolnay 2e635908d95 Rollup merge of #93755 - ChayimFriedman2:allow-comparing-vecs-with-different-allocators, r=dtolnay 1acf28e3beb Rollup merge of #88375 - joshlf:patch-3, r=dtolnay 263d8a567a5 Update target_has_atomic documentation for stabilization 57476eb9872 Rollup merge of #95368 - lopopolo:lopopolo/string-try-reserve-exact-doc-typo, r=Dylan-DPC b74ca828b83 Fix typo in `String::try_reserve_exact` docs 8c92caee35c Use default alloc_error_handler for hermit 6f56b6bdd33 Debug print char 0 as '\0' rather than '\u{0}' 376d0dd4294 Support arrays of zeros in Vec's __rust_alloc_zeroed optimization 8bcf1ee163e Bump const_ptr_offset stabilization to 1.61 4ac359f198a Auto merge of #95274 - jendrikw:slice-must-use, r=Dylan-DPC 40553ff901a Using macro to avoid performance hit (thanks LingMan) 9266c27c49a Update library/core/src/num/mod.rs df7f4da19e5 Better explanation cae1afa567d Update library/core/src/num/mod.rs 4e26991a589 removed likely 764d58c9c2f Update library/core/src/num/mod.rs 34e09ea30eb Update library/core/src/num/mod.rs dee02d3946c add likely and clearer comments ab661302fdd faster parsing when not possible to overflow 2f4c46eaa4d Auto merge of #95326 - lupd:std-iter-doc, r=Dylan-DPC 3be1bbd4ade add #[must_use] to functions of slice and its iterators. 4e8deaa3087 Remove mention of HashMap not offering iter_mut 66be029d8ae Add note about feature gates 35f15f630e6 Check for `"` and `\` in a filename b4508175e71 Avoid negative impls in the bridge 19085a0e2d4 Remove usage of extern_types feature gate 09cfbf8fe6f Remove usage of panic_update_hook feature gate 456ff2c421e Remove unused auto_traits feature gate a9533769fcc Add another assertion without into_iter b00031e095d std::process docs: linkify references to output, spawn and status 02557e15bcd Add a test verifying the number of drop calls 16d7bd0d9d6 Use ManuallyDrop::take instead of into_inner ed008a92982 Fix double drop of allocator in IntoIter impl of Vec 39c31086ed6 Adjust tests for isize::MAX allocation always being checked 5cf076c9e3d Enforce that layout size fits in isize in Layout 0cc8fa66b16 Document Linux kernel handoff in std::io::copy and std::fs::copy 2fe80474005 Rollup merge of #95276 - FoseFx:clippy_trim_split_whitespace, r=flip1995 63fccadc379 Auto merge of #94517 - aDotInTheVoid:inline_wrapping_next_power_two, r=yaahc 0ab7bd164e3 add diagnostic items for clippy's e7c6067d9cf add #[must_use] to functions of slice and its iterators. c9761c0c272 Explicitly use CLOCK_MONOTONIC in futex_wait. e2b802cac9d Make Timespec available in sys::unix. 206517a4769 Use FUTEX_WAIT_BITSET rather than FUTEX_WAIT on Linux. e3d31aef20e Auto merge of #87667 - the8472:document-in-place-iter, r=yaahc 5661e4b65da Add a `compile_fail` doctest to check that `io::Error: !UnwindSafe` b165b11406b Ensure io::Error's bitpacked repr doesn't accidentally impl UnwindSafe eb7aa075f1d fix some links, clarify documentation based on review feedback ab9ba9bd5ef Refactor set_ptr_value as with_metadata_of a9952828ef8 Explicitly mention overflow is what we're checking dcd774ab95e Auto merge of #94901 - fee1-dead:destructable, r=oli-obk 268597fea0b Spin before blocking in Mutex::lock. 67176ccff59 Update tests. 639e87165bf Replace Linux Mutex and Condvar with futex based ones. a2f9280678f Add futex_wake_all. c740b3bb1b5 Return timeout status in futex_wait. e3d598256e9 Clarify that `Cow::into_owned` returns owned data 40de75ae11b Auto merge of #95235 - asquared31415:ptr_eq_typo, r=Dylan-DPC 61f9d0ecfa1 ptr::guaranteed_eq doc typo 9424230bc76 Auto merge of #95173 - m-ou-se:sys-locks-module, r=dtolnay 301839353ae Add test for issue #95178 21a9d320e02 Command: handle exe and batch files separately cc5df4231df Refactor: Move argument building into args 15996ab87b0 Auto merge of #95223 - Dylan-DPC:rollup-idpb7ka, r=Dylan-DPC 566a6cbe97c Format unsafe {} blocks 802da6bc499 Optimize RcInnerPtr::inc_strong instruction count 4d26721b863 Rollup merge of #94713 - clarfonthey:is_char_surrogate, r=scottmcm 22b470750c6 Rollup merge of #92955 - llogiq:cloned-side-effect-doc, r=yaahc 3598104ba5b Rollup merge of #91608 - workingjubilee:fold-neon-fp, r=nagisa,Amanieu 29eeece3466 Auto merge of #95088 - bjorn3:fix_test_variadic_fnptr, r=dtolnay f9065114213 Fold aarch64 feature +fp into +neon cdcc2547446 Limit test_variadic_fnptr to unix a9764e95000 Remove impossible panic note from `Vec::append` fd9947cbace add perf side effect docs to `Iterator::cloned()` 17f323b7b9e Move std::sys::{mutex, condvar, rwlock} to std::sys::locks. c60c1dd2748 add some fix 1b617ccc8d3 fix the lint problem 60805b52e5e update Termination trait docs b241a272633 Auto merge of #95107 - r00ster91:fmt, r=joshtriplett 0d4f9e6b92f Auto merge of #95158 - sunfishcode:sunfishcode/windows-8, r=joshtriplett 749f0e065c8 Add u16::is_utf16_surrogate f7dc7172745 rename internal helper trait AsIntoIter to AsVecIntoIter 787e782699d Stabilize Stdin::lines. 0361684e2d0 weaken needlessly restrictive orderings on `Arc::*_count` 898343ee19d add module-level documentation for vec's in-place iteration 9e07a559f42 move AsIntoIter helper trait and mark it as unsafe 98126f4a95e rename module to better reflect its purpose e47d8e83e31 Move pthread locks to own module. 5a2ca54c8a4 Rename `~const Drop` to `~const Destruct` d17c75a0bf1 Add `Destructible` for replacing `~const Drop` e6c3f348f10 Add a testcase. 40986963df5 Preserve the Windows `GetLastError` error in `HandleOrInvalid`. 8764165aa00 Don't declare test_variadic_fnptr with two conflicting signatures 44b2681d2b4 Rollup merge of #95114 - ChrisDenton:symlink-test, r=the8472 841602d84c0 Auto merge of #92962 - frank-king:btree_entry_no_insert, r=Amanieu 2bc33eacb6c Rollup merge of #95110 - wmstack:patch-1, r=Dylan-DPC 52268f62263 Rollup merge of #94989 - compiler-errors:stream-alias, r=Dylan-DPC 3de455771db Rollup merge of #94749 - RalfJung:remove-dir-all-miri, r=cuviper 977132e0f57 Stabilize thread::is_finished ec997343f8c Auto merge of #94372 - erikdesjardins:asrefinl, r=dtolnay c66277d80cd Skip a test if symlink creation is not possible 9d7db03d6a8 Rollup merge of #94991 - CAD97:const-weak-new, r=dtolnay d7ee267b73c Rollup merge of #94650 - ChrisDenton:windows-absolute-fix, r=dtolnay d1d56917955 Rollup merge of #93858 - krallin:process-process_group, r=dtolnay 121ae59be77 Improve formatting in macro 216ed502652 Provide more useful documentation of conversion methods c5bd849a81a Rollup merge of #94984 - ericseppanen:cstr_from_bytes, r=Mark-Simulacrum e5200d66557 Rollup merge of #93692 - mfrw:mfrw/document-keyword-in, r=dtolnay 380bd8b066c Rollup merge of #93263 - sunfishcode:sunfishcode/detatched-console-handle, r=dtolnay 0b6be0a8c63 Rollup merge of #92663 - cuviper:generic-write-cursor, r=dtolnay c55b5cb5616 Rollup merge of #92612 - atopia:update-lib-l4re, r=dtolnay d6a4d7a38ec Rollup merge of #92519 - ChrisDenton:command-maybe-verbatim, r=dtolnay 0ef0affc56f impl From<&[T; N]> and From<&mut [T; N]> for Vec faa6f16822f Make Weak::new const 455c9f7d12f add CStr::from_bytes_until_nul b75a85c7bbd Bump impl Write for Cursor<[u8; N]> to 1.61 f0bda1214d0 Rollup merge of #95083 - danielhenrymantilla:patch-2, r=RalfJung cc27ac0951b Rollup merge of #95058 - wcampbell0x2a:use-then-in-unix-process, r=dtolnay 6dbd83ff7f6 Rollup merge of #95017 - zachs18:cmp_ordering_derive_eq, r=Dylan-DPC 4d657518942 Rollup merge of #94115 - scottmcm:iter-process-by-ref, r=yaahc e0dffe90002 Document that `Option` discriminant elision applies for any ABI c8741dca480 Auto merge of #88098 - Amanieu:oom_panic, r=nagisa 95422e15115 feat: Add use of bool::then in sys/unix/process dcafc5faf72 Rollup merge of #94960 - codehorseman:master, r=oli-obk e526baf116a Rollup merge of #93745 - tarcieri:stabilize-adx, r=cjgillot e4e9e30f9e2 Add test for StructuralEq for std::cmp::Ordering. 65b309d8a7d Derive Eq for std::cmp::Ordering, instead of using manual impl. 2e4199720a3 Docs: make Vec::from_raw_parts documentation less strict bc0f1738b4a BTree: evaluate static type-related check at compile time 66df1ddd5ab resolve the conflict in compiler/rustc_session/src/parse.rs 3b5a4b247cd Add Stream alias for AsyncIterator 6cdb5d9f6c7 Rollup merge of #94957 - iamzhangyong:explanation-read_line, r=Dylan-DPC 6a0aec08304 Rollup merge of #94868 - dtolnay:noblock, r=Dylan-DPC 1b3d56a1bbc changed wording 4d2d27c32cb Rollup merge of #94947 - Dylan-DPC:fix/typos, r=oli-obk a8da8aedca9 Improve the explanation about the behaviour of read_line b592654906d Unstably constify `impl IntoIterator for I: ~const Iterator` eab38397e30 fix typos 07f574965de Stabilize ADX target feature 26beff4495d Rollup merge of #90621 - adamgemmell:dev/stabilise-target-feature, r=Amanieu 97c160066d9 Add a `process_group` method to UNIX `CommandExt` 22bdf90e975 Stabilise `aarch64_target_feature` 32c0cf93d1b refactor: VecDeques Iter fields to private b0c01ba1da8 Auto merge of #94916 - matthiaskrgr:rollup-s6zedfl, r=matthiaskrgr 88533f5bf04 Rollup merge of #94816 - WaffleLapkin:atomic_get_mut_slice, r=Mark-Simulacrum 73b641ae791 Rollup merge of #93292 - nvzqz:nonzero-bits, r=dtolnay f232300ccea Auto merge of #94738 - Urgau:rustbuild-check-cfg-values, r=Mark-Simulacrum c3d92140f32 Use reduce_sum in as_simd example 1c50c1f2ac4 Sync portable-simd to rust-lang/portable-simd@72df4c45056a8bc0d1b3f06fdc828722177f0763 286e75d88c5 Use `Self::BITS` in `log2` implementation 04af6248716 Implement `BITS` constant for non-zero integers 42d905ba93c Format core and std macro rules, removing needless surrounding blocks 51af7da7537 Auto merge of #94860 - Dylan-DPC:rollup-n06j8h6, r=Dylan-DPC 274c0e90e65 Rollup merge of #94838 - antonok-edm:float-parse-docs, r=Dylan-DPC eff86641116 Rollup merge of #94818 - yoshuawuyts:into-future-associated-type, r=joshtriplett 0dbb5d81364 Rollup merge of #87618 - GuillaumeGomez:std-char-types-doc, r=jyn514,camelid 4029b558523 Auto merge of #94472 - JmPotato:use_maybeuninit_for_vecdeque, r=m-ou-se ed4b1dd591d Update tests. 1f140a64376 Update advance and advance_slices docs. 55abafbb01d Panic when advance_slices()'ing too far. afc9f51e7c7 Rollup merge of #94842 - tspiteri:there-is-no-try, r=Dylan-DPC 166f2fa549b Rollup merge of #94776 - martingms:optimize-escape-default, r=nnethercote 31238a145e9 Rollup merge of #93283 - m1guelperez:master, r=Mark-Simulacrum f2ad1db6c59 Show ignore message in console and json output 814fc7c9f14 Classify BinaryHeap & LinkedList unit tests as such 404a876c242 remove unnecessary try_opt for operations that cannot fail b632a6bdc17 make float parsing docs more comprehensive bcd1522c375 Rollup merge of #94826 - allgoewer:fix-retain-documentation, r=yaahc a9209e85bc1 Rollup merge of #94765 - m-ou-se:is-some-and, r=Dylan-DPC 1ffc2ad3da5 Rollup merge of #94356 - Thomasdezeeuw:stabilize_unix_socket_creation, r=dtolnay a4595a639a0 Rollup merge of #93293 - nvzqz:nonzero-min-max, r=joshtriplett 99fcfbb9eb0 Improve doc wording for retain on some collections dba18e52371 Move note about 0 gap to signed integers 8a8ca6d280b Rollup merge of #94790 - RalfJung:portable-simd-miri, r=Dylan-DPC 2e8f78153cc Rollup merge of #93950 - T-O-R-U-S:use-modern-formatting-for-format!-macros, r=Mark-Simulacrum 606dc01e058 Add `Atomic*::get_mut_slice` 32e8b11ab8f Rename `IntoFuture::Future` to `IntoFuture::IntoFuture` 5c16eb2f8b3 Rollup merge of #94805 - oli-obk:drop_box, r=pnkfelix 573e5965086 Rollup merge of #94644 - m-ou-se:scoped-threads-drop-soundness, r=joshtriplett 981362ada44 Rollup merge of #94587 - JKAnderson409:issue-90107-fix, r=scottmcm 433aa0c1c1f Use implicit capture syntax in format_args 1e0b9caeff1 Revert accidental stabilization daff96a2ad9 Inline ::next d2eea70b46c Rollup merge of #94746 - notriddle:notriddle/method-rustc-on-unimplemented, r=davidtwco 5dbae95049c Rollup merge of #94657 - fee1-dead:const_slice_index, r=oli-obk bc8d22e2160 Rollup merge of #94635 - jhpratt:merge-deprecated-attrs, r=davidtwco 72695c63043 Let `try_collect` take advantage of `try_fold` overrides 29b03eb493d Use MaybeUninit in VecDeque to remove the undefined behavior of slice 117ac269e70 enable portable-simd doctests in Miri 9759f0ac026 Rollup merge of #94768 - fortanix:raoul/fix_close_read_wakes_up_test_sgx_platform, r=dtolnay f588715e4a3 Rollup merge of #94763 - m-ou-se:scoped-threads-lifetime-docs, r=Mark-Simulacrum 25db37bb78e Rollup merge of #93057 - frengor:iter_collect_into, r=m-ou-se 4da6a1865c1 Rollup merge of #92541 - asquared31415:from-docs, r=m-ou-se 74274cc4e4c Rollup merge of #91804 - woppopo:const_clone, r=oli-obk 9022fd90d3f Add missing closing parenthesis e129080f105 Document NonZeroXxx layout guarantees c7a6904935c New `deprecated_suggestion` feature, use in tests 63833ff3587 Use indexing instead of .get_unchecked() for LUT lookup 0d7675d6a2e Add tracking issue ad1ccfac89c diagnostics: use rustc_on_unimplemented to recommend `[].iter()` c426915a069 Optimize ascii::escape_default by using a digit LUT 2d0bdff2bb1 BTreeMap::entry: Avoid allocating if no insertion 3e1c7bfaf25 Add documentation about lifetimes to thread::scope. dc5334a3d1b Ignore `close_read_wakes_up` test on SGX platform fe71d7badbb add as_raw() method to L4Re's Socket mock a41f7efb5c3 put L4Re specifics into their own platform 69c5cc1a744 adapt L4Re network interface mock to #87329 36a99ade133 L4Re does not support sanitizing standard streams af688ebc97d drop unused libc imports on L4Re d63607bfc80 fix return value of LookupHost::port() 220761303fd fix return values in L4Re networking stub bfd099742b0 Add soundness test for dropping scoped thread results before joining. 9235b7ca7d3 Remove outdated comment. 4c95f04e369 Properly abort when thread result panics on drop. 494ab291f99 Fix soundness issue in scoped threads. 77d5d6df5be Rename is_{some,ok,err}_with to is_{some,ok,err}_and. cd3c6a708e6 Rollup merge of #94756 - ChrisDenton:unreachable, r=yaahc 13628287021 Rollup merge of #94699 - ssomers:btree_prune_insert, r=Dylan-DPC e0cdff3141e Auto merge of #94750 - cuviper:dirent64_min, r=joshtriplett 5bced61cf65 docs 69681d391ba Use `unreachable!` for an unreachable code path 679b3869a7b Remove unexpected #[cfg(target_pointer_width = "8")] in tests 1e78e41091b Rollup merge of #94730 - msabansal:sabansal/b-atomic-mut-ptr, r=Dylan-DPC e1a13a87865 Rollup merge of #94724 - cuviper:rmdirall-cstr, r=Dylan-DPC 9743e96bf5e Rollup merge of #94723 - dtolnay:mustuse, r=Mark-Simulacrum 24deb8dd99f Rollup merge of #94714 - ChrisDenton:win-close_read_wakes_up, r=Mark-Simulacrum cff3a0b19a0 unix: reduce the size of DirEntry 694b986e011 remove_dir_all: use fallback implementation on Miri c28b303d9cf Add core::hint::must_use 237c5418481 Rollup merge of #94712 - kckeiks:remove-rwlock-read-error-assumption, r=Mark-Simulacrum a86242ccac1 Rollup merge of #94559 - m-ou-se:thread-scope-spawn-closure-without-arg, r=Mark-Simulacrum 7d16e30a88d Rollup merge of #92385 - clarfonthey:const_option, r=fee1-dead 5885ff9f21a Fix for issue #93283 4bb9015bccd Reverted atomic-mut-ptr feature removal causing compilation break bb4dd59826a unix: Avoid name conversions in `remove_dir_all_recursive` 3ba63dfed91 Enable `close_read_wakes_up` on Windows c2fe13a16b8 Use `f` instead of `|| f()`. db935ceadb4 promot debug_assert to assert ef2c6b2993e Rollup merge of #93827 - eholk:stabilize-const_fn-features, r=wesleywiser c275101455b Rollup merge of #93350 - gburgessiv:master, r=Mark-Simulacrum 93d4138d330 Stabilize const_impl_trait as well 9ddafceea25 Stabilize const_fn_fn_ptr_basics and const_fn_trait_bound 00fdd8d428a Add missing documentation for std::char types ce17b89e314 BTree: remove dead data needlessly complicating insert 1b827435615 Auto merge of #94272 - tavianator:readdir-reclen-for-real, r=cuviper d7c256332f3 Rollup merge of #94671 - csmoe:pin-typo, r=m-ou-se 7e18b02e693 fix pin doc typo 63ce2f71956 Rollup merge of #94649 - ChrisDenton:unix-absolute-fix, r=Dylan-DPC c3b48fc545a Constify slice index for strings 964ca4247ae doc: `Iterator::partition` use partial type hints f84e157adba Auto merge of #94648 - RalfJung:rollup-4iorcrd, r=RalfJung b429b6a73c3 Use as_os_str to compare exact paths bce504beb5e Relax tests for Windows dos device names b4cb4fe88aa Use `as_os_str` to compare exact paths 3a5bd01e4bd Unix `path::absolute`: Fix leading "." component 3b2ff4d995b do not attempt to open cgroup files under Miri fd202857f6c partially stabilize `(const_)slice_ptr_len` by stabilizing `NonNull::len` #71146 07016dcec02 Small fixes in thread local code. 4c708259063 Update documentation in thread/local.rs. 29a871d8d18 Add debug asserts in thread local cell set methods. 32e6aac0aff Add tracking issue number for local_key_cell_methods. 45986df83ca Rename LocalKey's with_{ref,mut} to with_borrow{,_mut}. accd56dbf6a Implement RFC 3184 - thread local cell methods. 51c642fae75 Auto merge of #94546 - JmPotato:std-features-cleanup, r=m-ou-se e8ba06caebd Rollup merge of #94620 - pierwill:partialord-constistency, r=yaahc 86c0ef9eb6d Rollup merge of #94446 - rusticstuff:remove_dir_all-illumos-fix, r=cuviper 48bec46d96c Clean up the std library's #![feature]s b05f152e5d5 Auto merge of #94628 - Dylan-DPC:rollup-v2slupe, r=Dylan-DPC c5f57965ad7 Implement Copy, Clone, PartialEq and Eq for core::fmt::Alignment dd1c1f1c1a1 Rollup merge of #94618 - lewisclark:remove-stack-size-rounding, r=yaahc 0525e891bbf Rollup merge of #94577 - RalfJung:simd-miri, r=scottmcm d8676acc810 Auto merge of #94298 - Urgau:rustbuild-check-cfg, r=Mark-Simulacrum b7679d0a211 Edit docs on consistency of `PartialOrd` and `PartialEq` 70b17a52ba4 Don't round stack size up for created threads d47362b30e2 Rollup merge of #94549 - m-ou-se:thread-is-finished, r=yaahc 693559d3e79 Rollup merge of #94236 - reez12g:add_track_caller_87707, r=yaahc 5a5a93f78af Add suggested changes to the docs 95ef88d6416 Make use statement visible badcecdb5fa Remove redundant code for handling NULL handles on Windows. a442a9bf0ec Fix a compilation error. a4f6661f787 Consistently present absent stdio handles on Windows as NULL handles. 50f5193a9c4 Integrate macos x86-64 remove_dir_all() impl. Step 2: readd 8ea6c1ebf1e Integrate macos x86-64 remove_dir_all() impl. Step 1: remove bc363bdcba1 remove_dir_all(): try recursing first instead of trying to unlink() db68d85b5d0 Use '_ for irrelevant lifetimes in Debug impl. 6b49d702e87 Add #![allow(unexpected_cfgs)] in preparation of global --check-cfg e52bd5900dd Add #[track_caller] to track callers when initializing poisoned Once 423f3ea330c Rollup merge of #94572 - sunfishcode:sunfishcode/handle-or, r=joshtriplett 59df46fda7e Rollup merge of #93965 - Mark-Simulacrum:owned-stdio, r=dtolnay cf3c24e7fb7 Rollup merge of #88805 - krhancoc:master, r=dtolnay 7455672d14c Document new recommended use of method 8858502efd0 only disable SIMD for doctests in Miri (not for the stdlib build itself) 69931b8c81a Miri can run this test now ebd3c202cd5 fix a warning when building core tests with cfg(miri) cceb3c358d3 Use `HandleOrNull` and `HandleOrInvalid` in the Windows FFI bindings. 7bf58dd2837 Rollup merge of #94551 - darnuria:doc-map-backstick, r=dtolnay 510cd36bfaf Rollup merge of #92697 - the8472:cgroups, r=joshtriplett 13b6c58485d Fix doctests. ef564360f25 Add -Z oom={panic,abort} command-line option ec035fc738b Auto merge of #94512 - RalfJung:sdiv-ub, r=oli-obk d367072c767 Remove argument from closure in thread::Scope::spawn. 6cea99ea737 Remove unnecessary #![feature]s from doctest. 0ef174b82b7 Update test. 0ac0e557e78 Rename JoinHandle::is_running to is_finished and update docs. 761f376b6cd Doc: Fix use of quote instead of backstick in Adapter::map. 8f2fc7f8c01 Rollup merge of #94534 - bstrie:cffistd, r=Mark-Simulacrum 132c75c5cfa Rollup merge of #93562 - sunfishcode:sunfishcode/io-docs, r=joshtriplett 59f600e3042 Remove the comment about `FILE_FLAG_OVERLAPPED`. 16a33930fc8 Rollup merge of #94529 - GuillaumeGomez:unused-doc-comments-blocks, r=estebank 527023a0062 Rollup merge of #93663 - sunfishcode:sunfishcode/as-raw-name, r=joshtriplett f42baf811c6 Rollup merge of #93354 - sunfishcode:sunfishcode/document-borrowedfd-toowned, r=joshtriplett c1e1226c5cb update available_parallelism docs since cgroups and sched_getaffinity are now taken into account dbc62c10afe hardcode /sys/fs/cgroup instead of doing a lookup via mountinfo c9123d86182 Use cgroup quotas for calculating `available_parallelism` dd2c42ed923 Fix a broken doc link on Windows. 26edf02c7a5 Update stdarch submodule 35b3701d28a Fix unused_doc_comments lint errors 9d580206609 Re-export core::ffi types from std::ffi 1fe1cb81257 merge the char signess list of archs with freebsd as it is the same 130a5e11fb6 update char signess for openbsd 316f87c551d Mark `uint::wrapping_next_power_of_two` as `#[inline]` ad715f87d03 Miri/CTFE: properly treat overflow in (signed) division/rem as UB 93d99a90cde Temporarily make `CStr` not a link in the `c_char` docs fe60644bb8a Provide C FFI types via core::ffi, not just in std 378463ba979 Add a copy of cfg_if to core's internal_macros.rs 605eacd919d Rollup merge of #94452 - workingjubilee:sync-simd-bitmasks, r=workingjubilee fcfb71c7ec4 Rollup merge of #94384 - cuviper:atomic-slice, r=dtolnay f195f720fbb Rollup merge of #94094 - chrisnc:tcp-nodelay-windows-bool, r=dtolnay 2772a287d29 Rollup merge of #92399 - Veeupup:fix_vec_typo, r=Dylan-DPC 30dd0abfb44 Sync rust-lang/portable-simd@5f49d4c8435a25d804b2f375e949cb25479f5be9 7e3193c3ac7 Rollup merge of #89793 - ibraheemdev:from_ptr_range, r=m-ou-se ec49ec4c9dc add `slice::{from_ptr_range, from_mut_ptr_range}` 3b4ce7848b2 Auto merge of #94412 - scottmcm:cfg-out-miri-from-swap, r=oli-obk aaef7a01c36 Stabilize unix_socket_creation f06b6f25717 For MIRI, cfg out the swap logic from 94212 bc5feb4d2bf Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum 71d4ca383a9 Auto merge of #94385 - matthiaskrgr:rollup-4pwegqk, r=matthiaskrgr 699bbb5b673 Rollup merge of #94363 - aDotInTheVoid:fmt-needless-borrows, r=scottmcm 7a2132b36a0 Auto merge of #94342 - ibraheemdev:swap-regression, r=Dylan-DPC 7b4743c63fe Add Atomic*::from_mut_slice 12dc413e663 Make TLS __getit #[inline(always)] on non-Windows 1d4413c480d Add #[inline] to trivial AsRef impls e257671398f Auto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini d7cc07e9578 Remove needless borrows from core::fmt f5a9f1bf54b Re-add track_caller to panic_no_unwind in bootstrap 0063f33cf0d Switch bootstrap cfgs d39bdaaa677 Rename unix::net::SocketAddr::from_path to from_pathname c172355d9e6 Fix SGX docs build f3513b302b7 Rollup merge of #94184 - ssomers:btree_tests, r=Dylan-DPC f71220a266b Rollup merge of #92714 - yanganto:ignore-message, r=Mark-Simulacrum 81eacd37abc revert implementation of `slice::swap` 16167a7eb69 Include ignore message in libtest output 649eefb80f8 Rollup merge of #94212 - scottmcm:swapper, r=dtolnay 83b852d9fc6 Rollup merge of #94300 - WaffleLapkin:patch-4, r=scottmcm 4a934b72df2 Rollup merge of #94283 - hellow554:stable_flow_control, r=Dylan-DPC 3a0fa8804f4 Rollup merge of #94273 - Dylan-DPC:doc/errorkind, r=joshtriplett 32996a0c8bd word wrpa 63b8f00f476 word wrpa 5f53b19929c Update library/std/src/io/error.rs 3df4869b4b3 Fix a typo in documentation of `array::IntoIter::new_unchecked` 2974676f2cb fs: Don't dereference a pointer to a too-small allocation 43172a38606 Rollup merge of #94264 - NyantasticUwU:patch-1, r=yaahc 76990e403e3 Rollup merge of #94240 - compiler-errors:pathbuf-display, r=lcnr f616cb07c16 Rollup merge of #94128 - mqy:master, r=Dylan-DPC 71920c18c24 remove feature gate in control_flow examples 55a92afcf70 add some more summary from pr discussion 22d44b21aa1 add some more summary from pr discussion 9d82c61942c add matching to errorkind f10999a5259 Auto merge of #83706 - a1phyr:fix_vec_layout_calculation, r=JohnTitor 2a7f153b42d Stabilize Termination and ExitCode 32abd34b90c Fix typo. feb2582ef1f Rollup merge of #94179 - devnexen:getexecname_directcall, r=kennytm 321b85c3b13 Constify slice indexing dd95fbe28b9 Suggest calling .display() on PathBuf too c7500ddb8fc Rollup merge of #94220 - GuillaumeGomez:miniz-oxide-decl, r=Amanieu d74e05ea622 Rollup merge of #94186 - ehuss:pin-stable-1.61, r=m-ou-se fe9f1ba622e Rollup merge of #91192 - r00ster91:futuredocs, r=GuillaumeGomez 173db082bd6 Correctly handle miniz_oxide extern crate declaration 68017702b67 Stop manually SIMDing in swap_nonoverlapping b3d96d4b17a use `BOOL` for `TCP_NODELAY` `setsockopt` value on Windows a59e26922bd Remove assertion on output length for `getsockopt`. a2cd73bf389 Fix `setsockopt` and `getsockopt` parameter names. 4f1a269fc06 Update pin_static_ref stabilization version. ff574d6f446 BTree: simplify test code 6c64309ea46 improve wording of Waker::wake documentation 0a421894ac7 solarish current_exe using libc call directly 596b2198e36 Auto merge of #94174 - matthiaskrgr:rollup-snyrlhy, r=matthiaskrgr 6ed655a9b1b Add collect_into fd5b7146033 Rollup merge of #94122 - GuillaumeGomez:miniz-oxide-std, r=notriddle 49329230216 Rollup merge of #94112 - digama0:patch-3, r=scottmcm 80d97a7f773 Rollup merge of #94019 - hermitcore:target, r=Mark-Simulacrum 4bc2d5a2f13 Rollup merge of #93686 - dbrgn:trim-on-byte-slices, r=joshtriplett 462f979836c Rollup merge of #93580 - m-ou-se:stabilize-pin-static-ref, r=scottmcm 78fe41b69f6 Auto merge of #92911 - nbdd0121:unwind, r=Amanieu 9360b446c0a Fix some confusing wording and improve slice-search-related docs 23454bdb23c Some improvements to the async docs d21661ba688 Auto merge of #94148 - matthiaskrgr:rollup-jgea68f, r=matthiaskrgr c40bab78def Rollup merge of #93979 - SUPERCILEX:debug_check, r=dtolnay b14c3fd6c11 Rollup merge of #93658 - cchiw:issue-77443-fix, r=joshtriplett aca062b6302 Rollup merge of #92902 - ssomers:docter_drain, r=yaahc 3ef968ed2a2 Auto merge of #94105 - 5225225:destabilise-entry-insert, r=Mark-Simulacrum 38190137f99 Collections: improve the documentation of drain members 907c527c95e Rollup merge of #93847 - solid-rs:fix-kmc-solid-fs-ts, r=yaahc 2add5f6b66f rustdoc: several minor fixes f53b3340c9b Fix miniz_oxide types showing up in std aa14c415d04 Rollup merge of #93613 - crlf0710:rename_to_async_iter, r=yaahc 73df7ad2556 fix c7f0d04dd7e Optimize char_try_from_u32 aefd6aa0fd9 Auto merge of #94095 - Amanieu:update_stdarch, r=dtolnay f25bf49b129 Destabilise entry_insert de1924bba22 Rollup merge of #94041 - a-lafrance:try-collect, r=scottmcm 3d132caed15 Rollup merge of #93976 - SUPERCILEX:separator_str, r=yaahc 4e472785aaa core: Implement trim functions on byte slices 5eb88bb7b9d Fix documentation for is_X_feature_detected! 6d62c597dce Keep the path after `program_exists` succeeds 3ef901254b1 Use verbatim paths for `process::Command` if necessary 93b835849e0 Rollup merge of #93479 - smoelius:master, r=yaahc 0783b1cfeda Rollup merge of #89869 - kpreid:from-doc, r=yaahc 92999ac2313 Add MAIN_SEPARATOR_STR 0dffd1f22ae Add debug asserts to validate NUL terminator in c strings 5c16f166186 Auto merge of #94040 - Mark-Simulacrum:destabilize-load-store, r=Amanieu efed97cd7f7 Add a `try_collect()` helper method to `Iterator` 371f0b0cce3 Auto merge of #91182 - ChrisDenton:command-broken-symlink, r=m-ou-se 333eebaf852 Rollup merge of #93962 - joboet:branchless_slice_ord, r=Mark-Simulacrum 7e49a61a6a7 Destabilize cfg(target_has_atomic_load_store = ...) 0e2f8c468ba Rollup merge of #93949 - glaubitz:m68k-unwind, r=Mark-Simulacrum c1958cb6721 Rollup merge of #93899 - ssomers:vecdeque_naming, r=m-ou-se fec8f7fd739 remove compiler warnings c87d65c141f removing architecture requirements for RustyHermit 65f0bf6747f Make [u8]::cmp implementation branchless 9e28fd22954 Add a comment to justify why the `pointer` field is `pub`. 20d75fc938a Replace `def_site`-&-privacy implementation with a stability-based one. 91a6da2d5e5 Improve documentation. 55a80a37098 Write {ui,} tests for `pin_macro` and `pin!` 5ccb4292bc8 Add a stack-`pin!`-ning macro to the `pin` module. 16f7a1ed8fc Maintain broken symlink behaviour for the Windows exe resolver 9466a4ce6b0 Describe VecDeque with more consistent names b3616064f1f document expectations for Waker::wake 7731db2fe29 Make default stdio lock() return 'static handles 0e6af151906 Auto merge of #91673 - ChrisDenton:path-absolute, r=Mark-Simulacrum 2993cb7283f allow const_mut_refs 95e6d3f9d52 stabilize const_ptr_offset feda0d1d855 Rollup merge of #93930 - name1e5s:chore/docs, r=Mark-Simulacrum 7faa82a15b2 Rollup merge of #93886 - clarfonthey:stable_ascii_escape, r=Mark-Simulacrum d2675ac8fd7 Rollup merge of #93851 - cyqsimon:option-examples, r=scottmcm 1cd2a587167 Rollup merge of #90532 - fee1-dead:improve-const-fn-err-msg, r=oli-obk 4f1036a6590 Rollup merge of #89926 - the8472:saturate-instant, r=Mark-Simulacrum 779c84a67be Guard against unwinding in cleanup code a17df34f1ac Auto merge of #93696 - Amanieu:compiler-builtins-0.1.68, r=Mark-Simulacrum 120292988eb Capitalize "Rust" 0359631f32a Add panic docs describing old, current and possible future behavior 6216a68a2d5 Add caveat about the monotonicity guarantee by linking to the later section d14829147a0 make Instant::{duration_since, elapsed, sub} saturating and remove workarounds bb2dc51dd27 library/unwind: Define unwinder_private_data_size for m68k eb8ff242fb7 library/panic_unwind: Define UNWIND_DATA_REG for m68k 72cdcbeb2cf Stabilise inherent_ascii_escape (FCP in #77174) b122efb771c Fix signature of u8::escape_ascii 555f0c61818 Auto merge of #93697 - the8472:fix-windows-path-hash, r=Mark-Simulacrum ef755e02c7c Fix typo 52a7b8610e2 Fix `shrink` and `capacity_from_bytes` 050e9e97e8f Fix a layout miscalculation in alloc::RawVec e3c112536c8 Improve error messages even more b970bfda21c Add note on Windows path behaviour e075649e93b add link to format_args! when being mentioned in doc 6a4327a2bbb `Option::and_then` basic example: show failure 368795f2090 `Result::and_then`: show type conversion e2b36df5fa1 `Result::and_then`: improve basic example a33a3ae9326 Auto merge of #93921 - matthiaskrgr:rollup-wn3jlxj, r=matthiaskrgr 0f1fb07046c Rollup merge of #93888 - sunfishcode:sunfishcode/impl-asfd-for-ref, r=joshtriplett 9999741af4a Rollup merge of #93635 - GuillaumeGomez:missing-platform-spec-info, r=Amanieu 7b534bd19be Rollup merge of #90955 - JohnTitor:os-error-123-as-invalid-input, r=m-ou-se fc9faf6c432 Auto merge of #90271 - adamgemmell:dev/feat-detect-stabilise, r=Amanieu a28a22fcef1 Add missing platform-specific information on current_dir and set_current_dir 49fdfdcc417 Implement `AsFd` for `&T` and `&mut T`. 6eede16fcd2 Add negative example for `Result::and_then` 27dd356b250 added space d0c18136367 add cfg_panic bootstrap 3ec49ac2d58 remove mention of cfg_panic from library tests 4dd23ff8fb4 replace feature expression (cfg_panic) in lib and remove expression from tests Rebase commit 7762f2e5df7 Update stdarch submodule 8ef80b09d73 Move `is_aarch64_feature_detected!` to `simd_aarch64` feature and stabilise f62a00e15ac Rename to `InvalidFilename` 0ed72103aae Fix description of FilenameInvalid a4a9927176e Map `ERROR_INVALID_NAME` to `FilenameInvalid` b9c0c53c180 Rename `FilenameTooLong` to `FilenameInvalid` 3387a1d33ff windows: Map `ERROR_INVALID_NAME` as `InvalidInput` 4d61d1cdc14 Rollup merge of #93843 - solid-rs:fix-kmc-solid-condvar, r=m-ou-se 707c795e610 Rollup merge of #93824 - Amanieu:stable_cfg_target_has_atomic, r=davidtwco 7bce81a6054 More practical examples for `Result::and_then` 265e0775ff4 Use 0-based idx for array content 8e99313d85b More practical examples for `Option::and_then` 6fefb2c3705 kmc-solid: Use the filesystem thread-safety wrapper e3805209692 kmc-solid: Wait queue should be sorted in the descending order of task priorities ffe4be871bf kmc-solid: Fix wait queue manipulation errors in the `Condvar` implementation 5876838fc15 Rollup merge of #93799 - wooorm:patch-1, r=dtolnay ea66082c0fb Bump compiler-builtins to 0.1.69 4c531de4fdc Stabilize cfg_target_has_atomic fd9f7dc196b Suggest collecting into `Vec<_>` when collecting into `[_]` 417271ae1fa Fix typo in `std::fmt` docs 91050f76978 Rollup merge of #93735 - m-ou-se:stabilize-int-abs-diff, r=joshtriplett c0c990635f1 Rollup merge of #93445 - yaahc:exitcode-constructor, r=dtolnay bf42f8dc363 Auto merge of #93778 - matthiaskrgr:rollup-yfngdao, r=matthiaskrgr a7e92301302 Rollup merge of #93206 - ChrisDenton:ntopenfile, r=nagisa 89ea2763a73 Fix `absolute` issues 86e52be8517 `std::path::absolute` a071dd7ac82 Auto merge of #93572 - scottmcm:generic-iter-process, r=yaahc d7bfa85e9a3 Rollup merge of #86497 - clarfonthey:nearest_char_boundary, r=scottmcm f7883408ed5 Allow comparing `Vec`s with different allocators using `==` db6ed74c80f Change `ResultShunt` to be generic over `Try` 4e8587730d4 fix exclusive range error f69073051a6 Auto merge of #87869 - thomcc:skinny-io-error, r=yaahc 620bf48b8a0 Add {floor,ceil}_char_boundary methods to str c2f9b5167e4 Auto merge of #93738 - m-ou-se:rollup-zjyd2et, r=m-ou-se 15cb10ddbae Rollup merge of #93416 - name1e5s:chore/remove_allow_fail, r=m-ou-se 2242cfe3ea0 Rollup merge of #93208 - kellerkindt:wrapping_int_assign_impl, r=m-ou-se dddd927e286 Rollup merge of #92724 - inteon:cleanup, r=Mark-Simulacrum 82ecf9e103c Auto merge of #93719 - scottmcm:core-as-2021-everywhere, r=Mark-Simulacrum 699919c95f2 Mark int_abs_diff as const stable. e18340b454e Stabilize int_abs_diff in 1.60.0. 9a465c6afc4 Stabilize wrapping_int_assign_impl in 1.60.0. c027ee18ff6 Auto merge of #93179 - Urgau:unreachable-2021, r=m-ou-se,oli-obk de09c55442f Build libcore as 2021 in a few more places 85a3518d945 Auto merge of #93695 - matthiaskrgr:rollup-zslgooo, r=matthiaskrgr 54f16a589f7 Add From for ExitCode c0649c1baff rewrite from_bytes_with_nul to match code style in from_vec_with_nul b694e5db6d0 Fix hashing for windows paths containing a CurDir component aaa6c40c214 Rollup merge of #93489 - Amanieu:panic_no_unwind, r=nagisa 4c12881e263 Rollup merge of #90998 - jhpratt:require-const-stability, r=oli-obk ca2dec1b1a0 Auto merge of #90414 - thomcc:count-chars-faster, r=nagisa 66ac66e4387 keyword_docs: document use of `in` with `pub` keyword aef8c9595f4 Mark __rgl_oom and __rd_oom as "C-unwind" aae89ce0dee Allow handle_alloc_error to unwind c0ca7110eaf Fix comment grammar for `do_count_chars` b5b0aab66e3 Respond to review feedback, and improve implementation somewhat 9bf99aba573 Ensure non-power-of-two sizes are tested in the Chars::count test 7e182341da0 Fix zh::SMALL string in core::str benchmarks 5a451b51059 Optimize `core::str::Chars::count` 7b1ae70314c Add more tests for io::Error packing, and fix some comments that weren't quite accurate anymore d97e9ca897e Update documentation somewhat ff828055920 Use wrapping pointer arithmetic in the bitpacked io::Error 1adc08540aa Elaborate some in the documentation and respond to some review comments 628939ef72b Update library/std/src/io/error/repr_bitpacked.rs 30de4d748aa Fix comment typos noticed by code review. b9cdcad0629 Address address comments, improve comments slightly eb52aba1ec7 Optimize io::error::Repr layout on 64 bit targets. 5d1d55992cf Hide Repr details from io::Error, and rework `io::Error::new_const`. a23092f33cc x.py fmt 3fe2548d644 Rename `BorrowedFd::borrow_raw_fd` to `BorrowedFd::borrow_raw`. f7f79795be4 Rollup merge of #93612 - tspiteri:master, r=m-ou-se fd1c2844127 Rollup merge of #93495 - solid-rs:fix-kmc-solid-rtc-month, r=yaahc 83b94cfebda Rollup merge of #91589 - derekdreery:arc_unwrap_or_clone, r=m-ou-se 4086aa6cf49 doc: use U+2212 for minus sign in integer MIN/MAX text a898b5fdf62 Rollup merge of #93585 - tamaroning:add_tests_for_92630, r=m-ou-se a4f94c93dd0 Rollup merge of #93555 - ChrisDenton:fs-try-exists-doc, r=Mark-Simulacrum 9d1a0d00cfe Stabilize pin_static_ref. 3be9a1b7cdd Add missing const stability attributes 3b747796cd9 Rollup merge of #93600 - last-partizan:fix-junit-formatter, r=yaahc 6d659090efd Move `{core,std}::stream::Stream` to `{core,std}::async_iter::AsyncIterator`. b7547e9126c Add tracking issue and impl for `Rc`. c09e57d8b8b impl `Arc::unwrap_or_clone` 09b0035da40 Auto merge of #93146 - workingjubilee:use-std-simd, r=Mark-Simulacrum 8fa3342442c Remove the documentation comment for `OwnedSocket::from_raw_socket`. dc504492800 Auto merge of #93101 - Mark-Simulacrum:library-backtrace, r=yaahc 27ea0bd4026 fix: Remove extra newlines from junit output aac4dfea52c Configure panic hook backtrace behavior 2a2136da6b4 add tests 7dadc22e7e5 Rollup merge of #93531 - TheColdVoid:patch-1, r=m-ou-se ed9c3c7e013 Rollup merge of #93493 - GKFX:char-docs-2, r=scottmcm 5c5cdc7a46d x.py fmt b9f8fa5ab73 Use `From`/`Into` rather than the traits they replaced. c05d8c7b664 Fix errors. 31b2ba0b381 Fix unresolved doc links. 08829ee918d Fix two copy+pastos. 1c004250c6f Add missing `pub` keywords. d990c6f2017 Update the documentation for `{As,Into,From}Raw{Fd,Handle,Socket}`. 551f4869d09 Fix annotation of code blocks 67ba7c3c57e Auto merge of #93442 - yaahc:Termination-abstraction, r=Mark-Simulacrum 501a99d2dff Link `try_exists` docs to `Path::exists` 42be35ba9fe Rollup merge of #93436 - dcsommer:master, r=Mark-Simulacrum 399febe95ab Rollup merge of #92584 - lcnr:query-stable-lint, r=estebank 595ff41a42a Rollup merge of #91828 - oxalica:feat/waker-getters, r=dtolnay 6fc819fd744 Auto merge of #86988 - thomcc:chunky-splitz-says-no-checking, r=the8472 2b1ecdf73f4 add a rustc::query_stability lint faa2ee3456d Rollup merge of #93504 - solid-rs:fix-kmc-solid-stack-size, r=nagisa ccfd5461f49 Rollup merge of #93090 - jyn514:errorkind-asstr, r=dtolnay 6fc76fd4e26 Fix incorrect panic message in example faba98be67a Improve test coverage of {Chunks,RChunks,RChunksMut}::{next,next_back} 3c453c9f34f (#93493) Add items from code review 50001585206 fix error handling for pthread_sigmask(3) 7af4d69e786 add inline attribute to new method 45d97792788 Take in account the unreachable! macro in the non_fmt_panic lint 4a5ca7fca83 Fix invalid special casing of the unreachable! macro b59689f9f1f Auto merge of #93498 - matthiaskrgr:rollup-k5shwrc, r=matthiaskrgr 6ee9affbddf kmc-solid: Increase the default stack size 4ca586f6886 Rollup merge of #93494 - solid-rs:fix-kmc-solid-spawned-task-priority, r=Mark-Simulacrum d56ba01fd2c Rollup merge of #93485 - est31:remove_curly, r=joshtriplett 54c3baa1daf Rollup merge of #93480 - est31:remove_unstable_deprecated, r=Mark-Simulacrum 95327577800 Rollup merge of #93471 - cuviper:direntry-file_type-stat, r=the8472 3e86979119a Rollup merge of #93462 - ChrisDenton:systime-doc, r=joshtriplett 0cedb264b41 Rollup merge of #93403 - nagisa:total-cmp-review, r=joshtriplett 6cb69a9597a Rollup merge of #93392 - GKFX:char-docs, r=scottmcm 404fdc0b516 Rollup merge of #93347 - WaffleLapkin:better_char_decode_utf16_size_hint, r=dtolnay bb69af94eb0 kmc-solid: `SOLID_RTC_TIME::tm_mon` is 1-based b54cb74b230 kmc-solid: Inherit the calling task's base priority in `Thread::new` ac974b2a1ee Auto merge of #90891 - nbdd0121:format, r=Mark-Simulacrum 7743d07deb1 (#93392) Update char::MAX docs and core::char::MAX d144342eb29 Document char validity d47bd9e45fa review the total_cmp documentation 1d0c6e34f69 Clarify safety of PanicInfo::can_unwind 983fb80d2a4 core: Remove some redundant {}s from the sorting code 1f1e7537880 Rollup merge of #92887 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum 1e9e8b08fd2 Use `optflag` for `--report-time` 2da4fd966ee Remove deprecated and unstable slice_partition_at_index functions 649ed316ad3 Fix an edge case in `chat::DecodeUtf16::size_hint` a7ae53df7bc unix: Use metadata for `DirEntry::file_type` fallback 1fe2fa42277 Add Result::{ok, err, and, or, unwrap_or} as const 7e005279552 Rollup merge of #93459 - tavianator:dirent-copy-only-reclen, r=cuviper e635b000bec Rollup merge of #93414 - Amanieu:std_arch_detect, r=m-ou-se 880f8989c36 Rollup merge of #93256 - EFanZh:patch-1, r=joshtriplett bddb79ac5f6 fs: Add a regression test for #93384 41d77c04062 fs: Don't copy d_name from struct dirent 420fdb9c603 Document `SystemTime` platform precision 32ceca5bdad Update compiler_builtins to fix duplicate symbols in `armv7-linux-androideabi` rlib a940b31d43a Create `core::fmt::ArgumentV1` with generics instead of fn pointer fd751320326 Rollup merge of #93410 - solid-rs:feat-kmc-solid-net-dup, r=dtolnay 374988ba725 Rollup merge of #93236 - woppopo:const_nonnull_new, r=oli-obk b63fa99030f Rollup merge of #92274 - woppopo:const_deallocate, r=oli-obk e4ba832af93 Document about some behaviors of `const_(de)allocate` and add some tests. 2316f6f3c32 Auto merge of #93351 - anp:fuchsia-remove-dir-all, r=tmandry ed54fe9facd Change Termination::report return type to ExitCode 40551ff434d Fix remove_dir_all on Fuchsia after CVE fix. 9d57354236f Rollup merge of #93404 - rust-lang:scottmcm-patch-1, r=wesleywiser fdb336d3baf Rollup merge of #93356 - pierwill:partialord-headline, r=dtolnay c728ac57685 Rollup merge of #93353 - kellerkindt:saturating_int_assign_impl, r=joshtriplett 856e3ecc27a Rollup merge of #93295 - ChrisDenton:tempdir-double-panic, r=dtolnay 5b78d6a2949 Rollup merge of #93239 - Thomasdezeeuw:socketaddr_creation, r=m-ou-se 720a398db0e Rollup merge of #93158 - haraldh:wasi_sock_accept, r=dtolnay d50492d95c2 Rollup merge of #92611 - Amanieu:asm-reference, r=m-ou-se f82a9e99f5b update cfg(bootstrap)s 584fa9d1363 Update tracking issue for unix_socket_creation 7b904dfb326 Update stdarch submodule 809e023744a wasi: enable TcpListener and TcpStream 50211141860 wasi: update to wasi 0.11.0 3375401a535 add allow_fail field in TestDesc to pass check d4962875394 remove allow_fail test flag 57f45f820a0 Move unstable is_{arch}_feature_detected! macros to std::arch 94845c4b601 Add a test case for using NonNull::new in const context 59cc1fb5738 Fix wrong assumption in `DecodeUtf16::size_hint` 15efb0dfe65 test_const_allocate_at_runtime c844c4e0ed3 Edit docs introduction for `std::cmp::PartialOrd` 4d6f3f0fb0b kmc-solid: Implement `FileDesc::duplicate` b8de84e92ae Fix a typo from #92899 806188e69aa Clarify documentation on char::MAX 6b8c33d22ab Rollup merge of #92899 - cameron1024:zip-docs, r=dtolnay 043e1b3d9ba Rollup merge of #91641 - dtolnay:cchar-if, r=Mark-Simulacrum bd76fc8e0bb Touch up PR 92899 Iterator::zip docs cbeb7128ec1 pub use std::simd::StdFloat; 1eea2274183 Sync rust-lang/portable-simd@03f6fbb21e6050da2a05b3ce8f480c020b384916 cbd19e1ac8b Use sockaddr_un in unix SocketAddr::from_path c4df3dc2de2 Make sockaddr_un safe and use copy_nonoverlapping 84c89bc84a1 mention std::iter::zip in Iterator::zip docs 441886f568c Add documentation about `BorrowedFd::to_owned`. fa9e4b42008 Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t> 9cca04f409d Rollup merge of #92778 - tavianator:linux-readdir-no-r, r=joshtriplett 9deb747486f Rollup merge of #92256 - fee1-dead:improve-selection-err, r=oli-obk 0d5c738c179 Rollup merge of #91861 - juniorbassani:use-from-array-in-collections-examples, r=yaahc 97810f727b3 libunwind: readd link attrs to _Unwind_Backtrace 9516d5f68e8 Add a test for `char::DecodeUtf16::size_hint` 125c6c2a71a Make char::DecodeUtf16::size_hist more precise 6ba14e517d2 Improve Duration::try_from_secs_f32/64 accuracy by directly processing exponent and mantissa d66d2302790 `const_deallocate`: Don't deallocate memory allocated in an another const. Does nothing at runtime. `const_allocate`: Returns a null pointer at runtime. 5f0b1469511 make Windows abort_internal Miri-compatible 21b3baa9e4a Add a minimal working `append_const_msg` argument b8b61145e28 Avoid double panics when using `TempDir` in tests d1a372c22c1 Implement `MIN`/`MAX` constants for non-zero integers 69b7be3b2c9 Impl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}Assign<$t> for Wrapping<$t> a833c0969e2 Rollup merge of #88794 - sunfishcode:sunfishcode/try-clone, r=joshtriplett 5f7700b9cd2 Rename SocketAddr::unix to from_path a66181ae898 Rollup merge of #93152 - ivmarkov:master, r=m-ou-se 5ab93f8aa47 Rollup merge of #92513 - Xuanwo:path-buf, r=dtolnay 05af636a378 Use `NtCreateFile` instead of `NtOpenFile` to open a file 5872d3cc712 Make `join!` description more accurate f706ac7ad21 Rollup merge of #92555 - m-ou-se:scoped-threads, r=Amanieu feb0d70d796 Add os::unix::net::SocketAddr::unix e942010875f Make `NonNull::new` `const` 580b8e9642a Auto merge of #93220 - matthiaskrgr:rollup-9bkrlk0, r=matthiaskrgr a492e339e8d Add `intrinsics::const_deallocate` 16d7739f21a Rollup merge of #91122 - dtolnay:not, r=m-ou-se 9fa63490e91 Rollup merge of #90666 - bdbai:arc_new_cyclic, r=m-ou-se 33eb9415f35 Auto merge of #92998 - Amanieu:hashbrown12, r=Mark-Simulacrum b0b9ce5202d Add test for thread::Scope invariance. 8fb4f97fce2 Update stabilization version of arc_new_cyclic e0fa8b27ffd Add tracking issue number for scoped_threads. d403104a1cd Simplify Send/Sync of std::thread::Packet. ec4360ac2d1 Rollup merge of #92828 - Amanieu:unwind-abort, r=dtolnay 7e05fda3a08 Rollup merge of #85967 - atopia:update-l4re-target, r=petrochenkov 400dc689bc0 Disable test_try_reserve on Android 5d4ce26566d Rollup merge of #93134 - tlyu:delete-stdin-split, r=Amanieu 951a1077592 Rollup merge of #93109 - JakobDegen:arc-docs, r=m-ou-se 7e5147fb42e Rollup merge of #92586 - esp-rs:bugfix/allocation-alignment-espidf, r=yaahc 90dfef70e9b Update HashMap::try_reserve test to version from hashbrown 1ba528e22da Update hashbrown to 0.12.0 a90b2ee3119 adapt L4Bender implementation d050e9c77d8 Old versions of Android generate SIGSEGV from libc::abort df1d818400c fs: Use readdir() instead of readdir_r() on Android 8f5e60bd90c fs: Use readdir() instead of readdir_r() on Linux be24be5dcb7 fs: Implement more ReadDir methods in terms of name_cstr() 1af636318f1 Fix STD compilation for the ESP-IDF target 02186a0587b delete `Stdin::split` forwarder 1bf3f8a3998 Rollup merge of #93112 - pietroalbini:pa-cve-2022-21658-nightly, r=pietroalbini d5461f3e742 Rollup merge of #92992 - kornelski:backtraceopt, r=Mark-Simulacrum f69f6bdb2bc Rollup merge of #89747 - Amanieu:maybeuninit_bytes, r=m-ou-se dc464ba3657 Fix compilation for a few tier 2 targets 74a7b1c586c Remove unnecessary unsafe code in `Arc` deferred initialization examples. 57a876a04b4 Correct docs in `Arc` and `Rc`. 5046309ebd8 Update stabilization version of impl Not for ! 61e4716571f Auto merge of #92138 - AngelicosPhosphoros:try_smarter_vec_from_iter_48994_2, r=Mark-Simulacrum ac9af7e9885 Write for Cursor with a custom Allocator a9ef8509ade impl Write for Cursor<[u8; N]> bbd6a67ec85 Refactor tests of Write for Cursor<_> 7ca3470d42d Add MaybeUninit::as_bytes 725a7326bcf Add links to the reference and rust by example for asm! docs and lints d257e8ca392 `impl Display for io::ErrorKind` d428d529296 Rollup merge of #92630 - steffahn:lift_bounds_on_BuildHasherDefault, r=yaahc d057283178e Implement `IterMut::as_mut_slice` 326561ef6df Update std::fs::remove_dir_all documentation 5a5efc7b1ab Fix CVE-2022-21658 for WASI f5b2af8ca94 Fix CVE-2022-21658 for UNIX-like b98c1c4b49b Fix CVE-2022-21658 for Windows 68271c3dd30 Improve estimation of capacity in Vec::from_iter c553530837f Rollup merge of #93051 - m-ou-se:is-some-with, r=yaahc 6520225fd99 Rollup merge of #92124 - AngelicosPhosphoros:remove_extra_alloc_in_cstring_new_35838, r=Mark-Simulacrum 18b380692db Rollup merge of #89621 - digama0:patch-2, r=yaahc 7d98db17548 Fix is_some_with tests. 3e0d7d2cefe Improve is_err_with example. 7f8a03ddcb3 Add is_some_with tracking issue number. 8de5abdedcd Add Result::{is_ok_with, is_err_with}. 92815427840 Add Option::is_some_with. 3500d012feb Rollup merge of #93035 - Amanieu:stdarch_fix, r=Mark-Simulacrum c8ee0337b34 Rollup merge of #93026 - klensy:f-typo, r=scottmcm 346e7583ead Fix stdarch submodule pointing to commit outside tree bdcfb3b7ed5 Replace iterator-based construction of collections by `Into` 78fe6c8136a fix typo in `max` description for f32/f64 1930fd41fdd Rollup merge of #93016 - Amanieu:vec_spare_capacity, r=Mark-Simulacrum 543ee5831e7 Rollup merge of #92870 - llogiq:atomic_bool_sym, r=Manishearth a3985355318 Rollup merge of #92866 - maxwase:does_exist_typo, r=Mark-Simulacrum 40e8cdbc8fd Stabilize vec_spare_capacity 19df8c0f4df Rollup merge of #92960 - scottmcm:carrying-bignum, r=Mark-Simulacrum 1babeb2e2d2 Rollup merge of #92956 - scottmcm:nonzero-log2, r=dtolnay ff4ae3d2f1b Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu 77b2e24336c Rollup merge of #92981 - RalfJung:const_ptr_offset_from, r=dtolnay 4c31fb58628 Rollup merge of #92977 - kornelski:popdoc, r=dtolnay d3a79158a2a Rollup merge of #92953 - azdavis:azdavis-copy-example, r=dtolnay 08aecabd150 Help optimize out backtraces when disabled 9d529785a4c Change TerminatorKind::Abort to call the panic handler instead of aborting immediately. e0a4e562c61 Add PanicInfo::can_unwind which indicates whether a panic handler is allowed to trigger unwinding. b3ecc05ba99 fix const_ptr_offset_from tracking issue b3b8bce97c5 Docs: recommend VecDeque instead of Vec::remove(0) 98b232aa6fc Rollup merge of #92706 - umanwizard:btree, r=dtolnay da175e7b692 Rollup merge of #92619 - Alexendoo:macro-diagnostic-items, r=matthewjasper 09761c83c33 Auto merge of #92356 - kellerkindt:saturating_int_assign_impl, r=dtolnay 81d35f77ab9 Touch up stray comment in PR 92953 5b4b2329550 Clear up discriminants with more examples d4a7b04fd7c Use `carrying_{mul|add}` in `num::bignum` 7dff0c038bd Tweak btree iterator wording to not use 'yield' 0cb09f21246 Auto merge of #92598 - Badel2:panic-update-hook, r=yaahc ad331d34279 Add `log2` and `log10` to `NonZeroU*` f594a2283e2 Copy an example to PartialOrd as well 598715c1e7b stabilize windows_process_extensions_raw_arg 9f7bb94ea70 Rollup merge of #92879 - compiler-errors:into_iter_unsound, r=dtolnay 4991972f31a Rollup merge of #92863 - camelid:read_to_string-rm-mut, r=m-ou-se 93b2dfd17c5 Rollup merge of #92775 - xfix:osstringext-inline, r=m-ou-se 77761fc1f7c Rollup merge of #92747 - swenson:bignum-bit-length-optimization, r=scottmcm 41c49244bc5 Rollup merge of #92684 - ibraheemdev:patch-10, r=m-ou-se 2675b1e9919 Rollup merge of #92382 - clarfonthey:const_convert, r=scottmcm 5c5846cd272 Rollup merge of #92768 - ojeda:stabilize-maybe_uninit_extra, r=Mark-Simulacrum 221b392e4eb Add Sync bound to allocator parameter in vec::IntoIter 0e1c6ef7326 Add rustc_diagnostic_item attribute to AtomicBool 1647edc1ccf Typos fix be644b32ced Set the allocation MIN_ALIGN for espidf to 4. 4f01651fff5 fix stability attribute for `tcp::IntoIncoming` 188e2f0c667 Remove `&mut` from `io::read_to_string` signature 98c9d8362c7 Rollup merge of #91938 - yaahc:error-reporter, r=m-ou-se bfdbafcc9b0 Auto merge of #92553 - m-ou-se:thread-join-simplify, r=Mark-Simulacrum f1355e5457b Use the correct `cvt` for converting socket errors on Windows. d817a9f284b Remove deprecated LLVM-style inline assembly 645267eff4d Rollup merge of #92748 - david-perez:eliminate-boxed-wording-std-error, r=Mark-Simulacrum 9de4dd234d0 Rollup merge of #92720 - rosik:patch-1, r=m-ou-se f2fda35e9b9 Rollup merge of #92709 - joshtriplett:file-options-docs, r=Mark-Simulacrum 127d1376674 Rollup merge of #92328 - camelid:sentence, r=scottmcm 7bbb6b72f09 Address review comments 40b8ba94e31 Inline std::os::unix::ffi::OsStringExt methods cbd99f4e31e Partially stabilize `maybe_uninit_extra` 02899cef17d Auto merge of #92070 - rukai:replace_vec_into_iter_with_array_into_iter, r=Mark-Simulacrum 1d99b0c4e18 Simplify BigNum::bit_length() with log2() 3026e9ece5b Improve documentation for File::options to give a more likely example 99a40c62e81 Eliminate "boxed" wording in `std::error::Error` documentation a36efab5610 Simplification of BigNum::bit_length 9cdf4bd1440 Auto merge of #92719 - matthiaskrgr:rollup-tc7oqys, r=matthiaskrgr 6a0e7c58d6f Fix doc formatting for time.rs 954194057db Rollup merge of #92602 - jsha:source-link-2, r=GuillaumeGomez 5a1c2c2083f Clarify explicitly that BTree{Map,Set} are ordered. 49d3dc0e46a Compute most of Public/Exported access level in rustc_resolve 091b9d4164d Rollup merge of #92671 - WaffleLapkin:atomic_from_mut_unique_ref, r=m-ou-se 408436a0d16 Rollup merge of #92657 - Kixunil:ptr_as_const_mut, r=m-ou-se 96c80e25814 export `tcp::IntoIncoming` 3118c3f76fb eplace usages of vec![].into_iter with [].into_iter cfb45a74ce9 Auto merge of #92068 - fee1-dead:libcore2021, r=m-ou-se 386fcce3bb0 Implemented const casts of raw pointers e7592ff4b31 Make source links look cleaner 2242bbfbe7d Make `Atomic*::from_mut` return `&mut Atomic*` 1c9a65c37db Rollup merge of #92632 - yoshuawuyts:stabilize-available-parallelism, r=joshtriplett 2f67fc28474 Rollup merge of #92600 - asquared31415:float-must-use, r=joshtriplett 26c06a5937b Rollup merge of #92568 - Mark-Simulacrum:non-exhaustive-variant-count, r=the8472 4708d628525 Add safety comments to panic::(set/take/update)_hook ceded63857d Change panic::update_hook to simplify usage 1efc0a507f8 silence tidy errors 5eb0a421cb6 Implement `TryFrom` for `u8` ec158f10606 Implement panic::update_hook 838c968fbdc Also change PhantomData parameter of iter::Empty, and future::Pending 4ff1a28937e Stabilize `#[feature(available_parallelism)]` a20d86f9a0c change PhantomData type for BuildHasherDefault a5d2abc5e8c Rollup merge of #92620 - steffahn:remove_unused_ExtendDefault_struct, r=Mark-Simulacrum 07d35c0330a remove unused ExtendDefault struct 66e2404e85b Add diagnostic items for macros 59f8b0a0827 Rollup merge of #92288 - yescallop:patch-1, r=m-ou-se ed6edd103e2 add some missing must use to float ops 4b0681a8b35 Auto merge of #92587 - matthiaskrgr:rollup-qnwa8qx, r=matthiaskrgr 0faeadeb1f3 Rollup merge of #92574 - luojia65:riscv-kernel-dev-rust, r=Amanieu a4bc655dd50 Rollup merge of #92483 - ksqsf:master, r=dtolnay 34d94283a2d Rollup merge of #92388 - SpriteOvO:master, r=Mark-Simulacrum 675cefc371c Rollup merge of #92092 - saethlin:fix-sort-guards-sb, r=danielhenrymantilla 54e45d293e2 Mention *scoped* thread in panic message. b2a08106c5d Note the invariance over 'env in Scope<'env>. 25948e11a12 Fix missing .load() in Scope's Debug impl. ed4ddb04324 Rename n_running_threads to num_running_threads. b52b4c1e38c Rollup merge of #92517 - ChrisDenton:explicit-path, r=dtolnay f1003485852 Rollup merge of #92322 - alper:add_debug_trait_documentation, r=dtolnay 58458388a89 Add is_riscv_feature_detected!; modify impl of hint::spin_loop 4a92822c369 Clarify that ordering is unspecified aa87385ab35 Add note about non_exhaustive to variant_count 75f801553ac Auto merge of #92560 - matthiaskrgr:rollup-jeli7ip, r=matthiaskrgr c7d81bb5524 Touch up Debug example from PR 92322 19389c8aa13 Rollup merge of #92530 - dtolnay:contains, r=yaahc f3b5e8f41e1 Rollup merge of #91587 - nrc:dispatchfromdyn-docs, r=yaahc fcb5c821b24 Update wording 11dfa015c96 Fix typo in Scope::spawn docs. e3c9d7368fd Fix typo in is_running() docs. 54efd22b3bd Fix typo in documentation. f68818ffb6a Use > rather than == for overflow check in scoped threads. b895d57bd82 Fix variance of thread::Scope. bbfc8fd1d59 Rollup merge of #92525 - zohnannor:patch-1, r=camelid a3baac3eb0e Rollup merge of #92456 - danielhenrymantilla:patch-1, r=petrochenkov d20342727c1 Rollup merge of #91884 - woppopo:const_box, r=oli-obk eadb0a9708e Rollup merge of #91754 - Patrick-Poitras:rm-4byte-minimum-stdio-windows, r=Mark-Simulacrum 18b99ab831b Formatting. 693efd0b5e8 Simplify panicking mechanism of thread::scope. 34a5c07e79e Add documentation for scoped threads. 46512fbf904 Add ScopedJoinHandle::is_running(). f781feee0ed Implement RFC 3151: Scoped threads. 3f7806fd248 Simpilfy thread::JoinInner. 61b27c9d3de Stabilize `result_cloned` and `result_copied` c65235b1e3b mirror mention of intent of From cf8ff472ca2 Make the documentation of builtin macro attributes accessible c18b6c76c2e Move `contains` method of Option and Result lower in docs 27fc7fe53b4 Make `Receiver::into_iter` into a clickable link fb1266918ce Fix a compile error when no_global_oom_handling d9c7cacd052 Add tracking issues (`const_box`, `const_alloc_error`) f192b74ab8c Rollup merge of #92444 - dtolnay:coremethods, r=joshtriplett 69027672610 Rollup merge of #92409 - bjorn3:libtest_cleanups, r=m-ou-se 22d38853b22 Explicitly pass `PATH` to the Windows exe resolver 63b582f30d6 std: Implement try_reserve and try_reserve_exact on PathBuf 45f0927eb8b Auto merge of #91961 - kornelski:track_split_caller, r=joshtriplett 216e5386530 Auto merge of #92482 - matthiaskrgr:rollup-uso1zi0, r=matthiaskrgr 6f1e47eee3e Rollup merge of #92463 - thomcc:thats-not-how-its-pronounced, r=joshtriplett 4e8b5478723 Rollup merge of #91593 - upsuper-forks:hashmap-set-methods-bound, r=dtolnay f3e5f5a2d89 Rollup merge of #84083 - ltratt:threadid_doc_tweak, r=dtolnay 134e448ebc6 Auto merge of #92396 - xfix:remove-commandenv-apply, r=Mark-Simulacrum b9995a3d7dd Rollup merge of #92469 - joshtriplett:test-number-fix, r=Mark-Simulacrum df5dcedc353 Rollup merge of #92097 - saethlin:split-without-deref, r=the8472 7cc2b56dc85 Make tidy check for magic numbers that spell things e7b09300d4e Clarify safety comment e3c72060cf6 Rollup merge of #92338 - Xuanwo:try_reserve, r=dtolnay 5ac509c165b Remove pronunciation guide from Vec 58c4a3a2d20 Remove needless allocation from example code of OsString d13a3de755d Fix some copy/paste hysteresis in OsString try_reserve docs 992b970183e Consolidate impl Option<&mut T> 626f7a0d0a4 Consolidate impl Option<&T> 90f4472605b Move Option::as_deref_mut 7119b22b709 Move Option::as_deref c5683c0e4b3 Move Option::unwrap_or_default de09ba0bdd9 Consolidate impl Result<&mut T, E> 134ffa8f9a0 Consolidate impl Result<&T, E> ec7d1ffe952 Move Result::into_err 6f03f0c24b1 Move Result::into_ok c00b1797b22 Move Result::expect_err and Result::unwrap_err 925b9244811 Move Result::unwrap_or_default c36789332b9 Move Result::expect and Result::unwrap 9d3665c5bd3 Move Result::as_deref_mut e6be64c753e Move Result::as_deref 7476f351a4c use generic params for arc_new_cyclic 17a6d14130f Use `UnsafeCell::get_mut()` in `core::lazy::OnceCell::get_mut()` c85442467c9 Remove unused allow deprecated f7a6980b902 Remove unused feature gates from libtest 3638636bd08 Remove #![crate_name] attribute from libtest 8b8611abd7e Replace TDynBenchFn with Fn(&mut Bencher) c465d449b48 fix typo in btree/vec doc: Self -> self cf2993530b9 Remove CommandEnv::apply 17fb8cf298c Address comments fcd14b3453f Auto merge of #92291 - AngelicosPhosphoros:typeid_inline_revert_92135, r=joshtriplett 597b93546da Update library/std/src/ffi/os_str.rs 790c28e036d Fix a minor mistake in `String::try_reserve_exact` examples 9ccaba3b0c7 Extend const_convert to rest of blanket core::convert impls 7d513cc1eac Add {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}{,Assign}<$t> to Saturating<$t> 9dcc68c14b2 Rollup merge of #92335 - ecstatic-morse:std-column-unicode, r=Manishearth 08918bcd021 Implement support in wtf8 9e4df09fc87 Fix windows build a311142c295 Add try_reserve for OsString 7c5acbdc2ae Document units for `std::column` dc5efdd7e0f Rollup merge of #92307 - hiroshi-maybe:fix-minor-typos, r=camelid 70c2389f375 Rollup merge of #92264 - Shadlock0133:patch-1, r=the8472 d364185c84e Tweak sentence in `transmute` docs ad7bb398869 Add another implementation example to Debug trait 11dc3b2921f Little improves in CString `new` when creating from slice 18fbf1008f1 fix typo: intialized -> initialized cf0be9dcab4 fix typo: the use f.pad -> then use f.pad 9a833139707 Reverts #92135 because perf regression a19453dcb03 Fix a pair of mistyped test cases in std::net::ip 825190656ff Remove `maybe_uninit_extra` feature from Vec docs 56bdac66510 Auto merge of #92135 - AngelicosPhosphoros:typeid_inline_74362, r=dtolnay a7a21bfa2d3 Auto merge of #92226 - woppopo:const_black_box, r=joshtriplett 89ef3cc1723 Auto merge of #92220 - nnethercote:RawVec-dont-recompute-capacity, r=joshtriplett 86906418c8d Rollup merge of #92121 - RalfJung:miri-core-test, r=kennytm ab729c5d6ad Rollup merge of #90625 - Milo123459:ref-unwind-safe, r=dtolnay bfe8cdbd10b Bless a few tests 49acf1e7a7e Constify `Box` methods b7409ff5796 Constify `core::intrinsics::black_box` f6b3dde0e2f Switch all libraries to the 2021 edition df90ddb5e2f Add const-stability to `panicking::panic_*` fns d7966683ad3 Auto merge of #92155 - m-ou-se:panic-fn, r=eddyb 6d02a62ceb1 Rollup merge of #92208 - ChrisDenton:win-bat-cmd, r=dtolnay 5654706d754 Rollup merge of #92139 - dtolnay:backtrace, r=m-ou-se 7d2532cd5f6 Rollup merge of #92117 - solid-rs:fix-kmc-solid-read-buf, r=yaahc 17c1cb95e18 Rollup merge of #88858 - spektom:to_lower_upper_rev, r=dtolnay b38fb30521c Update stability attribute for double ended case mapping iterators cd8693a32db Fix tests 68e298538cb RawVec: don't recompute capacity after allocating. edb51d44ed8 Use panic() instead of panic!() in some places in core. f56819ccc08 Rollup merge of #92129 - RalfJung:join-handle-docs, r=jyn514 19405255509 Rollup merge of #91823 - woppopo:const_ptr_as_ref, r=lcnr 0915b535993 Rollup merge of #90345 - passcod:entry-insert, r=dtolnay 58d8aa8b6a9 kmc-solid: Add `std::sys::solid::fs::File::read_buf` b2acf5044b3 Bump insert_entry stabilization to Rust 1.59 a6a6b727e97 Change Backtrace::enabled atomic from SeqCst to Relaxed a5e797f081a Add `#[inline]` modifier to `TypeId::of` bda3048c679 impl RefUnwindSafe for Once fcab510a19e JoinHandle docs: add missing 'the' 353bc19b636 disable test with self-referential generator on Miri 349e4d17f4e Implement split_at_spare_mut directly da320013149 paniced -> panicked 8fafcd2e551 Rollup merge of #92071 - ajtribick:patch-1, r=the8472 a7139713cdf Rollup merge of #92028 - petrochenkov:psimd, r=Mark-Simulacrum 7dd6c62ea2a Rollup merge of #91141 - jhpratt:int_roundings, r=joshtriplett 1eb412acb78 Derive src pointers in sort drop guards from &T 84962351f39 Rollup merge of #92063 - OverOrion:patch-1, r=jyn514 60e4f7d26cf Rollup merge of #92020 - Folyd:stream-unpin, r=m-ou-se 14f17d8f691 Update example code for Vec::splice to change the length c3dc70861cb Rollup merge of #92050 - r00ster91:patch-5, r=camelid 41e5eee3df6 docs: fix typo 64e30b61fca Auto merge of #92062 - matthiaskrgr:rollup-en3p4sb, r=matthiaskrgr 84e2ce08eb1 Rollup merge of #92030 - rukai:stdlib2021, r=m-ou-se 9fe6ed7edcd Rollup merge of #92025 - devnexen:revert-91553-anc_data_dfbsd, r=kennytm fc6e3be7d2b Rollup merge of #91439 - ecstatic-morse:const-cmp-trait-default-methods, r=oli-obk fad429d282a Rollup merge of #91928 - fee1-dead:constification1, r=oli-obk 75408eb57d4 Add space and 2 grave accents 0586cf7bce5 Auto merge of #91838 - scottmcm:array-slice-eq-via-arrays-not-slices, r=dtolnay 50d5609cb3b Update stdlib to the 2021 edition eb4ef72c252 Point to the tracking issue 3d1de270dbf Constify (most) `Option` methods 124ce4daa0a Merge commit '533f0fc81ab9ba097779fcd27c8f9ea12261fef5' into psimd 88ebb3bd68a Disable test on bootstrap compiler 7d5230e992a Test const impl of `cmp` traits 7c6d8c986c2 Mark defaulted `PartialEq`/`PartialOrd` methods as const e744d0ce233 Remove P: Unpin bound on impl Stream for Pin aadc2a12e30 attempt to make Report usable with Box dyn Error and fn main 91cd6c09cc2 more docs improvements 9e442b551b9 Auto merge of #92003 - matthiaskrgr:rollup-obgv0rt, r=matthiaskrgr 070c8ab4051 add a panicking example a817738b1f1 Update report output and fix examples ea1db02a0a4 Revert "socket ancillary data implementation for dragonflybsd." e917834b1f1 Implement data and vtable getters for `RawWaker` 58cb32a7dec Quote bat script command line 300c6b3fb59 Rollup merge of #91947 - ibraheemdev:io-error-other, r=joshtriplett 889443392fe Rollup merge of #91796 - not-my-profile:fix-const_manually_drop-since, r=kennytm a5ed8640043 Fix SB problems in slice sorting 94293e54792 Auto merge of #91996 - matthiaskrgr:rollup-8pdt8x7, r=matthiaskrgr 413b71c3d75 Rollup merge of #91986 - ayrtonm:bump-builtins, r=Amanieu bcd78dd1128 Rollup merge of #91972 - RalfJung:pref-align-of, r=Mark-Simulacrum 126d54f1bb4 Rollup merge of #91951 - SparrowLii:master, r=Amanieu cec662fca35 Auto merge of #91527 - the8472:retain-opt, r=dtolnay 9b41c2d8644 Bump compiler-builtins to 0.1.66 19711a2aaf2 Modifications to buffer UTF-16 internally so that there is no longer a 4-byte buffer minimum. Include suggestions from @agausmann and @Mark-Simulacrum. c25a5d6a1c1 link to pref_align_of tracking issue 0a8aa43f4a3 Auto merge of #91962 - matthiaskrgr:rollup-2g082jw, r=matthiaskrgr 654dba08983 Rollup merge of #91918 - fee1-dead:constification0-the-great-constification-begins, r=oli-obk 805aa7cc6ab Rollup merge of #91916 - steffahn:fix-typos, r=dtolnay 076464aaec0 Auto merge of #91959 - matthiaskrgr:rollup-rhajuvw, r=matthiaskrgr d663d9c9842 Track caller of slice split and swap 683b62fbfb8 Rollup merge of #91906 - anuvratsingh:remove_in_band_lifetimes_library_proc_macro, r=petrochenkov 5555b0219ce Rollup merge of #91886 - euclio:option-doc, r=dtolnay 49fd791a88b Rollup merge of #91479 - scottmcm:slice-as-simd, r=workingjubilee a0589aa91c9 Rollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, r=jackh726,pnkfelix 21c899aa59c Auto merge of #91752 - yaahc:track-caller-result, r=cuviper d577a3d194e Stabilize `destructuring_assignment` 92210e738ca Auto merge of #91945 - matthiaskrgr:rollup-jszf9zp, r=matthiaskrgr 9fa3b81254c update stdarch 538858466f9 add `io::Error::other` constructor d467e39d82d Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm d58d9e5bbf5 Rollup merge of #91859 - xkr47:patch-2, r=yaahc 3642bcd82bd Rollup merge of #90939 - estebank:wg-af-polish, r=tmandry 5f5f9e13385 Auto merge of #91933 - matthiaskrgr:rollup-cw9qolb, r=matthiaskrgr 1b2c3f178e9 Update comments per review feedback a673ce61d72 Stabilize iter::zip. 50917551d18 Update std::error::Report based on feedback e2ee3c4a6d0 Auto merge of #91728 - Amanieu:stable_asm, r=joshtriplett e7eeef9308c Do array-slice equality via arrays, rather than always via slices f5ec76fe64c Rollup merge of #89825 - martinvonz:split-inclusive-empty, r=m-ou-se 371af2d3c6e Constify `bool::then{,_some}` bfbfd2de2ec Fix a bunch of typos 4a2bc3f95db Auto merge of #91902 - matthiaskrgr:rollup-hjjyhow, r=matthiaskrgr 6388dba3696 made compiler happy 8e5931c18b4 Rollup merge of #91851 - woppopo:const_maybeuninit_zeroed, r=yaahc 2d1b73fc4c0 Rollup merge of #91529 - TennyZhuang:try_reserve_binary_heap, r=yaahc 6d15928debe Auto merge of #91766 - scottmcm:more-array-raw-eq, r=yaahc bf68cc118a2 Auto merge of #91680 - saethlin:spare_capacity_mut-in-join, r=dtolnay 16637aae5cd core: minor `Option` doc correction 145848f7e62 Reduce verbosity for `?` on non-`Try` expressions fe1239adc56 Stabilize arc_new_cyclic d265cbd7346 [ReviewFix] Linguistics fa65d6f53b8 Iterator::cycle() — document empty iterator special case ee1f17d1a10 Stabilize const_cstr_unchecked cca2a8a6847 Make `MaybeUninit::zeroed` `const` 552c2713f58 Auto merge of #91841 - matthiaskrgr:rollup-zlhsg5a, r=matthiaskrgr ab2e08d44ab Rollup merge of #91824 - woppopo:const_ptr_write_bytes, r=oli-obk bebfbfccd06 Rollup merge of #91749 - ssomers:btree_comments, r=Mark-Simulacrum 41bef38a53b Rollup merge of #91091 - ecstatic-morse:control-flow-enum-is, r=m-ou-se 4ffae1e238b Rollup merge of #91086 - rhysd:issue-91085, r=m-ou-se 14b90b757d2 Auto merge of #91549 - fee1-dead:const_env, r=spastorino 08a09f813bc Address review feedback 614599c7400 Stabilize asm! and global_asm! 2a9aa728a6b Rollup merge of #91814 - japm48:spelling-fix, r=RalfJung c3ff753349a Rollup merge of #91746 - ssomers:btree_tests, r=Mark-Simulacrum 34caf5c7efb Make `(*mut T)::write_bytes` `const` 6d1b94e8285 Make `PTR::as_ref` and similar methods `const`. 8aa9a011536 Revert "Auto merge of #89450 - usbalbin:const_try_revert, r=oli-obk" fb2f6ff7ea4 doc: fix typo in comments 6b428f43a08 Rollup merge of #91806 - woppopo:const_unique, r=dtolnay 3d79389330e Rollup merge of #91797 - the8472:fix-invalid-deref, r=Mark-Simulacrum 819294375fa Rollup merge of #91737 - Manishearth:panic-immediate-stdlib, r=joshtriplett 0bfb99e2cbb Rollup merge of #90081 - woppopo:const_write_bytes, r=oli-obk 36057aed34d Make `Unique`s methods `const` 41524185afc Make some `Clone` impls `const` 27d42bd68f5 Auto merge of #91799 - matthiaskrgr:rollup-b38xx6i, r=matthiaskrgr 440afa88328 Rollup merge of #91721 - danielhenrymantilla:patch-1, r=joshtriplett 79d17fb5a63 Rollup merge of #91548 - luojia65:hint-spin-loop-riscv, r=Amanieu 4daa737887c Rollup merge of #90741 - mbartlett21:patch-4, r=dtolnay 1cd95ad7094 Rollup merge of #90270 - woppopo:const_borrow_trait, r=dtolnay 19c9ef58904 Fix zero-sized reference to deallocated memory d05b82354e5 Fix since attribute for const_manually_drop feature 989b8d683df Rollup merge of #91782 - maxwase:is_symlink_since_attribute, r=jyn514 01809a2890d Rollup merge of #91711 - andrewbanchich:improve-zip-example, r=Mark-Simulacrum 43a89887d6d update feature gate 2df45c00530 add BinaryHeap::try_reserve and BinaryHeap::try_reserve_exact 3ddf582c75a Correct since attribute for feature ad4c119e75e Remove unnecessary bounds for some Hash{Map,Set} methods 92b316faf0f Rollup merge of #91553 - devnexen:anc_data_dfbsd, r=yaahc e9d69fe85e2 Rollup merge of #91515 - jethrogb:rsplit_array, r=yaahc 5a9602bcbe8 Rollup merge of #91127 - scottmcm:ptr_to_from_bits, r=dtolnay 4a20a8ed400 Auto merge of #91761 - matthiaskrgr:rollup-bjowmvz, r=matthiaskrgr 25ee6f328b0 Allow `memcmp` for more array comparisons 1cd373dc70d Rollup merge of #91755 - not-my-profile:fix-const_linked_list_new-since, r=dtolnay 2e988c6779a Rollup merge of #91709 - juniorbassani:use-from-array-in-set-examples, r=jyn514 434b2187c5b Rollup merge of #91697 - dtolnay:lossyfromstr, r=Mark-Simulacrum efe21d61b76 Rollup merge of #91686 - dalcde:patch-1, r=dtolnay 867c3a0b59c Rollup merge of #91681 - WaffleLapkin:patch-3, r=scottmcm c1491462d0b Rollup merge of #91679 - ibraheemdev:stream-mod, r=Mark-Simulacrum 4b40c2ccf9e Rollup merge of #91646 - ibraheemdev:patch-9, r=dtolnay 740d9ec45ce Rollup merge of #91524 - rukai:fix_extend_from_slice_docs, r=dtolnay faf484cfb82 Rollup merge of #91482 - JosephTLyons:update-HashMap-and-BTreeMap-documentation, r=yaahc 643b858cffa Rollup merge of #91325 - RalfJung:const_eval_select, r=dtolnay 0cc10cee186 Rollup merge of #91105 - jplatte:stream-docs, r=dtolnay 18400360e1b Rollup merge of #90897 - jhpratt:fix-incorrect-feature-flags, r=dtolnay f77faa410e5 Add rsplit_array variants to slices and arrays d4c8218c149 Fix since attribute for const_linked_list_new feature 5a8d79ad3bb Readd track_caller to Result::from_residual 97021459d36 BTree: improve public descriptions and comments 6760d571ca7 BTree: assert presence of derived functions f1a44b54510 BTree: rename compile-time assertions to match library/alloc/tests 0c1179dc169 Update library/core/tests/future.rs 1fe0d152eae Add separate impl of unwrap_failed to avoid constructing trait objects f84045e1c99 inline Option panics on panic_immediate_abort c18497410df inline slice panics on panic_immediate_abort fb87b64586f Improve std::iter::zip example. 418793eb858 Add tests asserting the function-like semantics of `join!()` 16bed629ddb Fix missing `mut` typo 1947a021f4e Bring back the colon separators for the macro munching. b82e0a9b9b3 Fix two false positive lints ae07f1830a9 Minor improvements to `future::join!`'s implementation 1a088814827 Auto merge of #85157 - the8472:drain-drop-in-place, r=Mark-Simulacrum c217bf49948 Replace iterator-based set construction by *Set::From<[T; N]> 4fec8c4dc48 Update stdarch dependency ad19cf4f594 Auto merge of #81156 - DrMeepster:read_buf, r=joshtriplett 1a2146fa08a Auto merge of #91692 - matthiaskrgr:rollup-u7dvh0n, r=matthiaskrgr 0521fc44cec Delete Utf8Lossy::from_str 2fee74fe026 Rollup merge of #89999 - talagrand:GetTempPath2, r=m-ou-se e5976cb7ba3 Rollup merge of #87599 - Smittyvb:concat_bytes, r=Mark-Simulacrum b11e9252294 Rollup merge of #91645 - ibraheemdev:future-join, r=joshtriplett a7222a8e4fc Fix `Vec::reserve_exact` documentation a181b8e5e3a fix typo in `intrinsics::raw_eq` docs bace8720adf Use `*mut [T]` instead of `[MaybeUninit]` 6c850ce0583 Use spare_capacity_mut instead of invalid unchecked indexing 32d3f1eef1d move core/stream/stream/mod.rs to core/stream/stream.rs 1a49e7a8898 trim down expansion of `core::future::join` 140f7584999 remove implicit .await from `core::future::join` a09fcf3a6a9 Auto merge of #91656 - matthiaskrgr:rollup-lk96y6d, r=matthiaskrgr ef8af0128f6 Rollup merge of #91467 - ChrisDenton:confusing-os-string, r=Mark-Simulacrum 179f4879ee4 Auto merge of #91512 - scottmcm:array-intoiter-advance, r=Mark-Simulacrum a4e5a6076c9 Work around Clippy false positive on `as c_char` bd67506da29 correct typo a9495417495 fix documentation for `core::ready::Ready` 202c9227916 add tests for `core::future::join` 7f091d64c93 generate `MaybeDone` futures inline `join` f60bf084bc9 implement `core::future::join` 46d250ce1ec Auto merge of #91484 - workingjubilee:simd-remove-autosplats, r=Mark-Simulacrum 4ef4a83690a Define c_char using cfg_if rather than repeating 40-line cfg ace4de7d69b core::ops::unsize: improve docs for DispatchFromDyn 6ccc15c9955 Rollup merge of #91547 - TennyZhuang:suggest_try_reserve, r=scottmcm 0015a1f88d1 s/from_raw_parts/new_unchecked/ 03ce65b6406 Implement concat_bytes! 74335b3d57e Add tracking issue; make `empty` const too (unstably) d9f611da0f0 Move the doc test to edition2021 e2c88c85cbe Add `array::IntoIter::{empty, from_raw_parts}` 21257a25c62 Add tracking issue number 7d645408fb5 Auto merge of #91284 - t6:freebsd-riscv64, r=Amanieu aa2506a1698 socket ancillary data implementation for dragonflybsd. 4a2e16c348f Auto merge of #88611 - m-ou-se:array-into-iter-new-deprecate, r=joshtriplett d9f810530ec Add spin_loop hint for RISC-V architecture 06eb4f54c06 doc: suggest try_reserve in try_reserve_exact 66a47885eb6 Rollup merge of #91355 - alexcrichton:stabilize-thread-local-const, r=m-ou-se 7ae402a6e37 Rollup merge of #91215 - GuillaumeGomez:vec-deque-retain-mut, r=m-ou-se 5046e4ca3b4 Rollup merge of #89642 - devnexen:macos_getenv_chng, r=m-ou-se 2a964d52ac2 Update array::IntoIter::new deprecation version. 2f3c1336958 Update docs. da534974ece Use IntoIterator for array impl everywhere. d36aab040ed Swap body of array::IntoIter::new and IntoIterator::new. 58582e7dea6 Deprecate array::IntoIter::new. 6a1b022164f Update stabilization version of try_from_mut_slice_to_array 3ffe98f3ab9 Add documentation to more `From::from` implementations. 926b9123d1d Optimize vec::retain performance 208cb5e55b7 update vec::retain benchmarks 9fc3b8acc63 Fix Vec::extend_from_slice docs 4ae94fcdc19 Make `Borrow` and `BorrowMut` impls `const` 6e8046cba91 Rollup merge of #87054 - kit-981:master, r=scottmcm f0d15c89813 Override `Iterator::advance(_back)_by` for `array::IntoIter` 3ca94bf9234 Add a `try_reduce` method to the Iterator trait b718c0ef4b0 Rollup merge of #90851 - ibraheemdev:downcast-unchecked, r=scottmcm 56e36a87c6c fix stability annotations for `Box::downcast` 1e7f3babe2b Auto merge of #90737 - eholk:intofuture, r=tmandry 6fe45589393 Auto merge of #91286 - scottmcm:residual-trait, r=joshtriplett 12752d0b32b Auto merge of #91486 - matthiaskrgr:rollup-699fo18, r=matthiaskrgr e0a343b2f51 Rollup merge of #91474 - rtzoeller:dfly_set_errno, r=cuviper f86d07ea294 Rollup merge of #91453 - ChrisDenton:doc-win-tls-dtors, r=dtolnay b41bbfccda7 Rollup merge of #91381 - Amanieu:android_libdl, r=petrochenkov 2a3e2a74a82 Rollup merge of #90269 - woppopo:const_option_expect, r=yaahc b45ae0bffc0 Rollup merge of #88906 - Kixunil:box-maybe-uninit-write, r=dtolnay 440f5680f3e Make `HashMap`s mutable again fcc5c23fdd4 Auto merge of #91339 - cbarrete:vecdeque-remove-grow-check, r=Mark-Simulacrum 24b089439e9 Force splatting in SIMD test 07b2420e340 Merge commit 'a8385522ade6f67853edac730b5bf164ddb298fd' into simd-remove-autosplats 08b2aef3ae4 Add `[T]::as_simd(_mut)` 72c33e8e2df suppress warning about set_errno being unused on DragonFly 253a0adb116 Rollup merge of #91464 - ChrisDenton:doc-path-case-sensitivity, r=joshtriplett 1b8faff781b Rollup merge of #91460 - ChrisDenton:doc-last-os-error, r=joshtriplett a17e61d99f2 Rollup merge of #91444 - RalfJung:miri-tests, r=dtolnay f2702379d0a Emphasise that an OsStr[ing] is not necessarily a platform string dc491ae8d8f Document file path case sensitivity e018f193a1f Code review feedback b43a428b4ab Make array::{try_from_fn, try_map} and Iterator::try_find generic over Try e2263f36051 Document how `last_os_error` should be used 38a51ee34d0 Use `BTreeMap::from()` instead of using `BTreeMap::new()` with `BTreeMap::insert()` bf454985e77 Use `HashMap::from()` instead of using `HashMap::new()` with `HashMap::insert()` b765abfc4c6 Implement write() method for Box> 5686068ac2c Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbini 804e372ecff Document Windows TLS drop behaviour 9dd5b1c7364 disable tests in Miri that take too long 5f53e23c698 Rollup merge of #88502 - ibraheemdev:slice-take, r=dtolnay 8c22e332b48 Rollup merge of #91346 - ibraheemdev:result-inspect, r=dtolnay b3feba1a402 Rollup merge of #91340 - cr1901:no-atomic, r=Mark-Simulacrum 4e0e3231618 Apply cfg-bootstrap switch 940e0c5a5e0 Auto merge of #91352 - nnethercote:RawVec-reserve_for_push, r=dtolnay 101162e9d15 Rollup merge of #91383 - ScriptDevil:drop-while-doc-alias, r=joshtriplett 5bc50fed1e6 Rollup merge of #91323 - RalfJung:assert-type, r=oli-obk 7a4e77bd647 Add `drop_while` as doc alias to `Iterator::skip_while` 9ac3dc4b455 Android: -ldl must appear after -lgcc when linking 64e8dbd2572 Remove unnecessary check in VecDeque::grow b65d6a58417 Auto merge of #91244 - dtolnay:lossy, r=Mark-Simulacrum 0c088993c33 Introduce `RawVec::reserve_for_push`. bc02c8e2acd CTFE: support assert_zero_valid and assert_uninit_valid 590fa775a9c std: Stabilize the `thread_local_const_init` feature ec936af63cd Rollup merge of #91049 - dimo414:patch-1, r=kennytm 15b168e525e add `Option::inspect` and `Result::{inspect, inspect_err}` 8f9cbeb102f Bump compiler_builtins to 0.1.55 to bring in fixes for targets lacking atomic support. eed8e702df9 Auto merge of #90681 - workingjubilee:update-libc, r=JohnTitor d5118cceeb1 adjust some const_eval_select safety comments b45cb183a2b adjust const_eval_select documentation 41a8c755a34 Rollup merge of #90896 - jhpratt:stabilize_const_maybe_uninit, r=oli-obk 7c2923be566 Add test for const `MaybeUninit` b3957f8e675 Stabilize some `MaybeUninit` behavior as const 2774f589ef1 Auto merge of #91301 - scottmcm:stabilize-nonzero-ipot, r=nagisa 83a6d6a05fc Update libc to 0.2.108 f1997e5bf4b Auto merge of #91241 - dtolnay:firstchunk, r=oli-obk dfe73f68865 Stabilize nonzero_is_power_of_two 37faf5dc419 Auto merge of #91288 - matthiaskrgr:rollup-yp5h41r, r=matthiaskrgr d78dc060349 Auto merge of #89916 - the8472:advance_by-avoid-err-0, r=dtolnay fa9ef5f76e8 Rollup merge of #91266 - jam1garner:fmt-ptr-fix, r=dtolnay 447dec26caa Rollup merge of #91057 - the8472:clarify-parallelism-steady-state, r=dtolnay 9c7418f98be Rollup merge of #90995 - the8472:hash-portability, r=dtolnay 535961968ce Rollup merge of #83791 - the8472:relax-zip-side-effect-guarantee, r=dtolnay 273e1964dac Auto merge of #90846 - cuviper:weak, r=dtolnay bd8ca4063ca Add riscv64gc-unknown-freebsd 2687c52d32d Auto merge of #91269 - matthiaskrgr:rollup-jh8i8eh, r=matthiaskrgr cfa2c3e7937 Rollup merge of #91248 - alessandrod:compiler-builtins-bump-bpf, r=Mark-Simulacrum 697627909a7 Rollup merge of #91240 - dtolnay:utf8width, r=Mark-Simulacrum caa914d162c Auto merge of #91246 - nnethercote:faster-layout-array, r=dtolnay ff58a29ba6d Clarify safety comment on using i to index into self.source 2ab690cab2f Use non-generic inner function for pointer formatting 4a22c059673 Rollup merge of #91176 - hermitcore:spin, r=kennytm bd364153748 Bump compiler-builtins to 0.1.53 dd5f7114154 Add a unit test for zero-sized types in `RawVec`. dc1845b8412 Optimize `Layout::array`. 5b3624604c7 Use unchecked construction in `Layout::pad_to_align`. 49cc8207b63 Eliminate bunch of copies of error codepath from Utf8LossyChunksIter 0174f02043c Eliminate an unreachable codepath from String::from_utf8_lossy a6171ca7169 Saner formatting for UTF8_CHAR_WIDTH table d55f6d54e62 Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=estebank f86dac2e5c9 Implement VecDeque::retain_mut f38db727bae Rollup merge of #91151 - name1e5s:chore/process_test, r=m-ou-se 6c33c8d7ff9 Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid 7a36fb27fb1 Rollup merge of #89542 - jhpratt:stabilize-duration-const-fns, r=oli-obk 33c17b55fe4 Create rustdoc_internals feature gate cbf3c12b3c0 Improving the readability 02efe912f36 If the thread does not get the lock in the short term, yield the CPU 82a25839393 Make `intrinsics::write_bytes` const 5e6750680bc Apply suggestions from code review 813fd6a9352 Add generator lang-item 15cf6328076 Rollup merge of #91153 - birkenfeld:kernel_copy_fallback, r=the8472 7e652295e60 kernel_copy: avoid panic on unexpected OS error ce419a2b61c fix test in std::process on android ed2db4a872a Use `derive_default_enum` in the compiler 187e0946019 Reintroduce `into_future` in `.await` desugaring b3cc9a60d93 Revert "Temporarily rename int_roundings functions to avoid conflicts" b7a2808df82 Partially stabilize `duration_consts_2` 04602352f96 Auto merge of #91101 - birkenfeld:io_error_docs, r=Mark-Simulacrum 67ea79662e8 Intra-doc links apparently don't like pointers? a740d5edbdf Add `<*{const|mut} T>::{to|from}_bits` 704fc2f295f impl Not for ! cd27c2f0f05 Test not never e284229b6dd Auto merge of #90352 - camsteffen:for-loop-desugar, r=oli-obk bbd1e9ed5f5 libcore: assume the input of `next_code_point` and `next_code_point_reverse` is UTF-8-like 44e33627126 Simplify for loop desugar 6f85399f8a1 Fix method name reference in stream documentation c0e65a42577 Rollup merge of #91008 - Urgau:float-minimum-maximum, r=scottmcm e208a5f691a Mention std::io::Error::from(ErrorKind) in Error::new() docs 8f6ea3cedf3 Reborrow mut slice instead of converting it with `as_ref` 2028a5c078b fix doc links for `downcast_unchecked` 478db58a33e Apply documentation suggestions from @est31 1d2b07d15e9 Auto merge of #91093 - matthiaskrgr:rollup-kovzwx0, r=matthiaskrgr 67cf8889cf5 Rollup merge of #89741 - sdroege:arc-rc-from-inner-unsafe, r=Mark-Simulacrum 2c3fd4451ed Add a caveat to std::os::windows::fs::symlink_file 47d89163f25 Stabilize `ControlFlow::{is_break, is_continue}` 6c61108927e Auto merge of #87704 - ChrisDenton:win-resolve-exe, r=yaahc e54742662c9 Update version in `stable` attribute 4c06bc36f9e Implement `TryFrom<&'_ mut [T]>` for `[T; N]` 784de4eea25 Add similar note as LLVM does for minNum and maxNum functions 9cfb0e50419 Implement IEEE 754-2019 minimun and maximum functions for f32/f64 d9f72cee1fe Auto merge of #91052 - ehuss:update-stdarch, r=Amanieu 435ddad8f3d document why we're not directly passing drop_ptr to drop_in_place a097612df67 replace vec::Drain drop loops with drop_in_place 0272c81b09c Rollup merge of #91044 - r00ster91:x1b, r=joshtriplett a34aac2958d Rollup merge of #88361 - WaffleLapkin:patch-2, r=jyn514 d78bd212c32 Expand available_parallelism docs in anticipation of cgroup quotas 131fcd55430 Update stdarch 5b2a27c2bf4 Turn all 0x1b_u8 into '\x1b' or b'\x1b' 9d74a30eddd Remove unnecessary doc links f79bdeba46f Fix Iterator::advance_by contract inconsistency 6d17e9b4dbd Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-se 1674e3f51bc Rollup merge of #89258 - est31:const_char_convert, r=oli-obk d79120bfd26 Auto merge of #90774 - alexcrichton:tweak-const, r=m-ou-se 19d951c84b9 Auto merge of #91019 - JohnTitor:rollup-q95ra7r, r=JohnTitor 126c93e8b74 Rollup merge of #90607 - WaffleLapkin:const_str_from_utf8, r=oli-obk 4b82f6c1951 Rollup merge of #90480 - r00ster91:remove, r=kennytm cb9838389c2 Auto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplett 797c2c78cd4 Fill in tracking issues for `const_str_from_utf8` and `const_str_from_utf8_unchecked_mut` features 2f587180ad9 Document non-guarantees for Hash cb7ac46a556 Make slice->str conversion and related functions const 7618a40499e Rollup merge of #90772 - GuillaumeGomez:vec-retain-mut, r=joshtriplett e06ab8b36e5 Rollup merge of #90687 - jhpratt:const_panic, r=oli-obk 8d804b87ed0 Fill in tracking issue for feature `const_align_offset` 55e57b880b1 Mark `<*const _>::align_offset` and `<*mut _>::align_offset` as `const fn` 230ef72257a windows: Return the "Not Found" error when a path is empty 152ac286e33 Rollup merge of #90909 - RalfJung:miri-no-portable-simd, r=workingjubilee 17889be7f99 Rollup merge of #90848 - scottmcm:remove-signed-bigint-helpers, r=joshtriplett 36a0343cbd7 Rollup merge of #90835 - sunfishcode:sunfishcode/wasi-char-device, r=alexcrichton e5caaaea7dd Rollup merge of #90790 - tamaroning:fix-lib-std-test, r=Mark-Simulacrum 54df273be44 Rollup merge of #88601 - ibraheemdev:termination-result-infallible, r=yaahc a28c6cc0ee7 Rollup merge of #85766 - workingjubilee:file-options, r=yaahc 113b9085f72 Auto merge of #90821 - scottmcm:new-slice-reverse, r=Mark-Simulacrum 7eb17391e21 Stabilize format_args_capture 92f4fcceb96 Give examples of format args capture in the fmt module documentation 6ecd03cf008 Auto merge of #88282 - Neutron3529:patch-4, r=Mark-Simulacrum b1ee167de70 disable portable SIMD tests in Miri 1fe0f157a4e Auto merge of #90596 - the8472:path-hash-opt, r=Mark-Simulacrum 2536f366b7d Fix incorrect feature flags 9c5a89ead43 Auto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obk cbf9a0712f8 Auto merge of #90542 - the8472:privatize-the-means-of-rawvec-production, r=joshtriplett 8dd9e355c50 Auto merge of #87264 - mystor:expand_literal, r=petrochenkov c8c6957927b Auto merge of #90041 - jfrimmel:rt_copy_checks, r=Mark-Simulacrum 4005085ba8b add slice take methods a40dd2e3d7d add tracking issue for `downcast_unchecked` eab8d7c3b15 add unchecked downcast methods 5e417febc65 Auto merge of #89167 - workingjubilee:use-simd, r=MarkSimulacrum 43778e9fa17 Remove bigint_helper_methods for *signed* types ecaab465394 Test core::simd works 3dd6e04e258 Expose portable-simd as core::simd 0f6bfd63bc8 Add 'library/portable-simd/' from commit '1ce1c645cf27c4acdefe6ec8a11d1f0491954a99' bb29d61a64f Refactor weak symbols in std::sys::unix 5aa54da3493 proc_macro: Add an expand_expr method to TokenStream 829f731bdae Rollup merge of #90798 - edmorley:doc-unreachable-custom-message, r=dtolnay e4254832fb2 Rollup merge of #90704 - ijackson:exitstatus-comments, r=joshtriplett e2e7fa973d1 Rollup merge of #90644 - est31:const_swap, r=Mark-Simulacrum 332154c36e4 Rename WASI's `is_character_device` to `is_char_device`. 0e8b9362fca Add Vec::retain_mut d928930c0bf provide a `SpecExtend` trait for `Vec` The discussion is [here](https://internals.rust-lang.org/t/append-vec-to-binaryheap/15209/3) 2ed9b69e262 MIRI says `reverse` is UB, so replace it with an implementation that LLVM can vectorize efa2422b55a `Prefix` can be case-insensitive, delegate to its Hash impl instead of trying to hash the raw bytes d275591255d process::ExitStatus: Discuss `exit` vs `_exit` in a comment. 7fe5aa8f8b8 unix::ExitStatus: Add comment saying that it's a wait status 32c58c35074 unix::ExitStatusExt: Correct reference to _exit system call 522a8f06c7f Document `unreachable!()` custom panic message 5b3bfa07247 Auto merge of #88798 - sunfishcode:sunfishcode/windows-null-handles, r=joshtriplett 0a34a33d70f Auto merge of #90755 - scottmcm:spec-array-clone, r=jackh726 94e884d6d92 compare between Path instead of str c6181462da3 Auto merge of #90784 - matthiaskrgr:rollup-car8g12, r=matthiaskrgr 78d17ae5e1d Rollup merge of #89930 - cuviper:avoid-clone3, r=joshtriplett 77445cf4402 Moar #[inline] 497d7e7854e std: Tweak expansion of thread-local const 56e00e39ed2 Update stdarch/dlmalloc bc7be9ad96c Update dlmalloc for libstd 1154bf34321 Update stdarch/compiler_builtins 92f0fee5083 Update more rustc/libtest things for wasm64 21d0a618884 Review comments cbffd992832 Use `target_family = "wasm"` 42d39a001ac std: Get the standard library compiling for wasm64 05efc177af9 Fix collection entry API documentation. 3b66194820f Specialize array cloning for Copy types b67628ea1e3 Rollup merge of #90751 - ehuss:update-books, r=ehuss 23e98ba6659 Rollup merge of #90748 - cuviper:track-setgroups, r=dtolnay a899a09071b Rollup merge of #90690 - solid-rs:fix-kmc-solid-asm-const, r=Mark-Simulacrum b6c9366a2b1 Update books 987d50c9fa4 Add a real tracking issue for `CommandExt::groups` 09a9f25b60b Format d097b345bf7 Rename `Option::cloned` gate e462de0fbe8 Make `Option::cloned` const fn. c911e5f4836 Auto merge of #90734 - matthiaskrgr:rollup-e1euotp, r=matthiaskrgr a40bc382bdd remove redundant .iter() call since zip() takes an IntoIterator argument c1eaae4d087 add fast path on Path::eq for exact equality 60a83ff67bd optimize Hash for Path f99f8b8dd82 add benchmarks and tests for Hash and Eq impls on Path 02b02d838c1 Extend the const_swap feature c6ec260e162 Stabilize File::options() 546ea8e72f8 Rollup merge of #90723 - asquared31415:box_docs, r=jyn514 0561856b361 Auto merge of #86041 - bstrie:unmagic-array-copy, r=jackh726 1e84a597948 Rollup merge of #87530 - bstrie:commentsync, r=bstrie abb1a0b2ee8 document Box and box_free connection 85a48f41a69 Re-enable `copy[_nonoverlapping]()` runtime checks f023c150b99 Permit const assertions in stdlib 211f89792a6 Attempt to address perf regressions with #[inline] 0cf7bb082bf Update Copy/Clone documentation WRT arrays 7d4fadd4a3a impl Copy/Clone for arrays in std, not in compiler f3b5cd2c575 Add comments regarding superfluous `!Sync` impls eb3808bc814 Rollup merge of #90494 - Meziu:armv6k-3ds-target, r=sanxiyn 18390bb415f kmc-solid: Avoid the use of `asm_const` 7e2782e38e7 Auto merge of #89310 - joshtriplett:available-concurrency-affinity, r=m-ou-se ac063b3936f Auto merge of #90348 - Amanieu:asm_feature_gates, r=joshtriplett b74d3114f01 Add features gates for experimental asm features 2d21a36307d Stabilize `const_raw_ptr_deref` for `*const T` d33c41c5932 use matches!() macro in more places 3946b3794c7 Auto merge of #90297 - dtolnay:dotzero, r=petrochenkov 4d2d2110e7a Also note tool expectations of fork vs clone3 b1bd6413336 Update another comment on fork vs. clone3 295699f81cc Only use `clone3` when needed for pidfd 6ea28916c7b Reorder `widening_impl`s to make the doc clearer 640af1fcd5c Add UnwindSafe to Once b1ce8a92dda Auto merge of #90604 - mbartlett21:iterator-reexports, r=kennytm 1ea75ef09e1 Auto merge of #90577 - matthiaskrgr:clippy_perf_nov, r=petrochenkov 139c888ab90 Fix `str::SplitInclusive` stabilisation date ee44916034c Add feature to `alloc` so we can re-export. de7f7ba67d3 Re-export `core::slice::EscapeAscii` 35a77299641 Re-export `core::slice::SplitInclusive[Mut]` 10fe35cd43a Rollup merge of #90556 - scottmcm:carrying_comments, r=joshtriplett b4054887d28 clippy::perf fixes 405cf5952c8 Add more text and examples to `carrying_{add|mul}" 6c8d41e2663 Auto merge of #87467 - inquisitivecrystal:ref-unwind, r=dtolnay fc5c3ca9b6d Auto merge of #90392 - solid-rs:fix-solid-support, r=Mark-Simulacrum 9e6d2744867 Make RawVec private to alloc 5dfc66a82c6 formatting bd49d5d9b61 fix change clobbered by rebase b8f7d78aca8 implement review suggestions c30d4139c8a Update library/std/src/sys/unsupported/fs.rs 2185c276070 add read_buf for &File cc0439f0309 fix test failure from trying to assume_init too much 7d24523fbd1 add safety comments 5b42208d903 Don't reinitialize here 9fe1ad55bff more efficent File::read_buf impl for windows and unix 7bc9698bb42 consolidate 2 unsafe blocks into 1 626ad69576f read_buf 70496c1e2a3 Auto merge of #90421 - thomcc:friendship-ended-with-ssize_t-now-ptrdiff_t-is-my-best-friend, r=joshtriplett 9648100b24f Implement `RefUnwindSafe` for `Rc` c89feffcfe6 Auto merge of #90442 - ChrisDenton:win-tls-dtor, r=alexcrichton cbef164fe63 Updated backtrace submodule f9129da5e97 Auto merge of #90439 - m-ou-se:thread-is-running, r=Mark-Simulacrum d70e54721f4 mention `remove` in `swap_remove` 5cf9ee997ea Run destructors from existing tls callback 5406e04c9b5 Add tracking issue for thread_is_running. 8b1328aa2aa itron: Rename `itron::thread::{available_conccurrency -> available_parallelism}` cb8e0e68929 Bump libc dependency of std to 0.2.106 9a9d8556a69 Pull `self.v.len()` out in `RChunks::next` as suggested in review comments 709e7806665 Reference Chunks::next_back in more of the chunk iterators safety comments 28d34ce9006 Address some issues in chunk iterator safety comments 1c674ce64d5 Carefully remove bounds checks from some chunk iterators 19d42a0e316 Re-add `std::os::raw::c_ssize_t`, with more accurate documentation 622a9362c19 Windows: Resolve Command program without using the current directory 47173dfd13f Windows thread-local keyless drop b333f27d968 Auto merge of #86336 - camsteffen:char-array-pattern, r=joshtriplett 5e8d093fa6a Add test for JoinHandle::is_running. 175f7f7266f Add JoinHandle::is_running. c587e8241ae Rollup merge of #90431 - jkugelman:must-use-std-o-through-z, r=joshtriplett d0dad74db5f Rollup merge of #90430 - jkugelman:must-use-std-a-through-n, r=joshtriplett 1a6b8f2d497 Rollup merge of #89786 - jkugelman:must-use-len-and-is_empty, r=joshtriplett ac41428f41c Rollup merge of #89068 - bjorn3:restructure_rt2, r=joshtriplett 680204c417e Rollup merge of #90427 - jkugelman:must-use-alloc-leak, r=joshtriplett 75d16581dfa Rollup merge of #89951 - ojeda:stable-unwrap_unchecked, r=dtolnay 87f1e704c97 Rollup merge of #89897 - jkugelman:must-use-core, r=joshtriplett d7754a52fe7 Rollup merge of #89839 - jkugelman:must-use-mem-ptr-functions, r=joshtriplett 44fe551b45e Rollup merge of #89835 - jkugelman:must-use-expensive-computations, r=joshtriplett 050d5009259 Rollup merge of #89833 - jkugelman:must-use-rc-downgrade, r=joshtriplett 6034da0584d Rollup merge of #89677 - maxwase:is-symlink-stabilization, r=joshtriplett 3852d761cc2 Rollup merge of #89446 - chrismit3s:issue-88715-fix, r=joshtriplett cf8648248f5 Add #[must_use] to remaining std functions (A-N) 7b445fcdb7b Add #[must_use] to remaining std functions (O-Z) 2c847d7703c Add #[must_use] to alloc functions that would leak memory b8b658dfd24 Auto merge of #90306 - kornelski:slicecloneasset, r=joshtriplett c31531225e8 Make std::thread::available_concurrency support process-limited number of CPUs fff156ed152 Update libc to 0.2.106 to get definitions for CPU_* 9e5a4b94356 Add #[must_use] to len and is_empty 38727e19ef3 Add #[must_use] to mem/ptr functions d0c394a4898 Rollup merge of #90401 - mkroening:hermit-condvar, r=joshtriplett c083da54e6f Rollup merge of #89899 - jkugelman:must-use-alloc, r=joshtriplett 804725bed99 Rollup merge of #89789 - jkugelman:must-use-thread-builder, r=joshtriplett 4f8b4d05e29 Add #[must_use] to remaining core functions ee193a42313 Replace `std::os::raw::c_ssize_t` with `std::os::raw::c_ptrdiff_t` 409cf024589 Auto merge of #90205 - mati865:link-modifiers-in-rustc, r=petrochenkov 71354f6b8f3 Rollup merge of #90377 - WaffleLapkin:const_slice_from_raw_parts, r=oli-obk c64e864c2e1 Rollup merge of #90371 - Veykril:patch-2, r=jyn514 bb507e64a8f Rollup merge of #89876 - AlexApps99:const_ops, r=oli-obk baf1a354ff1 Use "rustc" for testing Command args 0467ae972b5 Auto merge of #89174 - ChrisDenton:automatic-verbatim-paths, r=dtolnay ea008aa0855 Auto merge of #90346 - ferrocene:pa-short-circuit, r=oli-obk 74f0eae4064 Apply changes proposed in the review 6fe7c455651 Use proper issue number for `feature(const_slice_from_raw_parts)` 85da97fb469 hermit: Implement Condvar::wait_timeout f13cd36012b Auto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnr 1b79e1e1fcd Rollup merge of #90336 - mbartlett21:patch-4, r=Mark-Simulacrum 6543ad90197 Revert "Add rustc lint, warning when iterating over hashmaps" eb056c1ef16 Make `core::slice::from_raw_parts[_mut]` const 723fd62505f Fix incorrect doc link 36fd0a7a3df Fix broken doctest 445a461248a Auto merge of #90347 - matthiaskrgr:rollup-rp2ms7j, r=matthiaskrgr 9e49182d191 Format doctest b9b814d958b Add `rust` annotation to doctest 645618f46b9 Attempt to fix tidy errors 85b297d6b92 Rollup merge of #90344 - xfix:tracking-issue-const_cstr_unchecked, r=Mark-Simulacrum 189f23d8f5e Rollup merge of #90239 - r00ster91:patch-1, r=fee1-dead 02e1df8f87c Remove big O notation 9e07477c761 Auto merge of #90273 - nbdd0121:const, r=fee1-dead cc240674e22 replace `&` with `&&` in {integer}::checked_rem 9392421c018 replace `&` with `&&` in {integer}::checked_div b2839261b99 replace `|` with `||` in string validation 4a83c617565 replace `|` with `||` in {unsigned_int}::borrowing_sub 24f1394d4f2 replace `|` with `||` in {unsigned_int}::carrying_add e5c0bd497aa Stabilise entry_insert ae47f04f2b5 Update doctests for renames 58f6e8e8600 Expose HashMap:VacantEntry:insert_entry 0a10a470f2a Rename HashMap:Entry:insert to :insert_entry 887c94050c3 Add tracking issue number to const_cstr_unchecked a349389e766 Rollup merge of #90154 - camelid:remove-getdefid, r=jyn514 feb0f20f113 Remove extra lines in examples for `Duration::try_from_secs_*` 7e9bf9f172b Clarify platform availability of GetTempPath2 634984d0880 Auto merge of #90314 - matthiaskrgr:rollup-ag1js8n, r=matthiaskrgr 957579b5503 Rollup merge of #90296 - CAD97:rip-lerp, r=Mark-Simulacrum 4da25f9a74c Auto merge of #90290 - nyanpasu64:fix-string-as-mut-vec, r=m-ou-se e7b6735b33c track_caller for slice length assertions f6e7fb45eed Auto merge of #90284 - tonyyzy:patch-1, r=JohnTitor 606a5a83544 Remove redundant Aligner 9cd414cbe3e Fix copy-paste error in String::as_mut_vec() docs aaf568e05ec Remove fNN::lerp - consensus unlikely 114e28195fa Append .0 to unsuffixed float if it would otherwise become int token 39a33953248 remove requirement of T: Debug from Weak 7d4f2343764 Rollup merge of #90196 - yanok:master, r=scottmcm 1236806a8ff Clean up special function const checks bca425414fa Make `Option::expect` const 787556a19ca Auto merge of #90265 - GuillaumeGomez:rollup-gx3ficp, r=GuillaumeGomez d71ba2174a2 Fixed missing double quote in the patch (slice.swap) bd7f6d2b6fb Changed slice.swap documentation for better readability 99fd223f0ab Auto merge of #90042 - pietroalbini:1.56-master, r=Mark-Simulacrum 4e8e99e3e36 Fix and extend ControlFlow `traverse_inorder` example d7db36df132 Rollup merge of #90162 - WaffleLapkin:const_array_slice_from_ref_mut, r=oli-obk 2639caa5d62 Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 95e5e0eac54 update cfg(bootstrap) cc9bad8af60 Add tests for `const_slice_from_ref` and `const_array_from_ref` 422ba8dcd11 Fix typo 7a3bfdc0421 Make sure `CreateDirectoryW` works for path lengths > 247 ad1908e4600 Fill tracking issue for `const_slice_from_ref` and `const_array_from_ref` 7b8f89cdb25 Repace use of `static_nobundle` with `native_link_modifiers` 829ce5cfa25 Add caveat about changing parallelism and function call overhead b1ae1bafd45 Update control_flow.rs d294532ae47 Rollup merge of #90166 - smmalis37:patch-1, r=joshtriplett 5b66372fa11 Rollup merge of #90117 - calebsander:fix/rsplit-clone, r=yaahc b88f86dca81 Rollup merge of #88300 - ijackson:exitstatusext-methods, r=yaahc 0989d2d7bfd Rollup merge of #83233 - jethrogb:split_array, r=yaahc 55941955dc8 docs: Escape brackets to satisfy the linkchecker f3814c0a020 Auto merge of #90007 - xfix:inline-cstr-from-str, r=kennytm 5c96f24341f Change `source` field to `error` bad184fe6c7 Have `pretty` and `show_backtrace` accept booleans 879054b16dc Apply suggestions from code review 94aa2df75b9 Try commiting again 7dea60f26ba Add comment documenting why we can't use a simpler solution 0e26b861d02 Mark {array,slice}::{from_ref,from_mut} as const fn 068dfa8ee1d Rollup merge of #89944 - mbartlett21:patch-2, r=Mark-Simulacrum d6717178b89 Rollup merge of #89665 - seanyoung:push-empty, r=m-ou-se 4f98e9174e6 Rollup merge of #88624 - kellerkindt:master, r=JohnTitor 6d74760ea25 Implement split_array and split_array_mut 29f35f4202e Make RSplit: Clone not require T: Clone 95b94ef63db Added docs to internal_macro const 808123c748d Added const versions of common numeric operations d6c1da9a7fb Stabilize feature saturating_div for rust 1.58 7d87b921974 Clarify undefined behaviour for binary heap, btree and hashset a2425a7f748 Rollup merge of #90099 - SkiFire13:fix-vec-swap-remove, r=dtolnay e86c81524f5 Rollup merge of #90077 - woppopo:const_nonzero_from, r=oli-obk ffb9b8e9fec Rollup merge of #90010 - rusticstuff:vecdeque_with_capacity_in_overflow, r=m-ou-se e9eb5bb9364 Rollup merge of #89292 - CleanCut:stabilize-cstring_from_vec_with_nul, r=JohnTitor 1ec96de7871 Rollup merge of #87440 - twetzel59:fix-barrier-no-op, r=yaahc b7ad5cedbd0 Rollup merge of #86984 - Smittyvb:ipv4-octal-zero, r=m-ou-se b391b874bc6 fix 'since' version number e8dc7936d3e stabilize CString::from_vec_with_nul[_unchecked] 0f142815ca0 Prevent invalid values from existing in Vec::swap_remove 0205a9aa62e Change `Duration::from_secs_*` underflow error 4369e5037ba Make `From` impls of NonZero integer const. I also changed the feature gate added to `From` impls of Atomic integer to `const_num_from_num` from `const_convert`. 06a5789ddc3 Stabilize `option_result_unwrap_unchecked` 285924648d2 Rollup merge of #90009 - woppopo:const_from_more, r=dtolnay 677f92deb0d Rollup merge of #88860 - nbdd0121:panic, r=m-ou-se c03d258809a Rollup merge of #88789 - the8472:rm-zip-bound, r=JohnTitor 53ba8687521 Rollup merge of #87769 - m-ou-se:alloc-features-cleanup, r=yaahc,dtolnay 9dc287163fb Rollup merge of #86479 - exphp-forks:float-debug-exponential, r=yaahc 75e8fe11082 Deduplicate panic_fmt ebc12ff3d6e Reenable feature(nll) in alloc. 8aefbb8dc4f Remove unused language #![feature]s from alloc. e253ecb6a22 Remove unused library #![feature]s from alloc. e6c4b9f38f7 Sort and categorize #![feature]s in alloc. 8524464e541 Update std::env::temp_dir to use GetTempPath2 on Windows when available. 5f7b318a5f7 Auto merge of #90037 - matthiaskrgr:rollup-cdfhxtn, r=matthiaskrgr aad667ed15e Rollup merge of #90034 - moxian:unzip-doc, r=cuviper e2e6e748ec3 Rollup merge of #89941 - hermitcore:kernel, r=joshtriplett 4c06719acac Auto merge of #89905 - matthiaskrgr:rev_89709_entirely, r=michaelwoerister 366f67facca Tiny tweak to Iterator::unzip() doc comment example. b7d2743b964 Avoid overflow in `VecDeque::with_capacity_in()`. c5a55f90fb3 Make more `From` impls `const` e8319c0a55e Inline CStr::from_ptr d387441777a Rollup merge of #89996 - winterqt:bump-backtrace, r=Mark-Simulacrum 4d06df3b002 bump backtrace e2bbe91cd8e Rollup merge of #89977 - woppopo:result_const_as_mut, r=oli-obk 8b06c35738b Rollup merge of #89945 - JohnTitor:we-now-specialize-clone-from-slice, r=the8472 ee0b5f9c5df Make Result::as_mut const 37d1bd1a36a Auto merge of #88652 - AGSaidi:linux-aarch64-should-be-actually-monotonic, r=yaahc 9f1005b07ea Rollup merge of #89953 - woppopo:option_const_as_mut, r=oli-obk 7f2e1644984 Rollup merge of #89507 - lopopolo:lopopolo/ordering-repr-i8, r=joshtriplett 8b9ef6ea5fb Add `#![cfg_attr(bootstrap, feature(const_panic))]` to `library/core/tests/lib.rs` 345474aa9ba Make Option::as_mut const 07a06befa61 Remove a mention to `copy_from_slice` from `clone_from_slice` doc eb7cd760557 remove compiler warnings 19bf9764875 Rollup merge of #89925 - gilescope:update-docs-atomic-usage, r=m-ou-se c9a80c0b088 Rollup merge of #89921 - joshuaseaton:zircon-process, r=tmandry 290ba9d9b21 Rollup merge of #89898 - Amanieu:remove_alloc_prelude, r=joshtriplett 0ded5a1fdec Rollup merge of #89509 - jhpratt:stabilize-const_unreachable_unchecked, r=oli-obk 408ace86060 Make char conversion functions unstably const e8924bc32f0 Auto merge of #85379 - mdaverde:uds-abstract, r=joshtriplett e08accf690b updating docs to reflect current situation d37caca22c1 Auto merge of #84096 - m-ou-se:windows-bcrypt-random, r=dtolnay 12a05465fbf [fuchsia] Update process info struct 8844ed427ce Auto merge of #89337 - mbrubeck:vec-leak, r=m-ou-se 6aacdc11bf1 Add #[must_use] to remaining alloc functions 24a24942274 Auto merge of #88717 - tabokie:vecdeque-fast-append, r=m-ou-se 18d71b6170e Use BCryptGenRandom instead of RtlGenRandom on Windows. a0df6503b9d Auto merge of #88540 - ibraheemdev:swap-unchecked, r=kennytm 4dc68f32871 Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov" 9532e7849a6 add a `rustc::query_stability` lint 7dd19ba0df5 Remove alloc::prelude e0a249c9f92 Rollup merge of #89878 - GuillaumeGomez:add-missing-cfg-hide, r=notriddle 90f7357cd69 Rollup merge of #89873 - askoufis:patch-1, r=Mark-Simulacrum b3fc91851f2 Rollup merge of #89433 - arlosi:stdin-fix, r=joshtriplett f7aa38dc4b8 don't duplicate slice `panic_bounds_check` d9906fec514 Auto merge of #89247 - fee1-dead:const-eval-select, r=oli-obk 2e42231f81d Fix missing remaining compiler specific cfg information eb969064370 Ensure that pushing empty path works as before a2b62dbdbb0 Fix const stability d2bf3fc3daf Avoid tupling at the callee 4d085e1ae42 Add missing word to `FromStr` trait docs 7651fe63e7c Rollup merge of #89670 - yoshuawuyts:available-parallelism-docs, r=joshtriplett 6c7b0785d78 Improve `std::thread::available_parallelism` docs 0a04830034b Rollup merge of #89817 - m-ou-se:int-log-10-inline, r=the8472 758763b4cff Rollup merge of #89814 - jkugelman:must-use-string-transforms-typo, r=joshtriplett 07e8c388463 Rollup merge of #89794 - jkugelman:must-use-to_value-conversions, r=joshtriplett c0548a74f1c Rollup merge of #89781 - Wilfred:patch-2, r=JohnTitor 29ff0468fd6 Add #[must_use] to expensive computations 0d7cdd958f4 Auto merge of #89774 - the8472:inline-mut-iter-next, r=m-ou-se d9cf7ae0125 Add #[must_use] to Rc::downgrade 5215e4cd600 Merge branch 'master' into is-symlink-stabilization 21b3889fed3 Make split_inclusive() on an empty slice yield an empty output 662e4851376 Update library/std/src/thread/mod.rs 51becf254b5 Add #[inline] to int log10 functions. f54cf3d3e9a Remove potentially unsound note on reconstructing a leaked Vec. f14c4670250 Fix uppercase/lowercase error 36becdb6f9f Rollup merge of #89799 - ast-ral:ready-method-spellck, r=joshtriplett 69e73400d77 Rollup merge of #89797 - jkugelman:must-use-is_condition-tests, r=joshtriplett e29ee3b4711 Rollup merge of #89796 - jkugelman:must-use-non-mutating-verb-methods, r=joshtriplett 4a24c777b6f Rollup merge of #89778 - jkugelman:must-use-as_type-conversions, r=joshtriplett 06a0b936d17 Mention Rust version in Vec::leak docs. 8bc59d41efa Auto merge of #89770 - jkugelman:must-use-from-and-into, r=joshtriplett 03545c794a3 Auto merge of #89769 - jkugelman:must-use-maybe-uninit-new, r=joshtriplett ce4450189eb Add const_eval_select intrinsic 0a669919e70 Update library/std/src/path.rs a1417b79beb fix minor spelling error in Poll::ready docs a291c2bcaea Auto merge of #88788 - falk-hueffner:speedup-int-log10-branchless, r=joshtriplett 0af01997108 Add #[must_use] to non-mutating verb methods 328f3135757 Add #[must_use] to is_condition tests 915509232c3 Add #[must_use] to to_value conversions 2b2eb900613 Add #[must_use] to From::from and Into::into 1b85a802232 Rollup merge of #89785 - nbdd0121:master, r=Mark-Simulacrum e063c5082a8 Rollup merge of #89651 - ibraheemdev:poll-ready, r=dtolnay 32220519616 use fold instead of try_fold now that .by_ref().next() has been inlined a66390968e2 Add #[must_use] to thread::Builder 782333763ea add slice::swap tests f7ea2bc5dbf improve slice::swap panic message e04dfa0fe39 use `swap_unchecked` in `slice::reverse` a644a6881dc enable `slice_swap_unchecked` feature in doc test 7fd4c92dffb add `slice::swap_unchecked` 85411794c1d Fix ICE 89775 3f526898a40 Add missing words in `Infallible` docs 0cbeb7c7e9a Add library tracking issue for poll_ready feature 5b602f27748 Update library/core/src/mem/maybe_uninit.rs e94c9186deb Add #[must_use] to as_type conversions f33e37af843 Auto merge of #83908 - Flying-Toast:master, r=davidtwco 51ed99fc5ce inline next() on &mut Iterator impl f0540f6c03c Auto merge of #89767 - GuillaumeGomez:rollup-sczixhk, r=GuillaumeGomez 58f70ad8918 Add #[must_use] to MaybeUninit::new 89adacd8104 Rollup merge of #89753 - jkugelman:must-use-from_value-conversions, r=joshtriplett 880c8352aaf Rollup merge of #89729 - jkugelman:must-use-core-std-constructors, r=joshtriplett 9b79dcc9f1e Rollup merge of #89726 - jkugelman:must-use-alloc-constructors, r=joshtriplett 2ffc25cb6d3 Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov f2d705139bc Add enum_intrinsics_non_enums lint b6585ec966f Auto merge of #89755 - jkugelman:must-use-conversions-that-move-self, r=joshtriplett db616c87e10 Add #[must_use] to conversions that move self 41dfd9d3d93 Add #[must_use] to from_value conversions c2ac8133763 Rollup merge of #89707 - clemenswasser:apply_clippy_suggestions, r=Mark-Simulacrum 2b02d43794a Mark `Arc::from_inner` / `Rc::from_inner` as unsafe 275ed1774ea integrate I/O safety changes 00fd79fe58e cross-platform doctests bdd847775eb moves use ptr within from_abstract_namespace fn 43b3f202bac Update tracking issue in stability refs 2541f24c23d rustfmt ce8b5c81cb9 Add abstract namespace support for Unix domain sockets 7ec48abda1c Rollup merge of #89735 - bjorn3:stabilize_proc_macro_is_available, r=petrochenkov 8e90493546c Rollup merge of #89720 - jkugelman:must-use-math-operations, r=joshtriplett 30d11db4976 Rollup merge of #89719 - jkugelman:must-use-char-escape-methods, r=joshtriplett 95340539e0c Rollup merge of #89718 - jkugelman:must-use-is_condition-tests, r=joshtriplett 942f8248bc7 Rollup merge of #89705 - nbdd0121:doc, r=GuillaumeGomez a8d08ad0374 Rollup merge of #89438 - pierwill:prefix-free-hash, r=Amanieu 0702013c706 Rollup merge of #88713 - falk-hueffner:int-log10-documentation-fixes, r=scottmcm a9ea87dcb7d Rollup merge of #88374 - joshlf:patch-2, r=JohnTitor 1d8f191da9b Merge branch 'rust-lang:master' into must-use-alloc-constructors 5d3d3c3e7fe Apply clippy suggestions d3aa27bb249 Auto merge of #89219 - nickkuk:str_split_once_get_unchecked, r=Mark-Simulacrum f7b9330d17e Stabilize proc_macro::is_available c3fb2c3a6f0 Update core primitives_docs.rs up to date with std 6d0f5b58463 Update library/std/src/primitive_docs.rs 272612f9e13 Makes docs for references a little less confusing 21303f5b21b Auto merge of #88952 - skrap:add-armv7-uclibc, r=nagisa 8ea4f93646f Add #[must_use] to core and std constructors 5957ebb786a Add #[must_use] to alloc constructors bf11273f824 Add #[must_use] to math and bit manipulation methods f942a8a1b26 Add #[must_use] to char escape methods 09384401595 Add #[must_use] to is_condition tests 8219135e406 Update library/core/src/hash/mod.rs 0a6574a542d Apply clippy suggestions 56b3b6be87f Cfg hide no_global_oom_handling and no_fp_fmt_parse b426a13779e Rollup merge of #89664 - timClicks:51430-document-boxed-conversions, r=m-ou-se d825f107929 Rollup merge of #89614 - cuviper:unicode-14, r=joshtriplett 8d862682b84 Rollup merge of #88436 - lf-:stabilize-command-access, r=yaahc 80a5cbf69e5 Rollup merge of #87528 - :stack_overflow_obsd, r=joshtriplett 3d34fc2672a Rollup merge of #75644 - c410-f3r:array, r=yaahc 8d943b4810e Rollup merge of #89694 - jkugelman:must-use-string-transforms, r=joshtriplett 025885a5544 Rollup merge of #89693 - jkugelman:must-use-stdin-stdout-stderr-locks, r=joshtriplett 2679ce351f3 Rollup merge of #89678 - marcelo-gonzalez:master, r=joshtriplett b519326a436 Rollup merge of #88707 - sylvestre:split_example, r=yaahc 9d9e6b2d267 Remove unnecessary hyphen 5e2e9d2e9f8 Simplify wording c8a67476f58 Update library/core/src/num/mod.rs 32a0294c108 Auto merge of #89582 - jkugelman:optimize-file-read-to-end, r=joshtriplett 2985af9ec38 Add #[must_use] to string/char transformation methods 1cca2718b43 Add #[must_use] to stdin/stdout/stderr locks 899a0484b5d Fix minor std::thread documentation typo b522e5e984c Stabilize `is_symlink()` for `Metadata` and `Path` b1b0727223e Cfg hide more conditions for alloc aa1024c2ccf Cfg hide more conditions for core 07911dc22c9 Let stack_overflow::imp::cleanup call drop_handler directly 12f1c0369fc Also cfg flag auxiliar function 8745df3f993 Add documentation to boxed conversions 2c83aa04e01 Rollup merge of #89622 - m-ou-se:debug-assert-2021, r=estebank fe2d894656f Rollup merge of #89082 - smoelius:master, r=kennytm 99910705165 Rollup merge of #88772 - orlp:result-map-or-else-docfix, r=yaahc e00d7262f79 Auto merge of #89638 - rust-lang:revert-88548-intersperse, r=Mark-Simulacrum 8d353522f4a revert stabilization of `core::task::ready!` 5e622d66809 Optimize File::read_to_end and read_to_string 9c29a42671e add `Poll::ready` 38d47c26aed environ on macos uses directly libc which has the correct signature. dd03ab9417d Revert "Stabilize `Iterator::intersperse()`" f388b0fdaf7 Rollup merge of #89596 - GuillaumeGomez:implicit-doc-cfg, r=jyn514 d480499884e Use correct edition for panic in [debug_]assert!() etc. 0055c6bcb9d doc: guarantee call order for sort_by_cached_key 6beed6e4107 Regenerate tables for Unicode 14.0.0 f6ba8774b19 Rollup merge of #89531 - devnexen:stack_overflow_bsd_libc_upd, r=dtolnay 09914efb7bb Rollup merge of #89324 - yoshuawuyts:hardware-parallelism, r=m-ou-se 1342976e0c4 Rollup merge of #89245 - DeveloperC286:iter_mut_fields_to_private, r=joshtriplett 12da8d405aa Rollup merge of #89050 - DeveloperC286:drain_fields_to_private, r=joshtriplett 89c5a55b482 Rollup merge of #88523 - kpreid:category, r=yaahc cc435b67894 Rollup merge of #87601 - a1phyr:feature_uint_add_signed, r=kennytm a7586fd2651 Clean up code a bit: 7af425f2351 Update libc to 0.2.103. ae1963a3c4d add platform support details file for armv7-unknown-linux-uclibc 73ca7d99af5 Add new target armv7-unknown-linux-uclibceabihf d913154f29a Rebase Result::map_or_else doc wording on top of #89400. e717ff5e9e8 Apply suggestions from code review 8e7df22e6f7 Apply suggestions from code review 35e8654e7ac Document the valid values for `HandleOrNull` and `HandleOrInvalid`. 87c9bfc6ddd Fix compilation on WASI, which doesn't yet support `dup`. 8688e5293d2 Rollup merge of #89502 - FabianWolff:issue-89493, r=joshtriplett 48752671322 Rollup merge of #89351 - tspiteri:wrapping_rem, r=dtolnay b7d5994f51e Rollup merge of #88828 - FabianWolff:issue-88585, r=dtolnay a14a4f3ec39 refactor: VecDeques IterMut fields to private 27228a2784b refactor: VecDeques Drain fields to private 5d08f4caa35 Suppress some cfg from being shown in the stdlib docs 188eeb00e8f for signed overflowing remainder, delay comparing lhs with MIN 2c89aab676b Use get_unchecked in str::[r]split_once 360b84c7a60 Rollup merge of #89462 - devnexen:haiku_thread_aff_build_fix, r=nagisa 7fb804be776 Rollup merge of #89244 - DeveloperC286:pair_slices_fields_to_private, r=joshtriplett 91119651ef5 Rollup merge of #88651 - AGSaidi:monotonize-inner-64b-aarch64, r=dtolnay 49a9acf5f7b Rollup merge of #87631 - :solarish_upd_fs, r=joshtriplett 691797c10df library std, libc dependency update c2eac8e8043 Rollup merge of #89413 - matthewjasper:spec-marker-fix, r=nikomatsakis 7aaef266274 Rollup merge of #89270 - seanyoung:join_fold, r=m-ou-se 18b4fa2bc19 Rollup merge of #88780 - orlp:int-abs-diff, r=m-ou-se 0329f7fd169 Rollup merge of #87993 - kornelski:try_reserve_stable, r=joshtriplett 021cbc21059 Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett d5294d2fd10 Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebank 63fcad298f5 Rollup merge of #89443 - cuviper:btree-hash-len, r=dtolnay a2409d7e902 Rollup merge of #89400 - Nitepone:nitepone/map-or-else-docfix, r=dtolnay a0e3c4fe4c2 Rollup merge of #88452 - xu-cheng:vecdeque-from-array, r=m-ou-se 9500547a38d Rollup merge of #87091 - the8472:more-advance-by-impls, r=joshtriplett e4caeb0b403 Optimize `saturating_add_signed` 716534c4b67 Auto merge of #88834 - the8472:char-count, r=joshtriplett 2cacbf2f0c0 Stabilize try_reserve 7bab73cfd76 Add doc aliases to `std::thread::available_parallelism` a09b49558bd Auto merge of #89512 - Manishearth:rollup-meh9x7r, r=Manishearth 1cdac092473 Stabilize `const_panic` 31560aeb47a Rollup merge of #89472 - nagisa:nagisa/wsa-cleanup, r=dtolnay 76a60e1ef72 Rollup merge of #89401 - owengage:master, r=joshtriplett 3dddce579dd Rollup merge of #89138 - newpavlov:patch-2, r=dtolnay fe1fa64ae8a Rollup merge of #88370 - Seppel3210:master, r=dtolnay 7ca3c9bbcc9 Rollup merge of #88353 - jhpratt:stabilize-array-as-ref, r=joshtriplett 682e1465de0 Rollup merge of #88305 - ijackson:exitstatus-debug, r=dtolnay 9800c52726e Rollup merge of #88286 - LeSeulArtichaut:unnecessary-unsafe-block-std, r=dtolnay e50977809ae Rollup merge of #87910 - iago-lito:mark_unsafe_nonzero_arithmetics_as_const, r=joshtriplett d4b64444639 Rollup merge of #87679 - ssomers:btree_comments, r=joshtriplett c2e9a38e41b Rollup merge of #86828 - lambinoo:67441-const-fn-copied-take-replace, r=joshtriplett 049343f6dc6 Rollup merge of #86434 - CDirkx:ipv6-benchmarking, r=joshtriplett 23d227f3d11 Stabilize `unreachable_unchecked` as `const fn` 6adb9bd423c Auto merge of #89165 - jkugelman:read-to-end-overallocation, r=joshtriplett 31ad91ec5bd Add `#[repr(i8)]` to `Ordering` f8762b29513 Use a test value that doesn't depend on the handling of even/odd rounding c0bad194f13 Fix Lower/UpperExp formatting for integers and precision zero 6d279624dce Revert suggested use of `unwrap_or` 0446fd15118 Apply suggestions de6c9e7cbed Automatically convert paths to verbatim 1deed555c58 Re-export io::stdio::cleanup instead of wrap it 7a7271dc24e Use rtabort! instead of rtprintpanic! + abort_internal 9b268b876b5 Update outdated comment a79f345af50 Auto merge of #88086 - ssomers:btree_clone_testing, r=dtolnay 11597208e4d Added tracking issue numbers for int_abs_diff. aa9b5cb8c7d Skip platforms without unwinding support aa38cb99dd6 Auto merge of #87870 - WaffleLapkin:pub_split_at_unchecked, r=dtolnay 26db47eb62d Auto merge of #89459 - tspiteri:idiv-overflow-bitand, r=kennytm b2e5b01f6bd Practice diagnostic message convention fd96ec3ef35 Auto merge of #88060 - TennyZhuang:optimize-vec-retain, r=dtolnay eba8ed6f292 Make diangostic item names consistent 840f4649e13 Run the #85441 regression test on MSVC only acf017e785f Only register `WSACleanup` if `WSAStartup` is actually ever called c9c69dd97ce haiku thread affinity build fix 71e7789755f Fix typo and change a word in ControlFlow docs 8c56b68b6d8 Use bitand when checking for signed integer division overflow 5ca3a7791b4 Auto merge of #89450 - usbalbin:const_try_revert, r=oli-obk 8d2878efa1f Revert "Auto merge of #86853 - usbalbin:const_try, r=oli-obk" 2a73f76f5ef Add paragraph to ControlFlow docs to menion it works with the ? operator (#88715) d71e46f4475 Include the length in BTree hashes c8312198fb9 Call `libc::sigaction()` only on Android 50e41f81f17 path.push() should work as expected on windows verbatim paths d4744f084f2 fix: edit description of "prefix-free" 74281292517 Clarify a sentence in the documentation of Vec (#84488) c8c673619e7 docs: `std::hash::Hash` should ensure prefix-free data 31c468514e7 Add methods to add/sub `uX` to/from `iX` 0cbda1500f9 Fix doc test 63b29322a5f Apply suggestion for `overflowing_add_signed` 4800929d56f Add functions to add unsigned and signed integers 86e3e80bec0 Fix ctrl-c causing reads of stdin to return empty on Windows. a4a65354efb Auto merge of #89403 - camsteffen:fmt-unsafe-private, r=Mark-Simulacrum 1ce5e5e3156 Rollup merge of #89306 - devnexen:haiku_ncpus, r=nagisa e9f17538404 Rollup merge of #89303 - guswynn:std_suspend, r=dtolnay d55ab18e1bd Fix standard library for min_specialization changes 31d0dc34d51 fix issues pointed out in review c67abc0c4b3 from review: code style 87272a7fe7e implement advance_(back_)_by on more iterators 6955d3cf15a Add private arg to fmt::UnsafeArg c3a068e882f Check `allow_unstable` before checking environment variables fca203d2761 Add truncate note to Vec::resize f407a54969f Improve wording of `map_or_else` docs 8d6793c7d95 Remove an unnecessary use of unwrap_unchecked a34d6509f6e Improve previous commit 778ebb337bf Use reference instead of raw pointer e992713e204 Add 'core::array::from_fn' and 'core::array::try_from_fn' a27b295e41b Auto merge of #86853 - usbalbin:const_try, r=oli-obk da4be5c500c Rollup merge of #89335 - mbrubeck:range-is-sorted, r=cuviper aa8f111ff39 Rollup merge of #89315 - et342:cstr_from_vec_unchecked_doc, r=yaahc 0fd217cdfb4 Rollup merge of #88412 - mdsn:slice-sort-safety, r=dtolnay d2049acc4ff Add tests 949749267bd Implement #85440 990ae15a895 Auto merge of #89011 - bjorn3:restructure_rt, r=dtolnay 8df50a5ffa8 Clean up unneeded explicit pointer cast 4c66b8be0ad ref/refmut 0f03140f2ce Additional docs about Vec::leak behavior 6653927ca46 Avoid allocations and copying in Vec::leak 2a3d42fcab1 Optimize is_sorted for Range and RangeInclusive efd702b7eb9 Rollup merge of #89235 - yaahc:junit-formatting, r=kennytm 1e63a2518cb Rename `std::thread::available_onccurrency` to `std::thread::available_parallelism` 0d904d66480 Auto merge of #86191 - kawadakk:release-add-solid-support, r=nagisa,estebank,m-ou-se, dc671aabf6f Add SOLID targets 9d617f373e3 Clarify that `CString::from_vec_unchecked` appends 0 byte. ec000da6624 Apply suggestions from code review 2975266868a thread: implements available_concurrency on haiku 9b1db28fea1 lock types 15188e5a657 Auto merge of #89145 - rusticstuff:bump_stdarch, r=kennytm b95c09ca92b Auto merge of #89144 - sexxi-goose:insig_stdlib, r=nikomatsakis df02aaf16de Rollup merge of #89216 - r00ster91:bigo, r=dtolnay 2deedf7f96b Rollup merge of #89010 - est31:intra_doc_links, r=m-ou-se 7bbd04a0e7e Rollup merge of #88973 - lu-zero:std_detect-env_override, r=Amanieu 5df67f13ba7 Auto merge of #88343 - steffahn:fix_code_spacing, r=jyn514 80cb927b7d0 Expose the std_detect env_override feature 86a24371406 Apply 16 commits (squashed) 2c457d718b1 refactor: VecDeques PairSlices fields to private 6868cc022d5 Auto merge of #89030 - nbdd0121:box2, r=jonas-schievink e6dd6a40e8e Use Rvalue::ShallowInitBox for box expression 68c07f55355 make junit output more consistent with default format 8ed4e9f3227 Rollup merge of #89210 - Takashiidobe:master, r=kennytm ad32ebcffd3 Auto merge of #88999 - Migi:master, r=oli-obk 60749bdffda unitalicize O(1) complexities ac2bb5621c7 Merge branch 'rust-lang:master' into master 3dc873f617f consistent big O notation 87dfe342b3d Rollup merge of #89184 - joshtriplett:master, r=estebank 7e923ef9de3 Rollup merge of #88612 - lovasoa:patch-1, r=m-ou-se b0a77ebe3af remove trailing whitespace e611c828d54 Add time complexities to linked_list.rs 13628ab0bf1 Auto merge of #88587 - bdbai:fix/uwpio, r=joshtriplett 510323ff2ed Auto merge of #89139 - camsteffen:write-perf, r=Mark-Simulacrum d7adcf6a8e0 Reason safety for unsafe blocks for uwp stdin b4bacc38bbf Temporarily rename int_roundings functions to avoid conflicts fa9374cfeaa Update library/std/src/sync/mpsc/shared.rs 686ac9fb793 Rollup merge of #89036 - nbdd0121:alloc, r=yaahc ebb1c2261ab PR fixup 010739ffe76 Fix read_to_end to not grow an exact size buffer f88849f51a7 Rollup merge of #89141 - mbartlett21:patch-2, r=kennytm 79e62bc0bb9 Rollup merge of #89114 - dequbed:c-char, r=yaahc 246615bb704 Rollup merge of #89086 - WaffleLapkin:stabilize_iter_map_while, r=kennytm cf2ac75e3ca Rollup merge of #89015 - klensy:escape-def, r=Mark-Simulacrum d63fcb29ef4 Use ZST for fmt unsafety e0fd19e3c26 Re-export FromSecsError from `std` 55c1cbe7f54 Update stdarch submodule 07759f1742d 2229: Annotate stdlib with insignficant dtors a8411654d35 Impl `Error` for `FromSecsError` without foreign type f3a42f44318 Fix link in Ipv6Addr::to_ipv4 docs b69a811934f Mark unsafe NonZero*::unchecked_(add|mul) as const c1012c4c769 Auto merge of #88321 - glaubitz:m68k-linux, r=wesleywiser bb7f9507947 Fix a technicality regarding the size of C's `char` type 623d611ef7a Auto merge of #89089 - JohnTitor:rollup-6s6mccx, r=JohnTitor 4e7210bf9c0 Rollup merge of #89081 - ondra05:patch-1, r=dtolnay 0d1a89e2b8f Rollup merge of #89053 - DeveloperC286:into_iter_fields_to_private, r=Mark-Simulacrum f0c56ec42b7 Rollup merge of #89051 - schctl:master, r=jyn514 02b6a7a5262 Rollup merge of #89017 - the8472:fix-u64-time-monotonizer, r=kennytm bf650f42c8e Auto merge of #89031 - the8472:outline-once-cell-init-closure, r=Mark-Simulacrum eb7513cfe7d Fix typo c1186154e11 EscapeDefault: change `range` field to `Range`, reducing struct size 24 -> 6 bytes 28a19032aeb Auto merge of #88988 - Mark-Simulacrum:avoid-into-ok, r=nagisa 9a38745ae8f refactor: VecDeques IntoIter fields to private 8f80a7a14b6 modify std::os docs to be more consistent b4eb1924ccc use AtomicU64::fetch_update instead of handrolled RMW-loop 34bebdeae47 Stabilize `Iterator::map_while` ffc8a8827f0 Rollup merge of #88954 - nbdd0121:panic3, r=oli-obk 9487ea6fcd0 Rollup merge of #88953 - joshtriplett:chown, r=dtolnay 399aec6660c library/std/env: Add 'm68k' to comment on ARCH constant c512f6b635d libstd: Add m68k for raw type definitions on Linux 18b9816c96d Rollup merge of #88887 - fee1-dead:const-deref, r=oli-obk 417c49b257d Rollup merge of #88339 - piegamesde:master, r=joshtriplett cdc736beb16 Fix missing `no_global_oom_handling` cfg-gating bf1b52e8dc6 Don't inline OnceCell initialization closures 3a1adcd0ca3 Optimize unnecessary check in Vec::retain eee0d2d6bee Add benchmark for Vec::retain 69e9d0e2471 Rollup merge of #89009 - tatami4:master, r=Mark-Simulacrum b25771b83cc Rollup merge of #88986 - hargoniX:master, r=Mark-Simulacrum 1530f268227 Rollup merge of #88976 - notriddle:notriddle/cow-from-cstr-docs, r=Mark-Simulacrum 0731fc2a137 Rollup merge of #88928 - lefth:master, r=Mark-Simulacrum 28d28fbde3b fix potential race in AtomicU64 time monotonizer 1299351bf76 Rustfmt 1cd522f03cb Merge two THREAD_INFO.with and following RefCell borrow 6e22a0d81f5 Replace a couple of asserts with rtassert! in rt code ce0ecb7ac1d Remove unused function 8358e108b2b Use const {} for the THREAD_INFO thread local aae1a7e0103 Optimize ThreadInfo::with d75b65e4e9f Remove an allocation from rt::init c32b1064b01 Merge sys_common::rt into rt 5d7b645bd57 Add IntoIterator intra doc link to various collections 3947d4b5ce7 Fix typo in `break` docs 980e29aef7e Add intra-doc-links to BinaryHeap rustdoc d31b79a06bb Add intra-doc-links to LinkedList rustdoc 3eed89ee8fd Avoid codegen for Result::into_ok in lang_start 818f43c7b5b Make Duration's Debug format pad to width bdb8f6b61ac Rollup merge of #88915 - joshlf:patch-4, r=kennytm cb074a8f0a5 Allow `panic!("{}", computed_str)` in const fn. 90b3a1e535a Add tracking issue for unix_chown 8cb27c5b555 Update the backtrace crate e0d798a4a2a docs(std): add docs for cof_from_cstr impls 48380d4402a Fix formatting e1509de56f0 Add tracking issue 4907dfb0683 Updated for new const trait bounds syntax 09f06f10125 Move tests to library/core/tests a626a56a28f Constly impl TryV2 and Residual for Option 0e903091f9a Constly impl TryV2 and FromResidual for Result 76a9d9bb2be Constify identify conversions f83a58de7bb Auto merge of #88619 - GuillaumeGomez:simplify-std-os-reexports, r=Amanieu 7c5343a6bcf Const Deref dbc96577a59 Add chown functions to std::os::unix::fs to change the owner and group of files 92ed7e5e2d3 Document the closure arguments for `reduce`. aa743ad4f26 `Wrapping` has the same layout and ABI as `T` 02bf87f6375 Rollup merge of #88722 - WaffleLapkin:unsafe_cell_const_get_mut, r=dtolnay c4ec7027702 Move fortanix module position in std::os reexports for alpha sort 89d4981a5f0 Remove usage of cfg_if in std/src/os/mod.rs d2bb98e03c8 Simplify std::os module reexports to fix rustdoc linking issues b7fb4d7ba8c Fix linkcheck issues bd49226dbbc Add primitive documentation to libcore 51a4eaabf20 Allow reverse iteration of lowercase'd/uppercase'd chars 44e6de7db9a Rollup merge of #88849 - matthiaskrgr:clony_on_copy, r=petrochenkov 67349119ef3 Rollup merge of #87904 - kpreid:unsize, r=jyn514 4a20ec9673f manually inline function 7408da781dd don't clone types that are Copy (clippy::clone_on_copy) 54219a73a6c optimization continuation byte validation of strings containing multibyte chars df27b0f4b61 optimize utf8_is_cont_byte() to speed up str.chars().count() 8a1d062e545 benchmark for str.chars().count() 5b7a5596bbb Fill in the tracking issue for `#![feature(const_unsafecell_get_mut)]` 9109e9da778 Use `libc::sigaction()` instead of `sys::signal()` to prevent a deadlock fdbfbc97a49 Rollup merge of #88807 - jruderman:which_reverses, r=joshtriplett f46f69d5df7 Rollup merge of #88667 - kraktus:patch-1, r=dtolnay ffc81cf2b36 Rollup merge of #86165 - m-ou-se:proc-macro-span-shrink, r=dtolnay 5bb6d9538ca Fix typo in docs for iterators 9b492a59cd6 Run fmt 5ac6350e8d2 Clarification of default socket flags used by Rust f891f8318ad Fix Windows compilation errors. 9a478a1489c Fix another Windows compilation error. 30a9b305cce Fix more Windows compilation errors. 131a86148c3 Fix assertion failures in `OwnedHandle` with `windows_subsystem`. b7128262feb Fix Windows compilation errors. 2a717cd5cca Add a `try_clone()` function to `OwnedFd`. d7284bf5db7 Added psadbw support for u8::abs_diff. 2a1425c48ba remove unnecessary bound on Zip specialization impl 2bf3218ecfa Cosmetic fixes. 4de15619335 Ignore automatically derived impls of `Clone` and `Debug` in dead code analysis 3ab02966479 Speed up integer log10. 62a24b9ab84 Added abs_diff for integer types. d98d79946fc Bump stage0 compiler to 1.56 48ebb1527b9 Rollup merge of #88712 - jhpratt:fix-int_rounding-docs, r=joshtriplett 11d2f8acd53 Rollup merge of #88648 - kpreid:option, r=Mark-Simulacrum a94eb7a7758 Rollup merge of #88594 - steffahn:more_symbolic_doc_aliases, r=joshtriplett 1a2e1497130 Auto merge of #86943 - ptrojahn:suggest_derive, r=estebank 3eb8a626598 rearrange to be panic safe e828b8ccfd0 Make `UnsafeCell::get_mut` const aa376ad1573 Optimize VecDeque::append b719450e47c Improve docs for int_log ae9af5724ef Fix docs for `uX::checked_next_multiple_of` ef7e5d57269 Auto merge of #88448 - xu-cheng:btree-blk-build, r=Mark-Simulacrum 477b48142d2 String.split_terminator: Add an example when using a slice of chars fe87efe6c40 Suggest deriving traits if possible cb19c217cd3 Rollup merge of #88673 - Qwaz:node-typo, r=jyn514 6ceb7cbb913 Rollup merge of #88647 - ChrisDenton:win-symlink-docs, r=joshtriplett 6bae9c7d94b Add benchmark for integer log10. be9e8c7f98a rust fmt 1840fcbe8f1 Fix typo: needede -> needed 7fae9cb0b7c Mention usage of `const` in raw pointer types at the top of the keyword's documentation page. 363db0c07e2 Additional aliases for pointers c88b82df463 Tweak `write_fmt` doc. 02a230e89da Change return type for T::{log,log2,log10} to u32. The value is at most 128, and this is consistent with using u32 for small values elsewhere (e.g. BITS, count_ones, leading_zeros). 72630c28d4a Rollup merge of #88432 - terrarier2111:patch-1, r=joshtriplett e2fd1cc054a Auto merge of #88469 - patrick-gu:master, r=dtolnay 7c2ecc64f24 linux/aarch64 Now() should be actually_monotonic() 086a956f6ed Use the 64b inner:monotonize() implementation not the 128b one for aarch64 c509cd8fd7b Clarify what “a container” is in `FromIterator> for Option` doc. 5aa26f375d9 Add sentence punctuation and links in `Option` docs. f1d773df0a8 “Moves” instead of “copies” in ` as From>::from` doc. bbf8d105bf7 Document when to use Windows' `symlink_dir` vs. `symlink_file` 996ffe85065 Fix accidentally deleted part 903e7e76918 Add a missing backtick ec97f8dfac0 Remove excessive linking 483d2a156e9 simplify `impl Termination for Result` 3e8ee3b0389 Rollup merge of #88613 - m-ou-se:array-docs-2021, r=Amanieu 0b78f2b6969 Rollup merge of #88610 - m-ou-se:array-into-iter-docs, r=Amanieu 0dbc79bf265 Rollup merge of #88579 - ast-ral:master, r=m-ou-se e6efe92cc3a Rollup merge of #88507 - atsuzaki:slice-fill-maybeuninit-test, r=RalfJung e0a789ddaa8 Rollup merge of #88202 - azdavis:master, r=jyn514 80bc949f6dd Update primitive docs for rust 2021. c3749633c9e Add a better error message for #39364 bdf28297c73 Update outdated docs of array::IntoIter::new. f80d4e42414 implement `Termination` for `Result` 0b274f09002 Auto merge of #88596 - m-ou-se:rollup-cidzt4v, r=m-ou-se cb681365099 Rollup merge of #88582 - jhpratt:int_roundings, r=joshtriplett d968014cc0b Rollup merge of #88560 - klensy:formatter-pad-shrink, r=m-ou-se fb471f3b3db Rollup merge of #88505 - ibraheemdev:use-unwrap-unchecked, r=kennytm 346c300d58b Rollup merge of #88177 - joshtriplett:stabilize-chroot, r=m-ou-se 794d673ee85 Auto merge of #87580 - ChrisDenton:win-arg-parse-2008, r=m-ou-se 93cb7cc6888 Consistent placement of doc alias for primitives below the `doc(primitive…)` 833c837a0c4 Add "!" doc alias for `std::ops::Not` 7cc4a78efac I/O safety for WinUWP b3e28ea4ccd Implement #88581 3e6a74ea3d8 remove redundant / misplaced sentence from docs c98e4c885ee Auto merge of #83342 - Count-Count:win-console-incomplete-utf8, r=m-ou-se 458e7dbc28c fix clippy lints 0d73a8dd7b5 `fmt::Formatter::pad`: don't call chars().count() more than one time a0ad5ddda52 Rollup merge of #88551 - inquisitivecrystal:unsafe_cell_raw_get, r=m-ou-se 7358a279519 Rollup merge of #88548 - inquisitivecrystal:intersperse, r=m-ou-se 559006e421c Rollup merge of #88542 - tavianator:readdir_r-errno, r=jyn514 7cafc78f6ca Rollup merge of #88040 - nbdd0121:btreemap, r=m-ou-se fb39332bbf8 Add a few tests for `UnsafeCell` 3b4d4326a2d Stabilize `Iterator::intersperse()` 0827f82b055 Stabilize `UnsafeCell::raw_get()` 9ddab06789c Use the return value of readdir_r() instead of errno e3a4f3f4ecf Rollup merge of #88524 - soenkehahn:master, r=jyn514 ec2ed1d99f1 Rollup merge of #88495 - ibraheemdev:tcp-linger, r=joshtriplett cdac77783a8 Rollup merge of #85017 - clarfonthey:carrying_widening, r=m-ou-se fdfb8b156bf Move to the top of file 5950a8df5de disable `tcp_linger` feature in `std` 774c0927282 add safety annotation to `LinkedList::detach_all_nodes` 18ede4b01ee Rollup merge of #88465 - marcospb19:master, r=joshtriplett 3de8476721a Rollup merge of #88394 - ChrisDenton:patch-1, r=joshtriplett 8e05f978b2a Remove unnecessary `mut` from udp doctests 089da45f64a Expand documentation for `FpCategory`. cab2425287e Add test case for using `slice::fill` with MaybeUninit b9fcc9f2ba1 use `unwrap_unchecked` where possible 52d28af175a clean up `c::linger` conversion 95fdcc417b3 add `TcpStream::set_linger` and `TcpStream::linger` 65ac2b909b5 Adding examples to docs of std::time module 97e7a21e561 Add links in docs for some primitive types 78a1a8662d3 Rollup merge of #88381 - rtzoeller:dfly_stack_t_ss_sp_void, r=dtolnay a12022ebd41 const fn for option copied, take & replace + tests 2ce6033154b Auto merge of #88295 - alexcrichton:update-stdarch, r=kennytm 5dcd58a8a5e VecDeque: improve performance for From<[T; N]> 7699f65508e add benchmark for From<[T; N]> in VecDeque f7093a70dd9 BTreeSet::from_iter: use bulk building to improve the performance 8e27ef32172 BTreeMap::from_iter: use bulk building to improve the performance 964438a8a25 add benchmark for BTreeMap::from_iter e867b797b61 Auto merge of #87921 - kellerkindt:master, r=kennytm 19ead9c2561 std: Stabilize command_access b3e3fd81374 Fix a typo in raw_vec 9bb6cb36daf Unimpl Shl{Assign} for signed Saturating types until the correct impl is clear 2b0f6a027d2 Fix mentions of wrapping operations 4f317dd5725 Use wrapping shift for unsigned types 6f5fd08b59e build llvm libunwind.a in rustbuild 139de94f9bb Remove ignore-tidy-undocumented-unsafe from core::slice::sort 1159855fdfb Handle stack_t.ss_sp type change for DragonFlyBSD fc9e8766b36 Document `std::env::current_exe` rename behaviour 129e946642f Auto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearth 38fa3cfef5f Add carrying_add, borrowing_sub, widening_mul, carrying_mul methods to integers 23e3a8d027e Clarify that ManuallyDrop has same layout as T abcd61cecc4 Fix documentation in Cell 4d4f6f2dd1f Add TcpListener::into_incoming and IntoIncoming ca32ce09747 Add missing # Panics section to `Vec` method 25ec0328de2 Rollup merge of #88340 - thomcc:c_size_t, r=joshtriplett bbf8d9a8a7a Rollup merge of #88216 - kornelski:from_layout_err, r=kennytm c51742d7142 Auto merge of #87194 - eddyb:const-value-mangling, r=michaelwoerister,oli-obk fed31310f35 Partially stabilize `array_methods` a4b7e65f9e0 Auto merge of #88066 - LeSeulArtichaut:patterns-cleanups, r=nagisa 199038903fe Reference tracking issue d63f415710b Add `c_size_t` and `c_ssize_t` to `std::os::raw`. f6d2760695a Use if-let guards in the codebase df390538dca Rollup merge of #88299 - ijackson:bufwriter, r=Mark-Simulacrum f6ae5dcde5c Rollup merge of #88298 - ijackson:errorkind-reorder, r=dtolnay 6209b947bdc Rollup merge of #88293 - est31:fix_grammar, r=Mark-Simulacrum 59705d21f33 Rollup merge of #88291 - mdsn:partition-in-blocks-safety, r=Mark-Simulacrum 21b581a0d34 Rollup merge of #88273 - jhpratt:update-iterator-docs, r=jyn514 4d5204cb21d Rollup merge of #88226 - steffahn:an_rc, r=michaelwoerister c03ce916d93 Rollup merge of #88223 - scottmcm:fix-alias, r=yaahc d5c0c14ca9d Rollup merge of #88156 - steffahn:arc_make_mut_and_weak, r=Mark-Simulacrum 39c882049a8 Rollup merge of #87944 - oconnor663:as_array_of_cells, r=scottmcm b4b7c7f7c7f Add SAFETY comments to core::slice::sort::partition_in_blocks d5c7ff9098c Make explanations of cross-references between `make_mut` and `get_mut` more accurate f6c2e1db28d Clarifiy weak pointers being diassociated… 46bbc6aec5a Manual Debug for Unix ExitCode ExitStatus ExitStatusError 75d6fbb058a Stabilise unix_process_await_more, extra ExitStatusExt methods 6677a7d10da Stabilise BufWriter::into_parts 316671d8dcf Update rustc-demangle to 0.1.21. 1217079e18f Fix tidy 03499968332 Update the stdarch submodule 313f61bda60 Fix grammar ec51075f593 io::ErrorKind: rationalise ordering in main enum f0313624039 io::Error: alphabeticise the match in as_str() c4aba32add3 Remove unnecessary unsafe block in `process_unix` 870843d15cf Fix typo “a Rc” → “an Rc” 703cec3589f Fix references to `ControlFlow` in docs dd5d80af4db Auto merge of #83302 - camsteffen:write-piece-unchecked, r=dtolnay d5f2ce560fd Rollup merge of #88230 - steffahn:a_an, r=oli-obk 5540458b5b5 Auto merge of #88220 - sunfishcode:sunfishcode/unix-listener-io-safety, r=joshtriplett 2a071b9a8de Auto merge of #87598 - ccqpein:master, r=yaahc e8ef76d859d add Cell::as_array_of_cells, similar to Cell::as_slice_of_cells ac910271dfe Remove redundant conversions. 17303436312 Fix typos “an”→“a” and a few different ones that appeared in the same search 30cc0a58895 Fix more “a”/“an” typos 766db32b080 Fix more “a”/“an” typos 1d265ebcc60 Fix typos “a”→“an” 56f224f2da8 Add doctests for 's into_values and into_keys methods 3b97d77c7ae Auto merge of #88122 - Seppel3210:master, r=dtolnay 042de50370e Auto merge of #85166 - mbhall88:file-prefix, r=dtolnay 9e88fd5593c Implement `AsFd` etc. for `UnixListener`. 7be935fbe3e Auto merge of #88075 - Xuanwo:vec_deque_retain, r=dtolnay 4274cc57c03 Don't stabilize creation of TryReserveError instances 9af0eafe9b9 Remove the `TryV2` alias be195a1721e Add an example for deriving PartialOrd on enums 4d5f61e6ad8 Auto merge of #83093 - the8472:smaller-instant-hammer, r=Amanieu 5b3d507d796 fix tests on wasm targets that have 32bit time_t and don't have threads 5412205e5e8 Auto merge of #87329 - sunfishcode:sunfishcode/io-safety, r=joshtriplett 96e1b13baac Auto merge of #86898 - the8472:path-cmp, r=dtolnay 5612a2f1a88 Stabilize std::os::unix::fs::chroot 78753e0d300 Auto merge of #87996 - sexxi-goose:fix-87988, r=nikomatsakis 7a558c201c8 Fix doc test failures on Windows. 1e526bdb2ad Auto merge of #88165 - GuillaumeGomez:rollup-4o0v2ps, r=GuillaumeGomez a1439a3e193 Factor out a common `RawFd`/`AsRawFd`/etc for Unix and WASI. cb6ca58c049 Fix syntax for non-doc comments, and use `crate::` instead of `std::`. 73f7e109af2 Add I/O safety trait impls for process::Stdio and process::Child. b92d21a9e46 Use the correct `into_*` on Windows to avoid dropping a stdio handle. e957dfbae10 Remove the `#![feature(io_safety)]` from lib.rs. b63d7ee9a3c Fix an unused import warning. e8f9b48e2fb Update PidFd for the new I/O safety APIs. 7ddcb49b5a0 Rename OptionFileHandle to HandleOrInvalid and make it just wrap an Option 41cfe3ef1e1 Don't encourage migration until io_safety is stablized. 4d306efe683 Factor out Unix and WASI fd code into a common module. b66c531dc3c Synchronize minor differences between Unix and WASI implementations. 52ea526b7c8 Add more comments about the `INVALID_HANDLE_VALUE` situation. c804209daec Add comments about impls for File, TcpStream, ChildStdin, etc. 8b885ee9690 Fix copypasta of "Unix" within the WASI directory. dd7f06bcbae Reword the description of dup2/dup3. e21f8173359 Add Safety comments to the `As*` for `Owned*` implementations. 01359ec57f6 Add Owned*, Borrowed*, and As* to the preludes. 8fc1c7a424f Rename `OwnedFd`'s private field to match it's debug output. 6dfc04b7a57 Delete a spurious empty comment line. cc1c774a241 Add a comment about how `OwnedHandle` should not be used with registry handles. 2944c931783 Add a comment about `OptionFileHandle`. 94468ffed28 Be more precise about `mmap` and undefined behavior. 485880740e3 Add a test to ensure that RawFd is the size we assume it is. 7d4e52a5866 Update library/std/src/os/windows/io/socket.rs 278d4eaa360 Update library/std/src/os/windows/io/handle.rs d79b8c5246e Update library/std/src/os/unix/io/fd.rs e7d14b4d015 I/O safety. 21e6aa6563b Rollup merge of #87874 - schneems:schneems/tcpstream-iterator-type, r=Mark-Simulacrum 254a596fb97 Auto merge of #88151 - alexcrichton:update-backtrace, r=Mark-Simulacrum 6d6c717fa85 Update the backtrace crate in libstd 6d8f041315d Adjust documentation of `Arc::make_mut` 52fbd6088e5 Simplify saturating_div 277255e95ff Auto merge of #88002 - hermitcore:unbox-mutex, r=dtolnay e3acdd47ded Simplify Div impl for Saturating by using saturating_div 7a78d9de576 Add saturating_div to unsigned integer types 66b8d54114e Add doctests to and fix saturating_div for signed integer types 451c7defa89 Add and use saturating_div instead of impl inside Saturating 7d58c09e36e Saturate negative division c1b5bb22170 Rollup merge of #88109 - inquisitivecrystal:env-docs, r=m-ou-se a16b6b4a192 Rollup merge of #88031 - ibraheemdev:build-hasher-object-safe, r=m-ou-se 10a9549d25c Rollup merge of #88012 - sunfishcode:sunfishcode/wasi-raw-fd-c-int, r=alexcrichton 92258dc2483 BTree: remove Ord bound from new 2d14c987b9e Fix example in `Extend<(A, B)>` impl 40620145564 [review] fix comment ed5b935c6a7 BTree: refine some comments e14a349e2e9 Fix environment variable getter docs 2c99e6584b0 Constified `Default` implementations eae9027bcea Rollup merge of #88030 - fee1-dead:fixme, r=oli-obk 09ad5d4e29f correct overflows in the backslide case, add test 10a59834d74 Get piece unchecked in write 626986f8ad0 Make Arguments constructors unsafe 6ec621d5968 Auto merge of #87050 - jyn514:no-doc-primitive, r=manishearth 3aa503b6c37 BTree: toughen panicky test of clone() 905edfc469c Auto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiser e43f779dc7d Remove extra empty lines f255a20642e feature gate doc(primitive) 7d51ba175b8 Optimize unnecessary check in VecDeque::retain b76f301ff7d Uplift the `invalid_atomic_ordering` lint from clippy to rustc b6c60596f33 Auto merge of #87696 - ssomers:btree_lazy_iterator_cleanup, r=Mark-Simulacrum 5814fde0ffc Apply suggestions from code review fa1a5d67715 move object safety test to library/core 9a2779c6929 Allow the use of the deprecated llvm_asm! in black_box 93e83722157 Deprecate llvm_asm! 418d73467fc Auto merge of #87974 - steffahn:slice_split_size_hints, r=dtolnay b14eb9123ce make `BuildHasher` object safe 1ec4e32210b Assign FIXMEs to me and remove obsolete ones af63e33f778 Auto merge of #87913 - a1phyr:vec_spec_clone_from, r=dtolnay 8ed946eb1ac Change WASI's `RawFd` from `u32` to `c_int` (`i32`). ed8711940c0 Improve wording, correct -> tight. e8db68674ba switch to the latest version of hermit-abi 7f7d16a2a65 Consistent use of `impl Trait` arguments in the test's helper function. 74170120428 allow incomplete features for now f82e0cb7fa9 Moved ui test 8b7c69d5b3c Don't put hermit mutexes in a box. 45ce0429f62 Don't put hermit condvars in a box. 3c5c8a055a2 Don't put hermit rwlocks in a box. 3665699f862 add benchmarks for 1, 2, 4, 8, 16 threads 1bc37becc22 where available use 64- or 128bit atomics instead of a Mutex to monotonize time dcc6d4deb8a Rewrite test from previous commit but without using macros. 5ac5b5b5100 Auto merge of #87916 - nbdd0121:black_box, r=nagisa e610e342435 Rollup merge of #87916 - nbdd0121:black_box, r=nagisa f1bfe41b0a7 Test and fix size_hint for slice's [r]split* iterators 40307dda588 Implement `black_box` using intrinsic 17c156db556 Auto merge of #87963 - GuillaumeGomez:rollup-e54sbez, r=GuillaumeGomez 27b025501cd Implement Neg only for signed Saturating types beb80328efe Rollup merge of #87863 - ChrisDenton:command-env-path-fix, r=dtolnay cf89de2e858 Auto merge of #87666 - ivmarkov:master, r=Amanieu c4caa943915 Add naive remainder impl to Saturating d17f69a8e93 Add naive shift implementation to Saturating 6f013d249ac Replace doc test with doc macro call f7b5b3a99d9 Like in Wrapping use shift in doctest 67fd0299eaa Add missing cfg attribute a3a344337b9 Remove mentioning of modular arithmetic d377d76c50c Make all the impls for Staturating unstable saturating_int_impl 4b0d235746b Rollup merge of #85835 - Seppel3210:master, r=yaahc 6a6d9d2e876 Auto merge of #87843 - kornelski:try_reserve, r=m-ou-se b01448c3903 Weaken guarantee around advancing underlying iterators in zip 037c1a2b982 Auto merge of #87892 - rust-lang:spec-fill-size-one-bye, r=the8472 8e6c6aabd6c Specify maximum IP address length f3735d35bf7 Rollup merge of #87876 - lcnr:windows_no_panic, r=m-ou-se 6b72e8e0559 Rollup merge of #87848 - godmar:@godmar/thread-join-documentation-fix, r=joshtriplett 15df1d8e5cf Rollup merge of #87636 - Kixiron:unzip-option, r=scottmcm 824917afb6b Rollup merge of #86840 - usbalbin:const_from, r=oli-obk 8fa92444511 Fix missed tests ee80204ce71 Rustfmt a7fbbc3ba42 Remove unused macros 2f98c9fddb2 Add Saturating type (based on Wrapping type) 03a435720b6 Specialize `Vec::clone_from` for `Copy` types d0c3dafec5f STD support for the ESP-IDF framework 1c598ac6591 Reword description of automatic impls of `Unsize`. 4ed07b97bdf Remove size_of == 1 case from `fill` specialization. e60c8c36cea Added tracking issue to unstable attribute d5dc2dee52e Enabled unzip_option feature for core tests & unzip docs 01960affcd4 Added some basic tests for `Option::unzip()` and `Option::zip()` (I noticed that zip had no tests) 594e17f7b5d Added the `Option::unzip()` method 9252375d5a1 add `windows` count test 896da0b6967 Auto merge of #87820 - elichai:patch-2, r=kennytm 4aa1339d180 ## Context 8a83828ff49 Implement modern Windows arg parsing ac96d9d6cb1 Update Windows arg parsing tests 96a5a9f6127 Auto merge of #86879 - YohDeadfall:stabilize-vec-shrink-to, r=dtolnay 92e16b15a8a Bump shrink_to stabilization to Rust 1.56 f3999a6c3c6 Make `<[T]>::split_at_unchecked` and `<[T]>::split_at_mut_unchecked` public 72b0694d152 Fix Windows Command::env("PATH") 25f556efae6 Auto merge of #87827 - eddyb:wrapperless-mem-replace, r=m-ou-se fc765aa91f3 Avoid using the `copy_nonoverlapping` wrapper through `mem::replace`. add61031f9b Auto merge of #87836 - tsoutsman:master, r=petrochenkov 6677f2db859 Merge branch 'rust-lang:master' into master c51dd88e34b Auto merge of #86744 - ijackson:sink-default, r=dtolnay a42fe0759a7 Add test for int to float c985c00b8ab Add tests 65ad6a1e414 impl const From for num 2b5e80c710a Rollup merge of #87842 - steffahn:hidden_broken_intra_doc, r=dtolnay 7320d44e30a Rollup merge of #87838 - jetomit:add-readdir-note, r=dtolnay 55e6865bb60 removed references to parent/child from std::thread documentation a75644c0d61 Change proc_macro::Diagnostics docs a2cc4d2c8f9 Use assert_matches! instead of if let {} else 1b3a0fa9770 Inline from of TryReserveErrorKind 5ea7e625ae2 Auto merge of #87810 - devnexen:haiku_os_simpl, r=Mark-Simulacrum 3fbf2b55f2e Fix intra doc link in hidden doc of Iterator::__iterator_get_unchecked 82734e9a909 Document that fs::read_dir skips . and .. f59850f78bb Auto merge of #87408 - kornelski:try_reserve_error, r=yaahc d1a6f9255a9 Auto merge of #87774 - camelid:process-typo, r=jyn514 67ac366a8ef Replace read_to_string with read_line in Stdin example bee07afc073 Rollup merge of #87809 - InnovativeInventor:pointer-typo, r=dtolnay da74d067051 Rollup merge of #87787 - hyd-dev:c-unwind, r=RalfJung 82297bcc81f Auto merge of #87777 - the8472:fix-mir-max-rss, r=oli-obk,joshtriplett eb5034f9dcf current_exe haiku code path simplification all of these part of libc d6f93fd4ccf Auto merge of #87808 - JohnTitor:rollup-qqp79xs, r=JohnTitor eb31d9d639f Fix typo in the ptr documentation 19fe8ce036c Rollup merge of #87780 - est31:intra_doc_links, r=jyn514 2d44f6b380c Rollup merge of #87759 - m-ou-se:linux-process-sealed, r=jyn514 986202e537a Rollup merge of #87561 - devnexen:haiku_thread_build_fix, r=yaahc 58edd248dc2 Auto merge of #87462 - ibraheemdev:tidy-file-length-ignore-comment, r=Mark-Simulacrum 6eba6fedc0d add Box::try_new_uninit_slice for symmetry fce65e4a554 remove cfg gate on `use RawVec` since it is now also used in fallible code 8afe1441e6e Make rustfmt happy. 50b965f4e64 Remove unnecessary #[unstable] from internal macro. 4dfd9fcc090 Remove unused langauge #![feature]s from core. 6379816d904 Remove unused library #![feature]s from core. 39bc3a88eb8 Sort and categorize lint and feature attributes in core. 910ad83f83d Use `C-unwind` ABI for `__rust_start_panic` in `panic_abort` 568cbaf9a7f alloc: Use intra doc links for the reserve function fb2cc6962f4 add Box::try_new_zeroed_slice() 9fb091db49d Auto merge of #86155 - alexcrichton:abort-on-unwind, r=nikomatsakis bd6e4ff23aa Fix typo 9971e56dc6d Auto merge of #87736 - the8472:inline-advance-by, r=Mark-Simulacrum 533cd469b5c Auto merge of #87150 - rusticstuff:simplify_wrapping_neg, r=m-ou-se 5dfa10b1fff Re-use std::sealed::Sealed in os/linux/process. 85b5f12b772 Auto merge of #87712 - est31:line-column-1-based, r=petrochenkov adeddc318a5 Rollup merge of #87729 - adamgemmell:dev/deprecate-crypto, r=Amanieu d4f781edb11 Rollup merge of #87723 - frogtd:patch-3, r=JohnTitor 3610d6c43a9 Rollup merge of #87267 - dtolnay:negspace, r=Aaron1011 7d03e37af91 Rollup merge of #81797 - yoshuawuyts:stream_from_iter, r=dtolnay 810b1475932 #[inline] slice::advance_by 8a08c957861 Update library/core/src/iter/traits/collect.rs 5f2dd076d23 Remove space after negative sign in Literal to_string cb57a6867b9 rustc: Fill out remaining parts of C-unwind ABI 3f7c751a4f8 Update aarch64 runtime feature detection tests 9a362bad2de Update `stdarch` to deprecate `crypto` aarch64 target_feature f5bd99c354c Rollup merge of #87708 - the8472:canonical_v6, r=dtolnay 8dd2997e45b Rollup merge of #87685 - notriddle:lazy-from-docs, r=dtolnay 34e0b702f77 Use .contains instead of manual reimplementation. 7833e58f665 Auto merge of #86335 - CDirkx:ipv4-in-ipv6, r=dtolnay e5baf5dd816 Make the UTF-8 statement more explicit and explicitly test for it 7ec42ac0a72 Make columns 1 based e672e1bd806 Add convenience for handling ipv4-mapped addresses by canonicalizing them 13a4fe95d9c Rollup merge of #87690 - sharnoff:mut-ptr-allocated-obj-link, r=Mark-Simulacrum 779bb2b8e26 Rollup merge of #87654 - jesyspa:issue-87238-option-result-doc, r=scottmcm 0f3c06c8097 BTree: merge the complication introduced by #81486 and #86031 7e90429e4ec os current_exe using same approach as linux to get always the full absolute path but in case of failure (e.g. prcfs not mounted) still using getexecname. 026600d718d Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum 008e84433df Add missing "allocated object" doc link 24bba831d07 Auto merge of #87689 - JohnTitor:rollup-ns38b56, r=JohnTitor b219c92c8b8 Rollup merge of #87653 - RalfJung:dont-run-ub, r=kennytm 7d9de2bbb8e Rollup merge of #87644 - Flying-Toast:vec-remove-note, r=the8472 7234e9ec0ea Rollup merge of #87629 - steffahn:consistent_adapter_spelling, r=m-ou-se bb179e46bfa Rollup merge of #86936 - CDirkx:ipv6-multicast, r=JohnTitor 8ef582423cc Rollup merge of #86593 - jhpratt:stabilize-const_slice_first_last, r=m-ou-se 6e60fed3022 Rollup merge of #86509 - CDirkx:os_str, r=m-ou-se b98090246a2 Rollup merge of #86439 - CDirkx:ip-protocol-assignment, r=m-ou-se 45619c4433a Rollup merge of #86183 - inquisitivecrystal:env-nul, r=m-ou-se 6b04a80b2cd Auto merge of #85272 - ChayimFriedman2:matches-leading-pipe, r=m-ou-se 6f2f3855ad2 Auto merge of #86031 - ssomers:btree_lazy_iterator, r=Mark-Simulacrum 51e0df6328b Write docs for SyncOnceCell From and Default impl 35d88beeba1 Auto merge of #87622 - pietroalbini:bump-bootstrap, r=Mark-Simulacrum eb42dbc261a Auto merge of #81825 - voidc:pidfd, r=joshtriplett b96665d3b1b Update const_slice_first_last_not_mut stable version. f01038df7cd bump bootstrap compiler to 1.55 f0a3065f364 Add documentation for the order of Option and Result 297a8584d51 Add dummy FileDesc struct for doc target 65b0fe7b81e Auto merge of #84662 - dtolnay:unwindsafe, r=Amanieu fac8345492d Fix unused sync::atomic import on targets without atomics 409b017c68e Relocate Arc and Rc UnwindSafe impls 102a7b2d7e6 mark a UB doctest as no_run 094f5cd99a1 Auto merge of #87387 - the8472:slice-iter-advance_by, r=scottmcm 7cdad3e8491 Auto merge of #87488 - kornelski:track-remove, r=dtolnay fd4a8e89bc4 Recommend `swap_remove` in `Vec::remove` docs 6d3c22c905c Rollup merge of #87609 - LukasKalbertodt:improve-array-map-docs, r=m-ou-se 9c30f3adf1e Rollup merge of #87547 - GuillaumeGomez:nonnull-examples, r=kennytm ec6d066be07 Rollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkov 202c5dcffb5 Fix some broken rustdoc links in core::panic documentation 6e4793490b0 Fix comment referring to formerly-above code e65d5a4767b Fix undocumented unsafe in AssertUnwindSafe impls 2cf1622cd3d Move UnwindSafe, RefUnwindSafe, AssertUnwindSafe to core 921062319d2 Fix separation of public vs internal parts of Location 04e4ec12d0b Split core::panic module to subdirectory 3be67aa011a Consistent spelling of "adapter" in the standard library aecc32234fb Add missing examples for NonNull 95108aa0283 Rollup merge of #87602 - wesleywiser:partially_fix_short_backtraces_windows_optimized, r=dtolnay 4edb9cbbb28 Rollup merge of #87594 - devnexen:netbsd_fs_getfiledescriptor_path, r=joshtriplett 02b0e845cff Rollup merge of #87585 - GuillaumeGomez:char-types-doc, r=joshtriplett 3cf1bfc2ac5 Rollup merge of #87574 - cuviper:retain-examples, r=joshtriplett bc54cc4b8cc Rollup merge of #87522 - frogtd:patch-1, r=yaahc 73431fa912f Rollup merge of #87052 - phlopsi:patch-1, r=jyn514 a842042e1a3 Auto merge of #87445 - amalik18:issue-83584-fix, r=kennytm add168c7769 Add docs about performance and `Iterator::map` to `[T; N]::map` cad45ed3dfa rfc3052: Remove authors field from Cargo manifests 684232ba7b2 [backtraces]: look for the `begin` symbol only after seeing `end` 589fa35d066 fs File get_path procfs usage for netbsd same as linux. 60d29452120 Rename feature gate bufwriter_into_parts from bufwriter_into_raw_parts 3b5a3fb2225 BufWriter: rename `into_parts` from `into_raw_parts` 3f038cbd1ec BufWriter: actually export WriterPanicked error e07f9dcf9a9 Add missing links for core::char types 2317c9b4391 Auto merge of #86664 - m-ou-se:uninit-track-caller, r=JohnTitor eb21b921e4a Auto merge of #86998 - m-ou-se:const-panic-fmt-as-str, r=oli-obk 5ed413a297e Fix may not to appropriate might not or must not e9456627b5e Fix may not to appropriate might not or must not 004504d8095 Auto merge of #85874 - steffahn:fix_unsound_zip_optimization, r=yaahc 03b962fe643 Update the examples in `String` and `VecDeque::retain` 63403215503 Add char array without ref Pattern impl 2d39b8c1a6b impl Pattern for char array 14ed2c5d737 Rollup merge of #87565 - ibraheemdev:patch-7, r=scottmcm 20cee0ff9a0 Rollup merge of #86839 - D1mon:patch-1, r=JohnTitor b3541feef04 Rollup merge of #81363 - jonhoo:no-unpin-in-pin-future-impl, r=m-ou-se f325b6bdaac Rollup merge of #81050 - yoshuawuyts:stabilize-task-ready, r=m-ou-se ebd602544b5 Use backticks when referring to `core::future::Ready` in panic message 0f9e3062cee Add some doc aliases 33528615ba4 thread set_name haiku implementation. e244b170da2 Update stable version of ready!() macro. c282b7b8e82 Extend documentation of const_format_args!(). 3a0226df53d Improve comments about const panic handling b205ee47acd Make const_fmt_args!() work during bootstrap. 5e8b88313f8 Use unreachable_unchecked in const_panic_fmt. c8400277ba6 Add new const_format_args!() macro and use it in panics. 259b25b1dd5 Make const panic!("..") work in Rust 2021. f3de59ab495 Add #[track_caller] for some function in core::mem. d0e52bb9199 Documentation improvements a522edeb593 Make `SpecInPlaceCollect` use `TrustedRandomAccessNoCoerce` 2e619b6ea27 Remove redundant bounds on get_unchecked for vec_deque iterators, and run fmt 25fcfed21b2 Add back TrustedRandomAccess-specialization for Vec, but only without coercions 492cf6c8ae1 Change __iterator_get_unchecked to work with TrustedRandomAccessNoCoerce bd130fe22c8 Add TrustedRandomAccessNoCoerce supertrait without requirements or guarantees about subtype coercions 70fb156f2cb Improve documentation of TrustedRandomAccess e48ce70195c Remove unsound TrustedRandomAccess implementations b513bb700ad stack overflow handler specific openbsd fix. a035d60fed9 Rollup merge of #87523 - frogtd:patch-2, r=dtolnay 64cb6556119 Rollup merge of #87507 - jethrogb:jb/sgx-unmoveable-mutex, r=dtolnay 476ad7eb8d0 Rollup merge of #87501 - spastorino:remove-min-tait, r=oli-obk 150010e7021 Rollup merge of #87500 - Smittyvb:min-max-docs, r=kennytm caae6412fe1 Rollup merge of #87330 - inquisitivecrystal:extend-reserve, r=JohnTitor 310eb551f42 Auto merge of #86735 - jhpratt:rfc-3107, r=petrochenkov 9f814632d83 remove unneeded stringify 7e3fb0234af Update tests 8f260c2afea Update range.rs 3acb36a8029 Stabilize `const_fn_union` 3f94afeda5a Stabilize `const_fn_transmute` 0a65bdda925 Fix assert in diy_float 08e4ffdb94d Permit deriving default on enums with `#[default]` b5ddc107692 Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default 90baacaf291 Use type_alias_impl_trait instead of min in compiler and lib 82c5814566e Auto merge of #87509 - JohnTitor:rollup-8iqn6cl, r=JohnTitor 47ec54731f0 Rollup merge of #87494 - midgleyc:comment-typos, r=joshtriplett 2eaf77d0cba Rollup merge of #87446 - devnexen:macos_update, r=dtolnay 533445794e4 Rollup merge of #87354 - Wind-River:2021_master, r=kennytm ee2f754ca48 Auto merge of #87431 - the8472:array-iter-fold, r=kennytm 49ba30de8ba Add warning to SGX mutex implementation 3c229a2de6a Revert "SGX mutex is movable" 0a4f69e80e3 Auto merge of #85305 - MarcusDunn:master, r=pnkfelix 0f5d4b82e27 Auto merge of #87062 - poliorcetics:fix-85462, r=dtolnay aa07a168c8b Document math behind MIN/MAX consts on integers 1635f93734a from review: add a comment why try_fold was chosen instead of fold ca919a0edfd fix typo: whenver -> whenever 7997bae179c Track caller of Vec::remove() 05d39a2894b Auto merge of #87430 - devnexen:netbsd_ucred_enabled, r=joshtriplett 6463f09a448 ignore comments in tidy-filelength 393c7050b45 Auto merge of #86595 - a1phyr:allocator_api_for_vecdeque, r=Amanieu 4e200ced71f macos current_exe using directly libc instead. e7dd1904e10 Auto merge of #84111 - bstrie:hashfrom, r=joshtriplett 9b577b531ab Hide allocator details from TryReserveError f5125bde2c6 Remove unnecessary condition in Barrier::wait() 175d129b784 implement fold() on array::IntoIter to improve flatten().collect() perf 641d1ff9b02 Rollup merge of #87422 - mgeier:doc-strip-feature-attribute, r=LeSeulArtichaut e13373cfcd3 Rollup merge of #87410 - jonas-schievink:doc-hidden-format_args_nl, r=nagisa 9ba4c448725 Rollup merge of #87395 - ericonr:patch-1, r=joshtriplett ee37bb5ff1b netbsd enabled ucred 0487cf69b9e DOC: remove unnecessary feature crate attribute from example code 66fa53acb20 Auto merge of #84589 - In-line:zircon-thread-name, r=JohnTitor b86a464fc46 Fix parameter names in std::env documentation. 8b3eadc5502 Rollup merge of #87255 - RalfJung:miri-test-libcore, r=Mark-Simulacrum c09a59234fe Rollup merge of #87175 - inquisitivecrystal:inner-error, r=kennytm 8ecee812477 Rollup merge of #87171 - Alexendoo:bufwriter-option, r=Mark-Simulacrum 990a2a28322 Rollup merge of #86790 - janikrabe:retain-iter-order-doc, r=m-ou-se 6a8fc483cfb Add `#[unstable]` on new functions c39c7413ed4 Add unstable attribute for `A` in `Drain` and `IntoIter` 95a59dfe20b Add support for custom allocator in `VecDeque` 7d73fa76adf Mark `format_args_nl` as `#[doc(hidden)]` 55a6a72c248 Stabilize core::task::ready! 9aaab7d6319 Rollup merge of #87034 - mgeier:doc-step_by, r=JohnTitor 1581cd466ad Fix whitespace 5bcdc8bf9e6 Add tests 2f99406957d Implement slice::{Iter, IterMut}::{advance_by, advance_back_by} a5b5e74ec68 Remove Option from BufWriter 34f38d4720f Rollup merge of #87343 - steffahn:fix_unsound_zip_optimization_only_regression_fix, r=cuviper 244faa18cea VxWorks does provide sigemptyset and sigaddset b4d51576d8b Disable glibc tests on vxworks b9d53b6f2c1 Rollup merge of #81864 - ijackson:globalalloc-example, r=Amanieu 4a3a3cc65e2 Rollup merge of #87279 - sunfishcode:document-unix-argv, r=RalfJung 344f40ecd27 Remove unsound TrustedRandomAccess implementations 717738f721b docs: GlobalAlloc: Make example only require 4096-aligned static 9bb0f115d1c Add tracking issue and link to man-page 572fbc0b1d2 Add PidFd type and seal traits 6e5c97be0f1 Typo fix 6599994d2bb Add Linux-specific pidfd process extensions bafe34ef106 Auto merge of #86847 - tlyu:stdin-forwarders, r=joshtriplett 6f991aecb32 Auto merge of #87168 - the8472:flatten-len, r=scottmcm c9073cedc4e Use hashbrown's `extend_reserve()` in `HashMap` 74a41e8bb95 Auto merge of #87247 - crlf0710:merge-libterm-into-libtest, r=nagisa d7cad08749d docs: GlobalAlloc: completely replace example with one that works e0a8a50a454 replace Option combinators with try block 1ca0e9be506 Add comments explaining the unix command-line argument support. 2d2b7a4fe9f Rollup merge of #87236 - sunfishcode:avoid-locking-args, r=joshtriplett aad7349e462 Rollup merge of #87227 - bstrie:asm2arch, r=Amanieu 9092fc8385d Auto merge of #87196 - oxalica:option-insert-must-use, r=joshtriplett f0299e62883 Move asm! and global_asm! to core::arch d98d6af8e18 better support for running libcore and liballoc tests with Miri 6f5f7694d38 Remove unused stuff and switch to pub(crate) whenever possible. e03900614bf Fix compilation errors. 16aff55486c Move `library/term/src` to `library/test/src/term/`. 1a39710f2f1 Rollup merge of #87183 - RalfJung:option-doctest, r=jyn514 b3aa0e1dad4 Rollup merge of #87170 - xFrednet:clippy-5393-add-diagnostic-items, r=Manishearth,oli-obk f3971012731 x.py fmt 8cabcac481f Remove an unnecessary `Mutex` around argument initialization. a4d0538595a Remove args cleanup code. 0323e6a9dc2 Auto merge of #86761 - Alexhuszagh:master, r=estebank 6102fc36877 Changed dec2flt to use the Eisel-Lemire algorithm. 735e4e73571 Auto merge of #87195 - yaahc:move-assert_matches-again, r=oli-obk 36ac33f86e3 i sweat to god 57dc07adf4f pls this time 11a4675bba6 implement ConstSizeIntoIterator for &[T;N] in addition to [T;N] ea88e9dfa94 Rollup merge of #87174 - inquisitivecrystal:array-map, r=kennytm 37f89d974c3 rename specializing trait to ConstSizeIntoIterator ed178ebc007 Mark `Option::insert` as must_use dbbafd5e05d rename assert_matches module b398d3b1197 fix typo in compile_fail doctest 9d61f068309 Rollup merge of #87138 - dhwthompson:fix-range-invariant, r=JohnTitor dfd83658343 Stabilize `into_parts()` and `into_error()` 2e2abc592d5 Stabilize `[T; N]::map()` 885bd752c09 Added diagnostic items to structs and traits for Clippy 69d368bda7b Added diagnostic items to functions for Clippy c18b3e4fb43 implement TrustedLen for Flatten/FlatMap if the U: IntoIterator == [T; N] aa43c4ad48a Allow leading pipe in `matches!()` patterns. 249e403be78 Rollup merge of #87127 - poliorcetics:ptr-rotate-safety, r=scottmcm 6a8098d88e9 Rollup merge of #87081 - a1phyr:add_wasi_ext_tracking_issue, r=dtolnay f4b87bb73e6 Rollup merge of #86947 - m-ou-se:assert-matches-to-submodule, r=yaahc 008e03db39d Added Arc::try_pin 616beef680d Make wrapping_neg() use wrapping_sub(), #[inline(always)] d259d224486 Auto merge of #86765 - cuviper:fuse-less-specialized, r=joshtriplett 99ed1b56202 Correct invariant documentation for `steps_between` a8648c81e61 Rollup merge of #87027 - petrochenkov:builderhelp, r=oli-obk d96077f8ced Add safety comments in private core::slice::rotate::ptr_rotate function 4d9b37caeb7 Auto merge of #87118 - JohnTitor:rollup-8ltidsq, r=JohnTitor 2f35a334433 DOC: Add missing arguments to hypothetical code for step_by() a00023fccff Auto merge of #86211 - tlyu:option-result-overviews, r=joshtriplett fd01b71da9d Rollup merge of #87099 - JohnTitor:upgrade-cc-crate, r=alexcrichton 6637f5c3e94 Rollup merge of #87090 - ssomers:btree_comments, r=the8472 5164db72186 expand: Support helper attributes for built-in derive macros 21e227e104a Upgrade `cc` crate to 1.0.69 a2f0846496d add Stdin::lines, Stdin::split forwarder methods c95979ae1bd Rollup merge of #86846 - tlyu:stdio-locked-tracking, r=joshtriplett 8cb9403a73d Rollup merge of #86811 - soerenmeier:remove_remaining, r=yaahc 7c25f4cfc74 Rollup merge of #86344 - est31:maybe-uninit-extra, r=RalfJung 49a729eab99 Make BTreeSet::split_off name elements like other set methods do eb5848c8a05 Use the write function in some more places 324d8b71371 Add tracking issue number to `wasi_ext` 64933603c84 Rollup merge of #87045 - jhpratt:fix-tracking-issue, r=jyn514 6577b40d699 Rollup merge of #86951 - cyberia-ng:fp-negative-zero-sqrt-docs, r=Mark-Simulacrum 8352c7ff4b4 Add test for the fix 4fe6a58107f Fix #85462 by adding a marker flag 1af5fe31fde Add example with a bunch of leading zeos bce8a6596a1 Simplify leading zero checks 3ecebd9ad60 Optimize fmt::PadAdapter::wrap 077db217f63 Fix tracking issue for `bool_to_option` e8f1fa587bd Auto merge of #85953 - inquisitivecrystal:weak-linkat-in-fs-hardlink, r=joshtriplett d548450256c Make tests pass on old macos 1474ea5fa6f Change `weak!` and `linkat!` to macros 2.0 dc54535982a Rollup merge of #87011 - RalfJung:thread-id-supply-shortage, r=nagisa fed01bf6520 rename variable 05201d90348 avoid reentrant lock acquire when ThreadIds run out 246c8918155 Update docs for `fs::hard_link` 41f34570c0e Fix linker error b3db53451a5 Reject too-long IPs quicker 226b193324d Clarify docs on what IPv4 octal addresses are 135ecb72d7e Debug formatting of raw_arg() 5902aa9215a Use AsRef in CommandExt for raw_arg dc72ae0e94d Unescaped command-line arguments for Windows f0a79f116a3 Test escaping of trialing slashes in Windows command-line args 5123d5d1e8f Auto merge of #85828 - scottmcm:raw-eq, r=oli-obk 891ff4bd98a Auto merge of #86904 - m-ou-se:prelude-collision-check-trait, r=nikomatsakis e01077a6ab1 PR feedback 15e180029e3 Stop generating `alloca`s+`memcmp` for simple array equality 91b17a1d16f Move the `PartialEq` and `Eq` impls for arrays to a separate file ec8637c79e7 BTree: lazily locate leaves in rangeless iterators 6de1af8cb1b Auto merge of #86930 - tspiteri:int_log10, r=kennytm c3954d4b829 Disallow octal zeros in IPv4 addresses 9ebebb2c38c Auto merge of #86982 - GuillaumeGomez:rollup-7sbye3c, r=GuillaumeGomez 9b98d91fe49 Rollup merge of #86789 - janikrabe:btreeset-drainfilter-doc, r=kennytm 11012b06837 Rollup merge of #86726 - sexxi-goose:use-diagnostic-item-for-rfc2229-migration, r=nikomatsakis bfb6e7eafea Auto merge of #86520 - ssomers:btree_iterators_checked_unwrap, r=Mark-Simulacrum 378c6a9e7e7 Auto merge of #86823 - the8472:opt-chunk-tra, r=kennytm e10d71d80eb Rollup merge of #86956 - cuviper:unalias-every, r=m-ou-se 64eb5d7b52e Rollup merge of #86955 - Swordelf2:patch-1, r=cuviper 04dc679d51d Rollup merge of #86917 - notriddle:notriddle/from-try-reserve-error, r=JohnTitor 67cd025f72f Move [debug_]assert_matches to mod {core, std}::assert. 4547921fd6a Revert "Add "every" as a doc alias for "all"." 378e8e22e83 Fix typo in `ops::Drop` docs 254a893cb70 Clarify behaviour of f64 and f32::sqrt when argument is negative zero ec85c32a20c Check FromIterator trait impl in prelude collision check. 52b0f15ceae Add documentation for `Ipv6MulticastScope` 45c1ad217d6 special case for integer log10 595feca9395 test integer log10 values close to all powers of 10 a857516e1f0 Rollup merge of #86916 - godmar:@godmar/thread-yield-documentation-fix, r=joshtriplett f76ac1e865a Rollup merge of #86906 - juniorbassani:update-sync-docs, r=yaahc 203dbc9ef52 Rollup merge of #86880 - m-ou-se:test-manuallydrop-clone-from, r=Mark-Simulacrum 34f393c33b5 Rollup merge of #86717 - rylev:rename, r=nikomatsakis a106833bac9 Rollup merge of #80918 - yoshuawuyts:int-log2, r=m-ou-se e20c010a696 Add doc comment for `impl From for TryReserveError` 6c30c66002e rewrote documentation for thread::yield_now() 5369b93508c add Ord tests for Path comparisons a36eee52b45 optimize {Path,PathBuf,Components}::{cmp,partial_cmp} for shared prefixes fd4a9964a13 Add s to non_fmt_panic e94975bea5a Change or_patterns_back_compat lint to rust_2021_incompatible_or_patterns 1d9e2ff2078 Fix typo in core::sync::atomic::compiler_fence example 66e4a49b88c Replace deprecated compare_and_swap by compare_exchange_weak in core::sync::atomic::fence example 1fe80c7455a Stabilize Vec::shrink_to c6085700d98 Improve env var getter docs 3f3f1b5d95b Make `getenv` return an Option instead of a Result 4e3978a2ca4 Change env var getters to error recoverably 8d97d43a4bc use Eq::eq instead of Iterator::eq implementation a3c2f8c82ca Rollup merge of #86852 - Amanieu:remove_doc_aliases, r=joshtriplett f95613e41a6 Rollup merge of #86794 - inquisitivecrystal:seek-rewind, r=m-ou-se a7858e88bc4 Rollup merge of #85377 - ijackson:abort-docs, r=m-ou-se 5a0924bf8da Rollup merge of #83581 - arennow:dir_entry_ext_unix_borrow_name, r=m-ou-se b56527353ab Auto merge of #84560 - cjgillot:inline-iter, r=m-ou-se 05eae9bb1f4 Test ManuallyDrop::clone_from. 633d628a3a3 s/die/terminate/ in abort documentation. a87b6b5f31d Use american spelling for behaviour 0c4acdee7e7 Talk about "terminate" rather than "die" 3e28743ac36 Talk about invalid instructions rather than debug traps dac33e08724 abort docs: Document buffer non-flushing 745b1e06a4e abort docs: Do not claim that intrinsics::abort is always a debug trap 3b24ed309d4 aborts: Clarify documentation and comments 7bf261422f2 Auto merge of #86875 - JohnTitor:rollup-fuefamw, r=JohnTitor 2320c07da7b Rollup merge of #86864 - GuillaumeGomez:example-write-vectored, r=JohnTitor 965dfd7ddb6 Rollup merge of #86858 - JohnTitor:stabilize-string-drain-as-str, r=Mark-Simulacrum 96e8f9829b9 Auto merge of #86598 - yoshuawuyts:poll-method-docs, r=JohnTitor d4e317b3fb3 Add missing code example for Write::write_vectored 73ba49843f3 Auto merge of #86048 - nbdd0121:no_floating_point, r=Amanieu 101d3dc2470 Auto merge of #86213 - jhpratt:stabilize-const-from_utf8_unchecked, r=JohnTitor 75d4f2f8551 Stabilize `string_drain_as_str` 1f947e2be86 Auto merge of #86833 - crlf0710:remove-std-raw-mod, r=SimonSapin 94d79eb34b6 Auto merge of #85270 - ChrisDenton:win-env-case, r=m-ou-se 7d9c976e478 stdio_locked: add tracking issue 07ffe747850 Auto merge of #86810 - ojeda:alloc-gate, r=dtolnay 0b32e1b3983 Auto merge of #86799 - tlyu:stdio-locked, r=joshtriplett 109defb2c2b Remove the deprecated `core::raw` and `std::raw` module. 7b1246c4612 Auto merge of #79965 - ijackson:moreerrnos, r=joshtriplett c7476493fb9 Move `os_str_bytes` to `sys::unix` and reuse it on other platforms. 172096d2688 optimize chunks and chunks_mut d3928ce6ed6 stdio_locked: updates based on feedback 8783b1abb21 Rollup merge of #86807 - tversteeg:patch-1, r=bjorn3 5c304686aa2 Rollup merge of #86803 - xfix:remove-unnecessary-ampersand-from-command-args-calls, r=joshtriplett 7bfcad014aa Rollup merge of #86308 - bstrie:intrinsafe, r=JohnTitor 907c2ffd430 Rollup merge of #85001 - CDirkx:bytestring, r=JohnTitor 1dcc5d4c82c Rollup merge of #84029 - drahnr:master, r=petrochenkov be85bb6c9a6 Remove unstable `Cursor::remaining` 6d8d59f69c6 alloc: `no_global_oom_handling`: disable `new()`s, `pin()`s, etc. deff9733b49 Auto merge of #86806 - GuillaumeGomez:rollup-pr5r37w, r=GuillaumeGomez 426cc2f3021 Fix double import in wasm thread 62c9dd62e1c Rollup merge of #86797 - inquisitivecrystal:bound-cloned, r=jyn514 4e1459819ef Rollup merge of #86714 - iwahbe:add-linked-list-cursor-end-methods, r=Amanieu b8192b5b368 Auto merge of #85746 - m-ou-se:io-error-other, r=joshtriplett fcbf7d17472 add track_path::path fn for proc-macro usage 0b4b564fd54 add owned locked stdio handles bb4a45ea25e Stabilize `Bound::cloned()` b36ccd28434 Stabilize `Seek::rewind` e92a28e9764 Rollup merge of #86785 - lf-:dead-code, r=Mark-Simulacrum 2ca71bb6da3 Rollup merge of #86783 - mark-i-m:mutex-drop-unsized, r=Xanewok fa13c024fd2 Document iteration order of `retain` functions bb30650ea94 Update BTreeSet::drain_filter documentation d5c305c1b5b Implement changes suggested by @Amanieu 2a6a6e7bcf0 proc_macro/bridge: Remove dead code Slice type 7ba31d32b73 Make the specialized Fuse still deal with None 66c9f9417af Remove "length" doc aliases 5acf3b9be1d Remove "delete" doc aliases 9eee381b1f6 Remove alloc/malloc/calloc/realloc doc aliases 75113ebe5e0 alloc: `RawVec::shrink` can be in `no_global_oom_handling`. e8ba216ef03 impl Default, Copy, Clone for std::io::Sink and Empty 3f81861337a Rename variable 1ca2fcaff40 Use diagnostic items to check for Send, UnwindSafe and RefUnwindSafe traits 4ef98c4cbec Remove lang items Send, UnwindSafe and RefUnwindSafe 9ce27cfa3b1 Add non-mutable methods to `Cursor` c43d8511b50 add head/tail methods to linked list mutable cursor 5aaee1c9f14 Update to new bootstrap compiler d344a0d44f3 Auto merge of #82624 - ojeda:rwlock-example-deadlock, r=JohnTitor 89311b647af Auto merge of #86655 - jonas-schievink:const-arguments-as-str, r=kennytm 92dbaa1e3c1 Add reference to tracking issue #86302 for const_ptr_write 67fe63986f9 Add reference to issue for const_intrinsic_copy in ptr::write c29a2d7363f Revert "Revert tests added by PR 81167." 3734e3da413 Revert "Revert effects of PRs 81167 and 83091." 5a5b18d2900 Make `fmt::Arguments::as_str` unstably const 4a4846ae945 Auto merge of #86586 - Smittyvb:https-everywhere, r=petrochenkov e10044d62e5 Auto merge of #86637 - ehuss:spellings, r=dtolnay a8e661e5a46 Fix a few misspellings. 58927842831 Add Integer::{log,log2,log10} variants 6470189d7b1 Rollup merge of #86592 - jhpratt:non_exhaustive, r=JohnTitor 397f5af5d0d Auto merge of #86151 - scottmcm:simple-hash-of, r=joshtriplett 404091856e9 Fix grammar mistake 721b2b87c92 Add another example 5e1c2649d06 Document the various methods of `core::task::Poll` d8f907635dc Auto merge of #86467 - ChrisDenton:win-env-clear, r=JohnTitor 4dc126057a3 Partially stabilize `const_slice_first_last` ef1dd77601c Test that `env_clear` works on Windows e8bbc46e21c Use `hash_one` to simplify some other doctests d3ea074eca9 Add tracking issue and rename to hash_one 47cdc570bd8 Add `BuildHasher::hash_of` as unstable edf6766f2f8 Use `#[non_exhaustive]` where appropriate b3e942a7d90 Rollup merge of #86415 - Kmeakin:iterator-associativity-docs, r=dtolnay d8b05013a1b Use HTTPS links where possible 36263a9c2bf Add `core::stream::from_iter` 179478e4545 Auto merge of #86386 - inquisitivecrystal:better-errors-for-display-traits-v3, r=estebank bed788528d1 Rollup merge of #86521 - the8472:add-footgun-comments, r=RalfJung 1395cfcbd27 Add comments around code where ordering is important due for panic-safety c3764dca564 Auto merge of #84910 - eopb:stabilize_int_error_matching, r=yaahc 4cf2edd2731 postpone stabilizaton by one release 68bb31c022a Change Debug unimplemented message per request 27309d8516a Auto merge of #86527 - JohnTitor:rollup-cbu78g4, r=JohnTitor 35b846d2f52 Rollup merge of #86367 - m-ou-se:fix-abs-comment, r=scottmcm af67574a885 Rollup merge of #86114 - JDuchniewicz:feat/panic-frame-fmt, r=yaahc 201f1c1821d Rollup merge of #86037 - soerenmeier:cursor_remaining, r=yaahc 8a5adc5ee17 Rollup merge of #85182 - CDirkx:available_concurrency, r=JohnTitor 50bd6e56c02 Rollup merge of #85054 - jethrogb:jb/sgx-inline-asm, r=Amanieu 5061e2dbb20 Auto merge of #86383 - shamatar:slice_len_lowering, r=bjorn3 fba66b3dfcf BTree: consistently avoid unwrap_unchecked in iterators b3e445672ff Rollup merge of #86495 - r00ster91:patch-11, r=petrochenkov e4899fe6f2f Merge `sys_common::bytestring` into `os_str_bytes` 8c1e3abde0b Use `Unsupported` on platforms where `available_concurrency` is not implemented. dce516529aa Move `available_concurrency` implementation to `sys` c003213b2c4 Auto merge of #86502 - JohnTitor:rollup-wge0f3x, r=JohnTitor 4a64a8c06ff Rollup merge of #86452 - the8472:fix-zip-drop-safety, r=m-ou-se 42b776a2842 Rollup merge of #85637 - RalfJung:partial-ord, r=m-ou-se 9e829fff3d3 Auto merge of #85980 - ssomers:btree_cleanup_LeafRange, r=Mark-Simulacrum 7aa4696246f Improve documentation 80933a5c49b Auto merge of #84967 - CDirkx:os_str_ext, r=m-ou-se 0e0188cd2e3 Squashed implementation of the pass 1ee6150deb8 Add documentation/example to Extend impl b54f7c28487 disable test on platforms that don't support unwinding a557255aad8 Add comment to `std::os::unix::ffi::os_str` explaining that the module is reused on other platforms. 555c6db6d47 Make `os_str_bytes::{Buf, Slice}` `pub` and `repr(transparent)` 2dcbfc426ad Move `OsStringExt` and `OsStrExt` to `std::os` 8c46e3a26a3 Auto merge of #86463 - fee1-dead:fixed-encode_wide, r=m-ou-se 20732dd869d Automatic exponential formatting in Debug dc28c0e9a71 Auto merge of #86433 - paolobarbolini:string-overlapping, r=m-ou-se 807f63fff36 Auto merge of #86034 - nagisa:nagisa/rt-soundness, r=m-ou-se 50be6bfffaa Clarify that certain intrinsics are not unsafe 9f52ec71756 Remove `Ipv4Addr::is_ietf_protocol_assignment` 7cd74ceea12 Change entry point to 🛡️ against 💥 💥-payloads d5a98011ef7 Windows: Fix `Command::env_clear` so it works 63c7491c463 Auto merge of #86426 - hi-rustin:rustin-patch-lint-warn, r=Aaron1011 d5704629a35 Account for self.extra in size_hint for EncodeWide 951637c39db Rollup merge of #86453 - akiselev:patch-1, r=dtolnay acb1466c8e7 Rollup merge of #86397 - Eosis:alter-cell-docs, r=JohnTitor 77bfe1eda25 Rollup merge of #86359 - fee1-dead:f64-junit-formatter, r=JohnTitor 5291e2001c9 Rollup merge of #86136 - m-ou-se:proc-macro-open-close-span, r=m-ou-se f02a5822a94 Fixed typo `BorroeError` => `BorrowError` in RefCell docs 8507bdee22b fix panic-safety in specialized Zip::next_back 6ea6d7c94f3 Auto merge of #85815 - YuhanLiin:buf-read-data-left, r=m-ou-se 830f38cff4e Auto merge of #85747 - maxwase:path-symlinks-methods, r=m-ou-se 599235f920e Add `IpAddr::is_benchmarking` ed9ee19efff Add `Ipv6Addr::is_benchmarking` f3ff7f74384 Use `copy_nonoverlapping` to copy `bytes` in `String::insert_bytes` 9a1bdc0bbe8 Lint for unused borrows as part of UNUSED_MUST_USE ebf14486405 Rollup merge of #86357 - de-vri-es:simplify-repeated-cfg-ifs, r=m-ou-se 67f0fa84675 Rollup merge of #86202 - a1phyr:spec_io_bytes_size_hint, r=m-ou-se ad41e2af1cd Rollup merge of #85925 - clarfonthey:lerp, r=m-ou-se c0b7fe9e471 Document associativity of iterator folds. 223f89c6753 Rely on libc for correct integer types in os/unix/net/ancillary.rs. 9e78e287ed4 Rollup merge of #86389 - kpreid:sum, r=scottmcm a4728920262 Rollup merge of #85970 - jsha:remove-methods-implementors, r=GuillaumeGomez f8931b7e113 Rollup merge of #85802 - Thomasdezeeuw:ioslice-advance, r=m-ou-se 38c032e0367 Rollup merge of #85663 - fee1-dead:document-arc-from, r=m-ou-se 9fec41ef530 Alter std::cell::Cell::get_mut documentation 4495c5ca4b3 Fix comment about rustc_inherit_overflow_checks in abs(). 91d39e555cd Add doc(hidden) to all __iterator_get_unchecked d43eb025799 Make `sum()` and `product()` hyperlinks refer to `Iterator` methods. 3dc507ec3a2 Rollup merge of #86372 - snoyberg:patch-1, r=jonas-schievink 38747f7ea74 Rollup merge of #86141 - amorison:link-ref-in-doc-dyn-keyword, r=kennytm 481cf88bcce Rollup merge of #86140 - scottmcm:array-hash-facepalm, r=kennytm ef4a271bd21 Use as_secs_f64 in JunitFormatter b62b26f5a80 Typo correction: s/is/its 98d69ab66c5 Auto merge of #86179 - the8472:revere-path-cmp, r=kennytm cdee78ce71a Improve errors for missing Debug and Display impls 375282d316d Rollup merge of #86209 - tlyu:option-doc-typos, r=JohnTitor 372a2ea32e3 Rollup merge of #86200 - qwerty01:clone-doc-update, r=JohnTitor a67c3ac20f1 Auto merge of #85820 - CDirkx:is_unicast_site_local, r=joshtriplett de6338fd293 Split MaybeUninit::write into new feature gate and stabilize it bb2c96f4ef6 Auto merge of #85406 - VillSnow:integrate_binary_search, r=JohnTitor d620f1c00aa Rollup merge of #86314 - Veykril:patch-2, r=JohnTitor 07db29bf41b Rollup merge of #86294 - m-ou-se:edition-prelude-modules, r=joshtriplett f750f5d8c49 Rollup merge of #86220 - est31:maybe-uninit-extra, r=RalfJung 01f9af9c2f2 Rollup merge of #85792 - mjptree:refactor-windows-sockets, r=JohnTitor 5eb86dfe6db Rollup merge of #85608 - scottmcm:stabilize-control-flow-enum-basics, r=m-ou-se fc0454980a4 Rollup merge of #82179 - mbartlett21:patch-5, r=joshtriplett dc08f9b9e54 Rollup merge of #80269 - pickfire:patch-4, r=joshtriplett bdd5687eb09 Update keyword_docs.rs 85ae163648d Mention nested unzip in its documentation a27e554ca55 Stabilize {std, core}::prelude::rust_*. 7accc07a20b Auto merge of #86273 - JohnTitor:stabilize-maybe-uninit-ref, r=RalfJung 3d9943811a3 Improve maybe_uninit_extra docs 6b00da3ec94 Auto merge of #85758 - petertodd:2021-revert-manuallydrop-clone-from, r=m-ou-se ed5f6a98f7e run tidy 537afc1c554 stabilize `int_error_matching` eca0793be7c Stabilize `maybe_uninit_ref` 910a63b3b4f Auto merge of #86233 - JohnTitor:stabilize-simd-x86-bittest, r=Amanieu 0786e4e3ce2 Merge branch 'master' of https://github.com/rust-lang/rust 6d442f1cede Update `stdarch` submodule to stabilize `simd_x86_bittest` feature 9c9219075e1 Auto merge of #82703 - iago-lito:nonzero_add_mul_pow, r=m-ou-se 021ef442308 Remove "generic type" in boxed.rs 8ccfe751e3d Stabilize `str::from_utf8_unchecked` as `const` f890596f3e8 Auto merge of #86204 - alexcrichton:wasm-simd-stable, r=Amanieu 34a02c3fb32 std: Stabilize wasm simd intrinsics 768a8ac63e2 Auto merge of #85630 - gilescope:to_digit_speedup3, r=nagisa 08b65c87bea Specialize `io::Bytes::size_hint` for more types 250660a0e95 Updates `Clone` docs for `Copy` comparison. ade2592c963 Rollup merge of #86111 - spookyvision:master, r=JohnTitor 3ebc642e75b Rollup merge of #86051 - erer1243:update_move_keyword_docs, r=Mark-Simulacrum e675a72f786 Updated code examples and wording REVERT: 78fc550584d Auto merge of #133247 - GuillaumeGomez:reduce-integer-display-impl, r=workingjubilee REVERT: db5c2c6a18f Rollup merge of #132982 - suaviloquence:2-doc-changed-alloc-methods, r=Mark-Simulacrum REVERT: 117ad4f17b0 Rollup merge of #132533 - SUPERCILEX:patch-4, r=Mark-Simulacrum REVERT: e2aa7c108dc fix `Allocator` method names in `alloc` free function docs REVERT: 6b141ee1007 Rollup merge of #133298 - n0toose:remove-dir-all-but-not-paths, r=Noratrieb REVERT: e3691db3d70 Rollup merge of #133260 - compiler-errors:deref, r=fee1-dead REVERT: 895f290b058 Rollup merge of #132730 - joboet:after_main_sync, r=Noratrieb REVERT: 6ffa4556f46 Rollup merge of #133389 - eduardosm:stabilize-const_float_methods, r=RalfJung REVERT: f4139353bf6 Rollup merge of #133301 - GuillaumeGomez:add-example-wrapping-neg, r=workingjubilee REVERT: 6112cfd51ba Auto merge of #132611 - compiler-errors:async-prelude, r=ibraheemdev REVERT: 23a5a0e1f54 Auto merge of #132597 - lukas-code:btree-plug-leak, r=jhpratt REVERT: f0b0942f402 Constify Deref and DerefMut REVERT: d05e8e8e9fb Auto merge of #133379 - jieyouxu:rollup-00jxo71, r=jieyouxu REVERT: 641c1ae3978 Stabilize `const_float_methods` REVERT: 256c54db000 Auto merge of #133377 - jieyouxu:rollup-n536hzq, r=jieyouxu REVERT: dff533fc1d3 Improve code by using `unsigned_abs` REVERT: a850f7c8760 Rollup merge of #133237 - fee1-dead-contrib:constadd, r=compiler-errors REVERT: 99741dd6dcb Rollup merge of #133332 - bjoernager:const-array-as-mut-slice, r=jhpratt REVERT: 9a152e2565f Rollup merge of #131505 - madsmtm:darwin_user_temp_dir, r=dtolnay REVERT: a12c8386f5b Auto merge of #132994 - clubby789:cc-bisect, r=Kobzol REVERT: 6548ad8c627 Auto merge of #133360 - compiler-errors:rollup-a2o38tq, r=compiler-errors REVERT: a4f797ed7de Rollup merge of #133264 - lolbinarycat:os-string-truncate, r=joboet REVERT: a9398015dc4 Auto merge of #132329 - compiler-errors:fn-and-destruct, r=lcnr REVERT: 30aa6db150e Add code example for `wrapping_neg` method for signed integers REVERT: bc77567dc6b Deduplicate checking drop terminator REVERT: 6f3ec5caf86 Gate const drop behind const_destruct feature, and fix const_precise_live_drops post-drop-elaboration check REVERT: fb6f0c2e982 Auto merge of #133339 - jieyouxu:rollup-gav0nvr, r=jieyouxu REVERT: c792ef3e01a Rollup merge of #133337 - ColinFinck:thread-scoped-fix-typo, r=joboet REVERT: cfed1c696dd Rollup merge of #133330 - RalfJung:close, r=the8472 REVERT: e26edf01cab Rollup merge of #133313 - thesummer:fix-arc4random, r=cuviper REVERT: 90a85ef0042 Rollup merge of #133288 - bjoernager:const-array-each-ref, r=jhpratt REVERT: 4e6f154dba6 Rollup merge of #133238 - heiher:loong-stdarch-rexport, r=Amanieu REVERT: 23a1b31cfa4 Auto merge of #130867 - michirakara:steps_between, r=dtolnay REVERT: 9693572a6e3 Fix typo in `std::thread::Scope::spawn` documentation. REVERT: b4a50679016 Mark '<[T; N]>::as_mut_slice' as 'const'; REVERT: b6b40efcac5 library: update comment around close() REVERT: 6ce7e79948e Don't try to use confstr in Miri REVERT: 40d6e2ca941 Auto merge of #129238 - umgefahren:stabilize-ipv6-unique-local, r=dtolnay REVERT: 276c0fc3fd1 distinguish overflow and unimplemented in Step::steps_between REVERT: 8be952bbbdf Use arc4random of libc for RTEMS target REVERT: 4583ddef0cd Mention that std::fs::remove_dir_all fails on files REVERT: 4f6ca37539a Mark and implement 'each_ref' and 'each_mut' in '[T; N]' as const; REVERT: ec220b6b368 constify `Add` REVERT: 3c558bf870d Rollup merge of #131736 - hoodmane:emscripten-wasm-bigint, r=workingjubilee REVERT: 38d4c11c3ff implement OsString::truncate REVERT: 4fd2c8db81e Rollup merge of #133226 - compiler-errors:opt-in-pointer-like, r=lcnr REVERT: 3f03a0f3fcd Rollup merge of #130800 - bjoernager:const-mut-cursor, r=joshtriplett REVERT: eea7e230c2b Rollup merge of #129838 - Ayush1325:uefi-process-args, r=joboet REVERT: 8b4995aad87 Make PointerLike opt-in as a trait REVERT: f74b38aa2b1 Reduce integer `Display` implementation size REVERT: 2f179d1a7c9 Stabilize const_pin_2 REVERT: b2dc297e863 re-export `is_loongarch_feature_detected` REVERT: e26c298e75c Rollup merge of #132732 - gavincrawford:as_ptr_attribute, r=Urgau REVERT: d6ee9dbe8b0 Rollup merge of #133183 - n0toose:improve-remove-dir-docs, r=joboet REVERT: 40735d31322 Rollup merge of #125405 - m-ou-se:thread-add-spawn-hook, r=WaffleLapkin REVERT: 6c20348f356 Rollup merge of #123947 - zopsicle:vec_deque-Iter-as_slices, r=Amanieu REVERT: 2089cb3188c Update doc comments for spawn hook. REVERT: c02090d6a3a Address review comments. REVERT: 79bffa90cfe Fix tracking issue. REVERT: 3eff64c78b0 Add tracking issue. REVERT: 15bac4f115e Use Send + Sync for spawn hooks. REVERT: a42af062212 Add thread Builder::no_hooks(). REVERT: 49ac15b192b Update thread spawn hooks. REVERT: 2cc4b2ef6d9 Use add_spawn_hook for libtest's output capturing. REVERT: 24a0765dd03 Add std::thread::add_spawn_hook. REVERT: 50ac72542be Correct comments concerning updated dangling pointer lint REVERT: cdf54869ec6 Auto merge of #133205 - matthiaskrgr:rollup-xhhhp5u, r=matthiaskrgr REVERT: 543667a49e3 Rollup merge of #133200 - RalfJung:miri-rwlock-test, r=tgross35 REVERT: 7430eb407e2 ignore an occasionally-failing test in Miri REVERT: 607b493008b Rollup merge of #133182 - RalfJung:const-panic-inline, r=tgross35 REVERT: e6cd122d981 Rollup merge of #132758 - nnethercote:improve-get_key_value-docs, r=cuviper REVERT: a3c95972a3b Mention std::fs::remove_dir_all in std::fs::remove_dir REVERT: bd5c1426568 Bump `stdarch` to the latest master REVERT: e84f865601d const_panic: inline in bootstrap builds to avoid f16/f128 crashes REVERT: 05fecb95df2 std: allow after-main use of synchronization primitives REVERT: c1beb25002a Auto merge of #133160 - jhpratt:rollup-wzj9q15, r=jhpratt REVERT: ce80c9f20de Rollup merge of #133145 - kornelski:static-mutex, r=traviscross REVERT: f385ac21fee Auto merge of #128219 - connortsui20:rwlock-downgrade, r=tgross35 REVERT: 86151abcc67 rename rustc_const_stable_intrinsic -> rustc_intrinsic_const_stable_indirect REVERT: a33f889e959 Improve `{BTreeMap,HashMap}::get_key_value` docs. REVERT: 15e6fc0a5db Document alternatives to `static mut` REVERT: 1cd1dd7c56f Auto merge of #120370 - x17jiri:likely_unlikely_fix, r=saethlin REVERT: e475f40115f Likely unlikely fix REVERT: ddcabfe85ff Rollup merge of #133126 - ohno418:fix-String-doc, r=jhpratt REVERT: e4eff6a5a78 Rollup merge of #133116 - RalfJung:const-null-ptr, r=dtolnay REVERT: 16e6d209ccb alloc: fix `String`'s doc REVERT: e4fb96229e0 clean up const stability around UB checks REVERT: ee78601c3ce stabilize const_ptr_is_null REVERT: 1e4a9ee22cd Rollup merge of #132449 - RalfJung:is_val_statically_known, r=compiler-errors REVERT: 1dfe94c308a Rollup merge of #131717 - tgross35:stabilize-const_atomic_from_ptr, r=RalfJung REVERT: 70326e8f708 reduce threads in downgrade test REVERT: d58e4f2d08c fix `DOWNGRADED` bit unpreserved REVERT: 5d683160ada fix memory ordering bug + bad test REVERT: 0604b8ffc1d add safety comments for queue implementation REVERT: 00255e627b7 add `downgrade` to `queue` implementation REVERT: 40256c63003 modify queue implementation documentation REVERT: f8041644f07 add `downgrade` to `futex` implementation REVERT: 572adedb6a0 add simple `downgrade` implementations REVERT: 48bcf09d8d7 add `downgrade` method onto `RwLockWriteGuard` REVERT: 5416aef6a86 add `RwLock` `downgrade` tests REVERT: 40109807569 Rollup merge of #133050 - tgross35:inline-f16-f128, r=saethlin REVERT: 2ee4159af2a Rollup merge of #133048 - cyrgani:ptr-doc-update, r=Amanieu REVERT: e1448dee6d0 Rollup merge of #133019 - sorairolake:add-missing-period-and-colon, r=tgross35 REVERT: b1d31d297f2 Rollup merge of #132984 - sunshowers:pipe2, r=tgross35 REVERT: 8cef1ef708e Rollup merge of #132977 - cberner:fix_solaris, r=tgross35 REVERT: daa9c433370 Rollup merge of #132790 - aDotInTheVoid:ioslice-asslice-rides-again, r=cuviper REVERT: cdb5ff5f6fe Pass `f16` and `f128` by value in `const_assert!` REVERT: 60ef4797595 use `&raw` in `{read, write}_unaligned` documentation REVERT: d2983fffb15 Auto merge of #132709 - programmerjake:optimize-charto_digit, r=joshtriplett REVERT: 918cc8d59c8 Rollup merge of #133027 - no1wudi:master, r=jhpratt REVERT: 25f55123bf2 Auto merge of #133026 - workingjubilee:rollup-q8ig6ah, r=workingjubilee REVERT: d8de2ccfc55 Fix a copy-paste issue in the NuttX raw type definition REVERT: c06bb349936 Rollup merge of #133008 - onur-ozkan:update-outdated-comment, r=jieyouxu REVERT: 8eaea39049a Rollup merge of #133004 - cuviper:unrecover-btree, r=ibraheemdev REVERT: 81a191a826e Rollup merge of #133003 - zachs18:clonetouninit-dyn-compat-u8, r=dtolnay REVERT: e3e5e358c71 Rollup merge of #132907 - BLANKatGITHUB:intrinsic, r=saethlin REVERT: f57853bc421 Rollup merge of #131304 - RalfJung:float-core, r=tgross35 REVERT: 7bc04367d32 Auto merge of #122770 - iximeow:ixi/int-formatting-optimization, r=workingjubilee REVERT: ce2e318c5d1 docs: Fix missing colon in methods for primitive types REVERT: 1870e9269bf docs: Fix missing period in methods for integer types REVERT: 64397743828 Auto merge of #133006 - matthiaskrgr:rollup-dz6oiq5, r=matthiaskrgr REVERT: 98dad0baf9a update outdated comment about test-float-parse REVERT: 520d4fdff72 Rollup merge of #126046 - davidzeng0:mixed_integer_ops_unsigned_sub, r=Amanieu REVERT: e3c425b74bb Auto merge of #132662 - RalfJung:const-panic-inlining, r=tgross35 REVERT: c4b77cf11ef Update core CloneToUninit tests REVERT: d4e21f55ec3 btree: simplify the backdoor between set and map REVERT: 5d61cf9a7ea Bump `cc` REVERT: 44f376ba0c7 Fix compilation error on Solaris due to flock usage REVERT: 75609d6d329 Auto merge of #132556 - clubby789:cargo-update, r=Mark-Simulacrum REVERT: 5ba28a4d89a Run `cargo update` and update licenses REVERT: 08200043034 const_panic: don't wrap it in a separate function REVERT: d30e2c0963b [illumos] use pipe2 to create anonymous pipes REVERT: 7e12686e222 Auto merge of #132883 - LaihoE:vectorized_is_sorted, r=thomcc REVERT: 02e32d70d61 Auto merge of #132972 - matthiaskrgr:rollup-456osr7, r=matthiaskrgr REVERT: 157eb1c94be Rollup merge of #132970 - tyilo:nonzero-u-div-ceil-issue, r=tgross35 REVERT: 03e52a50ac8 Rollup merge of #132966 - RalfJung:const_option_ext, r=jhpratt REVERT: 2f615a1c410 Rollup merge of #132948 - RalfJung:const_unicode_case_lookup, r=Noratrieb REVERT: f00e0913f63 Rollup merge of #132851 - chansuke:update-comment, r=thomcc REVERT: 656009854a3 Auto merge of #132870 - Noratrieb:inline-int-parsing, r=tgross35 REVERT: a0c0c40eafd Add tracking issue number to unsigned_nonzero_div_ceil feature REVERT: c2296662624 Make `CloneToUninit` dyn-compatible REVERT: 6ab50dd1c97 stabilize const_option_ext REVERT: 27fe6c7ca46 Rollup merge of #132541 - RalfJung:const-stable-extern-crate, r=compiler-errors REVERT: 7fafe990a8b stabilize const_unicode_case_lookup REVERT: c5ed62506ae Stabilize `Ipv6Addr::is_unique_local` and `Ipv6Addr::is_unicast_link_local` REVERT: e0452c9af5e adds new declaration to codegen REVERT: 33fa8701b27 Auto merge of #132943 - matthiaskrgr:rollup-164l3ej, r=matthiaskrgr REVERT: 7f12f02c6ec Rollup merge of #132914 - rcorre:cell-grammar, r=tgross35 REVERT: 300a2664117 Rollup merge of #132895 - scottmcm:generalize-nonnull-from-raw-parts, r=ibraheemdev REVERT: a461cf9310e remove no-longer-needed abs_private REVERT: 170e993a781 allow rustc_private feature in force-unstable-if-unmarked crates REVERT: 4a20245f4ad Rollup merge of #132929 - cuviper:check-alloc_zeroed, r=tgross35 REVERT: 992bbf7c46c Rollup merge of #132869 - lolbinarycat:library-fix-too_long_first_doc_paragraph, r=tgross35 REVERT: e3925fa3b42 Rollup merge of #132847 - RalfJung:addr-dont-expose, r=Mark-Simulacrum REVERT: 327a0d7814e Auto merge of #132919 - matthiaskrgr:rollup-ogghyvp, r=matthiaskrgr REVERT: 67c3c9f8bb7 Check for null in the `alloc_zeroed` example REVERT: 068537aeb72 new intrinsic declaration REVERT: b689951272e new intrinsic declaration REVERT: 16fa12ebd98 Rollup merge of #132144 - adetaylor:receiver-trait-itself, r=wesleywiser REVERT: 54f699d3ee9 Rollup merge of #120077 - SUPERCILEX:set-entry, r=Amanieu REVERT: e541a4f8204 Update dangling pointer tests REVERT: 7707584415a Tag relevant functions with #[rustc_as_ptr] attribute REVERT: b541c5aebc8 Auto merge of #132902 - matthiaskrgr:rollup-43qgg3t, r=matthiaskrgr REVERT: 2d676d49a6e Update grammar in std::cell docs. REVERT: 7325f33701c Emscripten: link with -sWASM_BIGINT REVERT: 1c482c93dbd Rollup merge of #130999 - cberner:flock_pr, r=joboet REVERT: 4dd22707d54 Auto merge of #127589 - notriddle:notriddle/search-sem-3, r=GuillaumeGomez REVERT: 0af64b63ced Generalize `NonNull::from_raw_parts` per ACP362 REVERT: 2fd9ac4a7ba vectorize slice::is_sorted REVERT: 737521c21f5 `#[inline]` integer parsing functions REVERT: b9be1ddefcb split up the first paragraph of doc comments for better summaries REVERT: f9063ff15cf Update the doc comment of `ASCII_CASE_MASK` REVERT: 57c7b80414a elem_offset / subslice_range: use addr() instead of 'as usize' REVERT: d19aa692d4e Rollup merge of #132136 - RalfJung:target-feature-abi-compat, r=Mark-Simulacrum REVERT: 6b0bd5a6630 honor rustc_const_stable_indirect in non-staged_api crate with -Zforce-unstable-if-unmarked REVERT: 070baf4fab5 Add as_slice/into_slice for IoSlice/IoSliceMut. REVERT: 978a5535d35 Rollup merge of #132778 - lolbinarycat:io-Error-into_inner-docs, r=cuviper REVERT: 6d54bfe5925 update io::Error::into_inner to acknowlage io::Error::other REVERT: 7c0a90c3ead Address review comments REVERT: ac66068ca8b Update library/std/src/sys/pal/windows/fs.rs REVERT: d90f8668e45 Auto merge of #132717 - RalfJung:rustc_safe_intrinsic, r=compiler-errors REVERT: f2bf9e65116 remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead REVERT: 2391b4b2a0d Rollup merge of #132738 - cuviper:channel-heap-init, r=ibraheemdev REVERT: 086cfefa97e mark is_val_statically_known intrinsic as stably const-callable REVERT: dffc5e73119 Rollup merge of #132696 - fortanix:raoul/rte-235-fix_fmodl_missing_symbol_issue, r=tgross35 REVERT: f14fc562a82 Rollup merge of #132639 - RalfJung:intrinsics, r=workingjubilee,Amanieu REVERT: 6d63012a62e Initialize channel `Block`s directly on the heap REVERT: 7ff251b9793 core: move intrinsics.rs into intrinsics folder REVERT: 6244f4816fe Auto merge of #132714 - mati865:update-memchr, r=tgross35 REVERT: a2eaef75de6 Rollup merge of #132715 - tabokie:fix-lazy-lock-doc, r=Noratrieb REVERT: 6a77b2121f1 Rollup merge of #132665 - tyilo:nonzero-u-div-ceil, r=joboet REVERT: 79d2063e0b6 Separate f128 `%` operation to deal with missing `fmodl` symbol REVERT: 8022523cc73 Auto merge of #132705 - kornelski:inline-repeat, r=tgross35 REVERT: df9f5db19d7 fix lazylock comment REVERT: 7a82eb5b610 Auto merge of #131888 - ChrisDenton:deopt, r=ibraheemdev REVERT: 75b9ce3b0be unpin and update memchr REVERT: 4d1c7d9526a optimize char::to_digit and assert radix is at least 2 REVERT: 95bff3e6b5c Inline str::repeat REVERT: 52c2a459546 Rollup merge of #132617 - uellenberg:fix-rendered-doc, r=cuviper REVERT: 28f7e7bbbd9 Auto merge of #131721 - okaneco:const_eq_ignore_ascii_case, r=m-ou-se REVERT: 41b7e5f7705 Auto merge of #132500 - RalfJung:char-is-whitespace-const, r=jhpratt REVERT: 4ed08bd2262 Add new unstable feature `const_eq_ignore_ascii_case` REVERT: f4e9fe4ec00 Auto merge of #132664 - matthiaskrgr:rollup-i27nr7i, r=matthiaskrgr REVERT: afc66fe29e2 Change some code blocks to quotes in rendered std doc REVERT: 2e63cbdb695 Rollup merge of #131261 - clarfonthey:unsafe-cell-from-mut, r=m-ou-se REVERT: ab6f663ed6a Auto merge of #132661 - matthiaskrgr:rollup-npytbl6, r=matthiaskrgr REVERT: 8b165db1e5c Implement div_ceil for NonZero REVERT: 6bc1b1b449e Rollup merge of #132571 - RalfJung:const_eval_select_macro, r=oli-obk REVERT: c12f4d12055 Rollup merge of #132473 - ZhekaS:core_fmt_radix_no_panic, r=joboet REVERT: bbb927540c8 Rollup merge of #132153 - bjoernager:const-char-encode-utf16, r=dtolnay REVERT: 919de701b02 add const_eval_select macro to reduce redundancy REVERT: 538f5b4cd2b Rollup merge of #132609 - NotWearingPants:patch-1, r=Amanieu REVERT: 86c6f276b21 Rollup merge of #132606 - eduardosm:char-slice-str-pattern-doc, r=tgross35 REVERT: 4660d7ebef9 most const intrinsics don't need an explicit rustc_const_unstable any more REVERT: 8eb30fe4b09 add new rustc_const_stable_intrinsic attribute for const-stable intrinsics REVERT: 792d1646c7c convert all const-callable intrinsics into the new form (without extern block) REVERT: fad7d68d1c2 docs: fix grammar in doc comment at unix/process.rs REVERT: 92bb77993bd Improve example of `impl Pattern for &[char]` REVERT: 553bb181dad Add AsyncFn* to to the prelude in all editions REVERT: 2ae24bf3e15 Fixed typo, rebased REVERT: 47f60d7ad0d Updated SAFETY comment to address underflow REVERT: 581aa8d587f Replace checked slice indexing by unchecked to support panic-free code REVERT: c5a0f6c60aa Rollup merge of #132579 - RalfJung:rustc-std-workspace-crates, r=Amanieu REVERT: 9cdbf39ba56 btree: don't leak value if destructor of key panics REVERT: 4caff135a74 Stabilise 'const_char_encode_utf16'; REVERT: 84fae7ebfee Auto merge of #132586 - workingjubilee:rollup-qrmn49a, r=workingjubilee REVERT: 95b4127a6c8 update rustc-std-workspace crates REVERT: 082b98d885c Rollup merge of #132423 - RalfJung:const-eval-align-offset, r=dtolnay REVERT: 3b40634d007 Auto merge of #132434 - tgross35:f128-tests, r=workingjubilee REVERT: 5dea8b2e41f Enable `f128` tests on all non-buggy platforms 🎉 REVERT: 2bb8ea389a4 Auto merge of #132581 - workingjubilee:rollup-4wj318p, r=workingjubilee REVERT: 83bd286345b Update `compiler_builtins` to 0.1.138 and pin it REVERT: 699702f2a6c Rollup merge of #132563 - frectonz:master, r=Amanieu REVERT: 4390c35bcce Auto merge of #123723 - madsmtm:apple-std-os, r=dtolnay REVERT: 1e8ed9064ee Auto merge of #132479 - compiler-errors:fx-feat-yeet, r=fee1-dead REVERT: 9a3b7c0f20b Rename the FIXMEs, remove a few that dont matter anymore REVERT: ed4f110b101 Auto merge of #132542 - RalfJung:const_panic, r=tgross35 REVERT: d8bca01fc2b remove const-support for align_offset REVERT: 76b866c7156 Modify `NonZero` documentation to reference the underlying integer type REVERT: 9e579641927 Rollup merge of #132511 - RalfJung:const_arguments_as_str, r=dtolnay REVERT: bfeeb7450fd Rollup merge of #132503 - RalfJung:const-hash-map, r=Amanieu REVERT: a42fc213104 Rollup merge of #132499 - RalfJung:unicode_data.rs, r=tgross35 REVERT: 0278cab1fcc Rollup merge of #132393 - zedddie16:issue-131865-fix, r=tgross35 REVERT: 714115abfb6 Rollup merge of #131377 - rick-de-water:nonzero-exp, r=dtolnay REVERT: 9789c548b8c Rollup merge of #129329 - eduardosm:rc-from-mut-slice, r=dtolnay REVERT: ff9178b1a6a add const_panic macro to make it easier to fall back to non-formatting panic in const REVERT: 9ef483bbbb0 stabilize const_arguments_as_str REVERT: 4c6593fe8f8 Auto merge of #132458 - RalfJung:rustc-const-unstable, r=Amanieu REVERT: 81b20e0a3dd Rustdoc: added brief colon explanation REVERT: 73d9f4da9a9 Add Set entry API REVERT: e883a6074c2 Add BorrowedBuf::into_filled{,_mut} methods to allow returning buffer with original lifetime REVERT: 771d77c7cfa Rollup merge of #132495 - Houtamelo:remove_unintended_link, r=jieyouxu REVERT: d99f3cfc04b Rollup merge of #132493 - Houtamelo:doc_type-ref_html-tag, r=jieyouxu REVERT: e24475c97e0 Rollup merge of #132482 - lukas-code:stab-attrs, r=Noratrieb REVERT: 261c5b998ad remove const_hash feature leftovers REVERT: d515da6678b const_with_hasher test: actually construct a usable HashMap REVERT: 11dc6c388d9 make char::is_whitespace unstably const REVERT: 1a481fd9e01 unicode_data.rs: show command for generating file REVERT: 3a5b026c04a get rid of a whole bunch of unnecessary rustc_const_unstable attributes REVERT: 21e23b81a3a Rollup merge of #132398 - krtab:add_doc_link, r=Noratrieb REVERT: 64e247223a8 Remove unintended link REVERT: 166cea20be8 Fix type reference in documents which was being confused with html tags. REVERT: cab478ae96f fix some stability annotations REVERT: ecd55b1fa47 Rollup merge of #132459 - RalfJung:byte_sub_ptr, r=scottmcm REVERT: 3cd2636d62e Rollup merge of #132455 - RalfJung:const_alloc_layout, r=dtolnay REVERT: 8fdd6d4ceca Rollup merge of #132451 - RalfJung:less-rustc_allow_const_fn_unstable, r=tgross35 REVERT: 9f63901f152 Rollup merge of #132445 - RalfJung:const-unchecked-shifts, r=tgross35 REVERT: 2b0a6ddf113 Rollup merge of #132413 - lolbinarycat:offset_of_nested-docs, r=workingjubilee REVERT: 2e24b7fba4b remove no-longer-needed attribute REVERT: ffbcba08e7f add missing safety comments REVERT: 768d0cd7fe4 adjust test gating for f16/f128 REVERT: 6335056119f float types: move copysign, abs, signum to libcore REVERT: c80bb77d125 offset_from / sub_ptr docs: emphasize that pointers must be in the same allocation REVERT: 861009d737b feat(byte_sub_ptr): add ptr::byte_sub_ptr REVERT: f4e1fa3d8b7 make const_alloc_layout feature gate only about functions that are already stable REVERT: bf19bdab420 unchecked_shifts, unchecked_neg are safe-to-const-expose-on-stable, so we can get rid of a bunch of attributes REVERT: ebf7505acaa remove some unnecessary rustc_allow_const_fn_unstable REVERT: 36cfa4e5e34 Auto merge of #132206 - tgross35:update-builtins, r=wesleywiser REVERT: 4283f78c3d6 use semantic line break REVERT: a4b391601ce update offset_of! docs to reflect the stablization of nesting REVERT: f0634f0e84d Add intra-doc link in str::xxx_char_boundary REVERT: c353337b8d0 rustdoc-search: simplify rules for generics and type params REVERT: 5d892fb876e Remove do_not_const_check from Iterator methods REVERT: 93839e7405e Add intra-doc link in str::xxx_prefix REVERT: 8c0bdb3e115 Auto merge of #132238 - Urgau:midpoint-i64-hackers-impl, r=joboet REVERT: 9d10ab71105 Implement `From<&mut {slice}>` for `Box/Rc/Arc<{slice}>` REVERT: 9b9ea35b918 Auto merge of #132326 - matthiaskrgr:rollup-ngyw18g, r=matthiaskrgr REVERT: 94dd5c6224c Rollup merge of #132321 - betrusted-io:xous/fix-rustc_const_stable-attribute, r=joboet REVERT: eb2e4208c5c Auto merge of #132231 - lukas-code:rc-plug-leaks, r=tgross35 REVERT: ed1a265dec3 xous: sync: remove `rustc_const_stable` attribute REVERT: 6495896aefb Rollup merge of #132270 - yakiimoninja:fs-truncate-docs, r=Noratrieb REVERT: 057f9e91003 Rollup merge of #132233 - WaffleLapkin:box-module-split, r=workingjubilee REVERT: d0a99e723de Rollup merge of #131520 - zachs18:const-str-split, r=Noratrieb REVERT: e134006be99 Auto merge of #132277 - workingjubilee:rollup-5e6q6e4, r=workingjubilee REVERT: 34329c06529 Stabilize `const_atomic_from_ptr` REVERT: a1b88a08f16 Auto merge of #128985 - GrigorenkoPV:instantly-dangling-pointer, r=Urgau REVERT: 9318ae3e6ad Rc destructor: tweak inlining REVERT: 3a686cd946e Split `boxed.rs` into a few modules REVERT: 7be29e92b87 Rollup merge of #131441 - SpriteOvO:proc-macro-to-tokens-trait, r=dtolnay REVERT: d56ef5ac6af clarified std::fs truncate doc REVERT: b0248e22287 Auto merge of #132145 - RalfJung:stdarch, r=Amanieu REVERT: 191aa709931 clarified doc for `std::fs::OpenOptions.truncate()` REVERT: a5aa408646d New lint: `dangling_pointers_from_temporaries` REVERT: 8cdb783b8a6 Rollup merge of #131391 - ChaiTRex:isqrt, r=scottmcm,tgross35 REVERT: 4f4a6c641ca we can now enable the 'const stable fn must be stable' check REVERT: 79c45bee82c bump stdarch REVERT: 848fcd56c9e Auto merge of #132251 - jieyouxu:rollup-mtv9mpd, r=jieyouxu REVERT: e2122609dc1 Auto merge of #132200 - Mark-Simulacrum:strengthen-cross-lang, r=RalfJung REVERT: ac1ec5f65d3 Support `char::is_digit` in const contexts REVERT: b534a028f5a Use Hacker's Delight impl in `i64::midpoint` instead of wide `i128` impl REVERT: 28223bdba1d Rc/Arc: don't leak the allocation if drop panics REVERT: 5d8140df6fa add test for panicking drop in Box/Rc/Arc REVERT: cde6279ea2f Auto merge of #131284 - dingxiangfei2009:rename-smart-ptr-to-coerce-referent, r=compiler-errors REVERT: c6676830322 Auto merge of #132191 - Urgau:midpoint_signed_towards_zero, r=dtolnay REVERT: 80f0aa3a99b Add a new trait `proc_macro::ToTokens` REVERT: 3cfffb8c0ae Update compiler-builtins to 0.1.136 REVERT: 45d8393ddaf Auto merge of #131715 - tgross35:add-const_sockaddr_setters, r=Amanieu REVERT: ec7694203d1 Make clearer that guarantees in ABI compatibility are for Rust only REVERT: 139f6325aad Add test for all midpoint expectations REVERT: 4612afa48e0 Round negative signed integer towards zero in `iN::midpoint` REVERT: 06b5c8eae1b Rollup merge of #132019 - daboross:document-partialeq-oncelock, r=Mark-Simulacrum REVERT: 658e70932b5 Auto merge of #131349 - RalfJung:const-stability-checks, r=compiler-errors REVERT: db3b9fca1c0 Rollup merge of #132137 - RalfJung:behavior, r=Noratrieb REVERT: 6daffe4709d get rid of the internal unlikely macro REVERT: d2ff6a20074 Re-do recursive const stability checks REVERT: a2e1edf18f6 Arbitrary self types v2: (unused) Receiver trait REVERT: 295b932be95 library: consistently use American spelling for 'behavior' REVERT: 2d26681057c ABI compatibility: remove section on target features REVERT: 2348c065b0e Rollup merge of #131457 - kpreid:fnaddr, r=dtolnay REVERT: 2da7b7f12dc Auto merge of #132121 - workingjubilee:rollup-yrtn33e, r=workingjubilee REVERT: 5cf142bc64b Rollup merge of #132113 - LaihoE:pattern_as_utf8_default_impl, r=workingjubilee REVERT: 1f2f88e41ef Rollup merge of #132101 - youknowone:thread_local-gyneiene, r=tgross35 REVERT: 6c8134047be Rollup merge of #132048 - mustartt:aix-random-impl, r=workingjubilee REVERT: 980e5a2d181 Rollup merge of #131851 - sunshowers:musl-posix, r=workingjubilee REVERT: d25ee97a2b8 Avoid use imports in thread_local_inner! in statik REVERT: b4ea08d88cf Auto merge of #132116 - matthiaskrgr:rollup-3a0ia4r, r=matthiaskrgr REVERT: 0ae2951e1b0 Rollup merge of #131790 - nmathewson:doc_socketaddr_representation, r=tgross35 REVERT: 8baae66df74 Auto merge of #131985 - compiler-errors:const-pred, r=fee1-dead REVERT: 115a851440e provide default impl for as_utf8_pattern REVERT: a92f55cd463 Auto merge of #123550 - GnomedDev:remove-initial-arc, r=Noratrieb REVERT: c9460bfe499 Document textual format of SocketAddrV{4,6} REVERT: 78f4ed38d1d Remove associated type based effects logic REVERT: 21eb2c297f0 [musl] use posix_spawn if a directory change was requested REVERT: 03798ad0818 Rollup merge of #130225 - adetaylor:rename-old-receiver, r=wesleywiser REVERT: a45e03057ba Rollup merge of #132066 - tifv:ptr-docs-typo, r=Amanieu REVERT: 927edad8409 Rollup merge of #132065 - tifv:dangling-docs, r=Noratrieb REVERT: ded2a0afac4 Rollup merge of #132060 - joshtriplett:innermost-outermost, r=jieyouxu REVERT: e62b2cc663d Rollup merge of #132039 - a1phyr:vecdeque_read_exact, r=Noratrieb REVERT: 76e75ae973e Rollup merge of #130991 - LaihoE:vectorized_slice_contains, r=Noratrieb REVERT: 6799f8562be const fn str::split_at* REVERT: 887bcf653d8 const fn str::is_char_boundary REVERT: 01ed719bad8 vectorized SliceContains REVERT: 1bb8bdeeb98 s/SmartPointer/CoerceReferent/g REVERT: 843347f94b4 fix a typo in documentation of pointer::sub_ptr() REVERT: 10f64a79d36 fix documentation of ptr::dangling() function REVERT: 728a8d71d08 "innermost", "outermost", "leftmost", and "rightmost" don't need hyphens REVERT: 282790f75ad Specialize `read_exact` and `read_buf_exact` for `VecDeque` REVERT: 054b256111a Rollup merge of #132031 - slanterns:rc_default, r=ibraheemdev REVERT: 05b4955be28 Rollup merge of #131707 - clarfonthey:constify-core-tests, r=thomcc REVERT: b0fc9c793f3 Auto merge of #131929 - LaihoE:replace_default_capacity, r=joboet REVERT: 5c416b4572c AIX use /dev/urandom for impl REVERT: 09e26cb1460 better default capacity for str::replace REVERT: 3a5e669fcdb Rename Receiver -> LegacyReceiver REVERT: 224a60d32db refactor `Arc::default` REVERT: fe5101d2303 optimize `Rc::default` REVERT: 507193aaae8 Rollup merge of #131697 - ShE3py:rt-arg-lifetimes, r=Amanieu REVERT: 61fa53e24a6 Document PartialEq impl for OnceLock REVERT: 2e8dd5b1116 Rollup merge of #132003 - RalfJung:abi-compat-docs, r=traviscross REVERT: 7f91dbe9922 Rollup merge of #130350 - RalfJung:strict-provenance, r=dtolnay REVERT: 8499ec3da71 update ABI compatibility docs for new option-like rules REVERT: 6d2a4371f48 move strict provenance lints to new feature gate, remove old feature gates REVERT: 446117163a5 stabilize Strict Provenance and Exposed Provenance REVERT: e2b2c3aac1a fix docs REVERT: 20ed6b56971 replace FindFirstFileW with FindFirstFileExW and apply optimization REVERT: a065b8ecafd replace FindFirstFileW with FindFirstFileExW and regenerate bindings REVERT: 362aec6e09b Auto merge of #131948 - matthiaskrgr:rollup-c9rvzu6, r=matthiaskrgr REVERT: f1c99041c25 Support lock() and lock_shared() on async IO Files REVERT: 7628c4ff550 Rollup merge of #131921 - klensy:statx_all, r=ChrisDenton REVERT: affe042b2cf Rollup merge of #131772 - GnomedDev:remove-proc_macro-todo, r=petrochenkov REVERT: 5615efc263a Auto merge of #131907 - saethlin:update-compiler-builtins, r=tgross35 REVERT: b6b2903e331 Update `compiler-builtins` to 0.1.134 REVERT: b714f9d7b4f Rollup merge of #131919 - RalfJung:zero-sized-accesses, r=jhpratt REVERT: fb670790503 Rollup merge of #131890 - printfn:precise-capturing-docs, r=traviscross REVERT: 642ab07d02b Rollup merge of #127462 - Ayush1325:uefi-env, r=joboet REVERT: bac38912a1e Remove the Arc rt::init allocation for thread info REVERT: 85f6f48cb96 Auto merge of #131816 - Zalathar:profiler-feature, r=Kobzol REVERT: f843b262131 replace STATX_ALL with (STATX_BASIC_STATS | STATX_BTIME) as former is deprecated REVERT: aabdd7d597b zero-sized accesses are fine on null pointers REVERT: ff3f33f0147 Update `use` keyword docs to describe precise capturing REVERT: c949985e896 std: uefi: Use common function for UEFI shell REVERT: f973e62ee09 std: uefi: Add basic Env variables REVERT: 63a4a9bf56a Auto merge of #131895 - jieyouxu:rollup-jyt3pic, r=jieyouxu REVERT: 39ccfc9cfbb Rollup merge of #126207 - devnexen:stack_overflow_libc_upd, r=joboet REVERT: e08bce6edbf Auto merge of #131841 - paulmenage:futex-abstraction, r=joboet REVERT: 7f6af4dd882 Revert using `HEAP` static in Windows alloc REVERT: eba461cd50a Rollup merge of #131866 - jieyouxu:thread_local, r=jhpratt REVERT: 80bbaa966ed Rollup merge of #131858 - AnthonyMikh:AnthonyMikh/repeat_n-is-not-that-special-anymore, r=jhpratt REVERT: 5ec2cbcf4b0 Rollup merge of #131809 - collinoc:fix-retain-mut-docs, r=jhpratt REVERT: fe19eb64d14 Rollup merge of #131774 - thesummer:rtems-add-getentropy, r=joboet REVERT: fca737550f7 Rollup merge of #130136 - GKFX:stabilize-const-pin, r=dtolnay REVERT: 07aaa64759c Add entropy source for RTEMS REVERT: 1b957f4cc95 Rollup merge of #131850 - lexeyOK:master, r=compiler-errors REVERT: a6871b84557 Rollup merge of #131823 - thesummer:bump-libc-0.2.160, r=workingjubilee REVERT: 848aed94cd3 Rollup merge of #131654 - betrusted-io:xous-various-fixes, r=thomcc REVERT: a6e300e1fb6 Avoid shadowing user provided types or type aliases in `thread_local!` REVERT: a993e1de676 remove outdated documentation for `repeat_n` REVERT: 4d2c9694483 Auto merge of #131572 - cuviper:ub-index_range, r=thomcc REVERT: f905a0cd54e Bump libc to 0.2.161 REVERT: beee93f748d std::unix::stack_overflow::drop_handler addressing todo through libc update REVERT: c8f71dc9d2d Missing parenthesis REVERT: 01bce29cc5d Abstract the state type for futexes REVERT: 0ab703c6d44 Rollup merge of #131835 - ferrocene:amanjeev/add-missing-attribute-unwind, r=Noratrieb REVERT: bac74b68036 Rollup merge of #131833 - c-ryan747:patch-1, r=Noratrieb REVERT: 0d7c8897756 Auto merge of #130223 - LaihoE:faster_str_replace, r=thomcc REVERT: 34c8228660f Do not run test where it cannot run REVERT: d73f9242eab Add must_use to CommandExt::exec REVERT: aa027e9af5f Make `profiler_builtins` an optional dependency of sysroot, not std REVERT: 019ad0cab75 Remove TODO in proc_macro now `const_refs_to_static` is stable REVERT: 3b5d8a26f59 Fix predicate signatures in retain_mut docs REVERT: 6c85d31157b Auto merge of #131797 - matthiaskrgr:rollup-lzpze2k, r=matthiaskrgr REVERT: 3a5fdfc26a4 Partially stabilize const_pin REVERT: 7caa6d2fa3f Rollup merge of #131730 - zlfn:master, r=tgross35 REVERT: 1e13241be78 Auto merge of #131792 - matthiaskrgr:rollup-480nwg4, r=matthiaskrgr REVERT: 1581f568688 Rollup merge of #130822 - bjoernager:non-null-from-ref, r=dtolnay REVERT: f7b3231ad4c Auto merge of #131767 - cuviper:bump-stage0, r=Mark-Simulacrum REVERT: cdbd127ce77 Rollup merge of #131746 - slanterns:once_box_order, r=joboet REVERT: 6f3e65c5db7 Rollup merge of #131712 - tgross35:const-lazy_cell_into_inner, r=joboet REVERT: 151c0c71271 Auto merge of #131460 - jwong101:default-placement-new, r=ibraheemdev REVERT: 43f97fbcc51 update bootstrap configs REVERT: eae13d1eb36 replace placeholder version REVERT: e35d9fee2f0 relax a memory order in `once_box` REVERT: fbde7e89524 Rollup merge of #131521 - jdonszelmann:rc, r=joboet REVERT: 9d9ea42d6d4 Rollup merge of #130568 - eduardosm:const-float-methods, r=RalfJung,tgross35 REVERT: 435ce04088a Rollup merge of #129794 - Ayush1325:uefi-os-expand, r=joboet REVERT: bfd32fa365f Refactor `floating` macro and nofloat panic message REVERT: 7d1457e2a77 Auto merge of #131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgr REVERT: 148ed853756 Rename debug! macro to impl_Debug! REVERT: db2efb0ff0e Combine impl_int and impl_uint REVERT: 1897d05bfa1 Make some float methods unstable `const fn` REVERT: 76342d9978a Auto merge of #131724 - matthiaskrgr:rollup-ntgkkk8, r=matthiaskrgr REVERT: da7ca2278ec Rollup merge of #131706 - GKFX:fix-const-hacks, r=tgross35 REVERT: 54072ab6186 Rollup merge of #131496 - bjoernager:const-make-ascii, r=dtolnay REVERT: 1695b0a8e47 Rollup merge of #130608 - YohDeadfall:cstr-from-into-str, r=workingjubilee REVERT: f1ee2cd79c7 Rollup merge of #131339 - HeroicKatora:set_ptr_value-documentation, r=Mark-Simulacrum REVERT: ffc4a6cb394 Rollup merge of #122670 - beetrees:non-unicode-option-env-error, r=compiler-errors REVERT: cc7730e1264 Auto merge of #129458 - EnzymeAD:enzyme-frontend, r=jieyouxu REVERT: eeab9d49651 Stabilise 'const_make_ascii' REVERT: ec0b0dff72c Add a `const_sockaddr_setters` feature REVERT: e7884100078 Mark LazyCell::into_inner unstably const REVERT: acaf7e2e9ab Run most core::num tests in const context too REVERT: 63f38366fb6 Fix two const-hacks REVERT: 34d920c1aa6 `rt::Argument`: elide lifetimes REVERT: ecb3830a8b2 Rollup merge of #131384 - saethlin:precondition-tests, r=ibraheemdev REVERT: ea7a0c646f4 Rollup merge of #129424 - coolreader18:stabilize-pin_as_deref_mut, r=dtolnay REVERT: 843c9e98097 Auto merge of #131672 - matthiaskrgr:rollup-gyzysj4, r=matthiaskrgr REVERT: 3b92996e629 uefi: Implement getcwd and chdir REVERT: 8d35aa977cc Rollup merge of #131616 - RalfJung:const_ip, r=tgross35 REVERT: b6cfaeb1239 Rollup merge of #131274 - workingjubilee:stabilize-the-one-that-got-away, r=scottmcm REVERT: 6d8235e8adb Rollup merge of #130629 - Dirbaio:net-from-octets, r=tgross35 REVERT: 88634c8310a Rollup merge of #128967 - devnexen:get_path_fbsd_upd, r=joboet REVERT: d6318f3817a Auto merge of #126557 - GrigorenkoPV:vec_track_caller, r=joboet REVERT: 541bda102a0 Implement file_lock feature REVERT: d11e388017f Auto merge of #131662 - matthiaskrgr:rollup-r1wkfxw, r=matthiaskrgr REVERT: 089c495282b rename rcbox in other places as per review comments REVERT: 2cfa6d06db7 core/net: use hex for ipv6 doctests for consistency. REVERT: 9ae0e8bcfaf core/net: add Ipv[46]Addr::from_octets, Ipv6Addr::from_segments REVERT: da6c63c5a39 Rollup merge of #131646 - RalfJung:unix-miri-fallbacks, r=joboet REVERT: 87ea4bb9c12 Rollup merge of #131644 - RalfJung:win-miri, r=joboet REVERT: 928b99c635c library: xous: mark alloc as `FIXME(static_mut_refs)` REVERT: dde2ff0ebe8 xous: ffi: correct syscall number for adjust_process REVERT: c3955e47308 net: fix dead code warning REVERT: 3919c4f32a0 std: xous: add support for args and env REVERT: 9c1e16259db Auto merge of #125679 - clarfonthey:escape_ascii, r=joboet REVERT: 262c3fb4d69 unwind: update unwinding dependency to 0.2.3 REVERT: 4c6374963e6 sys/unix: add comments for some Miri fallbacks REVERT: e3f701c4b40 remove outdated comment now that Miri is on CI REVERT: e2c210e67f8 sys/windows: remove miri hack that is only needed for win7 REVERT: 1799481f55c switch unicode-data back to 'static' REVERT: ddfd2ea502a merge const_ipv4 / const_ipv6 feature gate into 'ip' feature gate REVERT: b6c03764111 Rollup merge of #131418 - coolreader18:wasm-exc-use-stdarch, r=bjorn3 REVERT: 1ee9b69f828 Rollup merge of #131120 - tgross35:stabilize-const_option, r=RalfJung REVERT: 6fc4b1a9f8b Fix bug where `option_env!` would return `None` when env var is present but not valid Unicode REVERT: d72915fce78 Fix typo thing->thin referring to pointer REVERT: a2d85a1f8b8 Stabilize `const_option` REVERT: 4a9ad4ac8cc Rollup merge of #131617 - RalfJung:const_cow_is_borrowed, r=tgross35 REVERT: 113c6c093fa Rollup merge of #131503 - theemathas:stdin_read_line_docs, r=Mark-Simulacrum REVERT: 7a515952c92 remove const_cow_is_borrowed feature gate REVERT: 7420c36fae4 Rollup merge of #131233 - joboet:stdout-before-main, r=tgross35 REVERT: 08e7188f626 Rollup merge of #130954 - workingjubilee:stabilize-const-mut-fn, r=RalfJung REVERT: 3febfb34f55 std: fix stdout-before-main REVERT: 3b820ee5e01 library: Stabilize `const_replace` REVERT: ee21064fde0 library: Stabilize `const_ptr_write` REVERT: 36ff2c84d56 library: Stabilize `const_intrinsic_forget` REVERT: 4f124de46bd Rollup merge of #131289 - RalfJung:duration_consts_float, r=tgross35 REVERT: de76914d8c6 Rollup merge of #130962 - nyurik:opts-libs, r=cuviper REVERT: 76ce3a99e3a Rollup merge of #124874 - jedbrown:float-mul-add-fast, r=saethlin REVERT: de18ce14fb9 Avoid superfluous UB checks in `IndexRange` REVERT: eb8ff202d9e Rollup merge of #131463 - bjoernager:const-char-encode-utf8, r=RalfJung REVERT: 964c91b858a Rollup merge of #131287 - RalfJung:const_result, r=tgross35 REVERT: a8b0950a043 Rollup merge of #131109 - tgross35:stabilize-debug_more_non_exhaustive, r=joboet REVERT: 637b5152fc6 Rollup merge of #131065 - Voultapher:port-sort-test-suite, r=thomcc REVERT: eeb881dee88 intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semantics REVERT: 2b6b22cebab Single commit implementing the enzyme/autodiff frontend REVERT: 00785c0149e stabilize const_result REVERT: 12b80281dcd stabilize duration_consts_float REVERT: c8d357c99d6 Rollup merge of #131512 - j7nw4r:master, r=jhpratt REVERT: 34f7831c7de rename RcBox in other places too REVERT: cd0a8f50855 rename RcBox to RcInner for consistency REVERT: dd6dd70c0fd Fixing rustDoc for LayoutError. REVERT: 7fdd5455da9 Rollup merge of #130741 - mrkajetanp:detect-b16b16, r=Amanieu REVERT: 77f7b2fe97e Rollup merge of #130538 - ultrabear:ultrabear_const_from_ref, r=workingjubilee REVERT: d7a7b0a361b uefi: process: Add args support REVERT: 14aef3d76cf Use with_capacity(0) because we're reading the capacity later on REVERT: 5b16abea8d5 Prefer `target_vendor = "apple"` on confstr REVERT: bc6398107f8 use `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)` as a `TMPDIR` fallback on darwin REVERT: fca091985c1 More clearly document Stdin::read_line REVERT: e4a9064e4d6 Stabilise 'const_char_encode_utf8'; REVERT: 8547f513811 allocate before calling T::default in >::default() REVERT: 669e25597c8 allocate before calling T::default in >::default() REVERT: 5ef6f834a52 rustc_target: Add sme-b16b16 as an explicit aarch64 target feature REVERT: 74264e37655 stdarch: Bump stdarch submodule REVERT: a5529ee2982 Clean up is_aligned_and_not_null REVERT: db5a9a7f814 Add more precondition check tests REVERT: 528dda2686f Allow zero-size reads/writes on null pointers REVERT: 86c75265bd5 Optimize escape_ascii REVERT: 36a90d74101 Rollup merge of #131462 - cuviper:open_buffered-error, r=RalfJung REVERT: 49220cd15f1 Rollup merge of #131449 - nickrum:wasip2-net-decouple-fd, r=alexcrichton REVERT: ff37c087e49 Rollup merge of #131383 - AngelicosPhosphoros:better_doc_for_slice_slicing_at_ends, r=cuviper REVERT: 136ec3ace84 Rollup merge of #130827 - fmease:library-mv-obj-save-dyn-compat, r=ibraheemdev REVERT: 8cdea8c34b0 Add "not guaranteed to be equal" REVERT: db9377d33aa Mention allocation errors for `open_buffered` REVERT: 7e225fa8a49 Apply suggestions from code review REVERT: 0ce4f76a7d5 Expand `ptr::fn_addr_eq()` documentation. REVERT: 885e3d14d82 Library: Rename "object safe" to "dyn compatible" REVERT: 5f495eef33c Decouple WASIp2 sockets from WasiFd REVERT: 78670fb644f stabilize `{slice,array}::from_mut` REVERT: 7153288b527 Update library/std/src/sys/pal/unix/process/process_vxworks.rs REVERT: cd0d5be2726 fix ref in process_vxworks.rs REVERT: 01e7f5f97b1 Update library/std/src/sys/pal/unix/process/process_unix.rs REVERT: fbb514cbba3 Change a few `&Option` into `Option<&T>` REVERT: cc1e8b56f8f Use throw intrinsic from stdarch in wasm libunwind REVERT: bc755bb5124 Stabilize Pin::as_deref_mut REVERT: fcc990d33eb Stabilize `isqrt` feature REVERT: f8dc879fa96 Add LowerExp and UpperExp implementations REVERT: b946b83a26a Add docs about slicing slices at the ends REVERT: 9ca739e65a6 cfg out checks in add and sub but not offset REVERT: 8293e745abb Add precondition checks to ptr::offset, ptr::add, ptr::sub REVERT: c65244c638a Rollup merge of #131308 - mati865:gnullvm-f16-f128, r=tgross35 REVERT: 6a809c73fad Rollup merge of #128399 - mammothbane:master, r=Amanieu,tgross35 REVERT: 723693ef035 liballoc: introduce String, Vec const-slicing REVERT: fee7e5e4dbb Auto merge of #128651 - folkertdev:naked-asm-macro-v2, r=Amanieu REVERT: 61eff8fd543 Expand set_ptr_value / with_metadata_of docs REVERT: 7c3b7e72f68 Rollup merge of #131335 - dacianpascu06:fix-typo, r=joboet REVERT: 8e3076e7875 Rollup merge of #131307 - YohDeadfall:prctl-set-name-dbg-assert, r=workingjubilee REVERT: b8c51a660a1 grammar fix REVERT: 4ca50c3c94a disallow `asm!` in `#[naked]` functions REVERT: cc09cb0dfa4 implement `naked_asm` macro REVERT: dbb22815a85 Rollup merge of #131316 - programmerjake:patch-4, r=Noratrieb REVERT: 4b276e63ed9 Auto merge of #131314 - tgross35:update-builtins, r=tgross35 REVERT: 5dc3e7cf205 Fix typo in primitive_docs.rs REVERT: 686d25dc005 Auto merge of #130540 - veera-sivarajan:fix-87525, r=estebank REVERT: 9555c10cffb Update `compiler-builtins` to 0.1.133 REVERT: 0f71b38a203 enable f16 and f128 on windows-gnullvm targets REVERT: d14d771cf46 Auto merge of #131302 - matthiaskrgr:rollup-56kbpzx, r=matthiaskrgr REVERT: b8dd44198e9 Android: Debug assertion after setting thread name REVERT: fcd199dec5f Rollup merge of #131281 - RalfJung:const-cell, r=Amanieu REVERT: 71aa514ef59 Auto merge of #131221 - XrXr:bump-compiler-builtins, r=tgross35 REVERT: b7c90c62514 library: Stabilize const `MaybeUninit::assume_init_mut` REVERT: 0418d546ad5 Add a Lint for Pointer to Integer Transmutes in Consts REVERT: 460459d3c24 Rollup merge of #131256 - RalfJung:f16-f128-const, r=ibraheemdev REVERT: a818a4dfa97 Rollup merge of #131094 - joboet:lazy_once_box, r=ibraheemdev REVERT: 2ed62821f6a make Cell unstably const REVERT: 575391b7daf move f16/f128 const fn under f16/f128 feature gate REVERT: b3da4ed72f7 Stabilize `const_slice_split_at_mut` and `const_slice_first_last_chunk` REVERT: bbe8bf7f827 Rollup merge of #131267 - okaneco:bufread_skip_until, r=tgross35 REVERT: 65049d1b3a2 Rollup merge of #131105 - slanterns:literal_c_str, r=petrochenkov REVERT: 7001dd5a296 Rollup merge of #130403 - eduardosm:stabilize-const_slice_from_raw_parts_mut, r=workingjubilee REVERT: 0f43ffb1b78 Update compiler-builtins to 0.1.132 REVERT: 7d4319e623c Rollup merge of #131177 - workingjubilee:stabilize-const-mut-referees, r=tgross35 REVERT: 67093076d45 Rollup merge of #130518 - scottmcm:stabilize-controlflow-extra, r=dtolnay REVERT: b732d237348 Stabilize `BufRead::skip_until` REVERT: eb2806b2450 Auto merge of #130157 - eduardosm:stabilize-const_float_classify, r=RalfJung REVERT: 50afc521a17 Stabilize UnsafeCell::from_mut REVERT: c822d330b90 update libc version REVERT: 26b231be7ab std::fs::get_path freebsd update. REVERT: 1bd16cdc12d Rollup merge of #131197 - EFanZh:avoid-emptyness-check-in-peekmut-pop, r=Amanieu REVERT: 8cfa0cad753 Avoid emptiness check in `PeekMut::pop` REVERT: 86fa4749d71 Rollup merge of #131163 - JakenHerman:master, r=Nadrieril REVERT: 6b57e57feb7 Auto merge of #128711 - clarfonthey:default-iters-hash, r=dtolnay REVERT: 254af0b5676 Add `get_line` confusable to `Stdin::read_line()` REVERT: f89b8dc4085 impl Default for Hash{Map,Set} iterators that don't already have it REVERT: 0c22ea874b0 Auto merge of #127912 - joboet:tls_dtor_thread_current, r=cuviper REVERT: 2b4f6ec1c62 Auto merge of #131148 - Urgau:hashbrown-0.15, r=Amanieu REVERT: 26013cd95f9 library: Stabilize `const_slice_first_last` REVERT: 51ed903979b library: Stabilize `const_unsafecell_get_mut` REVERT: cd6c1cc10b9 library: Stabilize `const_ptr_as_ref` REVERT: ecb0f03e4e2 library: Stabilize `const_str_as_mut` REVERT: 78ad293f3b4 library: Stabilize `const_str_from_utf8_unchecked_mut` REVERT: db56087d227 std: make `thread::current` available in all `thread_local!` destructors REVERT: d5599a7e273 Rollup merge of #131141 - RalfJung:mpmc-test, r=Amanieu REVERT: 487946f8cef Update hashbrown to 0.15 and adjust some methods REVERT: 0d191198a22 mpmc doctest: make sure main thread waits for child threads REVERT: a7d53dad608 Auto merge of #130829 - Urgau:option_array_transpose, r=ibraheemdev REVERT: 7c896fc637d Auto merge of #128204 - GuillaumeGomez:integers-opti, r=workingjubilee REVERT: f19cac15d11 std: replace `LazyBox` with `OnceBox` REVERT: e2ebf0447a4 Stabilize `const_slice_from_raw_parts_mut` REVERT: a575a8b0d73 Auto merge of #131111 - matthiaskrgr:rollup-n6do187, r=matthiaskrgr REVERT: 82e1372c75b Rollup merge of #130773 - bjoernager:master, r=thomcc REVERT: b33d815cbba Rollup merge of #130229 - RalfJung:ptr-offset-unsigned, r=scottmcm REVERT: bf40ab27b3b Implemented FromStr for CString and TryFrom for String REVERT: ea51d16d7c0 Stabilize `debug_more_non_exhaustive` REVERT: f8db8779429 update `Literal`'s intro REVERT: bcfd953c29e Auto merge of #131098 - GuillaumeGomez:rollup-kk74was, r=GuillaumeGomez REVERT: 3a8939e2d3c Rollup merge of #131085 - RalfJung:miri-slow-test, r=tgross35 REVERT: 90d63b16b5c Auto merge of #126839 - obeis:mpmc, r=Amanieu REVERT: 4451aeededb Remove the need to provide the maximum number of digits to `impl_Display` macro REVERT: 85c1cec695e Simplify `impl_Display` macro REVERT: c4be3da8440 Small optimization for integers Display implementation REVERT: 82014ee9988 make test_lots_of_insertions test take less long in Miri REVERT: f688d7d81d0 Enable `f16` tests on non-GNU Windows REVERT: e97c379df19 Rollup merge of #130966 - RalfJung:ptr-metadata-const-stable, r=scottmcm REVERT: e4d621e29b6 Rollup merge of #130961 - tgross35:f16-x86-apple, r=thomcc REVERT: 3c9808bdfcf Rollup merge of #130914 - compiler-errors:insignificant-dtor, r=Amanieu REVERT: 99e98538bb5 Rollup merge of #129638 - nickrum:wasip2-net, r=alexcrichton REVERT: e2a020e6863 Add multi-producer, multi-consumer channel (mpmc) REVERT: cbc9e287756 Port sort-research-rs test suite Rust stdlib tests REVERT: b36201981bc Rollup merge of #130972 - RalfJung:const_cell_into_inner, r=dtolnay REVERT: 109f2701e8b Rollup merge of #129003 - Voultapher:improve-ord-docs, r=workingjubilee REVERT: 07542a5c170 Rollup merge of #123932 - adamse:global-alloc-safety-preconds-positive, r=tgross35 REVERT: 2332c3d1a72 Rollup merge of #130931 - GuillaumeGomez:standalone-crate, r=notriddle REVERT: faa018ecfa8 Rename doctest attribute `standalone-crate` into `standalone_crate` for coherency REVERT: e36be64bdf1 Rollup merge of #130743 - YohDeadfall:net-nonblocking-doc, r=Mark-Simulacrum REVERT: a31f8828ccc Rollup merge of #130416 - BatmanAoD:130122-sort-by-docs, r=Mark-Simulacrum REVERT: 08ac3a03cfd Remove duplicate section REVERT: b4307a53105 Auto merge of #128321 - BatmanAoD:catch-unwind-doc-update, r=Mark-Simulacrum REVERT: 9ae087ce909 Fix std tests for wasm32-wasip2 target REVERT: b0cc90202cd Hook up std::net to wasi-libc on wasm32-wasip2 target REVERT: 7311aa8d2c7 Auto merge of #123778 - jhorstmann:optimize-upper-lower-auto-vectorization, r=the8472 REVERT: c3d3d1a1216 Enable `f16` tests on x86 Apple platforms REVERT: 3aae77071a0 Auto merge of #129385 - tgross35:more-platforms-enable-f16, r=Mark-Simulacrum REVERT: 26407360225 Auto merge of #130792 - tgross35:update-builtins, r=Amanieu REVERT: 383f0def784 Rename `standalone` doctest attribute into `standalone-crate` REVERT: 1f8a7736596 Update compiler_builtins to 0.1.130 REVERT: 7a5052a8ef7 Rollup merge of #128778 - RalfJung:atomic-read-read-races, r=Mark-Simulacrum REVERT: 098ada160f7 Auto merge of #130964 - matthiaskrgr:rollup-suriuub, r=matthiaskrgr REVERT: 81fcbcd76e6 Further clarificarion for atomic and UnsafeCell docs: REVERT: e7c99a7ec72 allow mixed-size atomic reads REVERT: addd05ec29a atomics: allow atomic and non-atomic reads to race REVERT: b8c2a2a31e9 stabilize const_cell_into_inner REVERT: 7946445e4ab make ptr metadata functions callable from stable const fn REVERT: 9f50f5ab7e1 Auto merge of #130897 - workingjubilee:dump-hexes-with-class, r=thomcc REVERT: e66058d77a1 Rollup merge of #130922 - tyilo:udp-unspecified, r=ibraheemdev REVERT: 1bd2532dc81 Rollup merge of #125404 - a1phyr:fix-read_buf-uses, r=workingjubilee REVERT: 288b9ca02b0 Update Unicode escapes; REVERT: 05590f7156d Enable `f16` on platforms that were missing conversion symbols REVERT: 3a00bff8352 Auto merge of #130946 - matthiaskrgr:rollup-ia4mf0y, r=matthiaskrgr REVERT: c2bd1e39c40 Rollup merge of #130926 - ChrisDenton:cc-1-1-22, r=tgross35 REVERT: 7ddd56672f4 Rollup merge of #129087 - slanterns:option_get_or_insert_default, r=dtolnay REVERT: 93916ed57b0 Mark some more smart pointers as insignificant REVERT: 118d2e4c7dc Mark some more types as having insignificant dtor REVERT: 9b4776b272b Add 'from_ref' and 'from_mut' constructors to 'core::ptr::NonNull'; REVERT: 56523a9df37 Update Cargo.lock REVERT: aabd713b24b Apply review feedback REVERT: df28bde6c18 Apply round 1 of review comments REVERT: cb0529a1e28 Fix mistake in example REVERT: a9eb97b8682 Improve Ord docs REVERT: 04d91457f81 Reference UNSPECIFIED instead of INADDR_ANY in join_multicast_v4 REVERT: edc72ca4a4b Rollup merge of #130892 - tgross35:library-cargo-update, r=Noratrieb REVERT: fdf84bfd56d Rollup merge of #130875 - folkertdev:naked-asm-bootstrap, r=tgross35 REVERT: 1b3f488a588 Rollup merge of #130846 - ChrisDenton:revert-break, r=Noratrieb REVERT: 89c9ef65418 Rollup merge of #130313 - c410-f3r:unlock-rfc-2011, r=thomcc REVERT: ea82a9668f4 Rollup merge of #130880 - RalfJung:const-hack, r=scottmcm REVERT: be1d9d67900 Rollup merge of #130861 - cuviper:sun-path-offset, r=ibraheemdev REVERT: c1c0a1b5a4d Rollup merge of #130845 - RalfJung:utf8chunk, r=tgross35 REVERT: 805d196d6a7 Rollup merge of #130279 - theemathas:manually-drop-docs, r=thomcc,traviscross REVERT: f40ec5aecf4 library: Compute `RUST_EXCEPTION_CLASS` from native-endian bytes REVERT: eae051bb5e2 Partially update `library/Cargo.lock` REVERT: 532cd8551de Add `sun_path` to the fake doc `sockaddr_un` REVERT: f0660deaec1 add missing FIXME(const-hack) REVERT: 0580e66c287 Add `[Option; N]::transpose` REVERT: 13417248b26 update `compiler_builtins` to `0.1.126` REVERT: cd704d4c632 add a bootstrap variant of `naked_asm` REVERT: a781a4a638a Stabilize the `map`/`value` methods on `ControlFlow` REVERT: ff453134135 Use `&raw` in the standard library REVERT: 3d036345362 Use `mem::offset_of!` for `sockaddr_un.sun_path` REVERT: f50b2ba584d Rollup merge of #130842 - Noratrieb:tracking-issue-inprogress, r=jieyouxu REVERT: c50befe9ea0 Rollup merge of #130832 - RalfJung:sort-cfg-mess, r=workingjubilee REVERT: d50c54a1171 Rollup merge of #130819 - bjoernager:char-must-use-len-utf, r=Noratrieb REVERT: 811ce7762b6 Rollup merge of #130811 - RalfJung:random, r=joboet REVERT: 275fb0eb691 Revert Break into the debugger on panic (129019) REVERT: f560508bef1 Utf8Chunks: add link to Utf8Chunk REVERT: 88474293f4b Add tracking issue for io_error_inprogress REVERT: fa38b29687b fix some cfg logic around optimize_for_size and 16-bit targets REVERT: b9ef35a8f73 Auto merge of #130816 - matthiaskrgr:rollup-jy25phv, r=matthiaskrgr REVERT: e4f89ece58f Add 'must_use' attribute to 'char::len_utf8' and 'char::len_utf16'; REVERT: bcb9d2385d9 Rollup merge of #130810 - kromych:master, r=workingjubilee REVERT: a5a32e2c8f0 Rollup merge of #130595 - no1wudi:master, r=ibraheemdev REVERT: 6a06555427f Rollup merge of #130549 - biabbas:riscv32_wrs_vxworks, r=nnethercote REVERT: f67efdd34d8 add link from random() helper fn to extensive DefaultRandomSource docs REVERT: 4a7aeff64ec Auto merge of #130803 - cuviper:file-buffered, r=joshtriplett REVERT: 54834b6bae3 Don't trap into the debugger on panics under Linux REVERT: 2c408b10a25 Rollup merge of #130789 - aviramha:add_inprogress, r=Noratrieb REVERT: 8849d13a2f0 Rollup merge of #130788 - tgross35:memchr-pinning, r=Noratrieb,Mark-Simulacrum REVERT: 2ab86f01c97 Add a tracking issue for `file_buffered` REVERT: 963cefb2cd1 Dogfood `feature(file_buffered)` REVERT: aa74e934264 Mark 'get_mut' and 'set_position' in 'std::io::Cursor' as const; REVERT: 15d69c9edf4 Pre-allocate buffers in `File::open_buffered` and `create_buffered` REVERT: eb07a61acf1 Add `File::open_buffered` and `create_buffered` REVERT: 92d5cef2a6a Auto merge of #129587 - Voultapher:opt-for-size-variants-of-sort-impls, r=cuviper REVERT: c86f1ce711b add InProgress ErrorKind gated behind io_error_inprogress feature REVERT: 6d8f5d81b18 Pin memchr to 2.5.0 in the library rather than rustc_ast REVERT: 194bbc77c56 Auto merge of #130738 - bjoernager:const-make-ascii, r=jhpratt REVERT: c47920fa3a5 Initial std library support for NuttX REVERT: 622d08c26df Mark and implement 'make_ascii_uppercase' and 'make_ascii_lowercase' in '[u8]' and 'str' as const; REVERT: 668b21ae951 Rollup merge of #130762 - RalfJung:const_intrinsic_copy, r=dtolnay REVERT: 43a4d34efd2 Rollup merge of #129545 - notriddle:notriddle/toolbar-v2, r=GuillaumeGomez REVERT: 57557c9629f Add a comment to `Read::read_buf` REVERT: 4a11249c0f7 Add tests REVERT: f34267540ce Fix `io::default_read_to_end` uses of `read_buf` REVERT: 57f279d91b7 Fix `io::BufReader` uses of `read_buf` REVERT: 8472204d13e Fix `io::Take::read_buf` REVERT: db0f33788d6 stabilize const_intrinsic_copy REVERT: 27136c4a376 Add fast path for ascii to ascii in str::replace REVERT: fc983bafafc Fix up standard library intro REVERT: 6d41b99edf7 Clarifications for set_nonblocking methods REVERT: f5406a512b8 Improve autovectorization of to_lowercase / to_uppercase functions REVERT: bab810c740a random: add tracking issue, address other comments REVERT: 849258c77c2 std: switch to faster random sources on macOS and most BSDs REVERT: a095a76d3a7 std: implement the `random` feature REVERT: ba6158c689b Rollup merge of #130723 - D0liphin:master, r=workingjubilee REVERT: 776d9eff4dc Rollup merge of #130713 - bjoernager:const-char-make-ascii, r=Noratrieb REVERT: 337c634511c Rollup merge of #130659 - bjoernager:const-char-encode-utf16, r=dtolnay REVERT: 8ffc1707657 Rollup merge of #129550 - kornelski:boxasstr, r=joshtriplett,dtolnay REVERT: a28cdffc73b Reformat using the new identifier sorting from rustfmt REVERT: 07a62f42f5d reword edge-conditions documentation on all slice 'sort' functions; resolves #130122 REVERT: 9bcb2d9551e Add test for `available_parallelism()` REVERT: 474b9af1e61 Mark 'make_ascii_uppercase' and 'make_ascii_lowercase' in 'u8' as const; Rename 'const_char_make_ascii' feature gate to 'const_make_ascii'; REVERT: b3d4fde409e Rollup merge of #130692 - RalfJung:result-flatten, r=Noratrieb REVERT: 55becb00610 Rollup merge of #130670 - the8472:read-to-end-heuristics, r=ChrisDenton REVERT: 202df818d33 Rollup merge of #130658 - EqualMa:patch-1, r=scottmcm REVERT: 9c26e05665e Auto merge of #130697 - bjoernager:const-char-make-ascii, r=dtolnay REVERT: 36b115fba8d Mark 'make_ascii_uppercase' and 'make_ascii_lowercase' in 'char' as const; REVERT: 98aba66e96e make unstable Result::flatten a const fn REVERT: d0989933442 Rollup merge of #130653 - RalfJung:result-abi-compat, r=traviscross REVERT: 2953dee0e23 Rollup merge of #130408 - okaneco:into_lossy_refactor, r=Noratrieb REVERT: 94105e87d4f wait for two short reads before uncapping the max read size REVERT: dea467af191 Mark and implement 'char::encode_utf16' as const; Rewrite 'encode_utf16_raw'; REVERT: 49128a49622 Fix docs of compare_bytes REVERT: db6427b456d ABI compatibility: mention Result guarantee REVERT: 1632f8f88e8 Reword ManuallyDrop+Box interaction REVERT: 4969ea81953 Rollup merge of #129718 - lolbinarycat:remove_dir-docs, r=Noratrieb REVERT: c11b3aa4a78 Avoid re-validating UTF-8 in `FromUtf8Error::into_utf8_lossy` REVERT: 93f5e21e0f0 Auto merge of #130631 - GuillaumeGomez:rollup-jpgy1iv, r=GuillaumeGomez REVERT: a7aac1ef4d2 Remove double spaces REVERT: 74935ec3185 Rollup merge of #130624 - theemathas:vec_as_non_null, r=Noratrieb REVERT: 2c9a4e3f2b2 Rollup merge of #130611 - bjoernager:const-char-encode-utf8, r=dtolnay REVERT: 25ab8efde9f Rollup merge of #130526 - eholk:pin-reborrow, r=compiler-errors REVERT: 97c4937a933 Rollup merge of #128209 - beetrees:no-macos-10.10, r=jieyouxu REVERT: 3e5c662a8b4 Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errors REVERT: 31d575bd5a0 Add `Vec::as_non_null` REVERT: 54e23b5d765 Address diagnostics regression for 'const_char_encode_utf8'; REVERT: 557a0b8ac2e Allow unused unsafe for vxworks in alligned_malloc to resolve build errors REVERT: 7ae682789c0 [Clippy] Remove final std paths for diagnostic item REVERT: 7b1c5e87b84 Allow shortening reborrows REVERT: 86240c7ca53 Add `#[track_caller]` to allocating methods of `Vec` & `VecDeque` REVERT: 33945576c22 Rollup merge of #130554 - ShE3py:unsupported-exitcode, r=Noratrieb REVERT: 17b0e39d3a9 Rollup merge of #130553 - GnomedDev:remove-clippy-paths, r=compiler-errors REVERT: 64a59842bb1 Rollup merge of #128001 - Krappa322:master, r=scottmcm REVERT: 81c4805e8ad Add str.as_str() for easy dereferencing of Box REVERT: 4ea6b8269c5 `pal::unsupported::process::ExitCode`: use an `u8` instead of a `bool` REVERT: cb771b22bc6 [Clippy] Swap `open_options` to use diagnostic items instead of paths REVERT: 04bd505e545 [Clippy] Swap `iter_over_hash_type` to use diagnostic items instead of paths REVERT: 8147cf45a26 [Clippy] Swap `non_octal_unix_permissions` to use diagnostic item instead of path REVERT: 1b0be2aa317 [Clippy] Swap `unnecessary_owned_empty_strings` to use diagnostic item instead of path REVERT: 9edfe1dc97f [Clippy] Swap `manual_strip` to use diagnostic items instead of paths REVERT: 995238ce3f5 [Clippy] Swap `unnecessary_to_owned` to use diagnostic item instead of path REVERT: c1a4a69d65a [Clippy] Swap `instant_subtraction` to use diagnostic item instead of path REVERT: beaebb53af0 [Clippy] Swap `waker_clone_wake` to use diagnostic item instead of path REVERT: 925c1c4ffc8 [Clippy] Swap `filter_map_bool_then` to use diagnostic item instead of path REVERT: 7bc30a7e0d1 [Clippy] Swap `manual_while_let_some` to use diagnostic items instead of paths REVERT: 08b676d07d8 [Clippy] Swap `repeat_vec_with_capacity` to use diagnostic item instead of path REVERT: b95bef03da4 [Clippy] Swap `VecArgs::hir` to use diagnostic items instead of paths REVERT: 6906fa9d9f5 [Clippy] Swap `single_char_add_str`/`format_push_string` to use diagnostic items instead of paths REVERT: b2dc66e63fe [Clippy] Swap `manual_main_separator_str` to use diagnostic item instead of path REVERT: a61b7b74edc [Clippy] Swap `redundant_clone` to use diagnostic items instead of paths REVERT: 3310a0ba289 [Clippy] Swap `float_equality_without_abs` to use diagnostic items instead of paths REVERT: 6ef72c4aead [Clippy] Swap `option_as_ref_deref` to use diagnostic items instead of paths REVERT: b8c0c3b59d6 [Clippy] Swap `lines_filter_map_ok` to use a diagnostic item instead of path REVERT: 116e527af29 [Clippy] Swap `map_entry` to use diagnostic items instead of paths REVERT: 03ff0df4056 Auto merge of #130547 - workingjubilee:rollup-tw30khz, r=workingjubilee REVERT: 6210ecb4fdb Auto merge of #130511 - bjoernager:const-char-encode-utf8, r=dtolnay REVERT: ccb31b838d9 run `x.py fmt` REVERT: 9510c7695c8 remove feature attributes as const_maybe_uninit_as_mut_ptr is stabilized REVERT: c12546bbad7 stabilize `const_maybe_uninit_as_mut_ptr` REVERT: e94c0809293 Mark and implement 'char::encode_utf8' as const. REVERT: 150994417ab Rollup merge of #130522 - GnomedDev:clippy-manual-retain-paths, r=compiler-errors REVERT: 8a9576c7fe5 Rollup merge of #130513 - shekhirin:fs-write-doc-comment, r=cuviper REVERT: d53d48a35c6 Rollup merge of #130487 - cuviper:min-llvm-18, r=nikic REVERT: f63c0c181dc Rollup merge of #130476 - workingjubilee:more-lazy-methods-take-2, r=Amanieu REVERT: 09e36adc31d Rollup merge of #129934 - ChrisDenton:remove-dir-all3, r=Amanieu REVERT: 5480d57c571 Rollup merge of #97524 - ibraheemdev:thread-raw, r=ibraheemdev REVERT: 886fc13b4a6 Revert "Add a hack to prevent proc_macro misopt in CI" REVERT: 56704d424c8 Begin experimental support for pin reborrowing REVERT: 262a08b3220 library: Call it really_init_mut to avoid name collisions REVERT: 51023b58e9b library: Destabilize Lazy{Cell,Lock}::{force,deref}_mut REVERT: ff51d9fe674 [Clippy] Swap `manual_retain` to use diagnostic items instead of paths REVERT: 28695bfc395 Auto merge of #130497 - saethlin:alloc-zeroed-is-unstable, r=bjorn3 REVERT: 8f6ca5b3867 Clarify docs for std::fs::File::write REVERT: b19bf06090d Auto merge of #129491 - StackOverflowExcept1on:master, r=m-ou-se REVERT: 37eb770d8c1 Auto merge of #129845 - scottmcm:redo-layout, r=Noratrieb REVERT: cc10a764910 Take more advantage of the `isize::MAX` limit in `Layout` REVERT: d740b8d22b1 read_volatile __rust_no_alloc_shim_is_unstable in alloc_zeroed REVERT: c4fe01a6b27 add `Thread::{into_raw, from_raw}` REVERT: e65d8e8dfef Rollup merge of #130481 - krtab:clamp_partial_ord, r=cuviper REVERT: f3a53b7c4de Auto merge of #130483 - matthiaskrgr:rollup-q1r0g0y, r=matthiaskrgr REVERT: 46a0aa844f2 Remove uneeded PartialOrd bound in cmp::Ord::clamp REVERT: c83fbfd2017 Rollup merge of #130467 - RalfJung:miri-sync, r=RalfJung REVERT: 6893990b5ba Rollup merge of #129674 - matthewpipie:rc-arc-new-cyclic-in, r=dtolnay REVERT: a0f4a4b3281 Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut` REVERT: 7505e2956ba Rollup merge of #128535 - mmvanheusden:master, r=workingjubilee REVERT: 8a5922fb084 Auto merge of #130145 - fee1-dead-contrib:repeatn, r=lcnr,workingjubilee REVERT: c15d489d04d Merge from rustc REVERT: e80d16cdf1e Rollup merge of #130448 - alilleybrinker:master, r=workingjubilee REVERT: cd8a7af7d0e Update library/alloc/src/sync.rs REVERT: 2819604711d Auto merge of #127633 - SamuelMarks:eq-exit-code, r=dtolnay REVERT: 49a855dba5e fix: Remove duplicate `LazyLock` example. REVERT: 9af97fc0a10 Rollup merge of #127879 - kornelski:bad-pointer-printf, r=workingjubilee REVERT: 2c1bd02a09a Merge from rustc REVERT: fc9c9009d26 Auto merge of #130220 - RalfJung:float-classify, r=workingjubilee REVERT: 35edcb6461b update docs for `catch_unwind` & related funcs REVERT: ee67105e0ae Rollup merge of #130339 - CAD97:unwind-choice, r=dtolnay REVERT: f3968493684 simplify abort_unwind REVERT: b66efddccf2 Rollup merge of #129439 - okaneco:vec_string_lossy, r=Noratrieb REVERT: af73374905e Rollup merge of #130381 - workingjubilee:sometimes-code-really-is-self-descriptive, r=Noratrieb REVERT: 524402a0fd4 Rollup merge of #130118 - RalfJung:unwrap_unchecked, r=Noratrieb REVERT: 3dccb864068 Rollup merge of #129195 - RalfJung:const-mut-refs, r=fee1-dead REVERT: 524a5e14330 also stabilize const_refs_to_cell REVERT: 29c8eef74ff const_refs_to_cell: dont let mutable references sneak past the interior mutability check REVERT: 5671193598c stabilize const_mut_refs REVERT: 085baa2b96e library: Compute Rust exception class from its string repr REVERT: fc53427da98 Rollup merge of #130214 - RalfJung:zeroed, r=Mark-Simulacrum REVERT: 0e7d343962e Rollup merge of #130061 - theemathas:box_vec_non_null, r=MarkSimulacrum,workingjubilee REVERT: 09f1d40a239 Rollup merge of #130042 - lolbinarycat:bufreaker_peek_eof, r=Amanieu REVERT: 0fd6e237ada Add tracking issue number for `box_vec_non_null` REVERT: d38c59a2454 Rollup merge of #130290 - passcod:stabilise-entry-insert, r=ChrisDenton REVERT: 96b5b7cd3e6 Rollup merge of #130268 - RalfJung:simd-shuffle-idx-vector, r=compiler-errors REVERT: 79d937d0854 simd_shuffle: require index argument to be a vector REVERT: 857ad2299b8 Rollup merge of #130053 - glowcoil:next_if-docs, r=jhpratt REVERT: 9c71d4ed0a3 add std::panic::abort_unwind REVERT: 91ebe065a2b add core::panic::abort_unwind REVERT: f30a0ad1f84 Merge from rustc REVERT: 24fa8b92d38 Rustfmt REVERT: 4f3d542db01 [`cfg_match`] Generalize inputs REVERT: 80f8aeb7458 Fix awkward wording. REVERT: 84d77befb81 Address WaffleLapkin's comments REVERT: 84da2fc1d77 Update tests for hidden references to mutable static REVERT: 34e22e80c1a Rollup merge of #130245 - RalfJung:miri-alloc-backtrace, r=Amanieu REVERT: ba7302270d3 Stabilize entry_insert REVERT: 283ce13a8f1 Auto merge of #130281 - matthiaskrgr:rollup-1b2ibs8, r=matthiaskrgr REVERT: ac68273ba0c Rollup merge of #130101 - RalfJung:const-cleanup, r=fee1-dead REVERT: 6695a568f5b Document subtleties of `ManuallyDrop` REVERT: 1128894f6c8 Stabilize `const_float_classify` REVERT: 0de05400c79 Auto merge of #129992 - alexcrichton:update-compiler-builtins, r=tgross35 REVERT: 553ca3f0eda also update the wrapping_ docs to use similar wording REVERT: 27049a03ee5 Rollup merge of #130160 - Scripter17:fix-slice-first_mut-doc, r=Amanieu REVERT: 03dedd99fd9 Rollup merge of #125060 - ChrisJefferson:pathbuf-doc, r=workingjubilee REVERT: abe63f65a04 simplify float::classify logic REVERT: 34e4b6d8f7e Fixup docs for PathBuf REVERT: 22ffa3d384f Expand PathBuf documentation REVERT: 4afc77fbbde Merge from rustc REVERT: 5997b68ff2a Auto merge of #130183 - Marcondiro:unicode-16.0.0, r=Manishearth REVERT: 60b4cf8f49c Rollup merge of #130248 - nyurik:fix-129895, r=workingjubilee REVERT: 136504a6163 Rollup merge of #130168 - juliusl:pr/fix-win-fs-change-time-links, r=ChrisDenton REVERT: e9cd33cba20 Rollup merge of #130077 - madsmtm:watchos-arm-unwind, r=workingjubilee REVERT: 0ff84286245 Rollup merge of #129835 - RalfJung:float-tests, r=workingjubilee REVERT: 15a8ea1b299 Rollup merge of #129696 - RalfJung:stdarch, r=Amanieu REVERT: e977a4483e4 Limit `libc::link` usage to `nto70` target only, not NTO OS REVERT: acd25269596 various updates based on review REVERT: dbf585c158e make basic allocation functions track_caller in Miri for nicer backtraces REVERT: 3e2ea2b035a chore: remove struct details REVERT: 6ff27d2d309 Rollup merge of #130207 - GrigorenkoPV:ERROR_CANT_RESOLVE_FILENAME, r=ChrisDenton REVERT: 0a476447a26 Rollup merge of #130206 - GrigorenkoPV:WSAEDQUOT, r=ChrisDenton REVERT: 61a646bcf16 Rollup merge of #129866 - root-goblin:patch-1, r=workingjubilee REVERT: bfe2669a142 docs: remove struct info REVERT: 3c00ffabf46 ptr::add/sub: these are *not* equivalent to offset(count as isize) REVERT: e8ddc864cb7 update stdarch REVERT: a55bf34b421 MaybeUninit::zeroed: mention that padding is not zeroed REVERT: 04c4ab4a2a1 clean up internal comments about float semantics REVERT: fc9b01ff3b2 these tests seem to work fine on i586 these days REVERT: 95de48b8208 Auto merge of #129403 - scottmcm:only-array-simd, r=compiler-errors REVERT: 95f9af09fc2 Clarify docs for std::collections REVERT: cc0044c5077 Map `ERROR_CANT_RESOLVE_FILENAME` to `ErrorKind::FilesystemLoop` REVERT: fde9f6bb823 Map `WSAEDQUOT` to `ErrorKind::FilesystemQuotaExceeded` REVERT: 22c4e8e02e4 Auto merge of #130025 - Urgau:missing_docs-expect, r=petrochenkov REVERT: 0eb5d756238 Bump unicode printable to version 16.0.0 REVERT: 17e1039b09f Bump unicode_data to version 16.0.0 REVERT: 4d5609fc793 Auto merge of #130179 - workingjubilee:rollup-l78cv44, r=workingjubilee REVERT: d9d37510b85 Ban non-array SIMD REVERT: 7e4cfbc077d Rollup merge of #130164 - RalfJung:const_ptr_as_ref, r=dtolnay REVERT: 3fdbce0f3f5 Rollup merge of #130146 - folkertdev:bootstrap-naked-asm, r=Amanieu REVERT: 0bbb25df201 Rollup merge of #130132 - sunshowers:illumos-sigsegv, r=Noratrieb REVERT: ec7fd8a79b5 Rollup merge of #128316 - GrigorenkoPV:io_error_a_bit_more, r=dtolnay REVERT: 237b11d4e77 Auto merge of #129778 - RalfJung:interp-lossy-typed-copy, r=saethlin REVERT: b47535f9562 chore: removing supporting links in favor of existing doc-comment style REVERT: b6f9e80a922 maint: update docs for change_time ext and doc links REVERT: f7b7aa3dce4 Rollup merge of #130154 - okaneco:stabilize_char_min, r=cuviper REVERT: 5a87e4c04c5 Rollup merge of #130067 - madsmtm:clean-up-fs-test, r=ChrisDenton REVERT: 41cd5712d57 move const fn with a null check into const_ptr_is_null gate REVERT: f28b1d1f142 move some const fn out of the const_ptr_as_ref feature REVERT: 4b1440a98ef Fix slice::first_mut docs pointer -> reference REVERT: 2bc7f6c8ae7 Stabilize `char::MIN` REVERT: d2571591f4f fix UB in a test REVERT: 931d271b035 Add missing `#[allow(missing_docs)]` on hack functions in alloc REVERT: 4f7783143b7 `RepeatN`: use MaybeUninit REVERT: 0414a2efc72 bootstrap `naked_asm!` for `compiler-builtins` REVERT: 2582bbb06c7 Rollup merge of #130115 - eduardosm:needless-returns-libs, r=workingjubilee REVERT: e8d9b858f36 Rollup merge of #130107 - RalfJung:const-ptr-is-null, r=oli-obk REVERT: 2e128a21428 Rollup merge of #130090 - RalfJung:result-copied, r=Noratrieb REVERT: 2ee8304535b Rollup merge of #130087 - RalfJung:option-const-iter, r=workingjubilee REVERT: af9a77d0661 [illumos] enable SIGSEGV handler to detect stack overflows REVERT: 1b763fc2428 remove const_slice_index annotations, it never had a feature gate anyway REVERT: 9849587e9b4 add FIXME(const-hack) REVERT: 565b336d144 move Option::unwrap_unchecked into const_option feature gate REVERT: f9a9560c597 Remove needless returns detected by clippy in libraries REVERT: cc4242b209f const: make ptr.is_null() stop execution on ambiguity REVERT: 295946c6c1a Option, Result: put the &mut variants of 'copied' under the same feature as the '&' variants REVERT: 4caabcd5cea Auto merge of #130002 - orlp:better-div-floor-ceil, r=thomcc REVERT: 55f602f895a Auto merge of #129019 - kromych:master, r=workingjubilee REVERT: 84184ab6ba4 Fix linking error when compiling for 32-bit watchOS REVERT: e954412fd46 remove pointless rustc_const_unstable on trait impls REVERT: 0dc4621c3ac add some FIXME(const-hack) REVERT: 796ae33b0c9 Auto merge of #130091 - matthiaskrgr:rollup-kalu1cs, r=matthiaskrgr REVERT: 64afc032b5d Rollup merge of #130047 - ChrisDenton:win-dbghelp, r=wesleywiser REVERT: 944866225f4 Rollup merge of #130046 - RalfJung:const_str_as_mut, r=dtolnay REVERT: 2feca1e6134 Rollup merge of #129555 - RalfJung:const_float_bits_conv, r=dtolnay REVERT: 4f47132d7d3 Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68 REVERT: 72723d7cc0d make Result::copied unstably const REVERT: 50116718108 remove 'const' from 'Option::iter' REVERT: 3a535378088 str: make as_mut_ptr and as_bytes_mut unstably const REVERT: 9469575a168 restate GlobalAlloc method safety preconditions in terms of what the caller has to do for greater clarity REVERT: ff7b66117b7 Remove now redundant check in symlink_hard_link test REVERT: 459f246405d Add `NonNull` convenience methods to `Vec` REVERT: a2e7f8b53ee Add `NonNull` convenience methods to `Box` REVERT: d1005f501ee fix doc comments for Peekable::next_if(_eq) REVERT: a9cf084c94a Remove duplicate impl REVERT: 7b61eea4f31 remove the Clone requirement REVERT: d6e859b240e Win: Add dbghelp to the list of import libraries REVERT: 335236cb011 properly handle EOF in BufReader::peek REVERT: b2d6fdd4d85 [library/std/src/process.rs] Remove `Eq` `derive` REVERT: fd0bc94d539 Adjust doc comment of Condvar::wait_while REVERT: 2699de648cc Rollup merge of #129963 - rjooske:fix/inaccurate_to_string_lossy_doc, r=workingjubilee REVERT: cde81452601 Auto merge of #129999 - matthiaskrgr:rollup-pzr9c8p, r=matthiaskrgr REVERT: 678165efe80 Break into the debugger (if attached) on panics (Windows, macOS, Linux, FreeBSD) REVERT: b947f0a81ef better implementation of signed div_floor/ceil REVERT: ab4b4f8c12e Rollup merge of #129947 - LiterallyVoid:duration-docs-digit-separators, r=tgross35 REVERT: 3e7e6cdbd64 Rollup merge of #129653 - RalfJung:addr-of-read-only, r=scottmcm REVERT: e51a0bc9ea0 Rollup merge of #129938 - chancancode:patch-1, r=thomcc REVERT: 355445b0261 [library/std/src/process.rs] Update docstring with @joshtriplett's replacement text REVERT: 0d4a80eaee3 Update compiler-builtins to 0.1.125 REVERT: 349f8d57256 update cfgs REVERT: 181dc2674a5 Rollup merge of #129919 - kevinmehall:waker-getters, r=dtolnay REVERT: 3d2a91f59a9 Rollup merge of #127021 - thesummer:1-add-target-support-for-rtems-arm-xilinx-zedboard, r=tgross35 REVERT: 25891c8560a Rollup merge of #101339 - the8472:ci-randomize-debug, r=Mark-Simulacrum REVERT: 5446229e7af Use non-overlapping swap for inner heapsort loop REVERT: 670630da181 Select tiny sorts for 16-bit platforms REVERT: cd3d6e88bc9 Shrink heapsort further by combining sift_down loops REVERT: bea61dafef2 Drop bubble_sort REVERT: eb4746892bf fix: correct {Path,OsStr}::to_string_lossy() docs REVERT: 83938b9ae3d Remove macOS 10.10 dynamic linker bug workaround REVERT: 76972316fb6 docs: add digit separators in `Duration` examples REVERT: 9ed92df9886 replace placeholder version REVERT: 00e12f791e4 Update marker.rs REVERT: 5de059ff2d0 Update marker.rs REVERT: 72e79f0c1de Update marker.rs REVERT: 870dfeddde9 Update marker.rs REVERT: de72cd33be9 Elaborate on deriving vs implementing `Copy` REVERT: be2b964527c Win: Open dir for sync access in remove_dir_all REVERT: fee63007a49 More robust extension checking REVERT: ae90e450fd9 Port std library to RTEMS REVERT: c313c072ba2 Rollup merge of #129916 - tshepang:basic-usage, r=ChrisDenton REVERT: c501959a497 Rollup merge of #129913 - saethlin:l4re-read-buf, r=Noratrieb REVERT: 83524b98e8b Rollup merge of #129885 - cuishuang:master, r=scottmcm REVERT: e41afdc2cc8 Rollup merge of #129800 - ChrisDenton:remove-dir-all2, r=Amanieu REVERT: 851f5b63258 Add `Waker::new` and `LocalWaker::new` REVERT: a2b8bb8baae Stabilize waker_getters REVERT: 2ec266b2cd4 Move the `data` and `vtable` methods from `RawWaker` to `Waker` REVERT: 562fdcec802 process.rs: remove "Basic usage" text where not useful REVERT: 9b3c3fecc0d Rollup merge of #129907 - saethlin:solid-io-error, r=WaffleLapkin REVERT: 02cecebd3a9 Rollup merge of #129892 - oskgo:clarify-slice-from-raw, r=RalfJung REVERT: ccc294c2a53 Rollup merge of #129890 - alex:patch-1, r=workingjubilee REVERT: 6d0e687304b Rollup merge of #129856 - RalfJung:compiler_fence, r=thomcc REVERT: 0ccc851a07e Rollup merge of #129748 - RalfJung:box-validity, r=workingjubilee REVERT: 37618495ad7 Add missing read_buf stub for x86_64-unknown-l5re-uclibc REVERT: 3b8ab5a6439 Fix compile error in solid's remove_dir_all REVERT: e14b9f387e8 clarify language around non-null ptrs in slice::raw REVERT: 9a76abd8364 Remove stray word in a comment REVERT: 1dd630f2324 Auto merge of #129873 - matthiaskrgr:rollup-bv849ud, r=matthiaskrgr REVERT: 26498824037 chore: remove repetitive words REVERT: 7fd784ec2ba Rollup merge of #129804 - ranger-ross:fixed-documentation-typos, r=Noratrieb REVERT: e4e9f6b9248 Rollup merge of #129793 - lolbinarycat:doc-missing-newlines, r=workingjubilee REVERT: c4aa66aca88 Auto merge of #129063 - the8472:cold-opt-size, r=Amanieu REVERT: 4e3dbeedf82 add extra linebreaks so rustdoc can identify the first sentence REVERT: e00784f5e85 compiler_fence documentation: emphasize synchronization, not reordering REVERT: a4c4e236c17 stabilize const_float_bits_conv REVERT: 8d8dbe91b02 tweak wording regarding Box validity REVERT: 065844bb5f0 Auto merge of #127897 - nyurik:add-qnx-70-target, r=saethlin REVERT: 759399be7a3 Rollup merge of #129832 - eduardosm:stray-dot, r=jhpratt REVERT: 60f37e4ad71 Rollup merge of #129207 - GrigorenkoPV:elided-is-named, r=cjgillot REVERT: 68e6537ba28 Rollup merge of #128641 - Konippi:standardize-duplicate-processes-in-parser, r=scottmcm REVERT: b93e3abbf07 Rollup merge of #128495 - joboet:more_memcmp, r=scottmcm REVERT: 64c1db22d08 when -Zrandomize-layout is enabled disable alloc test testing internal struct sizes REVERT: d432698157c Auto merge of #129831 - matthiaskrgr:rollup-befq6zx, r=matthiaskrgr REVERT: 77cf0ba112b Remove stray dot in `std::char::from_u32_unchecked` documentation REVERT: ef033b028ed Rollup merge of #129826 - Alcaro:patch-1, r=workingjubilee REVERT: 2ad03e02998 Rollup merge of #129650 - Zalathar:profiler-builtins, r=Mark-Simulacrum REVERT: c33b3dfa8ec Update mod.rs REVERT: 24ed1c124d6 Rollup merge of #129785 - RalfJung:miri-sync, r=RalfJung REVERT: 50681ab44e8 Rollup merge of #129730 - RalfJung:float-arithmetic, r=workingjubilee REVERT: 0402bb10c5a Fix `elided_named_lifetimes` in code REVERT: 3a754b1b94e Improve documentation for ::from_str_radix REVERT: 667d060bfd6 Move remove_dir_all impl into a module REVERT: ae18edf95f4 Rollup merge of #129754 - alexcrichton:fix-wasi-long-sleep, r=workingjubilee REVERT: 9138bd188f5 Rollup merge of #129675 - lolbinarycat:bufreader_peek_unsized, r=workingjubilee REVERT: 83cadd0fe20 Rollup merge of #129642 - workingjubilee:bump-backtrace-fc37b22, r=workingjubilee REVERT: d9af971403a Rollup merge of #129640 - saethlin:unignore-android-in-alloc, r=tgross35 REVERT: 6b12a632e1d Fixed more typos in library/core REVERT: 40f9251a0cd Fixed typos in btree map docs REVERT: 628be3dae28 Fixed some typos in the standard library documentation/comments REVERT: 21e893e6b6d enumerate the two parts of the NaN rules REVERT: 081353cd333 add hyphen in floating-point REVERT: c664843f3b7 Squashed `aarch64_unknown_nto_qnx700` support REVERT: 5c4c81a7c61 Merge from rustc REVERT: 24eca285951 add new_cyclic_in for Arc REVERT: 88d85a8c068 improve comments REVERT: 3e677e3f79a fix new_cyclic_in for rc REVERT: 7d4ef1728c0 fix fmt REVERT: a37464739a6 Try latest backtrace REVERT: 2c75dd81561 wasi: Fix sleeping for `Duration::MAX` REVERT: 374229a0231 Rollup merge of #128166 - ChaiTRex:isqrt, r=tgross35 REVERT: f0dce767de0 Rollup merge of #123940 - kornelski:remove-derived-debug, r=Urgau REVERT: 228ec9e62ac Box validity: update for new zero-sized rules REVERT: 717e3aa5f1f Use simpler branchy swap logic in tiny merge sort REVERT: 93a72daf8ad f32 docs: define 'arithmetic' operations REVERT: 1bc188fd531 Merge from rustc REVERT: c44af617f84 Speed up `checked_isqrt` and `isqrt` methods REVERT: 21396512b94 Improve `isqrt` tests and add benchmarks REVERT: 7c1560f9833 Rollup merge of #129715 - Amjad50:update-compiler-builtins, r=tgross35 REVERT: d2a001df590 Rollup merge of #129683 - RalfJung:copysign, r=thomcc REVERT: 8753a357ece Rollup merge of #129673 - matthewpipie:arc-weak-debug-trait, r=dtolnay REVERT: 3e1f63a7ab6 Rollup merge of #129401 - workingjubilee:partial-initialization-of-stabilization, r=dtolnay,joboet REVERT: cd59153e222 Rollup merge of #129378 - goffrie:patch-3, r=ChrisDenton REVERT: 6d31b6de716 Rollup merge of #128192 - mrkajetanp:feature-detect, r=Amanieu REVERT: 5fa71afdd50 add guarantee about remove_dir and remove_file error kinds REVERT: 60fd9c980c3 Update `compiler_builtins` to `0.1.123` REVERT: 86c924ff3e5 fmt-debug option REVERT: 8623fa49bac allow BufReader::peek to be called on unsized types REVERT: b1a56b508b6 Auto merge of #129691 - matthiaskrgr:rollup-owlcr3m, r=matthiaskrgr REVERT: 39ad6a926e3 Rollup merge of #129668 - coolreader18:fix-pin-set-regr, r=dtolnay REVERT: 5a4fe4044d8 Rollup merge of #129657 - jswrenn:transmute-name, r=compiler-errors REVERT: 1d44fabf570 Rollup merge of #129551 - RalfJung:ub-checks-fallback, r=saethlin REVERT: b0fee9815c8 Rollup merge of #129480 - lolbinarycat:euclid-docs, r=joboet REVERT: c8d3265d52d Enable some ilog2 tests as well REVERT: da08ef4ef5a Re-enable android tests/benches in alloc REVERT: bfbe13e1767 Auto merge of #129589 - saethlin:improve-panic-immediate-abort, r=tgross35 REVERT: 89021c809f8 copysign with sign being a NaN is non-portable REVERT: ed66a11c68e addr_of on places derived from raw pointers should preserve permissions REVERT: ea236f07aef add new_cyclic_in for rc REVERT: 17298981159 Add fmt::Debug to sync::Weak REVERT: 927a6da67ab Fix Pin::set bounds regression REVERT: 9876bd1014d library: Stabilize new_uninit for Box, Rc, and Arc REVERT: a0ea69f6e4e Rollup merge of #129652 - RalfJung:ptr-to-ref, r=traviscross REVERT: c7cbb41d48c Rollup merge of #129645 - beetrees:fix-float-docs, r=tgross35 REVERT: 04eabb59f6a Rollup merge of #129581 - RalfJung:exit, r=joshtriplett REVERT: 33e2d7e8de6 safe transmute: Rename `BikeshedIntrinsicFrom` to `TransmuteFrom` REVERT: 72c676f1fdb Auto merge of #128134 - joboet:move_pal_alloc, r=cupiver REVERT: c108af0dbf3 fix Pointer to reference conversion docs REVERT: 193310350fc clarify that addr_of creates read-only pointers REVERT: 4f6b8149292 rustc_target: Add SME aarch64 features REVERT: 012bb44c6c5 rustc_target: Add various aarch64 features REVERT: 4dc5b675267 std: move allocators to `sys` REVERT: ae57bdf05e4 Use last swap optimization in bubblesort REVERT: 264fa88ed6a Don't skip nonexistent source files REVERT: 5298b521b75 Add `cargo::rerun-if-changed` directives for source directories REVERT: 5defa797459 Always include `WindowsMMap.c` in the list of source files REVERT: 91d2ecf1eca Sort the list of source files REVERT: cb468d737ba Remove `InstrProfilingBiasVar.c` from the list of source files REVERT: 0e0134f5d4b Use helper functions to read environment variables REVERT: a628540ba41 Rollup merge of #129559 - RalfJung:float-nan-semantics, r=thomcc REVERT: 00c8f98e15e Rollup merge of #128731 - RalfJung:simd-shuffle-vector, r=workingjubilee REVERT: 6d3344f0919 Update old comment referring to `libcompiler_builtins` REVERT: 6d8a1f6903e Reflow a couple of paragraphs in floating-point primitive docs REVERT: 8834d35fa4b Fix typos in floating-point primitive type docs REVERT: 54c986a8287 Bump backtrace to rust-lang/backtrace@fc37b22 REVERT: 932cbd42f14 Rollup merge of #129032 - jswrenn:transmute-method, r=compiler-errors REVERT: 28a983de9a8 Rollup merge of #128157 - lolbinarycat:unify-ptr-ref-docs, r=cuviper REVERT: d1e21bdba8d Apply suggestions from code review REVERT: febaf22f00e Rollup merge of #129592 - saethlin:core-cfg-test, r=tgross35 REVERT: 77a1318f7f7 Rollup merge of #129588 - hermit-os:sleep-micros, r=workingjubilee REVERT: 12fe23bd5dc Rollup merge of #129539 - oconnor663:poll_link, r=tgross35 REVERT: 864e465be7b Rollup merge of #129377 - chorman0773:unbounded-shifts-impl, r=scottmcm REVERT: 07cfc6ae040 also update copysign docs REVERT: acaef605e72 move per-target NaN info into a table REVERT: 854ba7e4cef float types: document NaN bit pattern guarantees REVERT: 2fa330eeddd Convert cfg blocks to cfg_if REVERT: f46fcfed644 Reduce code duplication by moving partition_lomuto_branchless_simple into quicksort module REVERT: d958260763a Auto merge of #129595 - matthiaskrgr:rollup-4udn7nn, r=matthiaskrgr REVERT: 8dd3363de6a Remove cfg(test) from library/core REVERT: cd554e2b4ea Rollup merge of #129544 - mu001999-contrib:dead-code/clean, r=compiler-errors REVERT: ff769eef88a Rollup merge of #129525 - notriddle:notriddle/fake-variadic-tuple-array, r=GuillaumeGomez REVERT: 4d22c1c6b37 Auto merge of #129488 - saethlin:alignment-precondition, r=workingjubilee REVERT: c688deff96a pal/hermit: saturate `usleep` microseconds at `u64::MAX` REVERT: 8ea71ae5647 Auto merge of #129563 - matthiaskrgr:rollup-t6bai2d, r=matthiaskrgr REVERT: 46eff207f56 Tweak some attributes to improve panic_immediate_abort REVERT: fdb5fc1fca6 pal/hermit: correctly round up microseconds in `Thread::sleep` REVERT: 1805c29ca12 Add binary-size optimized variants for stable and unstable sort as well as select_nth_unstable REVERT: b392703506b exit: explain our expectations for the exit handlers registered in a Rust program REVERT: 22ec8977a9a link to Future::poll from the Poll docs REVERT: a994fbbca83 Rollup merge of #129487 - GrigorenkoPV:repr_transparent_external_private_fields, r=compiler-errors REVERT: 3a339226a95 Rollup merge of #129416 - workingjubilee:partial-move-from-stabilization, r=dtolnay REVERT: 3a8de952989 Rollup merge of #129091 - RalfJung:box_as_ptr, r=Amanieu REVERT: 4de4debd1eb Auto merge of #129295 - Zalathar:profiler-builtins, r=Kobzol REVERT: 0872cf30408 ub_checks intrinsics: fall back to cfg(ub_checks) REVERT: 8dafd337e12 Auto merge of #129521 - matthiaskrgr:rollup-uigv77m, r=matthiaskrgr REVERT: d9e489b48ce Removes dead code from the compiler REVERT: c14cf57e404 Rollup merge of #129481 - scottmcm:update-cb, r=tgross35 REVERT: acf6f03b6fa Rollup merge of #129449 - coolreader18:pin-as_deref_mut-signature, r=dtolnay REVERT: 112ebc4d5a9 Rollup merge of #128735 - jieyouxu:pr-120176-revive, r=cjgillot REVERT: 49aa496c5bb rustdoc: clean up tuple <-> primitive conversion docs REVERT: 0fe374666ac Rollup merge of #129501 - RalfJung:miri-rust-backtrace, r=Noratrieb REVERT: 7d5cf38931b Rollup merge of #129500 - fee1-dead-contrib:fxrel, r=compiler-errors REVERT: e91d825f826 Rollup merge of #129323 - Urgau:ptr_fn_addr_eq, r=Mark-Simulacrum REVERT: f6470795864 Rollup merge of #128596 - RalfJung:const_fn_floating_point_arithmetic, r=nnethercote REVERT: f965950f05e New `#[rustc_pub_transparent]` attribute REVERT: a6ea125cb0e panicking: improve hint for Miri's RUST_BACKTRACE behavior REVERT: a437005e6f3 Build `library/profiler_builtins` from `ci-llvm` if appropriate REVERT: 693477a3f65 remove invalid `TyCompat` relation for effects REVERT: 82fc74f6f1a library: Move unstable API of new_uninit to new features REVERT: 4bc6b1fd2a5 Pass `fmt::Arguments` by reference to `PanicInfo` and `PanicMessage` REVERT: 3ee2e18c8dc Enable Alignment::new_unchecked precondition check REVERT: 0803686e7fb Change `f16` doctests in core to run on x86-64 linux REVERT: 9359a126d41 Update `compiler_builtins` to `0.1.121` REVERT: da02e8b5609 Enable `f16` tests on x86 and x86-64 REVERT: f3a198e85be docs: correct panic conditions for rem_euclid and similar functions REVERT: 976fb4aeefc Move into_inner_unchecked back to the bottom of the impl block REVERT: 2741e8dacb4 Put Pin::as_deref_mut in impl Pin REVERT: 88790f80130 document & impl the transmutation modeled by `BikeshedIntrinsicFrom` REVERT: f670207d0f4 Auto merge of #129464 - GuillaumeGomez:rollup-ckfqd7h, r=GuillaumeGomez REVERT: 5bf661cc64f Rollup merge of #129276 - eduardosm:stabilize-char_indices_offset, r=Amanieu REVERT: e2614f24b27 Rollup merge of #129400 - Amjad50:update-compiler-builtins, r=tgross35 REVERT: 2c06146be10 Rollup merge of #127623 - lolbinarycat:fix_remove_dir_all, r=Amanieu REVERT: 1339c1bf0a9 Implement feature `string_from_utf8_lossy_owned` REVERT: eb747e53dd0 Check that `library/profiler_builtins` actually found some source files REVERT: eae79872269 fix typos in new pointer conversion docs REVERT: fe33d2c256c fix: fs::remove_dir_all: treat ENOENT as success REVERT: 3fd591ebdef feat(core): Make `unbounded_shl{l,r}` unstably const and remove `rustc_allow_const_fn_unstable` REVERT: 2168ce32967 Auto merge of #129398 - matthiaskrgr:rollup-50l01ry, r=matthiaskrgr REVERT: 12944c76047 Update `compiler_builtins` to `0.1.120` REVERT: 7496478b7a5 stabilize const_fn_floating_point_arithmetic REVERT: 6f534f94217 Rollup merge of #129382 - tgross35:once-cell-const-into-inner, r=Noratrieb REVERT: 2535017098e Rollup merge of #129376 - ChaiTRex:assert_unsafe_precondition_check_language_ub, r=workingjubilee,the8472 REVERT: 4ec19afe669 Rollup merge of #129374 - ChaiTRex:digit_unchecked_assert_unsafe_precondition, r=scottmcm REVERT: 024ec3c0f62 Rollup merge of #128432 - g0djan:godjan/wasi_prohibit_implicit_unsafe, r=tgross35 REVERT: f671c1129b9 Auto merge of #129365 - matthiaskrgr:rollup-ebwx6ya, r=matthiaskrgr REVERT: 5299ef149b1 fix(core): Use correct operations/values in `unbounded_shr` doctests REVERT: 84230062104 chore: `x fmt` REVERT: cbe7338e1f3 fix(core): Add `#![feature(unbounded_shifts)]` to doctests for `unbounded_shr`/`unbounded_shl` REVERT: 863123bd7c4 Add `const_cell_into_inner` to `OnceCell` REVERT: b51f35e9d47 format REVERT: 6fd539327d2 chore: `x fmt` and hopefully fix the tidy issue REVERT: e99c681c95b Clean up cfg-gating of ProcessPrng extern REVERT: 9d2bb976994 Change `assert_unsafe_precondition` docs to refer to `check_language_ub` REVERT: 32bd5dfb369 chore: Also format the control flow REVERT: 5f8cf71d7d6 Manually format functions and use `rhs` instead of `v` from my CE testing REVERT: 700af565751 feat(core): Add implementations for `unbounded_shl`/`unbounded_shr` REVERT: a9ad57eb6a1 Use `assert_unsafe_precondition!` in `AsciiChar::digit_unchecked` REVERT: 77bd65fdedc Rollup merge of #129321 - krtab:float_sum, r=workingjubilee REVERT: cc219788b51 Rollup merge of #129232 - ivmarkov:master, r=workingjubilee REVERT: c9cf844ccd3 Rollup merge of #127945 - tgross35:debug-more-non-exhaustive, r=Noratrieb REVERT: d37ebfea900 Rollup merge of #129332 - cuviper:cstr-cast, r=compiler-errors REVERT: 6d01ed8b3bd Rollup merge of #129312 - tbu-:pr_str_not_impl_error, r=Noratrieb REVERT: 93319c80754 Fix stability attribute of `impl !Error for &str` REVERT: 7f8bdd574b6 Auto merge of #126556 - saethlin:layout-precondition, r=joboet REVERT: 9e9141f54eb Auto merge of #128866 - scottmcm:update-stdarch, r=tgross35 REVERT: d47cfba89b7 Update stdarch submodule REVERT: b507a8bfeb9 Try to golf down the amount of code in Layout REVERT: 32b574e848f Avoid extra `cast()`s after `CStr::as_ptr()` REVERT: 9d4113ff24d Rollup merge of #129294 - scottmcm:stabilize-repeat-n, r=Noratrieb REVERT: 62d240d9b6a Implement `ptr::fn_addr_eq` REVERT: 529e33acb80 Change neutral element of to neg_zero REVERT: 126935f7257 Stabilize `iter::repeat_n` REVERT: 91439ce7b58 Auto merge of #129226 - RalfJung:libc, r=Mark-Simulacrum REVERT: bef7be0e71e Add a precondition check for Layout::from_size_align_unchecked REVERT: a55ab85ad47 Stabilize feature `char_indices_offset` REVERT: 7f45dcfa195 library: bump libc dependency REVERT: ebe99f3b8b6 Rollup merge of #128902 - evanj:evan.jones/env-var-doc, r=workingjubilee REVERT: 9b21aa05574 Document futility of printing temporary pointers REVERT: 8bdd95ba4da soft-deprecate the addr_of macros REVERT: 23b0aadc2ce code review improvements REVERT: 0b0dad4af6f Fix for issue #129212 for the ESP-IDF REVERT: bd7aa576572 Auto merge of #126877 - GrigorenkoPV:clone_to_uninit, r=dtolnay REVERT: d3c08f8f8ac Auto merge of #128598 - RalfJung:float-comments, r=workingjubilee REVERT: dc5fed53253 Auto merge of #106943 - mina86:exact_size_take_repeat, r=dtolnay REVERT: 88927ac26eb Auto merge of #116528 - daxpedda:stabilize-ready-into-inner, r=dtolnay REVERT: 9952947d86b Rollup merge of #129161 - dtolnay:spawnunck, r=Noratrieb REVERT: db3abec9727 Rollup merge of #129086 - slanterns:is_none_or, r=dtolnay REVERT: 44a558dc7dc Stabilize std::thread::Builder::spawn_unchecked REVERT: 028104e3bde Refer to other docs REVERT: 5c553c41134 float to/from bits and classify: update comments regarding non-conformant hardware REVERT: 9704e2df60c Rollup merge of #128064 - ijackson:noop-waker-doc, r=workingjubilee REVERT: 0497f0c6c91 Add cautionary paragraph about noop wakers. REVERT: e0fe4a7ca28 Add unordered list with possible values for each const REVERT: 84ea721e3d5 Format std::env::consts docstrings REVERT: 16dd42669a2 Rollup merge of #128946 - orlp:faster-ip-hash, r=joboet REVERT: 383c4db14b0 Rollup merge of #128925 - dingxiangfei2009:smart-ptr-helper-attr, r=compiler-errors REVERT: ba3a942d5de Rollup merge of #125970 - RalfJung:before_exec, r=m-ou-se REVERT: 32a71bb1dc7 size-optimize some of the panic dependencies REVERT: d7b85f24937 apply #[optimize(size)] to #[cold] ones and part of the panick machinery REVERT: 0dbf8cff9de Rollup merge of #128954 - zachs18:fromresidual-no-default, r=scottmcm REVERT: 4f0959927f2 Rollup merge of #128570 - folkertdev:stabilize-asm-const, r=Amanieu REVERT: b6c9e44d2a6 add Box::as_ptr and Box::as_mut_ptr methods REVERT: 23d1309b02e CommandExt::before_exec: deprecate safety in edition 2024 REVERT: 7921401d1ae stabilize `option_get_or_insert_default` REVERT: 9858d49b168 stabilize `is_none_or` REVERT: fd2b339c5a6 Auto merge of #129060 - matthiaskrgr:rollup-s72gpif, r=matthiaskrgr REVERT: 3b8aab7df81 Rollup merge of #129001 - cblh:fix/128713, r=Noratrieb REVERT: 16edf695130 Rollup merge of #128873 - ChrisDenton:windows-targets, r=Mark-Simulacrum REVERT: 0199b00c91f Rollup merge of #128759 - notriddle:notriddle/spec-to-string, r=workingjubilee,compiler-errors REVERT: c370665e88b Make `std::os::darwin` public REVERT: c6dc243b917 stabilize `asm_const` REVERT: b4bfc215048 Rollup merge of #129034 - henryksloan:coroutine-must-use, r=joboet REVERT: b56fdcb2730 Rollup merge of #127857 - tbu-:pr_deprecated_safe_todo, r=petrochenkov REVERT: 77f462da866 Rollup merge of #122884 - mzabaluev:pow-remove-exit-branch, r=Amanieu REVERT: 0a6a74bce1a Reduce merged doctest source code size REVERT: a83dde61642 Mark location doctest as standalone since file information will not work in merged doctest file REVERT: 7334c7178ce Auto merge of #129046 - matthiaskrgr:rollup-9x4xgak, r=matthiaskrgr REVERT: 9ed72103664 Rollup merge of #128745 - dtolnay:spawnunchecked, r=workingjubilee REVERT: c39d90e4d51 Rollup merge of #128655 - joboet:play_with_the_dice, r=ChrisDenton REVERT: f81c96a863e `#[deprecated_safe_2024]`: Also use the `// TODO:` hint in the compiler error REVERT: 23a19685c9b Allow to customize `// TODO:` comment for deprecated safe autofix REVERT: 37017c0f6f6 Auto merge of #128962 - devnexen:fs_get_mode_haiku, r=workingjubilee REVERT: 6ad03a7161f simd_shuffle intrinsic: allow argument to be passed as vector (not just as array) REVERT: 8a2671a2889 Revert to original loop for const pow exponents REVERT: c5e81895dfb Auto merge of #128742 - RalfJung:miri-vtable-uniqueness, r=saethlin REVERT: ac682f19873 Add must_use attribute to Coroutine trait REVERT: 658904d1a9a chore(lib): fmt core::fmt::Formatter's write_fmt method REVERT: 7eb73762bb3 trying common codepath for every unixes REVERT: 5fabf93c765 std::fs: get_mode implementation for haiku. REVERT: e3da824e62c Rollup merge of #129017 - its-the-shrimp:core_fmt_from_fn, r=Noratrieb REVERT: b247d9a7a9a derive(SmartPointer): register helper attributes REVERT: aa854485cea Explicitly specify type parameter on FromResidual impls in stdlib. REVERT: 262a4f6b641 std::fmt::FormatterFn -> std::fmt::FromFn REVERT: ceceae30ced Rollup merge of #128632 - joboet:dont_overwrite_style, r=Amanieu REVERT: e8f7afeb117 Rollup merge of #128149 - RalfJung:nontemporal_store, r=jieyouxu,Amanieu,Jubilee REVERT: 7dd208356e1 chore(lib): Enhance documentation for core::fmt::Formatter's write_fmt method REVERT: 048efd0bcec ignore some vtable/fn ptr equality tests in Miri, their result is not fully predictable REVERT: a367a12df0a std: use `/scheme/rand` on Redox REVERT: 4b816b496d5 core: make documentation clearer, rename slice comparison specialization trait REVERT: 1ca6b42583f std: do not overwrite style in `get_backtrace_style` REVERT: 91477777de1 Auto merge of #128862 - cblh:fix/128855, r=scottmcm REVERT: 56e1afe0810 Auto merge of #126793 - saethlin:mono-rawvec, r=scottmcm REVERT: ec7a585087c Do not use unnecessary endian conversion. REVERT: f48facfed72 Rollup merge of #128882 - RalfJung:local-waker-will-wake, r=cuviper REVERT: b581949746c Rollup merge of #120314 - mina86:i, r=Mark-Simulacrum REVERT: 451feca66ac Fix stability annotation and expand comment REVERT: 2e34ac388e0 Hash Ipv*Addr as an integer REVERT: b8b61e1e931 Auto merge of #128927 - GuillaumeGomez:rollup-ei2lr0f, r=GuillaumeGomez REVERT: 44f5b4fe515 Rollup merge of #128273 - Voultapher:improve-ord-violation-help, r=workingjubilee REVERT: 3d7afa0e721 Update std and compiler REVERT: 971df1c2948 Stabilize `min_exhaustive_patterns` REVERT: c37c6665b9b Add an optimizer hint for the capacity that with_capacity_in returns REVERT: c8cbd5c499c Hoist IS_ZST check out of RawVecInner::from_*_in REVERT: e843f7103a0 Polymorphize RawVec REVERT: dc39cbf9234 core: optimise Debug impl for ascii::Char REVERT: 9668691af5d doc: std::env::var: Returns None for names with '=' or NUL byte REVERT: 5d5d8bc73a9 Rollup merge of #128859 - MinxuanZ:mips-sig, r=Amanieu REVERT: 825def017bc Rollup merge of #128817 - biabbas:vxworks_update, r=tgross35 REVERT: 6e933a82c90 make LocalWaker::will_wake consistent with Waker::will_wake REVERT: 118c71296c8 Fix linkchecker issue REVERT: b1460b93704 Exclude windows-targets from the workspace REVERT: a3a6a9856c2 Add windows-targets crate to std's sysroot REVERT: f74940d94c2 Rollup merge of #128824 - GuillaumeGomez:update-compiler-builtins, r=Amanieu REVERT: 39b1eafc08c VxWorks: Add safety comment for vxCpuEnabledGet REVERT: 8b0a25df983 fix: Ensure `Guard`'s `drop` method is removed at `opt-level=s` for `Copy` types REVERT: c54958c5dad delete space REVERT: dadbd585cb3 fix format REVERT: 7c34ebf93de [SPARC] fix the name of signal 19 in sparc arch REVERT: b75648a7515 [MIPS] fix the name of signal 19 in mips REVERT: 3840b09aae3 Rollup merge of #128818 - RalfJung:std-miri-floats, r=tgross35 REVERT: d03bb5e33a9 Rollup merge of #128640 - RalfJung:rwlock-macos-miri, r=joboet REVERT: 7680a3c7598 Rollup merge of #128749 - tgross35:float-inline, r=scottmcm REVERT: 9df61adfaa1 Rollup merge of #128306 - WiktorPrzetacznik:WiktorPrzetacznik-nonnull-alignoffset-update, r=Amanieu REVERT: 39860ad52d1 Update compiler-builtins version to 0.1.118 REVERT: 42811859e46 std float tests: special-case Miri in feature detection REVERT: 4d6b36adfe6 Vxworks: Extern taskNameSet and fix build errors REVERT: e24a6ca11fa rwlock: disable 'frob' test in Miri on macOS REVERT: c21ba971a8a Fix VxWorks available parallelism: Move nonzero::uncheked into unsafe block REVERT: 249541802ec Rollup merge of #128800 - clarfonthey:core-pattern-type, r=compiler-errors REVERT: 79cd72af482 Rollup merge of #128691 - tgross35:update-builtins, r=Amanieu REVERT: 8f840157d66 Add tracking issue to core-pattern-type REVERT: b8f7f384f75 Stabilize `Ready::into_inner()` REVERT: 62ccdeb315d Rollup merge of #128261 - clarfonthey:iter-default, r=dtolnay REVERT: b4e53303f07 alloc: make `to_string_str!` a bit less complex REVERT: ec74467d64c Mark `{f32,f64}::{next_up,next_down,midpoint}` inline REVERT: b90a026d6f8 Rollup merge of #128766 - Monadic-Cat:patch-1, r=tgross35 REVERT: 5d7906c0270 Rollup merge of #128417 - tgross35:f16-f128-math, r=dtolnay REVERT: 83d1d167737 Trivial grammar fix in const keyword docs REVERT: 97384fa701b Update `compiler-builtins` to 0.1.117 REVERT: 6dc79bb6235 Rollup merge of #128751 - devnexen:vxworks_set_thread_name, r=tgross35 REVERT: 432425d28f7 Rollup merge of #128539 - biabbas:deny_unsafe, r=workingjubilee REVERT: 1bd5338eadf Rollup merge of #128406 - lolbinarycat:bufreader_peek, r=Mark-Simulacrum REVERT: e20aa6430f1 Rollup merge of #125048 - dingxiangfei2009:stable-deref, r=amanieu REVERT: bc13c6ca57a alloc: add ToString specialization for `&&str` REVERT: 14fe723f6b9 std::thread: set_name implementation proposal for vxWorks. REVERT: 67fa603356d Remove unused lifetime parameter from spawn_unchecked REVERT: 4a3da122172 Add a special case for CStr/CString in the improper_ctypes lint REVERT: 51ec2bb7ea2 implement BufReader::peek REVERT: 9cc3bc6add3 custom MIR: add support for tail calls REVERT: e6aede2233f nontemporal_store: make sure that the intrinsic is truly just a hint REVERT: a300df74d13 WASI fixing unsafe_op_in_unsafe_fn for std::{os, sys} REVERT: 5674d1c07e5 Auto merge of #128673 - matthiaskrgr:rollup-gtvpkm7, r=matthiaskrgr REVERT: deb1d7576df Rollup merge of #128619 - glandium:last_chunk, r=scottmcm REVERT: 6449537a625 Rollup merge of #128609 - swenson:smaller-faster-dragon, r=Amanieu REVERT: acb2c303c36 Rollup merge of #128026 - devnexen:available_parallelism_vxworks, r=Mark-Simulacrum REVERT: 89fe6dfa6b9 Rollup merge of #128309 - kmicklas:btreeset-cursor, r=Amanieu REVERT: 313484bb62c Correct the const stabilization of `<[T]>::last_chunk` REVERT: 22e026b048c Auto merge of #128534 - bjorn3:split_stdlib_workspace, r=Mark-Simulacrum REVERT: 59436fcc0b1 std: refactor UNIX random data generation REVERT: 8fe1e328a17 refactor: standardize duplicate processes in parser REVERT: 18136032131 Rollup merge of #128526 - tshepang:patch-1, r=Amanieu REVERT: e8a1a4151ee Auto merge of #128466 - sayantn:stdarch-update, r=tgross35 REVERT: 2adf9da42a3 Update stdarch REVERT: dc85bdb60ce Chore: add `x86_amx_intrinsics` feature flag to `core/lib.rs` and remove `issue-120720-reduce-nan.rs` REVERT: e88b04d135d Rollup merge of #128551 - Konippi:refactor-backtrace-style-in-panic, r=tgross35 REVERT: 43a1e939ebe Rollup merge of #128530 - scottmcm:repeat-n-unchecked, r=joboet REVERT: 47df194eec6 Remove unnecessary constants from flt2dec dragon REVERT: 6fafc6b5d92 Apply review comments to PartialOrd section REVERT: 0b5f1b8406f Auto merge of #128404 - compiler-errors:revert-dead-code-changes, r=pnkfelix REVERT: 35cd95f1edb Suppress new false-negatives that were masked by dead code analysis changes REVERT: 9eb9fa6d7db Revert "Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix" REVERT: 975dc19795e Rollup merge of #128368 - nnethercote:rustfmt-tweaks, r=cuviper REVERT: 0ee09fe87cf Rollup merge of #128303 - NobodyXu:specialise-for-pipe, r=cuviper REVERT: 1967a123728 Rollup merge of #127586 - zachs18:more-must-use, r=cuviper REVERT: fc53324c54d Rollup merge of #126704 - sayantn:sha, r=Amanieu REVERT: 7850a64f5bb Forbid unsafe_op_in_unsafe_fn in vxworks specific os and sys files REVERT: 74dd96fbea9 chore: refactor backtrace style in panic REVERT: 0e4358de84e Auto merge of #128528 - workingjubilee:you-dont-need-to-see-this-cpuid-move-along, r=Amanieu REVERT: 9fa74abcf83 Move the standard library to a separate workspace REVERT: e13d132801a Auto merge of #128254 - Amanieu:orig-binary-search, r=tgross35 REVERT: 05d8d7c0765 Implement `UncheckedIterator` directly for `RepeatN` REVERT: a5fa13e131b Rollup merge of #128491 - c410-f3r:unlock-rfc-2011, r=workingjubilee REVERT: 28e4d22aec0 Rollup merge of #128453 - RalfJung:raw_eq, r=saethlin REVERT: db770c6262d std: Remove has_cpuid REVERT: 39aad04eaaf time.rs: remove "Basic usage text" REVERT: 7df583ccfb3 Dogfood REVERT: cb110515265 Add the `sha512`, `sm3` and `sm4` target features REVERT: 86ea79fb335 Fix mutability in doc tests for `BTreeSet` cursors REVERT: e844efffe8f Add a disclaimer about x86 `f128` math functions REVERT: 21d297b29ad Update comments for `{f16, f32, f64, f128}::midpoint` REVERT: ad27d08e73e Add `core` functions for `f16` and `f128` that require math routines REVERT: c6407b0bfa7 Add math functions for `f16` and `f128` REVERT: d9b1de5180d Add math intrinsics for `f16` and `f128` REVERT: c7be27f744a Introduce `Cursor`/`CursorMut`/`CursorMutKey` thrichotomy for `BTreeSet` like map API REVERT: 8835b0ffaef Fix some uses of "map" instead of "set" in `BTreeSet` cursor API docs REVERT: 07f64a8e22c Share `UnorderedKeyError` with `BTReeMap` for set API REVERT: f859e542648 Rollup merge of #128499 - Konippi:refactor-backtrace-formatting, r=tgross35 REVERT: fb966d2b046 Rollup merge of #128497 - Bryanskiy:fix-dropck-doc, r=lcnr REVERT: ab00ae63d7a Rollup merge of #128433 - hermit-os:hermit-unsafe_op_in_unsafe_fn, r=joboet REVERT: 3c1586b3ce8 Hide internal sort module REVERT: 2614bd2ae16 chore: refactor backtrace formatting REVERT: a8a46595ff6 fix dropck documentation for `[T;0]` special-case REVERT: b927541dc3f core: use `compare_bytes` for more slice element types REVERT: 589c0a0e872 fix(os/hermit): `deny(unsafe_op_in_unsafe_fn)` REVERT: 0260e47b16e fix(pal/hermit): `deny(unsafe_op_in_unsafe_fn)` REVERT: 7bd6b11e0ad refactor(pal/hermit): make `ENV` a non-mutable static REVERT: 32894e2b70e Rollup merge of #128416 - maurer:remove-android-hack, r=tgross35 REVERT: beb76c31275 Auto merge of #128461 - matthiaskrgr:rollup-3dpp11g, r=matthiaskrgr REVERT: 1e3976be11a Rollup merge of #128162 - ChrisDenton:cleanup, r=joboet REVERT: cde45b0a077 Rollup merge of #127567 - joboet:once_wait, r=Amanieu REVERT: 06076429681 Fix docs for OnceLock::get_mut_or_init REVERT: da484175cbd raw_eq: using it on bytes with provenance is not UB (outside const-eval) REVERT: cc6f37ff93f std: fix busy-waiting in `Once::wait_force`, add more tests REVERT: 6fd82f18f54 std: implement the `once_wait` feature REVERT: 0c56873d90f Remove unneeded `pub(crate)` REVERT: 787a1f7a2e6 Rollup merge of #128388 - beetrees:f16-f128-slightly-improve-windows-abi, r=tgross35 REVERT: e3a4ed3406a Rollup merge of #128387 - liigo:patch-14, r=tgross35 REVERT: 8b7f4ee6e3d refactor(pal/hermit): use default impl of `GlobalAlloc::alloc_zeroed` REVERT: c3370198cca refactor(pal/hermit): return `!` to satisfy rust-analyzer REVERT: 21887129721 Apply review comments REVERT: 2ebe00aa0ba PinCoerceUnsized trait into core REVERT: 7aafdcf2fa2 android: Remove libstd hacks for unsupported Android APIs REVERT: ba65c6c88c8 Move Windows implementation of anon pipe REVERT: 176508ce960 Match LLVM ABI in `extern "C"` functions for `f128` on Windows REVERT: 85e4ba09e56 Cleanup sys module to match house style REVERT: ddff2b608a9 Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68 REVERT: e4b0e6d427b Rewrite binary search implementation REVERT: 556dc6028e1 More detailed note to deprecate ONCE_INIT REVERT: 440ec835e8f Auto merge of #128378 - matthiaskrgr:rollup-i3qz9uo, r=matthiaskrgr REVERT: a50fe577e5d Auto merge of #128250 - Amanieu:select_unpredictable, r=nikic REVERT: 47f9d6175ee Rollup merge of #128315 - zetanumbers:psvita-unsafe-in-unsafe, r=workingjubilee REVERT: f70ce7f3e03 Auto merge of #128234 - jcsp:retain-empty-case, r=tgross35 REVERT: 93b2f7c4e88 Insert some blank lines. REVERT: db0222e3e80 Move a comment. REVERT: 569ab6a3a03 CloneToUninit: use a private specialization trait REVERT: 26874cc98cc Sparkle some attributes over `CloneToUninit` stuff REVERT: e8c37187b60 impl CloneToUninit for Path and OsStr REVERT: ef8c591ec02 impl CloneToUninit for str and CStr REVERT: cc96f3e2d19 Stabilize offset_of_nested REVERT: 618fdd536b5 Auto merge of #128334 - matthiaskrgr:rollup-nhxdt0c, r=matthiaskrgr REVERT: e088cb1bcd7 Rollup merge of #128333 - RalfJung:miri-sync, r=RalfJung REVERT: 1ea0493512b Rollup merge of #128307 - ojeda:unescaped_backticks, r=GuillaumeGomez REVERT: 5d510999d8a Optimize empty case in Vec::retain REVERT: f2bcbecd66e Auto merge of #125016 - nicholasbishop:bishop-cb-112, r=tgross35 REVERT: 7a43febb9b1 Rollup merge of #128310 - kmicklas:btree-map-peek-next-docs, r=tgross35 REVERT: 03e5078d0f6 Rollup merge of #128055 - workingjubilee:deny-unsafe-ops-in-sys-personality-dwarf-eh, r=Amanieu REVERT: f9befad9f51 Rollup merge of #109174 - soerenmeier:cursor_fns, r=dtolnay REVERT: ed7d02fcc9b Update compiler_builtins to 0.1.114 REVERT: 80254cd2f12 Warn on `rustdoc::unescaped_backticks` for `core/alloc/std/test/proc_macro` REVERT: c8db8ead903 Remove spurious backticks detected by `rustdoc::unescaped_backticks` REVERT: d1d4fb32943 Reformat `use` declarations. REVERT: 3ec244feaeb Replace `io::Cursor::{remaining_slice, is_empty}` with `io::Cursor::{split, split_mut}` REVERT: 8744732f3ed Partially stabilize `io_error_more` REVERT: abc611ff511 step cfg(bootstrap) REVERT: 78cd7797193 Update CURRENT_RUSTC_VERSION REVERT: 70927dcd034 Add forbid(unsafe_op_in_unsafe_fn) REVERT: 06a22c946e3 Rollup merge of #128240 - mbrubeck:patch-3, r=joboet REVERT: 604d6183e4d Rollup merge of #128228 - slanterns:const_waker, r=dtolnay,oli-obk REVERT: 2a70839bf8f Rollup merge of #128103 - folkertdev:unsigned-int-is-multiple-of, r=Amanieu REVERT: 058f1d3e3a7 Rollup merge of #127765 - bitfield:fix_stdlib_doc_nits, r=dtolnay REVERT: 9a6c84e26c1 fix: psvita's std code REVERT: 5119266b79c Force LLVM to use CMOV for binary search REVERT: d6b6e639162 stabilize const_waker REVERT: 8e4f58a6520 Add missing periods on `BTreeMap` cursor `peek_next` docs REVERT: 458b9b07517 Implement cursors for `BTreeSet` REVERT: 65c6173bfe1 Update NonNull::align_offset quarantees REVERT: 02bf0de46e4 Enable `std::io::copy` specialisation for `std::pipe::{PipeReader, PipeWriter}` REVERT: 1f83bf3100e Rollup merge of #128282 - pitaj:nonzero_bitwise, r=workingjubilee REVERT: 357ff7a0265 Rollup merge of #128279 - slanterns:is_sorted, r=dtolnay REVERT: fcbdcae5542 stabilize `is_sorted` REVERT: c47f8bdd4f5 bitwise and bytewise methods on `NonZero` REVERT: 4ea98d76cfd Rollup merge of #128259 - sunshowers:msg-nosignal, r=Mark-Simulacrum REVERT: d6f970a682d Rollup merge of #125897 - RalfJung:from-ref, r=Amanieu REVERT: b014b0d7b74 Improve panic sections for sort*, sort_unstable* and select_nth_unstable* REVERT: 9bcfe84e72b Improve panic message and surrounding documentation for Ord violations REVERT: 339f7567cf0 Auto merge of #128255 - stepancheg:doc-shl, r=scottmcm REVERT: 7e55abb1837 Okay, I guess I have to give these a different feature name REVERT: bdc18e2ea2b impl Default for collection iterators that don't already have it REVERT: 0d6a7dd333b Merge from rustc REVERT: a66bc798ecd Auto merge of #127946 - tgross35:fmt-builders-set-result, r=cuviper REVERT: 2986bfed613 [illumos/solaris] set MSG_NOSIGNAL while writing to sockets REVERT: 3e854937500 Document int.checked_shl(BITS - 1) REVERT: 59f3fefb4cb Rollup merge of #128235 - harryscholes:fix-iterator-filter-docs, r=tgross35 REVERT: a2dbfd338e9 Rollup merge of #124941 - Skgland:stabilize-const-int-from-str, r=dtolnay REVERT: 5b78bae1394 Add links from `assert_eq!` docs to `debug_assert_eq!`, etc. REVERT: a0f135d76af Always set `result` during `finish()` in debug builders REVERT: bd11b3dcc6d Fix docs REVERT: 22ce603b463 Auto merge of #128165 - saethlin:optimize-clone-shims, r=compiler-errors REVERT: fb7d2a81c80 Fix doc nits REVERT: a1528206ab5 Rollup merge of #128170 - saethlin:clone-fn, r=compiler-errors REVERT: 0d636140614 Merge from rustc REVERT: cb8f69be7aa Rollup merge of #128211 - juliusl:pr/align-change-time, r=tgross35 REVERT: ba0582bf6c4 Rollup merge of #128150 - BoxyUwU:std_only_sized_const_params, r=workingjubilee REVERT: 30cfde4b97a Rollup merge of #127950 - nnethercote:rustfmt-skip-on-use-decls, r=cuviper REVERT: 8488ae6d29f Make Clone::clone a lang item REVERT: 1342ef157c3 fix: compilation issue w/ refactored type REVERT: 92c0ad77d5d Let InstCombine remove Clone shims inside Clone shims REVERT: c788415b025 Stop using `unsized_const_parameters` in core/std REVERT: ef4d4a039fe Auto merge of #128195 - matthiaskrgr:rollup-195dfdf, r=matthiaskrgr REVERT: 5b6c1e1ad32 Rollup merge of #128137 - GrigorenkoPV:cstr-derive, r=dtolnay REVERT: aaeac06292c Rollup merge of #127999 - ChrisDenton:arm32, r=Amanieu REVERT: f26f981c731 clarify interactions with MaybeUninit and UnsafeCell REVERT: 394c8640df0 remove duplicate explanations of the ptr to ref conversion rules REVERT: 571348bc357 create a new section on pointer to reference conversion REVERT: ea3a99f0fc7 Rollup merge of #128158 - workingjubilee:unsafe-wrap-personality-gcc, r=ChrisDenton REVERT: 886fe5b7f53 Rollup merge of #127300 - biabbas:fix_connect_timeout, r=tgross35 REVERT: b889a1defa7 CStr: derive PartialEq, Eq; add test for Ord REVERT: 3a181105a62 In connect timeout, read readiness of socket for vxworks. Check pollhup or pollerr for refused connections in linux REVERT: c4ee91f1305 Merge from rustc REVERT: 797c2498600 Implement `mixed_integer_ops_unsigned_sub` REVERT: 244d8430769 std: update comments on gcc personality fn REVERT: d252b6b475b std: unsafe-wrap gcc::rust_eh_personality and impl REVERT: 09bda4f2acb Rollup merge of #128135 - joboet:reduplicate_tls, r=tgross35 REVERT: a4c88bc2fbb Rollup merge of #128046 - GrigorenkoPV:90435, r=tgross35 REVERT: 2614d86fcb4 Rollup merge of #126548 - rik86189:issue-88264-fix, r=tgross35 REVERT: 75a178fdfa7 Rollup merge of #126042 - davidzeng0:master, r=Amanieu REVERT: 1e118aec933 Rollup merge of #128131 - ChrisDenton:stuff, r=workingjubilee REVERT: cea2ca9af78 Rollup merge of #128120 - compiler-errors:async-fn-name, r=oli-obk REVERT: 92e3688370a Rollup merge of #127733 - GrigorenkoPV:don't-forget, r=Amanieu REVERT: 9b1cffdc1be Rollup merge of #127480 - biabbas:vxworks, r=workingjubilee REVERT: 2632261f008 Rollup merge of #127252 - fitzgen:edge-cases-for-bitwise-operations, r=m-ou-se REVERT: b0d74144ae4 Rollup merge of #126152 - RalfJung:size_of_val_raw, r=saethlin REVERT: 6d0b7146359 Improved clarity of documentation for std::fs::create_dir_all REVERT: eb79e096922 std: use duplicate thread local state in tests REVERT: 8456a976820 Forbid unsafe_op_in_unsafe_fn in sys/pal/windows REVERT: 5a9fb1fc194 Import `core::ffi::c_void` in more places REVERT: 16450f7b3e9 Merge from rustc REVERT: 697c717b542 Add chroot unsupported implementation for VxWorks REVERT: 6242470207d Rollup merge of #128106 - hallfox:patch-1, r=ChrisDenton REVERT: de086ea59d4 Rollup merge of #128092 - ChrisDenton:wrappers, r=workingjubilee REVERT: ccba33ca2dc Rollup merge of #128043 - safinaskar:primitive, r=workingjubilee REVERT: a069998a10d Rollup merge of #127481 - a1phyr:pattern_gat, r=Amanieu REVERT: bc7345c7866 Rollup merge of #126770 - wr7:master, r=Amanieu REVERT: 21f6b6516e2 Rollup merge of #125962 - Coekjan:const-binary-heap, r=Amanieu REVERT: eee5bbaed57 Auto merge of #127153 - NobodyXu:pipe, r=ChrisDenton REVERT: fd3a45fc3f9 Gate AsyncFn* under async_closure feature REVERT: 0374ea22cab Add elem_offset and related methods REVERT: 2b3eacb22c6 library/core/src/primitive.rs: small doc fix REVERT: 45f80e6b25b Fix return type of FileAttr methods on AIX target REVERT: 6cabb65c3fa add `is_multiple_of` for unsigned integer types REVERT: 4c4a93a480e Initial implementation of anonymous_pipe REVERT: 63d29970101 Update process vxworks, set default stack size of 256 Kib for vxworks. User can set the stack size using RUST_MIN_STACK, with min size of libc::PTHREAD_STACK_MIN(4kib) REVERT: ee8604174b0 Rollup merge of #128089 - workingjubilee:commonly-wrapped-to-make-safe, r=ChrisDenton REVERT: ad9a52dcb35 Rollup merge of #125834 - workingjubilee:weaken-thir-unsafeck-for-addr-of-static-mut, r=compiler-errors REVERT: 642c69bbe40 Remove wrapper functions from c.rs REVERT: de2a0378391 std: Unsafe-wrap backtrace code held in-common REVERT: 155aef9d64b std: Unsafe-wrap alloc code held in-common REVERT: bee0155d119 Cfg disable on_broken_pipe_flag_used() for vxworks REVERT: 227b5afa55e Disable dirfd for vxworks, Return unsupported error from set_times and lchown for vxworks REVERT: 22a6797af81 Allow unused unsafe for vxworks in read_at and write at REVERT: 8be45a9e6a7 Docs for core::primitive: mention that "core" can be shadowed, too, so we should write "::core" REVERT: c039ee8ff7e library: vary unsafety in bootstrapping for SEH REVERT: 6765b971f38 std: unsafe-wrap personality::dwarf::eh REVERT: 971aa37f27b LocalWaker docs: Make long-ago omitted but probably intended changes REVERT: c4fdac9fe60 Docs for Waker and LocalWaker: Add cross-refs in comment REVERT: 7ae76f0ee2d Rollup merge of #128008 - weiznich:fix/121521, r=lcnr REVERT: 323e962d2cd Rollup merge of #127996 - ian-h-chamberlain:fix/horizon-warnings-unsafe-in-unsafe, r=tgross35 REVERT: ae6187f170c Rollup merge of #127415 - AljoschaMeyer:master, r=dtolnay REVERT: d6a36f520f5 Use given allocator instad of Global REVERT: d0bc9a0ec5d Start using `#[diagnostic::do_not_recommend]` in the standard library REVERT: ba43261b233 Rollup merge of #127583 - Nilstrieb:invalid-utf8, r=joboet REVERT: 0727e53d393 Fix warnings when checking armv6k-nintendo-3ds REVERT: bbe4da839fa Fix some `#[cfg_attr(not(doc), repr(..))]` REVERT: 9c299bc6b10 Implement `debug_more_non_exhaustive` REVERT: b405024dc09 Make use of raw strings in `core::fmt::builders` REVERT: 321dbf82a78 Deal with invalid UTF-8 from `gai_strerror` REVERT: 6aa00e1eece std::thread: available_parallelism implementation for vxWorks proposal. REVERT: 2fff48df757 Auto merge of #127722 - BoxyUwU:new_adt_const_params_limitations, r=compiler-errors REVERT: d7770e9cca2 Rollup merge of #128005 - ChrisDenton:msvc-include, r=joboet REVERT: 8fdee233d27 Rollup merge of #127734 - ChrisDenton:netc, r=Mark-Simulacrum REVERT: 3b2536ec206 Remove _tls_used hack REVERT: 07dbb381321 Rollup merge of #127873 - workingjubilee:forbid-unsafe-ops-for-kmc-solid, r=Amanieu REVERT: bd262955725 Rollup merge of #127843 - workingjubilee:break-up-big-ass-stack-overflow-fn, r=joboet REVERT: 00b4f61ec49 Inject win arm32 shims into metadata generation REVERT: 2b628674392 Rollup merge of #127918 - ChrisDenton:thread-name-string, r=joboet REVERT: a077eb1965c Rollup merge of #123196 - Ayush1325:uefi-process, r=joboet REVERT: eb09be43d35 std: forbid unwrapped unsafe in unsupported_backslash REVERT: dcb98546d31 kmc-solid: forbid(unsafe_op_in_unsafe_fn) REVERT: 845a2f78382 Auto merge of #127982 - matthiaskrgr:rollup-nzyvphj, r=matthiaskrgr REVERT: 00d6fc4cfef Rollup merge of #127978 - nyurik:lib-refs, r=workingjubilee REVERT: 4d8afcdd44b Avoid ref when using format! for perf REVERT: 9f20a0f28ba Rollup merge of #126199 - ivan-shrimp:nonzero_isqrt, r=tgross35 REVERT: f06530cc0c3 Rollup merge of #112328 - juliusl:pr/windows-add-change-time, r=ChrisDenton REVERT: 8d5cf50b19d uefi: process: Fixes from PR REVERT: c6cb67c41a3 uefi: process: Final Touchups REVERT: afe1ef08b0e uefi: process: Add CommandArgs support REVERT: ef6b1730a13 uefi: process: Add support for args REVERT: 1991fe38c57 uefi: process Implement inherit REVERT: 24a95828625 uefi: process: Add null protocol REVERT: 36a0e1e01c8 uefi: process: Add stderr support REVERT: b712e740ca4 uefi: process: Add support to capture stdout REVERT: e6eeb4ee295 uefi: Add process REVERT: f3b1c8a63e4 improve safety comment REVERT: 93489988c77 add `NonZero::isqrt` REVERT: edc4cdc351b Use `#[rustfmt::skip]` on some `use` groups to prevent reordering. REVERT: 489f1ef8747 unix: acquire-load NEED_ALTSTACK REVERT: 9e11e01d38f unix: Unsafe-wrap stack_overflow::{drop,make}_handler REVERT: 72c7444faf0 unix: Unsafe-wrap stack_overflow::cleanup REVERT: 33a32f20bfd unix: lift init of sigaltstack before sigaction REVERT: 9fb6e4958f7 unix: Unsafe-wrap stack_overflow::signal_handler REVERT: c99ebd411b7 Rollup merge of #127594 - c6c7:fuchsia-status-code-match-arm, r=tmandry REVERT: 83782615519 Move ThreadName conversions to &cstr/&str REVERT: 68e23910a05 Style change REVERT: 16bce8a458a Make `Thread::new_inner` a safe function REVERT: d1d98933f8f Rollup merge of #127748 - scottmcm:option_len, r=joboet REVERT: b0c85badd9f Rollup merge of #124881 - Sp00ph:reentrant_lock_tid, r=joboet REVERT: 7e218501a06 Update `ReentrantLock` implementation, add `CURRENT_ID` thread local. REVERT: c10a929ac5e Safely enforce thread name requirements REVERT: cc4ed954619 Rollup merge of #127077 - tbu-:pr_doc_fd_to_owned, r=workingjubilee REVERT: 37d7bff7bb1 Rollup merge of #127861 - Kriskras99:patch-1, r=tgross35 REVERT: 3d50720567e Rollup merge of #127859 - RalfJung:ptr-dyn-metadata, r=scottmcm REVERT: 1f3311b800b Rollup merge of #127845 - workingjubilee:actually-break-up-big-ass-stack-overflow-fn, r=joboet REVERT: 557859328cb Auto merge of #127865 - matthiaskrgr:rollup-8m49dlg, r=matthiaskrgr REVERT: 54728b12a9f feat: adding ext that returns change_time for Windows REVERT: b164bab985b Auto merge of #125942 - timokroeger:windows-once-futex, r=ChrisDenton REVERT: 0eda3a36123 Rollup merge of #127337 - celinval:intrinsics-fallback, r=oli-obk REVERT: ed3c6d115e4 Mention how you can go from `BorrowedFd` to `OwnedFd` and back REVERT: 455bd5705fb Make language around `ToOwned` for `BorrowedFd` more precise REVERT: ab7a0d4d6a5 Document the column numbers for the dbg! macro REVERT: 89cd225caaa ptr::metadata: update comment on vtable_ptr work-around REVERT: 51e54a4f5de ptr::metadata: avoid references to extern types REVERT: be0c06bc63e Split part of `adt_const_params` into `unsized_const_params` REVERT: 857ed93c04e Forbid `!Sized` types and references REVERT: a2cf63619d7 Rollup merge of #127813 - ChrisDenton:win-futex, r=joboet REVERT: aeae3328f01 Rollup merge of #127763 - ChrisDenton:safe-unsafe-unsafe, r=tgross35 REVERT: aedc16cadfe unix: unsafe-wrap install_main_guard_default REVERT: 4db3aa1e628 unix: clean up install_main_guard_freebsd REVERT: d167f00072d unix: stack_start_aligned is a safe fn REVERT: 27b79e6e1f7 unix: split stack_overflow::install_main_guard by os REVERT: e0ea7017a67 Prevent double reference in generic futex REVERT: 417b61f271f Narrow the scope of the ReadFile unsafe block REVERT: b4d1392064c forbid(unsafe_op_in_unsafe_fn) in sys/os_str REVERT: f431b519c02 Rollup merge of #127836 - workingjubilee:forbid-unsafe-ops-in-xous-uefi, r=tgross35 REVERT: 0a024bda728 Rollup merge of #127833 - risc0:erik/zkvm-deny-unsafe, r=workingjubilee REVERT: 0299bb5f196 Rollup merge of #127807 - ChrisDenton:win-parking, r=joboet REVERT: 61af010c325 Rollup merge of #127792 - workingjubilee:read-unaligned-is-dwarfier, r=joboet REVERT: d3cf2e16181 Rollup merge of #127444 - Sky9x:cstr-bytes-iter, r=dtolnay REVERT: 12075d15f76 Rollup merge of #126776 - nnethercote:rustfmt-use-pre-cleanups-2, r=cuviper REVERT: 00d603fc9c1 Rollup merge of #126271 - diondokter:dec2flt-skip-fast-path, r=tgross35 REVERT: 8490c84ffb2 Rollup merge of #125206 - mgeisler:simplify-std-env-vars, r=jhpratt,tgross35 REVERT: a752e3b2772 uefi: Forbid unwrapped unsafe in platform modules REVERT: 32a1b078ba4 Cfg nit REVERT: e189d3b30e1 xous: Forbid unwrapped unsafe in platform modules REVERT: 7ddd7f86509 zkvm: add `#[forbid(unsafe_op_in_unsafe_fn)]` in `stdlib` REVERT: 0723962ffe1 Adjust some comments on individual `use` declarations. REVERT: 4320ba0a9b5 Avoid comments that describe multiple `use` items. REVERT: 1aeddb00b1e Merge some `core::iter` entries. REVERT: 7a0b2fb5e16 Add unsafe blocks in unsafe Thread::new REVERT: 8e76b152b93 Remove `slice_to_end` REVERT: e8527cdadb6 std: unwrapped unsafe is VERBOTEN! REVERT: 5e4edbadcb7 Rollup merge of #127789 - Sword-Destiny:master, r=petrochenkov REVERT: 1b631e5f140 Use futex.rs for Windows thread parking REVERT: d59f862b675 std: Use read_unaligned for reading DWARF REVERT: 686f75bb7a6 Rollup merge of #127047 - tspiteri:f128-aconsts-lsd, r=tgross35 REVERT: 8b1d874a6ec deny unsafe_op_in_unsafe_fn for teeos REVERT: f8bb325e1cf clean unsafe op in unsafe fn REVERT: b5970178b63 clean unsafe op in unsafe fn REVERT: 9fd9c61c0ef clean unsafe op in unsafe fn REVERT: e0c57e42237 delete #![allow(unsafe_op_in_unsafe_fn)] REVERT: 704f56f5d84 `impl Send + Sync` and override `count` for the `CStr::bytes` iterator REVERT: d50143fddb9 Update name of Windows abort constant to match platform documentation REVERT: cbaa8317349 Add match arm for Fuchsia status code upon an abort in a test REVERT: a778c83ad92 Auto merge of #127777 - matthiaskrgr:rollup-qp2vkan, r=matthiaskrgr REVERT: 65355912072 Rollup merge of #124921 - RalfJung:offset-from-same-addr, r=oli-obk REVERT: f15715f3e48 lib: replace some `mem::forget`'s with `ManuallyDrop` REVERT: ac443f29c05 Auto merge of #127020 - tgross35:f16-f128-classify, r=workingjubilee REVERT: 57937d7f2bd allow(unsafe_op_in_unsafe_fn) on some functions REVERT: 94b381d6fc6 Some Windows functions are safe REVERT: f3bb34b1088 Deny more windows unsafe_op_in_unsafe_fn REVERT: 9bbf09d3d07 Windows: move BSD socket shims to netc REVERT: d76c965affa Remove generic lifetime parameter of trait `Pattern` REVERT: eae94518584 Rollup merge of #127750 - ChrisDenton:safe-unsafe-unsafe, r=workingjubilee REVERT: 6257980b38d Rollup merge of #127744 - workingjubilee:deny-unsafe-op-in-std, r=jhpratt REVERT: 05614f3ce16 Rollup merge of #127712 - ChrisDenton:raw-types, r=workingjubilee REVERT: 14c24b1ba4c Mark some `f16` and `f128` functions unstably const REVERT: ad3db57a529 Use Option's discriminant as its size hint REVERT: 1b70afd5267 Move safety comment outside unsafe block REVERT: 3c286d52b7d Make os/windows default to deny unsafe in unsafe REVERT: d96ed862d21 Make pal/windows default to deny unsafe in unsafe REVERT: bb3f60f0e69 Fix Windows 7 REVERT: 9fc6710fe07 Auto merge of #127719 - devnexen:math_log_fix_solill, r=Amanieu REVERT: decdb067d63 Don't re-export `c_int` from `c` REVERT: a1a1c6a2d51 Remove DWORD REVERT: 7d189919173 Remove ULONG REVERT: d89bce6a28b Remove PSRWLOCK REVERT: d3205de3d53 Remove LPVOID REVERT: 68ac381171e Remove LPSECURITY_ATTRIBUTES REVERT: 6d037b83d39 Remove LPOVERLAPPED REVERT: 61f617d370a Remove LPCVOID REVERT: 8a2537133ee Remove SIZE_T REVERT: cd51de1f064 Remove CHAR REVERT: 00a5b3b8733 Remove USHORT REVERT: d621d21f702 Remove LPWSTR REVERT: 0b22ecb55af Remove UINT REVERT: 18adceff5ae Remove LONG REVERT: 4eaaf7dcb61 Remove LARGE_INTEGER REVERT: aa45985349c Remove NonZeroDWORD REVERT: d7aa7cf7242 Auto merge of #127732 - GrigorenkoPV:teeos-safe-sys-init, r=Amanieu REVERT: 5ff7b404d5e std: Unsafe-wrap std::sync REVERT: e8fa3ef2c24 std: Unsafe-wrap in Wtf8 impl REVERT: 8c3a9c1c939 std: Unsafe-wrap std::io REVERT: 91b7331a825 std: Directly call unsafe {un,}setenv in env REVERT: 8c75111da55 std: Unsafe-wrap OSStr{,ing}::from_encoded_bytes_unchecked REVERT: 4679f9a6cff std: Unsafe-wrap HashMap::get_many_unchecked_mut REVERT: ac0fd279184 std: deny(unsafe_op_in_unsafe_fn) but allow sites REVERT: f710e38693e Add `classify` and related methods for `f16` and `f128` REVERT: 009660d51cc std: removes logarithms family function edge cases handling for solaris. REVERT: 3492a6b5146 Auto merge of #127728 - matthiaskrgr:rollup-ercdbjd, r=matthiaskrgr REVERT: 08732993c73 sys::init is not unsafe on teeos REVERT: 6c4029ad51b Rollup merge of #127592 - tesuji:patch-1, r=Mark-Simulacrum REVERT: 7cd8086b6c1 Auto merge of #125935 - madsmtm:merge-os-apple, r=workingjubilee REVERT: cfb0556a7f1 Merge Apple `std::os` extensions modules into `std::os::darwin` REVERT: 54435f79fa5 Rollup merge of #127704 - workingjubilee:fixup-better-than, r=ChrisDenton REVERT: e1229496e7f Auto merge of #127706 - workingjubilee:rollup-d07ij30, r=workingjubilee REVERT: 30331206bd2 Rollup merge of #127659 - saethlin:manually-drop-bufwriter, r=joboet REVERT: e9eb7de0b4a Rollup merge of #127446 - zachs18:miri-stdlib-leaks-core-alloc, r=Mark-Simulacrum REVERT: 3ad25605a1f Rollup merge of #127370 - ChrisDenton:win-sys, r=Mark-Simulacrum REVERT: 05bf6bcfaeb doc: Suggest `str::repeat` over `iter::repeat().take().collect()` REVERT: 96e8ba7a40c Fix minor typos in std::process doc on Win argv REVERT: 6b67c664112 Auto merge of #126958 - dtolnay:u32char, r=Mark-Simulacrum REVERT: 591aaaf1e3e std::unix::fs: removing, now useless, layers predating macOs 10.10. REVERT: 94ec6e79526 Auto merge of #127674 - jhpratt:rollup-0dxy3k7, r=jhpratt REVERT: a7c1f608ce4 Rollup merge of #127668 - spencer3035:improve-slice-doc, r=jhpratt REVERT: 1e49e055a69 Rollup merge of #127661 - eduardosm:stabilize-io_slice_advance, r=cuviper REVERT: c79e0030810 Auto merge of #127397 - jyn514:multi-thread-panic-hook, r=workingjubilee REVERT: 206678cfcd3 Auto merge of #126606 - zachs18:patch-2, r=joboet REVERT: 1bb035080b7 Updated slice documentation REVERT: c8b79ddd46c Use ManuallyDrop in BufWriter::into_parts REVERT: 20e64bd6cd3 Use is_val_statically_known to optimize pow REVERT: 6e26e27ee92 Stabilize io_slice_advance REVERT: cac66641bfb Rename the internal `const_strlen` to just `strlen` REVERT: 39647aba92c fix interleaved panic output REVERT: 0476fc4842e Rollup merge of #127433 - dtolnay:conststrlen, r=workingjubilee REVERT: f66bd5fdfbd Rollup merge of #126827 - the8472:pidfd-spawn, r=workingjubilee REVERT: 1e5cd219cb6 Rollup merge of #124980 - zachs18:rc-allocator, r=Amanieu REVERT: 949f0d63178 Add instability attribute on private const_strlen function REVERT: 20bfac6c159 Rollup merge of #127422 - greaka:master, r=workingjubilee REVERT: 79855bb9ba4 [library/std/src/process.rs] `PartialEq` & `Eq` for `ExitCode` REVERT: 05ee32298cb Explicitly unroll integer pow for small exponents REVERT: 4cfe24a3555 Optimize integer pow by removing exit branch REVERT: f937ef12bda Rollup merge of #127599 - tgross35:lazy_cell_consume-rename, r=workingjubilee REVERT: fde7fd261f2 Rollup merge of #127588 - uweigand:s390x-f16-doctests, r=tgross35 REVERT: ed47f986f1b Rollup merge of #127572 - tbu-:pr_debug_event_nonpacked, r=jhpratt REVERT: e5c8b859b88 Rollup merge of #124599 - estebank:issue-41708, r=wesleywiser REVERT: b71b538ec26 Rename `lazy_cell_consume` to `lazy_cell_into_inner` REVERT: 3b86ae3449f Explicitly ignore `into_raw_handle()` using `let _ =` in sys/pal/windows. REVERT: 9efc1cb294a core: Limit remaining f16 doctests to x86_64 linux REVERT: 1cb5354fc6c Add `must_use` to IntoRawFd/IntoRawSocket/IntoRawHandle's methods. REVERT: 697377abf32 Clarify/add `must_use` messages for more `into_raw*` functions of `alloc` types. REVERT: a7bec568626 size_of_val_raw: for length 0 this is safe to call REVERT: a18fbd0ad0e Rollup merge of #127554 - ferrocene:tshepang-add-missing-attribute, r=pietroalbini REVERT: e419147a511 Don't mark `DEBUG_EVENT` struct as `repr(packed)` REVERT: 4552576f397 Auto merge of #126690 - andyolivares:feature/show_window, r=dtolnay REVERT: 6f6e343956a Rollup merge of #127091 - Sky9x:fused-error-sources-iter, r=dtolnay REVERT: 0d64105175e Fixed doc links REVERT: 4fb7b225972 Few changes to doc comments. Added tracking issue number. REVERT: fe62f6f8ad6 Exposing STARTUPINFOW.wShowWindow in CommandExt (show_window function) to control how a new process should display its window (normal, minimized, maximized, etc) REVERT: 7d20047874d do not run test where it cannot run REVERT: c5f1c76ddea Auto merge of #127235 - martn3:no-mips-f16, r=tgross35,scottmcm REVERT: 3fefa04a3c1 Rollup merge of #127460 - Borgerr:clarify-drop-comment, r=jhpratt REVERT: 895175ada33 Rollup merge of #127355 - aceArt-GmbH:126475, r=oli-obk REVERT: 57cea32952c Rollup merge of #120248 - WaffleLapkin:bonk-ptr-object-casts, r=compiler-errors,oli-obk,lnicola REVERT: e74955e1f84 Attempt to fix CI REVERT: 39c4daabd50 Reset sigpipe not supported for vxworks REVERT: e466bf57650 Rollup merge of #127367 - ChrisDenton:run-sync, r=Nilstrieb REVERT: 90504f870c5 Rollup merge of #126921 - workingjubilee:outline-va-list, r=Nilstrieb REVERT: c6b3f3db220 Auto merge of #127454 - matthiaskrgr:rollup-k3vfen2, r=matthiaskrgr REVERT: 29d792329d4 Move/change declaration of `mod exit_guard;` REVERT: ecc90251720 clarify `sys::unix::fd::FileDesc::drop` comment (#66876) REVERT: 35c5a456fea Rollup merge of #127447 - RalfJung:once_lock_miri, r=joboet REVERT: 9f7100d382c Rollup merge of #127354 - nicholasbishop:bishop-sized-doc, r=Nilstrieb REVERT: ee06e7daee6 Rollup merge of #127297 - the8472:path-new-hash, r=Nilstrieb REVERT: 2206c6b52b9 Rollup merge of #127189 - GrigorenkoPV:linkedlist-cursor-list, r=Nilstrieb REVERT: 41bcc362ad5 Rollup merge of #127179 - tgross35:typeid-debug-hex, r=Nilstrieb REVERT: 7177ac878cc once_lock: make test not take as long in Miri REVERT: 294d87f0c25 Remove non-focused memory leak in `std` doctest for Miri. REVERT: a86fd0f0d19 Specialize `TrustedLen` for `Iterator::unzip()` REVERT: 5515bbad984 Mitigate focused memory leaks in `core` doctests for Miri. REVERT: 3a0fe26db17 Remove non-focused memory leaks in `core` doctests for Miri. REVERT: 20d6cb372e6 Mitigate focused memory leaks in `alloc` doctests for Miri. REVERT: cac890232ed Remove non-focused memory leaks in `alloc` doctests for Miri. REVERT: bcdc8e8471d Stabilize const_cstr_from_ptr (CStr::from_ptr, CStr::count_bytes) REVERT: ca537d2cb33 Fix them doc examples some more REVERT: be23cef3a42 Fix doc examples REVERT: a48f566b9a4 offset_from intrinsic: always allow pointers to point to the same address REVERT: 8d0199656c4 Run formatter on alloc/src/boxed.rs REVERT: 9919a83b414 Mark format! with must_use hint REVERT: 0907955d257 as_simd: fix comment to be in line with 507583a (#121201) REVERT: 5569eceddd0 Rollup merge of #127275 - RalfJung:offset-from-isize-min, r=Amanieu REVERT: c3b602af8ce Add missing try_new_uninit_slice_in and try_new_zeroed_slice_in REVERT: 2337ab518af Rollup merge of #125751 - pitaj:new_range_api, r=jhpratt REVERT: ad4fde64af5 Rollup merge of #127363 - GuillaumeGomez:improve-fmt-code-readability, r=Amanieu REVERT: 3eeca5f7708 Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix REVERT: 1b5e5ac49eb Rollup merge of #123600 - tisonkun:path_with_extension, r=dtolnay REVERT: 5e9d4458222 Attempt to fix CI REVERT: d8965d365be add `new_range_api` for RFC 3550 REVERT: ca0f659f69d Move exit guard from sys::common::exit_guard to sys::exit_guard. REVERT: cf300a7e34b Update library/std/src/sys/pal/common/exit_guard.rs REVERT: ba4c71a7433 add unit tests for extra extension feature REVERT: 55fc20b7cbd update comments REVERT: 6b7a259b4f0 Add experimental raw-dylib feature to std REVERT: c452e620459 Use windows_targets macro for alloc REVERT: 521c81ab1c4 Run alloc sync tests REVERT: 2fcdebb68d7 Improve readability of some fmt code examples REVERT: 625bcc4987d Rollup merge of #127320 - ChrisDenton:win-sys, r=Mark-Simulacrum REVERT: f8caf5f24be Rollup merge of #127214 - bjorn3:miri_native_unwind, r=oli-obk REVERT: 1862054af88 Describe Sized requirements for mem::offset_of REVERT: e26c8818397 impl FusedIterator and a size hint for the error sources iter REVERT: 8f1c6640319 core: erase redundant stability attrs in va_list REVERT: 60c33a58766 library: outline VaList into ffi::va_list REVERT: 03d11c20585 Auto merge of #126171 - RalfJung:simd_bitmask_multibyte, r=workingjubilee REVERT: 54875740eef Document safety of a few intrinsics REVERT: 87fcd2f5c73 Move a few intrinsics to use Rust abi REVERT: 6b549baafd8 mark `can_not_overflow` as `#[rustc_const_stable(...)]` REVERT: 259c058b9f7 stabilize `const_int_from_str` REVERT: 297850a677e Add more checks for pointers with vtable meta REVERT: f58a3d6903e Improve dead code analysis REVERT: 515bd305955 Add comments to windows_targets.rs REVERT: 89d2de0f95f Update windows-bindgen to 0.58.0 REVERT: 0860a040c83 also remove redundant requirements from offset() REVERT: 6f80604442b offset_from: "the difference must fit in an isize" is a corollary REVERT: de4f5c2ca62 Rollup merge of #127303 - cuishuang:master, r=jhpratt REVERT: 56c73c378a5 Rollup merge of #127195 - biabbas:vxworks_cleanup, r=jhpratt REVERT: 5dfdef71fae Rollup merge of #126792 - wooden-worm:master, r=Mark-Simulacrum REVERT: 4df2059a6f7 chore: remove repeat words REVERT: acbefbbdec7 impl PathBuf::add_extension and Path::with_added_extension REVERT: 13d5a423f3d Auto merge of #127226 - mat-1:optimize-siphash-round, r=nnethercote REVERT: ed3d4878d34 stir the hash state a little to avoid prefix collisions REVERT: 5ca124f6d8a Add more test cases for path comparisons REVERT: 33bc557dd48 Add test case demonstrating equality of paths "foo/bar" and "foobar" REVERT: 079f99970d6 Move unique_thread_exit call to lang_start_internal so it is not in a generic function, and wrap it in `catch_unwind` REVERT: 47d0cbc7e2f Remove Miri special-case REVERT: 596be7ee7d7 Use pthread_t instead of numeric thread id REVERT: 2e90f6f5e7c Use libc::pause instead of std::thread::park in wait-for-exit loop REVERT: 1fd23e8568a core: Limit four f16 doctests to x86_64 linux REVERT: e6f15c579fa std: Set has_reliable_f16 to false for MIPS targets in build.rs REVERT: 67535b62417 library/std/build.rs: "powerpc64le" is not a target_arch REVERT: 5b0d82f32d8 Rollup merge of #127204 - dimpolo:stabilize_atomic_bool_fetch_not, r=jhpratt REVERT: b184a84f13c Rollup merge of #123588 - tgross35:stabilize-assert_unchecked, r=dtolnay REVERT: 2a81053036c Fall back on remove dir implementation for vxworks REVERT: 538fe8146ef Add edge-case examples to `{count,leading,trailing}_{ones,zeros}` methods REVERT: a8b6d0a2e51 Rollup merge of #127230 - hattizai:patch01, r=saethlin REVERT: 4d7cbb257ee chore: remove duplicate words REVERT: 645e9f24d68 Optimize SipHash by reordering compress instructions REVERT: c5ab1f01d8c Rollup merge of #127128 - elomatreb:elomatreb/stabilize-duration_abs_diff, r=joboet REVERT: f09067288ce Rollup merge of #126732 - StackOverflowExcept1on:master, r=m-ou-se REVERT: 1dc4f05eed8 Use the native unwind function in miri where possible REVERT: 4fff3351c87 Avoid MIR bloat in inlining REVERT: 4385efde634 Stabilize atomic_bool_fetch_not REVERT: 6c3359cdb0b Rollup merge of #127182 - danielhuang:patch-4, r=Nilstrieb REVERT: a0a438a75f2 Remove unqualified import io:: Error for vxworks as all Error references are qualified in process_vxworks.rs REVERT: 2a65e9fd644 Auto merge of #127026 - Urgau:cleanup-bootstrap-check-cfg, r=Kobzol REVERT: bba22002ec8 LinkedList's Cursor: method to get a ref to the cursor's list REVERT: 40a9be9a29e Update ip_addr.rs REVERT: 986dbd1b458 Print `TypeId` as hex for debugging REVERT: f27723e63ee Rollup merge of #127069 - Sky9x:fmt-pointer-use-addr, r=Nilstrieb REVERT: b068fce0ad9 Rollup merge of #126895 - betelgeuse:improve_simd_gather_documentation, r=Amanieu REVERT: a6b22e95975 Rollup merge of #127134 - tgross35:typeid-debug, r=Nilstrieb REVERT: 7f0bb45d5b9 Rollup merge of #126906 - GrigorenkoPV:fixme-split_at_first, r=Mark-Simulacrum REVERT: b0feb54c3d8 Rollup merge of #126705 - safinaskar:panic, r=Mark-Simulacrum REVERT: b8977f5a191 Auto merge of #127133 - matthiaskrgr:rollup-jxkp3yf, r=matthiaskrgr REVERT: affa2f90405 Print `TypeId` as a `u128` for `Debug` REVERT: 05a472c8d62 Rollup merge of #127122 - TDecking:div_ceil, r=Nilstrieb REVERT: 9b3a5111038 Auto merge of #120639 - fee1-dead-contrib:new-effects-desugaring, r=oli-obk REVERT: f96a3214d6b Stabilize `duration_abs_diff` REVERT: bf9096fc013 small correction to fmt::Pointer impl REVERT: 171f5dbb17b Auto merge of #127121 - GuillaumeGomez:rollup-xjjjckn, r=GuillaumeGomez REVERT: 50a66465304 Remove uneccessary condition in `div_ceil` REVERT: 79143898a34 Updated docs on `#[panic_handler]` in `library/core/src/lib.rs` REVERT: 1858bdce9b8 Rollup merge of #127073 - Sky9x:unnecessary-seqcst, r=Nilstrieb REVERT: aaed20934c7 Rollup merge of #127072 - Sky9x:docs-includes-vs-does-include, r=scottmcm REVERT: e5a577d85dc Auto merge of #127119 - RalfJung:miri-sync, r=RalfJung REVERT: 77a5b51293f Rollup merge of #126953 - joboet:lazy_key, r=jhpratt REVERT: 8641f6a3b19 Merge from rustc REVERT: 402992c7d21 Rollup merge of #127071 - Sky9x:remove-ptr-to-from-bits, r=scottmcm REVERT: 0a2d8e47740 Rollup merge of #127070 - Sky9x:unit-const-param-ty, r=BoxyUwU REVERT: 663f3d54372 Rollup merge of #127055 - shepmaster:hash-finish-must-use, r=dtolnay REVERT: 729a10a00b8 address review comments REVERT: db228b821dd general fixups and turn `TODO`s into `FIXME`s REVERT: 47492c9ec94 Implement `Min` trait in new solver REVERT: cc4a0293697 implement new effects desugaring REVERT: d6fadf5ac19 std: add safety comments REVERT: 8c3c7dcea79 Rollup merge of #126970 - DaniPopes:simplify-str-clone_into, r=cuviper REVERT: ae98528d9f3 Rollup merge of #126956 - joboet:fmt_no_extern_ty, r=RalfJung REVERT: 652f0b8fe38 Merge from rustc REVERT: 48dc678b2c6 Remove unnecessary SeqCst in `impl fmt::Pointer for AtomicPtr` REVERT: e6e5e84cae6 docs: say "includes" instead of "does include" REVERT: a722d391cd8 Remove (deprecated & unstable) {to,from}_bits pointer methods REVERT: 2ed9c9f5b62 add () to the marker_impls macro for ConstParamTy REVERT: fdfe0148965 Mark `Hasher::finish` as #[must_use] REVERT: 2bd2069f1dd fix least significant digits of f128 associated constants REVERT: 8db57c2b618 core: improve comment REVERT: 1f8c8f42e51 Cleanup bootstrap check-cfg REVERT: 6c38c60873f Rollup merge of #126980 - Borgerr:fix-extendfromslice-check, r=workingjubilee REVERT: a2dc9b539e3 Rollup merge of #126929 - nnethercote:rm-__rust_force_expr, r=oli-obk REVERT: cf231e8ada7 Merge from rustc REVERT: a8b311eb853 Auto merge of #126608 - tgross35:f16-f128-library, r=Mark-Simulacrum REVERT: 4788a93eee2 std: test a variety of ways to extend a Wtf8Buf REVERT: 57c2de81f2b set self.is_known_utf8 to false in extend_from_slice REVERT: c14a130aa4a Rollup merge of #126879 - the8472:next-chunk-filter-drop, r=cuviper REVERT: f6fdef3996a core: avoid `extern` types in formatting infrastructure REVERT: 43a865ad540 fix UI test, simplify error message REVERT: ff33a6672e7 regression test for leaks in the the Filter::next_chunk implementation REVERT: f90972a4104 add comments explaining optimizations for Filter::next_chunk REVERT: 4039a7f34e7 fix Drop items getting leaked in Filter::next_chunk REVERT: 0351c5316c0 Simplify `str::clone_into` REVERT: 5aedb8ada69 Rollup merge of #126946 - cyrgani:patch-1, r=compiler-errors REVERT: 5664da3fcac Rollup merge of #126927 - workingjubilee:vaargsafe-is-unsafe, r=joboet REVERT: 927337346fd Rollup merge of #126885 - Borgerr:rm_internal_pathbuf_asmutvec, r=workingjubilee REVERT: 46074aad759 Rollup merge of #126302 - mu001999-contrib:ignore/default, r=michaelwoerister REVERT: 0fe53622318 Stabilize const unchecked conversion from u32 to char REVERT: 9dcaa15a8dc std: separate TLS key creation from TLS access REVERT: 5d08a54141c Detect unused structs which derived Default REVERT: e6c45e4a711 `PathBuf::as_mut_vec` removed and verified for UEFI and Windows platforms #126333 REVERT: 7cec6ef8d5e remove references to `PathBuf::as_mut_vec` in `PathBuf::_set_extension` REVERT: 37f78f46760 inner truncate methods for UEFI platforms REVERT: cfb802176cb #126333 remove `PathBuf::as_mut_vec` reference at top of `PathBuf::_push` REVERT: 3edb521863d simd_bitmask intrinsic: add a non-power-of-2 multi-byte example REVERT: 2ddf7942352 Add missing slash in const_eval_select doc comment REVERT: 19cfdb2c317 Add tests for `f16` and `f128` REVERT: 561daffd3f5 Add more `f16` and `f128` library functions and constants REVERT: 6cb3d34841e Add doctests to existing `f16` and `f128` functions REVERT: b0e050324f9 Add build.rs config for reliable `f16` and `f128` REVERT: 028026b9b30 Remove `__rust_force_expr`. REVERT: 1069a689007 core: VaArgSafe is an unsafe trait REVERT: a451b2a9f8b Auto merge of #126852 - scottmcm:more-checked-math-tweaks, r=Amanieu REVERT: 17d03b950a4 Check that we get somewhat sane PIDs when spawning with pidfds REVERT: 4c9a96eebda more fine-grained feature-detection for pidfd spawning REVERT: bf06e436d4a document safety properties of the internal Process::new constructor REVERT: 9212236fc18 use pidfd_spawn for faster process creation when pidfds are requested REVERT: 4815f2968d4 document the cvt methods REVERT: 1bd207e6b0a Rollup merge of #126904 - GrigorenkoPV:nonzero-fixme, r=joboet REVERT: 2676918a59b Rollup merge of #125575 - dingxiangfei2009:derive-smart-ptr, r=davidtwco REVERT: 9dcffa5782f Rollup merge of #125082 - kpreid:const-uninit, r=dtolnay REVERT: cf34f71c117 Replace `MaybeUninit::uninit_array()` with array repeat expression. REVERT: e51d8a2224f Auto merge of #126523 - joboet:the_great_big_tls_refactor, r=Mark-Simulacrum REVERT: 2b8c7a3813f Small fixme in core now that split_first has no codegen issues REVERT: 532304befc3 Small fixme in core now that NonZero is generic REVERT: 5ae0378035a std: fix wasm builds REVERT: ae08c581475 Rollup merge of #126213 - zachs18:atomicbool-u8-i8-from-ptr-alignment, r=Nilstrieb REVERT: 071e80d6c4a Fix simd_gather documentation REVERT: 0c4a661ebdf wasm64 build with target-feature=+simd128,+atomics REVERT: 36a20f7b383 Reword docs for `f32` and `f64` REVERT: 6839ec5efd2 Extract repeated constants from `f32` and `f64` source REVERT: c26bd79991f Rollup merge of #126854 - devnexen:std_unix_os_fallback_upd, r=Mark-Simulacrum REVERT: 828e528d416 Rollup merge of #126807 - devnexen:copy_file_macos_simpl, r=Mark-Simulacrum REVERT: 5fc66ddb6d3 Implement `unsigned_signed_diff` REVERT: e4bc79db7fe Also get `add nuw` from `uN::checked_add` REVERT: 7c83a041921 SmartPointer derive-macro REVERT: f0b95fcce71 fix build REVERT: 12ec5b7b691 Rollup merge of #126783 - tguichaoua:fix_tcplistener_into_incoming_issue_number, r=workingjubilee REVERT: eb265d0841e std::unix::os::home_dir: fallback's optimisation. REVERT: a48f3d6475d Auto merge of #126838 - matthiaskrgr:rollup-qkop22o, r=matthiaskrgr REVERT: ec8af4b3c06 Rollup merge of #126552 - fee1-dead-contrib:rmfx, r=compiler-errors REVERT: 6d6ba925574 Rollup merge of #126140 - eduardosm:stabilize-fs_try_exists, r=Amanieu REVERT: e1edea8f3a4 Auto merge of #116113 - kpreid:arcmut, r=dtolnay REVERT: 49d4fdb09f1 Generalize `{Rc,Arc}::make_mut()` to unsized types. REVERT: 5ac719ed6a2 Replace `WriteCloneIntoRaw` with `CloneToUninit`. REVERT: a4ca461939e Add `core::clone::CloneToUninit`. REVERT: 78368435c65 Auto merge of #126750 - scottmcm:less-unlikely, r=jhpratt REVERT: 934e7286794 Auto merge of #124101 - the8472:pidfd-methods, r=cuviper REVERT: c2ec99b6637 to extract a pidfd we must consume the child REVERT: f7cf777c00b Add PidFd::{kill, wait, try_wait} REVERT: d688595fa6c std::unix::fs: copy simplification for apple. REVERT: bb602cf940d Auto merge of #125853 - tesuji:promote-fail-fast, r=cjgillot REVERT: 1f1793634b4 update intrinsic const param counting REVERT: 5e7ce0bad23 Remove `feature(effects)` from the standard library REVERT: 8902c171c30 Auto merge of #126781 - matthiaskrgr:rollup-5u4pens, r=matthiaskrgr REVERT: 54eaed7e5ef fix issue number REVERT: 2e01ae34277 Rollup merge of #126613 - tgross35:log-test-update, r=cuviper REVERT: 306d7bf153a Stop using `unlikely` in `strict_*` methods REVERT: a8ab1ceb396 [GVN] Add tests for generic pointees with PtrMetadata REVERT: a272844a6e1 Don't perform mitigation for thread-unsafe libc::exit under Miri. REVERT: 5035a17dec1 fix rustdoc URL REVERT: 1530977b9a5 On `target_os = "linux"`, ensure that only one Rust thread calls `libc::exit` or returns from `main`. REVERT: 7e940ba00cf Auto merge of #126578 - scottmcm:inlining-bonuses-too, r=davidtwco REVERT: 9a945fdf0e9 Auto merge of #124032 - Voultapher:a-new-sort, r=thomcc REVERT: dbaf524df30 Rollup merge of #126737 - fee1-dead-contrib:rm-const-closures, r=compiler-errors REVERT: 0f6922d6272 Fix wrong big O star bracing in the doc comments REVERT: 7bf7f578614 Remove `feature(const_closures)` from libcore REVERT: b4e2e4ac6e9 Auto merge of #126736 - matthiaskrgr:rollup-rb20oe3, r=matthiaskrgr REVERT: 0829ab8d1b7 Rollup merge of #126717 - nnethercote:rustfmt-use-pre-cleanups, r=jieyouxu REVERT: f1c9c809b1f Rollup merge of #126711 - GKFX:const-option-as-slice, r=oli-obk REVERT: e0572323ddb Auto merge of #116088 - nbdd0121:unwind, r=Amanieu,RalfJung REVERT: 13ea648b170 Stabilize `PanicInfo::message()` and `PanicMessage` REVERT: b6a38581515 Rollup merge of #126703 - the8472:on-blackbox-crypto-use, r=scottmcm REVERT: 847726d1be8 Shrink some slice iterator MIR REVERT: 1ba2fa4b637 Stabilize `hint_assert_unchecked` REVERT: 9d0041c40d7 Update documentation for `hint::assert_unchecked` REVERT: e3e84a75a9b Add blank lines after module-level `//` comments. REVERT: 36ad0db0a23 Add blank lines after module-level `//!` comments. REVERT: 4e67110a2fb Convert some module-level `//` and `///` comments to `//!`. REVERT: 669d6fce08c Make Option::as_[mut_]slice const REVERT: 4ae781cb5e2 reword the hint::blackbox non-guarantees REVERT: dd7c901e95d core: add tracking issue for `array::repeat` REVERT: 5ddeaca202b core: simplify implementation of `array::repeat`, address other nits REVERT: 62f7a4e4e92 core: implement `UncheckedIterator` for `RepeatN` REVERT: 387fd1f34c6 core: implement `array::repeat` REVERT: 3fc18d0b40c Add a hack to prevent proc_macro misopt in CI REVERT: a95938d6730 Stabilise c_unwind REVERT: 2a5e5b887ef Rollup merge of #125787 - Oneirical:infinite-test-a-novel, r=jieyouxu REVERT: 227994dbde2 try implementing suggestions REVERT: 78867ab1aa0 run_make_support nm implementation + bin-emit-no-symbols rmake rewrite REVERT: 76e61bf77a6 Replace `move||` with `move ||` in `compiler/` and `library/` REVERT: 13a31b63b4f Auto merge of #126330 - m-ou-se:panic-message-type, r=Amanieu REVERT: 42802a3a09e Print the tested value in int_log tests REVERT: ea1ab74eb6d Add missing CopyMarker impl REVERT: 384c2054629 Revert panic_safe test changes REVERT: ca458bac5ae Add PanicMessage type for PanicInfo::message(). REVERT: 22389455823 Add tracking issue to async_drop API REVERT: 0b3227b6dac std: rename module for clarity REVERT: 2b9a4f38bd6 std: update TLS module documentation REVERT: 00d4964bb22 std: use the `c_int` from `core::ffi` instead of `libc` REVERT: bd3b9eca35a std: simplify `#[cfg]`s for TLS REVERT: 78eaad5fb0a Fix unintended regression for Freeze + Copy types REVERT: 8cd20cb8dc1 Auto merge of #126569 - jieyouxu:rollup-1uvkb2y, r=jieyouxu REVERT: c1acd7a6844 Rollup merge of #126531 - slanterns:error_provider, r=workingjubilee REVERT: cd1c9984d30 Rollup merge of #126468 - RalfJung:euclid, r=Mark-Simulacrum REVERT: 27308799efa Rollup merge of #126346 - hermit-os:fd, r=Amanieu REVERT: ebbce699236 Rollup merge of #126288 - x4exr:patch-1, r=dtolnay REVERT: 4aa43c72385 Auto merge of #125720 - folkertdev:optimize_for_size-ptr-rotate, r=Amanieu REVERT: 791232945c4 doc: Added commas where needed REVERT: 48e157873f1 Fix doc-link issue REVERT: 489dfceabae Remove reliance on const_trait in sort implementations REVERT: 89b578450c9 std: move `sys_common::backtrace` to `sys` REVERT: 90dbe22a287 use rustc-dep-of-std in panic_unwind REVERT: 6832ad31e1c Rollup merge of #126539 - lukaslueg:patch-1, r=jhpratt REVERT: 04e46c2630d Rollup merge of #125112 - tbu-:pr_create_dir_all_empty, r=dtolnay REVERT: e77b4744b48 Update `Arc::try_unwrap()` docs REVERT: 83c530fb2f8 Apply review comments REVERT: ae7f43eda80 Auto merge of #126299 - scottmcm:tune-sliceindex-ubchecks, r=saethlin REVERT: 339f26630a2 Redo SliceIndex implementations REVERT: 2388743f251 update comment REVERT: 4cc1c37692c Rollup merge of #126229 - ChrisDenton:bindgen, r=Mark-Simulacrum REVERT: b40c54bb5bc std: refactor the TLS implementation REVERT: 7e3c4f82606 Auto merge of #126518 - matthiaskrgr:rollup-wb70rzq, r=matthiaskrgr REVERT: 26785938493 std: suggest OnceLock over Once REVERT: b509ed20612 Polish `std::path::absolute` documentation. REVERT: c3c175798d2 Auto merge of #126473 - matthiaskrgr:rollup-8w2xm09, r=matthiaskrgr REVERT: a135342704a Rollup merge of #126285 - kpreid:unique-rc, r=dtolnay REVERT: 7fafb6d366e Rollup merge of #126266 - tbu-:pr_doc_alloc_default_system, r=jhpratt REVERT: afee9f5e11d Rollup merge of #126135 - hermit-os:fuse, r=jhpratt REVERT: 4a32b4bcf84 Rollup merge of #123769 - dtolnay:literal, r=fee1-dead REVERT: 3909d510924 div_euclid, rem_euclid: clarify/extend documentation REVERT: ca52a2ca0e3 Rollup merge of #126351 - devnexen:to_sol11_upd, r=ChrisDenton REVERT: 369fa557b2f Rollup merge of #126402 - firefighterduck:fix-unsafe-precon-copy, r=Nilstrieb REVERT: 2acb995e558 Rollup merge of #126390 - Kriskras99:master, r=Nilstrieb REVERT: b3c1dcb8a6b Rollup merge of #126360 - compiler-errors:uplift-structural-traits, r=lcnr REVERT: bdb9aa2f3cd Rollup merge of #123726 - jieyouxu:command-new-docs, r=Nilstrieb REVERT: 307d1afdbd4 Remove superfluous escaping from byte, byte str, and c str literals REVERT: 78d94eeb0ff LangItem-ify Coroutine trait in solvers REVERT: 891f00ce0fd fix wrong assert_unsafe_precondition message for core::ptr::copy REVERT: 9adf702cc46 Rollup merge of #126384 - RalfJung:is_none_or, r=workingjubilee REVERT: 02cb1e9e580 Rollup merge of #126347 - slanterns:try_simplify, r=scottmcm REVERT: fa2a54a54c6 Fix wording in {checked_}next_power_of_two REVERT: 3ef894f8bc5 add tracking issue for is_none_or REVERT: a5fe19dc0bd std::unix::fs::link using direct linkat call for Solaris and macOs. REVERT: 9921cd25ed1 Rollup merge of #126328 - RalfJung:is_none_or, r=workingjubilee REVERT: 93583a69853 Simplify `try_*` on `Iterator` REVERT: 47090b15fb8 export std::os::fd module on HermitOS REVERT: 17c90d81d23 Auto merge of #126273 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum REVERT: b482e06e29c add is_none_or REVERT: 027c82e6edc Rollup merge of #126322 - m-ou-se:panicinfo-and-panicinfo-2, r=RalfJung REVERT: db03ec6a89e Rollup merge of #126242 - yaahc:simplify-provider, r=jhpratt REVERT: 956efdef025 Rollup merge of #126039 - dpaoliello:arm64ecbuild, r=davidtwco REVERT: 3acb41fba7c Fix deprecated version. REVERT: bc5e618edd3 Update doc comment on PanicInfo::message(). REVERT: 249d63e985c Use payload_as_str instead of two downcasts. REVERT: 15677e9f865 Fix deprecation version. REVERT: a239d5bf0e1 Clarify doc comment. REVERT: 209f8c80d1f Auto merge of #126319 - workingjubilee:rollup-lendnud, r=workingjubilee REVERT: 6ec98e76fb6 Rollup merge of #126305 - workingjubilee:fix-os-string-to-string-utf8-invariant, r=joboet REVERT: 80467da88db Rollup merge of #126287 - nnethercote:reformat-cranelift-patch, r=bjorn3 REVERT: 5760a4e9d4e Rollup merge of #126281 - ChrisDenton:env, r=jhpratt REVERT: 439c2ae36dc Rollup merge of #126249 - workingjubilee:simplify-try-map-signature, r=scottmcm REVERT: 23e3dbf043a Rollup merge of #126210 - lolbinarycat:ptr_doctest_assert, r=workingjubilee REVERT: d46939470bf Rollup merge of #123374 - mgeier:doc-slice-from-raw-parts, r=scottmcm REVERT: 63fe960c257 Require any function with a tait in its signature to actually constrain a hidden type REVERT: e1d73c2d74a Revert "Rollup merge of #125362 - joboet:tait_hack, r=Nilstrieb" REVERT: 382ed528dc8 Make PathBuf less Ok with adding UTF-16 then `into_string` REVERT: 548e7a4135e Update a cranelift patch file for formatting changes. REVERT: 8ccbe9e6c8a `UniqueRc`: support allocators and `T: ?Sized`. REVERT: b3dcee69396 set_env: State the conclusion upfront REVERT: f56c02311ee Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_exists REVERT: c16d8b1f7a5 Unify guarantees about the default allocator REVERT: d8fe5899dc8 remove cfg(bootstrap) REVERT: a2ff49b68b4 replace version placeholder REVERT: f72e4a99cd5 Formatting. REVERT: 0503ca79148 Bump deprecation of std's PanicInfo alias to 1.82.0. REVERT: fea6b035e61 Add PanicHookInfo::payload_as_str(). REVERT: 0c8a9e06b97 Fix display of panic message in recursive panic. REVERT: 2f85702e572 Mention core's PanicInfo in error.md. REVERT: ad0667f9724 Add note on panic payload type. REVERT: 518722eccfc Downcast panic payload to String too in example. REVERT: c4dea816f7f Move deprecation of std::panic::PanicInfo to 1.80.0. REVERT: 143e4c4a40e Fix deprecation version. REVERT: c6749ae5b90 Rename std::panic::PanicInfo to PanicHookInfo. REVERT: db2e05588c5 Formatting. REVERT: 51f20ac6148 Fix invalid markdown/html. REVERT: d4b7304c0de Reorder body of begin_panic for consistency. REVERT: 373fb60b119 Impl Display for PanicPayload to simplify things. REVERT: 224d45cf15c Use unnamed lifetimes for [..]Payload impl blocks. REVERT: cf984e0e154 Move downcasting panic payload to str to a function. REVERT: a18eeac0a12 Mark some PanicInfo methods as #[inline] for consistency. REVERT: 47f359bc210 Remove std::panic::PanicInfo::internal_constructor+set_payload. REVERT: 701d6a23254 Remove core::panic::PanicInfo::internal_constructor. REVERT: cca865dd137 Update doc comment about core::panicking. REVERT: 221a90ccb77 Fix doc link. REVERT: d6658a5e3dd Add core::panic::PanicInfo::payload() for compatibility. REVERT: ca0bfebc0fe Document difference between core and std's PanicInfo. REVERT: 702405ed414 Split core's PanicInfo and std's PanicInfo. REVERT: 019e01f23f5 Skip fast path for dec2flt when optimize_for_size REVERT: 483f641ee13 Simplify `[T; N]::try_map` signature REVERT: 8b6f468edd8 Simplify provider api to improve llvm ir REVERT: c8170e67b53 Rollup merge of #126212 - SteveLauC:fix/haiku, r=joboet REVERT: 58bb5cfddf4 Rollup merge of #126191 - ivan-shrimp:nonzero_doc, r=scottmcm REVERT: d2f8ddfcc21 Bump windows-bindgen to 0.57 REVERT: 02bf1521553 Clarify `Command::new` behavior if passed programs with arguments REVERT: e17d6b968b4 Remove some unused crate dependencies. REVERT: 5840184c348 Update docs for AtomicU8/I8. REVERT: 87915497e69 fix: build on haiku REVERT: 263861f45c9 Update safety docs for AtomicBool::from_ptr. REVERT: e25ae61e2b5 docs(core): make more const_ptr doctests assert instead of printing REVERT: cf9de23d66b Auto merge of #126205 - jieyouxu:rollup-s64z5ng, r=jieyouxu REVERT: c5da756bc2a Rollup merge of #126194 - ChrisDenton:winerror, r=Mark-Simulacrum REVERT: c4bd74c1902 Rollup merge of #125253 - sunsided:feature/FRAC_1_SQRT_PI, r=Mark-Simulacrum REVERT: c9c5d8f0189 Auto merge of #126193 - RalfJung:miri-sync, r=RalfJung REVERT: e39299d577e Migrate more things to WinError REVERT: 0df0a38c38b fix `NonZero` doctest inconsistencies REVERT: 818933db00d Rollup merge of #126168 - devnexen:current_exe_haiku_simpl, r=ChrisDenton REVERT: a9bd5698ac7 Rollup merge of #126146 - devnexen:signal_fbsd, r=ChrisDenton REVERT: 05812a0309b Merge from rustc REVERT: 56bdaf3dfb3 std::unix::os current_exe implementation simplification for haiku. REVERT: e6c378f9a8e Auto merge of #125966 - schvv31n:impl_os_string_pathbuf_leak, r=workingjubilee REVERT: e000ecbd84a std::unix::process adding few specific freebsd signals to be able to id. REVERT: 67454f58555 Rollup merge of #126138 - wbk:patch-1, r=lqd REVERT: ca932c80555 Rollup merge of #125998 - devnexen:get_mode_illumos, r=Nilstrieb REVERT: 397e9cbe400 Rollup merge of #125951 - slanterns:error_in_core_stabilization, r=Amanieu REVERT: 4655eca9735 Fix typo in docs for std::pin REVERT: bb2e2d9fc7d add HermitOS support of vectored read/write operations REVERT: dd7ccb77633 Rollup merge of #126089 - wutchzone:option_take_if, r=scottmcm REVERT: 199da77e638 Rollup merge of #126030 - ChrisDenton:update-wingen-readme, r=Mark-Simulacrum REVERT: 8a4b11aa65d Rollup merge of #124012 - slanterns:as_slice_stabilize, r=BurntSushi REVERT: 05a92c2d02b Auto merge of #126110 - workingjubilee:backtrace-0.3.73, r=workingjubilee REVERT: cd73cbea88a Update backtrace to 0.3.73 REVERT: c6e53ce2b1a Merge from rustc REVERT: 3b603356225 Rollup merge of #125606 - diondokter:opt-size-int-fmt, r=cuviper REVERT: 7014731c32e fix doc comments about `error_generic_member_access` REVERT: 3f4816887c7 Stabilize `error_in_core` REVERT: 20f15f4d41a fixed memory leaks in PathBuf::leak & OsString::leak tests REVERT: fa66a61d655 Rollup merge of #126096 - c410-f3r:tests-tests-tests, r=jhpratt REVERT: 57369442f0d [RFC-2011] Allow `core_intrinsics` when activated REVERT: dfddd7e5a86 Stabilize Option::take_if REVERT: dbbb4ab477a less garbage, more examples REVERT: 051c6c60977 Raise `DEFAULT_MIN_STACK_SIZE` to at least 64KiB REVERT: 29932f32723 Auto merge of #126038 - matthiaskrgr:rollup-h4rm3x2, r=matthiaskrgr REVERT: 149a2370c6e Promote `arm64ec-pc-windows-msvc` to tier 2 REVERT: 4a81c121a38 Rollup merge of #126032 - ChrisDenton:update-docs, r=joboet REVERT: 7450cf043b4 Rollup merge of #125800 - fortanix:raoul/rte-99-fix_mut_static_task_queue, r=jethrogb REVERT: ed91d5578b4 Rollup merge of #125940 - devnexen:unix_fs_netbsd_get_path, r=cuviper REVERT: bf7430fdc68 Update description of the `IsTerminal` example REVERT: 91c8b231664 Update `./x fmt` command REVERT: 16321651051 Rollup merge of #125995 - kpreid:const-uninit-stable, r=Nilstrieb REVERT: 2c5f1acc4c1 Rollup merge of #125982 - xTachyon:fix-linked-list, r=jhpratt REVERT: 80cee25cbad Rollup merge of #123168 - joshtriplett:size-of-prelude, r=Amanieu REVERT: 28dc012bfbf std::unix::fs::get_mode implementation for illumos/solaris. REVERT: 14a6f295bcd Use inline const instead of unsafe to implement `MaybeUninit::uninit_array()`. REVERT: a2c3406e626 Use inline const instead of unsafe to construct arrays in `MaybeUninit` examples. REVERT: f8ee355f9c4 Rollup merge of #125932 - schvv31n:patch-1, r=lqd REVERT: 49dad463287 Rollup merge of #125927 - ferrocene:lw-alloc-unwind-test, r=pietroalbini REVERT: e38c13a5962 Rollup merge of #125696 - workingjubilee:please-dont-say-you-are-lazy, r=Nilstrieb REVERT: 1764910ce42 Rollup merge of #106186 - rossmacarthur:ft/iter-chain, r=Amanieu REVERT: fbb5246b92c Make deleting on LinkedList aware of the allocator REVERT: 85aa4b6ae53 impl OsString::leak & PathBuf::leak REVERT: b19dd145ea9 Add function `core::iter::chain` REVERT: 4952644d73e update tracking issue for `const_binary_heap_new_in` REVERT: 25245bba3d9 Rollup merge of #125919 - tbu-:pr_fix_typo, r=lqd REVERT: a415dddaa0d Rollup merge of #125504 - mqudsi:once_nominal, r=cuviper REVERT: ea7e91c6357 Let compiler auto impl `Send` for `Task` REVERT: 55f3d10071c Store `Task::p` as `dyn FnOnce() + Send` REVERT: 92b604f475f Pass function for `Thread` as `Send` to `Thread::imp` REVERT: 33389b0e051 more explicitly state the basic rules of working with the obtained raw pointers REVERT: 395ad9f8afc Windows: Use futex implementation for `Once` REVERT: 175ad227af0 Auto merge of #125525 - joboet:tls_accessor, r=cuviper REVERT: 31e0022e8f2 std::unix::fs::get_path: using fcntl codepath for netbsd instead. REVERT: 82e24ad44cd Fix typo in the docs of `HashMap::raw_entry_mut` REVERT: fcc07af4e3a Ignore `vec_deque_alloc_error::test_shrink_to_unwind` test on non-unwind targets REVERT: 6ef46b31227 Auto merge of #125912 - nnethercote:rustfmt-tests-mir-opt, r=oli-obk REVERT: 79271381c4f Remove stray "this" REVERT: 06d9b0e9397 Add "OnceList" example to motivate OnceLock REVERT: 6d001c57db6 Move first OnceLock example to LazyLock REVERT: 7e47256ddbf Differ LazyLock vs. OnceLock in std::sync overview REVERT: a198721997c Explain LazyCell in core::cell overview REVERT: ae5598aabc3 Reformat `mir!` macro invocations to use braces. REVERT: 494f05c1d78 Rollup merge of #125898 - RalfJung:typo, r=Nilstrieb REVERT: 7881d33deef Rollup merge of #125884 - Rua:integer_sign_cast, r=Mark-Simulacrum REVERT: 380d9a3d410 Rollup merge of #121062 - RustyYato:f32-midpoint, r=the8472 REVERT: 81b9e26560b Wording of the documentation REVERT: 1c707b64249 typo: depending from -> on REVERT: fe5adb924fb Auto merge of #125577 - devnexen:netbsd_stack_min, r=joboet REVERT: 7953644ecec from_ref, from_mut: clarify domain of quantification REVERT: 876458ec8a2 Implement feature `integer_sign_cast` REVERT: e929c7fda65 Change f32::midpoint to upcast to f64 REVERT: cd0400080d5 Auto merge of #124294 - tspiteri:ilog-first-iter, r=the8472 REVERT: 7f0b19dd24d stablize `const_binary_heap_constructor` & create an unstable feature `const_binary_heap_new_in` for `BinaryHeap::new_in` REVERT: 5c2e2744f32 Rollup merge of #125730 - mu001999-contrib:clippy-fix, r=oli-obk REVERT: 9fe18037b50 Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk REVERT: 894310362d5 Avoid `mut` and simplify initialization of `TASK_QUEUE` REVERT: ba98164a104 Auto merge of #124636 - tbu-:pr_env_unsafe, r=petrochenkov REVERT: bbaaa79ab59 Rollup merge of #125746 - jmillikin:duration-from-weeks-typo, r=lqd REVERT: 1329a62eb9e Rollup merge of #125739 - RalfJung:drop-in-place-docs, r=workingjubilee REVERT: 8883bcf630b Rollup merge of #125342 - tbu-:pr_doc_write, r=ChrisDenton REVERT: 14d5dcb4160 explain what the open questions are, and add a Miri test for that REVERT: 6f01ba7ade6 Apply x clippy --fix and x fmt REVERT: c9c0713ee9b Fix copy-paste error in `Duration::from_weeks` panic message. REVERT: e935223b1b8 Rollup merge of #125733 - compiler-errors:async-fn-assoc-item, r=fmease REVERT: 4feb8819521 Elaborate about modifying env vars in multi-threaded programs REVERT: 25007197aef Add note about safety of `std::env::set_var` on Windows REVERT: c4b1ff893a1 Make `std::env::{set_var, remove_var}` unsafe in edition 2024 REVERT: 07d3009644f drop_in_place: weaken the claim of equivalence with drop(ptr.read()) REVERT: 99eabb47fb4 Add lang item for AsyncFnKindHelper::Upvars REVERT: a8f468f97f8 Add lang item for Future::Output REVERT: 2e1896e1976 Add lang items for AsyncFn's associated types REVERT: d82378a11dd [ACP 362] genericize `ptr::from_raw_parts` REVERT: 619e33b0691 Add FRAC_1_SQRT_2PI doc alias to FRAC_1_SQRT_TAU REVERT: 12652447f15 make `ptr::rotate` smaller when using `optimize_for_size` REVERT: bb6d4eb5be6 Add safety comment to fix tidy REVERT: c8b699c1ab2 Optimize async drop glue for some old types REVERT: 0444ab852cd Add FRAC_1_SQRT_2PI constant to f16/f32/f64/f128 REVERT: 1aaf0a9adac Rollup merge of #125226 - madsmtm:fix-mac-catalyst-tests, r=workingjubilee REVERT: 565dce2d3fe Rollup merge of #124251 - scottmcm:unop-ptr-metadata, r=oli-obk REVERT: a4025eba8f9 Add custom mir support for `PtrMetadata` REVERT: 87b9f244814 Add an intrinsic for `ptr::metadata` REVERT: 914d2c03f3a Rollup merge of #125637 - nnethercote:rustfmt-fixes, r=GuillaumeGomez REVERT: 3170156cbf5 Make more of the test suite run on Mac Catalyst REVERT: 9753338652f Disable stack overflow handler tests on iOS-like platforms REVERT: 35483898acf Don't format `tests/run-make/*/rmake.rs`. REVERT: 6fcf1300f8b Rollup merge of #125647 - tspiteri:track-lazy_cell_consume, r=workingjubilee REVERT: 385e1b87512 Rollup merge of #125551 - clarfonthey:ip-bits, r=jhpratt REVERT: 457f5eebf4b update tracking issue for lazy_cell_consume REVERT: 893db811403 Auto merge of #125636 - workingjubilee:bump-backtrace-0.3.72, r=workingjubilee REVERT: 67858588bb6 Sync libstd deps with backtrace REVERT: b2148722d86 Bump backtrace to 0.3.72 REVERT: 0ef7706b6c1 Auto merge of #125609 - diondokter:opt-size-char-count, r=thomcc REVERT: 3578f429478 Rollup merge of #124870 - Lokathor:update-result-docs, r=dtolnay REVERT: d4fb66bf7aa Always use the general case char count REVERT: 1e8098b6dd4 Size optimize int formatting REVERT: a74509c7872 Rollup merge of #125559 - scottmcm:simplify-shift-ubcheck, r=workingjubilee REVERT: bc346a0aedb Auto merge of #122079 - tbu-:pr_copy_file_range_probe, r=the8472 REVERT: fdcee4d0921 std::pal::unix::thread fetching min stack size on netbsd. REVERT: d14171db7a1 Auto merge of #125574 - matthiaskrgr:rollup-1oljoup, r=matthiaskrgr REVERT: 3e545bcb6f3 Rollup merge of #125571 - tesuji:dummy-pi, r=Nilstrieb REVERT: 840944248ea Rollup merge of #125561 - Cyborus04:stabilize-slice-flatten, r=scottmcm REVERT: 8981ee4ff26 Auto merge of #125570 - tesuji:stdout-handle, r=Nilstrieb REVERT: addaaed02ce f32: use constants instead of reassigning a dummy value as PI REVERT: 8a6d10d57b7 use proper name instead of magic number REVERT: 64671fa9e4b Stabilize `slice_flatten` REVERT: 40140819538 Auto merge of #125070 - tbu-:pr_set_extension_panic, r=jhpratt REVERT: f54c5577ff7 Auto merge of #125518 - saethlin:check-arguments-new-in-const, r=joboet REVERT: a4bac2bc347 It seems that anchor names are implicitly all lowercase REVERT: 7cddfd46930 Simplify the `unchecked_sh[lr]` ub-checks a bit REVERT: 805f56b8e16 Fix URL target, it's in the module not the type. REVERT: 3b77f19a9a8 github showed that weird. REVERT: 65726c04182 correct for copy paste errors when fixing wrapping. REVERT: 613145f6c4e Resolve https://github.com/rust-lang/rust/pull/124870#issuecomment-2128824959 REVERT: 9677b7057a8 revert to the inconsistent paragraph wrapping. REVERT: bf3ca983d95 Rollup merge of #124667 - newpavlov:stabilize_div_duration, r=jhpratt REVERT: 4af28c44c31 Rollup merge of #123803 - Sp00ph:shrink_to_fix, r=Mark-Simulacrum REVERT: 79e1daf6925 Rollup merge of #122986 - taiki-e:aix-c-char, r=Mark-Simulacrum REVERT: 0b13a6c1235 Rollup merge of #121377 - pitaj:lazy_cell_fn_pointer, r=dtolnay REVERT: b1ac7da4a90 Stabilise ip_bits feature REVERT: 23bb5bc4f4f Auto merge of #121571 - clarfonthey:unchecked-math-preconditions, r=saethlin REVERT: c11b36abf02 Rollup merge of #125527 - programmerjake:patch-2, r=workingjubilee REVERT: d6812d57a9e Rollup merge of #125498 - zmodem:avx512er, r=workingjubilee REVERT: f52291bef6b Rollup merge of #125478 - Urgau:check-cfg-config-bump-stage0, r=Mark-Simulacrum REVERT: 38dcab941d6 Rollup merge of #125271 - RalfJung:posix_memalign, r=workingjubilee REVERT: 29a1b3b9ffd Move the checks for Arguments constructors to inline const REVERT: 5257f3f01ac Add manual Sync impl for ReentrantLockGuard REVERT: 078095a8b94 std: make TLS accessors closures that return pointers REVERT: 567096dab49 Rollup merge of #125497 - meesfrensel:patch-1, r=calebzulawski REVERT: 88f01060642 Auto merge of #125499 - matthiaskrgr:rollup-84i5z5w, r=matthiaskrgr REVERT: dd828cf426c Stop using the avx512er and avx512pf x86 target features REVERT: 749b3766746 Change pedantically incorrect OnceCell/OnceLock wording REVERT: 50f0fa2e235 Rollup merge of #125477 - nnethercote:missed-rustfmt, r=compiler-errors REVERT: eaee1cdb4f2 Rollup merge of #125455 - blyxyas:opt-clamp, r=joboet REVERT: 2b1602ae72f Fix some SIMD intrinsics documentation REVERT: 5af5f810520 Auto merge of #122494 - joboet:simplify_key_tls, r=m-ou-se REVERT: a3658901754 Auto merge of #121150 - Swatinem:debug-ascii-str, r=joboet REVERT: 30b5a70b553 std: clean up the TLS implementation REVERT: 3489d4a3099 std: simplify key-based thread locals REVERT: 99a4928cbe3 Auto merge of #125479 - scottmcm:validate-vtable-projections, r=Nilstrieb REVERT: dfd5a535192 Validate the special layout restriction on DynMetadata REVERT: 59b5617f8ce Remove now outdated comment since we bumped stage0 REVERT: 6fbd5f4643a Run rustfmt on files that need it. REVERT: 1fce3b3766b Auto merge of #125463 - GuillaumeGomez:rollup-287wx4y, r=GuillaumeGomez REVERT: 6d1cdb564d6 Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods REVERT: 2e4649525ca Auto merge of #123724 - joboet:static_tls, r=m-ou-se REVERT: e14d82458f5 Rollup merge of #125452 - Urgau:check-cfg-libraries-cleanup, r=bjorn3 REVERT: a581126333d Rollup merge of #125362 - joboet:tait_hack, r=Nilstrieb REVERT: 1903afc49de Auto merge of #125456 - fmease:rollup-n8608gc, r=fmease REVERT: 05754b8862f Process a single not-ASCII-printable `char` per iteration REVERT: 07f94cbbc6b Rollup merge of #124389 - CensoredUsername:master, r=petrochenkov REVERT: df45c5ffff5 Auto merge of #117804 - saethlin:no-recursive-panics, r=joboet REVERT: 87c3913a42c Make clamp inline REVERT: ba934ca9a2b Copy core/alloc check-cfg message also in std REVERT: 339f74947ea Move some expected cfgs to std build.rs as per Cargo recommandation REVERT: fb68dc3e935 Replace fake "restricted-std" Cargo feature by custom cfg REVERT: f250e00abc0 panic_nounwind in Arguments::new* instead of recursing REVERT: 0606c046ba6 Expect any feature cfg in core and std crates REVERT: 200bc14b638 std: rewrite native thread-local storage REVERT: 0c289fbf2a5 core: use `Copy` in TAIT to fix clippy lint REVERT: 8eaf7855ace Rollup merge of #125392 - workingjubilee:unwind-a-problem-in-context, r=Amanieu REVERT: de824e83a34 Rollup merge of #125156 - zachs18:for_loops_over_fallibles_behind_refs, r=Nilstrieb REVERT: 0e6a8cdbefb Auto merge of #125423 - fmease:rollup-ne4l9y4, r=fmease REVERT: b5a5583aa95 Rollup merge of #125043 - RalfJung:ref-type-safety-invariant, r=scottmcm REVERT: 2d5dc612b03 Rollup merge of #125296 - tesuji:checkcfg-buildstd, r=Nilstrieb,michaelwoerister REVERT: 1525484f4d0 Rollup merge of #124896 - RalfJung:miri-intrinsic-fallback, r=oli-obk REVERT: 074b6e06d75 Auto merge of #117329 - RalfJung:offset-by-zero, r=oli-obk,scottmcm REVERT: 94bb282e242 Wrap Context.ext in AssertUnwindSafe REVERT: 376bf965f88 improve comment wording REVERT: aa2aa238d7e tidy alphabetica REVERT: 27067086648 addresss reviews REVERT: 5fd639cbb32 Update check-cfg lists for std REVERT: 9d4f5b433a2 Update check-cfg lists for alloc REVERT: edd27e234c9 Update check-cfg lists for core REVERT: 83ca47e3269 core: actually use TAIT instead of emulating it REVERT: ce29159a108 Simplify environment variable examples REVERT: 725b38e46aa Auto merge of #125358 - matthiaskrgr:rollup-mx841tg, r=matthiaskrgr REVERT: 9a4c4c87d1a Rollup merge of #125348 - tbu-:pr_doc_path_absolute, r=jhpratt REVERT: 8032a1a27b6 Rollup merge of #125266 - workingjubilee:stream-plastic-love, r=RalfJung,nikic REVERT: eef1bb84e54 Rollup merge of #125225 - madsmtm:ios-crt_externs.h, r=workingjubilee REVERT: b20fc81d540 Rollup merge of #125011 - diondokter:opt-for-size, r=Amanieu,kobzol REVERT: 45acd46951f Auto merge of #124097 - compiler-errors:box-into-iter, r=WaffleLapkin REVERT: 8fa3f607e33 Document behavior of `create_dir_all` wrt. empty path REVERT: fd9af8b62e3 Implement BOXED_SLICE_INTO_ITER REVERT: a398018ee01 Add the impls for Box<[T]>: IntoIterator REVERT: dc3424e8f21 Rollup merge of #125333 - hermit-os:fuse, r=workingjubilee REVERT: 7142c42f289 Rollup merge of #125123 - a1phyr:fix-read_exact, r=workingjubilee REVERT: bab1aed8253 Rollup merge of #124050 - saethlin:less-sysroot-libc, r=ChrisDenton REVERT: be748b645d6 Small fixes to `std::path::absolute` docs REVERT: c0ee0c7948c switch also the default implementation for read_vectored REVERT: dd196e7c132 Document platform-specifics for `Read` and `Write` of `File` REVERT: 57347f2a1b2 switch to the default implementation of `write_vectored` REVERT: a408318fc9a Remove Windows dependency on libc REVERT: da656ae2ac8 Address review comments REVERT: a71d9d9f8e9 Fix c_char on AIX REVERT: 67271309ef4 Rollup merge of #125283 - zachs18:arc-default-shared, r=dtolnay REVERT: 93ac8fe8f67 Switch to primarily using `&str` REVERT: 33cdd89c72f Introduce printable-ASCII fast-path for `impl Debug for str` REVERT: 6973e37fc5f Add a fast-path to `Debug` ASCII `&str` REVERT: e7eba09123b Write `char::DebugEscape` sequences using `write_str` REVERT: ae94e59551c Auto merge of #125313 - matthiaskrgr:rollup-65etxv0, r=matthiaskrgr REVERT: d65aacc2ae6 Rollup merge of #125093 - zachs18:rc-into-raw-with-allocator-only, r=Mark-Simulacrum REVERT: 529d2f27182 Auto merge of #124560 - madsmtm:update-libc, r=Mark-Simulacrum REVERT: 7d0c6cf5266 Make NULL check in argument parsing the same on all unix platforms REVERT: cc937f3207c Auto merge of #123878 - jwong101:inplacecollect, r=jhpratt REVERT: 3a5f258f015 Rollup merge of #124992 - foresterre:example/is-terminal, r=ChrisDenton REVERT: 625f7c39d9c Rollup merge of #124948 - blyxyas:remove-repeated-words, r=compiler-errors REVERT: ce3db1b638a fix typo REVERT: 06f98cb53c4 Fix typo in assert message REVERT: 68bd71a03aa cfg-out unused code under no_global_oom_handling REVERT: bc89bd03ded fmt REVERT: 7e59233a60c Add example to IsTerminal::is_terminal REVERT: 7bdc025f3f9 Auto merge of #123786 - a1phyr:cursor_unsafe, r=joboet REVERT: 44037db2ae3 Fix stacked borrows violation REVERT: 1920ed9058b Use a single static for all default slice Arcs. REVERT: 0ed8a018153 Rollup merge of #125252 - beetrees:patch-1, r=joboet REVERT: 2dcefb792df Rollup merge of #124304 - hermit-os:fuse, r=joboet REVERT: fb9b5c4efde Rollup merge of #123709 - tgross35:windows-cmd-docs-update, r=ChrisDenton REVERT: 49138842df5 use posix_memalign on most Unix targets REVERT: 5df616a99cc Auto merge of #124640 - Billy-Sheppard:master, r=dtolnay REVERT: cfaf50022ea Add NULL check in argument parsing on Apple platforms REVERT: b3ed7df1198 Auto merge of #99969 - calebsander:feature/collect-box-str, r=dtolnay REVERT: 8bbbc353f7a compiler: add simd_ctpop intrinsic REVERT: c8f44c3500d use `Result::into_ok` on infallible result. REVERT: 6e066ce3c43 specialize `Iterator::fold` for `vec::IntoIter` REVERT: 7479403773d optimize in_place_collect with vec::IntoIter::try_fold REVERT: 811303f34cc optimize in-place collection of `Vec` REVERT: f5c17c8513e Rollup merge of #125251 - jonhoo:patch-1, r=Nilstrieb REVERT: bd2c0a2d2a2 Clarify how String::leak and into_boxed_str differ REVERT: ee7954d55c9 Fix typos (taking into account review comments) REVERT: ceaf2051f00 Add `#[inline]` to float `Debug` fallback used by `cfg(no_fp_fmt_parse)` REVERT: e3f681ebd02 android: use posix_memalign for aligned allocations REVERT: bbc5d731171 Add a warning to Delimiter::None that rustc currently does not respect it. REVERT: 65de37a5ec5 Inline Duration construction into Duration::from_{millis,micros,nanos} REVERT: 561b61ae6e1 Update libc to 0.2.155 REVERT: 43505500028 Use `_NSGetArgc`/`_NSGetArgv` on iOS/tvOS/watchOS/visionOS REVERT: 30e2e43ffd9 Use `_NSGetEnviron` instead of `environ` on iOS/tvOS/watchOS/visionOS REVERT: e703bb11006 Don't call Duration::new unnecessarily in Duration::from_secs REVERT: b30cbc8f8ad Auto merge of #125188 - tgross35:f16-f128-powi, r=Nilstrieb REVERT: 8dd9e072080 Rollup merge of #125186 - Colepng:master, r=lqd REVERT: 27c7709e6a8 Rollup merge of #125171 - scottmcm:rename-flatten, r=jhpratt REVERT: 4fc7740a216 Access alloc field directly in Arc/Rc::into_raw_with_allocator. REVERT: c26086e162a Auto merge of #125163 - ssukanmi:stdarch_arm_crc32, r=Amanieu REVERT: 38e61a0cd9e Add `powi` to `f16` and `f128` REVERT: 8f57068184b Add doctests for f16 and f128 library functions where possible REVERT: 4515461d9b8 Remove duplicate word from addr docs REVERT: 266f7a3a84d Auto merge of #124728 - beetrees:from-f16-for-f64, r=BurntSushi REVERT: 86878b964b1 Fix linkchecker doc errors REVERT: 1bf7a30d31a Turn bare links into automatic links REVERT: 736b2250797 Move BufGuard impl outside of function REVERT: a44e7b3adea Fix tidy errors REVERT: 36af6395634 Replace sort implementations REVERT: 4313a19fb79 Auto merge of #124959 - prorealize:update-result-documentation, r=joboet REVERT: 8fb10ab34e0 Rename `flatten(_mut)` → `as_flattened(_mut)` REVERT: 5051ef5f531 Rollup merge of #125003 - RalfJung:aligned_alloc, r=cuviper REVERT: 136dbc3c526 feat: update stdarch submodule for intrinsics on ARM REVERT: 883d0d924b0 Allow for_loops_over_fallibles in test that tests &mut Result as IntoIterator. REVERT: 6b32f28106b Rollup merge of #125038 - ivan-shrimp:checked_sub, r=joboet REVERT: fee95d4f505 Rollup merge of #124307 - reitermarkus:escape-debug-size-hint-inline, r=joboet REVERT: ae1cb832cb6 Update library/core/src/result.rs REVERT: 48a835b093a Divide float nanoseconds instead of seconds REVERT: 9a851b20a22 avoid using aligned_alloc; posix_memalign is better-behaved REVERT: 4cb203b1da4 Fix `read_exact` and `read_buf_exact` for `&[u8]` and `io:Cursor` REVERT: 09663fe5933 Rollup merge of #116675 - joshlf:patch-10, r=scottmcm REVERT: 1e7fecbfef0 Add fn into_raw_with_allocator to Rc/Arc/Weak. REVERT: 7b24df0047d Forward alloc features to core REVERT: 14deb328fd3 Rollup merge of #123817 - slanterns:seek_relative, r=dtolnay REVERT: 78ac4d3afb7 [ptr] Document maximum allocation size REVERT: f84d57f6cc3 Don't use `T` with both Result and Option, improve explanation. REVERT: 88338ff820a Add `size_of`, `size_of_val`, `align_of`, and `align_of_val` to the prelude REVERT: 5d56638742b Panic if `PathBuf::set_extension` would add a path separator REVERT: 05e74fce7d0 offset, offset_from: allow zero-byte offset on arbitrary pointers REVERT: d8853f8e443 Use shared statics for the ArcInner for Arc::default, and for Arc<[T]>::default where alignof(T) <= 16. REVERT: a5d075794b0 Add note about possible allocation-sharing to Arc/Rc::default. REVERT: 22bf3672e03 added Default impls REVERT: 09d9a3b2344 Auto merge of #125045 - GuillaumeGomez:rollup-em6qdzw, r=GuillaumeGomez REVERT: 8d7b24b36d0 Rollup merge of #125021 - joshlf:patch-11, r=RalfJung REVERT: 42c03b9b38a Auto merge of #124798 - devnexen:illumos_memalign_fix, r=RalfJung REVERT: adaf5214346 Auto merge of #125012 - RalfJung:format-error, r=Mark-Simulacrum,workingjubilee REVERT: 5241e407dc1 reference type safety invariant docs: clarification REVERT: b0c4bae2a9b reverse condition in `uN::checked_sub` REVERT: 367de08f6fa Rollup merge of #124981 - zachs18:rc-allocator-generalize-1, r=Mark-Simulacrum REVERT: c195fa04253 References must also be non-null REVERT: 36a981688e2 Relax slice safety requirements REVERT: 6c546e7e8a3 std::alloc: using posix_memalign instead of memalign on solarish. REVERT: 08c5880b820 Auto merge of #124213 - rust-lang:cargo_update, r=Mark-Simulacrum REVERT: b7519610dc3 Pin libc back to 0.2.153 REVERT: 5aa269a0108 io::Write::write_fmt: panic if the formatter fails when the stream does not fail REVERT: f596a68a415 Add flag to sysroot REVERT: 6ccf84a4aa8 Add flag to std and alloc too REVERT: 985bd7c5d18 Add opt-for-size core lib feature flag REVERT: 388e37a9498 Rollup merge of #124954 - kpreid:fmterr, r=Nilstrieb REVERT: c381e255df9 Rollup merge of #124928 - okaneco:trim_ascii, r=workingjubilee REVERT: b63b13f33d4 Rollup merge of #124991 - Infinixius:patch-1, r=Nilstrieb REVERT: 6f9c0775da2 Rollup merge of #124766 - devnexen:getrandom_solarish, r=Mark-Simulacrum REVERT: 0d33b4bf4dd Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str` REVERT: 9a1eb1e2050 Fix typo in ManuallyDrop's documentation REVERT: 960e8ab70e2 Relax A: Clone requirement on Rc/Arc::unwrap_or_clone. REVERT: bc074ab412e Relax allocator requirements on some Rc APIs. REVERT: 7db52fca9b3 Add fn allocator method to rc/sync::Weak. Relax Rc/Arc::allocator to allow unsized T. REVERT: 378c8fc9804 Auto merge of #124863 - DaniPopes:from-str-radix-panic, r=Amanieu REVERT: 86719215259 Fix assert REVERT: 8c54418f536 Auto merge of #124774 - the8472:subnanosecond-benches, r=jhpratt REVERT: 54be5488e0e Rollup merge of #124551 - Swatinem:debug-str-bench, r=cuviper REVERT: 222895b053e Refactor examples and enhance documentation in result.rs REVERT: fa63eff9805 Document proper usage of `fmt::Error` and `fmt()`'s `Result`. REVERT: 43bf016caa3 Suggest borrowing on fn argument that is `impl AsRef` REVERT: 382db29c362 Auto merge of #124773 - Marcondiro:master, r=joboet REVERT: 21100234707 Improve escape methods. REVERT: 24f4b5121d0 Auto merge of #124793 - scottmcm:simplify-as-chunks, r=Nilstrieb REVERT: 4399b9ebdd7 Auto merge of #124910 - matthiaskrgr:rollup-lo1uvdn, r=matthiaskrgr REVERT: a7f8f81e3fe Rollup merge of #124892 - jfgoog:update-cc, r=workingjubilee REVERT: 37f66ba2889 Avoid panicking branch in `EscapeIterInner`. REVERT: b8826854a39 Inline `EscapeDebug::size_hint`. REVERT: 19ae86b1d3d Auto merge of #124795 - scottmcm:simplify-slice-from-raw-parts, r=joboet REVERT: efc7b04b3ef Use generic `NonZero`. REVERT: 091b42eb014 Use generic `NonZero` in examples. REVERT: d51ea4b068e miri: rename intrinsic_fallback_checks_ub to intrinsic_fallback_is_spec REVERT: 7a07503ee21 Update cc crate to v1.0.97 REVERT: bb9678aaf93 fix #124714 str.to_lowercase sigma handling REVERT: c567ea1a23c Rollup merge of #124838 - RalfJung:next_power_of_two, r=scottmcm REVERT: 8d51e8508f9 Rollup merge of #124788 - madsmtm:reduce-target_os-macos, r=workingjubilee REVERT: ce2c4627b13 Rollup merge of #124782 - anatawa12:docs-create-new-already-exists, r=workingjubilee REVERT: 4870ba34a23 Rollup merge of #124470 - devnexen:no_sigpipe_fbsd, r=workingjubilee REVERT: 50d5af44701 use teletype on the attribute name REVERT: 43ae1871a8b Some Result combinations work like an Option. REVERT: a69f31c459b from_str_radix: outline only the panic function REVERT: d0c07aa8677 Move `test_shrink_to_unwind` to its own file. REVERT: d77b1cc251a Fix `VecDeque::shrink_to` UB when `handle_alloc_error` unwinds. REVERT: 6eba9d713ac Auto merge of #124836 - tgross35:const-slice-last-chunk, r=BurntSushi REVERT: 039a5431958 next_power_of_two: add a doctest to show what happens on 0 REVERT: 252441d0952 Correct the const stabilization of `last_chunk` for slices REVERT: f9f006de23d f16::is_sign_{positive,negative} were feature-gated on f128 REVERT: 6a2e422f4b5 Auto merge of #124811 - matthiaskrgr:rollup-4zpov13, r=matthiaskrgr REVERT: 8501809b599 Rollup merge of #124520 - tbu-:pr_create_dir_all_doc, r=Amanieu REVERT: 9a9f3635dd4 Auto merge of #123850 - tspiteri:f16_f128_consts, r=Amanieu REVERT: c6dcb9ded36 std::rand: adding solaris/illumos for getrandom support. REVERT: ba0be73796c Auto merge of #124497 - rytheo:move-std-tests-to-library, r=workingjubilee REVERT: c9041b78068 Avoid a cast in `ptr::slice_from_raw_parts(_mut)` REVERT: 58f261d8bca Implement `as_chunks` with `split_at_unchecked` REVERT: c4e5d54b093 iOS/tvOS/watchOS/visionOS: Improve File Debug impl REVERT: 74f121b381f iOS/tvOS/watchOS/visionOS: Fix reading large files REVERT: 6333ccf0843 iOS/tvOS/watchOS: Fix alloc w. large alignment on older versions REVERT: e16bbb88409 iOS/tvOS/watchOS/visionOS: Set the main thread name REVERT: 4ea3e928541 Apply suggestions from code review REVERT: d8efd5a647e iOS/tvOS/watchOS/visionOS: Default to kernel-defined backlog in listen REVERT: 41ab2856661 add note about `AlreadyExists` to `create_new` REVERT: 7c225d78d9c emit fractional benchmark nanoseconds in libtest's JSON output format REVERT: 6431fc87674 print walltime benchmarks with subnanosecond precision REVERT: 8e59cbf3014 alloc: implement FromIterator for Box REVERT: 456ecae149a Rename test for issue 21058 REVERT: 170468725bd Rollup merge of #124750 - ultrabear:ultrabear_softfloatdoc, r=workingjubilee REVERT: 2f5732c49d6 Rollup merge of #124749 - RossSmyth:stable_range, r=davidtwco REVERT: c738b82af9d Fix unwinding on 32-bit watchOS ARM REVERT: f467aea6d61 Re-add `From for f64` REVERT: 8e7baf3ac32 Make f128 docs mention lack of any normal platform support REVERT: e51d8ac6e03 Make f16 and f128 docs clearer on platform support REVERT: c1f3ead255c Tgross feedback tweaks REVERT: 28d5ede47ba Rollup merge of #124721 - ids1024:netbsd-32-bit-ulong, r=workingjubilee REVERT: 206c2198132 library/std: Fix build for NetBSD targets with 32-bit `c_long` REVERT: 1acfaf2a8bc Rollup merge of #124699 - scottmcm:split_at_unchecked_should_use_unchecked, r=Nilstrieb REVERT: 5bea81c92e2 Rollup merge of #122441 - a1phyr:improve_read_impls, r=ChrisDenton REVERT: 22d57767941 Rollup merge of #124701 - scottmcm:unchecked_sub_docs, r=Nilstrieb REVERT: e63ddd80c40 Rollup merge of #124700 - scottmcm:unneeded_cast, r=Nilstrieb REVERT: 571651c5c4a Rollup merge of #124293 - oli-obk:miri_intrinsic_fallback_body, r=RalfJung REVERT: 8187d388285 Rollup merge of #124159 - joboet:move_pal_thread_parking, r=ChrisDenton REVERT: d8fe9f930e2 Rollup merge of #123356 - joboet:set_current_size, r=ChrisDenton REVERT: a0bfcc320f7 Docs: suggest `uN::checked_sub` instead of check-then-unchecked REVERT: ba13017a305 Remove an unnecessary cast REVERT: b16906dbbe4 Use `unchecked_sub` in `split_at` REVERT: 6b993f55b5b mark const_(de)allocate intrinsics as suitable for Miri REVERT: a8985b9195c Rollup merge of #124681 - risc0:erik/fix-test, r=joboet REVERT: 78978b287c7 Rollup merge of #124678 - UserIsntAvailable:feat/stabilize-split-at-checked, r=jhpratt REVERT: 39b713f9528 Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxu REVERT: 7c1caa7639a zkvm: fix run_tests REVERT: be4a2b92e11 feat: stabilize `split_at_checked` REVERT: f748ca30945 Rollup merge of #124593 - GKFX:cstr-literals-in-api-docs, r=workingjubilee REVERT: e103a071226 Rollup merge of #124059 - RalfJung:default_alloc_error_hook, r=workingjubilee REVERT: 2dd44afac42 Rollup merge of #123815 - trueb2:patch-1, r=workingjubilee REVERT: ca6d5db5449 Rollup merge of #122492 - GrigorenkoPV:ptr_as_ref_unchecked, r=workingjubilee REVERT: df5e42c921f default_alloc_error_hook: explain difference to default __rdl_oom in alloc REVERT: 0342284416b Use `CURRENT_RUSTC_VERSION` REVERT: 9eb77db22f6 Stabilize `div_duration` REVERT: 4d19673b6bd Rollup merge of #124649 - Meziu:master, r=ChrisDenton REVERT: d53a5d87abd Ensure miri only uses fallback bodies that have manually been vetted to preserve all UB that the native intrinsic would have REVERT: f5339d58008 Horizon OS: dirfd unavailable REVERT: a31e6861f4d Rollup merge of #124626 - RalfJung:const_eval_select, r=joboet REVERT: 6b924c2d215 Rollup merge of #124609 - RalfJung:float-precision, r=cuviper REVERT: bbf602cf523 Rollup merge of #124604 - Enselic:std-gimli-symbolize, r=workingjubilee REVERT: 22f7c455b85 Rollup merge of #124441 - bravequickcleverfibreyarn:string.rs, r=Amanieu REVERT: ed69db3f9ad Rollup merge of #124412 - RalfJung:io-safety, r=Amanieu REVERT: 29b5199904a Rollup merge of #123480 - Nadrieril:impl-all-derefpures, r=compiler-errors REVERT: a930b12dbbe Stabilize exclusive_range REVERT: 53755c9d24b Update based on review REVERT: dbaecde9672 Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` REVERT: 87c17006251 variable-precision float operations behave non-deterministically REVERT: 798d96685ff const_eval_select: add tracking issue REVERT: 57f8e3f6215 add constants in std::f128::consts REVERT: a3caf785466 add constants in std::f16::consts REVERT: 96635050b03 add f128 associated constants REVERT: b90c063cf70 add f16 associated constants REVERT: 08dcd04c27b Auto merge of #124419 - WaffleLapkin:never-type-fallback-docs, r=workingjubilee REVERT: 5420e304749 std: move thread parking to `sys::sync` REVERT: a563923fd8a library/std: Remove unused `gimli-symbolize` feature REVERT: b79f6575858 fixup links in never type docs REVERT: 5f113115560 Workaround rustfmt bug replacing type ascription REVERT: 8f360735eef Slightly reformat !'s docs after applying github suggestions REVERT: 6453de7af31 Step bootstrap cfgs REVERT: d562f4d418d Apply suggestions from code review REVERT: 6754ce4b9b5 Replace version placeholders for 1.79 REVERT: 8b4a654c7da Describe and use CStr literals in CStr and CString docs REVERT: 7f3217e9690 Rollup merge of #124542 - CBSpeir:diagnostic-item-enumerate-method, r=scottmcm REVERT: c45c254f1aa Add benchmarks for `impl Debug for str` REVERT: dda73645a60 Auto merge of #124491 - madsmtm:target_vendor-apple, r=workingjubilee REVERT: 4f147e3ad08 std: rewrite TLS on platforms without threads REVERT: 23224f3d32c Add diagnostic item for std::iter::Iterator::enumerate REVERT: ddf4a17a38b Rollup merge of #124530 - djkoloski:fuchsia_dirfd, r=tmandry REVERT: bb9ac1bed65 Document that `create_dir_all` calls `mkdir`/`CreateDirW` multiple times REVERT: dcd99927e38 Rollup merge of #124484 - GKFX:offset_of_must_use, r=jieyouxu REVERT: 8cec3545621 Fix Fuchsia build broken by #124210 REVERT: 05d627050dc Fix ESP IDF build broken by #124210 REVERT: d43f05d92d9 Auto merge of #124502 - NCGThompson:statically-known-docs, r=jhpratt REVERT: 56d5b84b45f Update is_val_statically_known docs REVERT: 01ac54c964f Run tidy on tests REVERT: 9f4b5068ab7 Stabilize `non_null_convenience` REVERT: 4a2abd366dd Fix posix_spawn not being used on iOS and visionOS REVERT: e7cb5e33051 Move various stdlib tests to library/std/tests REVERT: ae52df677a4 Fix va_list on watchOS and visionOS REVERT: 31d3d1ef5d3 Fix SIGEMT and SIGINFO parsing on watchOS and visionOS REVERT: fb0aa42c804 Fix available_parallelism on watchOS and visionOS REVERT: aef2c4bf523 Fix #124478 - offset_of! returns a temporary REVERT: b3793608a22 std::net: Socket::new_raw set to SO_NOSIGPIPE on freebsd/netbsd/dragonfly. REVERT: d2f0f29a8e2 Use `target_vendor = "apple"` instead of `target_os = "..."` REVERT: 585e7880633 Auto merge of #124210 - the8472:consign-ebadf-to-the-fire, r=Mark-Simulacrum REVERT: fdcf9028e48 put FD validity behind late debug_asserts checking REVERT: 00ddbeef794 Rollup merge of #124447 - workingjubilee:set-argv-twice-on-gnu, r=ChrisDenton REVERT: 48087698a6c Unconditionally call really_init REVERT: 7a6ddb35da6 Lift the probe code of `copy_file_range` into a function REVERT: dd215a8df14 Elaborate in comment about `statx` probe REVERT: 94de29b7814 WS fix. REVERT: 5530b833536 String.truncate calls Vec.truncate, in turn, and that states "is greater or equal to". Beside common sense. REVERT: e43ff272329 Auto merge of #124432 - zetanumbers:non_copy_into_raw_with_alloc, r=Nilstrieb REVERT: b94c1ea3960 Relax `A: Clone` bound for `rc::Weak::into_raw_and_alloc` REVERT: c60c646afcb io safety: update Unix explanation REVERT: bc31aa7193d Rollup merge of #124387 - workingjubilee:use-raw-pointers-in-thread-locals, r=joboet REVERT: e3c3ae33f45 thread_local: refine LazyKeyInner::take safety doc REVERT: 649101a66c3 Rollup merge of #124410 - RalfJung:path-buf-transmute, r=Nilstrieb REVERT: 0cfee71b625 Apply suggestions from code review REVERT: f5305c1c49a Add missing .into_iter() REVERT: 2a5af324d19 Extend the example code and assert the result REVERT: 093b3a7340b Document never type fallback in `!`'s docs REVERT: 678e5a09970 Add "safety" comment REVERT: d83ddf5487c Auto merge of #123909 - dtolnay:utf8chunks, r=joboet REVERT: 0f28de0474e PathBuf: replace transmuting by accessor functions REVERT: 91e6f9d261f Auto merge of #124393 - scottmcm:do-the-macros-still-matter, r=joboet REVERT: dc3de6b3694 Convert some iter macros to normal functions REVERT: cb96ad55b1e Rollup merge of #124076 - NobodyXu:patch-1, r=dtolnay REVERT: 60c92534076 thread_local: split refs to fields of Key REVERT: 4fd95572c93 thread_local: use less &mut T in LazyKeyInner::take REVERT: ad88e3e3d00 remove trivial bounds REVERT: d2c5fb9f9df Stabilize Utf8Chunks REVERT: ad89cf034d8 Rollup merge of #124351 - Treeniks:master, r=workingjubilee REVERT: 72e9d095bf2 Rollup merge of #124335 - ChrisDenton:stabilize-absolute, r=dtolnay REVERT: 3504c1e55e3 Rollup merge of #124322 - whosehang:master, r=Nilstrieb REVERT: 9f98c505623 fix typo in binary_heap docs REVERT: e8578cf3182 Auto merge of #124330 - fmease:rollup-a98y7jf, r=fmease REVERT: fb15b05719f Fix cannot usage in time.rs REVERT: 2a9b748bdfb Stabilize `std::path::absolute` REVERT: e8ea161ce8d Add `cfg_attr(bootstrap)` to doc tests REVERT: e72526a7862 Stabilise `inline_const` REVERT: 0dcdc5d3d1f Rollup merge of #124308 - CBSpeir:diagnostic-item-enumerate, r=compiler-errors REVERT: 58adebb606f Rollup merge of #124282 - RalfJung:fill_utf16_buf, r=ChrisDenton REVERT: fa7cbc4922c Rollup merge of #124281 - RalfJung:win-tls, r=joboet REVERT: 7c70cbbbf3f Error on using `yield` without also using `#[coroutine]` on the closure REVERT: 59b57e9548e chore: fix some typos in comments REVERT: 89e9dd3247d Add diagnostic item for std::iter::Enumerate REVERT: 7e58b1f1fd6 increase the readability by using the unique name for the hermit-abi REVERT: b8dab92c929 Auto merge of #124302 - matthiaskrgr:rollup-2aya8n8, r=matthiaskrgr REVERT: 86d0c93fc7c Rollup merge of #124003 - WaffleLapkin:dellvmization, r=scottmcm,RalfJung,antoyo REVERT: fccc0999ded revise the interpretation of ReadDir REVERT: eb97638cea1 Rollup merge of #123048 - RalfJung:layout, r=dtolnay REVERT: ad38f9b8000 unroll first iter of checked_ilog loop to save one multiplication REVERT: 50a633b3dc5 Rollup merge of #123050 - RalfJung:panic_str, r=m-ou-se REVERT: 2d5d316d0cb fix weak memory bug in TLS on Windows REVERT: ee9b6a66af9 windows fill_utf16_buf: explain the expected return value REVERT: 7a3093ab053 Rollup merge of #124266 - RalfJung:no-answer, r=joboet REVERT: bffc1abb0fa Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obk REVERT: 9241efe43e8 Rollup merge of #124230 - reitermarkus:generic-nonzero-stable, r=dtolnay REVERT: 5e43c9e2343 Rollup merge of #115913 - FedericoStra:checked_ilog, r=the8472 REVERT: f68a2540450 remove an unused type from the reentrant lock tests REVERT: 263871761f1 export assert_unsafe_precondition macro for std-internal use REVERT: ddfc171f4d1 Stabilize generic `NonZero`. REVERT: 1e346e3f46a Rollup merge of #124246 - gurry:add-comma-in-abs-doc, r=jhpratt REVERT: 799338151c2 Add comma at one place in `abs()` documentation REVERT: bc9a3bac63d Update stdarch submodule REVERT: 5d3ff3c85b9 Address more PR feedback REVERT: 9dc6454cb12 Use it in the library, and `InstSimplify` it away in the easy places REVERT: 4718ee986d8 Add an intrinsic that lowers to AggregateKind::RawPtr REVERT: 3ecfe74aab9 Rollup merge of #124184 - gurry:124152-suggest-unsigned-abs-in-abs-doc, r=jhpratt REVERT: d11afaba321 Rollup merge of #124089 - simlay:fix-preadv64-and-pwritev64-link-for-watchos-and-visionos, r=workingjubilee REVERT: bab3c02e234 Fix watchOS and visionOS for pread64 and pwrite64 calls REVERT: 1602a46cce6 Auto merge of #123930 - Mark-Simulacrum:vec-length-invariant, r=jhpratt REVERT: 755057b1edc Avoid reloading Vec::len across grow_one in push REVERT: 39144205382 Auto merge of #124208 - jieyouxu:rollup-gbgpu4u, r=jieyouxu REVERT: 3e0bb0d3435 Abort a process when FD ownership is violated REVERT: 15cabd56959 Rollup merge of #124103 - dtolnay:metadatadebug, r=Mark-Simulacrum REVERT: 5a86d4a6510 Rollup merge of #123976 - ChrisDenton:no-libc-in-std-doc-tests, r=Mark-Simulacrum REVERT: 5b55d8707a4 Rollup merge of #123967 - RalfJung:static_mut_refs, r=Nilstrieb REVERT: 63994f74cf8 Auto merge of #122013 - Swatinem:unicode-gen-fastpath, r=scottmcm REVERT: aa25c2f1e6c Add a lower bound check to `unicode-table-generator` output REVERT: d32491fe8a4 Suggest using `unsigned_abs` in `abs` documentation REVERT: ed803c29a95 Auto merge of #124114 - scottmcm:better-checked, r=workingjubilee REVERT: e32c184903f Rollup merge of #124116 - RalfJung:miri-rust-backtrace, r=Nilstrieb REVERT: 63a6950cee6 Rollup merge of #124019 - ChrisDenton:futex-raw-dylib, r=joboet REVERT: 4660cc66f34 Rollup merge of #123406 - krtab:fix_remainder_iterchunk, r=scottmcm REVERT: 2a4abc3cdb0 Make `checked` ops emit *unchecked* LLVM operations where feasible REVERT: c6285016410 Auto merge of #123144 - dpaoliello:arm64eclib, r=GuillaumeGomez,ChrisDenton,wesleywiser REVERT: b079821f1a9 when suggesting RUST_BACKTRACE=1, add a special note for Miri's env var isolation REVERT: b3b8c6d95dd Improve std::fs::Metadata Debug representation REVERT: 9699e68541d fix: make `str::from_raw_parts_mut` mut REVERT: a1dfa797f23 Rollup merge of #124049 - slanterns:const_io_structs_stabilize, r=jhpratt REVERT: 3dc77cf6bf4 Rollup merge of #122201 - coolreader18:doc-clone_from, r=dtolnay REVERT: 720fc75c4c7 Stablise io_error_downcast REVERT: 3a4e1618d09 Address comments REVERT: a05f231cbc6 Rollup merge of #124051 - dtolnay:emptyset, r=compiler-errors REVERT: b12e3b3048d Fix empty-set symbol in comments REVERT: 493080a0281 Stabilize `const_io_structs` REVERT: a86fde379d2 Rollup merge of #124013 - RalfJung:box-to-raw, r=oli-obk REVERT: ffa1ca9d180 Rollup merge of #123859 - krtab:uneeded_clone, r=cuviper REVERT: ac79fe637e8 Rollup merge of #123811 - joboet:queue_em_up, r=ChrisDenton REVERT: e0dc297888d Add simple async drop glue generation REVERT: 8b73e2eb0fa Use raw-dylib for Windows futex APIs REVERT: 84236d9eb78 std: fix lint on SGX REVERT: a783e1008bc Remove uneeded clones now that TrustedStep implies Copy REVERT: bae79d94085 Rollup merge of #123721 - madsmtm:fix-visionos, r=davidtwco REVERT: dbd03d4517e Stabilize `BinaryHeap::as_slice` REVERT: 94853467d7b Box::into_raw: make Miri understand that this is a box-to-raw cast REVERT: 2f18bf025db Update usage note on OpenOptions::append() REVERT: 5a124e4bf0f Change intrinsic types to use `u32` instead of `T` to match stable reexports REVERT: 9b3dfe9b8f5 Add support for Arm64EC to the Standard Library REVERT: 03f665c66d5 Rollup merge of #123970 - risc0:erik/zkvm-fix-os-str, r=joboet REVERT: 9265a3ecc93 Use fake libc in core test REVERT: 94831ffaa3a Auto merge of #123968 - jieyouxu:rollup-1pnkxor, r=jieyouxu REVERT: 311588525c9 static_mut_refs: use raw pointers to remove the remaining FIXME REVERT: 87f16a326ba zkvm: fix references to `os_str` module REVERT: a8ebeb91144 Rollup merge of #123957 - RalfJung:create_dir_all_bare, r=joboet REVERT: 2db449f5918 Rollup merge of #123548 - RalfJung:what-is-time, r=joboet REVERT: 14447a8c9c7 Auto merge of #123937 - RalfJung:miri-link-section, r=oli-obk REVERT: 443a6fbe62c Auto merge of #123851 - NobodyXu:patch-1, r=BurntSushi REVERT: 46ba3f29fe5 Update doc for std::io::Error::downcast REVERT: 21d618464fd Remove bound checks from `BorrowedBuf` and `BorrowedCursor` methods REVERT: 0d1488560ff disable create_dir_all_bare on all(miri, windows) REVERT: f83d4d8991d libtest: also measure time in Miri REVERT: 246b74db31a Auto merge of #123928 - tbu-:pr_statx_enosys, r=workingjubilee REVERT: ff1212e6a22 Add vec_deque::Iter::as_slices and friends REVERT: 5d4f65899c2 Rollup merge of #123915 - shenawy29:patch-1, r=Nilstrieb REVERT: b83291d60fc Rollup merge of #120900 - marcospb19:std-use-seek-stream-position, r=joshtriplett REVERT: e7822c77056 Miri: run .CRT$XLB linker section on thread-end REVERT: 65e3bdb3b05 `statx` probe: `ENOSYS` might come from a faulty FUSE driver REVERT: e4eafca2b1c Auto merge of #122268 - ChrisDenton:no-libc, r=Mark-Simulacrum REVERT: 931580539b0 improve documentation slightly regarding some pointer methods REVERT: 25f46638c83 Move msvc libs to core REVERT: 97543b75e3e Replace libc::c_int with core::ffi::c_int REVERT: 01fea39a003 Rollup merge of #123879 - beetrees:missing-unsafe, r=Mark-Simulacrum REVERT: b6684584739 Rollup merge of #123875 - Ghamza-Jd:master, r=joboet REVERT: 20551dbdc37 Rollup merge of #123779 - semarie:notgull-openbsd-socket, r=Mark-Simulacrum REVERT: 96e9022361a Rollup merge of #123651 - tgross35:thread-local-updates, r=Mark-Simulacrum REVERT: 5055f25b945 Auto merge of #107462 - WaffleLapkin:from_iterator_for_tuple, r=dtolnay REVERT: c4e56d60c18 Auto merge of #123819 - joboet:fmt_usize_marker, r=Mark-Simulacrum REVERT: 61b9833b435 Rollup merge of #123876 - dpaoliello:backtrace, r=ChrisDenton REVERT: aeb4efaa7f0 Rollup merge of #123716 - Kriskras99:patch-2, r=Mark-Simulacrum REVERT: 3cc56ecd90d doc note that f16 and f128 hardware support is limited REVERT: de405577055 Rollup merge of #123868 - eduardosm:stabilize-slice_ptr_len, r=jhpratt REVERT: ed296750a27 Rollup merge of #123835 - saethlin:vec-from-nonnull, r=the8472 REVERT: c1b11248200 Add missing `unsafe` to internal `std::thread::Thread` creation functions REVERT: 5cc2d7b9acc Add missing `unsafe` to internal function `std::sys::pal::unix::thread::min_stack_size` REVERT: f3c1c93e3b5 Update backtrace submodule REVERT: 99e9da1b47a chore: replace x with y for hexa-decimal fmt REVERT: 1f25e2afc2f Avoid more NonNull-raw-NonNull roundtrips in Vec REVERT: 4ad58e6171a Rollup merge of #123867 - eduardosm:unsafe-fns, r=ChrisDenton REVERT: 369308bd980 Rollup merge of #123858 - marijanp:fix-zkvm-cmath-path, r=joboet REVERT: 903bde7926c Rollup merge of #123857 - devnexen:tcp_listener_update_backlog, r=ChrisDenton REVERT: 84700836317 Rollup merge of #123807 - joboet:sys_common_thread, r=jhpratt REVERT: 504503f8b33 Stabilize (const_)slice_ptr_len and (const_)slice_ptr_is_empty_nonnull REVERT: 9d15f69e3aa Add `unsafe` to two functions with safety invariants REVERT: 587e00a6dc8 zkvm: remove cmath REVERT: 4eaade240e7 std::net: TcpListener shrinks the backlog argument to 32 for Haiku. REVERT: 3f6c217bd29 Rollup merge of #123852 - kamaboko123:fix_typo_in_std_lib_rs, r=lqd REVERT: 4b86af9b1eb Rollup merge of #123833 - dpaoliello:stdarch, r=Amanieu REVERT: d2a60a7f480 Rollup merge of #123825 - saethlin:report-nounwind-panics, r=petrochenkov REVERT: 588cc02933c Auto merge of #123846 - matthiaskrgr:rollup-85y28av, r=matthiaskrgr REVERT: 2fea2cdba1f Update document for std::io::Error::downcast REVERT: 9c18712a859 fix typo in library/std/src/lib.rs REVERT: e6af2ad4dc7 Rollup merge of #123842 - ShockYoungCHN:master, r=scottmcm REVERT: 5ae3a55f952 Rollup merge of #123830 - tgross35:f16-f128-from-inference-fix, r=Nilstrieb REVERT: 60b12568535 Auto merge of #123783 - tgross35:f16-f128-debug-impl, r=Amanieu REVERT: 973fc512315 core: get rid of `USIZE_MARKER` REVERT: f804284c2b6 Avoid panicking branch in `append_to_string` REVERT: 3089f51c1bd `VecDeque::read_to_string`: avoid making the slices contiguous REVERT: b015b3251fc Improve several `Read` implementations REVERT: df15a2a4848 Auto merge of #123490 - niluxv:strict_prov_unwind_seh, r=Amanieu REVERT: b7771f8b2ac fix pin.rs typo REVERT: ebe1b73420a Rollup merge of #123826 - kornelski:one-in-a-quintillion, r=Amanieu REVERT: 0e7d31535ea Auto merge of #120092 - zetanumbers:pin_in_static_allocator, r=Amanieu REVERT: ad02b597a23 Update stdarch submodule REVERT: 5a085ee65ac Remove `From` impls for unstable types that break inference REVERT: 476c07d5b2b Auto merge of #123823 - matthiaskrgr:rollup-8zdtggx, r=matthiaskrgr REVERT: 584cfabd699 Call the panic hook for non-unwind panics in proc-macros REVERT: 57b82a1de29 Move rare overflow error to a cold function REVERT: e4cc7157b87 Rollup merge of #123806 - joboet:advanced_overflow, r=Amanieu REVERT: f8b5999caea Rollup merge of #123798 - tniessen:patch-1, r=workingjubilee REVERT: 3bb7b59fa72 Rollup merge of #122882 - Zoxc:panic-output-panic, r=Amanieu REVERT: 721c0565871 Auto merge of #123814 - matthiaskrgr:rollup-lxn0t4t, r=matthiaskrgr REVERT: 9db1089cf77 Add a `Debug` impl and some basic functions to `f16` and `f128` REVERT: 59ee6acc9ce Refactor `panic_unwind/seh.rs` pointer use; x86 now conforms to strict-provenance REVERT: 3e1a0b58166 Stabilize `Seek::seek_relative` REVERT: 4486f025021 Auto merge of #123732 - a1phyr:io_error_factor, r=cuviper REVERT: 3ae78cd8a03 std: use queue-based `RwLock` on Windows 7 REVERT: 5a7a9cf9656 std: use queue-based `RwLock` on Xous REVERT: b934c75f308 std: use queue-based `RwLock` on SGX REVERT: 5159baabd27 std: remove `sys_common::thread` REVERT: 645f98611da core: panic on overflow in `BorrowedCursor` REVERT: e1a0f771178 Avoid invalid socket address in length calculation REVERT: 3e38e05a403 OpenBSD fix long socket addresses REVERT: a3543cf4e67 Factor some common `io::Error` constants REVERT: b7da755d5b1 Correct broken link in core::pin doc REVERT: 4b612346121 Rollup merge of #123756 - lukas-code:file-sync, r=jhpratt REVERT: e8df7df8695 Rollup merge of #123661 - tgross35:stabilize-cstr_count_bytes, r=dtolnay REVERT: f9483eaef8d Rollup merge of #123360 - adamgemmell:dev/adagem01/restricted-std, r=ehuss REVERT: 0f8750d008f Rollup merge of #122470 - tgross35:f16-f128-step4-libs-min, r=Amanieu REVERT: 72320443c24 clean up docs for `File::sync_*` REVERT: 88e034579ac Add primitive documentation for `f16` and `f128` REVERT: 17fd64487f8 Add basic f16 and f128 modules REVERT: 72ada931244 Add basic library support for `f16` and `f128` REVERT: e153272bc8d Revert "Put basic impls for f16 and f128 behind cfg(not(bootstrap))" REVERT: f756686892a Auto merge of #123725 - GuillaumeGomez:rollup-gk2bbrg, r=GuillaumeGomez REVERT: 9cb12b1ba8c Rollup merge of #123534 - ChrisDenton:name, r=workingjubilee REVERT: 4a3664831b6 visionOS: Fix unused import warning REVERT: 0e6a2681b82 Rework Path::ancestors documentation to remove unwraps REVERT: f309ec40a85 Auto merge of #122393 - a1phyr:specialize_read_buf_exact, r=joboet REVERT: 38dbe578257 Bring documentation of Path::to_path_buf in line with the rest of Path/PathBuf REVERT: ffdd870f709 Auto merge of #122812 - dtolnay:mode, r=workingjubilee REVERT: 1c86e9a0b24 Update documentation related to the recent cmd.exe fix REVERT: 390c15ab9e8 Rollup merge of #123633 - bjorn3:unsupported_command_data, r=jhpratt REVERT: 32d0cd7bbd2 Show mode_t as octal in std::fs Debug impls REVERT: 78ff007512a Add comment on UTF-16 surrogates REVERT: d3716a5bf26 Windows: set main thread name without reencoding REVERT: 3f90d4a49c3 Add const UTF-8 to UTF-16 conversion macros REVERT: f0a8f5992c3 Auto merge of #123683 - pietroalbini:pa-cve-2024-24576-nightly, r=pietroalbini REVERT: 9968366faf4 Auto merge of #123485 - madsmtm:use-libc-copyfile, r=joboet REVERT: cb50d664185 Fix dead code warning REVERT: ecda94da65a Rollup merge of #123665 - Jules-Bertholet:patch-1, r=lqd REVERT: 9618feb15f6 Rollup merge of #123254 - stepancheg:thin-box-0-const-alloc, r=oli-obk REVERT: 3e93dcf61fd Fix typo in `Future::poll()` docs REVERT: b5b840ecad8 Stabilize `cstr_count_bytes` REVERT: d1f3afbcfbf Document Windows argument splitting REVERT: a85d8fbb00b Disallow or quote all specials in bat args REVERT: 546a08e07a4 Change method calls to using the method directly REVERT: 85d08249eb6 Add `SAFETY` comments to the thread local implementation REVERT: 193fd0785f6 Update thread local docs with idiomatic cell type use REVERT: 3e9e417bf06 Rollup merge of #123564 - scottmcm:step-by-div-zero, r=joboet REVERT: ca69d3b9664 Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errors REVERT: 8586a2477df Store all args in the unsupported Command implementation REVERT: 322d51c6b11 Rollup merge of #123595 - balaganesh102004:master, r=joboet REVERT: 46ff2baf0e8 Rollup merge of #123089 - Philippe-Cholet:vecdeque_pop_assume_cap, r=Nilstrieb REVERT: 40fb3529438 Rollup merge of #115984 - hermit-os:fuse, r=m-ou-se REVERT: 77ffffa2475 Add pattern types to parser REVERT: 7fc440d5712 std: update abort message in `thread::set_current` REVERT: c40d63b5b18 Add invariant to VecDeque::pop_* that len < cap if pop successful REVERT: 0eefa942d27 Auto merge of #123506 - RalfJung:miri-test-libstd, r=Mark-Simulacrum REVERT: 587f7c3ccab Auto merge of #123597 - Gbd199:patch-1, r=jhpratt REVERT: f2f504e1ed0 Fix typo in library/core/src/iter/traits/iterator.rs REVERT: 66db9e349d4 Made changes in documentation REVERT: a7d8284ffcb Auto merge of #123592 - matthiaskrgr:rollup-3k1pq8s, r=matthiaskrgr REVERT: 5940c0f0e30 Auto merge of #123561 - saethlin:str-unchecked-sub-index, r=scottmcm REVERT: 51d06bc7b22 sys_common::thread_local_key: make a note that this is not used on Windows REVERT: bbac74560fd make a doctest less slow in Miri REVERT: 3403cab01ad also test parts of std REVERT: 7bed73e68a0 disable benches in Miri REVERT: e51b7f0d11c Rollup merge of #123522 - dtolnay:constatomicintoinner, r=Nilstrieb REVERT: dbeb4549cc5 Rollup merge of #123411 - saethlin:ub-checks, r=Urgau,RalfJung REVERT: 06f6271ddc8 Rollup merge of #119224 - Duckilicious:test_main_memory_leak, r=cuviper REVERT: 766b197fe01 Don't emit divide-by-zero panic paths in `StepBy::len` REVERT: cc2f0a0b90e Use unchecked_sub in str indexing REVERT: 113e4e53d0d Drop panic hook after running tests REVERT: de9c939acda Rollup merge of #123541 - RalfJung:remove-old-hacks, r=Mark-Simulacrum REVERT: 34834b4a53e Put checks that detect UB under their own flag below debug_assertions REVERT: 738544752b1 Rollup merge of #122291 - lilasta:stabilize_const_location_fields, r=dtolnay REVERT: e6d7439b2be Rollup merge of #114788 - tisonkun:get_mut_or_init, r=dtolnay REVERT: 7ed8c46403a remove miri-test-libstd hacks that are no longer needed REVERT: 2758dcc4d06 Rollup merge of #123528 - dtolnay:asyncgeninternals, r=compiler-errors REVERT: f51e34cb326 Hide async_gen_internals from standard library documentation REVERT: 5b6d1ccbe36 Auto merge of #123433 - GnomedDev:remove-threadname-alloc, r=joboet REVERT: abd6e09dafa Stabilize const Atomic*::into_inner REVERT: 5180b60f529 Rollup merge of #123505 - ChrisDenton:revert-121666, r=workingjubilee REVERT: 63033e77821 Rollup merge of #121419 - agg23:xrOS-pr, r=davidtwco REVERT: 4963cb80557 Do not allocate for ZST ThinBox attempt 2 (using const_allocate) REVERT: b1080b2e290 Auto merge of #123317 - RalfJung:test-in-miri, r=m-ou-se,saethlin,onur-ozkan REVERT: 2f47b32cea1 Revert #121666 REVERT: 854efdee0da macOS: Use `libc` definitions for copyfile REVERT: 0200bb5d6a1 Rollup merge of #123206 - stepancheg:pointee-metadata-freeze, r=Amanieu REVERT: 4e485f71a26 Remove rt::init allocation for thread name REVERT: 6a96e4cc8be Impl `DerefPure` for more std types REVERT: a447b4e70f1 Rollup merge of #123431 - slanterns:literal_byte_character_c_string_stabilize, r=dtolnay REVERT: 3376f7ff605 Rollup merge of #123389 - ChrisDenton:dont-panic-on-startup, r=joboet REVERT: 46efe037ca8 Add comments about using debug_assert REVERT: f46c50173be force exhaustion in iter::ArrayChunks::into_remainder REVERT: 415b95a272e Rollup merge of #122356 - devnexen:dfbsd_build_fix, r=jhpratt REVERT: 9731fdd8b9e Stabilize `Literal::c_string` REVERT: 1cbda637aa2 Stabilize `Literal::byte_character` REVERT: 0741fde021e Rollup merge of #122964 - joboet:pointer_expose, r=Amanieu REVERT: de6296dd8bf add 'x.py miri', and make it work for 'library/{core,alloc,std}' REVERT: 457ae7e43bb Add docs for `FromIterator<(AE, BE)> for (A, B)` REVERT: 769ce0f1123 Implement `FromIterator<(AE, BE)>` for `(impl Default+Extend, impl Default+Extend)` REVERT: 8c4df2f59f8 rename `expose_addr` to `expose_provenance` REVERT: 8486ade2668 std: add comment about abort motivation REVERT: 11c572a0ffc Auto merge of #123390 - tgross35:f16-f128-libs-basic-impls-bootstrap, r=jhpratt REVERT: 3586bdc4067 Rollup merge of #123388 - tshepang:consistency, r=jhpratt REVERT: f7c7c7c6c00 Rollup merge of #122411 - alexcrichton:wasm32-wasip2-cabi-realloc, r=m-ou-se REVERT: 4e8d1299809 Rollup merge of #123203 - jkarneges:context-ext, r=Amanieu REVERT: 3eaf7659f60 Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=Amanieu REVERT: 38cb21b0dd8 set tracking issue REVERT: 15795eeccd0 Auto merge of #123385 - matthiaskrgr:rollup-v69vjbn, r=matthiaskrgr REVERT: d9e1cac6a72 Put basic impls for f16 and f128 behind cfg(not(bootstrap)) REVERT: 39edbca03a4 Avoid panicking unnecessarily on startup REVERT: 71fefd9cf72 use a consistent style for links REVERT: 4dd5c267874 Rollup merge of #123226 - scottmcm:u32-shifts, r=WaffleLapkin REVERT: 49e00d775be Rollup merge of #123198 - krtab:build_hasher_default_const_new, r=Amanieu REVERT: c1824d1760a Auto merge of #118310 - scottmcm:three-way-compare, r=davidtwco REVERT: 08f761fb838 DOC: Add FFI example for slice::from_raw_parts() REVERT: 7b4580775aa Document restricted_std REVERT: 49c559d07e4 std: reduce code size of `set_current` REVERT: 697f9ec1a06 style: fmt REVERT: c3a76d51e31 fix: build on haiku by adding missing import REVERT: 9f0af96d7dd Auto merge of #122945 - andy-k:sorted-vec-example, r=jhpratt REVERT: 5dc90794c34 Rollup merge of #123323 - devnexen:thread_set_name_solaris_fix, r=workingjubilee REVERT: eb67e0d19d9 std::thread: set_name change for solaris/illumos. REVERT: 248dae8e519 Auto merge of #123315 - devnexen:thread_get_name_solaris, r=ChrisDenton REVERT: a5ac952e9d2 Auto merge of #123265 - joboet:guardians_of_the_unix, r=ChrisDenton REVERT: 33d26377406 update comment REVERT: 07d6bde0fed std::thread: adding get_name implementation for solaris/illumos. REVERT: 979c3657e75 Fix error message for `env!` when env var is not valid Unicode REVERT: 29c7487f353 Auto merge of #123270 - JaniM:janim/string-alloc-doc, r=workingjubilee REVERT: 0d1b4618249 doc: mention heap allocation earlier in String docs REVERT: a14153d85bf Auto merge of #123299 - workingjubilee:rollup-2z8amaj, r=workingjubilee REVERT: 89219c1acb4 Rollup merge of #123271 - JaniM:janim/sliceindex-doc, r=Nilstrieb REVERT: 6bffcfd95b4 Rollup merge of #123268 - RalfJung:dont-freeze, r=Nilstrieb REVERT: e9a72a6a9be warn against implementing Freeze REVERT: c9197ed1bbe std::thread: adding get_name haiku implementation. REVERT: 0920de9dd4c doc: describe panic conditions for SliceIndex implementations REVERT: 638a6a800d6 catch_panic: warn about panicking payload drop REVERT: 2b790b47905 std: move `thread::current` TLS variable out of `thread_info` REVERT: 72141b19dfc std: move UNIX stack overflow guard page handling into `stack_overflow.rs` REVERT: e08d065fa19 Auto merge of #123233 - devnexen:thread_get_name_bsd, r=joboet REVERT: ae3a200f9e4 Require Pointee::Metadata to be Freeze REVERT: 87c46030544 Auto merge of #123181 - stepancheg:pointee-metadata-debug, r=the8472,Amanieu REVERT: 5e0f25d32f6 Auto merge of #123085 - tgross35:f16-f128-step4.0-libs-basic-impls, r=Amanieu REVERT: 93869554cb6 Auto merge of #99322 - GKFX:const-int-parse, r=Mark-Simulacrum REVERT: d9e6e56d887 std::thread: adding freebsd/netbsd to the linux's get_name implementation. REVERT: 4df64828416 Rollup merge of #123201 - Wilfred:patch-2, r=Nilstrieb REVERT: 2f2e9839c6a Make {integer}::from_str_radix constant REVERT: 0485d6a6be9 De-LLVM the unchecked shifts [MCP#693] REVERT: a46e82446f7 Auto merge of #121948 - Gankra:stab-align, r=dtolnay REVERT: bd43b555835 Auto merge of #122976 - caibear:optimize_reserve_for_push, r=cuviper REVERT: e32adcd64a2 stabilize ptr.is_aligned, move ptr.is_aligned_to to a new feature gate REVERT: 0421b4adfe3 Auto merge of #122520 - scottmcm:stabilize_unchecked_math_basics, r=jhpratt REVERT: 1a8eb39cbb1 rustfmt REVERT: f732282ad1f Auto merge of #121268 - Urgau:improve_ambi_wide_ptr_cmps, r=Nadrieril REVERT: f01260015ea Add `Context::ext` REVERT: 8c225c06c24 Improve wording in std::any explanation REVERT: 0a72d121f0c Add fn const BuildHasherDefault::new REVERT: 1721d80e6e4 Add detection of [Partial]Ord methods to the ambiguous wide ptr cmp lint REVERT: 834687c40a5 Add diagnostic items for Ord and PartialOrd methods REVERT: c7dbd2750cd Auto merge of #122616 - Jules-Bertholet:casemappingiter-layout, r=Nilstrieb REVERT: 060fa678c2f Require Debug for Pointee::Metadata REVERT: e9af8b05c9a Auto merge of #122975 - DianQK:simplify_ub_check, r=saethlin REVERT: f1695e54eaa Auto merge of #122671 - Mark-Simulacrum:const-panic-msg, r=Nilstrieb REVERT: aee40df0050 Rename reserve_for_push to grow_one and fix comment. REVERT: 10fa6ea3565 Fix previous. REVERT: 96cbf807c24 Remove len argument from RawVec::reserve_for_push because it's always equal to capacity. Also make Vec::insert use reserve_for_push. REVERT: 6a62aeb7465 Add basic trait impls for `f16` and `f128` REVERT: 8145779f8a2 Rollup merge of #123164 - Marcondiro:unicode15-1, r=Manishearth REVERT: 6e3f1b79e3a Bump Unicode printables to version 15.1, align to unicode_data REVERT: 68bbf064838 Rollup merge of #123139 - scottmcm:simpler-nonzero-get, r=jhpratt REVERT: 67af00952c5 Rollup merge of #123136 - Vagelis-Prokopiou:fix/docs, r=ChrisDenton REVERT: 78561cce61f Rollup merge of #123133 - xiaoxiangxianzi:master, r=fmease REVERT: dca5842e32d Rollup merge of #121943 - joshlf:patch-11, r=scottmcm REVERT: 59d11980a63 `num::NonZero::get` can be 1 transmute instead of 3 REVERT: 2700969f641 Less generic code for Vec allocations REVERT: 927ab559750 Some wording improvement REVERT: 79d3fd45d2e chore: fix some comments REVERT: 5422044d734 Eliminate `UbCheck` for non-standard libraries REVERT: 3c6111e1175 Auto merge of #123128 - GuillaumeGomez:rollup-3l3zu6s, r=GuillaumeGomez REVERT: 66911604656 Rollup merge of #123083 - klensy:clippy-me, r=workingjubilee REVERT: 5c2b09604d7 impl get_mut_or_init and get_mut_or_try_init for OnceCell and OnceLock REVERT: 7114443cf67 Auto merge of #116016 - jhpratt:kill-rustc-serialize, r=ehuss REVERT: 78f45f37b51 Rollup merge of #123118 - tgross35:rwlock-docs, r=workingjubilee REVERT: a8de319911a Rollup merge of #123107 - avandesa:vec_pop_if, r=joboet REVERT: 064e82268d7 Rollup merge of #123084 - a1phyr:unixstream_read_buf, r=workingjubilee REVERT: 3e10c57aa65 Rollup merge of #123038 - he32:netbsd-ilp32-fix, r=workingjubilee REVERT: 68bb0c30f28 Rollup merge of #122880 - a1phyr:preadv_more_platform, r=workingjubilee REVERT: c876c6525dd Update `RwLock` deadlock example to not use shadowing REVERT: e34fa149934 Implement `Vec::pop_if` REVERT: e34c7e541c5 Rollup merge of #123057 - sthibaul:systemtime, r=jhpratt REVERT: dad57648f3d Rollup merge of #122835 - compiler-errors:deref-pure, r=Nadrieril REVERT: 5c7c3184650 Rollup merge of #123086 - ding-young:fix-ref-to-BufWriter, r=the8472 REVERT: a5b01cbae73 unix fs: Make hurd and horizon using explicit new rather than From REVERT: d8f1379abc3 Auto merge of #122939 - joboet:proc_macro_bridge_state, r=petrochenkov REVERT: f406df2bb28 Unix: Support more platforms with `preadv` and `pwritev` REVERT: 491d87104fc `UnixStream`: override `read_buf` REVERT: ce33622010d Fix link to BufWriter REVERT: edfdbe23dd7 std library unix/thread.rs: fix NetBSD code for ILP32 CPUs. REVERT: e7e3e1b9d0a panic_str only exists for the migration to 2021 panic macros REVERT: b626fd5085c Extract helper, fix comment on DerefPure REVERT: 4185df282bc Require DerefPure for patterns REVERT: af786093e00 Rollup merge of #123042 - dpaoliello:prelude, r=Nilstrieb REVERT: 1bdf4ecb4c5 Rollup merge of #122896 - dpaoliello:stdarch, r=Amanieu REVERT: 25260fa10d4 Rollup merge of #122707 - reedwoodruff:string_docs_typo, r=workingjubilee REVERT: 0e62a1aa862 lib: fix some unnecessary_cast clippy lint REVERT: 24376b2aa43 Import the 2021 prelude in the core crate REVERT: 78f0dbb1adc alloc::Layout: explicitly document size invariant on the type level REVERT: 7b75def6138 Rollup merge of #122990 - SkiFire13:transmute-may-copy, r=jhpratt REVERT: 6bbd18a41c7 Address PR feedback REVERT: f90e0a998d3 Amended wording REVERT: 2f023449c40 Slightly simplify the `iN::partial_cmp` MIR REVERT: 9e8ceea5e9d Rollup merge of #122992 - devnexen:available_parallelism_sol_upd, r=Amanieu REVERT: 5287647bfc6 Rollup merge of #122984 - RalfJung:panic-in-hook, r=Amanieu REVERT: 1888f00cc1f Rollup merge of #122983 - taiki-e:bsd, r=workingjubilee REVERT: 31e4f2868df Rollup merge of #122977 - cuviper:as_statically_known_str, r=RalfJung REVERT: 05ae283da3b fix build. REVERT: 0b32d628b97 std::thread: refine available_parallelism for solaris/illumos. REVERT: e954f8c7e48 Clarify transmute example REVERT: 7f0a4b6ae8b panic-in-panic-hook: formatting a message that's just a string is risk-free REVERT: e25599af462 Fix build failure on ARM/AArch64/PowerPC/RISC-V FreeBSD/NetBSD REVERT: a64212d610c Add+Use `mir::BinOp::Cmp` REVERT: 0d29868fd91 Rollup merge of #122797 - alexcrichton:fix-compile-wasm64, r=Mark-Simulacrum REVERT: 78b1cea41b1 Rollup merge of #122762 - RoboSchmied:RoboSchmied-typo, r=workingjubilee REVERT: 6c5a3d53336 Rollup merge of #120419 - Ayush1325:uefi-sys-os, r=nicholasbishop,workingjubilee REVERT: 36e2b555a98 Rename `Arguments::as_const_str` to `as_statically_known_str` REVERT: beee5246d44 Auto merge of #122966 - matthiaskrgr:rollup-20k8nsm, r=matthiaskrgr REVERT: 31e93b3a6f4 clarify equivalency of binary_search and partition_point REVERT: 8ba3c19ef23 Rollup merge of #122963 - RalfJung:core-panicking, r=m-ou-se REVERT: 2dac79d27c3 Rollup merge of #122379 - RalfJung:int2ptr-transmute, r=m-ou-se REVERT: 5e5f3084b5e Auto merge of #122905 - dpaoliello:sync-portable-simd-2024-03-22, r=workingjubilee REVERT: 342da6700ac Fixed builds with modified libc REVERT: 3eda213e527 also rename the SIMD intrinsic REVERT: 895d1b89e72 Auto merge of #122629 - RalfJung:assert-unsafe-precondition, r=saethlin REVERT: 6a618a18004 core/panicking: fix outdated comment REVERT: e938deaf0f1 try adding a test that LowerHex and friends don't panic, but it doesn't work REVERT: 3263ad86c5c refactor check_{lang,library}_ub: use a single intrinsic, put policy into library REVERT: c629e7a93f8 move assert_unsafe_preconditions to its own file REVERT: 5d48a0357a6 Auto merge of #122947 - matthiaskrgr:rollup-10j7orh, r=matthiaskrgr REVERT: f44d047f888 Rollup merge of #122931 - herobs:patch-1, r=joboet REVERT: 0d1cab9d2b5 Rollup merge of #122930 - RalfJung:panic-in-panic-fmt, r=Amanieu REVERT: 953c42c2d58 Rollup merge of #122916 - MultisampledNight:docs-sync-typo, r=jhpratt REVERT: 7d5b8a25657 Rollup merge of #120577 - wutchzone:slice_split_at_unchecked, r=m-ou-se REVERT: 41ccb132f38 Auto merge of #122582 - scottmcm:swap-intrinsic-v2, r=oli-obk REVERT: 2704e90a581 improve example on inserting to a sorted vector to avoid shifting equal elements REVERT: 16022f9265f rename ptr::from_exposed_addr -> ptr::with_exposed_provenance REVERT: 6dbc32b295b proc_macro: simplify bridge state REVERT: a9d12dd1a9f Fix some typos in the pin.rs REVERT: f3dcd4a742d add panic location to 'panicked while processing panic' REVERT: 1c643468730 Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlin REVERT: 3b67ff0cb3e Merge commit 'cff979eec1ac0473fc4960ee6cde462c6aeda824' into sync-portable-simd-2024-03-22 REVERT: 443c645f4b3 docs(sync): normalize dot in fn summaries REVERT: fc539821467 Remove RustcEncodable/Decodable from 2024 prelude REVERT: ca0e3c3ae1a Soft-destabilize `RustcEncodable`/`RustcDecodable` REVERT: 953ea0a1e58 Update stdarch submodule REVERT: 0f7c3b3e7d6 `swap_simple` no longer needs to be a separate function REVERT: 50d95d93b0c Avoid a panic in `set_output_capture` in the default panic handler REVERT: 280bc7d82ad Codegen const panic messages as function calls REVERT: 241ba61f377 Rollup merge of #122800 - zachs18:nonnull-slice-is_empty, r=Amanieu REVERT: 5951b094c2e Auto merge of #122024 - clubby789:remove-spec-option-pe, r=jhpratt REVERT: 22221dbd7eb Rollup merge of #122829 - ShoyuVanilla:gen-block-impl-fused-iter, r=compiler-errors REVERT: 571bfda2b71 Rollup merge of #122817 - ultrabear:ultrabear_btreedoc, r=Nilstrieb REVERT: 132e16f4845 Rollup merge of #121881 - devnexen:bsd_acceptfilter, r=Amanieu REVERT: 27602fcc7db Not insta-stable REVERT: 94a08264b99 Auto merge of #122785 - the8472:const-select-specialized-impl, r=Amanieu REVERT: 1d8ba1b31b2 Implement `FusedIterator` for `gen` block REVERT: ed109e1fff2 Implement macro-based deref!() syntax for deref patterns REVERT: 8fcb41ef166 Stabilize `const_caller_location` and `const_location_fields` REVERT: 88ef094e9fe Rollup merge of #122806 - compiler-errors:type-ascribe, r=fmease REVERT: 03a162c1261 document into_iter in top level docs iterator ordering guarantees REVERT: add175b3da4 document iteration ordering on into_iter method instead of IntoIterator implementation REVERT: 2c758f0ae42 BTree(Set|Map): Guarantee that `IntoIter` will iterate in sorted by key order REVERT: 21485563d80 Make type_ascribe! not a built-in REVERT: d8fbe999932 Rollup merge of #122765 - workingjubilee:test-for-vec-handling-usize-max, r=Nilstrieb REVERT: 9e601f1b8b3 Rollup merge of #122729 - m-ou-se:relax, r=Amanieu REVERT: d9e295f1ab4 Add `NonNull::<[T]>::is_empty` as insta-stable. REVERT: cccb5088d79 Fix compile of wasm64-unknown-unknown target REVERT: 2c474d83a04 Auto merge of #122761 - jwong101:fix/vec-insert, r=workingjubilee,Nilstrieb REVERT: 3d4d0641c3e select Vec::from_iter impls in a const block to optimize compile times REVERT: a2ed0d196d4 std::net: adding acceptfilter feature for netbsd/freebsd. REVERT: 8e9f027dbe7 Update target.rs alloc.rs event.rs simd.rs REVERT: a443b96c9d7 SeqCst->Relaxed in condvar test. REVERT: d261e3cee8a SeqCst->Relaxed in thread local test. REVERT: 514fd74ab40 SeqCst->Relaxed in std::net::test. REVERT: 2e96b9bfb7a Use less restricted memory ordering in xous::thread_local_key. REVERT: dd7927a2d29 Auto merge of #122754 - Mark-Simulacrum:bootstrap-bump, r=albertlarsan68 REVERT: 62fb165c1b8 step cfgs REVERT: f8ec29cd69f Auto merge of #120717 - compiler-errors:cap-closure-kind, r=oli-obk REVERT: c6d2bb7445c improve codegen of fmt_num to delete unreachable panic REVERT: 6d8be786ce3 Add usize::MAX arg tests for Vec REVERT: db8c896be2f Rollup merge of #122739 - Sky9x:insert-put, r=jhpratt REVERT: 6adcb2c7add Rollup merge of #122730 - ferrocene:hoverbear/qnx-ucred-cfgs, r=Amanieu REVERT: ac8de22c9f0 Rollup merge of #121543 - onur-ozkan:clippy-args, r=oli-obk REVERT: 16e3fdef4ae fix OOB pointer formed in Vec::index REVERT: 5fefabbe6d2 branch 1.78: replace-version-placeholder REVERT: 0bdf2a8ac26 resolve clippy errors REVERT: 96d7f0c54db Only split by-ref/by-move futures for async closures REVERT: b31660cd246 Add "put" as a confusable for insert on hash map/set REVERT: 66b9f792315 Rollup merge of #122720 - heisen-li:offset_of, r=workingjubilee REVERT: 109470d3d8d Manually implement `PartialOrd`/`Ord` for `Option` REVERT: 82edda8ed6c Remove `SpecOptionPartialEq` REVERT: 1e803f2dc70 Expose ucred::peer_cred on QNX targets to enable dist builds REVERT: 2b29c96699d SeqCst->Relaxed for xous set_nonblocking. REVERT: f88a7963c55 SeqCst->{Release,Acquire} for xous DropLock. REVERT: 9abd38f174a SeqCst->Relaxed in pal::windows::pipe. REVERT: 9820ffeccef SeqCst->{Release,Acquire} for wasm DropLock. REVERT: f2380b3b3e1 SeqCst->{Release,Acquire} in sys_common::thread_local_key. REVERT: b5d0406a05c Use less restricted memory ordering in thread_parking::pthread. REVERT: 885af3702ad SeqCst->{Release,Acquire} in xous mutex. REVERT: ef4e684a7f7 SeqCst->Relaxed for FIRST_PANIC. REVERT: 21eb9e2ee01 SeqCst->{Release,Acquire} for alloc error hook. REVERT: 3e7a35ef902 SeqCst->Relaxed for proc_macro bridge counter. REVERT: bc52b591580 SeqCst->Relaxed in panic_unwind/emcc. REVERT: 4c7e127f4ea SeqCst->Relaxed in doc examples. REVERT: df612829d85 [doc]:fix error code example REVERT: c695d1bf63d Make ptr_guaranteed_cmp a rustc_intrinsic and favor its body over backends implementing it REVERT: e2f11bcf3c0 Make `vtable_align` a rustc_intrinsic REVERT: 1eb203d957b Make `const_eval_select` a rustc_intrinsic REVERT: ac3846bcacf add notes on how to store 'ptr or int' REVERT: 3db94e8645b Support for visionOS REVERT: ac5ae5d5990 Reimplement `CaseMappingIter` with `core::array::IntoIter` REVERT: b6679c0558e Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obk REVERT: 68f41577d69 Rollup merge of #122675 - tmfink:doc-clarify, r=scottmcm REVERT: 638f0a8bb85 Rollup merge of #122642 - pallix:improve-wording-for-vec-swap_remove, r=Amanieu REVERT: ef35b91b783 Fix a typo in the alloc::string::String docs REVERT: 5091bd7760f remove retag_box_to_raw, it is no longer needed REVERT: 4650a14f02a add_retag: ensure box-to-raw-ptr casts are preserved for Miri REVERT: 698c6d9c530 Let codegen decide when to `mem::swap` with immediates REVERT: 1d3d348859f Improve wording of `Vec::swap_remove` REVERT: 56f8bfc19a9 Expand sys/os for UEFI REVERT: d03788e007b chore(121952): echo comments on the `*_assign` methods REVERT: 4a4b268f69d chore(121952): remove redundant comments REVERT: d7a48470e99 feat: implement `{Div,Rem}Assign>` on `X` REVERT: 8e0f8666369 Rollup merge of #119411 - yotamofek:array-ptr-get, r=Nilstrieb REVERT: 99363a1d9f2 core: document default attribute stabilization REVERT: c4ae972a056 Optimize `core::char::CaseMappingIter` layout REVERT: 4c7bb8d5f0d Auto merge of #121885 - reitermarkus:generic-nonzero-inner, r=oli-obk,wesleywiser REVERT: f4c6e2f8380 Rollup merge of #122601 - joboet:ptr_replace, r=workingjubilee REVERT: 056c6965e47 Add as_(mut_)ptr and as_(mut_)slice to raw array pointers REVERT: 25c29d18ea3 Rollup merge of #122583 - Zoxc:tls-non-mut, r=joboet REVERT: ad38304cf28 Rollup merge of #122390 - ChrisDenton:bindgen, r=Mark-Simulacrum REVERT: 21f66a1d693 core: optimize `ptr::replace` REVERT: 559a10436c9 Use `UnsafeCell` for fast constant thread locals REVERT: 5be79977acd Rollup merge of #122562 - Wilfred:break_keyword_docs, r=workingjubilee REVERT: 19aa96cfde2 Workaround issue 122566 REVERT: d1623e9912d Mention labelled blocks in `break` docs REVERT: a71c75e30e9 Rollup merge of #122512 - baitcode:2024-03-14-buffer-documentation-fix, r=Nilstrieb REVERT: 26b22f30d47 Stabilize `unchecked_{add,sub,mul}` REVERT: b2112250f70 Auto merge of #122511 - matthiaskrgr:rollup-swzilin, r=matthiaskrgr REVERT: 8b661702d9f Use rust-lang/backtrace-rs@6fa4b85 REVERT: ed30c0114aa Rollup merge of #122498 - jfgoog:update-cc-crate-version, r=workingjubilee REVERT: 8f043860be1 Rollup merge of #122479 - GrigorenkoPV:duration_millis_float, r=scottmcm REVERT: d7b90d860d0 Rollup merge of #121650 - GrigorenkoPV:cap_setgid, r=Amanieu REVERT: b3d55625c6e Fix minor documentation issue. Code outside the test would fail. Seek documentation clearly states that negative indexes will cause error. Just making the code in the example to return Result::Ok, instead of Result::Error. REVERT: c640d978655 Update version of cc crate REVERT: 14035d07a36 Hide implementation details for `NonZero` auto traits. REVERT: d1f5e673fe7 Rollup merge of #119029 - dylni:avoid-closing-invalid-handles, r=ChrisDenton REVERT: f92b0d91c2f Implement ptr_as_ref_unchecked (#122034) REVERT: 9338daeca7f Auto merge of #122483 - matthiaskrgr:rollup-n07dsh5, r=matthiaskrgr REVERT: 2cdbd5b05a4 Rollup merge of #122461 - the8472:fix-step-forward-unchecked, r=Amanieu REVERT: 2ae6fb6e788 Rollup merge of #122421 - CAD97:step-trait-docs, r=jhpratt REVERT: fde38c8e684 Rollup merge of #104353 - clarfonthey:cstr-bytes-iter, r=cuviper REVERT: 9ab7ca4225d Auto merge of #114038 - Stargateur:108277, r=ChrisDenton REVERT: 76efb6428b4 fix unsoundness in Step::forward_unchecked for signed integers REVERT: 11b745fbc6b Implement `Duration::as_millis_{f64,f32}` REVERT: e1d5cafe3e1 Provide `cabi_realloc` on `wasm32-wasip2` by default REVERT: 4be2029c1b2 Get wasm32-wasip2 compiling with its custom pal implementation REVERT: db8c957760e Rollup merge of #122386 - joboet:move_pal_once, r=jhpratt REVERT: 557b190f526 Rollup merge of #122255 - Nadrieril:min_exh_pats-libs, r=scottmcm REVERT: 4900722b75d Improve Step docs REVERT: d7df67f55e7 Reduce unsafe code, use more NonNull APIs per @cuviper review REVERT: dedeeb09a13 Specialize many implementations of `Read::read_buf_exact` REVERT: 354df78141b transmute: caution against int2ptr transmutation REVERT: 74989423f11 Convert [u8] to [i8] in test REVERT: 323195a7360 Bump windows-bindgen to 0.55.0 REVERT: 2f04875c49d Bump windows-bindgen to 0.54.0 REVERT: 94050f85a72 std: move `Once` implementations to `sys` REVERT: 4e4ed209c02 Fix typo in lib.rs of proc_macro REVERT: ee32b661639 Allow dead code in sys/pal REVERT: 7fe24bd817c Allow dead code in thread local dtor REVERT: 02233db5f26 Remove unused fields in some structures REVERT: b9e42937190 Use `min_exhaustive_patterns` in core & std REVERT: 8a8d19da9ce std::rand: fix dragonflybsd after #121942. REVERT: b46f839cfed Auto merge of #122036 - alexcrichton:test-wasm-with-wasi, r=oli-obk REVERT: 8e39145af44 libtest: Print timing information on WASI REVERT: ad161738d1d Rollup merge of #121438 - coolreader18:wasm32-panic-unwind, r=cuviper REVERT: 5ec2f2cfaa6 Auto merge of #122331 - jhpratt:rollup-cbl8xsy, r=jhpratt REVERT: dc5de3d4f6d Rollup merge of #122326 - Zoxc:win-alloc-tweak, r=ChrisDenton REVERT: e694713ce82 Rollup merge of #122298 - RalfJung:raw-vec-into-box, r=cuviper REVERT: 9562390bc25 Rollup merge of #122002 - devnexen:thread_stack_netbsd_fix, r=workingjubilee,riastradh REVERT: 33c34eadeb1 Rollup merge of #121840 - oli-obk:freeze, r=dtolnay REVERT: aa105513771 Rollup merge of #121633 - ChrisDenton:precise, r=Nilstrieb REVERT: 71feb9bc03d Rollup merge of #121148 - clarfonthey:try-range, r=dtolnay REVERT: 74e83551126 Auto merge of #117156 - jmillikin:os-unix-socket-ext, r=Amanieu,dtolnay REVERT: 8d989141cd1 Optimize `process_heap_alloc` REVERT: 534708e729a Auto merge of #122312 - matthiaskrgr:rollup-0p8y7gg, r=matthiaskrgr REVERT: 7efbdd34d68 Rollup merge of #122302 - ratmice:issue122234, r=cuviper REVERT: 5a0a01871c7 Rollup merge of #122277 - RalfJung:BorrowedCursor, r=cuviper REVERT: 944c6402aaf Rollup merge of #122276 - RalfJung:io-read, r=Nilstrieb REVERT: 9141a657b4e Rollup merge of #122275 - RalfJung:std-oom, r=workingjubilee REVERT: 86e9b7020c2 Add CStr::bytes iterator REVERT: 9119a88daf2 Update backtrace submodule to 0.3.70 REVERT: 2a351437c48 docs: Correct ptr/ref verbiage in SliceIndex docs. REVERT: 4e59924d77a RawVec::into_box: avoid unnecessary intermediate reference REVERT: 2c75bb56f31 Fix lint. REVERT: 69f2909f5ae Move generic `NonZero` `rustc_layout_scalar_valid_range_start` attribute to inner type. REVERT: 17eea62ffb3 Rollup merge of #122271 - pitaj:diag_items-legacy_numeric_constants, r=Nilstrieb REVERT: 162704ab5f6 Rollup merge of #122244 - tvallotton:local_waker_leak_fix, r=Nilstrieb REVERT: 4c111ae9601 Rollup merge of #121942 - devnexen:getrandom_for_dfbsd, r=joboet REVERT: b7f02800408 Rollup merge of #113525 - workingjubilee:handle-dynamic-minsigstksz, r=m-ou-se REVERT: df1d279a07e Rollup merge of #112136 - clarfonthey:ffi-c_str, r=cuviper REVERT: 0cbacab3627 BorrowedCursor docs clarification REVERT: 2786853ff7a io::Read trait: make it more clear when we are adressing implementations vs callers REVERT: 1a6ecbb621b disable OOM test in Miri REVERT: a4b58b3297b fix legacy numeric constant diag items REVERT: e53abfcc702 Auto merge of #121662 - saethlin:precondition-unification, r=RalfJung REVERT: 7e2f02fb3bf Rollup merge of #121711 - ChrisDenton:junction, r=Mark-Simulacrum REVERT: 3c283ef826d Rollup merge of #121403 - kornelski:io-oom, r=dtolnay REVERT: d1870b35d6f Rollup merge of #121280 - ajwock:maybeuninit_fill, r=Amanieu REVERT: 78ff5504850 Rollup merge of #120504 - kornelski:try_with_capacity, r=Amanieu REVERT: e4e154f005c Rollup merge of #114655 - nbdd0121:io-safety, r=dtolnay REVERT: b9564b7e64d Rollup merge of #99153 - Dajamante:issue/95622, r=dtolnay REVERT: c2819a68666 Explain why we don't use intrinsics::is_nonoverlapping REVERT: 234116791f9 fix: remove memory leak due to missing drop implementation for local waker. Also, fix some of the stability attributes of LocalWaker's methods. REVERT: 3d513599c30 NonZero::from_mut_unchecked is library UB REVERT: 8a43d9ffa52 Avoid closing invalid handles REVERT: 6694cf026d7 Improve docs REVERT: c96bcc6ea4a Rollup merge of #122233 - RalfJung:custom-alloc-box, r=oli-obk REVERT: 3742d27544a Rollup merge of #122232 - RalfJung:misc, r=jhpratt REVERT: f53243880b4 Rollup merge of #121358 - GnomedDev:lower-align-typeid, r=Mark-Simulacrum REVERT: 6cd34e99b17 miri: do not apply aliasing restrictions to Box with custom allocator REVERT: b9e8877d692 fn is_align_to: move some comments closer to the cast they refer to REVERT: bb2f536f8c9 fix warning when building libcore for Miri REVERT: 056a9991346 Auto merge of #122095 - lukas-code:windows-shutdown-test, r=ChrisDenton REVERT: 35a151585c9 Distinguish between library and lang UB in assert_unsafe_precondition REVERT: 3e295db7505 further changes from feedback REVERT: e0fca7a80a3 Stabilize associated type bounds REVERT: 54c23e64bcf Rollup merge of #121201 - RalfJung:align_offset_contract, r=cuviper REVERT: 0e014c39087 Document overrides of `clone_from()` REVERT: 7e3a3db7a2d align_offset, align_to: no longer allow implementations to spuriously fail to align REVERT: 1e24803b17b Rollup merge of #122099 - Urgau:btreemap-inline-new, r=Amanieu REVERT: db0a06ed8c1 Rollup merge of #121938 - blyxxyz:quadratic-vectored-write, r=Amanieu REVERT: 32f69cfacac Rollup merge of #120608 - kornelski:slice-ptr-doc, r=cuviper REVERT: fc3c23c7ff0 Rollup merge of #118623 - haydonryan:master, r=workingjubilee REVERT: 4e62f99c5fc Auto merge of #122059 - nyurik:with-as-const-str, r=cuviper REVERT: cc5780c21cb Rollup merge of #122147 - kadiwa4:private_impl_mods, r=workingjubilee REVERT: 574a6bf4991 Rollup merge of #119888 - weiznich:stablize_diagnostic_namespace, r=compiler-errors REVERT: 65325da7119 make `std::os::unix::ucred` module private REVERT: 4161077f383 Rust is a proper name: rust → Rust REVERT: e5ab074b006 Auto merge of #122113 - matthiaskrgr:rollup-5d1jnwi, r=matthiaskrgr REVERT: cecc9528316 Rollup merge of #122088 - ChrisDenton:fixme, r=workingjubilee REVERT: 6f45029d2d4 Rollup merge of #122072 - KonradHoeffner:patch-1, r=cuviper REVERT: c156a81d9f1 Rollup merge of #122091 - ChrisDenton:comment, r=RalfJung REVERT: 1beba1ff75b Rollup merge of #122074 - KonradHoeffner:patch-2, r=jhpratt REVERT: 05671749e6e Rollup merge of #113518 - jyn514:streaming-failures, r=cuviper REVERT: 95530d87780 Document and test minimal stack size on Windows REVERT: 7045d043274 Add #[inline] to BTreeMap::new constructor REVERT: 71b8e46e973 Dynamically size sigaltstk in std REVERT: 5ba3f952024 fix `close_read_wakes_up` test REVERT: 7a5dfd7ea25 Note why we're using a new thread in a test REVERT: a7303b9d034 Remove unnecessary fixme REVERT: 30c876cbfb4 Be stricter with `copy_file_range` probe results REVERT: 3b7d1c3b79d Auto merge of #121956 - ChrisDenton:srwlock, r=joboet REVERT: fe052461e10 Less syscalls for the `copy_file_range` probe REVERT: 0999f9ca37f add missing PartialOrd impl doc for array REVERT: 2feba531613 Refer to "slice" instead of "vector" in Ord and PartialOrd trait impl of slice REVERT: 5547994c6d8 unix time module now return result REVERT: 73614f56775 Optimize write with as_const_str for shorter code REVERT: a27191d7e08 Rollup merge of #122018 - RalfJung:box-custom-alloc, r=oli-obk REVERT: 2dcbff18228 Rollup merge of #122016 - RalfJung:will_wake, r=dtolnay REVERT: 6b690c8a1ca Rollup merge of #121894 - RalfJung:const_eval_select, r=oli-obk REVERT: 4062b5df853 Rollup merge of #121065 - CAD97:display-i18n, r=cuviper REVERT: ebe605b6281 Add `Waitable` trait REVERT: 1252cd1bdd4 Implement MaybeUninit::fill{,_with,_from} REVERT: 94f6ed4f7cf Auto merge of #121428 - okaneco:ipaddr_parse, r=cuviper REVERT: e3e1ea49a8e only set noalias on Box with the global allocator REVERT: 04b0f470549 Auto merge of #121138 - Swatinem:grapheme-extend-ascii, r=cuviper REVERT: 75950eea9bc will_wake tests fail on Miri and that is expected REVERT: eb10acd1995 Auto merge of #122012 - matthiaskrgr:rollup-bzqjj2n, r=matthiaskrgr REVERT: 74b6933fb78 Rollup merge of #121826 - estebank:e0277-root-obligation-2, r=oli-obk REVERT: dfaeba0b8fd Rollup merge of #121287 - zachs18:rc-into-raw-must-use, r=cuviper REVERT: b30787b5753 Rollup merge of #121262 - 20jasper:add-vector-time-complexity, r=cuviper REVERT: 8750e154492 Rollup merge of #121213 - Takashiidobe:takashi/example-for-rc-into-inner, r=cuviper REVERT: 6d82806d5aa Auto merge of #121001 - nyurik:optimize-core-fmt, r=cuviper REVERT: 7bd13c02f4e libtest: Print the names of failed tests eagerly REVERT: 37ab9325a34 doc wording improvements REVERT: 6cd0c832f5a Explain use of display adapters REVERT: f0ade3422bf Windows: Implement mutex using futex REVERT: 3074f38431f Auto merge of #120675 - oli-obk:intrinsics3.0, r=pnkfelix REVERT: 69feac983fe Add benches for `net` parsing REVERT: 750d9b86077 net: Add branch to Parser::read_number for parsing without checked arithmetic REVERT: 4f1d6909390 std::threads: revisit stack address calculation on netbsd. REVERT: b37daadabd1 Rollup merge of #121977 - Lee-Janggun:master, r=WaffleLapkin REVERT: 88755c2dd19 Rollup merge of #121968 - roblabla:fix-win7, r=jhpratt REVERT: 6d0bb984f0d Rollup merge of #121939 - jonaspleyer:patch-typo-core-From-descr, r=workingjubilee REVERT: b1bc3e02054 Rollup merge of #121732 - Voultapher:improve-assert_matches-documentation, r=cuviper REVERT: e2937799f4c Rollup merge of #120976 - matthiaskrgr:constify_TL_statics, r=lcnr REVERT: 8430ecb7cf8 Add a scheme for moving away from `extern "rust-intrinsic"` entirely REVERT: 35e5a9cd9c1 Fix comment in Atomic{Ptr,Bool}::as_ptr. REVERT: e5b40ab7c81 include feedback from workingjubilee REVERT: 0e324c7ea87 Don't run test_get_os_named_thread on win7 REVERT: 3e797a33e0f Rollup merge of #121935 - RalfJung:ptr-without-prov, r=scottmcm REVERT: 660ab6244e1 Be more lax in `.into_iter()` suggestion when encountering `Iterator` methods on non-`Iterator` REVERT: e2361fb075d Use root obligation on E0277 for some cases REVERT: 04e9e6ada64 Update library/core/src/sync/atomic.rs REVERT: 668172d3171 Update library/core/src/sync/atomic.rs REVERT: 0afa385a5ff Use "size and alignment" rather than layout REVERT: 1ccd5577f5e Document AtomicPtr bit validity REVERT: 06da8d4c095 Clarify bit validity for AtomicBool REVERT: b1112959f9f Clarify atomic bit validity REVERT: 089e493103d std::rand: enable getrandom for dragonflybsd too. REVERT: 1c045731790 Apply suggestions from code review REVERT: c635e33f9fb Small enhancement to description of From trait REVERT: 865604687f0 Fix quadratic behavior of repeated vectored writes REVERT: 3572d5763f3 library/ptr: mention that ptr::without_provenance is equivalent to deriving from the null ptr REVERT: 6ed2af125db Add missing get_name for wasm::thread. REVERT: 6ea387bcf42 Auto merge of #121856 - ChrisDenton:abort, r=joboet REVERT: 2619acdba77 Auto merge of #121914 - Nadrieril:rollup-ol98ncg, r=Nadrieril REVERT: f0801511b8e Rollup merge of #121622 - dtolnay:wake, r=cuviper REVERT: 68d55671c95 Cleanup windows abort_internal REVERT: d954628fec4 typo REVERT: 4a156395cf0 Rollup merge of #121888 - cppcoffee:style, r=Nilstrieb REVERT: 9b10d83a189 Rollup merge of #121759 - RalfJung:addr_of, r=the8472 REVERT: 705bca47cef Rollup merge of #121758 - joboet:move_pal_thread_local, r=ChrisDenton REVERT: 7f1dfee5e76 Rollup merge of #121666 - ChrisDenton:thread-name, r=cuviper REVERT: 2e107e02af4 const_eval_select: make it safe but be careful with what we expose on stable for now REVERT: afadf202aa2 Apply review comments REVERT: 070f0a85910 attempt to further clarify addr_of docs REVERT: ae55e080c7f Rollup merge of #121861 - tbu-:pr_floating_point_exact_examples, r=workingjubilee REVERT: 84d3acfd568 Rollup merge of #121847 - shamatar:btreemap_fix_implicits, r=cuviper REVERT: f3a9659fe5c Rollup merge of #121835 - nnethercote:mv-HandleStore, r=bjorn3 REVERT: 0b6c0acd424 Rollup merge of #109263 - squell:master, r=cuviper REVERT: cb9f2f70cf2 style library/core/src/error.rs REVERT: aaffae72706 Rollup merge of #121730 - ecnelises:aix_pgo, r=wesleywiser REVERT: e85e891f362 Rollup merge of #121634 - RavuAlHemio:slice-prefix-suffix-docs, r=cuviper REVERT: 74a1f0c8142 Add `get_name` placeholder to other targets REVERT: 62a9b9c93ef Move capacity_overflow function to make ui tests change less REVERT: b537b17fbaa try_with_capacity for Vec, VecDeque, String REVERT: 128433c24f1 try_with_capacity for RawVec REVERT: 22314a531b0 Use the guaranteed precision of a couple of float functions in docs REVERT: bebb9ea7c57 Rollup merge of #121850 - reitermarkus:generic-nonzero-unsafe-trait, r=Nilstrieb REVERT: f1871c3d442 Rollup merge of #121736 - HTGAzureX1212:HTGAzureX1212/remove-mutex-unlock, r=jhpratt REVERT: 2cb31dc4d28 Make `ZeroablePrimitive` trait unsafe. REVERT: 36fab021aed remove hidden use of Global REVERT: 1df64282b65 revise interface to read directory entries REVERT: 205418fa11f Extending filesystem support for hermit-os REVERT: a3cdf362b8b Move `HandleStore` into `server.rs`. REVERT: f49177a442d Auto merge of #114016 - krtab:delete_sys_memchr, r=workingjubilee REVERT: 68b566cdc2b Rollup merge of #121809 - tgross35:suggest-path-split-fixup, r=Amanieu REVERT: 018584b9cbd Rollup merge of #121753 - mu001999:core/add_cfg, r=cuviper REVERT: 5d651230624 Rollup merge of #121681 - jswrenn:nix-visibility-analysis, r=compiler-errors REVERT: d45670885c3 Remove doc aliases to PATH REVERT: 3d9b11435f8 Rollup merge of #121596 - ChrisDenton:tls, r=joboet REVERT: 2f57d3e6e30 Forbid implementing `Freeze` even if the trait is stabilized REVERT: de4cd3eae3c Expose `Freeze` trait again REVERT: 9d594b70e50 Rollup merge of #121793 - tbu-:pr_floating_point_32, r=Amanieu REVERT: 6f29e7a2f56 Rollup merge of #121765 - hermit-os:errno, r=ChrisDenton REVERT: 18a5bfe6631 Rollup merge of #118217 - tbu-:pr_floating_point, r=Amanieu REVERT: 2b44b9eefca Document which methods on `f32` are precise REVERT: 29557831025 Document the precision of `f64` methods REVERT: 2c2ba108e86 Rollup merge of #121778 - ibraheemdev:patch-19, r=RalfJung REVERT: c743bceef96 Rollup merge of #121768 - ecton:condvar-unwindsafe, r=m-ou-se REVERT: 51dee9fc787 Rollup merge of #120291 - pitaj:string-sliceindex, r=Amanieu REVERT: 2951919a850 Rollup merge of #119748 - tgross35:suggest-path-split, r=Amanieu REVERT: 0d73d4adaf5 Drop link to matches macro and link matches macro to assert_matches. REVERT: f1dc4ac037d fix typos REVERT: dfe1fc2d7f4 document potential memory leak in unbounded channel REVERT: d713738e3c4 Add proper cfg REVERT: f89c0681402 Rollup merge of #110543 - joboet:reentrant_lock, r=m-ou-se REVERT: bfe5ae55379 Implement unwind safety for Condvar REVERT: 0b89e67a8be add platform-specific function to get the error number for HermitOS REVERT: 3747ff34982 std: move thread local implementation to `sys` REVERT: 7897a18f033 Rollup merge of #121691 - janstarke:handle-missing-creation-time-as-unsupported, r=cuviper REVERT: fa6b1862f17 Rollup merge of #120051 - riverbl:os-str-display, r=m-ou-se REVERT: 9a830a0f1c5 remove Mutex::unlock REVERT: 0961acc0cba Improve assert_matches! documentation REVERT: 84617e5539f Add profiling support to AIX REVERT: 20c02cc556f Implement junction_point REVERT: 6db7e059b0b Auto merge of #119616 - rylev:wasm32-wasi-preview2, r=petrochenkov,m-ou-se REVERT: 2bd8808a5da handle unavailable creation time as `io::ErrorKind::Unsupported` REVERT: e8eda6e9a6a have `String` use `SliceIndex` impls from `str` REVERT: 50ad9c25508 safe transmute: revise safety analysis REVERT: 2bbb714b758 Auto merge of #119636 - devnexen:linux_tcp_defer_accept, r=m-ou-se REVERT: 59ea7dbb02c Rename wasm32-wasi-preview2 to wasm32-wasip2 REVERT: 89c39f261c7 Add the wasm32-wasi-preview2 target REVERT: 06c41fd8eea Test getting the OS thread name REVERT: 30847ccc8ff Use the OS thread name by default for the current thread REVERT: e384a41925d intrinsics.rs: add some notes on unwinding REVERT: 01b9b83c8e0 Stabilize the `#[diagnostic]` namespace and `#[diagnostic::on_unimplemented]` attribute REVERT: 72f6010e45a Generate original vtable and clone's vtable in the same CGU REVERT: 823d14f92d7 Auto merge of #121655 - matthiaskrgr:rollup-qpx3kks, r=matthiaskrgr REVERT: ed4bb097a2c Rollup merge of #121648 - jieyouxu:from-into-raw-parts-docs, r=Nilstrieb REVERT: 50b156d4655 Rollup merge of #121598 - RalfJung:catch_unwind, r=oli-obk REVERT: ebf67e2a092 Auto merge of #121516 - RalfJung:platform-intrinsics-begone, r=oli-obk REVERT: a2cc79ab4cf change std::process to drop supplementary groups based on CAP_SETGID REVERT: deb2e443441 Document args returned from `String::into_raw_parts` REVERT: d3b08ce8101 Document args returned from `Vec::into_raw_parts{,_with_alloc}` REVERT: ac1fe4cb848 Rearrange `String::from_raw_parts` doc argument order to match code argument order REVERT: 0fa995daad1 Rearrange `Vec::from_raw_parts{,_in}` doc argument order to match code argument order REVERT: cd1df70afce fix race between block initialization and receiver disconnection REVERT: ea89df1720e Don't codegen wasm.throw unless with -Zbuild-std REVERT: e53e2d36b0b Remove _tls_used trickery unless needed REVERT: e03dceb3a9d Clarify behavior of slice prefix/suffix operations in case of equality REVERT: a8c3b12ecb4 Use volatile to make `p_thread_callback` used REVERT: e97d0a803f4 Win10: Use GetSystemTimePreciseAsFileTime directly REVERT: 6f4e8f7096d miri: rename miri_start_panic → miri_start_unwind REVERT: 4e9cd3840b8 rename 'try' intrinsic to 'catch_unwind' REVERT: b89280a0f6e Fill in Read::read_buf for &Stdin REVERT: fa28504548c Fix stable feature name and stabilization version of Read for &Stdin REVERT: 415c9b5d6b7 Auto merge of #121317 - ChrisDenton:win10-sync, r=Mark-Simulacrum REVERT: d9878e45f33 Add Waker::will_wake tests REVERT: 4c779365387 Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkin REVERT: e7d49dc1fad Auto merge of #121591 - matthiaskrgr:rollup-8wfhh3v, r=matthiaskrgr REVERT: aae4f43b8fd Rollup merge of #121513 - nshyrei:fix_tests_module, r=cuviper REVERT: d18bc841336 Rollup merge of #119590 - ChrisDenton:cfg-target-abi, r=Nilstrieb REVERT: cebe0017b1f Fix Hash impl REVERT: c7d8eb0c206 Windows: Use ProcessPrng for random keys REVERT: 469292b669d Make push docs more vague REVERT: 85769226c6b remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics REVERT: 93527c0da50 Auto merge of #117107 - zachs18:mapped-mutex-guard, r=Amanieu REVERT: cb645d493f2 Auto merge of #121114 - Nilstrieb:no-inline!, r=saethlin REVERT: df6c1975f77 Auto merge of #121569 - matthiaskrgr:rollup-awglrax, r=matthiaskrgr REVERT: ae9a8557c45 Rollup merge of #121556 - GrigorenkoPV:addr_of, r=Nilstrieb REVERT: 95a17b8bb55 Rollup merge of #121551 - nbdd0121:ffi_unwind, r=RalfJung REVERT: e6563106f22 Rollup merge of #121530 - wgslr:master, r=Mark-Simulacrum REVERT: 8578c1e7750 Rollup merge of #121343 - Takashiidobe:takashi/examples-for-slice, r=Mark-Simulacrum REVERT: f32ddaeacda Stabilize `cfg_target_abi` REVERT: 84e435a879c Add `#[rustc_no_mir_inline]` for standard library UB checks REVERT: 02dc95fe50d Forbid use of `extern "C-unwind"` inside standard library REVERT: 17b07c4384f library: use `addr_of!` REVERT: 0a0d0837b0f update stdarch REVERT: e30efbcbd72 Apply suggestions from code review REVERT: d076d5fa0b6 Fix incorrect doc of ScopedJoinHandle::is_finished REVERT: 50561849715 Auto merge of #119536 - Jules-Bertholet:const-barrier, r=dtolnay REVERT: a867d469af7 std: make `ReentrantLock` public REVERT: c4e8b13aae8 Auto merge of #121303 - GrigorenkoPV:static_mut_refs, r=oli-obk,RalfJung REVERT: bd29aa0936a Auto merge of #121514 - matthiaskrgr:rollup-5f0vhv7, r=matthiaskrgr REVERT: 2eb9b374bf2 Rollup merge of #121498 - flba-eb:make_timespec_capping_public, r=Nilstrieb REVERT: d41b66881dc moved tests file REVERT: 0e9f348ebbb Get rid of some `#[allow(static_mut_refs)]` REVERT: aaa39933ec7 Auto merge of #121454 - reitermarkus:generic-nonzero-library, r=dtolnay REVERT: 03061ef1638 Make timespec capping public to crate::sys REVERT: 34f5355cb0e remove repetitive words REVERT: 381c411033b Auto merge of #120730 - estebank:confusable-api, r=oli-obk REVERT: 73892694ff0 Use Itanium ABI for thrown exceptions REVERT: 0fcf3ddee07 Unconditionally pass -wasm-enable-eh REVERT: 16e190ddf45 std support for wasm32 panic=unwind REVERT: fd0a734571d Add `flatmap`/`flat_map` -> `and_then` suggestions REVERT: 3760b37731b On type error of method call arguments, look at confusables for suggestion REVERT: a765284214e Add `rustc_confusables` annotations to some stdlib APIs REVERT: 6fde7096568 Rollup merge of #121439 - jrudolph:patch-1, r=bjorn3 REVERT: c7f7d3ff646 Fix example. REVERT: d6edf7add65 Use generic `NonZero` everywhere else. REVERT: 1d649b8071b Use generic `NonZero` everywhere in `alloc`. REVERT: 7c87cda165b Use generic `NonZero` everywhere in `std`. REVERT: a1188703ccd Use generic `NonZero` everywhere in `core`. REVERT: 6837b824cdc Auto merge of #121309 - Nilstrieb:inline-all-the-fallbacks, r=oli-obk REVERT: c25d07a6318 remove potentially misleading sentence about libc::access REVERT: 6ab608963d2 Fix typo in metadata.rs doc comment REVERT: 09923461c9e Add std::ffi::c_str modules REVERT: c79c2703755 Auto merge of #117174 - Ayush1325:uefi-stdio-improve, r=workingjubilee REVERT: 2d5ed24d4f5 Auto merge of #121223 - RalfJung:simd-intrinsics, r=Amanieu REVERT: af104d23cac Auto merge of #118634 - Jules-Bertholet:box-allocator-static, r=Amanieu REVERT: d6c3d196099 Always use WaitOnAddress on Win10+ REVERT: fa98c50df21 os::net: expanding TcpStreamExt for Linux with `tcp_deferaccept`. REVERT: d5bb2e1798c remove simd_reduce_{min,max}_nanless REVERT: ae3a50b6122 rename ptr::invalid -> ptr::without_provenance REVERT: 6bcbec3c99e Remove unnecessary map_err REVERT: 3361dcfe9d9 TryReserveError to ErrorKind::OutOfMemory REVERT: 6abdde9985a make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all fast-math flags REVERT: d14435793d1 intrinsics::simd: add missing functions REVERT: 07d748e4f33 Auto merge of #121383 - Dylan-DPC:rollup-735p4u4, r=Dylan-DPC REVERT: 6642b854bbe Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercote REVERT: ab621b911bc Rollup merge of #121361 - pitaj:diag_items-legacy_numeric_constants, r=Nilstrieb REVERT: 511fe47e8ea Stabilize `LazyCell` and `LazyLock` (`lazy_cell`) REVERT: c817ed5d9ca Delete architecture-specific memchr code in std::sys REVERT: 9f4fae97f03 diagnostic items for legacy numeric modules REVERT: 2fbcb3b1266 Add extra detail to field comment REVERT: e46d3d17881 Reduce alignment of TypeId to u64 alignment REVERT: 2b3ae2ab839 Rollup merge of #121352 - malobre:patch-1, r=Nilstrieb REVERT: b200b05e1e7 Rollup merge of #121277 - reitermarkus:generic-nonzero-convert-num, r=dtolnay REVERT: 31829b0c723 Rollup merge of #119203 - farnoy:simd-masked-intrinsic-docfix, r=RalfJung REVERT: e0cc93ee302 Add "algebraic" versions of the fast-math intrinsics REVERT: 878cefd56e5 docs: add missing "the" to `str::strip_prefix` doc REVERT: 21a5e604aed Auto merge of #121345 - Nilstrieb:rollup-reb0xge, r=Nilstrieb REVERT: 9eec8b31227 Correct the simd_masked_{load,store} intrinsic docs REVERT: 70e9226dbfa Add examples for some methods on slices REVERT: f06f11f81c9 Rollup merge of #121302 - GrigorenkoPV:refmutl, r=bjorn3 REVERT: f393d47cecd Rollup merge of #121241 - reitermarkus:generic-nonzero-traits, r=dtolnay REVERT: 788e34c45a8 Rollup merge of #121196 - Nilstrieb:the-clever-solution, r=saethlin REVERT: 37a66b0d4c0 Auto merge of #120863 - saethlin:slice-get-checked, r=the8472 REVERT: 0296e662d32 fix doc link REVERT: 8e5ea63a25c Rollup merge of #121311 - Nilstrieb:is-it-overlapping, r=saethlin REVERT: 74fa4671ea0 Rollup merge of #121310 - GrigorenkoPV:doc-smallfix, r=Nilstrieb REVERT: d0650533cc3 A much simpler version of write REVERT: b9a2ed212d9 remove const REVERT: 74a39dc05c7 add safety text REVERT: 64d9e168071 Fix inlining issue for non-const case REVERT: b388b1b177b Use intrinsic REVERT: 13fa1a28ad1 perf: improve write_fmt to handle simple strings REVERT: 9e47cf450d3 Add more inline(always) to fix opt-level=z test on wasm32 REVERT: 6ccbbc6e398 Convert debug_assert_nounwind to intrinsics::debug_assertions REVERT: c5b24f002c9 Auto merge of #121185 - GuillaumeGomez:update-stdarch, r=Amanieu REVERT: 4b548a2ae73 Make `is_nonoverlapping` `#[inline]` REVERT: b70f8e9cfc0 Make intrinsic fallback bodies cross-crate inlineable REVERT: 1491cb4d8ad Remove an old hack for rustdoc REVERT: e354b122cbe Auto merge of #121177 - joboet:move_pal_locks, r=ChrisDenton REVERT: eeb54280f18 Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions) REVERT: 4937390dcf6 Remove `RefMutL` hack in `proc_macro::bridge` REVERT: e3442a7867a Rollup merge of #121272 - pitaj:diag_items-legacy_numeric_constants, r=Nilstrieb REVERT: 2586853a5f4 Rollup merge of #121041 - Nilstrieb:into-the-future-of-2024, r=Mark-Simulacrum REVERT: f31070073a2 Rollup merge of #119808 - GnomedDev:encode-charsearcher-size-in-type, r=Mark-Simulacrum REVERT: dc620332a7e Update stdarch submodule REVERT: 6b40c3d6539 Refactor trait implementations in `core::convert::num`. REVERT: 045057daaf9 Auto merge of #105917 - a1phyr:read_chain_more_impls, r=workingjubilee REVERT: bd70d763169 Clarify/add `must_use` message for Rc/Arc/Weak::into_raw. REVERT: b950a4056f1 Auto merge of #121269 - calebzulawski:sync-portable-simd-2024-02-18, r=Mark-Simulacrum REVERT: 56b90f47345 Fix error in push docs REVERT: 3d72a268758 Auto merge of #121101 - GnomedDev:dyn-small-c-string, r=Nilstrieb REVERT: 8d958dd5216 Add `Future` and `IntoFuture` to the 2024 prelude REVERT: 0e82369b52c diagnostic items for legacy numeric constants REVERT: b3bbcdeec36 Dyn erase at call site REVERT: 1b069b63d4f Add some comments to prevent regression REVERT: 7653d39a26d Reduce monomorphisation bloat in small_c_string REVERT: a6c89ed6adf Rollup merge of #121266 - SabrinaJewson:easy-syscall-aliases, r=Mark-Simulacrum REVERT: 5ef0db76cce Rollup merge of #121224 - hi-rustin:rustin-patch-unit-binding, r=Mark-Simulacrum REVERT: 910d274aa9c Rollup merge of #118569 - blyxxyz:platform-os-str-slice, r=Mark-Simulacrum REVERT: 4f721156b2b Merge commit '649110751ef4f27440d7cc711b3e07d11bf02d4a' into sync-portable-simd-2024-02-18 REVERT: 8dd16f53429 Add uncontroversial syscall doc aliases to std docs REVERT: 150523e5b46 Auto merge of #117772 - surechen:for_117448, r=petrochenkov REVERT: 85280706541 fix typo in push documentation REVERT: 513b920c7ee intradoc link for vec REVERT: 926f36b1ab4 time complexity for insert REVERT: b4ccf7db259 time complexity for pop REVERT: 8e6711c1751 time complexity for push_within_capacity REVERT: 31249e22cdf time complexity for push REVERT: 30336a77f73 By tracking import use types to check whether it is scope uses or the other situations like module-relative uses, we can do more accurate redundant import checking. REVERT: 597c2d255fd Auto merge of #121034 - obeis:improve-static-mut-ref, r=RalfJung REVERT: e80218906b8 Improve wording of static_mut_ref REVERT: 29c5be12c47 Auto merge of #118264 - lukas-code:optimized-draining, r=the8472 REVERT: 998f195b19b Implement `NonZero` traits generically. REVERT: 74527e99fbc Auto merge of #121204 - cuviper:flatten-one-shot, r=the8472 REVERT: e911cad4e7d Rollup merge of #121149 - SebastianJL:patch-1, r=Mark-Simulacrum REVERT: 4989bc38447 Rollup merge of #120952 - saethlin:vec-into-iter, r=the8472 REVERT: 09f2c5067fd Auto merge of #121232 - RalfJung:miri, r=RalfJung REVERT: 263cf10db7f Allow newly added non_local_definitions in std REVERT: 6d047e54069 Rollup merge of #121192 - oli-obk:intrinsics2.0, r=WaffleLapkin REVERT: a70e0963daa Rollup merge of #121187 - Takashiidobe:takashi/examples-for-quickselect, r=Nilstrieb REVERT: 80a94e4e2a8 Rollup merge of #119032 - smmalis37:patch-1, r=ChrisDenton REVERT: b0898be1180 Remove unnecessary unit binding REVERT: 2a42861b3f2 Merge from rustc REVERT: 0fda857591d Auto merge of #120563 - reitermarkus:generic-nonzero-get, r=dtolnay REVERT: b19e222bdbe Add an example to demonstrate how Rc::into_inner works REVERT: 6041bcea731 Auto merge of #120741 - a1phyr:safe_buffer_advance, r=m-ou-se REVERT: 89767fa283d Clarify the flatten specialization comment REVERT: df242d936cd Remove cfg_attr REVERT: d66aec0606d Use a hardcoded constant instead of calling OpenProcessToken. REVERT: 0464596b368 Give the (`un`)`likely` intrinsics fallback bodies REVERT: 38af756b834 Give the `assume` intrinsic a fallback body REVERT: 4de18f1ac27 Specialize flattening iterators with only one inner item REVERT: fbd7d663f57 Don't use mem::zeroed in vec::IntoIter REVERT: a22b06ba375 Add examples to document the return type of `select_nth_unstable`, `select_nth_unstable_by`, and `select_nth_unstable_by_key`. REVERT: 7840f483be4 Auto merge of #116385 - kornelski:maybe-rename, r=Amanieu REVERT: 0a915eb5e34 address review comments REVERT: 01fd99079c5 outline large copies REVERT: ae0b3dd4ba1 reduce branchiness REVERT: b46a88ea0cd reduce amount of math REVERT: 7676dfd132e simplify codegen for trivially droppable types REVERT: 03d6ce10579 Auto merge of #120538 - kornelski:read-not-exact, r=m-ou-se REVERT: 1a46f7213bb std: move locks to `sys` on platforms without threads REVERT: c426d14e7f8 std: move locks to `sys` on xous REVERT: cb2a73347c7 std: move locks to `sys` on Windows REVERT: aabb6094b6d std: move locks to `sys` on UNIX and other futex platforms REVERT: 653f7b597dd std: move locks to `sys` on teeos REVERT: 61659af728c std: move locks to `sys` on SGX REVERT: a8d0e2e9ea5 std: move locks to `sys` on µITRON REVERT: b457779990a Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkin REVERT: 9981b0eceb3 Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnay REVERT: baf1bbfd05f Merge from rustc REVERT: b484e9658a5 Auto merge of #120889 - Ayush1325:uefi-instant, r=joshtriplett REVERT: f3af02651df Rollup merge of #121155 - tspiteri:strict-doc-overflow, r=Nilstrieb REVERT: 4773c9e8a10 Rollup merge of #120971 - PizzasBear:patch-1, r=Nilstrieb REVERT: a0145d48d44 Rollup merge of #120777 - Marcondiro:unicode15-1, r=Manishearth REVERT: 143a39d9c5c doc: panicking division by zero examples for unsigned strict div ops REVERT: 2f86d6ee465 doc: add note before panicking examples for strict_overflow_ops REVERT: e834b7e30c7 Auto merge of #121142 - GuillaumeGomez:rollup-5qmksjw, r=GuillaumeGomez REVERT: dcb378aca13 Fix typo in VecDeque::handle_capacity_increase() doc comment. REVERT: 71ec8f8397c Add slice::try_range REVERT: 6e6fa8e1d20 Auto merge of #119863 - tmiasko:will-wake, r=m-ou-se REVERT: b6fd1a0e721 Update library/std/src/fs.rs REVERT: 9e1b7296787 Update library/std/src/fs.rs REVERT: b9a4a12f92b Rollup merge of #121120 - nnethercote:LitKind-Err-guar, r=fmease REVERT: 68b5e7bc17c Rollup merge of #120672 - devnexen:update_thread_stack_guardpages_fbsd, r=m-ou-se REVERT: 882dc683c69 Rollup merge of #120505 - Amanieu:fix-btreemap-cursor-remove, r=m-ou-se REVERT: 6a16d9dacbb Rollup merge of #120449 - udoprog:document-unsized-rc-arc-from-raw, r=m-ou-se REVERT: 26b44e1c0c1 Add ASCII fast-path for `char::is_grapheme_extended` REVERT: 6cba163d299 Rollup merge of #121098 - ShoyuVanilla:thread-local-unnecessary-else, r=Nilstrieb REVERT: 1a1ae7f0945 Rollup merge of #121082 - peterjoel:atomic-docs, r=cuviper REVERT: 50fbdb3f216 Rollup merge of #118749 - ChrisDenton:winsys, r=cuviper REVERT: 6e2c4f48cc5 Rollup merge of #111106 - Stargateur:doc/format_args, r=m-ou-se REVERT: 926ab97d2c0 Replace `NonZero::<_>::new` with `NonZero::new`. REVERT: 7870dc47f88 Use generic `NonZero` internally. REVERT: 4e6cd3e02b0 Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`. REVERT: 80913e18ce5 Clarified docs on non-atomic oprations on owned/mut refs to atomics REVERT: 05b5eff85e1 Merge from rustc REVERT: ad6965a4f1e Remove unnecessary else block from `thread_local!` expanded code REVERT: 71d02d48dff Auto merge of #121078 - oli-obk:rollup-p11zsav, r=oli-obk REVERT: f3650d6e46a Rollup merge of #121073 - IgorLaborieWefox:patch-1, r=workingjubilee REVERT: dc35347395f Rollup merge of #121024 - joseluis:feat-asciichar-default, r=scottmcm REVERT: dab1236f4d5 Rollup merge of #118890 - Amanieu:allocator-lifetime, r=Mark-Simulacrum REVERT: 187f847d781 Rollup merge of #118738 - devnexen:netbsd10_update, r=cuviper REVERT: 8c0023d8117 Rollup merge of #116387 - kpreid:wake-doc, r=cuviper REVERT: 6a6870751bd Auto merge of #100603 - tmandry:zst-guards, r=dtolnay REVERT: 34196f6d2ac Automatically sort windows_sys bindings REVERT: ee23acf6bc2 Add windows_sys readme REVERT: 08e47326af2 Move windows_sys.lst to bindings.txt REVERT: b0b371b1b7c Fix typos in `OneLock` doc REVERT: 8535e57e55e Fix incorrect use of `compile_fail` REVERT: 12ad021cc31 Store core::str::CharSearcher::utf8_size as u8 REVERT: e83394c84cf Add information about allocation lifetime to Allocator::allocate REVERT: de3bcca36f4 implement `Default` for `AsciiChar` REVERT: 236c25e8033 Implement Instant for UEFI REVERT: 0b5ada2b22a Auto merge of #121003 - matthiaskrgr:rollup-u5wyztn, r=matthiaskrgr REVERT: 821af2ba024 Rollup merge of #120986 - tshepang:extraneous, r=cuviper REVERT: ca63ba97a0d Rollup merge of #120967 - LeoDog896:master, r=cuviper REVERT: 0b357246fd2 Merge from rustc REVERT: 0fa295ae27a Auto merge of #120938 - Ayush1325:uefi-thread, r=joboet,Nilstrieb REVERT: fa026317a39 docs: use correct link, use secondary example REVERT: 2f68e0a1e11 iterator.rs: remove "Basic usage" text REVERT: 9fd456ccecb Support safe intrinsics with fallback bodies REVERT: 92c4f8451fe Give const_deallocate a default body REVERT: e4e14afe33d Teach llvm backend how to fall back to default bodies REVERT: e78e22d4dd5 Check signature of intrinsics with fallback bodies REVERT: b9a7dbf8125 Rollup merge of #120936 - ripytide:master, r=Amanieu REVERT: 2ee0698fb52 constify a couple thread_local statics REVERT: b4d39ca1fdb style: fmt REVERT: aeea8fe6af4 Clarify the lifetimes of allocations returned by the `Allocator` trait REVERT: b707b6c6d29 Fix comment in core/src/str/validations.rs REVERT: 985e87ec2df docs: mention round-to-even in precision formatting REVERT: 9a03ed37b5f Merge from rustc REVERT: 0a062ec3292 Auto merge of #110211 - joboet:queue_lock, r=Amanieu REVERT: 2f6532935af Implement intrinsics with fallback bodies REVERT: 6a1bbb0daa7 Rollup merge of #120888 - saethlin:unsafe-precondition-cleanup, r=RalfJung REVERT: e6f1dc2fcc8 Rollup merge of #120880 - RalfJung:vtable-fnptr-partialeq, r=cuviper REVERT: 5d7b839d85a Rollup merge of #120740 - ChrisDenton:cmaths, r=Mark-Simulacrum REVERT: 4c4ec2b7084 Rollup merge of #110483 - tleibert:thin-box-try-new, r=dtolnay REVERT: 1696700c69a std: use `stream_position` where applicable REVERT: 0b06390f4de add comparison warning to RawWakerVTable as well REVERT: d41a9487d38 fix intra-doc links REVERT: 8ee8a3922e5 Address ThinBox::try_new PR review REVERT: e870089a8e4 Implement sys/thread for UEFI REVERT: bb24215c837 Auto merge of #120903 - matthiaskrgr:rollup-tmsuzth, r=matthiaskrgr REVERT: 55ec6457c7d Cleanup around the new assert_unsafe_precondition REVERT: d95ae4eb60a fix incorrect doctest REVERT: 170a28a257d improve `btree_cursors` functions documentation REVERT: 0125017988d add doc-comment to `unlock_queue` REVERT: 2a9655399c5 std: enabling new netbsd (10) calls. REVERT: c8634c236cd Rollup merge of #120459 - rytheo:handle-conversion-docs, r=Mark-Simulacrum REVERT: 1d5ef4a9764 Rollup merge of #120307 - djc:duration-constructors, r=Mark-Simulacrum REVERT: 414edebf766 Rollup merge of #119449 - Nilstrieb:library-clippy, r=cuviper REVERT: f2e9990ceae Rollup merge of #119242 - BenWiederhake:dev-from-nanos, r=joshtriplett REVERT: 99e6261e199 Rollup merge of #118307 - scottmcm:tuple-eq-simpler, r=joshtriplett REVERT: a418c46bd84 Rollup merge of #117740 - majaha:format_docs, r=joshtriplett REVERT: 194da2e2fb4 Remove the link. REVERT: b6fb05a18e2 URL-encode chars in fragment. REVERT: 7bfd06ba1d9 Additional doc links and explanation of `Wake`. REVERT: 19a6b075dfa Merge from rustc REVERT: a11ef6a5b6a Fix typo REVERT: 90aaf184f38 Auto merge of #120232 - c272:json-buildstd, r=Mark-Simulacrum REVERT: d2d538a4f96 Rollup merge of #119213 - RalfJung:simd_shuffle, r=workingjubilee REVERT: 2ed3ac079d6 add note on comparing vtables / function pointers REVERT: 8c9555c9058 Rollup merge of #120823 - LegionMammal978:clarify-atomic-align, r=RalfJung REVERT: 02caf1fe8f7 Rollup merge of #120764 - Alfriadox:master, r=m-ou-se REVERT: 35ef0688244 various docs tweaks REVERT: cb302e0fc65 simd_scatter: mention left-to-right order REVERT: eb8fc13d691 add more missing simd intrinsics REVERT: 9fd3c75e19f simd intrinsics: add simd_shuffle_generic REVERT: 3f027117151 Stabilize slice_split_at_unchecked REVERT: df4ba99b376 Auto merge of #120712 - compiler-errors:async-closures-harmonize, r=oli-obk REVERT: f0ddef4a72e Merge from rustc REVERT: 6b589c4430d Change wording REVERT: f9e40ce4eb5 Auto merge of #120852 - matthiaskrgr:rollup-01pr8gj, r=matthiaskrgr REVERT: 39f26bdfcfc std::thread update freebsd stack guard handling. REVERT: 85a5f3a711c Rollup merge of #120815 - camsteffen:inspect-docs, r=m-ou-se REVERT: e7b1bc00c88 Rollup merge of #120776 - joboet:move_pal_path, r=ChrisDenton REVERT: 266b53157db Rollup merge of #120351 - Ayush1325:uefi-time, r=m-ou-se REVERT: 04889f625c4 Auto merge of #120676 - Mark-Simulacrum:bootstrap-bump, r=clubby789 REVERT: 8eeb7d733b2 address review comments REVERT: 4566d41aaee Bump Unicode to version 15.1.0, regenerate tables REVERT: 61833dff7f5 be more explicit about why adding backlinks eagerly makes sense REVERT: 6835f46f68d Improve Option::inspect docs REVERT: 9987f16537b Auto merge of #120843 - matthiaskrgr:rollup-med37z5, r=matthiaskrgr REVERT: f87fa6d677b format using latest rustfmt REVERT: 4a2ab6d1c5e inline some single-use functions, add documentation REVERT: d37b71e54cc queue_rwlock: use a separate `QUEUE_LOCKED` bit to synchronize waiter queue updates REVERT: b1a5f78b1ec use exponential backoff in `lock_contended` REVERT: 56e1efb8af3 immediately register writer node if threads are queued REVERT: ce581cca729 avoid unnecessary `Thread` handle allocation REVERT: db96f0366bd use braces to make operator precedence less ambiguous REVERT: dc2d0509e25 adjust code documentation REVERT: 132e36aad77 std: replace pthread `RwLock` with custom implementation inspired by usync REVERT: 88dbefe419a Rollup merge of #120809 - reitermarkus:generic-nonzero-constructors, r=Nilstrieb REVERT: d13b542ad25 Rollup merge of #120308 - utkarshgupta137:duration-opt, r=m-ou-se REVERT: 816944b6d47 Auto merge of #120594 - saethlin:delayed-debug-asserts, r=oli-obk REVERT: 95fc1c72851 Auto merge of #120238 - joboet:always_confirm_lock_success, r=Mark-Simulacrum REVERT: ea50f6e26d0 Clarify that atomic and regular integers can differ in alignment REVERT: f85909649a8 Add and use Unique::as_non_null_ptr REVERT: 1b7c1082604 Make `NonZero::get` generic. REVERT: fe47f1439c4 Use `transmute_unchecked` in `NonZero::new`. REVERT: afd4d75ffec Implement SystemTime for UEFI REVERT: 0bd39644c29 Reduce use of NonNull::new_unchecked in library/ REVERT: c04cba0ce9d Remove a now-obviated debug_assert! REVERT: 94a8293f01c Rewrite assert_unsafe_precondition around the new intrinsic REVERT: ab5ca413dc4 Add a new debug_assertions intrinsic REVERT: 1abe4f582a9 Step all bootstrap cfgs forward REVERT: 37f3ad90f22 Bump version placeholders REVERT: 6412eff99cd std: move path into `sys` REVERT: 0839a16de98 Auto merge of #120558 - oli-obk:missing_impl_item_ice, r=estebank REVERT: e79c64e92c8 Fix whitespace issues that tidy caught REVERT: 4ecc5c5b08d Add documentation on `str::starts_with` REVERT: 420b5d8c763 Auto merge of #120521 - reitermarkus:generic-nonzero-constructors, r=dtolnay REVERT: 00d45b89d67 Auto merge of #120381 - fee1-dead-contrib:reconstify-add, r=compiler-errors REVERT: 82b7f74a159 Make `io::BorrowedCursor::advance` safe REVERT: fa1947f78b2 Make cmath.rs a single file REVERT: 4c2ea7bc4be Replace `transmute_copy` with `ptr::read`. REVERT: a9847020e7b Don't use `assert_unsafe_precondition` twice. REVERT: 69b52185f26 Auto merge of #120527 - GnomedDev:atomicu32-handle, r=petrochenkov REVERT: 3ed3e1bb71a Make `NonZero` constructors generic. REVERT: 2edf2118adc Simplify `impl_zeroable_primitive` macro. REVERT: b825d658298 Update tests REVERT: 3b0b747eb3e Auto merge of #117905 - RalfJung:no-const-mut, r=lcnr REVERT: cf1c72f3202 Harmonize blanket implementations for AsyncFn* traits REVERT: 0039eee64dd Auto merge of #120361 - compiler-errors:async-closures, r=oli-obk REVERT: 26abc5319c1 Auto merge of #120326 - tmandry:abort-in-tests, r=cuviper REVERT: 04ebdf56df1 Bless tests, add comments REVERT: 0eccda24d9a Teach typeck/borrowck/solvers how to deal with async closures REVERT: fef14350edb revert stabilization of const_intrinsic_copy REVERT: 02cfedd4806 Auto merge of #117372 - Amanieu:stdarch_update, r=Mark-Simulacrum REVERT: e3078780d56 Add support for custom JSON targets when using build-std. REVERT: da24d528151 Remove some invalid cfg(doc) code REVERT: 7e09db626eb Rollup merge of #120657 - mu001999:clean, r=Nilstrieb REVERT: 3df14c076d0 Rollup merge of #120384 - wackbyte:array-equality-generics, r=Mark-Simulacrum REVERT: 4ba91a341b9 Rollup merge of #118960 - tvallotton:local_waker, r=Mark-Simulacrum REVERT: c0bffc467e6 Rollup merge of #115386 - RalfJung:partial-eq-chain, r=dtolnay REVERT: ae215772f37 Rollup merge of #113833 - WiktorPrzetacznik:master, r=dtolnay REVERT: 4221058a4ad Rollup merge of #120607 - conradludgate:fix-120603, r=dtolnay REVERT: 6c615798209 Rollup merge of #120572 - pheki:update-libc, r=Mark-Simulacrum REVERT: 9cfdb5a3413 Rollup merge of #120458 - rytheo:cstr-conversion-doc, r=Mark-Simulacrum REVERT: 063fcaccc5b Rollup merge of #119481 - romanows:fix-doc-select-nth-unstable, r=Mark-Simulacrum REVERT: 017ae66f9dc Remove unused struct REVERT: 4997a6fc271 Auto merge of #120624 - matthiaskrgr:rollup-3gvcl20, r=matthiaskrgr REVERT: 054ddec7455 Document various I/O handle conversions REVERT: 9d9e19a4617 Reconstify `Add` REVERT: 14f6ef0c350 Rollup merge of #120528 - GnomedDev:atomicu8-backtrace-style, r=cuviper REVERT: f578f843041 Rollup merge of #120523 - a1phyr:improve_read_buf_exact, r=the8472 REVERT: 66ef6117b29 add another test to make sure it still works with full reads REVERT: df313690e4f fix #120603 by adding a check in default_read_buf REVERT: d341004d0d7 Docs for std::ptr::slice_from_raw_parts REVERT: c85c615c689 fix typo REVERT: c00a2cfdca7 Update libc to 0.2.153 REVERT: 3475147f927 Revert unsound libcore changes of #119911 REVERT: 58d486dfdc4 Make File::read_to_end less special REVERT: 923702359df Store SHOULD_CAPTURE as AtomicU8 REVERT: 40ae652e04c Switch OwnedStore handle count to AtomicU32 REVERT: 58ba7c6b6d6 Rollup merge of #120430 - devnexen:fix_tls_dtor_fbsd, r=cuviper REVERT: 00e2eeced60 Rollup merge of #120355 - the8472:doc-vec-fromiter, r=cuviper REVERT: fa9df694f62 Improve `io::Read::read_buf_exact` error case REVERT: 76fd229e3ee Actually abort in panic-abort-tests REVERT: 170a1281fae Apply suggestions from code review REVERT: ad285ab96b9 document `FromIterator for Vec` allocation behaviors REVERT: 55c2280c052 Fix BTreeMap's Cursor::remove_{next,prev} REVERT: 3e8bd0c0893 Rollup merge of #120485 - chenyukang:yukang-add-query-instability-check, r=michaelwoerister REVERT: 1f82ee313cb Rollup merge of #120445 - Nemo157:arc-plug, r=Mark-Simulacrum REVERT: 8fe24a79470 Rollup merge of #120434 - fmease:revert-speeder, r=petrochenkov REVERT: ed0c6d99493 Rollup merge of #120295 - reitermarkus:remove-ffi-nonzero, r=dtolnay REVERT: f6e1c6bb945 Rollup merge of #120452 - alexcrichton:update-windows-seek-write-docs, r=ChrisDenton REVERT: c076f5a496e Rollup merge of #120424 - RalfJung:raw-ptr-meta, r=Nilstrieb REVERT: 362bcc93d3d Rollup merge of #119991 - kornelski:endless-read, r=the8472 REVERT: d5c992db4d1 Auto merge of #117925 - kornelski:read-to-oom, r=Amanieu REVERT: e1060193b0a Disable conversions between portable_simd and stdarch on big-endian ARM REVERT: 0e31f592f2c add missing potential_query_instability for keys and values in hashmap REVERT: 9e63613f632 Add stdarch_wasm_atomic_wait feature in std REVERT: 902bfb8f5e2 Update feature names for new stdarch REVERT: 8af5a729181 Update stdarch submodule REVERT: 89435160fa4 Handle out of memory errors in fs::read/read_to_string REVERT: a207d3d9a13 Handle out of memory errors in io:Read::read_to_end() REVERT: edf4d3b193e Remove `raw_os_nonzero` feature. REVERT: d1472178cb6 std: always check the result of `pthread_mutex_lock` REVERT: b0f911772fe Rollup merge of #120462 - mu001999:clean, r=Nilstrieb REVERT: 194dc82a92e Rollup merge of #120373 - HTGAzureX1212:HTGAzureX1212/issue-120040, r=ChrisDenton REVERT: fef22f4511e Rollup merge of #120266 - steffahn:a_rc_into_inner_docs, r=Mark-Simulacrum REVERT: 6c1713a9b98 Rollup merge of #116677 - joshlf:patch-11, r=RalfJung REVERT: 06f23bbbdc3 Auto merge of #120165 - reitermarkus:nonzero-switch-alias-direction, r=dtolnay REVERT: 01a4f67a108 raw pointer metadata API: data address -> data pointer REVERT: e3c4d0e937d Auto merge of #120451 - RalfJung:miri, r=RalfJung REVERT: bbaf4162a3c Clean dead code REVERT: 2e25b7fa03a Make `impl` impl take `?Sized` REVERT: 8a8d1a8dd1a Make `impl` impl take `?Sized` REVERT: 81008bad021 Document From<&CStr> for CString REVERT: 9820f89caa5 std: Update documentation of seek_write on Windows REVERT: 5c7d1a7c180 Fix some `Arc` allocator leaks REVERT: 3d037a2f68e Fix doctest REVERT: 1c6e690169d Replicate documentation in {Rc,Arc}::from_raw_in REVERT: 67eab0b10d5 Fix doctest REVERT: 571718891e4 Tidy up REVERT: d076deb752d Add examples for unsized {Rc,Arc}::from_raw REVERT: 131532637a6 Document requirements for unsized {Rc,Arc}::from_raw REVERT: 3e5c592e60c Revert "Add the wasm32-wasi-preview2 target" REVERT: 20241562eea std: thread_local::register_dtor fix proposal for FreeBSD. REVERT: a870b3b1dcc Reject infinitely-sized reads from io::Repeat REVERT: 251b2189464 Update primitive_docs.rs REVERT: cafbaea60dc Switch `NonZero` alias direction. REVERT: ede7f528115 Auto merge of #120417 - matthiaskrgr:rollup-5rszkmd, r=matthiaskrgr REVERT: d82e4e7e3cc Rollup merge of #119641 - eopb:std-unused-ip-feature, r=ChrisDenton REVERT: 2c2b164ae1b Auto merge of #111379 - nyurik:intersperse-speed-up, r=cuviper REVERT: ebed0b38c3d add extra check for invalid handle in ReadDir::next REVERT: e797c208a76 make modifications as per reviews REVERT: bf463a5fc3b Rollup merge of #120366 - RalfJung:is_val_statically_known, r=cuviper REVERT: 9f3934c9e67 Rollup merge of #120311 - mina86:h, r=cuviper REVERT: 652ff31096e Rollup merge of #120205 - Berrysoft:windows-alloc-init, r=ChrisDenton REVERT: f1c1f6a9bf3 Rollup merge of #119562 - LegionMammal978:rename-pin-pointer, r=Amanieu,dtolnay REVERT: 78dd0efd516 Rollup merge of #113489 - tguichaoua:cow_from_array, r=dtolnay REVERT: a92fc652797 Rollup merge of #103522 - Dylan-DPC:76118/array-methods-stab, r=dtolnay REVERT: 4ba0646f1f0 Use `` for array/slice equality `impl`s REVERT: e5445ecb356 Rollup merge of #120372 - bjorn3:fix_outdated_comment, r=Nilstrieb REVERT: 98ea88bb04c Rollup merge of #120117 - NobodyXu:99262/update-api-and-doc, r=m-ou-se REVERT: 74510b1fc9a Rollup merge of #119917 - Zalathar:split-off, r=cuviper REVERT: acc61cd30e7 Rollup merge of #117678 - niklasf:stabilize-slice_group_by, r=dtolnay REVERT: f9853e319bd fix REVERT: 414e7ab7477 remove redundant call to Error::last_os_error REVERT: c484634aafe Fix outdated comment on Box REVERT: 6bb34ba05ca fix issue 120040 REVERT: 8fa4258c304 mark a doctest with UB as no_run REVERT: c3d2137f2c8 Rollup merge of #120053 - AldanTanneo:specialize-stdinlock-bytes, r=the8472 REVERT: 98d42f962aa Rollup merge of #119466 - Sky9x:str_from_raw_parts, r=dtolnay REVERT: 341bc88acf0 Rollup merge of #107464 - WaffleLapkin:all_that_remains_of_lines, r=dtolnay REVERT: ba2c84144e9 Merge from rustc REVERT: 7a3fa73f643 Export core::str::from_raw_parts{,_mut} into alloc::str and std::str REVERT: 54ce792bc71 use checked_add for upper bound REVERT: dc450af05c7 Update library/core/src/iter/adapters/intersperse.rs REVERT: d3fa9aab2d9 Auto merge of #116167 - RalfJung:structural-eq, r=lcnr REVERT: d10df6e3dd7 fmt REVERT: 1ddfb2ed466 Postpone .next() call until iteration REVERT: 2fe04a4c0ed Boost intersperse(_with) performance REVERT: 844c75ad291 Rollup merge of #120338 - steffahn:provenance_links, r=Nilstrieb REVERT: f542fdf0165 Rollup merge of #120332 - mu001999:cleanup/dead_code, r=Nilstrieb REVERT: 4228738fbbf Rollup merge of #120306 - safinaskar:clone3-clean-up, r=petrochenkov REVERT: d7f98f79ea9 Rollup merge of #118208 - Amanieu:btree_cursor2, r=dtolnay REVERT: 9a0569081a9 core: add `From` implementations REVERT: 7991415f432 Update primitive_docs.rs REVERT: 7e1037a2e91 Fix links to [strict|exposed] provenance sections of `[std|core]::ptr` REVERT: 4ce53feb155 Rollup merge of #119305 - compiler-errors:async-fn-traits, r=oli-obk REVERT: 4d1253b8ceb Auto merge of #119911 - NCGThompson:is-statically-known, r=oli-obk REVERT: 2d76d7aa34e Rollup merge of #119616 - rylev:wasm32-wasi-preview2, r=petrochenkov,m-ou-se REVERT: 3a859ba1c27 Rollup merge of #118326 - WaffleLapkin:nz_count_ones, r=scottmcm REVERT: 8a66374864a Finishing clone3 clean up REVERT: d3a5ed01d2b This commit is part of clone3 clean up. Merge tests from tests/ui/command/command-create-pidfd.rs to library/std/src/sys/pal/unix/process/process_unix/tests.rs to remove code duplication REVERT: 622c7f3493d core: add Duration constructors REVERT: 30eb36be8ee This commit is part of clone3 clean up. As part of clean up we will remove tests/ui/command/command-create-pidfd.rs . But it contains very useful comment, so let's move the comment to library/std/src/sys/pal/unix/rand.rs , which contains another instance of the same Docker problem REVERT: 70726a41919 std/time: avoid divisions in Duration::new REVERT: cd531ab3346 remove StructuralEq trait REVERT: 0a9e968613c Merge from rustc REVERT: bfb2613e84f Add `NonZero*::count_ones` REVERT: a69f0dc661f Auto merge of #120283 - fmease:rollup-rk0f6r5, r=fmease REVERT: f687e3cf13e Rollup merge of #120183 - Zalathar:test-closure, r=compiler-errors REVERT: 2b544b5608a Rollup merge of #120171 - cjgillot:jump-threading-assume-assert, r=tmiasko REVERT: b08424cb576 Rollup merge of #120160 - reitermarkus:nonzero-traits, r=dtolnay REVERT: 29b88001bd0 Rollup merge of #120244 - reitermarkus:nonzero-self, r=dtolnay REVERT: 27b3c99c93b Rollup merge of #120188 - devnexen:update_bsd_compiler_base_specs, r=wesleywiser REVERT: c1c00283511 Wrap `HeapAlloc` and never inline REVERT: 8fd21eb2050 Further Implement Power of Two Optimization REVERT: 079bc949929 Further Implement `is_val_statically_known` REVERT: 3839afbc7b8 Auto merge of #119433 - taiki-e:rc-uninit-ref, r=Nilstrieb REVERT: 1dd2cefa0bb Add the wasm32-wasi-preview2 target REVERT: 017967455c9 Improve documentation for [A]Rc::into_inner REVERT: 6461396a5aa Auto merge of #117958 - risc0:erik/target-triple, r=davidtwco,Mark-Simulacrum REVERT: 9d6eabc08de Auto merge of #119892 - joboet:libs_use_assert_unchecked, r=Nilstrieb,cuviper REVERT: 0368120231a Merge from rustc REVERT: b91d8e354a5 Add Assume custom MIR. REVERT: 9040597d322 fixing build for the BSD REVERT: c9567f65a59 Rollup merge of #120233 - oli-obk:revert_trait_obj_upcast_stabilization, r=lcnr REVERT: b07695bcbf1 Rollup merge of #120220 - nnethercote:TokenStream-Display-docs, r=petrochenkov REVERT: 87f5f8e9b18 Rollup merge of #120143 - compiler-errors:consolidate-instance-resolve-for-coroutines, r=oli-obk REVERT: f7f9c1b0479 Rollup merge of #120109 - joboet:move_pal_cmath, r=ChrisDenton REVERT: d021d7757e9 Rollup merge of #119664 - ChrisDenton:mingw-pty, r=thomcc REVERT: d2a299af892 Use `Self` in `NonZero*` implementations. REVERT: 35c7150f0f9 Auto merge of #120242 - matthiaskrgr:rollup-a93yj3i, r=matthiaskrgr REVERT: 469d28fe957 zkvm: add partial std support REVERT: f035b7a6aee rustc: implement support for `riscv32im_risc0_zkvm_elf` REVERT: 3d8601e0b30 Rollup merge of #120181 - dtolnay:tlconst, r=thomcc REVERT: 00432fa0803 Rollup merge of #119801 - zachs18:zachs18-patch-1, r=steffahn,Nilstrieb REVERT: 8e19c2f9c90 Rollup merge of #117910 - madsmtm:msg-send-no-clashing, r=thomcc REVERT: b8ab270b79c Rollup merge of #119943 - devnexen:listener_update3, r=thomcc REVERT: 26a0c2d6d74 Rollup merge of #119408 - betrusted-io:xous-fixes-add-network, r=Mark-Simulacrum REVERT: 6e387500dc4 Rollup merge of #118578 - mina86:c, r=dtolnay REVERT: 74b04cd0114 std: move cmath into `sys` REVERT: b88cdf2a6b5 Revert "Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkin" REVERT: b92654a996e Fix msys2 tty detection for /dev/ptmx REVERT: da395c84b0e Auto merge of #120226 - matthiaskrgr:rollup-9xwx0si, r=matthiaskrgr REVERT: f05f80594e8 Auto merge of #120196 - matthiaskrgr:rollup-id2zocf, r=matthiaskrgr REVERT: a11e241292c Rollup merge of #120194 - HTGAzureX1212:HTGAzureX1212shorten-option-must-use, r=Nilstrieb REVERT: 1b2f1632ead Rollup merge of #119726 - NCGThompson:div-overflow-doc, r=Nilstrieb REVERT: 7b99e8bf05b Rollup merge of #118714 - The-Ludwig:explain_ord_derive_enum_field, r=Nilstrieb REVERT: 4090dcd4eee Document `Token{Stream,Tree}::Display` more thoroughly. REVERT: 6d5a74bbd3e review REVERT: bc9992af9a7 Move `OsStr::slice_encoded_bytes` validation to platform modules REVERT: 692a54a46bb Manually implement derived `NonZero` traits. REVERT: e5e916a7e95 Auto merge of #119807 - Emilgardis:track_caller_from_impl_into, r=Nilstrieb REVERT: 69b55e9a927 Remove unused struct REVERT: 4c6020e480e Fix `clippy::correctness` in the library REVERT: e0b37feb6b0 Add `#[coverage(off)]` to closures introduced by `#[test]`/`#[bench]` REVERT: d47da09513c Rollup merge of #120180 - Zalathar:vec-split-off-alternatives, r=dtolnay REVERT: 7d1b19b658b Rollup merge of #120145 - the8472:fix-inplace-dest-drop, r=cuviper REVERT: 0793ed787c7 Rollup merge of #120045 - scottmcm:unhide-repeat-n, r=Mark-Simulacrum REVERT: 709796275c9 Auto merge of #85528 - the8472:iter-markers, r=dtolnay REVERT: 274bbd122ff chore: suggest wrapping in an `assert!()` instead REVERT: ccd29f1fd96 Merge from rustc REVERT: b511b7748c3 Rollup merge of #119996 - joboet:move_pal_os_str, r=ChrisDenton REVERT: 8eac3537f5c Rollup merge of #119081 - jstasiak:is-ipv4-mapped, r=dtolnay REVERT: 0317715b84d Rollup merge of #118811 - EbbDrop:is-sorted-by-bool, r=Mark-Simulacrum REVERT: 72277be9b25 Rollup merge of #116090 - rmehri01:strict_integer_ops, r=m-ou-se REVERT: 7c212a197c4 Add test of thread_local containing multiline const block REVERT: 1ad5a9f60e6 Revert example change from PR 116392 REVERT: 7d0b4aa8f9d Allow any expression blocks in `thread_local!` REVERT: 0557f84f674 Document some alternatives to `Vec::split_off` REVERT: c00eb4b3994 Auto merge of #111803 - scottmcm:simple-swap-alternative, r=Mark-Simulacrum REVERT: c5c67ba3dbe Use bool instead of PartiolOrd in is_sorted_by REVERT: ef34f567c18 Auto merge of #120170 - GuillaumeGomez:rollup-edqdf30, r=GuillaumeGomez REVERT: 2064f2510ed Rollup merge of #120169 - sunrosa:patch-1, r=ChrisDenton REVERT: 60a75d68d47 Rollup merge of #120116 - the8472:only-same-alignments, r=cuviper REVERT: 1d3cd7878b6 Spelling fix REVERT: 0a10291827a Auto merge of #117756 - a1phyr:hashmap_fold, r=the8472 REVERT: 4a65f9e5eaa core: introduce split_at{,_mut}_checked REVERT: cf61a2db8f6 doc: fix some doctests after rebase REVERT: 93271858315 refactor: make waker mandatory. REVERT: 9b8ba34b6cb chore: make method order consistent with waker REVERT: 9acef64de0e docs: remove recommendations to use LocalWaker in stable API documentation REVERT: a71c8c936d8 fix: Apply suggestions from code review REVERT: febe058f73e doc: update thread safety explanation for RawWakerVTable and RawWaker. REVERT: 3fd20a44128 chore: add and !Sync impls for LocalWaker as a stability guarantee. REVERT: b0547247c8b fix: change issue number of waker_getters from #87021 to #96992. REVERT: bb4ad58bd8f chore: fix ci failures REVERT: 4b7b659d20e feat: impl AsRef for Waker. REVERT: 432a01ecec8 chore: add tracking issue number to local waker feature REVERT: 6ba5dc669a6 fix: make LocalWake available in targets that don't support atomics by removing a #[cfg(target_has_atomic = ptr)] REVERT: 052f069c462 feat: add try_waker and From<&mut Context> for ContextBuilder to allow the extention of contexts by futures REVERT: cf29047a5ff refactor: remove in favor of and to make the API infallible. REVERT: f24bf6ab54c perf: move null check from local_wake() to build() REVERT: 1ad5491c260 feat: add LocalWaker type, ContextBuilder type, and LocalWake trait. REVERT: d295bbf607b Rollup merge of #120150 - Jules-Bertholet:stabilize-round-ties-even, r=cuviper REVERT: 5f72ef24217 Rollup merge of #118799 - GKFX:stabilize-simple-offsetof, r=wesleywiser REVERT: 84aae4383bd Rollup merge of #113142 - the8472:opt-cstr-display, r=Mark-Simulacrum REVERT: ce50b33c45d Rollup merge of #103730 - SOF3:nonzero-from-mut, r=Mark-Simulacrum,dtolnay REVERT: 2868c19d555 Tweak the threshold for chunked swapping REVERT: 1d65033411e Stabilize `round_ties_even` REVERT: fc7d4487e16 fix: Drop guard was deallocating with the incorrect size REVERT: 4214a0e97d1 Assign tracking issue number for feature(nonzero_from_mut) REVERT: 157938620f9 Added assert_unsafe_precondition! check for NonZeroXxx::from_mut_unchecked REVERT: 42e8195716c Added NonZeroXxx::from_mut(_unchecked)? REVERT: 8defadbe91e Consolidate logic around resolving built-in coroutine trait impls REVERT: 0a9220c2d58 Remove feature(offset_of) from tests REVERT: 5b6e4e1eb90 Stabilize simple offset_of REVERT: 67c98f05f0a Clarify Panicking Behavior in Integer Division Docs REVERT: f757552a9eb Make `saturating_div` Docs Consistent with Others REVERT: 34b9aa86715 Adjust Attributes of Integer Division Methods REVERT: 4e590d48356 Fixes from PR REVERT: 01dc5c7f84a Use heap for stdout and stderr REVERT: 0143efa9499 Improve UEFI stdio REVERT: 424538e7055 Add new intrinsic `is_constant` and optimize `pow` REVERT: 2524d248f21 Rollup merge of #119984 - kpreid:waker-noop, r=dtolnay REVERT: 949da0cfb0f Rollup merge of #117561 - tgross35:split-array, r=scottmcm REVERT: f3780a206b3 Rollup merge of #120110 - invpt:patch-1, r=the8472 REVERT: 073205404f4 Rollup merge of #120107 - shepmaster:dead-code-repr-transparent, r=Nilstrieb REVERT: 295d9cef5dc Rollup merge of #119907 - asquared31415:fn_trait_docs, r=Nilstrieb REVERT: 8c13e47be3d Rollup merge of #119138 - AngelicosPhosphoros:use_proper_atomics_in_spinlock_example, r=Nilstrieb REVERT: 5c14aedd531 Rollup merge of #118798 - GnomedDev:use-atomicu8-backtrace, r=Nilstrieb REVERT: fd256ba9af5 Rollup merge of #118665 - dtolnay:signedness, r=Nilstrieb REVERT: b3d7856b673 Clarify docs for Vec::into_boxed_slice, Vec::shrink_to_fit REVERT: 9f60238563e Update `std::io::Error::downcast` return type REVERT: 2f659eefdc0 remove alignment-changing in-place collect REVERT: e4d9e439376 update internal ASCII art comment for vec specializations REVERT: 3e8c0fdbe12 Add `display` method to `OsStr` REVERT: 9e4ad631a31 Remove no-longer-needed `allow(dead_code)` from the standard library REVERT: 2e4eb7e79a4 Add `A: 'static` bound for `Arc/Rc::pin_in` REVERT: 4bd26dd0c1a Remove unnecessary `let`s and borrowing from `Waker::noop()` usage. REVERT: 5d45721aa96 Change return type of unstable `Waker::noop()` from `Waker` to `&Waker`. REVERT: 385a68a1dfb Rollup merge of #120044 - Storyyeller:patch-2, r=lqd REVERT: 7a001af8b6b Rollup merge of #119855 - rellerreller:freebsd-static, r=wesleywiser REVERT: e858fc37b51 specialize `Bytes` on `StdinLock<'_>` by using the underlying `BufReader` REVERT: d0c3feaf9c9 Un-hide `iter::repeat_n` REVERT: d37c75ac86e Auto merge of #119651 - novafacing:proc_macro_c_str_literals, r=Amanieu REVERT: 2f153831fd7 Fix typo in comments (in_place_collect) REVERT: 2d1669366a6 Auto merge of #120019 - lcnr:fn-wf, r=BoxyUwU REVERT: d009b0dbf95 proc_macro_c_str_literals: Implement Literal::c_string constructor REVERT: 03b17c7b528 Suggest less bug-prone construction of Duration in docs REVERT: 7b7ac99ea50 Rename `pointer` field on `Pin` REVERT: ee87b72f2fe Auto merge of #120025 - matthiaskrgr:rollup-e9ai06k, r=matthiaskrgr REVERT: 6743c06f3ca Rollup merge of #119990 - reitermarkus:nonzero-type-alias, r=dtolnay REVERT: aea5a3165e6 Rollup merge of #118361 - Dylan-DPC:80626/stab/bound-map, r=Amanieu REVERT: bcb48a166c5 Auto merge of #119954 - scottmcm:option-unwrap-failed, r=WaffleLapkin REVERT: f79fca48a1d borrowck: use implied bounds from impl header REVERT: e1ccdadb9fc borrowck: wf-check fn item args REVERT: 2465bdc6766 Revert unrelated changes from PR 119990 REVERT: cebd2c10e36 Auto merge of #119987 - matthiaskrgr:rollup-f7lkx4w, r=matthiaskrgr REVERT: d55452ccecb std: move OS String implementation into `sys` REVERT: a840749533f Add private `NonZero` type alias. REVERT: 87aece9ca61 Auto merge of #119878 - scottmcm:inline-always-unwrap, r=workingjubilee REVERT: 0601d24fad1 Rollup merge of #119870 - behnam-oneschema:lazylock-blocking-1, r=tgross35,ChrisDenton REVERT: 9b3d8486cc3 std::net: bind update for using backlog as `-1` too. REVERT: a4079c95c7a Auto merge of #119970 - GuillaumeGomez:rollup-p53c19o, r=GuillaumeGomez REVERT: 4cc56d58ef3 Unbreak tidy's feature parser REVERT: 7c783a11672 Move BITS into omnibus impl block REVERT: c59a7ecc689 Move signed MIN and MAX into signedness_dependent_methods REVERT: 7ca319888b9 Move unsigned MIN and MAX into signedness_dependent_methods REVERT: b358734e9f7 Move is_power_of_two into unsigned part of signedness_dependent_methods REVERT: 9eca5314072 Move nonzero_unsigned_signed_operations methods into the omnibus impl block REVERT: a520aed9340 Work around rustfmt doc attribute indentation bug REVERT: 5c9c8ff75cc Unindent nonzero_integer_signedness_dependent_methods macro body REVERT: d16b436e0f1 Move signedness dependent methods into the omnibus impl block REVERT: e385921bd6c Move Neg impl into the macro that generates Div and Rem REVERT: 07b7834c1d5 Split out `option::unwrap_failed` like we have `result::unwrap_failed` REVERT: 66f98585e22 Move leading_zeros and trailing_zeros methods into nonzero_integer macro REVERT: 2751fa6e881 Unindent nonzero_integer_impl_div_rem macro body REVERT: 1ba20b7f66e Move impl Div and Rem into nonzero_integer macro REVERT: 8dea5137635 Move 'impl FromStr for NonZero' into nonzero_integer macro REVERT: 6b4801aabe1 Format nonzero_integer macro calls same way we do the primitive int impls REVERT: fcb89f8ac8d Unindent nonzero_integer macro body REVERT: 77efbae19d7 Define only a single NonZero type per macro call REVERT: 89e81725212 Move nonzero_integers macro call to bottom of module REVERT: 600fcda6b42 Rollup merge of #119742 - Meziu:armv6k-nintendo-3ds, r=Mark-Simulacrum REVERT: 38a346e00ed Auto merge of #119796 - androm3da:bcain/compiler_builtins_0_1_105, r=Mark-Simulacrum REVERT: d62f5560c21 std: Doc blocking behavior of LazyLock methods REVERT: 23b47d19431 Rollup merge of #119949 - clubby789:spec-newtype-comment, r=nnethercote REVERT: f8f7724f01d Merge from rustc REVERT: 23e4bd47901 Add note on SpecOptionPartialEq to `newtype_index` REVERT: 3b43724b864 Rollup merge of #119935 - joboet:move_pal_personality, r=ChrisDenton REVERT: 258cbe9c68a libs: use `assert_unchecked` instead of intrinsic REVERT: 6a00c344109 Refactor uses of `objc_msgSend` to no longer have clashing definitions REVERT: 6f59033bd1c xous: thread: mark thread_main() as divergent REVERT: 8a82ba6ee1f std: xous: use constants for stdout and stderr REVERT: 3f1a7739b95 std: xous: mark stdio structs as `repr(C)` REVERT: 0652860e3c5 xous: net: initial commit of network support REVERT: 1d86ee981fc std: move personality implementation out of PAL REVERT: 95284ccd50e std: xous: share allocator symbol in tests REVERT: a17a5ba8802 std: xous: fix thread_local_key under tests REVERT: c20f22fb0a0 std: once: use queue implementation on Xous REVERT: d52b1de64e9 std: xous: rewrite rwlock to be more robust REVERT: 5a68d2d9c7c std: xous: use blocking_scalars for mutex unlock REVERT: 55a1c19ec9c std: xous: pass entire memory range to flag updater REVERT: bc986a1e00f std: xous: rework condvar to fix soundness issues REVERT: 924dd068835 xous: std: thread_parking: fix deadlocks REVERT: f49c4f8355e xous: ffi: correct size of freed memory REVERT: 2e66b566ade xous: ffi: fix lend_impl() return values REVERT: 46d53d9909d Auto merge of #119927 - matthiaskrgr:rollup-885ws57, r=matthiaskrgr REVERT: 932024c0137 Auto merge of #117285 - joboet:move_platforms_to_pal, r=ChrisDenton REVERT: 55cc0cb053a Rollup merge of #119902 - asquared31415:patch-1, r=the8472 REVERT: ee2c8b7df7c don't break a good link REVERT: 76bec372d02 Remove special-case handling of `vec.split_off(0)` REVERT: 76ef081651d Merge from rustc REVERT: c95730fbf75 update fn pointer trait impl docs REVERT: be91e4e1dce fix typo in `fn()` docs REVERT: 75a6517648b Auto merge of #119452 - AngelicosPhosphoros:make_nonzeroint_get_assume_nonzero, r=scottmcm REVERT: 5953e82dd07 Tune the inlinability of `Result::unwrap` REVERT: c6a3eaf3c3e Auto merge of #118548 - Enselic:bench-padding, r=thomcc,ChrisDenton REVERT: e4fca3cecb7 Auto merge of #119430 - NCGThompson:int-pow-bench, r=cuviper REVERT: f50fbfa704a update paths in comments REVERT: d384d7b2591 std: fix module references on Windows REVERT: 1d604c6717b std: fix module references on UNIX REVERT: 0e8b29eb4e8 std: fix module references on UEFI REVERT: ceac4ee3f9e std: fix module reference on SGX REVERT: 1e55abb8048 std: fix module references on hermit REVERT: 5928134d56c std: begin moving platform support modules into `pal` REVERT: 41aef6f2361 Reduced amount of int_pow benches REVERT: b3ce577b310 Rollup merge of #119853 - klensy:rustfmt-ignore, r=cuviper REVERT: db446b136b3 Rollup merge of #119845 - RalfJung:rint, r=nagisa REVERT: 43f65553095 Rollup merge of #119836 - hi-rustin:rustin-patch-docs-blank-line, r=ChrisDenton REVERT: d6f132376a7 Waker::will_wake: Compare vtable address instead of its content REVERT: cdc006f9e95 Edited int_pow micro-benchmarks REVERT: 8f4a7615f88 Added int_pow micro-benchmarks REVERT: 30b1acf531b removed nonfunctioning benchmark REVERT: d52e4a3c1fe Enable Static Builds for FreeBSD REVERT: c32d9c83dd6 rint: further doc tweaks REVERT: 2c7de7eb129 apply fmt REVERT: 321cbbba899 Merge from rustc REVERT: d3a4034cac1 Rollup merge of #119804 - tmccombs:stabilize-unpoison, r=cuviper REVERT: a29b2b039cf chore: remove unnecessary blank line REVERT: b3641829771 Make is_global/is_unicast_global special address handling complete REVERT: 38bc6461d81 Implement in-place iteratation markers for iter::{Copied, Cloned} REVERT: ccc1d9cabb3 bench trustedrandomaccess specialization in zip REVERT: c972ef2cf0c implement TrustedRandomAccess and TrustedLen for Skip REVERT: f3f403fe26d implement TrustedLen for StepBy REVERT: c11faa9a499 Stabilize mutex_unpoison feature REVERT: d2a67a72d07 Add `#[track_caller]` to the "From implies Into" impl REVERT: bff816467b4 Fix deallocation with wrong allocator in (A)Rc::from_box_in REVERT: f441f696ebd Stabilize `slice_first_last_chunk` REVERT: 134d6c24e78 Rollup merge of #119782 - RalfJung:rint, r=cuviper REVERT: abb6e68bb51 Update compiler_builtins to 0.1.105 REVERT: 1d8f313ca51 rint intrinsics: caution against actually trying to check for floating-point exceptions REVERT: dff91e465d5 Auto merge of #116846 - krtab:slice_compare_no_memcmp_opt, r=the8472 REVERT: 56d044dc202 Rollup merge of #119768 - ojeda:panic-link, r=Nilstrieb REVERT: 2db40bbb610 Rollup merge of #118645 - Patryk27:bump-compiler-builtins, r=Nilstrieb,dtolnay REVERT: ccdd384dcee Rollup merge of #118241 - fortanix:raoul/gh-530-make_userspace_types_send, r=Nilstrieb,dtolnay REVERT: e5fb3c0d094 core: panic: fix broken link REVERT: 1324f97b713 Rollup merge of #118748 - devnexen:fbsd_getrandom_simpl, r=Nilstrieb,dtolnay REVERT: 666c087f440 Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwco REVERT: a26532867f6 Backlog for HorizonOS UnixListener REVERT: 74028078fce Rollup merge of #119632 - ivmarkov:master, r=Nilstrieb,dtolnay REVERT: c5c2ee79451 Rollup merge of #118979 - ChrisDenton:unwrap-const, r=Nilstrieb,dtolnay REVERT: d29ecd71db4 Rollup merge of #119598 - Laura7089:fix/deref-typo, r=Nilstrieb REVERT: df2f0536d66 Increase visibility of `join_path` and `split_paths` REVERT: e2796e7ec35 A more efficient slice comparison implementation for T: !BytewiseEq REVERT: f979c9dce4d Rollup merge of #116129 - fu5ha:better-pin-docs-2, r=Amanieu REVERT: acbcab24adc link REVERT: c74f4014817 Update library/core/src/pin.rs REVERT: 527e1385b03 clean up structural pinning REVERT: 582c5b3a969 footnote on dropping futures REVERT: 306ea655154 valid REVERT: 87f4c89ad6b punctuation in parens REVERT: 5d8e0ffb49e Apply suggestions from code review REVERT: 55605c0185c Clean up guarantees wording REVERT: 904f3d00138 lifetime -> lifespan where relevant. improve docs on as_ref() REVERT: 326f8dc4613 Rephrase unpin docs in terms of pinning-agnosticness REVERT: a986d4c7f85 trim section on managed-box model REVERT: fb0cd1f016a improve `Pin::new_unchecked` docs REVERT: 6a3f06c8529 fix broken link REVERT: 3d87bffdc38 justify motivation of `Unpin` better REVERT: 7fa26795035 improve `Pin` and `Pin::new` docs REVERT: d324b8ac470 `Pin

` -> `Pin` REVERT: 0729258cc76 fix typos and edit prose REVERT: a79cc888bd2 edit new section for typos and better wording REVERT: a29ae4491f5 fix imports REVERT: da3f0ab6c16 fix typos REVERT: eaadef32392 add section on manual owning ptr managed solution via @kpreid REVERT: e0dc5cac99f improve structural Unpin + formatting REVERT: 0dab223a0c3 reword unpin auto impl section REVERT: 1398b9716c0 fix link in footnote REVERT: fec615ee43f improve `Pin` struct docs and add examples REVERT: 6ba492dd4cf improve intro and discussion of pinning as library contract REVERT: 8202a77523f improve intro and `Unpin`-related discussion REVERT: f59dcd27024 update doubly linked list commentary and fix links REVERT: cda3659f22f fix one more broken link REVERT: 8379a97bfe5 fix broken links REVERT: 351f30df578 Fix examples, finish polishing REVERT: f7584d3df7d mostly done REVERT: 8d0638f5faf Rewrite `Pin

` docs to clarify guarantees and uses REVERT: c43f3f34b39 rc,sync: Do not create references to uninitialized values REVERT: 0998d9300d7 Update test for `E0796` and `static_mut_ref` lint REVERT: 44be1f226de Auto merge of #114205 - the8472:vec-iter-nonnull, r=scottmcm REVERT: 03b9424cf32 Rollup merge of #119657 - cls:slice_split_once-typo, r=ChrisDenton REVERT: 9b20d4739c5 Rollup merge of #119656 - RalfJung:round-docs, r=Mark-Simulacrum REVERT: 6b3d14fb7d9 mark vec::IntoIter pointers as `!nonnull` REVERT: adcee056568 typo fix REVERT: 6d449b39ec1 Auto merge of #119599 - marthadev:position, r=the8472 REVERT: 380981cb553 Rollup merge of #119624 - petrochenkov:dialoc4, r=compiler-errors REVERT: 49feaea1a78 Rollup merge of #119595 - mbbill:patch-1, r=Mark-Simulacrum REVERT: 432266c541c Rollup merge of #118781 - RalfJung:core-panic-feature, r=the8472 REVERT: 9af3b718ef0 Add assume into `NonZeroIntX::get` REVERT: 31b9ad99c0d document rounding behavior of rint/nearbyint for ties REVERT: 25e551e0d4d Fix typo in docs for slice::split_once, slice::rsplit_once REVERT: f2f435c939d Rollup merge of #119642 - petrochenkov:winstdtest, r=ChrisDenton REVERT: 47bdaac3037 Rollup merge of #119640 - petrochenkov:rtstartup, r=Mark-Simulacrum REVERT: 4e5d31bfda0 Rollup merge of #119216 - weiznich:use_diagnostic_namespace_in_stdlib, r=compiler-errors REVERT: 4de07e2d01d library: Fix a symlink test failing on Windows REVERT: 78ec01857a5 Remove feature not required by `Ipv6Addr::to_cononical` doctest REVERT: 69b154cf12e library: Fix warnings in rtstartup REVERT: 358c36f9c3e Fix broken build for ESP IDF due to #119026 REVERT: 9ef88bd83b3 library: Add `allow(unused_assignments)` to custom MIR doctest REVERT: 06331ab8666 Rollup merge of #119583 - AngelicosPhosphoros:const_assume, r=RalfJung REVERT: 52981cc7823 Fix #119551: Rewrite Iterator::position default impl, storing the accumulating value outside of the fold in an attempt to improve code generation REVERT: 1db1f12a61a Replace some usage of `#[rustc_on_unimplemented]` with `#[diagnostic::on_unimplemented]` REVERT: 1ac13e79978 Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkin REVERT: 2c018a362ad Fix a typo in core::ops::Deref's doc REVERT: 610eaa974bb Fixed ambiguity in hint.rs REVERT: ab8814d3da2 Auto merge of #119569 - matthiaskrgr:rollup-4packja, r=matthiaskrgr REVERT: 4dc7fe961ba Make `intrinsics::assume` const stable REVERT: 922189472e3 Rollup merge of #119532 - GKFX:offset-of-parse-expr, r=est31 REVERT: 8e0797381b3 Rollup merge of #119475 - saethlin:remove-libtest-dylib, r=cuviper REVERT: de7ad758d57 Rollup merge of #119325 - RalfJung:custom-mir, r=compiler-errors REVERT: 8f5d5b644a9 Rollup merge of #119026 - devnexen:listener_upd, r=Mark-Simulacrum REVERT: cdf9ca6265b Rollup merge of #119534 - tgross35:thread-local-example-updates, r=JohnTitor REVERT: 331bd8ee9be Rollup merge of #119434 - taiki-e:rc-is-dangling, r=Mark-Simulacrum REVERT: 713047af3a6 Rollup merge of #119319 - chfogelman:buffered-file-doc, r=the8472 REVERT: 70d644c6a07 Update `thread_local` examples to use `local_key_cell_methods` REVERT: e2fb33b8a70 Make `Barrier::new()` const REVERT: e8ee49d17e3 Make offset_of field parsing use metavariable which handles any spacing REVERT: 10ef78ceba0 Adjust library tests for unused_tuple_struct_fields -> dead_code REVERT: 9c7d30658aa Document that File does not buffer reads/writes, refer to BufReader/BufWriter REVERT: 09a43574e0a Clarify ambiguity in select_nth_unstable docs REVERT: 53f1b6c23a1 Remove libtest's dylib REVERT: 583698320e6 Initial implementation of `str::from_raw_parts[_mut]` REVERT: a9ad6382bd8 Auto merge of #119436 - semarie:openbsd-available_parallelism, r=Mark-Simulacrum REVERT: cd322214c1d Rollup merge of #119424 - ojeda:send-sync, r=est31 REVERT: ac5be150204 Rollup merge of #119386 - Emilgardis:typo-ipaddr-canonical-doc, r=est31 REVERT: 62e42d8213d Rollup merge of #119158 - JohnTheCoolingFan:arc-weak-clone-pretty, r=cuviper REVERT: c7633debf2c openbsd: available_parallelism: use the right API REVERT: 27efe874907 rc: Take *const T in is_dangling REVERT: 18d0d684a94 Primitive docs: fix confusing `Send` in `&T`'s list REVERT: 6d1c60ee72b Italicise "bytes" in the docs of some `Vec` methods REVERT: b975bbe3946 fix typo REVERT: dcaa0b32408 custom mir: better type-checking REVERT: cc4ab45bdda custom mir: make it clear what the return block is REVERT: 5851572ab7c explain what crates should do when adding comparison with foreign types REVERT: 58a22dcf123 PartialOrd: transitivity and duality are required only if the corresponding impls exist REVERT: a4589ab0232 PartialEq: handle longer transitive chains REVERT: 832f55958ae Rollup merge of #119235 - Urgau:missing-feature-gate-sanitizer-cfi-cfgs, r=Nilstrieb REVERT: e01f231b841 Auto merge of #119133 - scottmcm:assert-unchecked, r=thomcc REVERT: 3ca61c9017e Auto merge of #119313 - matthiaskrgr:rollup-41x48j6, r=matthiaskrgr REVERT: 73ae685e38c select AsyncFn traits during overloaded call op REVERT: 5a6283fe846 We do not need impl_trait_in_assoc_ty REVERT: 2b6546b56f2 Add AsyncFn family of traits REVERT: 24bd2a138da Fix doc typo for read_exact_at REVERT: 4a91168bdb3 Documented unsafe blocks REVERT: df11fd7e44e Removed redundant bounds checking at Split's next and next_mut methods REVERT: 07e5d87af42 Stabilize ip_in_core feature REVERT: bf6e190ea6c std::net::bind using -1 for openbsd which in turn sets it to somaxconn. REVERT: 9e9d274b0a9 Rollup merge of #119205 - mumbleskates:vecdeque-comment-fix, r=Mark-Simulacrum REVERT: 02e7da0aa59 Rollup merge of #119153 - rursprung:stabilize-file_create_new, r=dtolnay REVERT: cbd07e0a520 Rollup merge of #119222 - eholk:into-async-iterator, r=compiler-errors,dtolnay REVERT: 08f7db22dd4 Auto merge of #119211 - rust-lang:pa-master-1.77, r=Mark-Simulacrum REVERT: 6cad6fd3791 Adjust the std library for sanitizer_cfi cfgs changes REVERT: 371744a6ba2 Use `IntoAsyncIterator` in `for await` loop desugaring REVERT: b5727e3fd6e Add IntoAsyncIterator REVERT: 4e13ec90805 Auto merge of #118847 - eholk:for-await, r=compiler-errors REVERT: 85508cf881c update cfg(bootstrap)s REVERT: 8aa2c6da86a update version placeholders REVERT: 76423671a8c fix minor mistake in comments describing VecDeque resizing REVERT: fb724c0df28 Auto merge of #119037 - RalfJung:repr-c-abi-mismatch, r=scottmcm REVERT: 1fe07466f72 Cleaned up alloc::sync::Weak Clone implementation REVERT: b09db1fa516 stabilize `file_create_new` REVERT: a81f8ac022e Auto merge of #106790 - the8472:rawvec-niche, r=scottmcm REVERT: 96384e21e4a Add `hint::assert_unchecked` REVERT: e227698963d Docs: Use non-SeqCst in module example of atomics REVERT: 7eb354da370 Desugar for await loops REVERT: 5aba25f768c Auto merge of #118853 - calebzulawski:simd-intrinsics, r=RalfJung REVERT: 645f4a9c20b Disable new intrinsics for bootstrap REVERT: b4331117d1c Add Ipv6Addr::is_ipv4_mapped REVERT: 936613cab1f Rollup merge of #119051 - ChrisDenton:wine, r=workingjubilee REVERT: 67f5ff7f4f0 Add new intrinsics REVERT: 4bd41ac3745 Further explain semantics REVERT: ac40140f02a Apply suggestions from code review REVERT: 75ecea3b0af Improve simd_bitmask documentation and other minor fixes REVERT: e21cb4d70b8 State type requirements first REVERT: 653b295ded2 Clarify UB and improve grammar REVERT: 06ce06bba99 Add core::intrinsics::simd REVERT: 1893d461a79 Auto merge of #114962 - darklyspaced:debug, r=est31 REVERT: 867bc885df0 Use FileEndOfFileInfo, not FileAllocationInfo REVERT: 209ffe5fd61 do not allow ABI mismatches inside repr(C) types REVERT: 8b4de1bdf9e Auto merge of #118830 - GuillaumeGomez:env-tracked_env, r=Nilstrieb REVERT: 2e29350f0cc Rollup merge of #118851 - bzEq:std-xcoff, r=Mark-Simulacrum REVERT: e88c7e301b1 Rollup merge of #118523 - okaneco:trim_ascii, r=Mark-Simulacrum REVERT: d09b5fb5389 Rollup merge of #118998 - jstasiak:improve-doc, r=workingjubilee REVERT: 5d3a2ffe537 Rollup merge of #118956 - danielhuang:patch-2, r=workingjubilee REVERT: 3f906cd58c5 Rollup merge of #118396 - compiler-errors:ast-lang-items, r=cjgillot REVERT: b58705c675d Add link to is_benchmark from the Ipv6Addr::is_global documentation REVERT: a1ec8a04c0a Rollup merge of #118234 - tgross35:type_name_of_value, r=dtolnay REVERT: 0dc0ee5e0db Stabilize `ptr::{from_ref, from_mut}` REVERT: 75850ee00f0 Cfg remove lang items in doctest REVERT: de9d630fefa Use assert_unsafe_precondition for char::from_u32_unchecked REVERT: 3201319d1a4 Auto merge of #118966 - matthiaskrgr:rollup-sdvjwy6, r=matthiaskrgr REVERT: e69c55f1915 Rollup merge of #116888 - tbu-:pr_unsafe_env, r=Amanieu REVERT: 0016fb262a0 Auto merge of #118770 - saethlin:fix-inline-never-uses, r=nnethercote REVERT: 9d61bf9a8f7 Update c_str.rs REVERT: a291d755cec Update c_str.rs REVERT: ead77e1bb9d Fix target_feature config in portable-simd REVERT: 765f33b45c1 Fix cases where std accidentally relied on inline(never) REVERT: b745bf64490 Auto merge of #118566 - klensy:cstr-new, r=WaffleLapkin REVERT: bc80b0ca11c Reformulate `std::env::{set,remove}_env` as safety note REVERT: e7905e96cf0 Auto merge of #117050 - c410-f3r:here-we-go-again, r=petrochenkov REVERT: 0264e5a1128 Auto merge of #118900 - workingjubilee:rollup-wkv9hq1, r=workingjubilee REVERT: 12f558a21a5 Rollup merge of #118873 - lukas-code:fix_waker_getter_tracking_issue_number, r=workingjubilee REVERT: 14fa829c879 Rollup merge of #118858 - mu001999:dead_code/clean, r=cuviper REVERT: a99042aae12 Auto merge of #116438 - ChrisDenton:truncate, r=thomcc REVERT: fc8ea3d2d8a Use different cfg for AIX REVERT: 0ce772afa8b Add ASCII whitespace trimming functions to `&str` REVERT: 29a20ae0950 fix `waker_getters` tracking issue number REVERT: 1303ff78792 added column number to dbg!() REVERT: 0d01fb98fbc Remove dead codes in core REVERT: 26355968bc9 Add xcoff support REVERT: d1161819ae3 add comment to RawVec::cap field REVERT: cda08d760a9 add more niches to rawvec REVERT: ff972740941 Updating fs::read example to remove SocketAddress REVERT: ebe4c0ebe0a fixing error std::fs::read_to_string example documentation REVERT: 8d0bce7eb34 Add support for `--env` on `tracked_env::var` REVERT: 362840c0a15 Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwco REVERT: 4404fa8b498 Auto merge of #118823 - GuillaumeGomez:rollup-6v51gxv, r=GuillaumeGomez REVERT: 092154854a1 Rollup merge of #118807 - SUPERCILEX:allo, r=the8472 REVERT: ea46fb67805 Auto merge of #118661 - fee1-dead-contrib:restore-const-partialEq, r=compiler-errors REVERT: fb347dd6e93 Auto merge of #118032 - RalfJung:char-u32, r=Mark-Simulacrum REVERT: c6a1b36995f Improve `print_tts` by changing `tokenstream::Spacing`. REVERT: 52167fd5cce Remove an allocation in min_stack REVERT: b2a0e58f836 Auto merge of #118692 - surechen:remove_unused_imports, r=petrochenkov REVERT: 86a04b47c2a Use AtomicU8 instead of AtomicUsize in backtrace.rs REVERT: 3ed6ee8cb4f Restore `const PartialEq` REVERT: 326b6e41991 Auto merge of #118792 - naglis:fix-mutex-doc-typo, r=workingjubilee REVERT: 5cd42bacf6c Auto merge of #116949 - hamza1311:stablize-arc_unwrap_or_clone, r=dtolnay REVERT: 31a1d2a045c remove redundant imports REVERT: 5699bfb8dff Fix typo in `std::sync::Mutex` example REVERT: d25534fab84 merge core_panic feature into panic_internals REVERT: f076903f044 Auto merge of #117873 - quininer:android-emutls, r=Amanieu REVERT: 6a7207d2985 Auto merge of #114136 - TennyZhuang:linked-list-retain, r=thomcc REVERT: 65dcc58d1fc Implement `async gen` blocks REVERT: 682baa51dfe std: getrandom simplification for freebsd. REVERT: dd7d9ab20a3 Rollup merge of #118581 - ianrrees:add-drop-note-to-once_lock, r=workingjubilee REVERT: 2f37d21e6d4 Rollup merge of #118505 - CLEckhardt:update_ip_addr_bits_docs, r=cuviper REVERT: 702fe07987c OnceLock: Rework example, statics aren't dropped REVERT: 5efbbf46076 libtest: Fix padding of benchmarks run as tests REVERT: ad95354decd Introduce explanation about fields being used in ordering REVERT: a2529912de8 Elaborate on ip_addr bit conversion endianness REVERT: 9d5995869ac Auto merge of #116565 - Sword-Destiny:master, r=Amanieu REVERT: a4e3239c0eb add teeos std impl REVERT: 92eecd31c7a Auto merge of #117960 - zhiqiangxu:dry, r=workingjubilee REVERT: a6876a9a090 Rollup merge of #118669 - klensy:comment-fix, r=workingjubilee REVERT: 1db0463a465 Rollup merge of #117563 - 0xalpharush:docs/into-raw, r=workingjubilee REVERT: 2cb5974e95a Add emulated TLS support REVERT: 02e3a5b558f library: fix comment about const assert in win api REVERT: 4184a83281f Auto merge of #118460 - the8472:fix-vec-realloc, r=saethlin REVERT: f40f7b60d16 Adjust tests for newly added ambiguous_wide_pointer_comparisons lint REVERT: c6d0863b892 Allow ambiguous_wide_pointer_comparisons lint for std methods REVERT: cc32febdd2f Auto merge of #118655 - compiler-errors:rollup-vrngyzn, r=compiler-errors REVERT: 906be37005f Auto merge of #117072 - betrusted-io:unwinding-crate-support, r=cuviper REVERT: ac9937c7cf3 std: xous: take eh_frame address from main args REVERT: 6e0aa516b32 Don't repeat yourself REVERT: e1df5c889cf fmt REVERT: 958c3874ef1 Auto merge of #118547 - alexcrichton:invert-common-net-inclusion, r=workingjubilee REVERT: c19706ca784 Specify behavior if the closure passed to *Guard::*map panics. REVERT: 7eef08f813e fix MappedMutexGuard::(try_)map doc typo. REVERT: 360eb8ec3e2 Add MappedMutexGuard and MappedRwLock*Guard tests. REVERT: 7a18e61477f Fix Condvar typo, add public re-exports of Mapped*Guard. REVERT: 53a341467ba Add comment about `Mapped(Mutex|RwLockWrite)Guard` variance. REVERT: aa5ef631181 Auto merge of #118273 - AngelicosPhosphoros:dedup_2_loops_version_77772_2, r=the8472 REVERT: 9b32093edd9 Implmement `MappedRwLock(Read|Write)Guard`. REVERT: 74d02c1fe17 Implement `MappedMutexGuard`. REVERT: 4c7e6b59aa5 Allow cloning `poison::Guard`s. REVERT: 82a421f46ed Split `Vec::dedup_by` into 2 cycles REVERT: 1bde123f9c7 Rollup merge of #118450 - marcin-serwin:master, r=workingjubilee REVERT: a6cc97dd1a6 Rollup merge of #118350 - DaniPopes:tuple-default, r=workingjubilee REVERT: 01e8141e11d Rollup merge of #118123 - RalfJung:internal-lib-features, r=compiler-errors REVERT: 1f32217d579 Rollup merge of #117793 - wdunicornpro:patch-1, r=workingjubilee REVERT: d61287a6843 Stabilize `type_name_of_val` REVERT: c67493204ca Fix in-place collect not reallocating when necessary REVERT: b0a10c924e7 chore: Bump compiler_builtins REVERT: 3c7cfa9d1b2 Auto merge of #118362 - RalfJung:panic_nounwind, r=thomcc REVERT: eea1c82d178 Remove useless `'static` bounds on `Box` allocator REVERT: da07686e178 Rollup merge of #118591 - RalfJung:portable-simd-build-fix, r=workingjubilee,calebzulawski REVERT: 4c9a21410d9 Specialize `count` too REVERT: 2d3860a3d57 `HashMap`/`HashSet`: forward `fold` implementations of iterators REVERT: 4a6d35afb1e portable-simd: add missing feature gate REVERT: ed4b5a1fec9 Improve example in `slice::windows()` doc REVERT: 11217daa1be Auto merge of #116915 - bend-n:unwet, r=saethlin REVERT: 5547e8d0c3a use `assume(idx < self.len())` in `[T]::get_unchecked` REVERT: 0456f5650e8 move calling miri_promise_symbolic_alignment to a shared helper REVERT: 69339656e73 miri: support 'promising' alignment for symbolic alignment check REVERT: 2dc74f25914 library: use c string literals REVERT: cd14f7f12af Auto merge of #118487 - RalfJung:exposed-provenance, r=thomcc REVERT: a7ee0e8ba5c Auto merge of #118128 - RalfJung:bad-intrinsics, r=the8472 REVERT: a4acf531541 Auto merge of #118484 - blyxxyz:os-str-slice, r=BurntSushi REVERT: a688cd609d2 std: Invert logic for inclusion of `sys_common::net` REVERT: 54a38d3ae41 Auto merge of #118077 - calebzulawski:sync-portable-simd-2023-11-19, r=workingjubilee REVERT: 2c4cf37961f Remove link to core::arch::x86_64 REVERT: 16acb23ce1f Add diagnostic item to PartialEq::{eq,ne} REVERT: 8aa069b682a Add substring API for `OsStr` REVERT: 1a59060becf Attempt to try to resolve blocking concerns REVERT: 4e215387927 Auto merge of #117248 - ChrisDenton:ci-symlink, r=m-ou-se REVERT: 6165bd36754 update addr docs REVERT: 44459bab083 move exposed-provenance APIs into separate feature gate and explain the relationship of Exposed Provenance and Strict Provenance REVERT: c25305de3c8 Remove `{,r}split_array_ref{,_mut}` methods from slices REVERT: 62f8953e200 Use OnceCell in cell module documentation REVERT: 3b36c19dbc0 Auto merge of #118315 - WaffleLapkin:don't-repeat_byte, r=m-ou-se REVERT: b5dda9dc0f3 Rollup merge of #118231 - RalfJung:const-raw-slice-empty, r=cuviper REVERT: ceefb973a9d Auto merge of #118433 - matthiaskrgr:rollup-fi9lrwg, r=matthiaskrgr REVERT: 8bee45e9d7c Rollup merge of #118383 - shepmaster:unused-tuple-struct-field-cleanup-stdlib, r=m-ou-se REVERT: 0a916c15608 Rollup merge of #118398 - mu001999:std/add_cfgs, r=thomcc REVERT: 8cb2cd4c3e0 Rollup merge of #118265 - RalfJung:memcpy, r=cuviper REVERT: 075e360d2a9 Rollup merge of #116839 - joboet:xous_thread_parking, r=m-ou-se REVERT: c0cbb816db5 Auto merge of #114841 - bvanjoi:fix-114814, r=cuviper REVERT: e82f18c604c Address unused tuple struct fields in the standard library REVERT: f8a09f1b0dc reword panic comments and add spaces to unlikely branches REVERT: 52ac5605dd6 Rollup merge of #118222 - the8472:copy-use-vec-write, r=m-ou-se REVERT: 97e02096d00 Rollup merge of #118193 - max-heller:command-typo, r=m-ou-se REVERT: 733c0c203d0 Auto merge of #110353 - the8472:in-place-flatten-chunks, r=cuviper REVERT: 784d67ad5a4 Rollup merge of #118397 - Zalathar:nonzero, r=WaffleLapkin REVERT: 227ddf59972 Rollup merge of #118314 - WaffleLapkin:rename_collectionstests, r=cuviper REVERT: 12f17fbdc27 Rollup merge of #118299 - frewsxcv:patch-2, r=cuviper REVERT: 86b61084bc7 Rollup merge of #118236 - ksw2000:update_mod_comment, r=cuviper REVERT: fd4d3df4cf4 Rollup merge of #115331 - the8472:chars_advance, r=cuviper REVERT: 093c29adba2 Add proper cfgs REVERT: 1937527d2ba Fix comments for unsigned non-zero `checked_add`, `saturating_add` REVERT: 166f26a805a optimize str::iter::Chars::advance_by REVERT: 47351b93698 benchmarks for Chars::advance_by REVERT: 85d916537b2 use the usual attributes for panic_misaligned_pointer_dereference REVERT: 4aed0409379 make sure panic_nounwind_fmt can still be fully inlined (e.g. for panic_immediate_abort) REVERT: 444ce11a4fb stabilise bound_map REVERT: 807a13a267d Auto merge of #118321 - WaffleLapkin:unspace-fn-pointer-fake-variadic, r=notriddle REVERT: ccf9058e113 Simplify Default for tuples REVERT: 02a6133a1c8 Auto merge of #118313 - WaffleLapkin:fixup_comments_in_some_nonzero_ops, r=thomcc REVERT: 82d58f6e744 Auto merge of #117697 - WaffleLapkin:non-null-convenience-ops, r=Amanieu REVERT: 7c9a4e935db unify read_to_end and io::copy impls for reading into a Vec REVERT: 264eca02f9e Add `is_aligned{,_to}` convenience methods to `NonNull` REVERT: c7cde9ab8ec Add `align_offset` convenience method to `NonNull` REVERT: b87ac32a530 Add `replace` and `swap` convenience methods to `NonNull` REVERT: 57f81c59ec9 Add `offset_from`-ish convenience methods to `NonNull` REVERT: cfe9d74c5c5 Add offset-ish convenience methods to `NonNull` REVERT: c6dc76d2fab Add read/write/copy convenience methods to `NonNull` REVERT: 5f59f6822f7 rustdoc: Remove space from fake-variadic fn ptr impls REVERT: b1b17feb129 Rollup merge of #118302 - mu001999:dead_code/clean, r=cjgillot REVERT: d934bc562be Update std::simd usage and test outputs REVERT: a728673c3fc Use inner docs to fix links REVERT: 97b4e129073 Fix library tests REVERT: 3f11433d444 Merge commit 'e0e9a4517f9fc021283514da387e70a56061bd3e' into sync-portable-simd-2023-11-19 REVERT: e0a80dae8a7 Use `usize::repeat_u8` instead of implementing `repeat_byte` in `memchr.rs` REVERT: 186061fe1b4 Rename `{collections=>alloc}{tests,benches}` REVERT: 1fe0fe646ae Improve some comments for non-zero ops REVERT: e90cb220c29 Making `User` and `User<[T]>` `Send` REVERT: a69bf0fe8b0 Auto merge of #110303 - nbdd0121:master, r=Mark-Simulacrum REVERT: 44a8bf585a3 Remove an unneeded helper from the tuple library code REVERT: 6bdcc8b2efe Clean dead codes REVERT: c57f81d68dd Address review feedback REVERT: 9798c745ed1 Convert many `assert_unsafe_precondition` to `debug_assert_nounwind` REVERT: 4332b228b5d Add `debug_assert_nounwind` REVERT: 4adf1ae0387 Rollup merge of #117968 - Urgau:stabilize-ptr-addr-eq, r=dtolnay REVERT: f4817b4c0c5 Update `OnceLock` documentation to give a concrete 'lazy static' example, and expand on existing example. REVERT: 68b6f3db188 Add more benchmarks of `Vec::dedup` REVERT: 250aa17cd87 Auto merge of #118138 - Nilstrieb:one-previous-error, r=WaffleLapkin REVERT: d09c09a7720 remove the memcpy-on-equal-ptrs assumption REVERT: 6406e64fa1b add `#[track_caller]` to improve panic locations REVERT: 1e12b75a190 implement strict_* operations for unsigned integer types REVERT: e3ecdb2cebe implement strict_* operations for signed integer types REVERT: 0f160fce3f8 Show number in error message even for one error REVERT: d50b12aa2f7 Rollup merge of #118238 - RalfJung:memcpy, r=Mark-Simulacrum REVERT: 6bc6797174e Auto merge of #118228 - Mark-Simulacrum:alloc-opt, r=scottmcm REVERT: eea97623121 memcpy assumptions: update GCC link REVERT: 6db637d8847 correct grammar REVERT: 77e3d4862e8 Auto merge of #118232 - matthiaskrgr:rollup-x8crvm0, r=matthiaskrgr REVERT: aedbd3865c8 Update comment for consistent context logic. REVERT: d6d6ce942fc also add is_empty to const raw slices REVERT: 6c5c2d5e715 Rollup merge of #118060 - ChrisDenton:abs-device-path, r=thomcc REVERT: befcea363b0 Rollup merge of #118028 - Jules-Bertholet:dyn-any-doc, r=thomcc REVERT: e8ca39162b7 Rollup merge of #117940 - zhiqiangxu:remove_redundant_drop, r=thomcc REVERT: 5cb0d5a113b Rollup merge of #117656 - ChrisDenton:invalid, r=thomcc REVERT: 615951b7d1a Rollup merge of #116807 - seanlinsley:patch-2, r=thomcc REVERT: 911a031702c Auto merge of #117722 - okaneco:binarysearch, r=thomcc REVERT: 4c9023b68fb Indicate that multiplication in Layout::array cannot overflow REVERT: 35919bef0e3 Auto merge of #98943 - WilliamVenner:feat/bufread_skip_until, r=dtolnay REVERT: 8ab0060e092 Fix tracking issue of Windows ExitCodeExt REVERT: 9bc42f0edc3 add track_caller for arith ops REVERT: 87366bd1fe3 Add UnorderedKeyError REVERT: 6f4ed4fc96b Update library/alloc/src/collections/btree/map.rs REVERT: afc13c42fea Rewrite the BTreeMap cursor API using gaps REVERT: a4a9ac29e51 Auto merge of #115159 - solid-rs:patch/kmc-solid/io-safety, r=workingjubilee REVERT: 5c18bde04ee add missing period in `std::process::Command` docs REVERT: 8131d3a5796 Auto merge of #118154 - ChrisDenton:win-clippy, r=scottmcm REVERT: 249effeffbb also make 'core_intrinsics' internal REVERT: 139bf69a864 warn against using intrinsics that leave the scope of our memory model REVERT: 50957c1d683 x fmt library/std REVERT: 680d49ed50b redundant_slicing REVERT: 9716902e2fc cmp_null REVERT: 0457852df69 manual_range_contains REVERT: af34fba0ddb op_ref REVERT: 7d610cda7ca manual_map REVERT: 2416736a121 unnecessary_lazy_evaluations REVERT: 9f0932e3d62 redundant_closure REVERT: b0b31973b66 duration_subsec REVERT: d8813db82e0 unnecessary_cast REVERT: 9c2ba70ced9 needless_borrow REVERT: d5cfef4ee78 needless_borrows_for_generic_args REVERT: 83db9823d37 manual_slice_size_calculation REVERT: fc4d42b4708 unnecessary_mut_passed REVERT: 524de718bdb useless_conversion REVERT: a65bbb124d0 needless_return REVERT: b35deec9bb2 Stabilize RFC3324 dyn upcasting coercion REVERT: 9010d413230 allow clippy style in windows/c.rs REVERT: 7cb2960776b Update backtrace submodule REVERT: ca5e92f067d Auto merge of #117619 - elomatreb:add-duration-abs-diff, r=thomcc REVERT: 09100d10bba Rollup merge of #118094 - JarvisCraft:SpecFromElem-for-empty-tuple, r=thomcc REVERT: 601c0bad3c4 Rollup merge of #117790 - rcvalle:rust-cfi-fix-000000, r=workingjubilee REVERT: e8f4c1d9e96 docs(GH-118094): make docs a bit more explicit REVERT: cfe54eba7ea chore(GH-118094): explicitly mark `_elem` as unused REVERT: aab564bb946 feat: specialize `SpecFromElem` for `()` REVERT: 6fe5b287930 Rollup merge of #117957 - the8472:pidfd-wait, r=Mark-Simulacrum REVERT: ff4b6367c1f Use an absolute path to the NUL device REVERT: 14bd0b4a733 Don't set cmsg fields in msghdr if we have no cmsg to send REVERT: 1e8542e4df7 Auto merge of #117895 - mzohreva:mz/fix-sgx-backtrace, r=Mark-Simulacrum REVERT: 8953c4a7517 Rollup merge of #116750 - fintelia:seek_seek_relative, r=Mark-Simulacrum REVERT: 9bd4f8a2581 Auto merge of #117525 - GKFX:remove_option_payload_ptr, r=petrochenkov REVERT: e2f628d761f Update based on petrochenkov's review REVERT: 9e9c2dea178 Auto merge of #115412 - eswartz:docs/total_cmp-test-result-in-docs, r=scottmcm REVERT: e2788546712 guarantee that char and u32 are ABI-compatible REVERT: ebc67d41b0d Auto merge of #115249 - clarfonthey:alignment, r=scottmcm REVERT: 651d2e2a7c5 impl more traits for ptr::Alignment, add mask method REVERT: 2a2c1802317 Auto merge of #117825 - fee1-dead-contrib:corefx, r=petrochenkov REVERT: c22e517cfaa Auto merge of #117138 - zachs18:rwlock_guard_debug_unsized, r=dtolnay REVERT: c3439abc89b Document behavior of `::type_id()` REVERT: 9607c5e8d93 Rollup merge of #118006 - lcnr:discriminant-docs, r=compiler-errors REVERT: dc0ae2aaa01 Rollup merge of #117549 - DaniPopes:more-copied, r=b-naber REVERT: 41d06d9a587 Rollup merge of #117338 - workingjubilee:asmjs-meets-thanatos, r=b-naber REVERT: 1f966bc4f92 Use ptr::invalid_mut for SGX image base REVERT: bd12e0cf1fb Auto merge of #111922 - vaporoxx:feat-searcher, r=dtolnay REVERT: 98588433a36 Update windows-bindgen REVERT: 2ec1a5f39d2 Define `INVALID_HANDLE_VALUE` ourselves REVERT: 299f83e3c2b Improve slice_group_by doc wording REVERT: 679fe310fdc only free lifetimes may get erased REVERT: 4facd4b27be Rollup merge of #115476 - RalfJung:abi-compat-docs, r=Mark-Simulacrum REVERT: 1a8076147a4 linking in general has more pitfalls than just call ABI REVERT: 48262cc483a Rollup merge of #117946 - RalfJung:miri-libcore-test, r=Mark-Simulacrum REVERT: d196240afa3 Remove option_payload_ptr; redundant to offset_of REVERT: e3311c4e819 Stabilize ptr_addr_eq library feature REVERT: e1f138bc38e std: personality: support gcc personality on Xous REVERT: 0ad26a8b3aa panic_unwind: support unwinding on xous REVERT: ab0d3ec8a57 unwind: add support for using `unwinding` crate REVERT: 01a4518cf0c Re-format code with new rustfmt REVERT: 13406e04885 if available use a Child's pidfd for kill/wait REVERT: d823ae600df Bump cfg(bootstrap)s REVERT: 663cb721905 Substitute version placeholders REVERT: a556806728c update comment, we're currently using a different syscall REVERT: 7005d825e35 set CLOEXEC on pidfd received from child process REVERT: b98b94fba8d avoid exhaustive i16 test in Miri REVERT: 2c360bd5dba remove unnecessary drop REVERT: 152562d4c71 Move SGX-specific image base logic to sys_common REVERT: 0f6170617b7 Adjust frame IP in backtraces relative to image base for SGX target REVERT: 8b887422f8e Auto merge of #117330 - tmiasko:custom-mir-cleanup-blocks, r=cjgillot REVERT: 1899caf6842 Custom MIR: Support cleanup blocks REVERT: 7b5ab643dcf Auto merge of #116301 - mj10021:issue-115737-fix, r=cuviper REVERT: 4ff896465e2 Auto merge of #116866 - slanterns:inspect-stabilize, r=BurntSushi REVERT: 78e5cd2e0ee Reenable effects in libcore REVERT: 6fcdc17ce75 Rename MaybeUninit::write_slice REVERT: 222c6778a25 round to even REVERT: e3841c14ea0 fix rounding issue with exponents in fmt REVERT: 05c76f7a125 Auto merge of #115694 - clarfonthey:std-hash-private, r=dtolnay REVERT: 6f0106f4dc1 clarify ABI compatibility of fn ptr types and ptr types REVERT: 8afbc868e51 Update variable name to fix `unused_variables` warning REVERT: 37d7fcec4db add 'import functions' to the list of situations where ABI compatibility comes up REVERT: 9cc6f672fff CFI: Add missing use core::ffi::c_int REVERT: 7478aed03e9 Auto merge of #117572 - RalfJung:addr_of, r=cuviper REVERT: 2b7f7d568e6 mention null explicitly REVERT: 9adffc0af8d Rollup merge of #117730 - jmillikin:fmt-debug-helper-fns, r=cuviper REVERT: 609cb02960e Rollup merge of #117039 - scottmcm:clarify-get-unchecked, r=cuviper REVERT: 448a897598a Closure-consuming helper functions for `fmt::Debug` helpers REVERT: f738a969919 Remove trailing whitespace REVERT: 2b5c1e9c0dd Add note on how 0 flag overrides fill character REVERT: 30237d8a970 Rollup merge of #117694 - jmillikin:core-io-borrowed-buf, r=m-ou-se REVERT: fdbd4d1efaa Rollup merge of #116762 - WaffleLapkin:fixup_fromptr_docs, r=RalfJung REVERT: 6f4b484e930 Move `BorrowedBuf` and `BorrowedCursor` from `std:io` to `core::io` REVERT: b0aad8e77a0 Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwco REVERT: af84f0fd2cf Refactor `binary_search_by` to use conditional moves REVERT: aa5a4e83ca4 Add link to Formatting traits from alternate forms REVERT: f7a91f0fc2f Auto merge of #115460 - zachs18:borrowedcursor_write_no_panic, r=dtolnay REVERT: 37b6a42cdb2 Fix addition formatting REVERT: e88506a7f1d kmc-solid: Re-export `{As,Borrowed,Owned}Fd` in `std::os::solid::prelude` REVERT: 35ce017a64f kmc-solid: Reimplement `AsFd` etc for `{TcpStream,TcpListener,UdpSocket}` by delegating to inner `Socket` REVERT: b518da63042 kmc-solid: Implement `{From,Into}Inner` for `Socket` REVERT: d4d094b81dd kmc-solid: Remove `FileDesc` REVERT: f701dc72106 kmc-solid: Replace `{From,Into}Inner` impls with `*RawFd` for `Socket` REVERT: fae2e126f1b kmc-solid: Implement `AsFd` for `{Arc,Rc,Box}` REVERT: bb2dc48ebbc kmc-solid: Implement `AsFd` and conversion to/from `OwnedFd` for `{TcpStream,TcpListener,UdpSocket}` REVERT: c4b1d8a627e kmc-solid: Document I/O safety in `std::os::solid::io` REVERT: f62fe4a2a02 kmc-solid: Add `std::os::solid::io::{BorrowedFd,OwnedFd,AsFd}` REVERT: 65d2dd64f76 Document how rust atomics work wrt mixed-sized and non-atomic accesses REVERT: b82649d5d6c Auto merge of #117617 - Urgau:bump-libc-0.2.150, r=Mark-Simulacrum REVERT: 1396d445feb Stabilize `slice_group_by` REVERT: 1a244b8d0d2 Rollup merge of #117631 - smarnach:error-request-doc-fix, r=ChrisDenton REVERT: b2906d3d2c4 Auto merge of #116988 - RalfJung:null, r=WaffleLapkin REVERT: e2256df53a7 Documentation cleanup for core::error::Request. REVERT: deefdeb8d81 Auto merge of #117576 - the8472:fix-io-copy-vec, r=Mark-Simulacrum REVERT: 1ed7f6dee3b Auto merge of #96979 - SabrinaJewson:waker-update, r=workingjubilee REVERT: 9f940f427c3 Add `Duration::abs_diff` REVERT: 340ea5f103a Auto merge of #117179 - Voultapher:fix-useless-comp-in-partition-equal, r=Mark-Simulacrum REVERT: da199be057d libc: bump dependency to 0.2.150 REVERT: ac69fd93f34 Auto merge of #117537 - GKFX:offset-of-enum-feature, r=cjgillot REVERT: f7aec6fde7e Auto merge of #117608 - matthiaskrgr:rollup-g9fagmv, r=matthiaskrgr REVERT: ce376e139ea Rollup merge of #117596 - thomcc:core_macro_diag_items, r=Nilstrieb REVERT: 524e310a89d update and clarify addr_of docs REVERT: 29ded64255f Auto merge of #117504 - pcc:android-link-libunwind, r=Mark-Simulacrum REVERT: 95de36d4d26 Auto merge of #116218 - tgross35:const-maybe-uninit-zeroed, r=dtolnay REVERT: b27525e497e Auto merge of #117581 - nicholasbishop:bishop-update-cb, r=Mark-Simulacrum REVERT: 50e7cf9fba2 Auto merge of #117503 - kornelski:hint-try-reserved, r=workingjubilee REVERT: ce3444ab3d7 Add diagnostic items for a few of core's builtin macros REVERT: 6f6dd79a97c Improve documentation REVERT: 528acddb7fc Rollup merge of #117534 - RalfJung:str, r=Mark-Simulacrum REVERT: e6aad49eb59 Rollup merge of #116894 - joshlf:patch-12, r=RalfJung REVERT: eb1eb958c5e Rollup merge of #110340 - jmaargh:jmaargh/deref-docs, r=Mark-Simulacrum REVERT: 2c243c550c5 Stabilize `const_mem_zeroed` REVERT: 591110583a8 Stabilize `const_maybe_uninit_zeroed` REVERT: 37ba6ef0882 Draft fleshed-out deref docs REVERT: 68f73166420 Bump compiler_builtins to 0.1.103 REVERT: b308efd15a9 detect EOF earlier REVERT: 106b2886ad6 avoid excessive initialization when copying to a Vec REVERT: faa216fec3c avoid acronyms when we don't really need them REVERT: d880bb130c0 document ABI compatibility REVERT: 32286ac43bd docs: clarify explicitly freeing heap allocated memory REVERT: 5fe76a58d64 Make documentation of `slice_first_last_chunk` more consistent REVERT: a240925d722 Reverse ordering of `split_{first,last}_chunk` to be `(preceding, last)` REVERT: f0f884c4346 Auto merge of #116412 - nnethercote:rm-plugin-support, r=bjorn3 REVERT: 97fd78d55c5 Remove support for compiler plugins. REVERT: 4a4850ee2f4 Auto merge of #115333 - joshlf:patch-5, r=RalfJung REVERT: e07b588cce5 library: use `copied` instead of manual `map` REVERT: 833798dae4a cfg_attr offset_of_enum feature in doctest REVERT: a2b8680e552 Update primitive_docs.rs REVERT: aac85369961 Feature gate enums in offset_of REVERT: 6dcc3b45fc4 Rollup merge of #117434 - BugenZhao:box-error-provide, r=cuviper REVERT: 422c527c99a Auto merge of #117510 - elichai:patch-3, r=cuviper REVERT: 13c01b9da65 clarify that the str invariant is a safety, not validity, invariant REVERT: 2cc2e1feb0d Remove obsolete support for linking unwinder on Android REVERT: 3412744cb18 Add insta-stable std::hash::{DefaultHasher, RandomState} exports REVERT: c363991b2d8 Move RandomState and DefaultHasher into std::hash, but don't export for now REVERT: 0ae67fa0919 Pretty print Fn traits in rustc_on_unimplemented REVERT: ca9851cc651 Rollup merge of #117512 - joshlf:patch-8, r=dtolnay REVERT: 72f6caac657 Rollup merge of #117495 - compiler-errors:unsize-docs, r=lcnr REVERT: ba00f1b59c0 Update mod.rs REVERT: f1aaaf8e5d4 Update mod.rs REVERT: ff405d93f92 Remove trailing space REVERT: 89316f5b3f1 Expand mem::offset_of! docs REVERT: ff925dcccbd Add track_caller to transmute_copy REVERT: 75e2181a0f7 Auto merge of #117386 - roblabla:fix-switch-stdio-win7, r=ChrisDenton REVERT: b02647c7b43 fixes: typo in `std::cmp::Ord` trait docs REVERT: 49ad5a38b3f Hint optimizer about reserved capacity REVERT: 3707d836397 Rework unsize documentation REVERT: 9503f71eff7 Remove a false statement from Unsize docs, add a test REVERT: c5982fe1590 Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiser REVERT: 13038107438 Rollup merge of #115626 - clarfonthey:unchecked-math, r=thomcc REVERT: 2b2f41a3bff Auto merge of #115356 - devnexen:haiku_set_name_use_return, r=thomcc REVERT: 5847d911b6f Auto merge of #117422 - joshtriplett:stabilize-file-times, r=workingjubilee REVERT: a76475613b1 Update based on wesleywiser review REVERT: 900e92354ff Update MIR tests for offset_of REVERT: 2d90553a1b7 Enums in offset_of: update based on est31, scottmcm & llogiq review REVERT: e3a872da5ee Auto merge of #117459 - matthiaskrgr:rollup-t3osb3c, r=matthiaskrgr REVERT: 656b5587a03 Add support for pre-unix-epoch file dates on Apple platforms (#108277) REVERT: 323ebe34da1 Accept less invalid Rust in rustdoc REVERT: 593201c3c1d Fix switch_stdout_to on Windows7 REVERT: 8d58780a93a delegate box error provide REVERT: 5e20ca8cc8f Stabilize `file_set_times` REVERT: 2d0d52d24f8 Rollup merge of #117205 - weiznich:multiple_notes_for_on_unimplemented, r=compiler-errors REVERT: 9dcc24335af Rollup merge of #117177 - Ayush1325:uefi-alloc-type, r=workingjubilee REVERT: 903da5fafb1 Use ImageDataType for allocation type REVERT: a7f94388891 Add tracking issue REVERT: dc849c31926 Auto merge of #117332 - saethlin:panic-immediate-abort, r=workingjubilee REVERT: b8df78093de Auto merge of #117089 - wesleywiser:update_backtrace, r=Mark-Simulacrum REVERT: 7544442dba0 Increase the reach of panic_immediate_abort REVERT: 089e0d41460 Rollup merge of #117312 - RalfJung:memcpy-assumptions, r=Mark-Simulacrum REVERT: e203dc18a12 Rollup merge of #115968 - git-bruh:master, r=workingjubilee REVERT: c8e5d2f4e65 Remove asmjs from library REVERT: 7636352fd6a Don't use LFS64 symbols on musl REVERT: 18e810d3770 Rollup merge of #117316 - Coekjan:const-binary-heap-constructor, r=dtolnay REVERT: 3d466ccc86f Rollup merge of #117162 - c410-f3r:try, r=workingjubilee REVERT: 303a50e7f47 Auto merge of #116240 - dtolnay:constdiscriminant, r=thomcc REVERT: 01281969354 make pointer_structural_match warn-by-default REVERT: 3aad7dde1bc mark constructor of `BinaryHeap` as const fn REVERT: 1e0f273f16a Auto merge of #117038 - saethlin:inline-range-methods, r=workingjubilee REVERT: 82330939c6a Auto merge of #116609 - eduardosm:bump-stdarch, r=workingjubilee REVERT: 9e2cd8695ed memcpy assumptions: link to source showing that GCC makes the same assumption REVERT: abbd2f60e1f Rollup merge of #116816 - ChrisDenton:api.rs, r=workingjubilee REVERT: 1711461075b Rollup merge of #117281 - RalfJung:thread-safety, r=thomcc REVERT: f3673bad248 Rollup merge of #117270 - jhpratt:hide-print-internals, r=ChrisDenton REVERT: 2a35f164720 std::thread: add SAFETY comment REVERT: 0fc29268278 Allows `#[diagnostic::on_unimplemented]` attributes to have multiple notes REVERT: 1f614eccb80 Auto merge of #117272 - matthiaskrgr:rollup-upg122z, r=matthiaskrgr REVERT: 6c88aea9fcb Rollup merge of #117266 - RalfJung:cast-not-transmute, r=thomcc REVERT: 0fb83cc40f1 Rollup merge of #117240 - trueNAHO:docs-std-iter-Iterator-collect-into-fix-typo, r=the8472 REVERT: bfd73da43e6 Hide internal methods from documentation REVERT: a2e56ce53f7 Auto merge of #116205 - WaffleLapkin:stabilize_pointer_byte_offsets, r=dtolnay REVERT: 4a51bc4c3ed replace transmute by raw pointer cast REVERT: 0f72839ba68 Auto merge of #117260 - okaneco:ascii_branchless, r=thomcc REVERT: c5541d81cd8 Refactor some `char`, `u8` ascii functions to be branchless REVERT: 7e5234287aa Rollup merge of #117243 - chfogelman:replace-not-swap-comment, r=thomcc REVERT: c21bd2c3759 Error if symlinks not supported in CI REVERT: da2ac48bc65 Add comment to mem::replace to explain why it's not implemented via mem::swap REVERT: 10132b56909 Fix documentation typo in std::iter::Iterator::collect_into REVERT: 0bbc81b3d71 Auto merge of #112875 - compiler-errors:negative-coherence-rework, r=lcnr REVERT: 9866f9cdd4f Stabilize `[const_]pointer_byte_offsets` REVERT: 41f3f384852 Auto merge of #117180 - matthiaskrgr:rollup-rxhl6ep, r=matthiaskrgr REVERT: dcbb6055a69 Avoid unnecessary comparison in partition_equal REVERT: ebc58996799 Make `Iterator` a lang item REVERT: df71cdffce2 Add the missing word REVERT: c8a83a6c98e Update library/core/src/primitive_docs.rs REVERT: 54f4e276c22 Fix some coroutine sentences that don't make sense anymore. REVERT: 391cb25650f Remove `cfg_match` from the prelude REVERT: 6b3f21b76bd Auto merge of #117102 - devnexen:dfbsd_stack_overflow_upd, r=thomcc REVERT: d91014cffee Convert `Unix{Datagram,Stream}::{set_}passcred()` to per-OS traits REVERT: b62b843a887 Add T: ?Sized to RwLock*Guards' Debug impls. REVERT: d2040606285 Auto merge of #117135 - matthiaskrgr:rollup-zdh18i6, r=matthiaskrgr REVERT: bed00226c0a Rollup merge of #116714 - WaffleLapkin:order-the-order, r=joshtriplett REVERT: 90ad33e01a9 Auto merge of #117126 - matthiaskrgr:rollup-8huie8f, r=matthiaskrgr REVERT: bd95d1eaf98 Rollup merge of #117081 - GoodDaisy:master, r=wesleywiser REVERT: 2dcac89e045 Auto merge of #116773 - dtolnay:validatestable, r=compiler-errors REVERT: 503ca95aa61 Auto merge of #116461 - ChrisDenton:sleep, r=thomcc REVERT: fa852c66b92 Auto merge of #116319 - BlackHoleFox:apple-rand-take-2, r=thomcc REVERT: 6a5e867fcfb Auto merge of #116238 - tamird:gettimeofday, r=thomcc REVERT: 96d5ca30065 Remove Apple RNG fallbacks and simplify implementation REVERT: 0a88b6178de Remove FnPtr hack from trait_ref_is_knowable REVERT: 2cc3c1b4648 Auto merge of #117103 - matthiaskrgr:rollup-96zuuom, r=matthiaskrgr REVERT: 30aa4e8da1a stack_overflow: get_stackp using MAP_STACK flag on dragonflybsd too. REVERT: ada5b648dad Rollup merge of #107159 - devnexen:random_fbsd_update, r=workingjubilee REVERT: 485d30c589e Auto merge of #116033 - bvanjoi:fix-116032, r=petrochenkov REVERT: 20cab20acb4 Fix invalid stability attribute features in standard library REVERT: 1c590e7dd5c Update backtrace submodule REVERT: f971270cb92 fix typos in comments REVERT: 76853d250c0 Auto merge of #116606 - ChrisDenton:empty, r=dtolnay REVERT: 398def5bf5d use visibility to check unused imports and delete some stmts REVERT: e1a440b1742 Rollup merge of #116989 - ChrisDenton:skip-unsupported, r=Mark-Simulacrum REVERT: 3f14e4c7959 Clarify UB in `get_unchecked(_mut)` REVERT: 91734e363f8 Add #[inline] to some recalcitrant ops::range methods REVERT: 1706a2c5936 Update boxed.rs REVERT: 06b0dd832c2 Rollup merge of #114521 - devnexen:std_fbsd_13_upd, r=cuviper REVERT: b498d0a9ed8 changes from feedback REVERT: 7c2c6e90587 Fix stage0 core tests REVERT: 213241de099 s/generator/coroutine/ REVERT: 8372855aad0 s/Generator/Coroutine/ REVERT: 178a2b85f0c Skip test if Unix sockets are unsupported REVERT: 70a2e0d5ac8 document that the null pointer has the 0 address REVERT: 8323ce3027c Auto merge of #116966 - clarfonthey:atomic-docs-typo, r=workingjubilee REVERT: 9a2c7f6c1ce std: freebsd build update. REVERT: 5ee1837645b Fix typo in atomic docs REVERT: b7a1739bfe6 Auto merge of #116785 - nnethercote:spec-Bytes-read, r=the8472 REVERT: 589cd088a52 Specialize `Bytes::next` when `R` is a `BufReader`. REVERT: 647b02f933b Stablize arc_unwrap_or_clone REVERT: e8685c50e39 Auto merge of #116132 - darthunix:connect_poll, r=cuviper REVERT: 93cf68bbf89 Auto merge of #116923 - fmease:rollup-ev7q387, r=fmease REVERT: 44a089fa315 Rollup merge of #116795 - DaniPopes:track-caller-option, r=cuviper REVERT: d6521bcc2f9 Auto merge of #114534 - niluxv:strict_prov_unwind, r=cuviper,workingjubilee REVERT: 5a5fe4d83a8 Auto merge of #116402 - joboet:global_alloc_tls_unsoundness, r=thomcc,workingjubilee REVERT: d7fcaf9d051 Guarantee that `char` has the same size and alignment as `u32` REVERT: 889aa9fbaae std: send free message when xous thread parker is dropped REVERT: f839fa277c8 std: implement thread parking for xous REVERT: 4ab32c49a7d Add discussion that concurrent access to the environment is unsafe REVERT: 770363d1538 Rollup merge of #116856 - oli-obk:no_effects, r=compiler-errors REVERT: 074d6927459 Automatically enable cross-crate inlining for small functions REVERT: 2125f872d5d Stabilize `result_option_inspect` REVERT: d37e3cce689 Disable effects in libcore again REVERT: ad1c965f6e7 Auto merge of #115577 - RalfJung:atomic-load, r=Amanieu REVERT: 0bd7bf19bed Auto merge of #116518 - vita-rust:vita, r=workingjubilee REVERT: cd5a8c52477 Updated libc and doc for Vita target REVERT: 2778fb037bc remove 128bit atomics, they are anyway not exposed on those targets REVERT: 579d174c5a8 Auto merge of #116820 - GuillaumeGomez:rollup-l54ri5q, r=GuillaumeGomez REVERT: eaf2cfe33a1 Create `windows/api.rs` for safer FFI REVERT: da6e701da70 Improve rewind documentation REVERT: f0ad97f3041 Make `rustc_onunimplemented` export path agnostic REVERT: c586be3bf73 use target-arch based table REVERT: 3dda08361ef Add invariant to Vec::pop that len < cap if pop successful REVERT: 798ee6f4f3c Add `#[track_caller]` to `Option::unwrap_or_else` REVERT: a540175685b Auto merge of #116782 - matthiaskrgr:rollup-t3yrgku, r=matthiaskrgr REVERT: 0a238304319 Rollup merge of #115955 - tgross35:ip-to-canonical, r=dtolnay REVERT: be46dc8d93d Auto merge of #116775 - nnethercote:inline-Bytes-next, r=the8472 REVERT: 93aab806d90 Auto merge of #114589 - ijackson:exit-code-default, r=dtolnay REVERT: e3669bfc65d Auto merge of #113747 - clarfonthey:ip_bitops, r=dtolnay REVERT: b91ec06898d Auto merge of #116772 - matthiaskrgr:rollup-mpff3lh, r=matthiaskrgr REVERT: 10706e3516c Inline `Bytes::next` and `Bytes::size_hint`. REVERT: 5b7000f6db4 Rollup merge of #116760 - Nilstrieb:triviality, r=oli-obk REVERT: 1bff6245283 Rollup merge of #116341 - Ayush1325:uefi-args, r=Mark-Simulacrum REVERT: d612c5703ae Rollup merge of #116172 - joboet:recursive_tls_initialization, r=dtolnay REVERT: 2cdac870ef5 Auto merge of #110604 - a1phyr:vecdeque_buf_read, r=dtolnay REVERT: 7020c99ca6f Deduplicate std::process Default impl feature names REVERT: 1efbb39d826 Auto merge of #110729 - ColinFinck:decode-utf16-fused-iterator, r=dtolnay REVERT: 4623ef52cbb acquire loads can be done as relaxed load; acquire fence REVERT: 6e8159bc88c only guarantee for Relaxed; add ptr-size fallback REVERT: 99b9b872620 wording REVERT: 4213dbcd82d define 'read-only memory' REVERT: 4c6364a0131 add general powerpc64le bound REVERT: 08033400ccb add ARM and RISC-V values REVERT: 2904d725fba document when atomic loads are guaranteed read-only REVERT: 7a10fffd413 Auto merge of #116527 - sthibaul:libc, r=Mark-Simulacrum REVERT: 2694e7ae64f Implement args for UEFI REVERT: ffc3cbc10ea Add tests for `SocketAddrV6` ordering with scope_id and flowinfo REVERT: e240ac54d71 Remove trivial cast in `guaranteed_eq` REVERT: cdf6ea5d49d Make File::create work on Windows hidden files REVERT: b66dae8b93a Rollup merge of #116594 - tae-soo-kim:convert-tryfrom-doc, r=scottmcm REVERT: 41e2b393a57 Auto merge of #116683 - ChrisDenton:exists, r=Mark-Simulacrum REVERT: 5a072fd1ec2 Auto merge of #115515 - the8472:zip-for-arrays, r=scottmcm REVERT: 2d0476fa8ab Add Seek::seek_relative REVERT: c6b70e0b3df Rollup merge of #116540 - daxpedda:once-cell-lock-try-insert, r=Mark-Simulacrum REVERT: 5510adbd888 Rollup merge of #116723 - ivmarkov:master, r=dtolnay REVERT: c7c086185c3 Rollup merge of #115653 - joshlf:patch-9, r=dtolnay REVERT: e9aff9c508c Fix broken build on ESP-IDF caused by #115108 REVERT: 8209c7268cd Auto merge of #116407 - Mark-Simulacrum:bootstrap-bump, r=onur-ozkan REVERT: f21122e513a Guarantee representation of None in NPO REVERT: 2d8b9e06b33 Auto merge of #115719 - tgross35:atomic-from-ptr, r=dtolnay REVERT: 4e40287f1d8 Derive `Ord`, `PartialOrd` and `Hash` for `SocketAddr*` REVERT: 6f39945bea3 Stabilize 'atomic_from_ptr', move const gate to 'const_atomic_from_ptr' REVERT: 9e5063eee78 Correct documentation for `atomic_from_ptr` REVERT: 90e9aab1338 Revert "Invoke `backtrace-rs` buildscript in `std` buildscript" REVERT: dc136f9a284 Auto merge of #116233 - DaniPopes:stabilize-const_maybe_uninit_assume_init_read, r=dtolnay REVERT: b13b0787694 Update primitive_docs.rs REVERT: d10f540254d Update library/core/src/primitive_docs.rs REVERT: 126efbb96f5 Auto merge of #115108 - ijackson:broken-wait-status, r=dtolnay REVERT: 0c3f936f925 Add some optimizations REVERT: 012501b13c3 Implement `OnceCell/Lock::try_insert()` REVERT: 6199b1ce08d Make TCP connect() handle EINTR correctly REVERT: 74d0a1d689d Clean up unchecked_math, separate out unchecked_shifts REVERT: 1d8d3fecbe9 Remove Not for IpAddr REVERT: 2618b27f681 impl Not, Bit{And,Or,Xor}{,Assign} for IP addresses REVERT: 8fee20a215c Test that unix sockets exist on Windows REVERT: 9359b967c30 Make try_exists return Ok(true) for Windows UDS REVERT: 4893fbb0d06 Update primitive_docs.rs REVERT: f5d4983f7cd Update library/core/src/alloc/layout.rs REVERT: 9ec130e3102 References refer to allocated objects REVERT: 5b50d81274b Bump stdarch submodule REVERT: 2b0c0f75c35 Auto merge of #116506 - Wilfred:remove_tmp_var, r=workingjubilee REVERT: 11af29ed980 Auto merge of #112818 - Benjamin-L:add-slice_split_once, r=cuviper REVERT: 14d951093d8 Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease REVERT: 1e344a6b721 Rollup merge of #95967 - CAD97:from-utf16, r=dtolnay REVERT: bdf0ef51913 On Windows make readdir error on the empty path REVERT: b0cc07826da Rollup merge of #116559 - Kritzefitz:btree-new-in-const, r=Amanieu REVERT: d3324b0e216 Rewrite `read_encoded_pointer` conforming to strict provenance REVERT: ec183b94abf Use pointers instead of `usize` addresses for landing pads REVERT: d7abe144783 Update mod.rs REVERT: 232c3aab4be std: explain unconventional choice of let-else binding over while-let loop REVERT: 349d5f522ce Make BTreeSet::new_in const REVERT: ab0ad55b61b Make BTreeMap::new_in const REVERT: e33f6a62dea Support AIX in Rust standard library REVERT: 17991f325ad rustdoc: remove rust logo from non-Rust crates REVERT: 03ab228d3d1 Bump to latest beta REVERT: 3077e1332fb Bump libc dependency REVERT: 7a19a72e0ab Auto merge of #100806 - timvermeulen:split_inclusive_double_ended_bound, r=dtolnay REVERT: 7391321b876 Expose tests for {f32,f64}.total_cmp in docs, along with comment REVERT: 4ec0ef1afd0 std: fix registering of Windows TLS destructors REVERT: 4344de11e13 Auto merge of #109214 - tosti007:std_collection_hash_new_rework, r=workingjubilee REVERT: 6114ce67b34 Remove unnecessary tmp variable in default_read_exact REVERT: 621aec0d64b Auto merge of #116318 - pitaj:android-backtrace-build, r=workingjubilee REVERT: 249c9eeb34c Auto merge of #116501 - workingjubilee:rollup-fpzov6m, r=workingjubilee REVERT: ab1a442ee42 Rollup merge of #116500 - simlay:tvos-support-for-register_dtor, r=workingjubilee REVERT: 113ef17b053 Auto merge of #114709 - ShE3py:wasi-io-error-more, r=workingjubilee REVERT: b4255669353 Add tvOS to target_os for register_dtor REVERT: d87113fcafd Rollup merge of #116484 - peterjoel:once-doc-clarify, r=cuviper REVERT: 44c6915fc80 Rollup merge of #116481 - scottmcm:tweak-combinators, r=cuviper REVERT: 09553498f97 Rollup merge of #114564 - scottmcm:when-to-from, r=dtolnay REVERT: 4572ded6851 Use `io_error_more` on WASI REVERT: 73a5cecd6b2 optimize zipping over array iterators REVERT: 5b5fce6c362 Auto merge of #116483 - GuillaumeGomez:rollup-z65pno1, r=GuillaumeGomez REVERT: 4151564fd00 Minor doc clarification in Once::call_once REVERT: 61a4558bfb4 Rollup merge of #116329 - RalfJung:swap-comments, r=scottmcm REVERT: 01d70302cd9 Rollup merge of #116198 - Jarcho:diag_items, r=WaffleLapkin REVERT: b995b9942fe Rollup merge of #115588 - tifv:fix-comment-successors, r=scottmcm REVERT: c6fe05ebecc Rollup merge of #115522 - joshlf:patch-8, r=scottmcm REVERT: 073ad6becc3 Rollup merge of #115454 - vwkd:patch-1, r=scottmcm REVERT: d0d6399a028 Auto merge of #111595 - fortanix:raoul/waitqueue_clarifications, r=workingjubilee REVERT: 8c67aba71fb Reuse existing `Some`s in `Option::(x)or` REVERT: e761ace1e8b Elaborate some caveats to lossless REVERT: a5e0731fae2 Don't mention "recover the original" in `From` docs REVERT: dd654cf8132 Attempt to describe the intent behind the `From` trait further REVERT: 400290dc033 Windows: Support sub-millisecond sleep REVERT: e4bdd73847f Auto merge of #116463 - ChrisDenton:nlibc, r=workingjubilee REVERT: 8da71a6b06d Auto merge of #101150 - jethrogb:jb/cleanup-sgx-user-memory-copies, r=workingjubilee REVERT: 1de77bfbb1e Remove libc REVERT: a0f5fa3fa8e Add more diagnostic items for clippy REVERT: 1eee0fac387 Auto merge of #116455 - matthiaskrgr:rollup-p226a5u, r=matthiaskrgr REVERT: bbfeab66df7 Rollup merge of #116220 - llogiq:stabilize-option-as-slice, r=BurntSushi REVERT: 12f7eace5cc Auto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee REVERT: f895b42cfa5 Auto merge of #114042 - liushuyu:ubuntu/i586-fpmath, r=workingjubilee REVERT: 541035f4c0f docs: Correct terminology in std::cmp REVERT: 6d386c9b1a2 Auto merge of #104153 - tspiteri:doc-float-constants, r=workingjubilee REVERT: f3d6222f96d Rollup merge of #116223 - catandcoder:master, r=cjgillot REVERT: 16167c268e1 Disable CFI for core and std CFI violations REVERT: 736b71a5975 std: abort instead of panicking if the global allocator uses TLS REVERT: b652cb8c52a Auto merge of #116408 - matthiaskrgr:rollup-hmolg4m, r=matthiaskrgr REVERT: c0c76ed52e8 Rollup merge of #116363 - Colonial-Dev:issue-116130-fix, r=thomcc REVERT: a244fe472d8 Rollup merge of #116146 - Milo123459:milo/clarify-arg-documentation, r=thomcc REVERT: 3eb78377ee2 Rollup merge of #115961 - Kriskras99:master, r=thomcc REVERT: a8fe5254dce Auto merge of #116386 - elichai:patch-2, r=thomcc REVERT: 1a59a07d955 Bump version placeholders REVERT: 271ceae80a3 Auto merge of #116367 - scottmcm:more-addr-eq, r=workingjubilee REVERT: 229c37b18a5 Fix misuses of a vs an REVERT: 15b7a673c39 std: panic when the global allocator tries to register a TLS destructor REVERT: 49e1192fa3b Auto merge of #105394 - Patiga:improve-udpsocket-docs, r=workingjubilee REVERT: 100b253f0d8 Add missing inline attributes to Duration trait impls REVERT: 1b59a54df02 Rollup merge of #116282 - rustaceanclub:master, r=davidtwco REVERT: 62baec1b84d Rollup merge of #116361 - eduardosm:bump-stdarch, r=Amanieu REVERT: 5478412be61 Rollup merge of #116355 - orlp:signed-zero-rounding-mode, r=thomcc REVERT: 260cf2e54ee Rollup merge of #116351 - asquared31415:ptr_eq_must_use, r=workingjubilee REVERT: 965667c2ec6 Invoke `backtrace-rs` buildscript in `std` buildscript REVERT: c9801793a82 Use `addr_eq` in `{Arc,Rc}::ptr_eq` REVERT: 9add4a5368b Appease tidy REVERT: c73ae5ca483 Adapt `todo!` documentation to mention displaying custom values REVERT: f829080ac9c Bump stdarch submodule REVERT: 4e6cd719d97 Rollup merge of #116350 - Nilstrieb:in-situ, r=Dylan-DPC REVERT: c38e163b9a0 Rollup merge of #116289 - linkmauve:patch-1, r=the8472 REVERT: 334d133ca38 Clarify float rounding direction for signed zero REVERT: 75906501079 Improve wording of `hint::black_box` docs REVERT: 7ec3d94d24e add must_use on pointer equality functions REVERT: ec2f5620381 Rollup merge of #116326 - Colonial-Dev:issue-116165-fix, r=joshtriplett REVERT: 0c33dba2205 MIRI -> Miri REVERT: 50752d1c4a7 update some comments around swap() REVERT: 72cce65c0fb Auto merge of #116325 - scottmcm:addr_eq, r=dtolnay REVERT: 0cdbbeb40e9 Correct misleading std::fmt::Binary example REVERT: 7f3909b2887 Auto merge of #116317 - ravenclaw900:track-caller-unwrap-or-else, r=Mark-Simulacrum REVERT: f7548ccf0ae Add `ptr::addr_eq` REVERT: 0a087db50fa Auto merge of #116207 - Ayush1325:uefi_stdio, r=Mark-Simulacrum REVERT: 02ebc6f1da1 Stdio for UEFI REVERT: 38312522559 Add track_caller attribute to Result::unwrap_or_else REVERT: 6cd16135e2b Rollup merge of #116295 - asquared31415:mem_drop_docs, r=WaffleLapkin REVERT: 3440566be7c Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum REVERT: c9b74f4811a Auto merge of #116157 - the8472:doc-monotonoic-suspend, r=Mark-Simulacrum REVERT: 35a01b01e83 mem::drop docs REVERT: a4bcc51bf66 Add missing #[inline] on AsFd impl for sys::unix::fs::File REVERT: 6b4933572e5 Fix broken links REVERT: a289528953e Auto merge of #115546 - SUPERCILEX:patch-2, r=Amanieu REVERT: b5c0ca380b0 Rollup merge of #116241 - dtolnay:exclusivefwd, r=Amanieu REVERT: 202117ccec7 Auto merge of #113797 - RalfJung:offset_from_docs, r=workingjubilee REVERT: 59c723018e4 Auto merge of #116176 - FedericoStra:isqrt, r=dtolnay REVERT: c574917c025 fix char imports REVERT: 8e699fbecaf add str_from_utf16_endian tracking issue REVERT: 6523329273b style nits REVERT: 2d0ad2b45c6 Add feature(str_from_utf16_endian) REVERT: db8dbcbb780 time: use clock_gettime on macos REVERT: b72aa738a13 time: use clock_gettime on macos REVERT: e4c3635ae79 Const stabilize mem::discriminant REVERT: 5d3b0cff636 Add Exclusive forwarding impls (FnOnce, FnMut, Generator) REVERT: e5407a65bd2 time: cfg(any(x)) is the same as cfg(x) REVERT: d2aa9d7baa9 isqrt: disable long running tests in Miri REVERT: 7f7aeab118c Auto merge of #116230 - matthiaskrgr:rollup-hi1ciwy, r=matthiaskrgr REVERT: ad76c2862bd Stabilize `const_maybe_uninit_assume_init_read` REVERT: 04e222c08a2 Rollup merge of #116221 - ArchUsr64:patch-1, r=ChrisDenton REVERT: 1e0752c769d Auto merge of #114882 - ChrisDenton:riddle-me, r=dtolnay REVERT: 03ed8b8347d isqrt: `assume` that `isqrt` takes half as many bits REVERT: 970c03410b2 Auto merge of #114428 - ChaiTRex:master, r=dtolnay REVERT: 20ecbdaa71e fixup! isqrt: fix stability REVERT: 2b881652bd0 isqrt: cite source and rename variables to match original C code REVERT: 4426c51060c Auto merge of #98704 - vthib:impl-from-raw-for-childstd-structs, r=dtolnay REVERT: 2249d687f3e isqrt: fix stability REVERT: 41022a6c736 fixup! isqrt: initial implementation REVERT: 6ea777eb60a Auto merge of #116222 - matthiaskrgr:rollup-dnag90q, r=matthiaskrgr REVERT: 4ff38446dab Rollup merge of #115888 - RalfJung:assert_receiver_is_total_eq, r=dtolnay REVERT: 02cffa4b5b6 Rollup merge of #115535 - tshepang:patch-2, r=dtolnay REVERT: 7f898bf31dc Rollup merge of #112959 - tbu-:pr_fmt_error_wording, r=dtolnay REVERT: f848e1605c4 Update stability attribute for child stream From impls REVERT: 0e8deafd145 stabilize `Option::as_`(`mut_`)`slice` REVERT: 658e6d841dd changed 'rotate' to 'rotating' REVERT: 5326c4c4a60 Auto merge of #114041 - nvzqz:nvzqz/shared_from_array, r=dtolnay REVERT: 682ecae24ed Fix "unresolved link to std::fmt::Error" REVERT: 8f0b0dcf0d8 Auto merge of #111278 - EFanZh:implement-from-array-refs-for-vec, r=dtolnay REVERT: 70c90f17e3d take more clarifying text from Gankra's PR REVERT: a59734193c2 isqrt: add more tests REVERT: a0e4d3a95c6 isqrt: remove duplication by delegating to unsigned integers REVERT: ff9fb8c16b9 std: broaden the allowed behaviour for recursive TLS initialization REVERT: 67abb817c47 Auto merge of #116125 - RalfJung:const-param-ty-eq, r=compiler-errors REVERT: 6117c42fb0e Auto merge of #116124 - WaffleLapkin:fix-proc-macro-literal-to-string, r=compiler-errors REVERT: 1ce12f32044 Auto merge of #116070 - eduardosm:IoSlice-advance_slices-checked_add, r=Mark-Simulacrum REVERT: c18d2bc48c1 Document that Instant may or may not include system-suspend time REVERT: 408728ce6c7 update other place REVERT: 9ac9811196d clarify documentation about variable substituion REVERT: 9e0d14614d3 Auto merge of #116074 - fzs111:clarify-pin-docs, r=Mark-Simulacrum REVERT: 84c7619fe5c Auto merge of #116057 - RalfJung:io-safety, r=Mark-Simulacrum REVERT: bdfc70f797e ConstParamTy: require Eq REVERT: 7ac052165bd Fix `.to_string()` of `proc_macro::Literal` (properly print cstr literals) REVERT: 7bcfc8e7033 Auto merge of #105861 - Ayush1325:uefi-std-minimial, r=workingjubilee REVERT: 57354b08f25 Auto merge of #116075 - Colonial-Dev:issue-116063-fix, r=Mark-Simulacrum REVERT: 6834dc30a90 Auto merge of #115416 - c410-f3r:match_cfg, r=Amanieu REVERT: 649ba6b764a Auto merge of #104385 - BlackHoleFox:apple-minimum-bumps, r=petrochenkov REVERT: 7d2909fc029 Raise minimum supported iOS version to 10.0 REVERT: 46ccbb1393a Raise minimum supported macOS to 10.12 REVERT: 984efdf81eb implement Literal::byte_character REVERT: 81bc83df99b Add the `cfg_match!` macro REVERT: f40849f5324 Clarify example in `Pin::new_unchecked` docs REVERT: 9f0548f0260 Avoid overflow in `IoSlice::advance_slices` REVERT: 22e0cf73fe8 Extend fix to wrapping_div, wrapping_div_euclid and wrapping_rem_euclid REVERT: a87ff950a90 Resolve rust-lang/rust#116063 REVERT: 9b8d437f940 Fixes from PR REVERT: 47ce7fb336e isqrt: add tests REVERT: 71ccd15af63 isqrt: initial implementation REVERT: 0d4a3459a90 checked_ilog: remove duplication by delegating to unsigned integers REVERT: 5cd16608c71 checked_ilog: add benchmarks REVERT: 01aba0cc79c checked_ilog: add comments explaining the correctness of the 128 bit optimization REVERT: 9e40498672c checked_ilog: set `n` and `r` directly avoiding arithmetic operations REVERT: a536343f319 checked_ilog: improve performance REVERT: 027ac9f981d Rebase to master REVERT: 7e3f74875b0 Use RawOsError for UEFI REVERT: 020572aba24 Fixes from PR REVERT: 07f8b9db4fa Add support for building `std::os::uefi` docs REVERT: 42b5003f89a Handle ExitBootServices REVERT: abfe98ba411 Fixes from PR REVERT: 82ff6d01252 Add Minimal Std implementation for UEFI REVERT: 4ae3a1f6b5d fix OS-specific I/O safety docs since the io_safety feature is stable REVERT: 040e71a2974 Auto merge of #116054 - matthiaskrgr:rollup-3pusno6, r=matthiaskrgr REVERT: fc02a0ec362 Rollup merge of #116038 - the8472:panic-on-sched_getaffinity-bug, r=cuviper REVERT: c7527293d72 Rollup merge of #114379 - RalfJung:command-removed-env-vars, r=m-ou-se REVERT: 9695dcf6399 Auto merge of #114780 - RalfJung:io-safety, r=Amanieu REVERT: ea795ff3caf Auto merge of #114776 - fee1-dead-contrib:enable-effects-in-libcore, r=oli-obk REVERT: c5fe0d9deed Auto merge of #115230 - Vtewari2311:mod-hurd-latest, r=b-naber REVERT: b3a8248842d Fall back to _SC_NPROCESSORS_ONLN if sched_getaffinity returns an empty mask REVERT: 555a8a529a7 added support for GNU/Hurd REVERT: 9846f5100ae Rollup merge of #116007 - m-ou-se:const-panic-fmt-panic-display, r=oli-obk REVERT: f522288bef3 avoid talking about inverses REVERT: 3e763cc0e45 consistent wording REVERT: 1ea6e5df204 documentation tweaks REVERT: 037342ab60a offset_from: docs improvements REVERT: a454306acd0 Auto merge of #116013 - matthiaskrgr:rollup-mv5i4fd, r=matthiaskrgr REVERT: 1516b243db3 Rollup merge of #116008 - m-ou-se:boxmeup, r=oli-obk REVERT: 693fd6e3376 Auto merge of #115542 - saethlin:fileencoder-is-bufwriter, r=WaffleLapkin REVERT: 15015709e48 PR feedback REVERT: 4ecce448108 Fix typo. REVERT: 919dccbbb03 Rename BoxMeUp to PanicPayload. REVERT: 85e8bb26925 Call panic_display directly in const_panic_fmt. REVERT: 62285a21d80 Auto merge of #115753 - tgross35:threadinfo-refactor, r=thomcc REVERT: d801fa93745 fix rustdoc tests REVERT: 9fcefb108a4 Enable effects for libcore REVERT: 0674111e9d8 Auto merge of #114443 - tgross35:cstr-len, r=dtolnay REVERT: f90d01196f5 Auto merge of #115979 - GuillaumeGomez:rollup-06ujzgh, r=GuillaumeGomez REVERT: 8c64bd13f9a Rollup merge of #115958 - RalfJung:mystery-plus, r=Mark-Simulacrum,notriddle REVERT: b66fad37e0a explain mysterious addition in float minimum/maximum REVERT: 108e5805564 Auto merge of #115627 - compiler-errors:icedump-no-std, r=m-ou-se REVERT: 63784b1e073 Replace 'mutex' with 'lock' in RwLock documentation REVERT: 98018c11324 Rollup merge of #115946 - the8472:panic-on-sched_getaffinity-bug, r=Mark-Simulacrum REVERT: 2ce5db77612 Rollup merge of #115839 - Dirreke:bump-libc, r=dtolnay REVERT: 801eb1ce5c7 Auto merge of #104101 - betrusted-io:xous-libstd-initial, r=bjorn3 REVERT: bdda4d7354d Stabilize `{IpAddr, Ipv6Addr}::to_canonical` REVERT: be74b238d48 panic when encountering an illegal cpumask REVERT: 318bf9faa01 Rollup merge of #115494 - RalfJung:primitive_docs, r=Mark-Simulacrum REVERT: 8b9a61f59f0 Rollup merge of #109409 - WaffleLapkin:progamer, r=dtolnay REVERT: 3361aa160da Fill-in tracking issue for `feature(cmp_minmax)` REVERT: ae944473b81 Add `minmax*` functions to `core::cmp` REVERT: 147de3c4c6a get rid of duplicate primitive_docs REVERT: fadf21c612a Auto merge of #108043 - a1phyr:string_write_fmt, r=workingjubilee REVERT: eab39107c8b Auto merge of #115547 - WaffleLapkin:spin_looping, r=Mark-Simulacrum REVERT: 6dc8de3ed4c Specialize `fmt::Write::write_fmt` for `Sized` types REVERT: 459b122db6d Rollup merge of #115477 - kellerkindt:stabilized_int_impl, r=dtolnay REVERT: 74d4a131cd2 Rollup merge of #115434 - soqb:ascii-char-manual-debug, r=dtolnay REVERT: a6ed6d65b6e Rollup merge of #114965 - benschulz:mpsc-drop, r=dtolnay REVERT: 1263bfa819a Auto merge of #113748 - clarfonthey:ip-step, r=dtolnay REVERT: 0788b18cb85 Auto merge of #115782 - a1phyr:improve_pad_adapter, r=dtolnay REVERT: 8165c974c5f Auto merge of #113753 - dvdsk:master, r=dtolnay REVERT: a6257fad217 Rollup merge of #115895 - 52:patch-docs-vec-truncate, r=dtolnay REVERT: 68024dba27e Rollup merge of #115560 - ShE3py:format-results, r=dtolnay REVERT: 5a0fd487bb5 Rollup merge of #115487 - ModProg:patch-1, r=dtolnay REVERT: b2feb38f581 Rollup merge of #115329 - xzmeng:fix-std-doc, r=dtolnay REVERT: e872ec46300 Rollup merge of #115247 - the8472:life-before-main, r=dtolnay REVERT: 83d586e596f Auto merge of #112229 - clarfonthey:range-iter-count, r=dtolnay REVERT: ac242ceaf7e edit `std::collections::VecDeque` docs REVERT: 679bec732f8 edit `std::vec::Vec::truncate` docs REVERT: d0b350af4e2 Rollup merge of #115607 - RalfJung:safe-traits-unsafe-code, r=dtolnay REVERT: e3ac107aeb5 fix a comment about assert_receiver_is_total_eq REVERT: ce766420eef Specialize count for range iterators REVERT: 134d80d201b impl Step for IP addresses REVERT: 077fdf6b520 Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726 REVERT: bbb7cdcb11c Auto merge of #115520 - Finomnis:const_transmute_copy, r=dtolnay REVERT: f0abd2360af Bump libc to 0.2.148 REVERT: d897473f556 Auto merge of #114656 - bossmc:rework-no-coverage-attr, r=oli-obk REVERT: 2d00e297ad8 Disabled socketpair for Vita REVERT: ce978cec6a7 Improve `PadAdapter::write_char` REVERT: bbfcbddb47a Refactor `thread_info` to remove the `RefCell` REVERT: de385c76954 Auto merge of #114967 - japaric:ja-gh114966, r=Mark-Simulacrum REVERT: fff02c349e2 Auto merge of #114590 - ijackson:stdio-stdio-2, r=dtolnay REVERT: 4352b43e0e7 std::process (unsupported): Implement From etc. for imp::Stdio REVERT: 0e6026f9073 Rollup merge of #115201 - notriddle:notriddle/type-alias-impl-list, r=GuillaumeGomez REVERT: 22fbd092b19 Rollup merge of #104299 - mkrasnitski:discriminant-transmute-docs, r=oli-obk REVERT: d2362021763 Partially outline code inside the panic! macro REVERT: 427dc6124b7 Rename the feature, but not the attribute, to `coverage_attribute` REVERT: a058cc2296a Rework no_coverage to coverage(off) REVERT: fc8d4505245 Auto merge of #114299 - clarfonthey:char-min, r=dtolnay,BurntSushi REVERT: 949ecce6a3d Guarantee that Layout::align returns a non-zero power of two REVERT: 48d24b87032 Auto merge of #115617 - coastalwhite:bump-stdarch-riscv-intrinsics, r=Amanieu REVERT: dad74562f2b Don't modify libstd to dump rustc ICEs REVERT: b38df3949db Auto merge of #115166 - Urgau:invalid_ref_casting-invalid-unsafecell-usage, r=est31 REVERT: e034a794433 Auto merge of #115580 - eduardosm:stdarch-intrinsics, r=davidtwco,bjorn3 REVERT: 71d67ef1feb Bump: Include RISC-V intrinsics for stdarch REVERT: 63ae4d9e4f9 Fix minor grammar typo REVERT: 0faa48742d1 fix typo REVERT: 0899ae53b1a clarify that unsafe code must not rely on our safe traits REVERT: 3dc829d2c54 Update doc for `alloc::format!` and `core::concat!` REVERT: f57784c13db Auto merge of #115453 - ibraheemdev:patch-16, r=joshtriplett REVERT: 533f2d0ade4 Rollup merge of #114794 - RalfJung:swap-safety, r=m-ou-se REVERT: 329adae000f Bump stdarch submodule REVERT: 0ea189ff7bf fix a comment in std::iter::successors REVERT: 82d7fe05aba if -> when REVERT: da77fabdb6e Rollup merge of #115540 - cjgillot:custom-debuginfo, r=oli-obk REVERT: 27599f9e8e3 Rollup merge of #114813 - RalfJung:fpu-control, r=Amanieu REVERT: 95f4046a5d9 Rollup merge of #114412 - RalfJung:libc-symbols, r=pnkfelix REVERT: ee69335089f Rollup merge of #113510 - ink-feather-org:const_ptr_transmute_docs, r=RalfJung REVERT: d45d2459865 Weaken needlessly restrictive orderings on Arc::*_count REVERT: cdc6dd76e78 Simplify `core::hint::spin_loop` REVERT: 9d4c75301c3 "what would rustfmt do" REVERT: 15e050cddb8 Auto merge of #115493 - Ayush1325:raw-os-error, r=workingjubilee REVERT: 69be5325f4e Clarify ManuallyDrop bit validity REVERT: 0ab49c1ebca Auto merge of #115491 - Zoxc:refcell-tweak, r=Mark-Simulacrum REVERT: 7bfdc2ab4dc Stabilize const_transmute_copy REVERT: 9faf2893c85 Rollup merge of #115512 - Fulgen301:startupinfow, r=ChrisDenton REVERT: 80d8bffa2b4 Rollup merge of #115489 - saethlin:is-interrupted, r=thomcc REVERT: e2d99dc997f Rollup merge of #115279 - schuelermine:patch/doc/RangeFull/remote-parens, r=Mark-Simulacrum REVERT: 39b2b5135bc unchecked layout calculations when shrinking during in-place collect REVERT: 9058c964967 relax size and alignment requirements for in-place iteration REVERT: a2d8a577e25 support in-place collecting additional FlatMap shapes REVERT: a0fdbf415b3 update in-place-iteration module docs REVERT: 63c4a15f43a don't leak items if alloc::shrink panics REVERT: 7dc28366f31 Expand in-place iteration specialization to Flatten, FlatMap and ArrayChunks REVERT: 852dbabf921 Command::spawn: Fix STARTUPINFOW.cb being initialized with the address of size_of REVERT: 4c54e41b436 Use std::io::Error::is_interrupted everywhere REVERT: 4446221726e Merge from rustc REVERT: f042df56a04 Move RawOsError defination to sys REVERT: e5e8866f2e8 Outline panicking code for `RefCell::borrow` and `RefCell::borrow_mut` REVERT: e11f0bcbcbd Stabilize the Saturating type (saturating_int_impl, gh-87920) REVERT: 11ae749faa2 Unimpl Shl, ShlAssign, Shr and ShrAssign for Saturating REVERT: 657d5c1387e Improve documentation on when signes are printed by default REVERT: aa77122fda8 Auto merge of #115273 - the8472:take-fold, r=cuviper REVERT: ebe4667a02e Rollup merge of #115449 - scottmcm:stable-const-is-ascii, r=ChrisDenton REVERT: 16a2d81a268 Rollup merge of #115443 - epage:os_str, r=cuviper REVERT: f82639f04f7 Rollup merge of #115427 - solid-rs:patch/kmc-solid/is-interrupted, r=cuviper REVERT: 664598a3a6a Rollup merge of #114845 - scottmcm:npo-align, r=WaffleLapkin REVERT: 95a89f9aba8 don't panic in BorrowedCursor::write REVERT: 636fe4a703c Merge from rustc REVERT: e13abf03cdc fix(std): Rename os_str_bytes to encoded_bytes REVERT: aaf6c727925 Auto merge of #113295 - clarfonthey:ascii-step, r=cuviper REVERT: f492326ec28 stabilize `io_error_other` feature REVERT: 45dd4867dbc Update mod.rs REVERT: 6d95a279cdc Const-stabilize `is_ascii` REVERT: d041ae8b3b0 Support bootstrap. REVERT: 2ef9e53a80d Support debuginfo for custom MIR. REVERT: 379077ed859 feat(std): Stabilize 'os_str_bytes' feature REVERT: d4caab5a68d Auto merge of #114065 - lukas-code:u16_from_char, r=dtolnay REVERT: aa7a3da104d fix `Debug` impl for `AsciiChar` REVERT: 57854eb52b4 [`clippy`] Use symbols intended for `arithmetic_side_effects` REVERT: c7b6aa3c9ba Auto merge of #114448 - SteveLauC:std_fs_read_doc, r=Mark-Simulacrum REVERT: 8c471d7386a kmc-solid: Refactor `is_interrupted` to avoid integer overflow REVERT: b4cf127ee35 docs: improve std::fs::read doc REVERT: e41f31734d5 kmc-solid: Directly delegate to `net::is_interrupted` in `std::sys::solid::is_interrupted` REVERT: 50f66987930 std::thread::set_name exploit the return on haiku REVERT: 35092395525 further expand on Arc and Box analogy REVERT: 9d33437ebc0 Implement `CStr::count_bytes` REVERT: 525c1f94c74 Refactor the const `strlen` implementation to `const_strlen` REVERT: 337ff1025ae rewording after comments by @thomcc REVERT: 334c99b4724 Auto merge of #114795 - RalfJung:cell-swap, r=dtolnay REVERT: 03cd11d0c46 Auto merge of #113859 - Manishearth:vec-as-mut-ptr-stacked-borrow, r=dtolnay REVERT: eda85d1fcab Auto merge of #115312 - hermitcore:hermit-is_interrupted, r=thomcc REVERT: a4290ec9ffb Auto merge of #115309 - hermitcore:hermit-net-init, r=cuviper REVERT: 79b1962bca4 fix std::primitive doc: homogenous -> homogeneous REVERT: c3a939f23c3 fix a doc typo at std::os::unix::fs::FileExt::write_at REVERT: 33753accde0 Remove old bindings that have been moved REVERT: 7cfa10202d2 Add GetActiveProcessorCount and process attributes REVERT: 56b512d62b8 Abstract over internal `SOCKET` type REVERT: be10e64a42c Update windows ffi bindings REVERT: 2efbbe71cb7 Rollup merge of #115311 - dtolnay:usearcself, r=compiler-errors REVERT: 288c90b2c99 Rollup merge of #115310 - RalfJung:panic-and-format, r=scottmcm REVERT: 34ca3760785 reduce indirection in for_each specialization REVERT: 5b48f5f39c4 Auto merge of #114848 - michaelvanstraten:spawn_with_attributes, r=ChrisDenton REVERT: 5502997bbf2 fix(sys/hermit): add is_interrupted REVERT: 58ebdb0d623 fix(sys/hermit): remove obsolete network initialization REVERT: 7a29f9df5db Revert "Suggest using `Arc` on `!Send`/`!Sync` types" REVERT: e4b3cbd4bdf Revert "Make `rustc_on_unimplemented` std-agnostic for `alloc::rc`" REVERT: 2e9cfc6efbe improve panic.md edition disucssion, and nits REVERT: 6728269ea56 format, format_args: Make xref to std::fmt much more prominent REVERT: 5d9a6c5ea67 panic macro: Link directly to format syntax, not to format! REVERT: 81d1bdb0f45 print macros: add xrefs to format syntax documentation REVERT: df996386bdd panic macro: Document edition differences REVERT: ece3b84f982 Auto merge of #103836 - H4x5:extra-float-constants, r=thomcc REVERT: 73bf7cbd500 Rollup merge of #115280 - RalfJung:panic-cleanup-triple-backtrace, r=Amanieu REVERT: 93b883ae56c Rollup merge of #114512 - devnexen:fix_tests_fbsd, r=thomcc REVERT: d23e2e215ab Rollup merge of #114238 - jhpratt:fix-duration-div, r=thomcc REVERT: 4a45117e269 Rollup merge of #109660 - ijackson:leap, r=thomcc REVERT: dbf16386c10 Auto merge of #115254 - cuviper:aligned_alloc-size, r=thomcc REVERT: 898ae6a65ee avoid triple-backtrace due to panic-during-cleanup REVERT: 95ab305ee37 Remove parens around .. in documentation snippet REVERT: 1eafb85ce8e Optimize Take::{fold, for_each} when wrapping TrustedRandomAccess iterators REVERT: 012037290f2 Auto merge of #115263 - matthiaskrgr:rollup-taqu2h0, r=matthiaskrgr REVERT: 00acb8bf8cc Rollup merge of #115007 - kpreid:alloc, r=Mark-Simulacrum REVERT: 071a1390012 Auto merge of #114969 - kpreid:dropdoc, r=Mark-Simulacrum REVERT: 69d6ff25c85 wasi: round up the size for `aligned_alloc` REVERT: fa14d54681d Document std limitations before/after main REVERT: 900f0e759d2 Rollup merge of #115210 - DogPawHat:std-agnostic-rustc_on_unimplemented-for-alloc-rc, r=WaffleLapkin REVERT: 7be4142c4b6 Rollup merge of #115197 - tbu-:pr_simpler_ipv6_addr_display, r=joshtriplett REVERT: 76d5dc74ffe Auto merge of #115228 - saethlin:is-interrupted, r=thomcc REVERT: 62d528afbc3 Add a new helper to avoid calling io::Error::kind REVERT: c4a8342fad6 Make `rustc_on_unimplemented` std-agnostic for `alloc::rc` REVERT: 744ad4cb9b6 Auto merge of #115133 - coderwithcat:master, r=cuviper REVERT: 4730cd04938 Added option to set ProcThreadAttributes for Windows processes REVERT: ff8dbe86dac Auto merge of #115045 - RalfJung:unwind-terminate-reason, r=davidtwco REVERT: 1a19c4dec04 use the correct link REVERT: 28e388d17f2 Rollup merge of #114754 - workingjubilee:gamma-ray-logger, r=thomcc REVERT: 24db62cf998 Fix intra-doc links from pointer appearing in windows HANDLE type alias REVERT: e91db6d6a51 Remove special cases that are no longer needed due to #112606 REVERT: c61c748a47c Rollup merge of #115124 - solid-rs:patch/kmc-solid/import-poison-error-in-os, r=cuviper REVERT: 60593e61a92 Lint on invalid UnsafeCell::raw_get with invalid_reference_casting lint REVERT: a58bd115538 document more things as needing to stay in sync REVERT: cb2a23464ec when terminating during unwinding, show the reason why REVERT: ee421a285c4 Auto merge of #115094 - Mark-Simulacrum:bootstrap-update, r=ozkanonur REVERT: 1a559367754 also use 'env' for printing unsetting REVERT: a41d7fa2379 also print clearing the environment entirely REVERT: 2e0128e851e fix a typo in env_clear docs REVERT: 6ca4b54f29d make unsetting env vars print as executable command REVERT: 80704f64ff2 Command: also print removed env vars REVERT: 240fd38adaf Bump cfg(bootstrap) REVERT: ddcd7fb06c0 Auto merge of #115112 - tmandry:backtrace-0369, r=compiler-errors REVERT: 28a874b3777 Rollup merge of #114696 - g0djan:godjan/fix_114610, r=Mark-Simulacrum REVERT: 590f06e9c9c Rollup merge of #115100 - Urgau:invalid_ref_casting-ptr-writes, r=est31 REVERT: f51a9dd2b40 Rollup merge of #115053 - waywardmonkeys:augment-type-keyword-docs, r=cuviper REVERT: f7edd4c770e kmc-solid: Import `std::sync::PoisonError` in `std::sys::solid::os` REVERT: e0d063c1056 Bump backtrace to 0.3.69 REVERT: e6768378f68 std: unix process_unsupported: Provide a wait status emulation (tidy) REVERT: 93312ec2c88 fixup! std: unix process: Test exit statuses / wait statuses REVERT: b3cf568187d std: unix process_unsupported: Provide a wait status emulation (fmt) REVERT: 3f213c999b4 fixup! std: unix process_unsupported: Provide a wait status emulation REVERT: e99c89a654d std: unix process: Test exit statuses / wait statuses REVERT: d7212e39dcc std: unix process_unsupported: Provide a wait status emulation REVERT: 46df6ba2af1 Improve UdpSocket documentation REVERT: fc1a07566db Add support for ptr::write for the invalid_reference_casting lint REVERT: fdd1db9f8be std: enable feature(slice_ptr_len) on xous REVERT: 35326b4210f std: xous: add support for locks REVERT: 33703123532 std: xous: add thread_local_key REVERT: 52afeed5c11 std: xous: add thread support REVERT: a6008c5fe38 std: xous: add support for time REVERT: 8117b334a54 std: xous: add output support for stdio REVERT: e33f714c884 std: xous: add services support REVERT: ffaa9038803 panic_abort: call __rust_abort on xous REVERT: b2f14f1ac22 std: xous: add alloc support REVERT: c4d4c8d9be0 std: process: skip tests on xous REVERT: 0760edcf220 std: fs: skip fs tests on xous REVERT: 94f014cadd9 std: net: skip tests on xous REVERT: 7e70fa7a97f std: xous: the basics of `os` REVERT: 42bdf64a3b8 std: xous: add os-specific ffi calls REVERT: 34e0683b85c Replace version placeholders with 1.73.0 REVERT: 451c49d4311 clarify what you cannot do REVERT: 2546d9e09b7 typos and wording REVERT: 38e439d9ab0 libstd: add xous to libstd REVERT: 459fe1bf5af Auto merge of #113365 - dima74:diralik/add-deprecated-suggestions, r=workingjubilee REVERT: 9ea094108c3 docs: add alias log1p to ln_1p REVERT: b41b00fa294 docs: Add example, reference link for `type` keyword. REVERT: df67d53a1b9 try to clarify wording REVERT: 73433c7daf8 Add `suggestion` for some `#[deprecated]` items REVERT: 55e7fbe3a18 Add data race test to `std::env::{get, set}` REVERT: 23cccee4e85 Rollup merge of #115000 - RalfJung:custom-mir-call, r=compiler-errors,JakobDegen REVERT: 1e4afb9f90d Rollup merge of #114968 - ShE3py:unix-getsetenv-ub, r=thomcc REVERT: e46d614efcf Auto merge of #113167 - ChAoSUnItY:redundant_explicit_link, r=GuillaumeGomez REVERT: 4f4fc1361f4 Rollup merge of #114983 - crlf0710:formatmsg, r=ChrisDenton REVERT: 60ac46abfe1 Rollup merge of #114973 - shepmaster:std-provide-value, r=Amanieu REVERT: bb27c071315 Rollup merge of #114950 - xfix:inline-cstr-from-ptr, r=cuviper REVERT: b1aee38db59 Rollup merge of #114605 - Easyoakland:hash-collection-doc, r=thomcc REVERT: dc1d5c878cd custom_mir: change Call() terminator syntax to something more readable REVERT: 5b77ed30bc4 Correct and expand documentation of `handle_alloc_error` and `set_alloc_error_hook`. REVERT: 57754aee676 Usage zero as language id for FormatMessageW() REVERT: b88992f8a3a Rollup merge of #114977 - kpreid:modulo, r=thomcc REVERT: 96111bfaad2 Rollup merge of #114971 - kpreid:trig, r=joshtriplett REVERT: f14af4689a4 Add `modulo` and `mod` as doc aliases for `rem_euclid`. REVERT: 1c534c74ba7 Auto merge of #114591 - joboet:thread_parking_ordering_fix, r=thomcc REVERT: fa9cba7e9d2 Expose core::error::request_value in std REVERT: a653a86a686 Add doc aliases for trigonometry and other f32,f64 methods. REVERT: 7d67d881511 Go into more detail about panicking in drop. REVERT: 0ee6de08222 Fix UB in `std::sys::os::getenv()` REVERT: 7a7c42565be QNX: pass a truncated thread name to the OS REVERT: c32690f679a Remove Drop impl of mpsc Receiver and (Sync)Sender REVERT: 4ad8eaccfa3 resolve conflicts REVERT: a57bace743a relax redundancy constraint REVERT: 07e4fb8c75b resolve conflicts REVERT: 4e3056a6300 resolve conflicts REVERT: 2d6edd371f0 tidy doc link REVERT: a4dd43d9269 lint links REVERT: 19a07677062 Inline strlen_rt in CStr::from_ptr REVERT: 0e5f0509bed Rollup merge of #114897 - joshtriplett:partial-revert-ok-0, r=m-ou-se REVERT: 0f2287ec7e5 Auto merge of #114799 - RalfJung:less-transmute, r=m-ou-se REVERT: 966159fd4fb Rollup merge of #114881 - RalfJung:cstr, r=cuviper REVERT: 4db6dace343 Rollup merge of #114749 - gurry:issue-114722, r=thomcc REVERT: 0684199658c Update library/alloc/src/vec/mod.rs REVERT: 93a688ce446 Auto merge of #114905 - matthiaskrgr:rollup-uxhhr7p, r=matthiaskrgr REVERT: 6fd87da2437 Update library/alloc/src/vec/mod.rs REVERT: 74d9d630a90 Rollup merge of #114784 - Urgau:many-improve-invalid_reference_casting-lint, r=est31 REVERT: 7cf969e1cc5 Auto merge of #114617 - petrochenkov:docspacing, r=Mark-Simulacrum REVERT: c4239e2067e Partially revert #107200 REVERT: d837ffe6c78 proc_macro: Update docs for `Spacing` REVERT: bc46f207a7c address comments REVERT: c83155d06b0 Fix a pthread_t handle leak #114610 REVERT: fe42f969af8 clarify CStr lack of layout guarnatees REVERT: bbde19b7917 use mem::swap instead of ptr::swap_nonoverlapping REVERT: 9fe618e8363 Rollup merge of #114871 - schvv31n:fix-link-in-docs, r=scottmcm REVERT: 8dfcdf87d6f Rollup merge of #114867 - ttsugriy:ttsugriy-patch-1, r=scottmcm REVERT: b666b554b07 Rollup merge of #114861 - RalfJung:no-effect, r=wesleywiser REVERT: 630e4a41734 Rollup merge of #114721 - danflapjax:bool-ord-optimization, r=cuviper REVERT: 3f34997d81c Auto merge of #114689 - m-ou-se:stabilize-thread-local-cell-methods, r=thomcc REVERT: c4fba9d1f41 Auto merge of #111071 - nyurik:simpler-issue-94005, r=m-ou-se REVERT: 3b02b27b9f9 other elements REVERT: 009a0cc8762 Update the link in the docs of `std::intrinsics` REVERT: bcc8b442f71 Cleaner assert_eq! & assert_ne! panic messages REVERT: 18641b76f44 [nit] Fix a comment typo. REVERT: 29a3c05f36d Rollup merge of #114837 - RalfJung:error_in_core, r=cuviper REVERT: 23c802b6099 Rollup merge of #114619 - g0djan:godjan/fix_#114608, r=m-ou-se REVERT: b3d9defea23 Rollup merge of #114588 - ijackson:exit-status-default-2, r=m-ou-se REVERT: f45b8324802 fix typo: affect -> effect REVERT: 067daf763fa Auto merge of #114852 - GuillaumeGomez:rollup-vjagxjr, r=GuillaumeGomez REVERT: 8388bb07350 Update library/alloc/src/vec/mod.rs REVERT: 7236910c1fe Update library/alloc/src/vec/mod.rs REVERT: 7005d37348c Document Default for ExitStatus REVERT: 3d2ebbdd47b Auto merge of #112387 - clarfonthey:non-panicking-ceil-char-boundary, r=m-ou-se REVERT: fc1273fea6d Fix typo. REVERT: 6be6732114f Rollup merge of #114800 - RalfJung:transparent, r=cuviper REVERT: 7362c87da66 clarify that these assumtpions are for us, not all Rust code REVERT: 7d5446b7c51 Add alignment to the NPO guarantee REVERT: 43df78d1a43 Add diagnostic items for `<*const _>::cast` and `<*mut _>::cast_const` REVERT: a8dfd08c3a7 add missing feature(error_in_core) REVERT: 9a2340352a8 Auto merge of #113658 - Dirreke:csky-unknown-linux-gunabiv2, r=bjorn3 REVERT: 0bcf80c0373 actually this doesn't even affect doctests. nice. REVERT: ee0107a398e Auto merge of #113464 - waynr:remove-provider-trait, r=Amanieu REVERT: a4fff0d99e2 Upgrade Object and related deps REVERT: 4fdde92cf95 add a csky-unknown-linux-gnuabiv2 target REVERT: 3de838281c3 reference-counting analogy REVERT: eaf32a772a3 explain why we can mutate the FPU control word REVERT: 9ea7df4d510 reword the paragraph on file description ownership REVERT: 7eb96ad0e3a don't link to RFCs, they are not up-to-date docs REVERT: 0c669858189 std: add some missing repr(transparent) REVERT: 286bf517f9e avoid transmuting Box when we can just cast raw pointers instead REVERT: efa8ae0ff1d simplify is_nonoverlapping a bit REVERT: d4cbb5ac8fa make Cell::swap panic if the Cells partially overlap REVERT: b2dcc332a6e clarify safety documentation of ptr::swap and ptr::copy REVERT: 776b0a3d81a mention /proc/self/fd with /proc/self/mem REVERT: 51cab1baf46 wording; and explain some of the possible consequences of violating io-safety REVERT: 28533218884 typos REVERT: a447e897a85 sync the various FromRawFd trait docs, and remove 'valid' REVERT: a6b9716c89c Implement Step for AsciiChar REVERT: 8f3d34c7a8a core/any: remove Provider trait REVERT: b93842ad13f Rollup merge of #114069 - cuviper:profiler-path, r=Mark-Simulacrum REVERT: be4112112fd Rollup merge of #94667 - frank-king:feature/iter_map_windows, r=Mark-Simulacrum REVERT: a10269eccc3 add more explicit I/O safety documentation REVERT: 073ad77da53 aliasing guarantee REVERT: 19a2c92f616 Rollup merge of #114132 - tamird:better-env-debug-impls, r=Amanieu REVERT: 6f021e67955 Name what ln_gamma does REVERT: fe5d10e0b00 Remove unnecessary feature gates REVERT: b6feab3a1a2 Partially stabilize #![feature(int_roundings)] REVERT: 418e39f2e58 Update Sender documentation for Sync REVERT: 98f52b0d696 Auto merge of #114720 - scottmcm:better-sub, r=workingjubilee REVERT: 010ec4e3be5 Auto merge of #113432 - klensy:ms-cut-backtrace, r=ChrisDenton REVERT: 9cb000b13e3 Tell LLVM that the negation in `<*const T>::sub` cannot overflow REVERT: 8ac99e2d67b Optimized implementations of max, min, and clamp for bool REVERT: cabb6af2af7 Rollup merge of #114402 - tifv:tifv-fix-rc-doc, r=cuviper REVERT: bfe6d2de7bc Rollup merge of #114359 - ttsugriy:barrier-simpl, r=cuviper REVERT: c28f3b08887 Rollup merge of #114257 - rytheo:linked-list-avoid-unique, r=cuviper REVERT: 9dd4c7074e3 Rollup merge of #114194 - thomcc:flushinline, r=cuviper REVERT: 1e7643db65d Add Iterator::map_windows REVERT: 5c8e5827447 Stabilize thread local cell methods. REVERT: 8df5cb6f09f Rollup merge of #114377 - Enselic:test_get_dbpath_for_term-utf-8, r=thomcc REVERT: 03cf41a6baf Suggest using `Arc` on `!Send`/`!Sync` types REVERT: 610e2f92f7e Auto merge of #114646 - matthiaskrgr:rollup-xf7qnmn, r=matthiaskrgr REVERT: c8247158ebf Rollup merge of #114641 - kupiakos:ascii-char-to-not-as, r=scottmcm REVERT: 11b8ec81f5a Rollup merge of #113939 - the8472:pidfd-from-child, r=Mark-Simulacrum REVERT: 40b300e6ab4 Auto merge of #99747 - ankane:float_gamma, r=workingjubilee REVERT: eb4da0bc2cd Rename copying `ascii::Char` methods from `as_` to `to_` REVERT: 0163d78aa85 open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSG REVERT: c87def9aa8b Rollup merge of #106425 - ijackson:exit-status-default, r=dtolnay REVERT: d5b032ec666 Fix #114608 REVERT: ce59352e112 Increase clarity about Hash - Eq consistency in HashMap and HashSet docs REVERT: 0c9acf07d65 Bump compiler_builtins to 0.1.100 REVERT: 7b6a172cfa3 core: Remove #[macro_export] from `debug_assert_matches` REVERT: 54d3aad41e9 std: synchronize with all calls to `unpark` in id-based thread parker REVERT: dd30031d26b Better Debug for Vars and VarsOs REVERT: 4c7d4c59e94 impl Default for ExitCode REVERT: a15fcb851ef Rollup merge of #114562 - Trolldemorted:thiscall, r=oli-obk REVERT: fc3c91664d9 Adjust the duration_since(UNIX_EPOCH) docs REVERT: 042626bfba6 impl Default for ExitStatus REVERT: 2c7cdd11f72 std::process: impl From (etc.) for Stdio REVERT: 5230f43c31a std::process (windows): Implement From etc. for imp::Stdio REVERT: 80d493e9d82 std::process (windows): refactor Stdio::to_handle slightly REVERT: 206af1b5aa6 std::process (unix): Implement From etc. for imp::Stdio REVERT: 22ae332f4bf stabilize abi_thiscall REVERT: 3ed11891872 Rollup merge of #114382 - scottmcm:compare-bytes-intrinsic, r=cjgillot REVERT: 99cae0f098a Rollup merge of #114365 - tshepang:patch-6, r=Mark-Simulacrum REVERT: 7b6b3c72354 Rollup merge of #114362 - tshepang:patch-1, r=Mark-Simulacrum REVERT: d3d94bbce1b Rollup merge of #98935 - kellerkindt:option_retain, r=Mark-Simulacrum REVERT: e56b825f2f3 Add a new `compare_bytes` intrinsic instead of calling `memcmp` directly REVERT: b9189e1596a Rollup merge of #114519 - the8472:dirent-offset-of, r=dtolnay REVERT: d3611a76cef Remove ptr_from_mut diagnostic item REVERT: fb1a71bcb24 Add #[rustc_never_returns_null_ptr] to std functions REVERT: 36f51e44241 Auto merge of #111200 - a1phyr:spec_sized_iterators, r=the8472 REVERT: dfb58831435 use offset_of! to calculate dirent64 field offsets REVERT: 954221bf73b Rollup merge of #114029 - Enselic:clone-doc, r=scottmcm REVERT: e78db6b613b std/tests: disable ancillary tests on freebsd since the feature itself is. REVERT: c097c6c4cea document our assumptions about symbols provided by the libc REVERT: 4651b16f599 Rollup merge of #114373 - xstaticxgpx:dev, r=the8472 REVERT: a79a14a78e6 unix/kernel_copy.rs: copy_file_range_candidate allows empty output files REVERT: 6f152dc8510 Auto merge of #108955 - Nilstrieb:dont-use-me-pls, r=oli-obk REVERT: 3d9e40db1c4 Convert `Into for ExitStatusError` to `From for ExitStatus` in `std::process` REVERT: c4874fe84b2 Rollup merge of #113657 - Urgau:expand-incorrect_fn_null_check-lint, r=cjgillot REVERT: e6e254e1e2c Add `internal_features` lint REVERT: 8f1a98484d3 Add assertion to test `skip_until` return value REVERT: d048e8ad733 Fix documentation of Rc as From> REVERT: f6199afbb8e Implement Option::take_if REVERT: ec080749e94 Auto merge of #113220 - tgross35:cstr-bytes-docs, r=workingjubilee REVERT: f71d2d8528f test_get_dbpath_for_term(): handle non-utf8 paths REVERT: 3d93d22e376 test_get_dbpath_for_term(): Use assert_eq!() REVERT: d7a6afcb5cb Document soundness of Integer -> Pointer -> Integer conversions in ` const` contexts. REVERT: a63c387b5fe Auto merge of #112431 - Urgau:cast_ref_to_mut_improvments, r=Nilstrieb REVERT: 5dd1465b8c1 str.rs: remove "Basic usage" text REVERT: 37bd4acd4e7 string.rs: remove "Basic usage" text REVERT: 40e624aa41e Clarify documentation for `CStr` REVERT: 4e14d795511 [library/std] Replace condv while loop with `cvar.wait_while`. REVERT: dabec21cb82 Auto merge of #112922 - g0djan:godjan/wasi-threads, r=wesleywiser REVERT: b04da8adaa0 Add diagnostic items for `<*const _>::cast` and `ptr::from_mut` REVERT: 8791449d045 Auto merge of #114331 - matthiaskrgr:rollup-rnrmwcx, r=matthiaskrgr REVERT: 3e62c754bf4 Rollup merge of #100455 - xfix:backtrace-ref-unwind-safe, r=dtolnay REVERT: 36743583bba Auto merge of #112849 - m-ou-se:panic-message-format, r=thomcc REVERT: cd2ee9682b9 Aborting when `before_wait` function panics REVERT: ae46414fcc4 Rollup merge of #111081 - mattfbacon:master, r=workingjubilee REVERT: 21f1cf1910d Auto merge of #114308 - matthiaskrgr:rollup-m64bkm7, r=matthiaskrgr REVERT: 84333a07371 Rollup merge of #113701 - aswild:std-ffi-frombytesuntilnul, r=dtolnay REVERT: 084a33cd26d Rollup merge of #109318 - joboet:better_fmt_placeholder, r=dtolnay REVERT: 36a1b808ccd Rollup merge of #114111 - allaboutevemirolive:add-test-case-string, r=Mark-Simulacrum REVERT: 4851dcb7ac4 Rollup merge of #113717 - cuishuang:master, r=Nilstrieb REVERT: c8fe0cfecf5 Rollup merge of #112858 - chriswailes:riscv64-android, r=Mark-Simulacrum REVERT: cc0451b8c5c I'm mathematically challenged REVERT: b497a7c4bed Work around missing <*str>::len REVERT: 0e2e6ebffca impl SliceIndex for (Bound, Bound) REVERT: 54edbaaa172 Can't compare usize and u32 REVERT: b11ee289544 Use u32::from for MIN/MAX examples REVERT: 25cad43953c Add note on gap for MIN/MAX REVERT: 56c3f52a23f Add char::MIN REVERT: 4100622876f Add gamma and ln_gamma functions to f32 and f64 REVERT: 2ca76537628 Clean up SGX user memory copies REVERT: 95a3632237e `waitqueue` clarifications for SGX platform REVERT: 8c4fe3b438b Implement UnwindSafe and RefUnwindSafe for Backtrace REVERT: 6f21117e5c6 remove repetitive words REVERT: d1e15d5ed66 Rollup merge of #114268 - SUPERCILEX:empty, r=workingjubilee REVERT: 3461d325933 Rollup merge of #109075 - joboet:lazylock_backtrace, r=workingjubilee REVERT: acc983aa555 Rollup merge of #95965 - CAD97:const-weak-new, r=workingjubilee REVERT: 95e52f38958 Stabilize const-weak-new REVERT: 985fdf7ff0f Auto merge of #112843 - chenyukang:yukang-more-on-backtrace, r=workingjubilee REVERT: a05f2f2a576 Fix empty_write since rust version attribute REVERT: d5d081c4e36 Rollup merge of #102198 - lukas-code:nonnull_as_ref, r=Amanieu REVERT: 9579451ae4f Rollup merge of #98154 - vidhanio:master, r=workingjubilee REVERT: e5c70cde671 Explain more clearly why `fn() -> T` can't be `#[derive(Clone)]` REVERT: cd15eae3732 Avoid using ptr::Unique in LinkedList code REVERT: 586d21a1a17 Rollup merge of #114223 - ryanoneill:vec-indexing-doc-language, r=workingjubilee REVERT: 1632bf893fb Rollup merge of #112655 - WaffleLapkin:must_use_map_or, r=workingjubilee REVERT: 423d3a86968 Rollup merge of #110056 - chenyukang:yukang/fix-110045, r=workingjubilee REVERT: 35bbfce8fca Mark `map_or` as `#[must_use]` REVERT: c543674af83 rand use getrandom for freebsd (available since 12.x) REVERT: 337b7462a9a Fix the example in document for WaitTimeoutResult::timed_out REVERT: 03ef33f5505 Fix implementation of `Duration::checked_div` REVERT: d64000be680 Auto merge of #114236 - fee1-dead-contrib:rollup-m92j7q1, r=fee1-dead REVERT: e8ba34deec4 Rollup merge of #113512 - vallentin:lines-doc, r=workingjubilee REVERT: 88ccae3b2b1 Rollup merge of #112151 - chloekek:patch-1, r=workingjubilee REVERT: 066e02da7c7 Auto merge of #112280 - zica87:master, r=workingjubilee REVERT: 7c286727791 Documentation: Fix Stilted Language in Vec->Indexing REVERT: 0358fa14057 Add wasm32-wasi-threads target + WASI threads REVERT: 454ab9f5e67 print omitted frames count for short backtrace mode REVERT: 9fe3a195204 Adjust some tests for invalid_reference_casting improvements REVERT: 85eca92c928 Change default panic handler message format. REVERT: b63c4ab00f3 Auto merge of #113099 - bvanjoi:fix-112713-2, r=petrochenkov REVERT: 3f14c47d215 Auto merge of #114197 - matthiaskrgr:rollup-iluf7u4, r=matthiaskrgr REVERT: c42fc2da647 Rollup merge of #114174 - tshepang:patch-6, r=workingjubilee REVERT: c2d4ae47fcc Rollup merge of #114173 - tshepang:patch-1, r=workingjubilee REVERT: 8a05af57278 Rollup merge of #114172 - fortanix:raoul/fix_process-spawning_test, r=workingjubilee REVERT: fba5523a1dc Rollup merge of #114171 - fortanix:raoul/fix_switch-stdout_test, r=workingjubilee REVERT: 1d0417de66c Auto merge of #111916 - fee1-dead-contrib:noop-method-call-warn, r=compiler-errors REVERT: 2dc4335e350 inline trivial (noop) flush calls REVERT: 824e97859fb Rollup merge of #114128 - estebank:delayed-span-bug-dump, r=davidtwco REVERT: ec0de5bd163 library: allow `ambiguous_glob_reexports` for `core_arch` REVERT: 5859a1edbf1 Fix issue_15149 test for the SGX target REVERT: dd3255d19f8 doc: replace wrong punctuation mark REVERT: 9d52b90e606 btree/map.rs: remove "Basic usage" text REVERT: c11eba248e7 Fix switch-stdout test for none unix/windows platforms REVERT: 25ef2bc09a1 reduce deps for windows-msvc targets for backtrace REVERT: 9378504aa5d Auto merge of #112390 - MoskalykA:move-two-tests-from-library-to-tests, r=workingjubilee REVERT: a31ea7e0f40 add LinkedList::{retain,retain_mut} REVERT: d9ad8b7508c Override `Waker::clone_from` to avoid cloning `Waker`s unnecessarily REVERT: 7c26d45279e When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist REVERT: 46c7e863210 Rollup merge of #114109 - veera-sivarajan:fix-str-docs, r=GuillaumeGomez REVERT: 6a68d0108b8 Rollup merge of #114091 - waywardmonkeys:doc-fmt-finish-comments, r=GuillaumeGomez REVERT: 0f3717eecad Auto merge of #114034 - Amanieu:riscv-atomicbool, r=thomcc REVERT: aaaaf0a1a08 Fix URL for `rmatches` REVERT: f95e144f6aa Improve test case for experimental API remove_matches in library/alloc/tests/string.rs REVERT: 24fab3ca316 Add tests and comments about `read_to_string` and `read_line` specializations REVERT: d366e26cd62 `io::Chain`: specialize some `BufRead` methods REVERT: 19d2d9dfd21 `io::Chain`: specialize some `Read` methods REVERT: 33122ba1e4c Rollup merge of #101994 - devnexen:rand_fbsd_update, r=workingjubilee REVERT: a6c845d0210 Add definitions for riscv64_linux_android target REVERT: 850878610b8 Have a better file name than just the issue id REVERT: 428555ad7ec docs: fmt::Debug*: Fix comments for finish method. REVERT: c00bef1ef92 std: add auto traits to TAIT bound REVERT: c0e4f82b03f Auto merge of #102757 - pcc:android-std-tests, r=workingjubilee REVERT: 2bd355547bb Auto merge of #113928 - nicholasbishop:bishop-update-cb-4, r=workingjubilee REVERT: db2f9e4debc Optimize `AtomicBool` for target that don't support byte-sized atomics REVERT: 6098b3467f5 Allow using external builds of the compiler-rt profile lib REVERT: 83c2b9dce1a Add note that Vec::as_mut_ptr() does not materialize a reference to the internal buffer REVERT: 0fd48457924 `impl TryFrom for u16` REVERT: fe59644cac3 Rollup merge of #114043 - cathaysia:doc_lazy_lock, r=thomcc REVERT: 15f1d448fda Auto merge of #112646 - vn971:document-thread-names-for-sgx-target, r=m-ou-se REVERT: 29511283185 Auto merge of #114020 - steffahn:hide-specialized-ToString-impls, r=thomcc REVERT: 73bd3107ca8 docs(LazyLock): add example pass local LazyLock variable to struct REVERT: b1fdaa22a63 Auto merge of #113411 - unikraft:unikraft, r=wesleywiser REVERT: fa273538623 core library: Disable fpmath tests for i386 ... REVERT: 36d7e395cc2 Implement `From<[T; N]>` for `Rc<[T]>` and `Arc<[T]>` REVERT: 7a93f485d75 Auto merge of #111362 - mj10021:issue-74838-update, r=cuviper REVERT: 53ada77e8b3 remove additional [allow(unused_unsafe)] REVERT: 5be6c19c756 Auto merge of #113687 - saethlin:inline-assertion-helpers, r=cuviper REVERT: 74e7d803452 delete [allow(...)] from issue #74838 REVERT: fb1d919d088 `unix::init`: Don't use `signal` on Unikraft. REVERT: 87562c4784b `unix::init`: Handle `ENOSYS` from `poll` on Unikraft. REVERT: 7b1d69e6918 Hide `ToString` implementations that specialize the default ones REVERT: f9e5dbc273d Auto merge of #113975 - matthiaskrgr:clippy_07_2023, r=fee1-dead REVERT: 3bea34c5c9f fix REVERT: 19e040bc0c0 fix couple of clippy findings: REVERT: c2030b26333 match on chars instead of &strs for .split() or .strip_prefix() REVERT: f2342aa8d85 Add #[inline] to core debug assertion helpers REVERT: a512e21c2af Auto merge of #113746 - clarfonthey:ip_bits, r=thomcc REVERT: 79ba586b751 Auto merge of #113954 - matthiaskrgr:rollup-e2r9suz, r=matthiaskrgr REVERT: dc7cc6414e5 Rollup merge of #113934 - ajtribick:string-pop-remove-multibyte, r=thomcc REVERT: 7f411f93f82 Rollup merge of #113898 - ajtribick:encode_utf16_size_hint, r=cuviper REVERT: bc5f0ac016f Rollup merge of #113876 - darklyspaced:master, r=cuviper REVERT: a6e917def5e Rollup merge of #113442 - epage:osstring, r=cuviper REVERT: 453b019f63b Rollup merge of #113252 - tgross35:const-cstr-from-ptr-tracking-issue, r=ChrisDenton REVERT: e63398a6d8b Rollup merge of #112490 - Alexendoo:c-char-cfg-all, r=cuviper REVERT: 2744d894555 Auto merge of #113224 - zachs18:vec_extend_remove_allocator_lifetime, r=cuviper REVERT: f6d61919b6c Auto merge of #113033 - JohnTitor:stabilize-unix-chown, r=cuviper REVERT: bb7208229fc Auto merge of #112699 - bluebear94:mf/more-is-sorted-tests, r=cuviper REVERT: a90cf763912 Clarify logic on bytes:code units ratio REVERT: b10d276daab Demonstrate multibyte character removal in String::pop and String::remove doctests REVERT: e2444a5c98e Bump compiler_builtins to 0.1.98 REVERT: 77cc0f02827 Auto merge of #113911 - matthiaskrgr:rollup-wk6cr7v, r=matthiaskrgr REVERT: db4b10486eb Rollup merge of #113907 - ChrisDenton:tls, r=thomcc REVERT: 94cc560bb0a Rollup merge of #113810 - glandium:allocator-fn, r=Amanieu REVERT: 2eda937b33c Auto merge of #113106 - marcospb19:improve-path-with-extension-function, r=thomcc REVERT: 682e886161c Auto merge of #105571 - kadiwa4:remove_atomic_init_consts, r=Amanieu REVERT: 93bec3d7ca2 Minor improvements to Windows TLS dtors REVERT: e591135c00a Fix size_hint for EncodeUtf16 REVERT: 604120a26b7 Get `!nonnull` metadata consistently in slice iterators, without needing `assume`s REVERT: 72829ef71c5 Auto merge of #113861 - ibraheemdev:mpsc-tls-bug, r=Mark-Simulacrum REVERT: 9dcdf0d59d3 added a problematic example REVERT: b1856d099a1 Rollup merge of #113787 - sanchopanca:process-command-windows-docs, r=ChrisDenton REVERT: bad1263145b fix docs & example for FileExt::write_at REVERT: e0ff46fc07d avoid tls access while iterating through mpsc thread entries REVERT: b9eb2be3dfb On nightly, dump ICE backtraces to disk REVERT: a00a0f32285 Link methods in From impls REVERT: ce58c9187c4 std::error::Error -> Trait Implementations: lifetimes consistency improvement REVERT: 31f90f7d8cd support for mips32r6 as a target_arch value REVERT: f9bb81a750d support for mips64r6 as a target_arch value REVERT: 63925f605a7 Update documentation for std::process::Command's new method REVERT: 5e13028dff1 remove the unstable `core::sync::atomic::ATOMIC_*_INIT` constants REVERT: 43e3f461665 Make {Rc,Arc}::allocator associated functions REVERT: 8fd2fedd40b Auto merge of #89132 - Cyborus04:rc_allocator_support, r=Amanieu REVERT: b978c586a30 Rollup merge of #113762 - alexpovel:master, r=Nilstrieb REVERT: 7f5e9e8e5ab Rollup merge of #113750 - nipzu:italicize-sort-complexity, r=workingjubilee REVERT: 526f9b9c5f1 adds crate attribute to examples so they compile REVERT: 8ee78ff104a Fix typo REVERT: f6539f58e73 Implement `From<{&,&mut} [T; N]>` for `Vec` REVERT: 3c72a594709 fix examples add tracking issue REVERT: 67811467fcc fixes sleep_until examples REVERT: c1970ad809f Fix sort_unstable_by_key italicization REVERT: 60e997f0de4 Add BITS, from_bits, to_bits to IP addresses REVERT: 7602dc556d6 collect.rs: remove "Basic usage" text where not useful REVERT: a4490234726 Adds thread::sleep_until, tracking issue TODO REVERT: 27cab814793 Rollup merge of #113662 - pedroclobo:vec-deque-rotate, r=thomcc REVERT: 14fda70200f std: add tests for `Path::with_extension` REVERT: 024c5e4e91b Re-export core::ffi::FromBytesUntilNulError in std::ffi REVERT: d5b85c30196 Auto merge of #113113 - Amanieu:box-vec-zst, r=Mark-Simulacrum REVERT: e9fbdf35043 Rollup merge of #113618 - tshepang:patch-1, r=jyn514 REVERT: eda09d741e7 Rollup merge of #112525 - hermitcore:devel, r=m-ou-se REVERT: e6fbc6f3035 Fix VecDeque's rotate_left and rotate_right panic tests REVERT: 255ee29288c Rename VecDeque's rotate_left and rotate_right parameters REVERT: 3bd0cbb5ff7 Eliminate ZST allocations in `Box` and `Vec` REVERT: d69a46ac1e1 Re-format let-else per rustfmt update REVERT: b6d99322af5 Flip cfg's for bootstrap bump REVERT: 54704b32972 Replace version placeholder to 1.72 REVERT: 7b00836a836 avoid ambiguous word REVERT: acb92f9853b use latest version of hermit-abi REVERT: df540edf817 fix usage of Timespec om the target hermit REVERT: 28cedd24d2c define hermit_abi as public depedenceny REVERT: 3eb50522fd0 add support of available_parallelism for target hermit REVERT: 0c6d1e0f9c8 update ancient note REVERT: 8fff287c682 Auto merge of #103754 - SUPERCILEX:filled-mut, r=m-ou-se REVERT: 64bee8c4426 Auto merge of #113175 - bryangarza:safe-transmute-rustc-coinductive, r=compiler-errors REVERT: 046c106e803 Auto merge of #113130 - chriswailes:android-library-defs, r=Amanieu REVERT: bc6f0f67c44 Auto merge of #111717 - Urgau:uplift_fn_null_check, r=oli-obk REVERT: 5bec0b1cb7d Correct the Android stat struct definitions REVERT: 23494a9ba17 Auto merge of #94748 - tbu-:pr_file_arc, r=Amanieu REVERT: 935db865ed9 Auto merge of #108796 - devsnek:personality-pal-exception, r=workingjubilee REVERT: 2eba3715c67 move personality to sys REVERT: dd5d48a7b12 Auto merge of #108485 - devsnek:float-pat-exception, r=workingjubilee REVERT: fe2c4fa5d5e move pal cfgs in f32 and f64 to sys REVERT: bdfb1aa6cf8 Updated lines doc to include trailing carriage return note REVERT: 801db6fbb09 Rollup merge of #113493 - the8472:spec-iocopy-slice, r=Mark-Simulacrum REVERT: 20d24a08239 Rollup merge of #113469 - JohnTitor:rm-default-free-fn, r=Amanieu REVERT: ba9e0e31656 additional io::copy specializations REVERT: 2ff2960c843 Rollup merge of #113064 - marcospb19:add-note-in-vec-swap-docs, r=Mark-Simulacrum REVERT: 796da8cc329 mark as stable REVERT: 776cf50f56d impl `From<&[T; N]>` for `Cow<[T]>` REVERT: f27c5568e21 Remove `default_free_fn` feature REVERT: 520df2c1138 Allow limited access to `OsString` bytes REVERT: be91fd86d85 Sync portable-simd to 2023 July 07 REVERT: 78717091046 Rollup merge of #113318 - tgross35:113283-allocator-trait-eq, r=m-ou-se REVERT: 8f6f9bd4aba Rollup merge of #112008 - intruder-kat:master, r=Nilstrieb REVERT: c464184d588 Auto merge of #113269 - jyn514:update-compiler-builtins, r=Amanieu REVERT: b8dab3eb0e7 Rollup merge of #113334 - fmease:revert-lexing-c-str-lits, r=compiler-errors REVERT: 19faeaa45f1 Auto merge of #113287 - RalfJung:miri-test-libstd, r=JohnTitor REVERT: 20e02a865dc Rollup merge of #113356 - he32:netbsd-riscv64, r=oli-obk REVERT: 4a1a2b1cdf4 Update compiler-builtins to 0.1.95 REVERT: 5a9fb37a910 Add support for NetBSD/riscv64 aka. riscv64gc-unknown-netbsd. REVERT: 776d882559d Revert "use c literals in library" REVERT: f96ac998ee6 Revert "fix ptr cast" REVERT: c5792404f11 Auto merge of #112594 - ChrisDenton:process=-kill, r=Amanieu REVERT: a9d307aaff4 Workaround for old android not having echo REVERT: 4db987c4a76 Revert "alloc: Allow comparing `Box`s over different allocators" REVERT: e1c8513f0eb Test Child::kill behaviour on exited process REVERT: f9afe0ea3d4 Add diagnostic items for `<*mut _>::is_null` and `<*const _>::is_null` REVERT: 329d337e8b5 enable test_join test in Miri REVERT: c95ee7798b9 Auto merge of #113271 - matthiaskrgr:rollup-2ik4vaj, r=matthiaskrgr REVERT: cdad96d405f Update std to backtrace 0.3.68 REVERT: 5af8651c350 Rollup merge of #113253 - nurmukhametdaniyar:rc_from_cstr_doc_fix, r=Nilstrieb REVERT: e9440186744 downgrade compiler_builtins REVERT: a9c633a4bb5 Rollup merge of #113202 - guilliamxavier:patch-1, r=workingjubilee REVERT: 029d226c26b Rollup merge of #113147 - lizhanhui:fix_vec_from_raw_parts_doc_example, r=Mark-Simulacrum REVERT: f0b35a5b88d fixed documentation of from for Rc: Arc -> Rc REVERT: 35449c4ceb9 Update the tracking issue for `const_cstr_from_ptr` REVERT: 32de72209e7 Remove lifetime bound for A for `impl Extend<&'a T> for Vec`. REVERT: cebb5799754 Auto merge of #111992 - ferrocene:pa-panic-abort-tests-bench, r=m-ou-se REVERT: 27ad775e5b4 Auto merge of #113194 - lu-zero:intrinsics-inline, r=thomcc REVERT: 9b1b9fa5e34 Return `Ok` on kill if process has already exited REVERT: 1fe8d3c4035 Rollup merge of #113153 - tshepang:patch-6, r=cuviper REVERT: c94a69f26a9 Rollup merge of #113072 - tshepang:patch-1, r=cuviper REVERT: 904734fbe00 Add support for allocators in `Rc` and `Arc` REVERT: 9a55bbbeed8 Add support for allocators in `Rc` and `Arc` REVERT: 952a07466f8 std docs: factorize literal in Barrier example REVERT: 367a7dc727a Mark wrapped intrinsics as inline(always) REVERT: 67062abcfa2 Rollup merge of #107624 - tgross35:const-cstr-methods, r=dtolnay REVERT: 693211ad701 Enable co-induction support for Safe Transmute REVERT: 7ebb6dfa2a2 make HashMap::or_insert_with example more simple REVERT: 6cb2299b9b0 Fix document examples of Vec::from_raw_parts and Vec::from_raw_parts_in REVERT: 2bfce11af2d Rollup merge of #113054 - Rageking8:make-`rustc_on_unimplemented`-std-agnostic, r=WaffleLapkin REVERT: a455c945b54 Rollup merge of #112670 - petrochenkov:typriv, r=eholk REVERT: eb7b0992f34 optimize Cstr/EscapeAscii display REVERT: 400f736e794 Rollup merge of #111571 - jhpratt:proc-macro-span, r=m-ou-se REVERT: 7ec1885fe37 std: remove an allocation in `Path::with_extension` REVERT: 6d51c2caaed std: edit [T]::swap docs REVERT: e04435634b3 Rollup merge of #112628 - gootorov:box_alloc_partialeq, r=joshtriplett REVERT: 922230d0ddc Change the wording in `std::fmt::Write::write_str` REVERT: 70c720234e1 Make `rustc_on_unimplemented` std-agnostic REVERT: 6419fe0b4d4 str docs: remove "Basic usage" text where not useful REVERT: 1c997f4622c Rollup merge of #112677 - the8472:remove-unusued-field, r=JohnTitor REVERT: 1b420846042 Auto merge of #113024 - Jerrody:master, r=thomcc REVERT: 836776173e5 Auto merge of #111850 - the8472:external-step-by, r=scottmcm REVERT: c053ee32152 Mark the StepBy specialization as unsafe REVERT: ee0d7ad1a31 StepBy> can be TrustedLen REVERT: 36278d1f84e doccomments for StepBy specializations REVERT: 4cc63f6b188 Stabilize chown functions (`unix_chown`) REVERT: c4c6e13e275 Auto merge of #113001 - ChrisDenton:win-arm32-shim, r=thomcc REVERT: 20ae416e488 Always inline primitive data types. REVERT: a976ed6db66 Rollup merge of #113009 - ChrisDenton:remove-path, r=workingjubilee REVERT: 656bdf82cd5 Rollup merge of #112956 - Amanieu:weak-intrinsics, r=Mark-Simulacrum REVERT: 9b3b9eeb83e Rollup merge of #112950 - tshepang:patch-4, r=Mark-Simulacrum REVERT: 624560d7c20 Remove unnecessary `path` attribute REVERT: 92c20977768 Move arm32 shim to c.rs REVERT: 8a825b6516b Rollup merge of #112763 - Patryk27:bump-compiler-builtins, r=Amanieu REVERT: 8526c210793 Rollup merge of #111087 - ibraheemdev:patch-15, r=dtolnay REVERT: 4ef4a6e8a07 Add `Read`, `Write` and `Seek` impls for `Arc` where appropriate REVERT: 4f168377938 Forward `io::{Read,Seek,Write}` impls of `File` to `&File` REVERT: cbdbd8dfcb2 Rollup merge of #112704 - RalfJung:dont-wrap-slices, r=ChrisDenton REVERT: 69970efef81 Expose `compiler-builtins-weak-intrinsics` feature for `-Zbuild-std` REVERT: 481300fb0ab DirEntry::file_name: improve explanation REVERT: 3ee1a28ce9c add inline annotation to concrete impls REVERT: 535e157a767 Specialize StepBy> REVERT: 2f15b3456ac Actually save all the files REVERT: 77d55024fbf Update tvOS support elsewhere in the stdlib REVERT: fdfaa943d47 Avoid fork/exec spawning on tvOS/watchOS, as those functions are marked as prohibited REVERT: cbe79a44e35 Finish up preliminary tvos support in libstd REVERT: 815e9b4648b wip: Support Apple tvOS in libstd REVERT: 8ccfe395126 Auto merge of #111684 - ChayimFriedman2:unused-offset-of, r=WaffleLapkin REVERT: cba8ea1008c Add known issue of let binding to format_args doc REVERT: 24a54baf717 Rollup merge of #112863 - clubby789:stderr-typo, r=albertlarsan68 REVERT: 6cde7dfe2ec Rollup merge of #99587 - ibraheemdev:park-orderings, r=m-ou-se REVERT: c916185b5d5 "Memory Orderings" -> "Memory Ordering" REVERT: 7258c898397 Warn on unused offset_of!() result REVERT: 1e50543cd93 Auto merge of #112877 - Nilstrieb:rollup-5g5hegl, r=Nilstrieb REVERT: dcef97c9659 Rollup merge of #112632 - gootorov:vec_alloc_partialeq, r=dtolnay REVERT: adfcb61c27a Auto merge of #106450 - albertlarsan68:fix-arc-ptr-eq, r=Amanieu REVERT: cee2ecaa29f Fix typo in `eprintln` docs REVERT: d5035524c06 relaxed orderings in `thread::park` example REVERT: eb498ef7a62 Merge proc_macro_span_shrink and proc_macro_span REVERT: 8b76a5b60cc Add `Span::{line, column}` REVERT: 42e1e7b81ea `Span::{before, after}` → `Span::{start, end}` REVERT: bae491b9625 Remove `LineColumn`, `Span::start`, `Span::end` REVERT: b167953cd14 Rollup merge of #112464 - eval-exec:exec/fix-connect_timeout-overflow, r=ChrisDenton REVERT: cec7f65ed16 Remove useless unit tests REVERT: 70016cb9143 Ignore `connect_timeout` unit test on SGX platform REVERT: 21e34dca8cd Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr REVERT: 47690286274 Merge attrs, better validation REVERT: feeca3589a0 Add rustc_do_not_implement_via_object REVERT: 8a78f583ee4 Auto merge of #112817 - compiler-errors:rollup-0eqomra, r=compiler-errors REVERT: 84a3a0faa1b Implement slice::split_once and slice::rsplit_once REVERT: 8ec2e41e456 Rollup merge of #112606 - clarfonthey:ip-display, r=thomcc REVERT: 2d73c4bbb83 Rollup merge of #112499 - tgross35:py-ruff-fixes, r=Mark-Simulacrum REVERT: a71bf4571a4 Auto merge of #111849 - eholk:uniquearc, r=Mark-Simulacrum REVERT: a6232565188 Introduce `alloc::::UniqueRc` REVERT: 297d0409dfc Rollup merge of #112757 - Danvil:patch-1, r=Mark-Simulacrum REVERT: 0bc2753ce7f Rollup merge of #109970 - danielhenrymantilla:add-poll-fn-pin-clarifications, r=thomcc REVERT: 4e3dc9098f8 Document thread names for SGX compilation target REVERT: c40d80fcfd4 Auto merge of #112724 - scottmcm:simpler-unchecked-shifts, r=Mark-Simulacrum REVERT: 61712f9c86f Bump compiler_builtins REVERT: e6ebddb1eb0 [doc] poll_fn: explain how to pin captured state safely REVERT: 16f0980d707 Same for BorrowRef REVERT: 38af2f529a6 Add unit test to connect to an unreachable address REVERT: ec467caa409 Use BorrowFlag instead of explicit isize REVERT: c4876150c61 Rollup merge of #112685 - cuviper:wasm-dlmalloc, r=Mark-Simulacrum REVERT: 46e290e17a4 Rollup merge of #107200 - mina86:c, r=Amanieu REVERT: 69bea2eb1d4 alloc: Allow comparing `Box`s over different allocators REVERT: f664f6c4b83 alloc: Implement PartialOrd for `Vec`s over different allocators REVERT: 6b89333d3bb Auto merge of #112599 - saethlin:cleaner-panics, r=thomcc REVERT: 3a7c906a820 Auto merge of #112595 - hargoniX:l4re_fix, r=Mark-Simulacrum REVERT: 9ab83b20f09 Auto merge of #112746 - matthiaskrgr:rollup-se59bfd, r=matthiaskrgr REVERT: dba10569795 Add unit test for `TcpStream::connect_timeout` REVERT: 5c87bf04b10 Fix windows `Socket::connect_timeout` overflow REVERT: c0cfa2809e1 Rollup merge of #112610 - scottmcm:update-stdarch, r=Amanieu REVERT: 128686291a4 Auto merge of #100036 - DrMeepster:box_free_free_box, r=oli-obk REVERT: 76d190829c4 Auto merge of #112739 - matthiaskrgr:rollup-8cfggml, r=matthiaskrgr REVERT: 972a8f5dd54 Rollup merge of #112644 - zica87:nonZeroTypes, r=Mark-Simulacrum REVERT: b1f6e39579a Rollup merge of #112352 - dankm:fbsd_doc_fix, r=thomcc REVERT: 369a002867d Extend io::copy buffer reuse to BufReader too REVERT: 1e20083e17b Apply changes to fix python linting errors REVERT: 5030f578360 [libs] Simplify `unchecked_{shl,shr}` REVERT: 26fd461d40a remove box_free and replace with drop impl REVERT: bc50a9bd4c2 Rollup merge of #112662 - Vanille-N:symbol_unique, r=RalfJung REVERT: a35b1909906 Rollup merge of #112226 - devnexen:netbsd_affinity, r=cuviper REVERT: c8d7adfea65 Rollup merge of #111074 - WaffleLapkin:🌟unsizes_your_buf_reader🌟, r=Amanieu REVERT: ce3edd7528c `#[lang_item]` for `core::ptr::Unique` REVERT: dc86e79ab71 Launch a non-unwinding panic for misaligned pointer deref REVERT: d08ab881863 slice::from_raw_parts: mention no-wrap-around condition REVERT: 0de09334a86 Remove `#[cfg(all())]` workarounds from `c_char` REVERT: c101b4d80ca Rollup merge of #112579 - MikaelUrankar:freebsd_docs, r=cuviper REVERT: f643c2d805e Rollup merge of #112535 - RalfJung:miri-test-libstd, r=cuviper REVERT: 2a8cf80f896 Add more comprehensive tests for is_sorted and friends REVERT: c43c3dda58e std: only depend on dlmalloc for wasm*-unknown REVERT: 98d72cfa646 Rollup merge of #112529 - jieyouxu:block-expr-unused-must-use, r=oli-obk REVERT: e3673d601a6 remove unused field REVERT: 3e5d3263cf8 privacy: Do not mark items reachable farther than their nominal visibility REVERT: f6accf8b16b Rollup merge of #112621 - GrigorenkoPV:env, r=jyn514 REVERT: 8ef507a139b Extend `unused_must_use` to cover block exprs REVERT: 150347d778d Auto merge of #106343 - the8472:slice-iter-fold, r=scottmcm REVERT: 9be217472e0 Correct types in method descriptions of `NonZero*` types REVERT: 83e727b5ef8 Auto merge of #104455 - the8472:dont-drain-on-drop, r=Amanieu REVERT: ebee2ffcd17 use indexed loop instead of ptr bumping REVERT: 599ca56e3ff Auto merge of #112625 - matthiaskrgr:rollup-jcobj3g, r=matthiaskrgr REVERT: 749900bf11c Fix `SocketAddrV6: Display` tests REVERT: 700c908a64e Fix `Ipv6Addr: Display` tests REVERT: 56d02aec818 Auto merge of #112624 - matthiaskrgr:rollup-db6ta1b, r=matthiaskrgr REVERT: e705af9843c Rollup merge of #111974 - Sp00ph:update_guarantees, r=Amanieu REVERT: 0221337a646 Rollup merge of #109814 - est31:stabilize_string_leak, r=Amanieu REVERT: 55deca8d12d Rollup merge of #107619 - stepancheg:hash-set-insert, r=Amanieu REVERT: 7b29910ce39 Rollup merge of #98202 - aticu:impl_tryfrom_osstr_for_str, r=Amanieu REVERT: 4cf3b36af1c Mention `env!` in `option_env!`'s docs REVERT: ddea1a6600a Fix typo REVERT: f21bc1e151c Auto merge of #112418 - ferrocene:pa-mir-opt-panic, r=ozkanonur,saethlin REVERT: 3db55edf0c3 Auto merge of #110662 - bryangarza:safe-transmute-reference-types, r=compiler-errors REVERT: 6acd7ee78dc update hashbrown and replace Hash{Set,Map}::DrainFilter with ExtractIf REVERT: 5a0e770f7c8 s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedList REVERT: af4efeb852e remove drain-on-drop behavior from linked_list::DrainFilter and add #[must_use] REVERT: 002ee8eccc1 remove drain-on-drop behavior from BTree{Set,Map}::DrainFilter and add #[must_use] REVERT: 566a10ca692 remove drain-on-drop behavior from vec::DrainFilter and add #[must_use] REVERT: b2883343899 Bump stdarch REVERT: f24820aa658 Alter `Display` for `Ipv6Addr` for IPv4-compatible addresses REVERT: 30aed8a5ee6 fix: get the l4re target working again REVERT: 74128bd06e4 Auto merge of #112314 - ferrocene:pa-core-alloc-abort, r=bjorn3 REVERT: 183e08afa96 ignore core, alloc and test tests that require unwinding on panic=abort REVERT: 65fefd887d1 Fix building the documentation on FreeBSD. REVERT: abd6bb5168f Auto merge of #112575 - matthiaskrgr:rollup-7a8d7tg, r=matthiaskrgr REVERT: 1dde18cd307 Rollup merge of #112558 - eltociear:patch-21, r=thomcc REVERT: 1047ece3155 Auto merge of #99339 - yanchith:binary-heap-ta, r=Amanieu REVERT: dbe2bc37f42 Fix typo in mod.rs REVERT: 4d7363d7514 Add comment for arm_shim in generate-windows-sys REVERT: 8967cb7306f Add windows_sys typedef for Win ARM32 REVERT: e7ec6673d80 optimize slice::Iter::fold REVERT: 9a9e598ae78 add benchmark REVERT: e029489caac Revert "Fix intra-doc links from pointer appearing in windows HANDLE type alias" REVERT: b1919dde466 Implement `TryFrom<&OsStr>` for `&str` REVERT: 07bb050711b make sure the standard library compiles properly with synthetic targets REVERT: f1a4535b30c Impl allocator function for iterators REVERT: be9a1d21349 Remove explicit lifetimes REVERT: baeec37d13d reorder attributes to make miri-test-libstd work again REVERT: 31e002f4666 Rollup merge of #112497 - icecream17:patch-1, r=Mark-Simulacrum REVERT: 7dca083f954 Rollup merge of #112484 - bdbai:fix/uwpntdll, r=ChrisDenton REVERT: a022a637d8e implement `Sync` for `mpsc::Sender` REVERT: 0d8be2e673e abs_sub: fix typo 0[-:][+.]0 REVERT: 1b1530d6e84 Auto merge of #111818 - Urgau:uplift_cmp_nan, r=cjgillot REVERT: c107466e964 Keep uwp specific code in sync with windows-sys REVERT: 3bbb09dfb86 Lazy load ntdll functions on UWP REVERT: 6c13e3b5434 Add diagnostic items for `f32::NAN` and `f64::NAN` REVERT: a7864913c5f Auto merge of #112465 - GuillaumeGomez:rollup-gyh5buc, r=GuillaumeGomez REVERT: 46e7e94a55d Auto merge of #111530 - Urgau:uplift_undropped_manually_drops, r=compiler-errors REVERT: e602feecef5 Don't explicitly name Global REVERT: f65658569f4 Pass tidy again REVERT: 7894f544940 Add allocator function REVERT: c94ce584794 Reallocatorize after merge REVERT: c363dfa9a2d Merge branch 'master' into binary-heap-ta REVERT: 578cfd995f4 Fix intra-doc links from pointer appearing in windows HANDLE type alias REVERT: d28d2b5dd22 Fix test REVERT: 5a64f2765b2 Rollup merge of #109953 - thomcc:thomcc/typeid128, r=WaffleLapkin REVERT: 28a73a66f7c Allow undropped_manually_drops for some tests REVERT: 2423e10ca0c Auto merge of #112292 - thomcc:tls-ohno, r=m-ou-se REVERT: 3099f898f58 Fix typo REVERT: 96c8c6903d2 Make Unix or Windows mandatory for the `switch-stdout.rs` test REVERT: 7bff8d5664e Move two tests from `tests/ui/std` to `library/std/tests` REVERT: e5a8352cf3f Safe Transmute: Disable coinduction support REVERT: 66a71a6c6ce Don't panic in ceil_char_boundary REVERT: da6ff891084 Auto merge of #96875 - SabrinaJewson:noop-waker, r=m-ou-se REVERT: 2ec23ee8d76 Auto merge of #111819 - nikarh:vita-improved, r=Amanieu REVERT: b8eaa203f2b Fix documentation build on FreeBSD REVERT: 58d8be67d8b Bumped libc version REVERT: 4b5664406ef std: available_parallelism using native netbsd api first before falling back to existing code paths like FreeBSD does. REVERT: ab08bf5628d Simplified bool to int conversion REVERT: c88e92d241e Std support improvement for ps vita target REVERT: 9d75c1b0d2e Rollup merge of #112263 - GrishaVar:remove-extend-element, r=scottmcm REVERT: 7d30c629006 Avoid unwind across `extern "C"` in `thread_local::fast_local.rs` REVERT: bcde06588d1 Remove redundant example of `BTreeSet::iter` REVERT: 62329cfae79 Use 128 bits for TypeId hash REVERT: ec43acc34c4 Remove ExtendWith and ExtendElement REVERT: dc4520077e7 Rollup merge of #112172 - tshepang:patch-1, r=Mark-Simulacrum REVERT: 03a5dbb4926 Rollup merge of #109093 - Dante-Broggi:patch-2, r=joshtriplett REVERT: 51f02cb6b59 Rollup merge of #111702 - cgwalters:option-map-or-else-with-result, r=Mark-Simulacrum REVERT: 5877b0353de Auto merge of #109432 - flba-eb:108594_forkspawn_exponential_backoff, r=workingjubilee REVERT: 98c267ea59f Rollup merge of #112206 - k0ur0x:typo, r=Nilstrieb REVERT: 193c6d0ea93 Rollup merge of #111647 - klensy:cstr, r=oli-obk REVERT: a97184c9d77 Only determine clock res once; give up before sleeping more than 1 second REVERT: 04efffd1028 Retry to fork/spawn with exponential backoff REVERT: 492faec29a1 Fix typo in `std::cell` module docs REVERT: cad170c2dfe fix ptr cast REVERT: d1949260e49 Rollup merge of #111670 - compiler-errors:const-param-ty, r=BoxyUwU REVERT: 9b3bf4187cf Stabilize 'const_cstr_methods' REVERT: e344e846356 Rollup merge of #112154 - ShaneEverittM:zero-len-utf16, r=thomcc REVERT: 047d3eddc96 Impl ConstParamTy for tuples, make PartialStructuralEq a supertrait too REVERT: de0d0cc39f0 Require that const param tys implement ConstParamTy REVERT: ac00fcc07fd doc: improve explanation REVERT: 6ed711787e4 Rollup merge of #112141 - anna-singleton:issue-111655-fix, r=thomcc REVERT: 31278ff5c78 Auto merge of #111567 - Urgau:uplift_cast_ref_to_mut, r=b-naber REVERT: e101f9ec335 Fix bug in utf16_to_utf8 for zero length strings REVERT: 4b25e033c34 Clarify behavior of inclusive bounds in BTreeMap::{lower,upper}_bound REVERT: 0fcf54630b1 use c literals in library REVERT: 39aa19ef3e5 remove reference to Into in ? operator core/std docs, fix 111655 REVERT: 405badcd738 Auto merge of #111076 - notriddle:notriddle/silence-private-dep-trait-impl-suggestions, r=cjgillot REVERT: 601399c7f67 Add diagnostic items for `ptr::cast_mut` and `ptr::from_ref` REVERT: 165d750e98f Rollup merge of #112103 - Mark-Simulacrum:bootstrap-update, r=clubby789 REVERT: 0fad623ca4d Auto merge of #112127 - matthiaskrgr:rollup-77pt893, r=matthiaskrgr REVERT: a9e5f5c37f4 Rollup merge of #112096 - workingjubilee:array-unzip, r=scottmcm REVERT: ae17488a634 Auto merge of #112120 - weihanglo:update-cargo, r=ehuss REVERT: 6f8cb2e43b8 Explicit set `workspace.resolver = "1"` REVERT: beac94e1ac1 Auto merge of #109698 - epage:wtf, r=Amanieu REVERT: 1f9363a9106 add doc on From impl for ChildStd* REVERT: 2cf784ee63f add FromOwnedFd/FromOwnedHandle for ChildStdin/out/err REVERT: 91157c56cb5 Bump to latest beta compiler REVERT: 725eb665033 Swap out CURRENT_RUSTC_VERSION to 1.71.0 REVERT: 0b2cfa50d55 Rollup merge of #111543 - Urgau:uplift_invalid_utf8_in_unchecked, r=WaffleLapkin REVERT: 0f4296a3018 Rollup merge of #107916 - reez12g:issue-107040, r=Amanieu REVERT: ffe677ffe11 Remove array_zip REVERT: 7cee3098351 fix comment on Allocator trait REVERT: 7f2aeea7027 Make `TrustedStep` require `Copy` REVERT: dbbf172f91d Rollup merge of #112045 - Sp00ph:update_current_impl, r=Amanieu REVERT: 7cd2f42637d Update current impl comment for `select_nth_unstable_by_key` REVERT: aff348a22f7 Update runtime guarantee for `select_nth_unstable` REVERT: e33dacb0e82 Stabilize String::leak REVERT: eb7c1b53360 Rollup merge of #111656 - finnbear:string_leak_unbounded_lifetime, r=Amanieu REVERT: e4d3d1dd577 Rollup merge of #108630 - overlookmotel:realloc-docs-fix, r=Amanieu REVERT: c55ccc46143 Auto merge of #110975 - Amanieu:panic_count, r=joshtriplett REVERT: 8f370bd4ee8 Rework handling of recursive panics REVERT: 7255a90fd79 Auto merge of #112016 - GuillaumeGomez:rollup-fhqn4i6, r=GuillaumeGomez REVERT: 3c2439c51a6 Rollup merge of #111966 - saethlin:inline-slice-tryfrom, r=thomcc REVERT: 22ca1f9aca8 Auto merge of #111934 - scottmcm:stabilize-hash-one, r=Amanieu REVERT: 007eb57354b Auto merge of #111928 - c410-f3r:dqewdas, r=eholk REVERT: b8d5a3aabc4 Auto merge of #111348 - ozkanonur:remove-hardcoded-rustdoc-flags, r=albertlarsan68,oli-obk REVERT: 07397b3b440 Rollup merge of #111973 - Sp00ph:update_current_impl, r=Amanieu REVERT: d38bebbb09b Allow newly uplifted invalid_from_utf8 lint REVERT: 27cfafef385 Add invalid_from_utf8 analogous to invalid_from_utf8_unchecked REVERT: b5b6607a25d Uplift clippy::invalid_utf8_in_unchecked as invalid_from_utf8_unchecked REVERT: 8b39f6d4c74 Fix incorrect documented default bufsize in bufreader/writer REVERT: 00c8dc4e9d2 Auto merge of #103291 - ink-feather-org:typeid_no_struct_match, r=dtolnay REVERT: 88db75429e5 convert benches to tests in subprocess if we're not benchmarking REVERT: 231ce1365bf add StaticBenchAsTestFn and DynBenchAsTestFn to convert benches to tests REVERT: 03a11644e01 remove nested function from run_test REVERT: a47eabe454b refactor executing tests to centralize actually invoking tests REVERT: 133f107b207 Rollup merge of #111940 - zirconium-n:io-read-doc-change, r=thomcc REVERT: 72d2ab3f81a Update current implementation comments for `select_nth_unstable` REVERT: e661ecb51df Add #[inline] to array TryFrom impls REVERT: cacb5601d1b Rollup merge of #107522 - Sp00ph:introselect, r=Amanieu REVERT: e762b25f39a Remove structural match from `TypeId`. REVERT: 1b269b336b6 Auto merge of #86844 - bjorn3:global_alloc_improvements, r=pnkfelix REVERT: ff38db02bad std: make `fortanix-sgx-abi` a public depedenceny REVERT: 5f95694dd44 std: make internal-only items `pub(crate)` REVERT: 94313d26b46 std: mark common functions in test crate `pub(crate)` REVERT: 4e1f97036df bootstrap: enable Cargo `public-dependency` feature for `libstd` REVERT: cccdc136bfd Clarify safety concern of `io::Read::read` is only relevant in unsafe code REVERT: 0a8dfd33f49 Stabilize `BuildHasher::hash_one` REVERT: 683e52b2a64 Rollup merge of #95198 - clarfonthey:get_chunk, r=scottmcm REVERT: 6a4da977e2b [RFC-2011] Expand more expressions REVERT: 1529682d340 Rollup merge of #111915 - jyn514:libtest-errors, r=thomcc REVERT: c83487da610 Safe Transmute: Enable handling references, including recursive types REVERT: 7f2a4844756 feat: implement `DoubleEndedSearcher` for `CharArray[Ref]Searcher` REVERT: c464d86a7e4 Use helper functions for min/max_idx REVERT: e1a2ab5b179 libtest: Improve error when missing `-Zunstable-options` REVERT: 3cbdfd091d0 Add Median of Medians fallback to introselect REVERT: d8b387d93c7 Roll compiler_builtins to 0.1.92 REVERT: 48d03640956 const stabilize `NonNull::as_ref` REVERT: 9a2c316a385 Auto merge of #111807 - erikdesjardins:noalias, r=oli-obk REVERT: b62bca2167b Rollup merge of #111756 - Urgau:rename_drop_forget_copy_ref_lints, r=fee1-dead REVERT: e061ae9fc7e Rollup merge of #111612 - ChayimFriedman2:collect-into-slice-ref, r=petrochenkov REVERT: 248666b03dc Rollup merge of #111609 - LegionMammal978:internal-unsafe, r=thomcc REVERT: 34754a65c9b Auto merge of #111634 - marc0246:arc-new-uninit-bloat, r=thomcc REVERT: c7f93427154 Auto merge of #111711 - Jules-Bertholet:document-pin-layout, r=thomcc REVERT: d13baed799d Auto merge of #111835 - matthiaskrgr:rollup-qd4b2vu, r=matthiaskrgr REVERT: bb49d8f3a7d Rollup merge of #111810 - compiler-errors:less-macro, r=thomcc REVERT: e2d678842d7 Auto merge of #111781 - the8472:filter-map-chunk, r=thomcc REVERT: dc31893c7e5 drop_in_place docs: remove pseudocode-ish implementation details REVERT: 4bdb916b2ee Rename `drop_copy` lint to `dropping_copy_types` REVERT: da899140df1 Don't use inner macro in marker_impls REVERT: 371b88aff67 Auto merge of #111696 - lukas-code:offset-of-erase-regions-harder, r=compiler-errors REVERT: 27d893b66c1 improve drop_in_place docs REVERT: d706e42bb28 Add missing "unsafe" to fix doctest REVERT: 3afffd8ae97 Update documentation for `drop_in_place()` REVERT: 5d1d2b64cac Auto merge of #111646 - Voultapher:restore-branchless-code-gen-for-merge, r=cuviper REVERT: 4546c8c3200 don't skip inference for type in `offset_of!` REVERT: bed46686afe derive `Default` trait for `compiletest::common::Config` REVERT: 3a3fbaecaed Auto merge of #111778 - Dylan-DPC:rollup-107ig9h, r=Dylan-DPC REVERT: b9f0289c37d optimize next_chunk impls for Filter and FilterMap REVERT: 82a452b7c8e Rollup merge of #111715 - juntyr:const-param-ty-derive-fix, r=Nilstrieb REVERT: 8f24543d21b Rollup merge of #111665 - est31:offset_of_tests, r=WaffleLapkin REVERT: f94cec7e497 Auto merge of #111524 - scottmcm:escape-using-ascii, r=cuviper REVERT: adfcaf812a5 docs: Add missing period REVERT: 06cbe6b4a09 Auto merge of #111453 - scottmcm:constify-as-slice, r=Mark-Simulacrum REVERT: 20a9af3cb82 Add slice::{split_,}{first,last}_chunk{,_mut} REVERT: e6196f92949 Auto merge of #109773 - beetrees:set-file-time-improvements, r=Amanieu REVERT: c4e2c0490d9 tidy REVERT: 821282a3851 remove unstable `Poll::ready` REVERT: eca6f46e1bf constify `slice_as_chunks` (unstable) REVERT: a4b599606b1 Auto merge of #111590 - dtolnay:panictemporaries, r=bjorn3 REVERT: ef9c69418da Add tracking issue ID for `bufread_skip_until` feature gate REVERT: 2a2f4aade96 Move `BufRead::skip_until` test to a more appropriate location REVERT: de046da4bf3 Add `BufRead::skip_until` test REVERT: 3717cf67dd7 Option::map_or_else: Show an example of integrating with Result REVERT: 9f614c1e2bd Add more tests for the offset_of!() macro REVERT: a6774eefb9e Fix doc comment for `ConstParamTy` derive REVERT: 81ec11fe706 Auto merge of #111710 - Dylan-DPC:rollup-eutrx54, r=Dylan-DPC REVERT: 26d82e0dbe1 Document `Pin` memory layout REVERT: 64d420af11e Rollup merge of #111527 - knickish:bind_port_0_documentation, r=Mark-Simulacrum REVERT: 8d90fb0918b Rollup merge of #111168 - DaniPopes:arguments-to-string, r=Mark-Simulacrum REVERT: 99f72621faa docs: Clarify OsStr is self-synchronizing REVERT: 7d8b77f1d8f Fix #107910, Shorten backtraces in ICEs REVERT: 86971cefeca Rollup merge of #111654 - JoJoJet:unsafe-cell-from-mut-lib, r=joshtriplett REVERT: 48bd87a1970 Rollup merge of #111649 - Nilstrieb:derive-const-param-ty, r=BoxyUwU REVERT: 5f293307373 Rollup merge of #111043 - jmillikin:cstr-is-empty, r=dtolnay REVERT: 8fb25812d3b docs: Add examples of OsStr safety violation REVERT: a5a2eba86bb Use an unbounded lifetime in String::leak. REVERT: 0332d7bd708 add `UnsafeCell::from_mut` REVERT: c08864e4416 Rollup merge of #111592 - Nemo157:fix-vec-capacity-examples, r=joshtriplett REVERT: fce7292ca89 Add derive for `core::marker::ConstParamTy` REVERT: 8d3f57e5b21 Hide repr attribute from doc of types without guaranteed repr REVERT: f372b03ca68 Use code with reliable branchless code-gen for slice::sort merge REVERT: efa35883b1e Rollup merge of #111617 - kesleta:master, r=Dylan-DPC REVERT: 3384ab25556 Fix duplicate `arcinner_layout_for_value_layout` calls REVERT: 3142e41bde8 Auto merge of #111134 - GilShoshan94:remove-send-bound-on-error, r=dtolnay REVERT: 24a877077cb Auto merge of #111044 - jmillikin:nonzero-negation, r=dtolnay REVERT: b80fc0eb220 Fixed typo REVERT: 022add67071 Mark internal functions and traits unsafe REVERT: d1c226e6cf6 Give better error when collecting into `&[T]` REVERT: 782d00b817a Rollup merge of #111587 - cbeuw:copy-for-deref, r=oli-obk REVERT: 881fb7726cb Rollup merge of #110049 - SkiFire13:localkey-with-docs-fix, r=workingjubilee REVERT: 88edddab27d Rollup merge of #108356 - gftea:master, r=workingjubilee REVERT: 67c427fea9f Rollup merge of #108291 - chenyukang:yukang/fix-benchmarks, r=workingjubilee REVERT: fce788f319c Add test for `FileTimes` REVERT: 82a1cb6e617 Add creation time support to `FileTimes` on apple and windows REVERT: 11336537f33 Change Vec examples to not assert exact capacity except where it is guaranteed REVERT: 1eb2b1979cf Shorten lifetime of even more panic temporaries REVERT: d1e6d13d29a Documentation REVERT: 08020e09e22 Add CopyForDeref to custom MIR REVERT: 80879c8db0f Rollup merge of #111582 - Vagelis-Prokopiou:fix/wanting, r=workingjubilee REVERT: 9679d50b418 Rollup merge of #111581 - scottmcm:fix-pattern-comment, r=workingjubilee REVERT: 26e27baf7ab Rollup merge of #102673 - lukas-code:infered-lifetimes, r=ehuss REVERT: fe37ba27760 wanting => want REVERT: 83eaac359d5 Fix some misleading and copy-pasted `Pattern` examples REVERT: bab811fb609 Auto merge of #108273 - tspiteri:const_slice_split_at_not_mut, r=dtolnay REVERT: f5e6c6795f0 Auto merge of #108196 - sunfishcode:sunfishcode/windows-as-socket-impls, r=dtolnay REVERT: bdb156fb655 Auto merge of #92048 - Urgau:num-midpoint, r=scottmcm REVERT: 53947ad9063 explain that `PhantomData<&'a T>` infers `T: 'a` REVERT: 47457536741 Shorten lifetime of panic temporaries in panic_fmt case REVERT: d04423479ae Auto merge of #111425 - Bryanskiy:privacy_ef, r=petrochenkov REVERT: e3999897efb refactor: Remove bespoke from_os_str_bytes_unchecked REVERT: 0c3c7527652 refactor: Remove redundant, private OsStr::bytes REVERT: 71954d1cf86 add examples of port 0 binding behavior REVERT: f86db5e30ab Auto merge of #111447 - scottmcm:remove-more-assumes, r=thomcc REVERT: eead372fcca `ascii::Char`-ify the escaping code REVERT: f032a84f45d Remove useless `assume`s from `slice::iter(_mut)` REVERT: 971ef73b4a3 Auto merge of #103413 - RalfJung:phantom-dropck, r=lcnr REVERT: 248c6c43649 hedge for future changes REVERT: 83b7d711785 Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwco REVERT: 54a0e1877de Auto merge of #111475 - workingjubilee:sync-simd-2023-may-10, r=workingjubilee REVERT: 6db7a246c3c Correct swizzle_dyn cfg for armv7 neon REVERT: 2d4451fcbb5 Auto merge of #111395 - scottmcm:slice-iter-zst-experiment, r=the8472 REVERT: bba130efc28 Sync portable-simd to 2023 May 10 REVERT: 1cec942348b Prevent insta-stable no alloc shim support REVERT: 0c862691105 Auto merge of #111454 - RalfJung:miri, r=RalfJung REVERT: a7e1e5d0920 Populate effective visibilities in rustc_privacy REVERT: a15064d243b Improve code around SGX waitqueue REVERT: f479a513e5c Simplify the implementation of iterators over slices of ZSTs REVERT: c296c9ce177 Allow the drop_copy lint in some library examples REVERT: 72cc56d1945 Remove useless drop of copy type REVERT: c708c64fb42 Remove and fix useless drop of reference REVERT: a8b5039ab2a Auto merge of #111401 - ChrisDenton:no-windows-allowed, r=workingjubilee REVERT: dc510b73eb7 Merge from rustc REVERT: 2ed6c80ca83 Rollup merge of #111408 - TomMD:patch-1, r=workingjubilee REVERT: b0c4cfa6f43 Fix incorrect implication of transmuting slices REVERT: 70cef769c22 Rollup merge of #111282 - scottmcm:remove-unneeded-assumes, r=workingjubilee REVERT: d606f18f340 Rollup merge of #110770 - m-ou-se:fmt-temp-lifetime, r=oli-obk REVERT: f88ab29167e Rollup merge of #97320 - usbalbin:stabilize_const_ptr_read, r=m-ou-se REVERT: 1f1199a02c6 Don't force include Windows goop when documenting REVERT: 17b6e73c245 Auto merge of #111371 - compiler-errors:revert-110907, r=petrochenkov REVERT: c8963212ff8 Limit lifetime of format_args!() with inlined args. REVERT: 4a56973fe78 Auto merge of #110285 - KisaragiEffective:sync-stdarch, r=Amanieu REVERT: cc0b02dfeee Auto merge of #111380 - Dylan-DPC:rollup-xiptbhn, r=Dylan-DPC REVERT: 00d1c869d06 Rollup merge of #110694 - est31:builtin, r=petrochenkov REVERT: afa2e61b8d5 Auto merge of #110152 - ChrisDenton:windows-sys, r=thomcc REVERT: 7e7d953ec2d Auto merge of #110027 - nbdd0121:dieting, r=m-ou-se REVERT: 85dc6d27639 Auto merge of #111296 - Sp00ph:const_gcd, r=nagisa,Mark-Simulacrum REVERT: d4725ccf297 Revert "Populate effective visibilities in `rustc_privacy`" REVERT: 780d3780189 Rollup merge of #104070 - nbdd0121:unwind, r=Amanieu REVERT: 7ea39326253 Rollup merge of #111315 - Swatinem:rm-identitiy-future, r=Mark-Simulacrum REVERT: 711b0e38ce3 Rollup merge of #110638 - nikarh:vita, r=Mark-Simulacrum REVERT: f9173335e6c std: remove test for arm's crypto feature please see https://github.com/rust-lang/rust/pull/110285#issuecomment-1521201953 for more details REVERT: 3f10ee6fb89 stdarch: update submodule, take 5 REVERT: 3c0c054d0fe Auto merge of #106621 - ozkanonur:enable-elided-lifetimes-for-doctests, r=Mark-Simulacrum REVERT: b9217cae64d Auto merge of #111306 - Urgau:hashbrown-std-0.13, r=Amanieu REVERT: 1155f18dbc5 Merge from rustc REVERT: fbfe4cc7e1b PS Vita std support REVERT: 2ad76d7f72d Auto merge of #111222 - scottmcm:constify-is_ascii, r=thomcc REVERT: 6bd0c531826 Add `#[inline]` to functions that are never called REVERT: a0c8148156d Prevent aborting guard from aborting the process in a forced unwind REVERT: ad0a987e5a7 Parse catch filter in personality function REVERT: 71480f65b99 Remove `identity_future` from stdlib REVERT: 43082bf8862 Auto merge of #111125 - xfix:inline-socketaddr-methods, r=Mark-Simulacrum REVERT: 97bc0298f56 Tune the `is_ascii` implementation used for short slices REVERT: 426d62a8558 Rollup merge of #111301 - JohnBobbo96:cleanup_option_insert_methods, r=scottmcm REVERT: 3a9b4625d72 Rollup merge of #110094 - lukas-code:less-transmute, r=thomcc REVERT: c28694c0d2f Update hashbrown from 0.12.3 to 0.13.1 for std REVERT: cf4e9f7e8a8 Remove unneeded calls to `mem::forget` and `mem::replace` in `Option::get_or_insert_with`. REVERT: b19704afb9b enable `rust_2018_idioms` for doctests REVERT: 32c954c6411 Auto merge of #110907 - Bryanskiy:privacy_ef, r=petrochenkov REVERT: 9611bf65c2e Always const-eval the gcd in `slice::align_to_offsets` REVERT: 50555bf912e clean up transmutes in core REVERT: 4cdaf511851 Remove some `assume`s from slice iterators that don't do anything REVERT: bc9a09c7896 Rollup merge of #111139 - fortanix:raoul/fix_mxcsr_configuration_dependent_timing, r=thomcc REVERT: 6ae41457c66 Rollup merge of #110830 - Freaky:freebsd-cpuset, r=thomcc REVERT: c7e6ea0e15a Sort windows_sys.lst alphabetically REVERT: d1643ea297d Use new bindings REVERT: ef1190aa028 Generate windows-sys bindings REVERT: 06e247df28b Migrate offset_of from a macro to builtin # syntax REVERT: 7839e7bd797 Stabilize const_ptr_read REVERT: d51b860d8ff Auto merge of #111248 - Dylan-DPC:rollup-lbp0ui3, r=Dylan-DPC REVERT: e5cb7ad90eb Populate effective visibilities in `rustc_privacy` REVERT: 409375105b5 feat: merge functionality of `io::Sink` into `io::Empty` REVERT: 920b125cbc4 Rollup merge of #111238 - workingjubilee:fix-btree-cursormut-peek-prev, r=Amanieu REVERT: 689c6edeba8 Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors REVERT: 4a0cefa6970 Rollup merge of #103056 - beetrees:timespec-bug-fix, r=thomcc REVERT: c029b14e1c4 Auto merge of #111113 - scottmcm:assume-align-offset, r=thomcc REVERT: ad1645f30ca `assume` the runtime range of `align_offset` REVERT: ba92f662a7b btree_map: `Cursor{,Mut}::peek_prev` must agree REVERT: 664d5b0e079 Rollup merge of #111213 - WaffleLapkin:fixup_dates, r=scottmcm REVERT: ebc40ce85a7 Rollup merge of #110946 - RalfJung:tls-realstd, r=m-ou-se REVERT: cf43b3e9106 Stabilize feature `nonzero_negation_ops` REVERT: 5d467011c54 Add an example that depends on `is_ascii` in a `const` REVERT: 43c1a708c04 Constify `[u8]::is_ascii` (unstably) REVERT: 70ca92c3942 Fixup "since" dates for `array_tuple_conv` feature REVERT: 116fc34972d Rollup merge of #111186 - jmillikin:nonzero-is-positive, r=dtolnay REVERT: 99d2b7869e0 Rollup merge of #111009 - scottmcm:ascii-char, r=BurntSushi REVERT: 3abe347660b Rollup merge of #110651 - durin42:xunit-stdout, r=cuviper REVERT: 353599ac7c7 Rollup merge of #108865 - Zoxc:library-dummy-crate, r=jyn514 REVERT: ba149465cc7 Optimize `Iterator` implementation for `&mut impl Iterator + Sized` REVERT: a1fbb498289 Add `is_positive` method for signed non-zero integers. REVERT: ec21b38d6e5 Add the basic `ascii::Char` type REVERT: 8caf78953f6 stdarch: update submodule, take 4 REVERT: 91dfba31149 Rollup merge of #111127 - xfix:const-slice-flatten, r=scottmcm REVERT: 9c502dac116 Rollup merge of #105695 - joboet:remove_generic_parker, r=m-ou-se REVERT: d78075d2547 Rollup merge of #105452 - rcvalle:rust-cfi-3, r=bjorn3 REVERT: ba75201f289 Rollup merge of #97594 - WaffleLapkin:array_tuple_conv, r=ChrisDenton REVERT: e370e6abc86 Specialize ToString implementation for fmt::Arguments REVERT: d8667514228 Add cross-language LLVM CFI support to the Rust compiler REVERT: 4f4ef3ab3d2 Mention array<->tuple convs in docs REVERT: ddfb7ea8590 Fix MXCSR configuration dependent timing REVERT: dec31605fe0 Remove unnecessary Send bound REVERT: 62e0c721000 Constify slice flatten method REVERT: aaa568d8c17 Use `from_wide_to_user_path` in `read_link` REVERT: 8b5499de8f1 Inline SocketAddr methods REVERT: 84d2adeff9d Correctly convert an NT path to a Win32 path REVERT: 25c9282d499 Auto merge of #109729 - fortanix:raoul/bugfix_libtest_json_synchronization, r=pietroalbini REVERT: e1171b2affb Remove `[]` <-> `()` `From` convertions REVERT: c048420b32d Use metavar `${count(x)}` instead of reimplementing it REVERT: 3dc90f94c2a implement tuple<->array convertions via `From` REVERT: 4582b0f5aa9 rm diag item, use lang item REVERT: ab8185477d2 fix TODO comments REVERT: c59d45b2ac5 initial step towards implementing C string literals REVERT: c18ac5c4def Rollup merge of #110955 - fee1-dead-contrib:sus-operation, r=compiler-errors REVERT: f61db841792 Rollup merge of #110895 - Ayush1325:thread-local-fix, r=thomcc REVERT: a60f96819af Rollup merge of #108161 - WaffleLapkin:const_param_ty, r=BoxyUwU REVERT: 8a9c66c8021 Rollup merge of #105076 - mina86:a, r=scottmcm REVERT: 2be1f66f985 Auto merge of #106075 - nbdd0121:ffi-unwind, r=joshtriplett REVERT: f0c9fbc0f51 Relax implicit `W: Sized` bound on `LineWriter` REVERT: afa75997ae0 Relax implicit `W: Sized` bound on `BufWriter` REVERT: 1368974bd5b Relax implicit `R: Sized` bound on `BufReader` REVERT: 2ed134140df Auto merge of #111066 - matthiaskrgr:rollup-4k6rj23, r=matthiaskrgr REVERT: 274a3cc3daf Rollup merge of #111065 - est31:send_mut_ref, r=m-ou-se REVERT: 151a83e07a6 Rollup merge of #111057 - xfix:tcpstream-as-raw-fd-inline, r=m-ou-se REVERT: e76b8777a75 Rollup merge of #110987 - infdahai:wasi_clock_time, r=m-ou-se REVERT: 209fe14cbc6 Rollup merge of #110093 - beetrees:set-times-32-bit, r=joshtriplett REVERT: 4af993bbd57 Rollup merge of #109540 - marcospb19:edit-Path-with_file_name-example, r=m-ou-se REVERT: 08a44739249 Explicitly document how Send and Sync relate to references REVERT: 50436553bef Auto merge of #111010 - scottmcm:mem-replace-simpler, r=WaffleLapkin REVERT: a7358cf5c70 Fix `StructuralEq` impls for `&T`, `[T]` and `[T; N]` REVERT: af21cb6f87f Inline AsRawFd implementations REVERT: f9677615f72 Inline socket function implementations REVERT: 06c3f2ce994 Inline AsInner implementations REVERT: 5c7cfd12f9b Auto merge of #111036 - RalfJung:miri, r=RalfJung REVERT: 7ae33035d23 Ensure test library issues json string line-by-line REVERT: 1351af14837 Codegen fewer instructions in `mem::replace` REVERT: dc954e2505a Stabilize feature `cstr_is_empty` REVERT: 8904f145648 Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naber REVERT: c566e7cc3af Merge from rustc REVERT: 7c0fc6e3836 Auto merge of #111017 - matthiaskrgr:rollup-yy9updi, r=matthiaskrgr REVERT: 31d365bd15f Rollup merge of #111000 - JohnBobbo96:core_option_unneeded_function, r=jyn514 REVERT: af5596f86c9 Auto merge of #103406 - Jules-Bertholet:from_clone_slice_to_box, r=dtolnay REVERT: cae5ad79209 a bit more usize::from REVERT: f16187783fc Auto merge of #110935 - scottmcm:always-ord, r=Mark-Simulacrum REVERT: 974de20d5ee review REVERT: 6138035a8d4 Rollup merge of #110997 - scottmcm:slice-iter-comments, r=the8472 REVERT: a621b37c03b Remove unneeded function call in `core::option`. REVERT: 4d6b7f6c7ae `cfg`-gate `BoxFromSlice` trait REVERT: 11e0d3d294c Improve internal field comments on `slice::Iter(Mut)` REVERT: c977020568d Partial stabilisation of `c_unwind` REVERT: f835314e8f9 update wasi_clock_time_api ref. REVERT: 8f039245ee4 fix rustdoc and core test REVERT: 12db0ee3b0d Rollup merge of #110958 - compiler-errors:stdlib-refinement, r=cuviper REVERT: c752a9f1f63 junit: fix typo in comment and don't include output for passes when not requested REVERT: 163ee4c5f78 Make sure that signatures aren't accidental refinements REVERT: 690347ffe29 handle cfg(bootstrap) REVERT: 72463934e85 replace version placeholders REVERT: 9244ab055ed avoid duplicating TLS state between test std and realstd REVERT: aac8a6a1493 Merge from rustc REVERT: 4242324eaea Auto merge of #110837 - scottmcm:offset-for-add, r=compiler-errors REVERT: e6c1c7e6bcd `inline(always)` for `lt`/`le`/`ge`/`gt` on integers and floats REVERT: dd6da6b83e5 Auto merge of #110924 - matthiaskrgr:rollup-jvznpq2, r=matthiaskrgr REVERT: 89d0dc89957 Also use `mir::Offset` for pointer `add` REVERT: 4ac5cc58a24 Rollup merge of #110918 - ChrisDenton:on-error-resume-next, r=cuviper REVERT: 747504357a2 Rollup merge of #110766 - m-ou-se:fmt-rt, r=jyn514 REVERT: 37a8fb497f6 Rollup merge of #110898 - m-ou-se:remove-unused-thread-local-key, r=cuviper REVERT: a86535dbfd8 Rollup merge of #110620 - Nilstrieb:document-the-undocumented, r=thomcc REVERT: e0a186bfec1 remove_dir_all: delete directory with fewer perms REVERT: f53b99ecc54 Rollup merge of #106599 - MikailBag:patch-1, r=jyn514 REVERT: ce9de0ede49 Rollup merge of #106456 - kadiwa4:std-prelude-comment, r=jyn514 REVERT: d7684bf459a Rollup merge of #105745 - philpax:patch-1, r=jyn514 REVERT: d4372c3841b Document `const {}` syntax for `std::thread_local`. REVERT: 897ec9c018d Don't call await a method REVERT: 53572585c1b Fix some marker impls REVERT: 5947019dc3d Add FIXMEs REVERT: ad596def2ad Impl `StructuralEq` & `ConstParamTy` for `str`, `&T`, `[T; N]` and `[T]` REVERT: 8bb3496f88d Add a macro to conveniently implement marker traits REVERT: c0744256b14 Remove `feature(const_param_ty_trait)`, use `adt_const_params` instead REVERT: 7eb98313543 Add a `ConstParamTy` trait REVERT: d9c838d8d50 pub -> pub(super). REVERT: efdfbd57bb1 Implement `StructuralEq` for integers, `bool` and `char` REVERT: 3e1da1ae768 correct `std::prelude` comment REVERT: 124f3f48271 Update test. REVERT: 8724271bd83 Remove unused std::sys_common::thread_local_key::Key. REVERT: a7f646b513b Rollup merge of #110804 - cuishuang:master, r=jyn514 REVERT: 47044ddf1d1 Remove all in target_thread_local cfg REVERT: 8706ba093de std: use `LazyLock` to lazily resolve backtraces REVERT: 64a3955634d Loosen `From<&[T]> for Box<[T]>` bound to T: Clone REVERT: f219b26248e Auto merge of #110562 - ComputerDruid:riscv, r=tmandry REVERT: 16067687e42 docs(std): clarify `remove_dir_all` errors REVERT: 637f8ea5431 Auto merge of #110861 - m-ou-se:thread-local-restructure, r=workingjubilee REVERT: b7e50cacd81 Restructure and rename thread local things in std. REVERT: f0ecf61e37c Rollup merge of #110819 - tamird:flattencompat-trustedlen, r=the8472 REVERT: 9debcf5ffb7 Rollup merge of #110419 - jsoref:spelling-library, r=jyn514 REVERT: 2dea1d374c1 Remove repeated definite articles REVERT: a00a89f7472 Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadata REVERT: 163133224ff Implement midpoint for all unsigned NonZeroU{8,16,32,64,128,size} REVERT: f2baf7ccbd8 Implement midpoint for all floating point f32 and f64 REVERT: 2b28f0ef45a Implement midpoint for all signed and unsigned integers REVERT: a9f1ead9d3a Merge from rustc REVERT: 22d18800464 Rollup merge of #110587 - tomaka:fix-109727, r=jyn514 REVERT: c08e05dbd9f Rollup merge of #110266 - tgross35:try-exists-wording, r=jyn514 REVERT: 5f4894b5d4a Rollup merge of #108416 - pat-nel87:Issue-107957-black_box_docs, r=jyn514 REVERT: 6b5907f2e0b rewrite: line_long_tail_not_flushed description REVERT: 81e925cf714 rewrite: long_line_flushed description REVERT: d4cde073321 Spelling library/ REVERT: 4cefbbeef44 Add definitions for riscv64gc-unknown-fuchsia REVERT: 4f766bb3199 Add FreeBSD cpuset support to std::thread::available_concurrency REVERT: ea2c36a7226 Rollup merge of #110796 - madsravn:wake-example, r=Mark-Simulacrum REVERT: 5a85eb0f88f Rollup merge of #110649 - arlosi:fix_no_global_oom_handling, r=Mark-Simulacrum REVERT: e3e0f38a39b simplify TrustedLen impls REVERT: 2fe8fa720c4 Updating Wake example to use new 'pin!' macro REVERT: 4075e17589e Add a `sysroot` crate to represent the standard library crates REVERT: d8cec564435 Auto merge of #103093 - rytheo:linked-list-alloc-api, r=Mark-Simulacrum REVERT: 7598a9709a3 Auto merge of #110389 - mazong1123:add-shortcut-for-grisu3, r=Mark-Simulacrum REVERT: 4cd12115a45 Rollup merge of #110782 - matthiaskrgr:revert_panic_oom, r=Amanieu REVERT: 98b9168d0cc Add shortcut for Grisu3 algorithm. REVERT: f404ef4bd70 Add support for allocators in LinkedList REVERT: 65545bb59b4 Auto merge of #106152 - SUPERCILEX:lazycell, r=Amanieu REVERT: d326fd93f0b Revert "Report allocation errors as panics" REVERT: e6fe2bf1248 Revert "Remove #[alloc_error_handler] from the compiler and library" REVERT: 0afd6ec4e08 Revert "Rename -Zoom=panic to -Zoom=unwind" REVERT: 1fa15036b15 stdarch: update submodule, take 3 REVERT: d212c58fb68 Restructure std::fmt::rt a bit. REVERT: 2939a8116b0 Remove "V1" from ArgumentsV1 and FlagsV1. REVERT: f451af89fdf Implement FusedIterator for DecodeUtf16 when the inner iterator does REVERT: 632eb7f38db Merge from rustc REVERT: 93256238468 Rollup merge of #110706 - scottmcm:transmute_unchecked, r=oli-obk REVERT: 12fc0aae87e stdarch: update submodule, take 2 REVERT: 5f3b8b471bf Rollup merge of #110689 - Spartan2909:fix-grammar, r=JohnTitor REVERT: bf86d174c39 Auto merge of #110655 - ChrisDenton:read-to-end, r=joshtriplett REVERT: b2c8c57a9c6 Add `intrinsics::transmute_unchecked` REVERT: 79a1b8e52d3 Fix grammar REVERT: c18104a44da Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwco REVERT: a861077c947 Merge from rustc REVERT: 2c3fdc6be7e Auto merge of #110666 - JohnTitor:rollup-3pwilte, r=JohnTitor REVERT: de359b033f1 Rollup merge of #110635 - scottmcm:zst-checks, r=the8472 REVERT: ee53692beab Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin REVERT: 61b73e479b7 More `IS_ZST` in `library` REVERT: bf1809d6ee9 Limit read size in `File::read_to_end` loop REVERT: ff573fba780 junit: also include per-case stdout in xml REVERT: 799e438a630 Fix no_global_oom_handling build REVERT: 5262752e175 Rollup merge of #110633 - scottmcm:more-take, r=thomcc REVERT: da7c7d6a47f Rollup merge of #110608 - a1phyr:specialize_io_methods, r=thomcc REVERT: 24a1b72ded9 Auto merge of #109002 - michaelvanstraten:master, r=petrochenkov REVERT: 3acabc8ba3e major test improvements REVERT: 64a94a65136 minor tweaks REVERT: 44f808157c5 fmt REVERT: da39e7ab81c fix incorrect param env in dead code lint REVERT: a42bb6effff test improvements REVERT: a82ad234c6b offset_of REVERT: b4f43886f09 More `mem::take` in `library` REVERT: ced93c78fbf Add reason to #![unstable] tag. REVERT: 2eb6b267be2 Remove doc link to private item. REVERT: 0d409b8c5a3 Get rid of core::fmt::FormatSpec. REVERT: 01812d1a8f6 Rename fmt::rt::Argument to Placeholder. REVERT: d57e55bebbf Turn core::fmt::rt::v1 into a private module. REVERT: 7227ed5f4cd Use fmt::Alignment instead of fmt::rt::v1::Alignment. REVERT: 08d858a3e38 Don't reexport core::fmt::rt from alloc::fmt. REVERT: 7b5b91a492e Specialize some `io::Read` and `io::Write` methods for `VecDeque` and `&[u8]` REVERT: fad48465570 Implement `BufRead` for `VecDeque` REVERT: cdc2033ab38 Fix `std` compilation error for wasi+atomics REVERT: ff9d41d5a7b Rollup merge of #110448 - ripytide:master, r=cuviper REVERT: 64c02f32618 Implement `Neg` for signed non-zero integers. REVERT: 741f1dfe78d Auto merge of #106704 - ecnelises:big_archive, r=bjorn3 REVERT: 0ee4774effa Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obk REVERT: b8164292734 std: make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent with `Mutex` and `RwLock` REVERT: 90186f5a60b Bump version of object and related crates REVERT: ec2a2af76dd Rollup merge of #110432 - compiler-errors:unsatisfied-index-impl, r=cjgillot REVERT: f99bfcdeb31 Use a diagnostic item instead of filtering for Index::Output REVERT: 957017f9648 Rollup merge of #110441 - kadiwa4:typos, r=thomcc REVERT: fcb3de6594a Create try_new function for ThinBox REVERT: 60c9cc3bd69 cmp doc examples consistency improvements REVERT: 207c2683bfc fix codegen difference REVERT: 9de525fdb09 Merge from rustc REVERT: 2109328cd88 typos REVERT: 57084c47042 Rollup merge of #110433 - ChrisDenton:notfound, r=thomcc REVERT: 8163a8769b4 Rollup merge of #110388 - JohnBobbo96:remove-intrinsic-unwrap, r=the8472 REVERT: 55a3242bb84 Windows: map a few more error codes to ErrorKind REVERT: 2c6d707ed2c Rename -Zoom=panic to -Zoom=unwind REVERT: 6e668fcfcd2 Remove #[alloc_error_handler] from the compiler and library REVERT: 2f3476d1e1b Report allocation errors as panics REVERT: 16f76010105 Add a message indicating overflow in `core::intrinsics::is_nonoverlapping`. REVERT: 11f5a8e88d7 fix library and rustdoc tests REVERT: aa6d2f8c179 readd `const_trait` to `Drop`, `Destruct`, and `Fn*` REVERT: 96fb880b6cd fix tidy REVERT: 9ce0e9fa92e fix alloc REVERT: 957c37dad16 core is now compilable REVERT: 259b36273d8 more hacks REVERT: 0652fee117a hack cstr is_empty REVERT: 088ef2f1a02 hack signum as well REVERT: 6267a21811c memchr hack REVERT: be7f0ddbb1c rm const traits in libcore REVERT: 2280e9732dc Remove unused unused_macros REVERT: 1b753f5201e Use a `saturating_mul` instead of a `checked_mul` and `unwrap` in `core::intrinsics`. REVERT: ced8adb93d1 Rollup merge of #110347 - est31:size_of_links, r=jyn514 REVERT: 35ef74411e4 Add intra-doc links to size_of_* functions REVERT: cc907bd0253 edit docs of `PathBuf::set_file_name` REVERT: 30f19dc17cf Add Lazy{Cell,Lock}::into_inner REVERT: 8b23524876b Rollup merge of #110244 - kadiwa4:unnecessary_imports, r=JohnTitor REVERT: e2a87da5cbd Rollup merge of #110154 - DaniPopes:library-typos, r=JohnTitor REVERT: 5bec5e54c24 Rollup merge of #110110 - lukas-code:display-panic-info, r=JohnTitor REVERT: eb5525fd7a1 Rollup merge of #109947 - clubby789:cmp-macro-crosslink, r=JohnTitor REVERT: ccf1d6d53f2 Rollup merge of #109272 - schneems:schneems/add-docs-to-command-env-methods, r=Amanieu REVERT: aa242172300 Rollup merge of #110292 - scottmcm:sort-features-2, r=jyn514 REVERT: be5b49534dc Rollup merge of #110269 - scottmcm:sort-features, r=jyn514 REVERT: 498a332f7f5 Rollup merge of #110047 - skaunov:patch-1, r=ChrisDenton REVERT: 4f511042cec Auto merge of #101959 - Xaeroxe:clamp-better-assert, r=ChrisDenton REVERT: 433054d4f26 Add links to docs to `Iterator` REVERT: b0dc1b74158 Auto merge of #110311 - matthiaskrgr:rollup-kn2k5bq, r=matthiaskrgr REVERT: b3a3f8786ca Rollup merge of #110298 - jmaargh:jmaargh/hypot-docs-edge-cases, r=thomcc REVERT: 8544322a7a7 Rollup merge of #110158 - TDecking:obsolete_test, r=ChrisDenton REVERT: 84106353796 Rollup merge of #109800 - bryangarza:safe-transmute-improved-errors, r=compiler-errors REVERT: 504f3a08c2e Rollup merge of #109225 - seanlinsley:patch-1, r=ChrisDenton REVERT: 9a1faf77da6 Auto merge of #105007 - dlaugt:solaris-fs-link, r=ChrisDenton REVERT: 71b43a83b4d Update documentation wording on path 'try_exists' functions REVERT: 830a7f69808 Improve safe transmute error reporting REVERT: ce45adc2c1d Cover edge cases for {f32, f64}.hypot() docs REVERT: 0fadfb2659b Rollup merge of #110259 - ndrewxie:issue-109964-fix-gitstuff, r=cjgillot REVERT: 9bf7d1687aa Rollup merge of #110233 - nbdd0121:intrinsic, r=tmiasko REVERT: 1eae6ab2323 Add `tidy-alphabetical` to features in `alloc` & `std` REVERT: b34fcd0dcea stdarch: update submodule REVERT: 38d10523307 Document catch_fn in r#try cannot unwind REVERT: d55c6a7e90a Rollup merge of #110262 - justincredible:patch-1, r=ChrisDenton REVERT: 42c376c1f0a Rollup merge of #110234 - marc0246:btree-insert-after-fix, r=cuviper REVERT: ac9c0fd9427 Rollup merge of #110072 - joshtriplett:stabilize-is-terminal, r=Mark-Simulacrum REVERT: e85be6cff1f Add `tidy-alphabetical` to features in `core` REVERT: 45e25cd9dbc Auto merge of #108283 - the8472:remove-splice-into-pipe, r=ChrisDenton REVERT: 21201c47332 Update unwind_safe.rs REVERT: ce9e075aa24 Added diagnostic for pin! macro in addition to Box::pin if Unpin isn't implemented REVERT: 6f10ef29fce Rollup merge of #110089 - petrosagg:mpsc-ub, r=m-ou-se REVERT: 8f1953cd0e7 remove some unneeded imports REVERT: d1011d5fe00 Fix btree `CursorMut::insert_after` check REVERT: 593615a3b31 Rollup merge of #110190 - cbeuw:mir-offset, r=oli-obk REVERT: a2516d08401 Make rust-intrinsic ABI unwindable REVERT: da2e20257f2 Rollup merge of #110173 - solid-rs:patch/kmc-solid/socket-read-buf, r=cuviper REVERT: 3a2787d7a23 Rollup merge of #110104 - kormosi:todo_typo, r=cuviper REVERT: 3cba431a416 Rollup merge of #109894 - fleetingbytes:109893-var_os-never-returns-an-error, r=cuviper REVERT: 8c7a6c25480 Rollup merge of #96971 - zhaixiaojuan:master, r=wesleywiser REVERT: b997221881b clarify wording around spurious wakeups from `thread::park` REVERT: a158ebd8e00 Reword the docstring in todo! macro definition REVERT: 02878e8197e Add Offset binary op to custom mir REVERT: b8288e5fa02 Rollup merge of #110070 - scottmcm:wrapping-neg, r=cuviper REVERT: aed8fd0b625 kmc-solid: Implement `Socket::read_buf` REVERT: 6cff5498eb2 Break up long first paragraph REVERT: 0446783874c remove obsolete test REVERT: 7082ca0ab6e Fix typos in library REVERT: ef020f2aabd Auto merge of #107007 - TDecking:float_parsing_improvments, r=Mark-Simulacrum REVERT: da45a8b5096 Rollup merge of #110044 - scottmcm:more-size-of-val, r=ChrisDenton REVERT: 82cd979f62d Stabilize IsTerminal REVERT: d1c7341374f Improve the floating point parser in `dec2flt`. REVERT: 5df38836afb Auto merge of #109684 - fee1-dead-contrib:rv_const_range, r=Mark-Simulacrum REVERT: 99f29b61277 Apply suggestions from code review REVERT: 5adc54f7d9f Auto merge of #109500 - petrochenkov:modchainld, r=oli-obk REVERT: 5ba02304576 Use `Display` in top-level example for `PanicInfo` REVERT: 6463d94071e Fix typo in todo! macro docstring REVERT: 08dea2023aa Auto merge of #110101 - JohnTitor:rollup-ol20aw7, r=JohnTitor REVERT: a6964bfa400 Rollup merge of #110060 - WaffleLapkin:sync_refs, r=jyn514 REVERT: bbb63f82b99 Enforce that PointerLike requires a pointer-like ABI REVERT: fa655ad2c8e Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times` REVERT: 9705c62eb79 sync::mpsc: synchronize receiver disconnect with initialization REVERT: 46983854576 std: Mark two reexports that should be inlined as `doc(inline)` REVERT: f97e8e7ea3d Auto merge of #110076 - Nilstrieb:rollup-22yp01c, r=Nilstrieb REVERT: efec0fb39a6 Revert "Make the `Step` implementations const." REVERT: 1d496c39a63 Revert "Mark DoubleEndedIterator as #[const_trait] using rustc_do_not_const_check, implement const Iterator and DoubleEndedIterator for Range." REVERT: bbbdb7cdd86 Auto merge of #109995 - enkron:u/enkron/substitute-hardcoded-port-num-in-listen-on-fn, r=the8472 REVERT: 7312ccab695 The `wrapping_neg` example for unsigned types shouldn't use `i8` REVERT: aa7ae41f677 fix(tcp): remove redundant `format!` macro call REVERT: 8bb45819696 Fix wrong type in docs: i16 -> u16 REVERT: dca5b16887d Document that `&T` and `&mut T` are `Sync` if `T` is REVERT: 17a845b8889 Define UNWIND_DATA_REG for loongarch64 REVERT: b77fc70711e Inline try_from and try_into REVERT: 35633e176c5 Don't claim LocalKey::with prevents a reference to be sent across threads REVERT: 37423d641ff Avoid some manual slice length calculation REVERT: a3a8aabdf48 Auto merge of #110019 - jplatte:jplatte/stabilize-is-some-and, r=Amanieu REVERT: b9374865634 Auto merge of #109990 - gwy15:remove-bufwriter-useless-mut-pointer, r=jyn514 REVERT: eedc7c32c5f Rollup merge of #109960 - thomcc:symlink-junction-buffer-overrun, r=ChrisDenton REVERT: ce930297859 Rollup merge of #109806 - Zoxc:gnu-tls, r=pnkfelix REVERT: 9b8bb4050b0 Stabilize is_some_and REVERT: e11bbfacf34 chore(tcp): change the hardcoded port number to `port` var REVERT: 25b269f73fe Remove an unnecessary `mut` in `BufWriter::into_parts`. REVERT: 7969f6ecd0f Derive String's PartialEq implementation REVERT: 3aad2652377 Refactor core::char::EscapeDefault and co. structures REVERT: f673e610d8e Fix buffer overrun in (test-only) symlink_junction REVERT: 9f52e3b6962 Auto merge of #94786 - joshlf:patch-5, r=dtolnay REVERT: c02898bdf1d Add links from `core::cmp` derives to their traits REVERT: da3f4252894 library/unwind: Add definitions for loongarch64 REVERT: e994d121c11 library/std: Add support for loongarch64 REVERT: a5c5d7791ba Rollup merge of #109883 - skaunov:patch-1, r=thomcc REVERT: 8c8e29a8314 avoid zero-copy ops for File->Pipe and File->Socket in io::copy REVERT: 4a502f62bb5 test that modifications to the source don't become visible after io::copy REVERT: 6197da54187 Preserve potential mood for equal or NUL sign REVERT: 8b00a0fbdca Remove redundant empty line REVERT: e3c6c66df4f remove self-reference in var_os doc REVERT: 4797c7297f9 add situation where var_os returns None REVERT: 5c335fe60ae Update env.rs REVERT: b19e6b968e1 Auto merge of #109756 - cr1901:msp-shift, r=Mark-Simulacrum REVERT: 05525a75251 Auto merge of #108448 - ishitatsuyuki:binary-heap, r=Mark-Simulacrum REVERT: c231dc49dd1 Rollup merge of #109722 - hermitcore:read, r=Mark-Simulacrum REVERT: d5380fa2d03 Add links to REVERT: cff1d374489 Auto merge of #109852 - Nilstrieb:rollup-g3mgxxw, r=Nilstrieb REVERT: 7021faf7479 Rollup merge of #109840 - taiki-e:typo, r=ChrisDenton REVERT: f4633f2ce73 Rollup merge of #109839 - sartak:iter-grammar, r=scottmcm REVERT: 1924ba18727 Auto merge of #109701 - Amanieu:binaryheap_retain, r=ChrisDenton REVERT: ba2813b1910 Auto merge of #109483 - joboet:optimize_lazycell, r=Mark-Simulacrum REVERT: e6c0c6558e9 Fix typo in std/src/os/fd/owned.rs REVERT: 39d1973d3f0 Improve grammar of Iterator.partition_in_place b9535c0b7d6 Auto merge of #109801 - aliemjay:test-implied-normalization, r=petrochenkov REVERT: 7b186d8db84 Rollup merge of #109443 - GuillaumeGomez:doc-primitive-hard-error, r=notriddle REVERT: 750d7501ec7 Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obk REVERT: c9924769cf0 Workaround #109797 on windows-gnu REVERT: e286b4c186b Rollup merge of #109793 - lukas-code:negative-impl-comment, r=scottmcm REVERT: e66208f802f Rollup merge of #109784 - beetrees:riscv32-time64, r=cuviper REVERT: f780c154462 Rollup merge of #109598 - veera-sivarajan:improve-wording, r=thomcc REVERT: d475e60859a Replace doc(primitive) with rustc_doc_primitive REVERT: 538caa7fb64 add comment to `impl !Error for &str` REVERT: a6f56586174 Refactor glibc time64 support, riscv32 always has 64-bit `time_t` REVERT: 19a2e7b2368 fix typo and adjust comment REVERT: d8d89221ad8 core: use `pointer::write` to cleanup `LazyCell` initialization REVERT: 758cb43f462 core: improve code documentation for `LazyCell` REVERT: 0655ebcf222 core: optimize `LazyCell` size REVERT: 097c19dc6f2 Auto merge of #109769 - JohnTitor:rollup-7n2bnpg, r=JohnTitor REVERT: 106697a3680 Rollup merge of #106985 - jofas:106746-fix, r=ChrisDenton REVERT: 14b0c7ec15b Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se REVERT: b99daa17f5b removed deprecated markdown links from documentation REVERT: 9183a3c310c Update compiler-builtins to 0.1.91 to bring in msp430 shift primitive fixes. REVERT: 5ce04c32bce Auto merge of #107221 - kleisauke:getentropy-emscripten, r=ChrisDenton REVERT: 542bde3bea0 Em dashes are cooler than hyphens. REVERT: 4762f32a4b4 Documentation updates to better share the purpose of OnceCell/OnceLock REVERT: e6cbedc9f28 Stabilize a portion of 'once_cell' REVERT: 894bd6df050 Rollup merge of #109693 - workingjubilee:maybe-unconstify-alloc, r=fee1-dead REVERT: 5276bdd31eb Rollup merge of #107387 - joboet:hermit_random, r=ChrisDenton REVERT: e25c4fa8609 Auto merge of #108089 - Zoxc:windows-tls, r=bjorn3 REVERT: e9e0a8b83ba Implement read_buf for RustHermit REVERT: eeed6a7bfcf Use with_capacity_and_hasher instead of using base REVERT: 37f9bce801e enhanced documentation of binary search methods for slice and VecDeque for unsorted instances REVERT: 3136c03bffe std: use `cvt` to handle errors from `read_entropy` on Hermit REVERT: 7d947a0862c Auto merge of #108792 - Amanieu:ohos, r=petrochenkov REVERT: dc07d90de98 Use #[inline] on Windows for thread local access REVERT: bcb1f920888 Auto merge of #108095 - soc:drop-contains, r=Amanieu REVERT: d95d5d11396 Remove ~const from alloc REVERT: 85736d7c143 Stabilize `binary_heap_retain` REVERT: 4693215a360 Auto merge of #109692 - Nilstrieb:rollup-hq65rps, r=Nilstrieb REVERT: a78e28925e2 Add OpenHarmony targets REVERT: 25c5543d109 Auto merge of #108080 - oli-obk:FnPtr-trait, r=lcnr REVERT: 1298171bd7d Rollup merge of #92284 - the8472:simplify-advance-by, r=scottmcm REVERT: 6e42c31b8cd Rollup merge of #91793 - devnexen:anc_data_fbsd, r=ChrisDenton REVERT: fac0b9bdcf5 Rollup merge of #109687 - joshtriplett:document-windows-isterminal-heuristics, r=BurntSushi REVERT: b64de859fa8 Rollup merge of #109682 - clubby789:c-str-inline, r=scottmcm REVERT: 814423ff929 Allow access to `OsStr` bytes REVERT: 4e8007d3d30 Add "Platform-specific behavior" heading and link to changes disclaimer REVERT: 2c97f30bf74 Document the heuristics IsTerminal uses on Windows REVERT: 6bfdb1c6f9e Add `#[inline]` to CStr trait implementations REVERT: d8515bf1a73 socket ancillary data implementation for FreeBSD (from 13 and above). REVERT: ea7fb587ba6 Fix ASCII case comment REVERT: 173bc3dd115 fix advance_by impl for vec_deque and add tests REVERT: 9fca0e95eee update documentation REVERT: 2442cdf5819 replace advance_by returning usize with Result<(), NonZeroUsize> REVERT: 2e60a185031 Use the FnPtr trait to avoid implementing common traits via macros REVERT: eca43935de1 Add a builtin `FnPtr` trait REVERT: 4c871ad2704 Change advance(_back)_by to return `usize` instead of `Result<(), usize>` REVERT: f6169cd7e98 Document that SystemTime does not count leap seconds REVERT: 4d2624060fa Add note about clone-and-hack to the two UNIX_EPOCH definitions REVERT: 28af9c025d6 Rollup merge of #102742 - bjorn3:cleanup_rust_start_panic, r=ChrisDenton REVERT: fb4f8ee84de Rollup merge of #98651 - mattfbacon:master, r=ChrisDenton REVERT: 3c508e14904 Rollup merge of #97506 - JohnTitor:stabilize-nonnull-slice-from-raw-parts, r=m-ou-se,the8472 REVERT: 113f72dc6b4 Auto merge of #109357 - saethlin:inline-as-deref, r=thomcc REVERT: 3cdd30baedf Remove unnecessary raw pointer in __rust_start_panic arg REVERT: 44c7aab8bdd Merge branch 'master' into Issue-107957-black_box_docs REVERT: f02f04fd603 Rollup merge of #109620 - eievui5:patch-1, r=compiler-errors REVERT: d3b2fab09a2 Auto merge of #105096 - LegionMammal978:copied-allocators, r=Amanieu REVERT: 2dd9f168569 Correct typo (`back_box` -> `black_box`) REVERT: 08685a1b4ab Improve documentation for str::replace() and str::replacen() REVERT: 1c4294d4905 Auto merge of #99929 - the8472:default-iters, r=scottmcm REVERT: 6ae3f89405e Auto merge of #109546 - saethlin:inline-into, r=scottmcm REVERT: 1b42803defe Add #[inline] to the Into for From impl REVERT: 3b3248ba9d3 Auto merge of #109216 - martingms:unicode-case-lut-shrink, r=Mark-Simulacrum REVERT: 6dfc1acaa73 Rollup merge of #109406 - WaffleLapkin:🥛, r=cuviper REVERT: 9a5d53cdeee Rollup merge of #109368 - hermitcore:typo, r=cuviper REVERT: c086eb79aca Rollup merge of #109142 - the8472:mutex-block-docs, r=cuviper REVERT: dfbaad616b5 Rollup merge of #108924 - tmiasko:panic-immediate-abort, r=thomcc REVERT: c186ebd3623 A MIR transform that checks pointers are aligned REVERT: 55b9726a429 Auto merge of #109538 - matthiaskrgr:rollup-ct58npj, r=matthiaskrgr REVERT: a90568d5056 Rollup merge of #106964 - workingjubilee:crouching-ioerror-hidden-documentation, r=ChrisDenton REVERT: df796031741 Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obk REVERT: 26b5f5f2fe8 Auto merge of #109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgr REVERT: 18e7d9ec3aa Rollup merge of #109504 - steffahn:stabilize_a_rc_into_inner, r=joshtriplett REVERT: edd5c0326d9 Auto merge of #109503 - matthiaskrgr:rollup-cnp7kdd, r=matthiaskrgr REVERT: a3445cea9ec Stabilize `arc_into_inner` and `rc_into_inner`. REVERT: fd8f74d96ec Add `CastKind::Transmute` to MIR REVERT: e089bc68d06 Rollup merge of #109359 - Nilstrieb:bump-stdarch, r=Amanieu REVERT: b612c4bfc0f Auto merge of #109497 - matthiaskrgr:rollup-6txuxm0, r=matthiaskrgr REVERT: 67bc6fea47b Rollup merge of #109392 - cbeuw:composite-ret, r=JakobDegen REVERT: bc13a36600c Rollup merge of #109179 - llogiq:intrinsically-option-as-slice, r=eholk REVERT: 5d6b7688b8b Rollup merge of #100311 - xfix:lines-fix-handling-of-bare-cr, r=ChrisDenton REVERT: c6f1e40c9f4 Check the presence of linkat() on Solaris (not available in version 10, available in version 11) REVERT: e79d25cbcf5 Rollup merge of #108164 - joboet:discard_messages_mpmc_array, r=Amanieu REVERT: 49006ef2c57 Rollup merge of #96391 - ChrisDenton:command-non-verbatim, r=joshtriplett REVERT: e0887780986 Rollup merge of #108326 - tmiasko:read-buf, r=thomcc REVERT: cc0b9c07e1b Rollup merge of #106434 - clubby789:document-sum-result, r=the8472 REVERT: d3fe8b61c0f Use hex literal for INDEX_MASK REVERT: 7a4bdc553e3 Auto merge of #106967 - saethlin:remove-vec-as-ptr-assume, r=thomcc REVERT: 6a6522d8b06 Auto merge of #108717 - TDecki:dec2flt-inline, r=thomcc REVERT: d15127809ca Auto merge of #108262 - ChrisDenton:libntdll, r=Mark-Simulacrum REVERT: 98db604f6df Remove outdated comments REVERT: 9dd8be9038b Add example for `Option::product` and `Result::product` REVERT: 88d8c41b941 Add documentation for `type RET = ...` REVERT: e6f5020ed9b Allow optional RET type annotation REVERT: 7ea616e64b5 Apply suggestions from code review REVERT: 37dfc00dba2 Add block-based mutex unlocking example REVERT: 272d5cb538a Rollup merge of #109273 - WaffleLapkin:slice_is_sorted_by_array_windows, r=scottmcm REVERT: 5ef11b1616b Rollup merge of #109353 - Nilstrieb:rustc-mir-building, r=compiler-errors REVERT: d875fa2bb18 Rollup merge of #109337 - frengor:collect_into_doc, r=scottmcm REVERT: 9e2ced5d12e Auto merge of #108148 - parthopdas:master, r=oli-obk REVERT: 5a3494be362 fix typo in the creation of OpenOption REVERT: fcb93149c46 Add `#![feature(generic_arg_infer)]` to core for stdarch REVERT: f5c8af67271 Update stdarch REVERT: 1b2c9e682b9 Add #[inline] to as_deref REVERT: 2c91f70f782 Fix wrong crate name in custom MIR docs REVERT: 7f0cd7e8f50 Rollup merge of #109022 - tmiasko:read-buf-exact, r=dtolnay REVERT: 08a4e753a18 Rollup merge of #108973 - est31:pin_docs, r=Mark-Simulacrum REVERT: 0eed6b511f4 Rollup merge of #108829 - xfix:use-edition-2021-pat-in-matches, r=Mark-Simulacrum REVERT: 5864082e9f8 Rollup merge of #108798 - devsnek:panic-pal-exception, r=workingjubilee REVERT: c9754f358c1 Rollup merge of #104100 - ink-feather-org:const_iter_range, r=the8472,fee1-dead REVERT: e150499f133 Improve collect_into documentation REVERT: 7f8879a4a3e Rollup merge of #109288 - jmillikin:linux-abstract-socket-addr, r=joshtriplett REVERT: 1b47769d6f1 Rollup merge of #109287 - scottmcm:hash-slice-size-of-val, r=oli-obk REVERT: 28cfe153248 Mark DoubleEndedIterator as #[const_trait] using rustc_do_not_const_check, implement const Iterator and DoubleEndedIterator for Range. REVERT: e2d430a417f move Option::as_slice to intrinsic REVERT: 8ad105ae678 review REVERT: d8157bec765 move default backtrace setting to sys REVERT: 12b5f6d3431 Stabilise `unix_socket_abstract` REVERT: 7f9907fe86b Use `size_of_val` instead of manual calculation REVERT: af2d0ef2855 Rollup merge of #109235 - chaitanyav:master, r=ChrisDenton REVERT: def897e091c Make the `Step` implementations const. REVERT: 753c2e7ff56 Remove irrelevant docs on error kinds REVERT: 586e615942e Auto merge of #108862 - Mark-Simulacrum:bootstrap-bump, r=pietroalbini REVERT: ebb51d3f302 Switch impls of `is_sorted_by` between slices and slice iters REVERT: 9fd5d9b851b Make `slice::is_sorted_by` impl nicer REVERT: 28f1d0d1005 Add Command environment variable inheritance docs REVERT: 84059399426 Modify code style as per comments REVERT: e9c15bbfedb Update mod.rs REVERT: fa76ddf9ddd fix typo in documentation for std::fs::Permissions REVERT: 0ed8ffdbd29 run rustfmt on changes REVERT: 221c7c29e76 fallback to lstat when stat fails on Windows REVERT: 23fbb7bd3df Improve case mapping encoding scheme REVERT: 10e6399c113 Beautify pin! docs REVERT: 8f35bbddbca Clarify that RUST_MIN_STACK is internally cached REVERT: cf79eec2175 Auto merge of #106824 - m-ou-se:format-args-flatten, r=oli-obk REVERT: 7bf9ec1aff4 Split unicode case LUTs in single and multi variants REVERT: 5da38376663 Don't allow new const panic through format flattening. REVERT: 5c69f9d211f Update format_args!() test to account for inlining. REVERT: 7392f8f87ec unequal → not equal REVERT: 63e3a528a41 Implementing " --list --format json" #107307 #49359 REVERT: a33e8c355cd Skip serializing ascii chars in case LUTs REVERT: 9be44703098 Bump to latest beta REVERT: 0edb12ca7cb Bump version placeholders REVERT: 75291bc1bcf Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen REVERT: 07af1880339 Improved implementation and comments after code review feedback REVERT: a788913fe61 std: leak remaining messages in bounded channel if message destructor panics REVERT: bce85392b3a Update libc dependency of std to 0.2.140 REVERT: 99037a17615 Use getentropy() instead of /dev/urandom on Emscripten REVERT: 4125ee5b318 Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errors REVERT: 3cb37c1b5d1 Rollup merge of #108507 - hermitcore:new, r=m-ou-se REVERT: b4549565835 Rollup merge of #108419 - tgross35:atomic-as-ptr, r=m-ou-se REVERT: ef5cd79cb47 add `#[doc(alias="flatmap")]` to `Option::and_then` REVERT: 0ce98c286ee Auto merge of #108623 - scottmcm:try-different-as-slice-impl, r=the8472 REVERT: 17326af7983 Clarify stability guarantee for lifetimes in enum discriminants REVERT: 6eaadd313cd Clarify the text of some comments REVERT: 48ea552301a Add a better approach comment in `ptr::read` to justify the intrinsic REVERT: f5a3353428f Rollup merge of #109026 - joshtriplett:rc-into-inner, r=dtolnay REVERT: e9cbac0f405 Fix formatting of new Rc::into_inner test REVERT: 3b5ad5a545e Move `Option::as_slice` to an always-sound implementation REVERT: faf3a29b7f0 `MaybeUninit::assume_init_read` should have `noundef` load metadata REVERT: ebba1747e98 Introduce `Rc::into_inner`, as a parallel to `Arc::into_inner` REVERT: bf4abcb726a Auto merge of #109019 - matthiaskrgr:rollup-ihjntil, r=matthiaskrgr REVERT: 180704d55e3 read_buf_exact: on error, all read bytes are appended to the buffer REVERT: b9bf0f06b3f Rollup merge of #108708 - noamtashma:issue-108706-fix, r=m-ou-se REVERT: 38dde333a00 Rollup merge of #106633 - c410-f3r:stabilize-nonzero_bits, r=dtolnay REVERT: 4d3e3b67356 Rollup merge of #104363 - WaffleLapkin:bonk_box_new, r=Nilstrieb REVERT: 1ed98858823 Rollup merge of #108927 - Ayush1325:pal-cleanup, r=workingjubilee REVERT: 573257e129c Rollup merge of #106276 - Sp00ph:unify_slice_ranges, r=the8472 REVERT: 60a920af974 Renamed to byte_range and changed Range generics [skip ci] REVERT: 1ec010b13a2 Auto merge of #109001 - matthiaskrgr:rollup-a3agnwp, r=matthiaskrgr REVERT: 72171f7c64c added byte position range for proc_macro::Span REVERT: bebf44e4ca1 added byte position range for proc_macro::Span REVERT: 2206fa1142e Rollup merge of #105962 - zertosh:stabilize_path_as_mut_os_str, r=dtolnay REVERT: 8ea8b5237fa improve doc test for UnsafeCell::raw_get and fix docs error REVERT: 894ac2d3d82 Rollup merge of #106921 - madsmtm:cell-memory-layout, r=dtolnay REVERT: dfd43710e8e Moved thread_local implementation to sys::common REVERT: 0354fda5a81 Split __thread_local_inner macro REVERT: 2656eb1473a Move __thread_local_inner to sys REVERT: 03807b704e7 Rollup merge of #108964 - majaha:ptr_metadata_doc, r=workingjubilee REVERT: 548a9ebceae Rollup merge of #108956 - Raekye:master, r=scottmcm REVERT: 1197686ad73 Fix docs for ptr method with_metadata_of() REVERT: 71f8ba339a2 Make ptr::from_ref and ptr::from_mut in #106116 const. REVERT: 73e0833dbfd Add examples section which demonstrates the behaviour (specifically the sign positive aspect) REVERT: ea5bba5efc9 Add missing comment for f64 REVERT: ae03877e2db Indicate that `0.0` refers to positive `0.0` REVERT: 5732556d2f9 Document the resulting values produced when using `From` on floats REVERT: 16076d8cf99 Auto merge of #108920 - matthiaskrgr:rollup-qrr9a0u, r=matthiaskrgr REVERT: 72889f76832 panic_immediate_abort requires abort as a panic strategy REVERT: c5350130a50 Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiasko REVERT: 479bcff7b00 rand: freebsd update, using getrandom. REVERT: 88f14308127 Remove `identity_future` indirection REVERT: fa22dafc122 may not => cannot REVERT: 862f0b6515a black_box hint - Adjust for improved readability REVERT: a29772b4aba Remove DropAndReplace terminator REVERT: ee0e00ac129 Auto merge of #108763 - scottmcm:indexing-nuw-lengths, r=cuviper REVERT: 51ff5833429 Auto merge of #95317 - Jules-Bertholet:round_ties_to_even, r=pnkfelix,m-ou-se,scottmcm REVERT: ced613ae96d Use Edition 2021 :pat in matches macro REVERT: aac91712481 issue-108706-fix REVERT: d55960cfcdc Implement read_buf for a few more types REVERT: b55cbf74199 Use `nuw` when calculating slice lengths from `Range`s REVERT: 3528152276b Auto merge of #108157 - scottmcm:tuple-gt-via-partialcmp, r=dtolnay REVERT: 41825254c00 Auto merge of #105117 - pitaj:debug_asserts, r=the8472 REVERT: 40969204a6b Comment for why char boundaries aren't checked REVERT: e4237465900 Rollup merge of #108660 - xfix:remove-ne-method-from-str, r=thomcc REVERT: 202d79591b1 Auto merge of #89518 - a1phyr:unix_file_vectored_at, r=workingjubilee REVERT: e1143590c10 Update comment. REVERT: d307b218f63 typo REVERT: 537da8bc6cf Add inlining annotations REVERT: 6663a09e35e Rollup merge of #108688 - est31:backticks_matchmaking_library, r=jyn514 REVERT: 578c250b08d Rollup merge of #108540 - WaffleLapkin:atomic_thingy_from_thingy_pointer, r=m-ou-se REVERT: 24cd510b869 fix an alloc test REVERT: a71dfd9eb31 Make `unused_allocation` lint warn against `Box::new` REVERT: 9925c1a5942 Use weak linkage for `preadv` and `pwritev` on MacOS and iOS REVERT: 02d39781c5b Update library/std/src/io/mod.rs REVERT: cdddb79048e Match unmatched backticks in library/ REVERT: fc46ed1ca66 Make std tests pass on newer Android REVERT: e3217a3fae6 Remove manual implementation of String::ne REVERT: cdf2321fd0c Remove manual implementation of str::ne REVERT: 43b875f295f Revert "Stabilize `#![feature(target_feature_11)]`" REVERT: 1261869e20c Fill-in tracking issue for `feature("atomic_from_ptr")` REVERT: feee768d541 Add basic tests REVERT: 59383a8aa00 Take shared references as parameter REVERT: cbd3103bb2d Use weak linkage on Android REVERT: 1ca9c435167 Auto merge of #106673 - flba-eb:add_qnx_nto_stdlib, r=workingjubilee REVERT: 72399efad56 Fix docs for `alloc::realloc` REVERT: ffcac4381d3 Auto merge of #108483 - scottmcm:unify-bytewise-eq-traits, r=the8472 REVERT: 91cbdfb165d Merge two different equality specialization traits in `core` REVERT: 2933a23f9e5 Rollup merge of #108462 - pommicket:fix-vecdeque-zst-overflow, r=Amanieu REVERT: 347e36dd094 Auto merge of #105871 - llogiq:option-as-slice, r=scottmcm REVERT: 6b7238ca3e0 Auto merge of #108476 - saethlin:remove-library-rustc-box, r=thomcc REVERT: 2721cd1fe0e Update library/std/src/os/nto/mod.rs REVERT: b2d307cfc84 Update library/std/src/io/mod.rs REVERT: 1956e50e85a Rollup merge of #108558 - RalfJung:core-tests, r=thomcc REVERT: e647d97cbe1 Rollup merge of #108531 - Coca162:rustdoc-repeat-const-array, r=thomcc REVERT: 87ebd39640a Add `Option::as_slice`(`_mut`) REVERT: c6761f73708 relax bounds on iterator adapter Default impls REVERT: 48d9ed9a06f Support allocators in various Default for IntoIter impls REVERT: dc20eaa28c1 rewrite iterator `Default` tests as doctests REVERT: 700eac9b1c2 Implement Default for some alloc/core iterators REVERT: 02c42239530 Retry to spawn/fork up to 3 times when it failed because of an interruption REVERT: 1b71308d56c Add QNX Neutrino support to libstd REVERT: 05ae636b63d Auto merge of #107987 - EFanZh:inline-poll-methods, r=Mark-Simulacrum REVERT: 42f0abc7b7f add missing feature in core/tests REVERT: 7c4d4781a37 Auto merge of #106774 - Nugine:master, r=Amanieu REVERT: 0955c572e2d Remove or justify use of #[rustc_box] REVERT: 136e9cc55ec Auto merge of #99767 - LeSeulArtichaut:stable-target-feature-11, r=estebank REVERT: e82974c28a1 Add `Atomic*::from_ptr` REVERT: 92e627385aa Rollup merge of #107110 - strega-nil:mbtwc-wctmb, r=ChrisDenton REVERT: 2912c7e3916 Rollup merge of #104265 - faern:move-ipaddr-to-core, r=joshtriplett REVERT: 701e296f784 Clarify that Copy is a trait in array docs REVERT: cac346944a7 Update docs to show [expr; N] can repeat const expr REVERT: ea610ad6d85 Add vectored positioned I/O on Unix REVERT: 1143da104d9 use `as_ptr` to determine the address of atomics REVERT: 90847d23596 remove unused imports REVERT: 15600fa6284 Merge from rustc REVERT: 8e8800b0875 Add tracking issue REVERT: 03d6b472a1b Move IpAddr and SocketAddr to core REVERT: e8612fdb812 Rollup merge of #108484 - Nilstrieb:˂DiagnosticItem˂FromFn˃ as From˂˂LangItemFromFn˃˃˃꞉꞉from, r=cjgillot REVERT: 43915a1c1ee Rollup merge of #108475 - Sp00ph:fix_shrink_to, r=thomcc REVERT: 8474e262a47 Rollup merge of #108299 - scottmcm:literal-bits, r=Nilstrieb REVERT: fdad5d2ccf9 std: disconnect senders before discarding messages REVERT: 2919c3402ae std: use random HashMap keys on Hermit REVERT: 30841611676 Remove `from_fn` lang item REVERT: 2b0bbe8da84 Disambiguate comments REVERT: 8c06abd3ec4 Fix `VecDeque::shrink_to` and add tests. REVERT: 668ea44a5c7 Rollup merge of #108432 - klensy:test-deps, r=Mark-Simulacrum REVERT: 261bc4cef2b Rollup merge of #107890 - obeis:mapping-to-unit, r=cjgillot REVERT: 3fbe383b809 Auto merge of #107405 - hermitcore:bsd, r=bjorn3 REVERT: fcd54a487a4 [stdio][windows] Use MBTWC and WCTMB REVERT: 708984b58a5 Add test for VecDeque::append ZST capacity overflow REVERT: f75ddf1993c Auto merge of #108450 - matthiaskrgr:rollup-rqvfgu3, r=matthiaskrgr REVERT: a9ed83f06ed Use checked_add in VecDeque::append for ZSTs to avoid overflow REVERT: 861536841b4 Rollup merge of #108407 - notriddle:notriddle/vec-get-mut, r=thomcc REVERT: f127e016ee0 Auto merge of #108233 - ChrisDenton:move-std-tests, r=thomcc REVERT: 19ef09220e6 binary_heap: Unify Extend implementation. REVERT: 3843261da7d binary_heap: Make RebuildOnDrop a common helper. REVERT: a68780fa0da Auto merge of #107638 - zhangyunhao116:pdqsort-rand, r=cuviper REVERT: 1b2ab923770 test: drop unused deps REVERT: c35610e4554 avoid the usage of libc during the creation of documentation REVERT: aa3657848b0 remove code duplications REVERT: 919ca7183e0 move IO traits to std/src/os/hermit REVERT: d649783a609 add support of RustyHermit's BSD socket layer REVERT: 548879e17e2 Rollup merge of #108391 - sunfishcode:sunfishcode/is-terminal-file-length, r=ChrisDenton REVERT: 8a0d376cbda Rollup merge of #108370 - fbq:time-doc-fix, r=thomcc REVERT: db142f8dabb Rollup merge of #106918 - dtolnay:heapretain, r=the8472 REVERT: 8cee638ac94 Rollup merge of #106541 - fee1-dead-contrib:no-const-check-no, r=thomcc REVERT: 3021fb0b750 Stabilize atomic_as_ptr REVERT: 0087533510a black_box doc corrections - Issue #107957 REVERT: ac56e77f37e docs: use intra-doc links for `Vec::get(_mut)` REVERT: 5bbc9aa7399 Fix `is_terminal`'s handling of long paths on Windows. REVERT: 6111ea78f2e Add lint against `Iterator::map` receiving a callable that returns `()` REVERT: 8850f4ec9bd Require `literal`s for some `(u)int_impl!` parameters REVERT: 47a64b8d576 Rollup merge of #108218 - ChrisDenton:cmd-escape, r=cuviper REVERT: 62ed3a0bbe8 std: time: Avoid to use "was created" in elapsed() description REVERT: 6acdb2d2698 Rollup merge of #107736 - tgross35:atomic-as-ptr, r=m-ou-se REVERT: 29c43621bec Optimize break patterns REVERT: f01bdfa58e1 Quote more batch file arguments REVERT: 9698d77bb89 Exclude SGX from create_dir_all_bare test REVERT: d7e16651cd4 Make `create_dir_all_bare` an std integration test REVERT: 27e5db85002 Move `rename_directory` from ui-fulldeps to std REVERT: 5801873f177 Remove unused FileDesc::get_cloexec REVERT: b58b9502789 Merge from rustc REVERT: 7919e47b973 Rollup merge of #108272 - MrNossiom:master, r=thomcc REVERT: 9333fe50155 Rollup merge of #108105 - majaha:patch-1, r=cuviper REVERT: d3dda2a6e9f fix more benchmark test with black_box REVERT: 7f81a05530f Explain the default panic hook better REVERT: 0892ad7a7ef use UpperCamelCase REVERT: d67724d9479 Changes according to review REVERT: b27dcb61b43 Rollup merge of #108279 - Nilstrieb:int, r=scottmcm REVERT: 72833aa8071 Use named arguments for `int_impl` macro REVERT: 9d427c629e1 Use named arguments for `uint_impl` macro REVERT: fbc5b30ddea Stabilize const slice::split_at REVERT: 6fe3eb3a335 docs: wrong naming convention in struct keyword doc REVERT: 69669fc6987 Rollup merge of #108124 - kornelski:cstr_c_char, r=thomcc REVERT: 22a93b86352 Merge from rustc REVERT: 220c8d8941d Distribute libntdll.a with windows-gnu toolchains REVERT: db02d819f8e Remove the assume(!is_null) from Vec::as_ptr REVERT: cadcde4824e Use custom implementation of read_buf in Read for &'a FileDesc REVERT: ca284320073 Rollup merge of #108130 - tshepang:just-one-example, r=workingjubilee REVERT: 5bf95614807 Rollup merge of #106933 - schuelermine:fix/doc/102451, r=Amanieu REVERT: f8cb11080bb Rollup merge of #104659 - tshepang:reflow, r=workingjubilee REVERT: 93422209027 Auto merge of #106241 - Sp00ph:vec_deque_iter_methods, r=the8472 REVERT: a00ccbf3a80 Merge from rustc REVERT: e1a32c03b18 Update documentation of select_nth_unstable and select_nth_unstable_by and select_nth_unstable_by_key to state O(n log n) worst case complexity REVERT: 2e74c9738b6 Auto merge of #107329 - joboet:optimize_lazylock, r=m-ou-se REVERT: 1eeb9620cb7 Implement `AsHandle`/`AsSocket` for `Arc`/`Rc`/`Box` on Windows REVERT: 3a9d7e41785 Add a slightly-contrived tuple comparison benchmark REVERT: 4ed3de2d1a2 std: add regression test for #107466 REVERT: 7ef9ba2681d std: drop all messages in bounded channel when destroying the last receiver REVERT: 7f75cdfa93b Use `partial_cmp` to implement tuple `lt`/`le`/`ge`/`gt` REVERT: 3ab2eb876bf Rollup merge of #104068 - yancyribbens:partial-cmp-doc-update, r=scottmcm REVERT: bfd40aa34ef rustdoc: Update the description to include PartialOrd elements REVERT: 187b3336368 "Basic usage" is redundant for there is just one example REVERT: 453d7fb633c Document that CStr::as_ptr returns a type alias REVERT: 4b9cf232e95 std: replace generic thread parker with explicit no-op parker REVERT: 6d0f42da4aa Merge from rustc REVERT: 740682f6443 Rollup merge of #108084 - ink-feather-org:const_range, r=dtolnay REVERT: 5941c8ccd80 Rollup merge of #106372 - joboet:solid_id_parking, r=m-ou-se REVERT: f6540f14177 Rollup merge of #108094 - kornelski:fsdocs, r=cuviper REVERT: eb140e17bc9 Remove `#![feature(option_result_contains)]` from library/core/tests/lib.rs REVERT: a2a54fab871 Suggest simpler fs helper methods in File::{open,create} REVERT: 7526934dbc2 Drop unstable `Option::contains`, `Result::contains`, `Result::contains_err` REVERT: b534ee11541 Demonstrate I/O in File examples REVERT: 841cf87feb3 clarify correctness of `black_box` REVERT: 8136b3c2f1a Constify `RangeBounds`, `RangeX::contains` and `RangeX::is_empty`. REVERT: 9c056af3b01 Use libc which supports QNX Neutrino REVERT: 45e8d20e180 Merge from rustc REVERT: 37d6af631dd Rollup merge of #108060 - ChrisDenton:rtlgenrandom, r=thomcc REVERT: e4fa74dd2f2 Auto merge of #108056 - matthiaskrgr:rollup-oa6bxvh, r=matthiaskrgr REVERT: b00f643c834 Revert to using `RtlGenRandom` REVERT: 3ab5203925b Rollup merge of #108033 - lcnr:coinductive-attr, r=compiler-errors REVERT: b027c280dda Rollup merge of #107573 - cuviper:drop-llvm-13, r=nagisa REVERT: ffdd35759bb Rollup merge of #108023 - JulianKnodt:smaller_benchmark, r=workingjubilee REVERT: 0a6e9c1e586 Rollup merge of #108016 - tshepang:just-one-example, r=thomcc REVERT: 5245aca6e64 add a `#[rustc_coinductive]` attribute REVERT: 6d6dac5822f Shrink size of array benchmarks REVERT: 2e98c85419a "Basic usage" is redundant for there is just one example REVERT: 599b741fb47 Rollup merge of #107985 - alesito85:master, r=ChrisDenton REVERT: 71d7b9c647d fix and extend dropck documentation REVERT: 3fe3c2505b1 Add another error to Windows file open fallback REVERT: 6a6c1d8d1b4 Auto merge of #107634 - scottmcm:array-drain, r=thomcc REVERT: bf9c91ab223 Auto merge of #107980 - Dylan-DPC:rollup-u4b19bl, r=Dylan-DPC REVERT: 9b08f7b6bba Inline `Poll` methods REVERT: 2d51085b454 Rollup merge of #107970 - hermitcore:hermit-rm-floor, r=thomcc REVERT: ac56d166b95 Rollup merge of #107962 - scottmcm:why-not-exact, r=Mark-Simulacrum REVERT: ca7dfeefa53 Rollup merge of #107961 - scottmcm:unify-ilog-panics, r=Mark-Simulacrum REVERT: d0cfafd40c5 Rollup merge of #107915 - JulianKnodt:array_benches, r=Mark-Simulacrum REVERT: 54b9ae3e6a6 Rollup merge of #107654 - pitaj:reword-integral-modules, r=thomcc REVERT: 9c6b50cc7b5 Auto merge of #107191 - Voultapher:reverse-timsort-scan-direction, r=thomcc REVERT: fb0bc947507 Hermit: Remove floor symbol REVERT: db7d351035b Rollup merge of #107954 - RalfJung:tree-borrows-fix, r=m-ou-se REVERT: bfad8a4e3ac Rollup merge of #107943 - compiler-errors:document-pointer-like, r=jyn514 REVERT: 127b505ecec Add a doc note about why `Chain` is not `ExactSizeIterator` REVERT: 844993d9ebc avoid mixing accesses of ptrs derived from a mutable ref and parent ptrs REVERT: f3ea8f3c067 Auto merge of #105671 - lukas-code:depreciate-char, r=scottmcm REVERT: 11ddd7c5840 Auto merge of #107894 - Voultapher:improve-heapsort-fallback, r=scottmcm REVERT: b2d452a1528 Document PointerLike REVERT: 0d402fd0a55 Auto merge of #106677 - tbu-:pr_less_doc_hidden_pub, r=scottmcm REVERT: ec46918d422 Auto merge of #107167 - the8472:rawvec-simpler-layout, r=thomcc REVERT: fbaf93c33c9 Split branches in heapsort child selection REVERT: 1182ce6bf67 Rollup merge of #107900 - ChrisDenton:zero-header, r=thomcc REVERT: 89358bd3d94 Rollup merge of #107878 - workingjubilee:new-size-means-bytes, r=scottmcm REVERT: 4723faf1d99 Rollup merge of #106001 - sdroege:glibc-skip-over-null-argv, r=ChrisDenton REVERT: 7e9408896b4 Add array::map benchmarks REVERT: e20fdb02380 Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref #66893) REVERT: 6f4daed7e7c Drop llvm14-builtins-abi with compiler_builtins 0.1.87 REVERT: 09c81fc4eed Have a function for the `log(0)` panic, rather than copy-pasting the string constant REVERT: b92a531db9b Zero the `REPARSE_MOUNTPOINT_DATA_BUFFER` header REVERT: 23c5c36a364 Speedup heapsort by 1.5x by making it branchless REVERT: 32eec48afd6 Clarify `new_size` for realloc means bytes REVERT: 29272482f90 Remove a couple of `#[doc(hidden)] pub fn` and their `#[feature]` gates REVERT: f41b528f774 Allow wasi-libc to initialize its environment variables lazily. REVERT: 652530e2106 Rollup merge of #107655 - notriddle:notriddle/small-url-encode, r=GuillaumeGomez REVERT: 6609fe86188 Merge from rustc REVERT: fd4a692e725 Rollup merge of #107429 - tgross35:from-bytes-until-null-stabilization, r=dtolnay REVERT: 341ae7fb4c1 Rollup merge of #107317 - ids1024:asfd-rc, r=dtolnay REVERT: 6f15820e5d4 Rollup merge of #107793 - joboet:raw_os_error_ty_tracking, r=Dylan-DPC REVERT: aaec226bf97 Rollup merge of #105641 - Amanieu:btree_cursor, r=m-ou-se REVERT: a45335325cc std: add tracking issue for `RawOsError` REVERT: 0f22d171f6f Rollup merge of #107776 - dbrgn:docs-string-reserve-headings, r=cuviper REVERT: e3eb12dda13 Rollup merge of #107769 - compiler-errors:pointer-like, r=eholk REVERT: 16374804f5e Docs: Fix format of headings in String::reserve REVERT: de99e9a959c Rename PointerSized to PointerLike REVERT: 4dd2dffc5a3 Rollup merge of #107706 - tgross35:atomic-as-mut-ptr, r=m-ou-se REVERT: e7451acaa9f Merge from rustc REVERT: e05e562da64 Rollup merge of #107720 - tshepang:consistency, r=Mark-Simulacrum REVERT: 5f21926edcf Rollup merge of #107714 - Wilfred:round_docs, r=m-ou-se REVERT: 2c6d446c167 Auto merge of #103761 - chenyukang:yukang/fix-103320-must-use, r=compiler-errors REVERT: 54957ea2aea end entry paragprah with a period (.) REVERT: a94d3412a8a Clarify wording on f64::round() and f32::round() REVERT: 83ae4dd6cc7 Mark 'atomic_mut_ptr' methods const REVERT: 26b22420079 Fix typo in HashMap::with_capacity REVERT: 5dea6384799 Add `slice_ranges` safety comment REVERT: 9dd395eb10a Allow canonicalizing the `array::map` loop in trusted cases REVERT: 1cd824f64aa Stop forcing `array::map` through an unnecessary `Result` REVERT: 936801f85b7 Stop using `into_iter` in `array::map` REVERT: 2de17138c83 docs: update fragment for Result impls REVERT: 6aa6041cdc1 reword descriptions of the deprecated int modules REVERT: e8d4ea279b7 Rollup merge of #107632 - ameknite:issue-107622-fix, r=jyn514 REVERT: 43f06cbce97 Rollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obk REVERT: c547df12c1e Rollup merge of #107519 - joboet:raw_os_error_ty, r=Amanieu REVERT: 3456d5056f9 nit fixed REVERT: d315ab54bfa Clarifying that .map() returns None if None. REVERT: bee1b0aea11 Update library/std/src/io/mod.rs REVERT: 3b07fa431a1 Fix #103320, add explanatory message for [#must_use] REVERT: 87fc032ee97 Replace `ConstFnMutClosure` with const closures REVERT: 014808c94ab Rollup merge of #107598 - chenyukang:yukang/fix-core-bench, r=thomcc REVERT: dc8923548a1 Specify behavior of HashSet::insert REVERT: d87538fe743 fix #107590, Fix benchmarks in library/core with black_box REVERT: eb38d94de99 Merge from rustc REVERT: acb6f7e8079 Stabilize `#![feature(target_feature_11)]` REVERT: 495e21709e2 Change 'from_bytes_until_nul' to const stable REVERT: f42f4256447 Stabilize feature 'cstr_from_bytes_until_nul' REVERT: fc4b51372b0 Rollup merge of #107442 - lukas-code:slice-panics, r=cuviper REVERT: 7ebdbc5cac0 Rollup merge of #107389 - zvavybir:master, r=estebank REVERT: 5b20b20102b Stabilize cmpxchg16b_target_feature REVERT: b26ef3dbbf0 BTreeMap: Add Cursor and CursorMut REVERT: e97545f02ff BTreeMap: Change internal insert function to return a handle REVERT: 8ddff35ebb6 improve panic message for slice windows and chunks REVERT: 9e236905af8 Rollup merge of #107535 - dcompoze:tcp-doc-unwrap, r=cuviper REVERT: 08f0e802fe3 Replace unwrap with ? in TcpListener doc REVERT: b2ce765c122 Auto merge of #107297 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini REVERT: 24abb433391 implement const iterator using `rustc_do_not_const_check` REVERT: 915a9e8473f std: add type alias for raw OS errors REVERT: 2d0240e67d9 Fix `vec_deque::Drain` FIXME REVERT: 9c2e5f74828 Rollup merge of #107494 - lebensterben:patch-1, r=JohnTitor REVERT: da66b27c8a5 Rollup merge of #107445 - Swatinem:rm-genfuture, r=cuviper REVERT: 0d07f33821f fix link in std::path::Path::display() REVERT: a8591590d0a Improved wording of error messages of missing remainder implementations REVERT: 8abff9b7fab Merge from rustc REVERT: 8a2168b09a2 stage-step cfgs REVERT: 5184a66f45e Rollup merge of #107424 - bpeel:clone-into-from-share-code, r=scottmcm REVERT: deb5c38a0a6 Auto merge of #107080 - Urgau:cleanup-bootstrap-extra-check-cfgs, r=Mark-Simulacrum REVERT: 6ea63a0e10f Add `str::Lines::remainder` REVERT: a2247d8cb2d Rollup merge of #107459 - tshepang:cosistency, r=WaffleLapkin REVERT: 1a3a094d012 Rollup merge of #107452 - y21:get-mut-unchecked-typo, r=Mark-Simulacrum REVERT: 7d240844cda Rollup merge of #101569 - m-ou-se:alloc-no-rexport-argumentv1, r=thomcc REVERT: 8658c3481f6 end entry paragraph with a period (.) REVERT: 22d6df99e8f Don't re-export private/unstable ArgumentV1 from `alloc`. REVERT: ae71b43a72f fix typo in {Rc, Arc}::get_mut_unchecked docs REVERT: f162de9918e Rollup merge of #107431 - notriddle:notriddle/colon, r=thomcc REVERT: 93727dc61d3 Rollup merge of #106798 - scottmcm:signum-via-cmp, r=Mark-Simulacrum REVERT: 48819e07265 Rollup merge of #106769 - lenko-d:libtest-print_why_a_test_was_ignored_if_its_the_only_test_specified, r=Mark-Simulacrum REVERT: 59536f7bca7 Remove `GenFuture` from core REVERT: a8cfd21a74a Auto merge of #106253 - nbdd0121:upcast, r=compiler-errors REVERT: cd9a7920d85 Rollup merge of #107154 - glaubitz:m68k-alloc, r=JohnTitor REVERT: fdf650b3144 Rollup merge of #106618 - jmillikin:os-net-rustdoc-wasm32, r=JohnTitor REVERT: 20f287166cd docs: remove colon from time header REVERT: 5a103a84735 vec: Use SpecCloneIntoVec::clone_into to implement Vec::clone_from REVERT: cb5200ed21c slice: Add a specialization for clone_into when T is Copy REVERT: f011b218fe7 Reintroduce multiple_supertrait_upcastable lint REVERT: e8b1c385472 Rollup merge of #107398 - scottmcm:its-their-funeral, r=dtolnay REVERT: 0ce09e77e97 Rollup merge of #105524 - Ayush1325:libc-free, r=ChrisDenton REVERT: 297752db835 Rollup merge of #104252 - faern:stabilize-const_socketaddr, r=JohnTitor REVERT: 82a1b03f479 Replace libc::{type} with crate::ffi::{type} REVERT: 915e2739c47 Rollup merge of #107022 - scottmcm:ordering-option-eq, r=m-ou-se REVERT: 3100ddbf671 Remove `ControlFlow::{BREAK, CONTINUE}` REVERT: ea3bded0fb7 Link to the LLVM issue from a comment on `SpecOptionPartialEq` REVERT: 8605f71e2e3 Fixed confusement between mod and remainder REVERT: f94c244eb6d std: add safety comment in `LazyLock::get` REVERT: f06ab60d54e std: fix `Debug` implementation on `LazyLock` REVERT: 679cd327abb Rollup merge of #106856 - vadorovsky:fix-atomic-annotations, r=joshtriplett REVERT: 38a97d5913b Rollup merge of #105784 - yanns:update_stdarch, r=Amanieu REVERT: 1774374ed8b Implement `AsFd` and `AsRawFd` for `Rc` REVERT: cfab500026e Auto merge of #107328 - matthiaskrgr:rollup-lfqwo0o, r=matthiaskrgr REVERT: 65a53c98630 std: optimize `LazyLock` size REVERT: bfdd79a6e71 Rollup merge of #107322 - JakobDegen:custom-mir, r=tmiasko REVERT: 5d3d055c725 Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obk REVERT: c10c629a686 Custom mir: Add support for some remaining, easy to support constructs REVERT: d60ce62ddd3 fix alphabetical sort REVERT: 4f392be42c1 remove avx512 prefix for gfni, vaes and vpclmulqdq REVERT: 60bfe329cd0 Auto merge of #107318 - matthiaskrgr:rollup-776kd81, r=matthiaskrgr REVERT: ab13660277b Rollup merge of #106946 - dtolnay:hashlinecolumn, r=m-ou-se REVERT: 4e621282f31 Rollup merge of #106836 - ibraheemdev:sync-sender-spin, r=Amanieu REVERT: 7b1a347e2b9 Rollup merge of #106779 - RReverser:patch-2, r=Mark-Simulacrum REVERT: b01d991ab8b Rollup merge of #97373 - dimpolo:cell_dispatch_from_dyn, r=dtolnay REVERT: 7267216b3de Rollup merge of #106407 - mejrs:attr_check, r=compiler-errors REVERT: 5ff3b294393 Stabilize the const_socketaddr feature REVERT: 34618b5a86b Rollup merge of #106944 - Nilstrieb:there-once-was-a-diagnostic, r=WaffleLapkin REVERT: 61be4c0f357 Set version placeholders to 1.68 REVERT: ab56c601732 Remove outdated cfg on `le32` REVERT: afebb11cd8f Rollup merge of #107223 - ChayimFriedman2:patch-5, r=WaffleLapkin REVERT: bcea9893381 Rollup merge of #106823 - m-ou-se:format-args-as-str-guarantees, r=dtolnay REVERT: a52c41a61b1 Rollup merge of #106767 - chbaker0:disable-unstable-features, r=Mark-Simulacrum REVERT: dc91f204636 core: Support variety of atomic widths in width-agnostic functions REVERT: ebea57d095e Guarantee the memory layout of `Cell` REVERT: a04b5a32d20 impl DispatchFromDyn for Cell and UnsafeCell REVERT: 3fa93b1d438 io: soften ‘at most one write attempt’ requirement in io::Write::write REVERT: 2033f90ad7f `sub_ptr()` is equivalent to `usize::try_from().unwrap_unchecked()`, not `usize::from().unwrap_unchecked()`. REVERT: 322371116de Rollup merge of #107109 - est31:thin_box_link, r=Mark-Simulacrum REVERT: 488d048fcbc Merge from rustc REVERT: 8ccb0bc34bc Document missing unsafe blocks REVERT: ad9f646adf7 Rollup merge of #106854 - steffahn:drop_linear_arc_rebased, r=Mark-Simulacrum REVERT: d6c29124bfd Merge from rustc REVERT: 24282ce5514 Auto merge of #106981 - joboet:std_remove_box_syntax, r=thomcc REVERT: 22be508c8eb Print why a test was ignored if it's the only test specified. REVERT: ded16d9c4da simplify layout calculations in rawvec REVERT: 6ebf7150441 Flip scanning direction of stable sort REVERT: 05bffbbb07a Unify insertion sort implementations REVERT: ffabd00c441 Rollup merge of #107180 - nvzqz:rm-fmt-ref, r=joshtriplett REVERT: 6b853e11f0e Rollup merge of #107114 - Erk-:add-absolute-note-to-path-join, r=m-ou-se REVERT: bbc2d42f43a Rollup merge of #106144 - tgross35:patch-1, r=Mark-Simulacrum REVERT: cf64c482b5c Remove unnecessary `&format!` REVERT: f3bcca9be51 debug assertions for `slice::split_at_unchecked`, `str::get_unchecked` REVERT: f81399dbfd8 Add Arc::into_inner for safely discarding Arcs without calling the destructor on the inner type. REVERT: 239997f5e98 library/std/sys_common: Define MIN_ALIGN for m68k-unknown-linux-gnu REVERT: a406857a00f Use NonNull in merge_sort REVERT: 3c7fd952b13 Rollup merge of #104672 - Voultapher:unify-sort-modules, r=thomcc REVERT: 06a907218c3 add example of joining with a absolute path REVERT: 7a565da04e9 Add note about absolute paths to Path::join REVERT: 1b88ed90728 ThinBox: Add intra-doc-links for Metadata REVERT: 705bab93f61 Rollup merge of #107067 - tmiasko:custom-mir-storage-statements, r=oli-obk REVERT: 63584173a8e Rollup merge of #107053 - devnexen:sigstringrepr_haiku, r=thomcc REVERT: f368d7c486f Add `rustc_on_unimplemented` on `Sync` for cell types REVERT: e6512dc0b69 Add `OnceCell: !Sync` impl for diagnostics REVERT: 1f08f668c4d Auto merge of #107064 - GuillaumeGomez:rollup-pbgu6r3, r=GuillaumeGomez REVERT: 0e46852cdd2 Custom MIR: Support storage statements REVERT: 75107778164 Auto merge of #106989 - clubby789:is-zero-num, r=scottmcm REVERT: 7bda637e26f Transform async ResumeTy in generator transform REVERT: b132b9f29df Implement `SpecOptionPartialEq` for `cmp::Ordering` REVERT: 578d08fb88b signal update string representation for haiku. REVERT: b4bc54a3caf Update `IsZero` documentation REVERT: 1b86ff4ae9f Implement `alloc::vec::IsZero` for `Option<$NUM>` types REVERT: 613d5d18657 Rollup merge of #106950 - the8472:fix-splice-miri, r=cuviper REVERT: b0079676e31 Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett REVERT: 3883b80349b Rollup merge of #103702 - WaffleLapkin:lift-sized-bounds-from-pointer-methods-where-applicable, r=m-ou-se REVERT: 1f0e93b3eff Rollup merge of #106997 - Sp00ph:introselect, r=scottmcm REVERT: a57e241a1ac Rollup merge of #106992 - joboet:alloc_remove_box_syntax, r=thomcc REVERT: 962eb39961b Add `vec_deque::IntoIter` benchmarks REVERT: aa18251434d Don't do pointer arithmetic on pointers to deallocated memory REVERT: 17e44cb8ff8 Rollup merge of #106889 - scottmcm:windows-mut, r=cuviper REVERT: 567348b61f8 Add heapsort fallback in `select_nth_unstable` REVERT: 17b416672be refactor[alloc]: remove unused box syntax feature REVERT: e73286d56eb Rollup merge of #106922 - ChayimFriedman2:patch-5, r=workingjubilee REVERT: fafc8d08f85 Rollup merge of #106148 - chenyukang:yukang/fix-105061-unused, r=lcnr REVERT: 5eec3f4dc8c refactor[std]: do not use box syntax REVERT: b8d3c85a0ca Explain the "no-error" io::Error case REVERT: 06f01580094 Constify `TypeId` ordering impls REVERT: 7ddcdd9508e implement Hash for proc_macro::LineColumn REVERT: 7c219da2111 Implement DoubleEnded and ExactSize for Take and Take REVERT: 59570ef0bb3 Avoid unsafe code in `to_ascii_[lower/upper]case()` REVERT: fbc18e4b4f8 Rebuild BinaryHeap on unwind from retain REVERT: b70440c2ade Add test showing broken behavior of BinaryHeap::retain REVERT: 422fe1899bd Auto merge of #106393 - the8472:use-ptr-sub, r=scottmcm REVERT: 05e0ad66934 replace manual ptr arithmetic with ptr_sub REVERT: 0342b3b4868 Auto merge of #105851 - dtolnay:peekmutleak, r=Mark-Simulacrum REVERT: d66713dd7ac Rollup merge of #106880 - tspiteri:borrowing-sub-typo, r=cuviper REVERT: bf3aa107d64 Rollup merge of #106867 - sunfishcode:sunfishcode/std-os-fd-stable-version, r=m-ou-se REVERT: d061ac92947 Mention the lack of `windows_mut` in `windows` REVERT: b92749577f0 Document guarantees about BinaryHeap invariant REVERT: e7992035bfa Leak amplification for peek_mut() to ensure BinaryHeap's invariant is always met REVERT: 6147e2f43ff Add test of leaking a binary_heap PeekMut REVERT: 84cb8ccb209 doc: fix typo REVERT: c360ede4011 Fix the stability attributes for `std::os::fd`. REVERT: 626ad28184c Rollup merge of #106860 - anden3:doc-double-spaces, r=Dylan-DPC REVERT: 3e94f9444f2 Rollup merge of #106661 - mjguzik:linux_statx, r=Mark-Simulacrum REVERT: 40b83b9899b Rollup merge of #105526 - Xiretza:iter-from-generator-derive, r=scottmcm REVERT: 2516173285f Fix some missed double spaces. REVERT: 3589c949464 Remove various double spaces in source comments. REVERT: c98fa9b9da7 Re-add #[allow(unused)] attr REVERT: be98dbe66bc Use associated items of `char` instead of freestanding items in `core::char` REVERT: e038c3f19e1 fix issues in unused lint REVERT: 6de2662a966 remove optimistic spinning from `mpsc::SyncSender` REVERT: c423b6de573 Rollup merge of #106799 - scottmcm:remove-unused-generics, r=cuviper REVERT: 18c22e997c0 Rollup merge of #106762 - WaffleLapkin:atomicptr+as_mut_ptr, r=m-ou-se REVERT: 6280faf58d5 Rollup merge of #106692 - eggyal:mv-binary_heap.rs-binary_heap/mod.rs, r=Mark-Simulacrum REVERT: 87ebf8873a3 Rollup merge of #105172 - alexs-sh:issue-98861-fix-next, r=scottmcm REVERT: 2a6b3616d51 Rollup merge of #104965 - zacklukem:p-option-as_ref-docs, r=scottmcm REVERT: 15da903bda5 Allow fmt::Arguments::as_str() to return more Some(_). REVERT: 4dc94900958 Rollup merge of #106701 - ibraheemdev:sync-sender-spin, r=Amanieu REVERT: 82ef76628ae Stop having unused lifetimes on some `impl`s REVERT: 05aa5404516 Implement `signum` with `Ord` REVERT: b31e8de3305 Auto merge of #106004 - fee1-dead-contrib:const-closures, r=oli-obk REVERT: 8eaeff9fa08 Rollup merge of #106740 - petar-dambovaliev:float-iterator-hint, r=Nilstrieb REVERT: ed8b3b9db14 Rollup merge of #106446 - bzEq:fix-unwind-lsda, r=Amanieu REVERT: c0af508443b Avoid __cxa_thread_atexit_impl on Emscripten REVERT: 12c94c9d133 add note for float iterator REVERT: 3a11261d0af Auto merge of #106760 - compiler-errors:rollup-0bogyco, r=compiler-errors REVERT: c86f71ff1bc Allow setting CFG_DISABLE_UNSTABLE_FEATURES to 0 REVERT: d8e9bca91ee Make `// SAFETY` comment part of the doctest, and not surrounding code REVERT: af5b504ebce Remove unused `mut` from a doctest REVERT: 57608a8919f Add `AtomicPtr::as_mut_ptr` REVERT: f3c70c94fb0 Rollup merge of #106323 - starkat99:stabilize-f16c_target_feature, r=petrochenkov REVERT: 8ac30015ded Rollup merge of #103800 - danielhenrymantilla:stabilize-pin-macro, r=dtolnay REVERT: 46bbaf857b6 Rollup merge of #103236 - tspiteri:redoc-int-adc-sbb, r=m-ou-se REVERT: d8d8745124c Rollup merge of #106638 - RalfJung:realstd, r=thomcc REVERT: 5933e8a9736 rework and document backoff behavior of `sync::mpsc` REVERT: 91ef5c85fbf test use in libcore REVERT: 0b9a8bad906 Make core::fmt::rt::v1::Argument::new const+inline. REVERT: 70f2dec9828 Improve proc macro attribute diagnostics REVERT: d67cc199815 Stabilize `::{core,std}::pin::pin!` REVERT: 14b8c9653da Add new fn to core::fmt::rt::v1::Argument. REVERT: e0988eb9550 Turn format arguments types into lang items. REVERT: 972b9e79e12 Stop probing for statx unless necessary REVERT: 0251d8b3a38 Rollup merge of #106664 - chenyukang:yukang/fix-106597-remove-lseek, r=cuviper REVERT: 68590a2a73b Rollup merge of #106570 - Xaeroxe:div-duration-tests, r=JohnTitor REVERT: 43c5f3976fd Change `src/test` to `tests` in source files, fix tidy and tests REVERT: 4a4ece4b641 Rollup merge of #106662 - Ezrashaw:specialize-bool-tostring, r=cuviper REVERT: 092669b71f9 Rollup merge of #106635 - RalfJung:std-test-nits, r=thomcc REVERT: aebf6981d58 add `SyncSender::send_timeout` test REVERT: 0d363ad42a4 fix `SyncSender` spinning behavior REVERT: 61958187eae mv binary_heap.rs binary_heap/mod.rs REVERT: 47a746cb851 use with_capacity in read read_to_string REVERT: fa9db07374a impl: specialize impl of `ToString` on `bool` REVERT: 60b34cc2b9b Rollup merge of #105034 - HintringerFabian:improve_iterator_flatten_doc, r=cuviper REVERT: 5a005f44610 std tests: use __OsLocalKeyInner from realstd REVERT: 938323dd4df Add comment REVERT: 120b8794dd5 Move to intepret_cs_action REVERT: 768623ddb7e Add comments REVERT: b43c8cc270c std test: better type name, clarifying comment REVERT: e80d7ece362 Also check ttype_index when using SJLJ REVERT: 44afe76ba9d Remove unstable feature REVERT: 9e8f4b4f21a Stabilize `nonzero_min_max` REVERT: 8c89f766c64 Relocate changes REVERT: d0c1f9a500e Disable `linux_ext` in wasm32 and fortanix rustdoc builds. REVERT: 5ce31e8b580 Rollup merge of #106584 - kpreid:vec-allocator, r=JohnTitor REVERT: 25df1826a77 Rollup merge of #104163 - H4x5:once-repeat-with-debug, r=dtolnay REVERT: 965cea5fb2c Auto merge of #90291 - geeklint:loosen_weak_debug_bound, r=dtolnay REVERT: c40e4c185b9 Change memory ordering in System wrapper example REVERT: 8fab40cc08d Rollup merge of #106562 - clubby789:vec-deque-example, r=Mark-Simulacrum REVERT: c855233e1eb Rollup merge of #103104 - SUPERCILEX:sep-ref, r=dtolnay REVERT: 22e68833746 Auto merge of #104658 - thomcc:rand-update-and-usable-no_std, r=Mark-Simulacrum REVERT: 23827693d09 Document that `Vec::from_raw_parts[_in]` must be given a pointer from the correct allocator. REVERT: f00c51e2be7 Remove unnecessary lseek syscall when using std::fs::read REVERT: bd922529db5 Improve the documentation of `black_box` REVERT: b0550088c29 Rollup merge of #106564 - Folyd:feat-repeatn, r=scottmcm REVERT: bba18ce1df6 Rollup merge of #106553 - Ezrashaw:fix-hashset-doctest, r=JohnTitor REVERT: 5c811aff2a3 Rollup merge of #105128 - Sp00ph:vec_vec_deque_conversion, r=dtolnay REVERT: d8dea262869 Rollup merge of #104081 - joshlf:patch-6, r=dtolnay REVERT: b05f79cba7b Don't derive Debug for `OnceWith` & `RepeatWith` REVERT: b94245edc5a add tests for div_duration_* functions REVERT: e3cac7886f8 Change to immutable borrow when cloning element of RepeatN REVERT: c8f6e22c162 Clarify examples for `VecDeque::get/get_mut` REVERT: dd27db649fc docs: make `HashSet::retain` doctest more clear REVERT: 41b3398d9d3 Rollup merge of #106453 - coastalwhite:master, r=GuillaumeGomez REVERT: 7aaa8b8395b Remove HTML tags around warning REVERT: 23a5fcd4086 Better phrasing for hygiene of include macro REVERT: f0685e313fd Update rand in the stdlib tests, and remove the getrandom feature from it REVERT: 3e8bb832529 Rollup merge of #106461 - notriddle:notriddle/window-searchstate-focus, r=GuillaumeGomez REVERT: 9283f5a35a8 Rollup merge of #106398 - jyn514:fix-clippy, r=thomcc REVERT: 357c412a206 docs: fix broken link "search bar" REVERT: 095f27833f3 Link to Option/Result for `Iterator::sum/product` REVERT: 2b438ff886b Tidy up whitespace REVERT: cc2099b7431 Improve include macro documentation REVERT: 67b1b4c4327 Auto merge of #106239 - LegionMammal978:thin-box-drop-guard, r=Amanieu REVERT: 6aba02124bc [LSDA] Take ttype_index into account when taking action REVERT: 34eb866d18f Rollup merge of #106327 - gimbles:dbg, r=jyn514 REVERT: 81a1964ab75 Rollup merge of #106200 - compiler-errors:suggest-impl-trait, r=estebank REVERT: 149de5db2fd relax reference requirement on from_abstract_name REVERT: 721562cb0f9 Rollup merge of #106045 - RalfJung:oom-nounwind-panic, r=Amanieu REVERT: 741a40f67b7 Suggest more impl Trait on `-> _` REVERT: 0b8bcc5f653 Make ExitStatus an inhabited type on all platforms REVERT: 5aaac25ced0 Fix a few clippy lints in libtest REVERT: cd24dbeaae3 Added error documentation for write_fmt REVERT: abed96b064f Auto merge of #95644 - WaffleLapkin:str_split_as_str_refactor_take2, r=Amanieu REVERT: 998f33ecc3d Rollup merge of #104298 - tbu-:pr_set_extension_caveats, r=m-ou-se REVERT: 98bf497d309 Remove test of static Context REVERT: 130e1920aa9 Add PhantomData marker to Context to make Context !Send and !Sync REVERT: 725ff88008c default OOM handler: use non-unwinding panic (unless -Zoom=panic is set), to match std handler REVERT: 4193bd76143 improve wording of `thread::park` docs REVERT: 57c0de1441e Deallocate ThinBox even if the value unwinds on drop REVERT: 160a5d873d7 Document a way to limit read_line length REVERT: 41aa221bc2d Document read_line gotcha REVERT: fb29c114842 Rollup merge of #106280 - Ezrashaw:path-join-docs-better, r=thomcc REVERT: 75294c6dea3 Auto merge of #106275 - Nilstrieb:const-eval-select-me-some-compile-time, r=thomcc REVERT: a58ce151ed6 Add tidy check for dbg REVERT: ac746aa2af2 std: use id-based thread parking on SOLID REVERT: 8c66c30e95a Rollup merge of #106248 - dtolnay:revertupcastlint, r=jackh726 REVERT: a90946346c7 Rollup merge of #105903 - joboet:unify_parking, r=m-ou-se REVERT: 7bfe9d73bc8 Stabilize f16c_target_feature REVERT: d39abba987c Add notes and examples about non-intuitive `PathBuf::set_extension` behavior REVERT: ce50cc21047 Auto merge of #105651 - tgross35:once-cell-inline, r=m-ou-se REVERT: c86297fd654 Auto merge of #106296 - matthiaskrgr:rollup-ukdbqwx, r=matthiaskrgr REVERT: 59de9f45aaa Rollup merge of #104182 - gabhijit:ipv6-in6addr-any-doc-fix, r=m-ou-se REVERT: 9987eb4f6f3 Rollup merge of #103707 - jonathanCogan:master, r=m-ou-se REVERT: 5d45fe6edb0 Rollup merge of #99244 - gthb:doc-improve-iterator-scan, r=m-ou-se REVERT: f6bddeaeb84 Use some more `const_eval_select` in pointer methods for compile times REVERT: 312f3e4952d std: remove unnecessary `#[cfg]` on NetBSD REVERT: e8528f88a70 std: rename `Parker::new` to `Parker::new_in_place`, add safe `Parker::new` constructor for SGX REVERT: 8005c7e24c3 Update paths in comments. REVERT: f0852162282 Replace libstd, libcore, liballoc in line comments. REVERT: 12a5174acaa Replace libstd, libcore, liballoc in docs. REVERT: bdae3c8e3f5 Auto merge of #105426 - flba-eb:fix_tls_destructor_unwinding, r=m-ou-se REVERT: faac262c9a1 docs: add link to `Path::join` in `PathBuf::push` REVERT: 3c92f2522f2 Auto merge of #106210 - fee1-dead-contrib:const-closure-trait-method, r=compiler-errors REVERT: ddbb87f8d89 std: pass hint to id-based parking functions REVERT: dd73e9da98e std: unify id-based thread parking implementations REVERT: 72c128dd993 update stdarch REVERT: b3af1514e20 Revert "Implement allow-by-default multiple_supertrait_upcastable lint" REVERT: b36e02e1587 Auto merge of #105590 - solid-rs:patch/kmc-solid/thread-lifecycle-ordering, r=m-ou-se REVERT: 48959bfa636 Implement more methods for `vec_deque::IntoIter` REVERT: cd856f557d5 Auto merge of #105741 - pietroalbini:pa-1.68-nightly, r=Mark-Simulacrum REVERT: 8372641aafc Rollup merge of #106161 - meithecatte:iter-find-position, r=Mark-Simulacrum REVERT: 8ccbe8642ce Rollup merge of #105998 - RalfJung:no-unwind-panic-msg, r=thomcc REVERT: a6d3983339b Rollup merge of #105497 - albertlarsan68:doc-panic-hook-and-catch-unwind, r=m-ou-se REVERT: 54c0c12af39 Rollup merge of #105359 - flba-eb:thread_local_key_sentinel_value, r=m-ou-se REVERT: 4d80bf1cbfa Rollup merge of #104493 - adamncasey:cgroupzeroperiod, r=m-ou-se REVERT: 58cafab9605 Rollup merge of #104402 - joboet:sync_remutex, r=m-ou-se REVERT: bbd77cf4edf Catch panics in destruction of TLS values REVERT: 2fae000315d Clarify catch_unwind docs about panic hooks REVERT: fe9cf53afdd fix custom mir doc tests REVERT: e65be496a23 fix documenting private items of standard library REVERT: 6e0fe797894 delete more `cfg(bootstrap)` REVERT: 105c50e6459 Update bootstrap cfg REVERT: 1e7e5d6d41d update stabilization version numbers REVERT: 84b8ef32dce Rollup merge of #106172 - estebank:suggest-impl-trait, r=compiler-errors REVERT: 2d174ece344 Auto merge of #106209 - fee1-dead-contrib:rollup-47ysdcu, r=fee1-dead REVERT: f1085e9cc1c adjust message on non-unwinding panic REVERT: 2549b600797 Allow trait method paths to satisfy const Fn bounds REVERT: a8c8a0235e1 Rollup merge of #106184 - albertlarsan68:docs-106154, r=Nilstrieb REVERT: f3d95846a92 Rollup merge of #105484 - nbdd0121:upcast, r=compiler-errors REVERT: 5b7612a7671 Rollup merge of #104708 - jonasspinner:fix-backoff-doc-to-match-implementation, r=compiler-errors REVERT: d098f90ad44 Rollup merge of #104024 - noeddl:unused-must-use, r=compiler-errors REVERT: 64c229c06e3 Rollup merge of #103945 - H4x5:remove-iter-empty-hack, r=compiler-errors REVERT: 60e3e7b6971 Rollup merge of #94145 - ssomers:binary_heap_tests, r=jyn514 REVERT: c0382472dbc Auto merge of #103881 - ChayimFriedman2:patch-2, r=compiler-errors REVERT: fb1993d7e35 Auto merge of #100539 - joboet:horizon_timeout_clock, r=thomcc REVERT: 203ea0d335b Auto merge of #106193 - compiler-errors:rollup-0l54wka, r=compiler-errors REVERT: 41c601ea0a0 Fix `core::any` mod-level docs REVERT: 4912e11d438 Rollup merge of #106189 - alexhrao:master, r=Nilstrieb REVERT: 54b60bc75a4 Rollup merge of #106187 - ChayimFriedman2:patch-4, r=compiler-errors REVERT: 7e929bb00ca Rollup merge of #106179 - RetroSeven:typo_fix, r=compiler-errors REVERT: c1dc91e6c05 Rollup merge of #103718 - matklad:infer-lazy, r=dtolnay REVERT: 362b26965d9 Fix UnsafeCell Documentation Spelling Error REVERT: 4e6710c1b4d Auto merge of #97176 - kraktus:cmd_debug, r=the8472 REVERT: a4441c1affd Update the documentation of `Vec` to use `extend(array)` instead of `extend(array.iter().copied())` REVERT: 6170536e8b7 Fix a formatting error REVERT: 79d1e1a18a3 More verbose `Debug` implementation of `std::process:Command` REVERT: b27b37ae229 Suggest `impl Iterator` when possible for `_` return type REVERT: ba58800ba2e Iterator::find: link to Iterator::position in docs for discoverability REVERT: 234990c045a Auto merge of #105997 - RalfJung:immediate-abort, r=eholk REVERT: 88b6c873b1d Auto merge of #106112 - RalfJung:into-iter, r=thomcc REVERT: 339f9cdc8cd Auto merge of #104977 - RalfJung:ptr-from-ref, r=dtolnay REVERT: 4810b09fd88 Auto merge of #106111 - matthiaskrgr:rollup-nnpoe5h, r=matthiaskrgr REVERT: f4d7cd6c280 add tracking issue, fix typo REVERT: 4170f3b4b3f add lib tests for vec::IntoIter alignment issues REVERT: d0e8030ff44 Rollup merge of #106032 - mcha-forks:lfs-musl-fix, r=thomcc REVERT: 00ecf16f326 Auto merge of #106081 - mina86:c, r=Mark-Simulacrum REVERT: 5eeb6c44e0f fix one more unaligned self.ptr, and add tests REVERT: fd8bd1c319a fix IntoIter::drop on high-alignment ZST REVERT: 5fcf84ee438 char: µoptimise UTF-16 surrogates decoding REVERT: e855d0afd04 Stop at the first `NULL` argument when iterating `argv` REVERT: 6644b43c562 abort immediately on bad mem::zeroed/uninit REVERT: acf3142111d std: only use LFS function on glibc REVERT: d4db1c7eea2 Auto merge of #106025 - matthiaskrgr:rollup-vz5rqah, r=matthiaskrgr REVERT: 76e738f2745 Auto merge of #106023 - JohnTitor:rollup-k8mettz, r=JohnTitor REVERT: c4b544632de Rollup merge of #106012 - JakobDegen:retag-raw, r=RalfJung REVERT: 3b857562798 Rollup merge of #105960 - oli-obk:effect_cleanup, r=fee1-dead REVERT: ae15900d8a9 Rollup merge of #105980 - goffrie:waker-drop, r=thomcc REVERT: d137be3dacd Rollup merge of #105824 - zacchiro:patch-1, r=JohnTitor REVERT: 38af5414022 Rollup merge of #105584 - raffimolero:patch-1, r=JohnTitor REVERT: 2099db27769 Auto merge of #105613 - Nilstrieb:rename-assert_uninit_valid, r=RalfJung REVERT: 382d49f7306 Clarify that raw retags are not permitted in Mir REVERT: 2b23e1b49b2 Auto merge of #100390 - jhpratt:float-from-bool, r=dtolnay REVERT: 8401b0c8cc9 less specific wording REVERT: de2c4d61908 Refer to "Waker" rather than "RawWaker" in `drop` comment REVERT: 7accfae79fc Auto merge of #105127 - Sp00ph:const_new, r=dtolnay REVERT: e0117fe3f76 Auto merge of #105381 - uweigand:s390x-ffi-vaarg, r=nikic REVERT: 7c74888e09f Stabilize path_as_mut_os_str REVERT: edab1230088 Fix some `~const` usage in libcore REVERT: 2d171bc4db8 Update coerce_unsized tracking issue from #27732 to #18598 REVERT: b3d2d98b6e5 Implement va_list and va_arg for s390x FFI REVERT: ad8ebb51491 Rollup merge of #105915 - andrewpollack:revert-105250-async-rm-resumety, r=tmandry REVERT: aea7b6a8aee Rollup merge of #105902 - vincenzopalazzo:macros/pin_docs, r=eholk REVERT: eee16ea3f90 Rollup merge of #105801 - zertosh:path_mut_os_str_doc_test, r=dtolnay REVERT: 597f0a201c3 Revert "Replace usage of `ResumeTy` in async lowering with `Context`" REVERT: 7844df0de6c Auto merge of #105698 - joboet:unsupported_threads_once, r=thomcc REVERT: 3e81ff800e9 docs: improve pin docs REVERT: c70f61949b9 Rollup merge of #105889 - Nilstrieb:fmt-libtest, r=thomcc REVERT: 2b7d70399a9 Rollup merge of #105682 - thomcc:expose-ptr-fmt, r=RalfJung REVERT: e514837fc9d Fix `uninlined_format_args` in libtest REVERT: 3079f87630f Rollup merge of #105858 - scottmcm:extra-as-chunks-example, r=the8472 REVERT: 50f0416ed1f Auto merge of #105638 - tavianator:fix-50619-again, r=Mark-Simulacrum REVERT: 90dc74a1da6 Another `as_chunks` example REVERT: a235f499083 Rollup merge of #105836 - evanj:fmt-doc-use-variables, r=Mark-Simulacrum REVERT: 561646010e3 Rollup merge of #105814 - JakobDegen:custom-mir-terms, r=oli-obk REVERT: e21e455e68e Rollup merge of #105458 - Ayush1325:blocking_spawn, r=Mark-Simulacrum REVERT: 9b52c660a3d std::fmt: Use args directly in example code REVERT: be35a651424 str.lines() docstring: clarify that line endings are not returned REVERT: af0d409c587 Auto merge of #105794 - ChrisDenton:internal-doc, r=jyn514 REVERT: e515526049b Support call and drop terminators in custom mir REVERT: 1a8373acc08 Realistic `Path::as_mut_os_str` doctest REVERT: 89b35e25923 Fix intra-doc link REVERT: 7a0182d93da Auto merge of #105018 - zertosh:path_buf_deref_mut, r=dtolnay REVERT: 8cc86932201 Replace `Split*::as_str` with `remainder` REVERT: 1ecf48024db Rollup merge of #105748 - hakoerber:master, r=Dylan-DPC REVERT: 60916b29872 SplitInternal: always set `finished` in `get_end` REVERT: 08a798246a1 Auto merge of #105356 - JakobDegen:more-custom-mir, r=oli-obk REVERT: 8779b642a27 doc: Fix a few small issues REVERT: b6fe7b55a06 Implement `From` for f32, f64 REVERT: ab055aabeda Rollup merge of #105598 - RalfJung:more-comments, r=the8472 REVERT: 82b58879f57 Rollup merge of #105399 - mikebenfield:lfs, r=thomcc REVERT: 6d67530c41e fs/tests: Fail fast on duplicate errors rather than looping indefinitely REVERT: 5e38c333d15 fs/tests: Explicitly kill the zombie rather than sleeping until it dies REVERT: d10dc9ca1cf std: use a more efficient `Once` on platforms without threads REVERT: 8d5998f9753 Auto merge of #105690 - matthiaskrgr:rollup-khtq97k, r=matthiaskrgr REVERT: ce8ae7d2120 Rollup merge of #105642 - uberFoo:master, r=Dylan-DPC REVERT: fb055264c9b Rollup merge of #105523 - estebank:suggest-collect-vec, r=compiler-errors REVERT: 62bde9bc03b Address documentation suggestions REVERT: dc442ddede7 Add documentation for custom mir REVERT: 5499f4aada2 Support more projections in custom mir REVERT: 8293014ec05 Support common enum operations in custom mir REVERT: b24029fe155 Use `expose_addr()` in `fmt::Pointer` REVERT: 844982c4cc6 Improve wording for Option and Result REVERT: 0784b7223d5 Add docs for question mark operator for Option REVERT: 02babb96740 Suggest `collect`ing into `Vec<_>` REVERT: 75ce421ff2b Rename `assert_uninit_valid` intrinsic REVERT: bceef98dbe2 Add result example + rewording REVERT: 4777b439217 Add #[inline] marker to OnceCell/LazyCell/OnceLock/LazyLock REVERT: 9a1e15d7152 Minor grammar nit. REVERT: 1eab125ea0a fs: Fix #50619 (again) and add a regression test REVERT: 79c32e9daf3 explain mem::forget(env_lock) in fork/exec REVERT: 99fa2e30f8a Rollup merge of #105616 - est31:add_the, r=Dylan-DPC REVERT: aae6c89292a Add a "the" to proc_macro documentation REVERT: 7a57c5abd88 Correct typos in `core::sync::Exclusive::get_{pin_mut, mut}` REVERT: 7163dd479b2 kmc-solid: Synchronize with the read when sending a joining task ID to a joinee REVERT: 3ac1c921334 kmc-solid: Synchronize the first update of `ThreadInner::lifecycle` with the second one on detach REVERT: 2bd579b9d64 add assert messages if chunks/windows are length 0 REVERT: 1223cea8c29 Rollup merge of #101648 - Timmmm:home_dir_docs, r=joshtriplett REVERT: 95031dfcb9c Auto merge of #105508 - eduardosm:ptr-methods-inline-always, r=Mark-Simulacrum REVERT: f41c30afa2d Remove some `cfg(not(bootstrap))` REVERT: 872a94c25f4 Use rint instead of roundeven REVERT: a79e6317c44 Add tracking issue REVERT: c28c27b7e41 Add `round_ties_even` to `f32` and `f64` REVERT: 1ec160c766e Implement blocking output REVERT: 295623693b0 Rollup merge of #105460 - mkroening:compiler-builtins-0.1.85, r=Mark-Simulacrum REVERT: 7439ff3d2e0 Rollup merge of #103146 - joboet:cleanup_pthread_condvar, r=Mark-Simulacrum REVERT: 8c543994f8a Rollup merge of #105239 - gh2o:no-heap-alloc-on-thread-start, r=cuviper REVERT: 9d0803e977f libcore: make result of iter::from_generator Clone REVERT: 55310b9f1d5 libcore: make result type of iter::from_generator concrete REVERT: 297aa2c098e Rollup merge of #105522 - est31:remove_or_and_note, r=scottmcm REVERT: 099cec4c645 Rollup merge of #104901 - krtab:filetype_compare, r=the8472 REVERT: a41cd267eea Rollup merge of #98391 - joboet:sgx_parker, r=m-ou-se REVERT: b35a34d8d88 Correct wrong note for short circuiting operators REVERT: 1f9a410c8d4 Rollup merge of #105453 - scottmcm:vecdeque_from_iter, r=the8472 REVERT: 6102f392404 Rollup merge of #105265 - aDotInTheVoid:sum-product-on-unimplemented, r=estebank REVERT: 81b79c86665 Make `<*{const,mut} T>::{,wrapping_}sub` methods `#[inline(always)]` REVERT: e6b65d50a17 Auto merge of #105262 - eduardosm:more-inline-always, r=thomcc REVERT: 5e9dadd7158 Replace hand-made masking by call to masked() method in FileType REVERT: 26a3e7600a7 Rollup merge of #105474 - RalfJung:typo, r=dtolnay REVERT: 3e105eb4d68 Rollup merge of #105245 - RalfJung:align_to, r=Amanieu REVERT: a571a5c7554 Apply review feedback; Fix no_global_oom_handling build REVERT: 1619cba3585 Implement allow-by-default multiple_supertrait_upcastable lint REVERT: 351b0026c75 Add `rustc_on_unimplemented` to `Sum` and `Product` trait. REVERT: a7d30fc705e lib docs: fix typo REVERT: bfe125328ae Bump compiler-builtins to 0.1.85 REVERT: 025c3d4abad Add read_to_end for AnonPipe REVERT: 90f7fcb3c9a Rollup merge of #105434 - nbdd0121:lib, r=thomcc REVERT: cf26637e713 Rollup merge of #105120 - solid-rs:patch/kmc-solid/maintainance, r=thomcc REVERT: 64b1a1e49f0 Make `VecDeque::from_iter` O(1) from `vec(_deque)::IntoIter` REVERT: 35eb13f2183 Fix warning when libcore is compiled with no_fp_fmt_parse REVERT: c2e90418e80 Avoid heap allocation when truncating thread names REVERT: 9186f1d68bc Use more LFS functions. REVERT: f9d34692a37 Make some trivial functions `#[inline(always)]` REVERT: 97fec55bc77 Auto merge of #103459 - ChrisDenton:propagate-nulls, r=thomcc REVERT: 265eff2b647 Auto merge of #104799 - pcc:linkage-fn, r=tmiasko REVERT: a3252cd2bab Auto merge of #105271 - eduardosm:inline-always-int-conv, r=scottmcm REVERT: 2e081a92080 Don't set `STARTF_USESTDHANDLES` if none are set REVERT: 43ed2050e0b Rollup merge of #105250 - Swatinem:async-rm-resumety, r=oli-obk REVERT: 1c6d709212f Rollup merge of #105243 - RalfJung:no-op-let, r=Mark-Simulacrum REVERT: 8f90316b54e Implement masking in FileType hashing on Unix REVERT: 26b342b2295 Replace usage of `ResumeTy` in async lowering with `Context` REVERT: c85a5def991 Make sentinel value configurable REVERT: cf577589181 Rollup merge of #105289 - Rageking8:fix-dupe-word-typos, r=cjgillot REVERT: 0aa15cb4611 Reimplement weak! using Option. REVERT: ee04594fd34 Rollup merge of #105222 - devnexen:fbsd_update_img, r=petrochenkov REVERT: 343a2730898 Rollup merge of #104912 - RalfJung:per, r=Mark-Simulacrum REVERT: cfb1186d567 Add O(1) `Vec -> VecDeque` conversion guarantee REVERT: 3c59a7ac887 attempt to clarify align_to docs REVERT: 48757a5b5e2 Auto merge of #105046 - scottmcm:vecdeque-vs-vec, r=Mark-Simulacrum REVERT: 5955c4dec85 fix dupe word typos REVERT: bc38f6fd2a5 Make integer-to-integer `From` impls `#[inline(always)]` REVERT: f81f6059b54 remove no-op 'let _ = ' REVERT: 1ea4613a27f Auto merge of #101514 - nvzqz:nvzqz/stabilize-nonzero-bits, r=thomcc REVERT: f3c77007598 std update libc version and freebsd image build dependencies REVERT: 01f89b01bfd Rollup merge of #105153 - oli-obk:fail_faster, r=compiler-errors REVERT: 6ea17d4195f Rollup merge of #105100 - jhpratt:fix-docs, r=JohnTitor REVERT: 02b2fd4aae3 Rollup merge of #105032 - HintringerFabian:improve_docs, r=JohnTitor REVERT: 36626376d94 Auto merge of #104999 - saethlin:immediate-abort-inlining, r=thomcc REVERT: 37750d48af2 Windows: make Command prefer non-verbatim paths REVERT: fb49f4496a4 std: cleanup timeouts in pthread condvar REVERT: 2f2078891dc kmc-solid: Don't do `Box::from_raw(&*(x: Box) as *const T as *mut T)` REVERT: c0c3c125e78 Rollup merge of #105137 - yjhn:patch-1, r=Dylan-DPC REVERT: 7c06805f8ef Rollup merge of #105126 - Sp00ph:const_new_in, r=dtolnay REVERT: 95b1756b3f7 Rollup merge of #104614 - Nilstrieb:type-ascribe!, r=TaKO8Ki REVERT: 6329cb2b751 Create a hacky fail-fast mode that stops tests at the first failure REVERT: b34a2ac6808 Add tracking issue for file_create_new REVERT: ba4a4617636 Fix typo in comment REVERT: fc08eb4f910 Make `VecDeque::new` const REVERT: b55cb1a2215 Make `VecDeque::new_in` unstably const REVERT: 75de680ff7b Auto merge of #104975 - JakobDegen:custom_mir_let, r=oli-obk REVERT: 08ba592d9bb Gate macros behind `#[cfg(not(bootstrap))]` REVERT: 0c67c317401 kmc-solid: Address compiler warnings REVERT: 0da35ed3af9 kmc-solid: Add a stub implementation of `is_terminal` REVERT: 3e226e84e8c kmc-solid: Use `expose_addr` and `from_exposed_addr` for pointer-integer casts REVERT: e967372e89e Auto merge of #104160 - Ayush1325:windows-args, r=m-ou-se REVERT: 38f965e729a Add test for regression for FileType equality REVERT: 12e3af2ba2c Add missing intra-doc link REVERT: 474b03cbe6d Clarify that copied allocators must behave the same REVERT: 7e7f3895070 Rollup merge of #104811 - haraldh:feat/wasm32_wasi_shutdown, r=joshtriplett REVERT: 1712b41b90f Support statics in custom mir REVERT: e2512f70b80 Support most constant kinds in custom mir REVERT: 5ba99986846 Support arbitrary `let` statements in custom mir REVERT: 0015288068a Add in the comment that solaris lacks also the 'linkat' REVERT: 6cd8e14cb2b Rollup merge of #105049 - mkroening:hermit-fixes, r=jyn514 REVERT: f3dc9fa40f9 Rollup merge of #105002 - zertosh:acp-140, r=dtolnay REVERT: e40eb229542 Rollup merge of #104436 - ismailmaj:add-slice-to-stack-allocated-string-comment, r=Mark-Simulacrum REVERT: 7c45e4e9f0d Adjust inlining attributes around panic_immediate_abort REVERT: 6511173546e hermit: Remove unused exports REVERT: d2039815877 hermit: Fix fuzzy_provenance_casts REVERT: 927f110440a Send `VecDeque::from_iter` via `Vec::from_iter` REVERT: e42106f6f13 Add example for iterator_flatten REVERT: acf0171100b improve doc REVERT: 7e93e88449c Add `as_mut_os_string` to `&mut PathBuf` and `as_mut_os_str` to `&mut Path` REVERT: a0ea66caa0a Implement DerefMut for PathBuf REVERT: 1d924925852 Extract WStrUnits to sys_common::wstr REVERT: e7c31eb8cc3 Auto merge of #102991 - Sp00ph:master, r=scottmcm REVERT: 05521790f8a linkat() not available in the system headers of Solaris 10 REVERT: 6706d573b08 Rollup merge of #104934 - ChrisDenton:all-anybody-wants, r=thomcc REVERT: 6588630f04e Rollup merge of #104892 - lukas-code:discriminant, r=scottmcm REVERT: 74e09d2e223 add ptr::from_{ref,mut} REVERT: e49f97ca392 add link for string to as_ref docs REVERT: dfd0e7b5fa5 Auto merge of #104818 - scottmcm:refactor-extend-func, r=the8472 REVERT: 13c4639bca7 reword Option::as_ref and Option::map examples REVERT: 8aa1bd5f29b Add second test case in `make_contiguous_head_to_end` REVERT: 5883abecd0f Improve slow path in `make_contiguous` REVERT: 43effe5f5ae fix broken link fragment REVERT: 59c6fd6c36d explain how to get the discriminant out of a `#[repr(T)] enum` REVERT: 8813466f095 Auto merge of #104935 - matthiaskrgr:rollup-nuca86l, r=matthiaskrgr REVERT: 2914af80b00 Rollup merge of #104839 - HintringerFabian:docs_array_from_fn, r=scottmcm REVERT: c923975aa3e Remove redundant `all` in cfg REVERT: 87fde33a0f9 Auto merge of #103556 - clubby789:specialize-option-partial-eq, r=scottmcm REVERT: d468171f381 Don't use `Take` in `SpecExtend` impl REVERT: 79841e44d78 PERs are homogeneous REVERT: 831caf532f1 Implement masking in FileType comparison on Unix REVERT: 0142242530e Rollup merge of #104873 - RalfJung:therefore, r=Dylan-DPC REVERT: 3093af208b7 Rollup merge of #104654 - thomcc:alloc-tests-unsafe_op_in_unsafe_fn, r=Mark-Simulacrum REVERT: d51bea7ae23 change example of array_from_fn to match suggestion REVERT: d06a350c5a7 RefCell::get_mut: fix typo REVERT: 74bd768a04e Auto merge of #104855 - thomcc:revert-noinline-wintls, r=ChrisDenton REVERT: 193bc2f7d41 Tune RepeatWith::try_fold and Take::for_each and Vec::extend_trusted REVERT: 2b817f318d1 Changes according to code review REVERT: 9a71b779f24 Revert "Forbid inlining `thread_local!`'s `__getit` function on Windows" REVERT: 22de631a720 Rollup merge of #104774 - vojtechkral:doc-str-empty-split-whitespace, r=thomcc REVERT: 89dced577e2 improve array_from_fn documenation REVERT: c034e26c20a Document split{_ascii,}_whitespace() for empty strings REVERT: 2c820239ba5 Stop peeling the last iteration of the loop in `Vec::repeat_with` REVERT: 3b3b58b2bda Extract the logic for `TrustedLen` to a named method that can be called directly REVERT: ca5781142d9 feat: implement TcpStream shutdown for wasm32-wasi REVERT: 414dc53c694 Avoid `GenFuture` shim when compiling async constructs REVERT: 7f0a7a39d83 Add `#![deny(unsafe_op_in_unsafe_fn)]` in liballoc tests REVERT: 0c8e481295c Rollup merge of #104647 - RalfJung:alloc-strict-provenance, r=thomcc REVERT: 7de3eeeaf49 Auto merge of #104743 - JohnTitor:rollup-9z9u7yd, r=JohnTitor REVERT: 7043733a916 Rollup merge of #101368 - thomcc:wintls-noinline, r=ChrisDenton REVERT: fc41abbc4a1 fix OOB access in SIMD impl of str.contains() REVERT: 3d367693ae5 add test for issue 104726 REVERT: 95bb118977a Rollup merge of #104710 - RalfJung:doc-strict-provenance, r=thomcc REVERT: 40ab083e283 Rollup merge of #104464 - mati865:reduce-eh-overallocation-amd64, r=thomcc REVERT: 7f3c15f23e4 disable strict-provenance-violating doctests in Miri REVERT: 6aa7cd3b147 Forbid inlining `thread_local!`'s `__getit` function on Windows REVERT: d62e0a2fab5 rustdoc: Fix backoff doc to match implementation REVERT: 7beed68e7c6 Rollup merge of #103193 - krasimirgg:sysonce, r=Amanieu REVERT: ef2b88aee07 Rollup merge of #102207 - CraftSpider:const-layout, r=scottmcm REVERT: 6c3ebe7313d Rollup merge of #101655 - dns2utf8:box_docs, r=dtolnay REVERT: 5af13953565 Rollup merge of #95583 - scottmcm:deprecate-ptr-to-from-bits, r=dtolnay REVERT: bdc610308cc Rollup merge of #83608 - Kimundi:index_many, r=Mark-Simulacrum REVERT: 80aae8cd48f Touch up Box one-liner REVERT: 12a0827941e Rustc_deprecated attribute superseded by deprecated REVERT: 1192a351e15 Bump ptr_to_from_bits deprecation to Rust 1.67 REVERT: ed4f8cad691 Rollup merge of #104692 - chbaker0:libtest-cfg-if, r=thomcc REVERT: 1134632bf5c Rollup merge of #103396 - RalfJung:pinning-closure-captures, r=dtolnay REVERT: c7202d7f147 Update test's cfg-if dependency to 1.0 REVERT: ffed1884e45 dont attempt strict provenance in SGX REVERT: ff20558047c Document all unsafe blocks REVERT: c9fbea91390 Remove debug unused REVERT: 98674f9feb8 Rollup merge of #104420 - TethysSvensson:master, r=JohnTitor REVERT: f8eb1df3920 type annotate &str when stack allocating a string REVERT: 2b192209964 reflow the stack size story REVERT: 8ef1d03b482 Rollup merge of #104643 - pnkfelix:examples-for-chunks-remainder, r=scottmcm REVERT: d265ce9994f Rollup merge of #104641 - tshepang:grammar, r=Mark-Simulacrum REVERT: d47d8c381c3 Rollup merge of #104634 - RalfJung:core-arch, r=Mark-Simulacrum REVERT: 182923ffae7 Rollup merge of #104632 - RalfJung:core-test-strict-provenance, r=thomcc REVERT: 60ea177b9ad Rollup merge of #104461 - mati865:gnullvm-aarch64-fixup, r=Mark-Simulacrum REVERT: 37f73e692b3 Rollup merge of #101310 - zachs18:rc_get_unchecked_mut_docs_soundness, r=Mark-Simulacrum REVERT: 4ff45849947 Only one feature gate needed REVERT: 00328db4de3 Use ? instead of match REVERT: c25904f55fa Fix issue number REVERT: b9dcde038c3 Add derive_const feature REVERT: f24c81ac8fe Update with derive_const REVERT: 99de0da6f95 Add stability for alignment REVERT: 3bc91b41e24 constify remaining layout methods REVERT: 1c339c80ffc Unify stable and unstable sort implementations in same core module REVERT: 442510d23eb enable fuzzy_provenance_casts lint in libstd REVERT: d483ea32842 enable fuzzy_provenance_casts lint in liballoc REVERT: e898bbaa70d Rollup merge of #104568 - RalfJung:realloc, r=Amanieu REVERT: c5c46a40cd9 Rollup merge of #104558 - thomcc:unalign-diriter, r=ChrisDenton REVERT: a5e783991d9 Rollup merge of #104537 - HintringerFabian:docs_default_min_stack_size, r=the8472 REVERT: 8dacb5bbfd8 add examples to chunks remainder methods. Also fixed some links to rchunk remainder methods. REVERT: 629c30168ed Add get_many_mut methods to slice REVERT: dd98712ebee replace unusual grammar REVERT: 7c6554c3d50 enable fuzzy_provenance_casts in libcore+tests REVERT: 6fe0d67073d Update VecDeque implementation REVERT: 51882256293 Auto merge of #104617 - RalfJung:miri, r=RalfJung REVERT: ec233107c68 Incorporate review feedback REVERT: 7aef6c01b22 cfg(miri) no longer needed in sys/unix/time.rs REVERT: 801a931b119 move core::arch into separate file REVERT: a611f4c4b91 Improve documentation of Stack size REVERT: a215cefb28e avoid non-strict-provenance casts in libcore tests REVERT: b658e77a61c Auto merge of #98914 - fee1-dead-contrib:min-deref-patterns, r=compiler-errors REVERT: 52c7e65b4d1 Rollup merge of #104435 - scottmcm:iter-repeat-n, r=thomcc REVERT: 2eabae14c0b Rollup merge of #104112 - yancyribbens:add-copy-to-repeat-description, r=JohnTitor REVERT: f3fd864c548 Rollup merge of #103901 - H4x5:fmt-arguments-as-str-tracking-issue, r=the8472 REVERT: 952f7951907 Add unstable `type_ascribe` macro REVERT: e392337e84e Auto merge of #102795 - lukas-code:constify-is-aligned-via-align-offset, r=oli-obk REVERT: 19dbb984168 update provenance test REVERT: b7da0216e26 Update comment on pointer-to-usize transmute REVERT: 981906ee982 Revert "don't call `align_offset` during const eval, ever" REVERT: eacc42a5161 fix const `align_offset` implementation REVERT: 373c87796d3 docs cleanup REVERT: d1d0e9f64f2 always use `align_offset` in `is_aligned_to` + add assembly test REVERT: 7c9d5756154 Schrödinger's pointer REVERT: 4b0fa46c247 address more review comments REVERT: 62439ced0f7 document `is_aligned{,_to}` REVERT: 1607d1617c4 don't call `align_offset` during const eval, ever REVERT: f4e9a3934b9 mark `align_offset` as `#[must_use]` REVERT: abcaa84e237 add coretests for `is_aligned` REVERT: eae758db990 constify `pointer::is_aligned{,_to}` REVERT: 4338a819b74 add coretests for const `align_offset` REVERT: 7f464be79b8 Auto merge of #104607 - matthiaskrgr:rollup-9s589me, r=matthiaskrgr REVERT: c220bc2f351 make const `align_offset` useful REVERT: 3a4e0d77632 constify `exact_div` intrinsic REVERT: 13ecb82ac8d Rollup merge of #103989 - arlosi:arm32-panic, r=Amanieu REVERT: 33af1704e37 Auto merge of #104571 - clubby789:remove-vec-rc-opt, r=the8472 REVERT: b7d3be62a32 Rollup merge of #104553 - mwillsey:asinh-acosh-accuracy, r=thomcc REVERT: 4f9872308c1 Rollup merge of #104528 - WaffleLapkin:lazy_lock_docfix, r=matklad REVERT: bf1c98d5ddd Hide the items while waiting for the ACP REVERT: 567249d5f98 Auto merge of #104591 - Manishearth:rollup-b3ser4e, r=Manishearth REVERT: 6c314a2711f Rollup merge of #104338 - compiler-errors:pointer-sized, r=eholk REVERT: 5805e2aa2fd Rollup merge of #103701 - WaffleLapkin:__points-at-implementation__--this-can-be-simplified, r=scottmcm REVERT: b6f2dcf50c3 Rollup merge of #103456 - scottmcm:fix-unchecked-shifts, r=scottmcm REVERT: 2a98ba12801 Rollup merge of #103378 - nagisa:fix-infinite-offset, r=scottmcm REVERT: 1cd4c2fa7c3 Rollup merge of #102977 - lukas-code:is-sorted-hrtb, r=m-ou-se REVERT: b5fa2ca8b31 Change undefined-behavior doctests from ignore to no_run. REVERT: 8a5cf8e5eab Apply suggestions from code review REVERT: f8d7c375012 Add examples to show when `{Arc,Rc}::get_mut_unchecked` is disallowed. REVERT: 59645b4474a Clarify and restrict when `{Arc,Rc}::get_mut_unchecked` is allowed. REVERT: bbf8ee1010a Enforce that dyn* casts are actually pointer-sized REVERT: db5d177ecb6 Rollup merge of #103594 - maniwani:fix-issue-91417, r=thomcc REVERT: 6e45e559e35 Remove Vec/Rc storage reuse opt REVERT: 3c0214cb833 clarify that realloc refreshes pointer provenance even when the allocation remains in-place REVERT: 89ace0ff0af Handle the case that even the filename array is unaligned. REVERT: 08620588839 Rm diagnostic item, use lang item REVERT: 854cfe7893d Don't assume `FILE_ID_BOTH_DIR_INFO` will be aligned REVERT: 3696d635b29 Improve accuracy of asinh and acosh REVERT: 3cfc190c5ba Readd the matches_macro diag item REVERT: 507e0de82fb Auto merge of #104219 - bryangarza:async-track-caller-dup, r=eholk REVERT: e7d4613a288 Minimal implementation of implicit deref patterns REVERT: 426d49dfca8 Properly link `{Once,Lazy}{Cell,Lock}` in docs REVERT: b1746938cc5 Auto merge of #104205 - clubby789:grow-rc, r=thomcc REVERT: b49d908c40c Auto merge of #103779 - the8472:simd-str-contains, r=thomcc REVERT: d7eb69ff8ef available_parallelism: Handle 0 cfs_period_us REVERT: 3aea48addf0 Auto merge of #104481 - matthiaskrgr:rollup-hf8rev0, r=matthiaskrgr REVERT: b346b80f57f Rollup merge of #104401 - RalfJung:mpsc-leak, r=Amanieu REVERT: dd7cd349e73 Rollup merge of #103489 - WaffleLapkin:byte_offset_from_you, r=scottmcm REVERT: b2ab7b7b67c Auto merge of #102935 - ajtribick:display-float-0.5-fixed-0, r=scottmcm REVERT: e685b678444 Reduce exceptions overallocation on non Windows x86_64 REVERT: 9999867605b Fix building of `aarch64-pc-windows-gnullvm` REVERT: da872f95414 Auto merge of #104054 - RalfJung:byte-provenance, r=oli-obk REVERT: 0a27440daa5 - convert from core::arch to core::simd - bump simd compare to 32bytes - import small slice compare code from memmem crate - try a few different probe bytes to avoid degenerate cases - but special-case 2-byte needles REVERT: c99059cc6bc generalize str.contains() tests to a range of haystack sizes REVERT: e158c8599c6 Rollup merge of #104339 - compiler-errors:rustc_deny_explicit_impl, r=cjgillot REVERT: 3b185d25145 Rollup merge of #104241 - bjorn3:smaller_unwind_build_script, r=Mark-Simulacrum REVERT: 18dee49ada8 Rollup merge of #103734 - Mark-Simulacrum:fix-version-stabilized, r=JohnTitor REVERT: 5fcafe3f41a `VecDeque::resize` should re-use the buffer in the passed-in element REVERT: 6c95950ae05 Auto merge of #104428 - matthiaskrgr:rollup-jo3078i, r=matthiaskrgr REVERT: 5866156d034 Rollup merge of #104383 - WaffleLapkin:rustc_undiagnostic_item, r=compiler-errors REVERT: 5d443221a8f Rollup merge of #104372 - Ayush1325:compiler-builtins, r=JohnTitor REVERT: 67a3bc6f8b6 Rollup merge of #104354 - lukas-code:blank-lines-2, r=JohnTitor REVERT: e3da43c12cc x86_64 SSE2 fast-path for str.contains(&str) and short needles REVERT: 26a6fa21512 update str.contains benchmarks REVERT: 884e4f7ec2c black_box test strings in str.contains(str) benchmarks REVERT: eb9e882c4fb Fix doc example for `wrapping_abs` REVERT: 7087dcb5986 Rollup merge of #104332 - Elarcis:maybe_uninit_doc_fix, r=m-ou-se REVERT: d1aff276949 Rollup merge of #102470 - est31:stabilize_const_char_convert, r=joshtriplett REVERT: 970909cd866 Rollup merge of #101967 - jmillikin:linux-abstract-socket-addr, r=joshtriplett REVERT: 5a079db6b6d macos, aarch64, and not(miri) REVERT: 2badc144bdc Move most of unwind's build script to lib.rs REVERT: d6d92fd4ebc rustdoc: Add copy to the description of repeat REVERT: 3a04b41b78e std: move `ReentrantMutex` to `sync` REVERT: 528fc538a96 avoid memory leak in mpsc test REVERT: e479c70759e Auto merge of #104387 - Manishearth:rollup-9e551p5, r=Manishearth REVERT: 1df07695405 Add rustc_deny_explicit_impl REVERT: 2c2a8828e19 Rollup merge of #104300 - tbu-:pr_path_parent_caveats, r=Mark-Simulacrum REVERT: e8be1516874 Rollup merge of #103744 - palfrey:unwind-upgrade-cc, r=Mark-Simulacrum REVERT: f0bb4588425 Add `Vec` storage optimization to `Arc` and add tests REVERT: ec0b464c7c8 Reuse `Vec` backing storage for `Rc<[T]>` REVERT: 2e81036d3e1 Auto merge of #103858 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini REVERT: 61ad88db0aa Fix clippy and rustdoc REVERT: 6723bf5b054 Auto merge of #103894 - mati865:gnullvm-libunwind-changes, r=thomcc REVERT: f6b5b284ab7 just use `libc::clockid_t` REVERT: 51d873de626 Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targets REVERT: b95ca297d2c Remove unused diagnostic items REVERT: 152f32b16d7 Update compiler-builtins REVERT: ea28fd52df7 Rollup merge of #104320 - fee1-dead-contrib:use-derive-const-in-std, r=oli-obk REVERT: 155cfc97c91 Rollup merge of #103996 - SUPERCILEX:docs, r=RalfJung REVERT: 062007a3485 Auto merge of #93563 - ibraheemdev:crossbeam-channel, r=Amanieu REVERT: cb3b86559e3 remove leading newlines from `NonZero*` doc examples REVERT: 538ad279928 avoid using channels in thread-local tests REVERT: 286b03d346c avoid calling `thread::current` in channel destructor REVERT: c3d86dfcc3b Auto merge of #103913 - Neutron3529:patch-1, r=thomcc REVERT: e0ee69c8cab Fixed some `_i32` notation in `maybe_uninit`’s doc REVERT: fec020f42f6 Rollup merge of #104308 - scottmcm:no-more-validalign, r=thomcc REVERT: ead9a63423f Rollup merge of #104263 - albertlarsan68:add-ilog2-to-leading-zeroes-docs, r=scottmcm REVERT: 66231e9be13 Use `derive_const` and rm manual StructuralEq impl REVERT: e066709cc7c Use correct EH personality on `*-windows-gnu-*` REVERT: c04669c7eb0 Bump unwinder private data size for AArch64 Windows REVERT: bd9522da200 Rollup merge of #102049 - fee1-dead-contrib:derive_const, r=oli-obk REVERT: 0c808c3c3df Remove the old `ValidAlign` name REVERT: 2a0e67ce0a5 Auto merge of #103150 - joboet:remove_lock_wrappers, r=m-ou-se REVERT: eebae29467a Document `Path::parent` behavior around relative paths REVERT: 981bd4cc072 Try another way REVERT: 70c4915c551 Apply suggestions REVERT: aabb55e61b4 Add a reference to ilog2 in leading_zeros integer docs REVERT: f78345b78ef Rollup merge of #104060 - ink-feather-org:const_hash, r=fee1-dead REVERT: 1f80e248e99 tidy REVERT: 4efce362bcb spin less in `mpsc::SyncSender::send` REVERT: 37d87954e6d remove extra spinning from `mpsc` parker REVERT: 9036f877287 `sync::mpsc`: quadratic backoff REVERT: 39f28b1e44b `sync::mpsc`: reload state after spinning on CAS failure REVERT: b9500dcad18 remove extra spinning from `mpsc::Receiver::recv` REVERT: 6653ef8ec0f remove mention of rust-lang#39364 from mpsc docs REVERT: e8380a114e5 add test case for rust-lang#39364 REVERT: b5fb9bfd89a implement `sync::mpsc` as a wrapper around `sync::mpmc` REVERT: cb621780d0a initial port of crossbeam-channel REVERT: ef648e8d641 Allow and add `track_caller` to generators REVERT: 372b3ca2e9c Upgrade cc to 1.0.76 REVERT: a65c3008c22 Rollup merge of #104015 - alex:remove-kernel, r=oli-obk REVERT: 739e5939d14 Rollup merge of #103464 - JakobDegen:mir-parsing, r=oli-obk REVERT: 723e4c8b76f Rollup merge of #103307 - b4den:master, r=estebank REVERT: 32c75c01c85 Rollup merge of #104125 - ink-feather-org:const_cmp_tuples, r=fee1-dead REVERT: 8236ebfa05d Rollup merge of #104111 - yancyribbens:add-mutable-to-the-description-for-as-simd-mut, r=scottmcm REVERT: 13b3ac186ce Rollup merge of #103694 - WaffleLapkin:mask_doc_example, r=scottmcm REVERT: ee9e825e39c Rollup merge of #103570 - lukas-code:stabilize-ilog, r=scottmcm REVERT: 65471926e77 const Compare Tuples REVERT: eb4d88974d4 Add support for custom MIR parsing REVERT: 835d5175663 `IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` documentation. REVERT: e2f5e7fe4d6 Rollup merge of #104139 - ferrocene:pa-channel-licensing, r=pnkfelix REVERT: 379f05d9802 Rollup merge of #104113 - ink-feather-org:fix_const_fn_ref_impls, r=compiler-errors REVERT: c5c63760638 Rollup merge of #104109 - yancyribbens:add-mutable-to-comment-for-align-to-mut, r=thomcc REVERT: 8b47f106c45 Rollup merge of #104097 - RalfJung:miri-alloc-benches, r=thomcc REVERT: bf3e5d53c74 Rollup merge of #104093 - RalfJung:test-sizes, r=thomcc REVERT: 0e3b3ed8b09 Test const `Hash`, fix nits REVERT: 3b51cd1e71b doc: expand description for f32 and f64 associated constants REVERT: 37c358a9899 clarify licensing situation of mpsc and spsc queue REVERT: 2aa71e7c78b Rollup merge of #103446 - the8472:tra-array-chunks, r=Mark-Simulacrum REVERT: 3b77f42aba5 document and improve array Guard type REVERT: 80a0adcb148 simplification: do not process the ArrayChunks remainder in fold() REVERT: 507711985e6 specialize iter::ArrayChunks::fold for TrustedRandomAccess iters REVERT: 2cc5f26e0a7 make the array initialization guard available to other modules REVERT: c5ee56d40ec add benchmark for iter::ArrayChunks::fold specialization REVERT: d40d18f0d1c Auto merge of #103934 - notriddle:notriddle/backtrace-deps, r=Mark-Simulacrum REVERT: d5a93c95828 Fix `const_fn_trait_ref_impl`, add test for it REVERT: a147ab56e19 rustdoc: Add mutable to the description REVERT: e1c2c31b655 rustdoc: Add mutable to the description REVERT: 20a93030d50 Removed unnecessary Trait bound REVERT: d4ec570d067 fmt REVERT: 2f27e500441 Rollup merge of #104090 - wanghaha-dev:master, r=Dylan-DPC REVERT: 73585195597 Lift `T: Sized` bounds from some `strict_provenance` `NonNull` methods REVERT: a2da9d1feb1 run alloc benchmarks in Miri and fix UB REVERT: 6def9a4e409 disable btree size tests on Miri REVERT: 18e2d733507 Modify comment syntax error REVERT: 9b98bbb1aa7 Rollup merge of #104074 - yancyribbens:add-example-to-round, r=Mark-Simulacrum REVERT: a3f5bba3024 Rollup merge of #104056 - ripytide:patch-1, r=Mark-Simulacrum REVERT: 91d22e56344 PhantomData layout guarantees REVERT: c5edef9a914 Fix rebase errors REVERT: 25c6ab0ce78 Fix rustdoc lints REVERT: 621577862aa cfg-step code REVERT: 432627f756f Bump version placeholders to release REVERT: 7f0889c528c rustdoc: Add an example for round that is different from truncate REVERT: 81e738b5011 Add small clarification around using pointers derived from references REVERT: a02cdb0ad9a Auto merge of #99943 - compiler-errors:tuple-trait, r=jackh726 REVERT: 94bfbc1b63e Added `const_hash` tracking issue id REVERT: a34a128cab2 Made `Sip` const `Hasher` REVERT: 75d1954272f Vec: IntoIterator signature consistency REVERT: 7b032724678 std: fix double-free of mutex REVERT: 19b64abb9df std: remove lock wrappers in `sys_common` REVERT: 9d11a6b8294 remove no-longer-needed work-arounds from the standard library REVERT: 8587fd81251 Rollup merge of #104002 - RalfJung:unsafecell-new, r=JohnTitor REVERT: 2119a21a395 Fix unused_must_use warning for Box::from_raw REVERT: ba104583f5c Merge conflicts and rebase onto master REVERT: f4722e027de Enforce Tuple trait on Fn traits REVERT: 596fab708ef Remove linuxkernel targets REVERT: 68a5912fb0b fix a comment in UnsafeCell::new REVERT: 0f403da22c2 Rollup merge of #103995 - SUPERCILEX:typos, r=Dylan-DPC REVERT: 297783b012f Small round of typo fixes REVERT: 2f17179c2fb Fix build of thumbv7a-pc-windows-msvc REVERT: f196fbf78fd Make `BuildHasher` const_trait REVERT: 1e751402718 Made `Hash` and `Hasher` const_trait REVERT: 4034aec3e2a Rollup merge of #103681 - RalfJung:libtest-thread, r=thomcc REVERT: b2af3d1f0c9 Rollup merge of #103367 - chbaker0:update-std-getrandom, r=thomcc REVERT: cd2e480a4d7 Rollup merge of #103941 - douweschulte:patch-1, r=jyn514 REVERT: fe09b970b6e Rollup merge of #103680 - RalfJung:cstr-links, r=JohnTitor REVERT: 69b3913fdae update comment REVERT: f844864bd2b Remove `iter::Empty` hack REVERT: b6cc74500c5 Fixed typos REVERT: 1ce1954005f std: sync "Dependencies of the `backtrace` crate" with `backtrace` REVERT: 21a5f141c73 fix the overflow warning. REVERT: b8c10540419 Optimize the code to run faster. REVERT: 0f23b92eeb1 Remove std's transitive dependency on cfg-if 0.1 REVERT: 748c757a4ca Add tracking issue for `const_arguments_as_str` REVERT: 0885d6cfd94 Rollup merge of #103807 - H4x5:string-extend-from-within-tracking-issue, r=Dylan-DPC REVERT: 0f97fc8ae2b Rollup merge of #103774 - compiler-errors:dyn-trait-in-type-name, r=eholk REVERT: fcd652768f8 Add additional float constants REVERT: 20ca1b9c032 Clarify docs of `RefCell` REVERT: f6f60509467 Rollup merge of #103637 - ChrisDenton:stdio-uwp, r=thomcc REVERT: e77bc72633a Rollup merge of #103084 - inquisitivecrystal:control-flow, r=scottmcm REVERT: fe02bb5ed0f Format dyn Trait better in type_name intrinsic REVERT: 8be8d8b3b3d Change the way libunwind is linked for `*-windows-gnullvm` targets REVERT: 1eb52fe4866 Rollup merge of #103809 - tyggja:patch-1, r=JohnTitor REVERT: 4d5e41525f0 Rollup merge of #103729 - RalfJung:align-of-val-packed, r=oli-obk REVERT: c3353901dfc Rollup merge of #103061 - Amanieu:rewrite_alloc_error_handler, r=bjorn3 REVERT: 7a65a8004ce Use `allow_internal_unstable` and add unstable reason REVERT: 031ec50589c Auto merge of #103795 - thomcc:untest, r=Mark-Simulacrum REVERT: 38cf93632d1 Specialize PartialEq for Option and Option REVERT: 75449272f24 Rewrite implementation of `#[alloc_error_handler]` REVERT: a6742125588 Update mod.rs REVERT: bc2c6edd59c Add tracking issue for `string_extend_from_within` REVERT: 52c7d2fa109 Rollup merge of #103766 - lukas-code:error-in-core, r=Dylan-DPC REVERT: 7f006309b56 Include both benchmarks and tests in the numbers given to `TeFiltered{,Out}` REVERT: c08c7797973 Add tracking issue to `error_in_core` REVERT: 082fc0aac09 Rollup merge of #103689 - saethlin:libtest-startup, r=thomcc REVERT: 147bb2c5926 Add BorrowedBuf::filled_mut REVERT: 1e142d53e96 Rollup merge of #103715 - tshepang:consistency, r=Dylan-DPC REVERT: 2789b4ebc91 Rollup merge of #100006 - jyn514:update-copy, r=dtolnay REVERT: 65ee159da9c Upgrade cc for working is_flag_supported on cross-compiles REVERT: e3a8fcbe0a0 Adjust stabilization version to 1.65.0 for wasi fds REVERT: 6e003a0387d interpret: fix align_of_val on packed types REVERT: d6d5a13251f Rollup merge of #103719 - joseluis:fix-typos-try-reserve, r=the8472 REVERT: e0e1bd60521 Rollup merge of #102721 - nbdd0121:panic, r=Amanieu REVERT: d1aff3d995e fix typo in hashmap and hashset try_reserve method REVERT: 51ed742da44 More inference-friendly API for lazy REVERT: 71462d33f34 use consistent terminology REVERT: 478f17e4d91 Rollup merge of #102961 - reitermarkus:const-cstr-from-ptr, r=oli-obk REVERT: 9afea990c02 Auto merge of #102737 - RalfJung:poll_fn_pin, r=Mark-Simulacrum REVERT: 8665128c87a Lift `T: Sized` bounds from some `strict_provenance` pointer methods REVERT: 5d9192b667f Simplify implementation of various pointer methods REVERT: d629f70a374 Make `pointer::with_metadata_of` const (+simplify implementation) REVERT: ceb9e180a30 Add examples for `pointer::mask` REVERT: 9f41617af9f Remove unneeded attribute. REVERT: 708d5c8c5e6 libtest: run all tests in their own thread, if supported by the host REVERT: cab72b9750a CStr: add some doc links REVERT: f1a13f2a659 Do fewer passes and generally be more efficient when filtering tests REVERT: a896c1367d0 Use stdio in UWP apps REVERT: 9a9cf011c26 Rollup merge of #103394 - Pointerbender:unsafecell-docs, r=Amanieu REVERT: 4d746814ba2 Rollup merge of #103110 - RalfJung:manual-send, r=thomcc REVERT: 303572e3b7a Rollup merge of #103564 - RalfJung:miri-unused, r=thomcc REVERT: d005fa12ed3 Rollup merge of #103106 - saethlin:from_exposed_docs, r=thomcc REVERT: 0cb0d84604f Rollup merge of #103035 - saethlin:assert_unsafe_precondition3, r=thomcc REVERT: 0952ca71b3b add "Memory layout" subsection to documentation of `UnsafeCell` for additional clarity REVERT: 892fd1b7de7 Print the precondition we violated, and visible through output capture REVERT: e7286e53a56 Rollup merge of #103596 - RalfJung:thread-setname, r=cuviper REVERT: 262b5ed3a96 Rollup merge of #103580 - lukas-code:guaranteed_ne, r=GuillaumeGomez REVERT: c0482ca3750 Rollup merge of #103567 - RalfJung:ptr-eq-dyn-trait, r=dtolnay REVERT: 6f645d173c3 Rollup merge of #103526 - Rageking8:more-dupe-typos-again, r=Mark-Simulacrum REVERT: 220f7dcbd54 thread::set_name: debug-assert that things went well REVERT: 0bd9ff7afb4 Fix typo in docs for `guaranteed_ne` REVERT: a5c912289dc Update library/core/src/ptr/mod.rs REVERT: 2f0c08f8f41 explicitly mention that both components of wide prts are compared REVERT: 9eae483cf47 stabilize `int_log` REVERT: 83b11580789 ptr::eq: clarify that comparing dyn Trait is fragile REVERT: ab3339a534b library: allow some unused things in Miri REVERT: d2a270e0ff4 Rollup merge of #103287 - saethlin:faster-len-check, r=thomcc REVERT: cf8adfa60e0 Try to say that memory outside the AM is always exposed REVERT: 3fdf2cfd2d9 more dupe typos again REVERT: dc1a19f246b stabilise array methods REVERT: ab0a00861fa Auto merge of #103392 - RalfJung:miri, r=oli-obk REVERT: 7232a5e1e7a Rollup merge of #103482 - aDotInTheVoid:vec-cap-docs, r=thomcc REVERT: 009ca9f604b Rollup merge of #103379 - cuviper:truncate-thread-name, r=thomcc REVERT: c99f2e991d5 Rollup merge of #98204 - Kixiron:stable-unzip, r=thomcc REVERT: 57c824a47b5 Make `pointer::byte_offset_from` more generic REVERT: 670e6267795 Clairify Vec::capacity docs REVERT: 525a17ee74d Rollup merge of #103466 - jruderman:patch-2, r=Dylan-DPC REVERT: aa1893b2146 Rollup merge of #103277 - thomcc:bump-libc-135, r=Mark-Simulacrum REVERT: a73c8f40ed3 Rollup merge of #102766 - thomcc:remove-resolv, r=Mark-Simulacrum REVERT: bc9b44129f7 Rollup merge of #102271 - lopopolo:lopopolo/stabilize-duration-try-from-secs-float, r=dtolnay REVERT: 45888a5165a Rollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726 REVERT: c8873657a20 Rollup merge of #99578 - steffahn:remove_redundant_bound, r=thomcc REVERT: cf213c5ff63 Fix grammar in docs for std::io::Read REVERT: a811cbba6bf Auto merge of #100848 - xfix:use-metadata-for-slice-len, r=thomcc REVERT: c0002f81964 fix typos REVERT: ef99e45662d Pass on null handle values to child process REVERT: 6c720ab9eba `unchecked_{shl|shr}` should use `u32` as the RHS REVERT: afb89037362 Rollup merge of #103447 - ajtribick:maybe_uninit_doc_update, r=scottmcm REVERT: 0557862bf6c Rollup merge of #103005 - solid-rs:patch/kmc-solid/readdir-terminator, r=m-ou-se REVERT: 19ca9d8929f Rollup merge of #101644 - Timmmm:file_permissions_docs, r=thomcc REVERT: 4359c0613e3 Rollup merge of #100462 - zohnannor:master, r=thomcc REVERT: d70bac10cef Fix alloc size REVERT: 472bd713165 Apply suggestion REVERT: 845b314b69d Implement Rust foreign exception protection for EMCC and SEH REVERT: 0fb873854fe Prevent foreign Rust exceptions from being caught REVERT: 785a058c6b6 Auto merge of #103137 - dtolnay:readdir, r=Mark-Simulacrum REVERT: 41cce87f43f Only test pthread_getname_np on linux-gnu REVERT: c58090771f9 MaybeUninit: use assume_init_drop() in the partially initialized array example REVERT: bff5f03c8ca Fix typo in docs of `String::leak`. REVERT: 8acdd6bdde5 Pin::new_unchecked: discuss pinning closure captures REVERT: 1dc9020008b Rollup merge of #103360 - ChrisDenton:isterm-filetype, r=thomcc REVERT: f20bb4c5fe9 Rollup merge of #103346 - HeroicKatora:metadata_of_const_pointer_argument, r=dtolnay REVERT: 0f7388c057b Rollup merge of #103329 - saethlin:nonnull-precondition, r=thomcc REVERT: 72ad968deaa Rollup merge of #103280 - finnbear:impl_string_leak_2, r=joshtriplett REVERT: c36e3a4b5a0 Move truncation next to other thread tests for tidy REVERT: 40518860f6f Fix mod_inv termination for the last iteration REVERT: cdc9c1cf024 Truncate thread names on Linux and Apple targets REVERT: 81f14f66162 Auto merge of #103375 - matthiaskrgr:rollup-4xrs7f2, r=matthiaskrgr REVERT: dd27b4e0b65 Rollup merge of #103359 - WaffleLapkin:drain_no_mut_qqq, r=scottmcm REVERT: 45c0cb1396e Rollup merge of #103340 - RalfJung:winconsole, r=thomcc REVERT: 196431f469a Auto merge of #101263 - lopopolo:lopopolo/c-unwind-fn-ptr-impls, r=thomcc REVERT: 5d5369bb048 Auto merge of #101077 - sunshowers:signal-mask-inherit, r=sunshowers REVERT: 67e71571abb Reduce false positives in msys2 detection REVERT: 62fd24a9f81 Remove incorrect comment in `Vec::drain` REVERT: 4ad50c130bc Reduce mutability in std-use of with_metadata_of REVERT: 29266ffa0c2 Argument type for mutable with_metadata_of (#75091) REVERT: 902ca4955d2 WinConsole::new is not actually fallible REVERT: 50ba11bf23a merge rustc history REVERT: 6b40315dc73 Auto merge of #103308 - sunfishcode:sunfishcode/wasi-io-safety, r=joshtriplett REVERT: 74a97e8e12e Add a missing precondition check REVERT: aa6566ea0c7 Change process spawning to inherit the parent's signal mask by default REVERT: 2a570856c4f Make the whole `std::os::wasi::io` module stable. REVERT: a9cdcfe2d3c Rollup merge of #103288 - johnmatthiggins:master, r=thomcc REVERT: 887f48a805a Rollup merge of #103281 - thomcc:long-overdue, r=jyn514 REVERT: 3a58f4e36fa Add tests for rounding of ties during float formatting REVERT: f838355da38 Update tests to match error message changes REVERT: 8dbabf7d849 Mark `std::os::wasi::io::AsFd` etc. as stable. REVERT: bd8f6d33d24 Skip C-unwind fn pointer impls with the bootstrap compiler REVERT: 17fdf2c026c clarify documentation about the memory layout of `UnsafeCell` REVERT: b66c84ad0b3 Rollup merge of #103272 - clubby789:extra-spaces, r=thomcc REVERT: 46446a2f762 Rollup merge of #103197 - est31:stabilize_proc_macro_source_text, r=petrochenkov REVERT: 0cf6aaa11c6 Adjust `transmute{,_copy}` to be clearer about which of `T` and `U` is input vs output REVERT: 88706b9b567 Fixed docs typo in `library/std/src/time.rs` REVERT: 805c34195a3 Use a faster allocation size check in slice::from_raw_parts REVERT: a3ba8dfa6f2 Update stability annotations on fnptr impls for C-unwind ABI REVERT: a6cec84fcb3 Add default trait implementations for "c-unwind" ABI function pointers REVERT: 3c58e656977 Put fn in the right place. REVERT: aca4f1658a8 Copy of #102941. REVERT: 251182ce6b7 Update libstd's libc to 0.2.135 REVERT: a49984f0f28 Remove extra spaces REVERT: 8cbf4736ae9 Derive `Eq` and `Hash` for `ControlFlow` REVERT: 13d8942d46c doc: rewrite doc for signed int::{carrying_add,borrowing_sub} REVERT: 84a0e80f1b3 Rollup merge of #103153 - ChrisDenton:leak-oom, r=m-ou-se REVERT: 7a0bc955ba3 Rollup merge of #103127 - SUPERCILEX:inline-const-uninit, r=scottmcm REVERT: 3e56f2a5bbe Auto merge of #103225 - matthiaskrgr:rollup-1zkv87y, r=matthiaskrgr REVERT: 55a0d038780 Rollup merge of #103166 - the8472:copied-next-chunk, r=m-ou-se REVERT: 36a60e1cff5 specialize slice_iter.copied().next_chunk() REVERT: 28d631407f1 Rollup merge of #102507 - scottmcm:more-binary-search-docs, r=m-ou-se REVERT: a9d7faa328c Rollup merge of #101889 - tspiteri:redoc-uint-adc-sbb, r=m-ou-se REVERT: 6362c54a20d Stabilize proc_macro::Span::source_text REVERT: 9d4199166ff mark sys_common::once::generic::Once::new const-stable REVERT: 1746cd848f7 Auto merge of #103188 - JohnTitor:rollup-pwilam1, r=JohnTitor REVERT: 412f6f8f1bf Rollup merge of #103163 - SUPERCILEX:uninit-array-assume2, r=scottmcm REVERT: 0b5156fca23 Rollup merge of #103159 - cuviper:check_pow-final-try_opt, r=Mark-Simulacrum REVERT: 8da18fc8096 Rollup merge of #103154 - H4x5:reverse-searcher-typo, r=Mark-Simulacrum REVERT: 00732a8b614 Rollup merge of #103142 - fmease:fix-103052, r=oli-obk REVERT: 85bc402d20a Auto merge of #103075 - SUPERCILEX:miri-metadata, r=thomcc REVERT: 22951282a78 add a benchmark for slice_iter.copied().array_chunks() REVERT: 60d99373bcb Remove all uses of array_assume_init REVERT: 84b6896606c Auto merge of #101837 - scottmcm:box-array-from-vec, r=m-ou-se REVERT: 184fec9c54e Remove the redundant `Some(try_opt!(..))` in `checked_pow` REVERT: db67d79a3fa Fix typo in `ReverseSearcher` docs REVERT: ef5d6f2cdc8 Allow `Vec::leak` with `no_global_oom_handling` REVERT: 350330eecef Make diagnostic for unsatisfied Termination bounds more precise REVERT: eb9d21d7c1a Eliminate 280-byte memset from ReadDir iterator REVERT: a5cfaa20505 Fix types in documentation for Alignment::as_usize and Alignmnet::as_nonzero REVERT: 007c5b7e642 Make transpose const and inline REVERT: 63746be2d05 Rollup merge of #103109 - RalfJung:phantom-data-impl, r=thomcc REVERT: 3b2caf998ce Rollup merge of #103102 - H4x5:len_utf16_docs, r=scottmcm REVERT: 9d8bd0becce Rollup merge of #103087 - phimuemue:btreemap_append_doc, r=Mark-Simulacrum REVERT: 9b690cf28e1 Support DirEntry metadata calls in miri REVERT: c74e319ec3f Clarify the possible return values of len_utf16 REVERT: d407dffb10a remove redundant Send impls for references REVERT: 96c87208bff PhantomData: inline a macro that is used only once REVERT: ff00132d8c9 Rollup merge of #102023 - SUPERCILEX:maybeuninit-transpose, r=scottmcm REVERT: 63b33ea4f6e Rollup merge of #101717 - Pointerbender:unsafecell-memory-layout, r=Amanieu REVERT: 0571a990414 Stabilize `main_separator_str` REVERT: 9c518d3c9c5 Add MaybeUninit array transpose impls REVERT: dc05a69464a Auto merge of #100579 - joboet:sync_mutex_everywhere, r=thomcc REVERT: 931abd99a54 More slice::partition_point examples REVERT: 84c2a1a1d86 Stabilize `duration_checked_float` REVERT: 3743d2b6262 Documentation BTreeMap::append's behavior for already existing keys REVERT: 06e4ad24f5d Rollup merge of #102773 - joboet:apple_parker, r=thomcc REVERT: 68cb3e68b87 Auto merge of #98033 - joshtriplett:is-terminal-fd-handle, r=thomcc REVERT: 1aa7e2c7db0 Use Align8 to avoid misalignment if the allocator or Vec doesn't align allocations REVERT: 4a4e465da95 Rewrite FILE_NAME_INFO handling to avoid enlarging slice reference REVERT: e99d08a7b9f Make is_terminal fail fast if a process has no console at all REVERT: 68419752328 Add `IsTerminal` trait to determine if a descriptor or handle is a terminal REVERT: c481679a386 Auto merge of #103069 - matthiaskrgr:rollup-xxsx6sk, r=matthiaskrgr REVERT: 15711114876 Rollup merge of #103067 - Nilstrieb:tidy-likes-the-alphabet, r=jackh726 REVERT: a71bdf9fbcb Rollup merge of #103059 - beetrees:duration-from-negative-zero, r=thomcc REVERT: 7ece71cc0ac Rollup merge of #103045 - lukas-code:blank-lines, r=GuillaumeGomez REVERT: 47d44b7df5e Rollup merge of #103017 - fortanix:raoul/sgx_tls_fix, r=ChrisDenton REVERT: e8eb746c0ed Rollup merge of #102781 - StackOverflowExcept1on:master, r=joshtriplett REVERT: c556cf0587a Auto merge of #101030 - woppopo:const_location, r=scottmcm REVERT: 13e2caa3a78 Sort target features alphabetically REVERT: 91b7f82b886 Add some tidy-alphabetical REVERT: ee4e592e202 Auto merge of #102783 - RalfJung:tls, r=thomcc REVERT: 240b834071b Bugfix: keep TLS data in sync REVERT: 4cba8b2e11b Fix `Duration::{try_,}from_secs_f{32,64}(-0.0)` REVERT: 0c443b6fd0d Fix `checked_{add,sub}_duration` incorrectly returning `None` when `other` has more than `i64::MAX` seconds REVERT: 5acfcf00e0d Auto merge of #102529 - colinba:master, r=joshtriplett REVERT: f527f1fae66 Tweak grammar REVERT: 43c769436f3 Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8Ki REVERT: 4691f0ca1da Rollup merge of #102847 - joshtriplett:bugfix-impl-fd-traits-for-io-types, r=m-ou-se REVERT: dfde1420eda remove leading newlines from integer primitive doc examples REVERT: c1547579e5a more dupe word typos REVERT: 4ad654b6df8 Auto merge of #103009 - Dylan-DPC:rollup-9c2tng6, r=Dylan-DPC REVERT: 2c49b9abbc2 Rollup merge of #102854 - semarie:openbsd-immutablestack, r=m-ou-se REVERT: 1fd20367347 smarter way to avoid 'unused' warning when building for tests REVERT: b58546d27de sync thread_local key conditions exactly with what the macro uses REVERT: 3a210b81130 Auto merge of #102919 - luojia65:update-stdarch, r=Amanieu REVERT: c0cefed8c72 std: use `sync::Mutex` for internal statics REVERT: 609eb9f3bd8 Auto merge of #102655 - joboet:windows_tls_opt, r=ChrisDenton REVERT: a35fe5f5ccd kmc-solid: Handle errors returned by `SOLID_FS_ReadDir` REVERT: 3cfa3e1b13e Auto merge of #102995 - JohnTitor:rollup-yomkwge, r=JohnTitor REVERT: 2c3bdb88a84 library: update stdarch submodule REVERT: ffe72e2abb5 Rollup merge of #102974 - Rageking8:fix-small-word-dupe-typos, r=JohnTitor REVERT: 6fd578e4cb9 Auto merge of #102372 - abrown:issue-102157, r=thomcc REVERT: 75bbef96051 expand documentation on type conversion w.r.t. `UnsafeCell` REVERT: 62bccc1fbf0 merge rustc history REVERT: ae9e3c9ba99 fix small word dupe typos REVERT: c8dd62c2657 remove HRTB from `[T]::is_sorted_by{,_key}` REVERT: c0f7b1f18eb Auto merge of #102732 - RalfJung:assert_unsafe_precondition2, r=bjorn3 REVERT: 4692189f332 Update docs for `CStr::from_ptr`. REVERT: 802814f9b76 Make `CStr::from_ptr` `const`. REVERT: 8bab6b49648 Auto merge of #102460 - flba-eb:fix_85261_prevent_alloc_after_fork, r=thomcc REVERT: 83438b4c84d Auto merge of #102948 - Dylan-DPC:rollup-j8h74rb, r=Dylan-DPC REVERT: eec48be8c98 Rollup merge of #102811 - the8472:bufread-memset, r=m-ou-se REVERT: 4c48a2601a0 Rollup merge of #102578 - lukas-code:ilog-panic, r=m-ou-se REVERT: 1746487f92f Auto merge of #102692 - nnethercote:TokenStreamBuilder, r=Aaron1011 REVERT: 8bb4892738b Fix inconsistent rounding of 0.5 when formatted to 0 decimal places REVERT: 7ac5a21de9b reorder panicking.rs to put main entry points at the top REVERT: 089fc04ced2 use panic_fmt_nounwind for assert_unsafe_precondition REVERT: 5c49d566925 add panic_fmt_nounwind for panicing without unwinding, and use it for panic_no_unwind REVERT: 60fa7b3b5b5 rename rustc_allocator_nounwind to rustc_nounwind REVERT: 0b5c93cce71 fix: return type of single-threaded dummy lock must be droppable REVERT: 84cdee7257c Rollup merge of #102869 - azdavis:master, r=joshtriplett REVERT: e396b2b0be7 Rollup merge of #102685 - nbdd0121:unwind, r=m-ou-se REVERT: ca65590337a Rollup merge of #102445 - jmillikin:cstr-is-empty, r=Mark-Simulacrum REVERT: cb60a6edb6f Rollup merge of #102227 - devnexen:solarish_get_path, r=m-ou-se REVERT: e057db737a2 Rollup merge of #101774 - Riolku:atomic-update-aba, r=m-ou-se REVERT: 4667b94194a Rollup merge of #101727 - est31:stabilize_map_first_last, r=m-ou-se REVERT: 87d87b3b283 Rollup merge of #102625 - Rageking8:fix-backtrace-small-typo, r=m-ou-se REVERT: 8676cacc3f0 Rollup merge of #102589 - RalfJung:scoped-threads-dangling, r=m-ou-se REVERT: d77fe898b7a Rollup merge of #102412 - joboet:dont_panic, r=m-ou-se REVERT: 9f18983a8e7 Rollup merge of #102277 - mgeisler:rwlock, r=m-ou-se REVERT: 2c4343c9478 Rollup merge of #102258 - cjgillot:core-kappa, r=m-ou-se REVERT: 4055bd5b1e8 Change tracking issue from #76156 to #102911 REVERT: 93fd9afd708 Do not alias for fs REVERT: 7c9380010b6 Auto merge of #102596 - scottmcm:option-bool-calloc, r=Mark-Simulacrum REVERT: 8bc5964ae23 Implement `env_lock` with `RwLock` REVERT: ba2d282998e Allow compiling the `wasm32-wasi` std library with atomics REVERT: 2657cf7e1a3 merge rustc history REVERT: 4720fd91fa7 Consolidate AsFd instances for stdio types into `library/std/src/os/fd/owned.rs` REVERT: 8e08a51f3ae Auto merge of #96711 - emilio:inline-slice-clone, r=nikic REVERT: bfb9bbcf991 Rollup merge of #102794 - dtolnay:termination, r=thomcc REVERT: cd4f6564847 Rollup merge of #99696 - WaffleLapkin:uplift, r=fee1-dead REVERT: 7002aa24a17 Add basename and dirname aliases REVERT: 41e51f64eb9 Rollup merge of #102862 - scottmcm:more-alignment-traits, r=thomcc REVERT: d7c692ab56e From for usize & NonZeroUsize REVERT: e6280cddf2c Auto merge of #89123 - the8472:push_in_capacity, r=amanieu REVERT: 9b28a4f0236 expand documentation on type conversion w.r.t. `UnsafeCell` REVERT: e07250df6f0 Auto merge of #102850 - JohnTitor:rollup-lze1w03, r=JohnTitor REVERT: 36f5c4c62e7 impl AsFd for io::{Stdin, Stdout, Stderr}, not the sys versions REVERT: 9976082d98e openbsd: don't reallocate a guard page on the stack. REVERT: 43b4964b5da Rollup merge of #102072 - scottmcm:ptr-alignment-type, r=thomcc REVERT: db88f3fa127 Rollup merge of #101118 - devnexen:fs_getmode_bsd, r=Mark-Simulacrum REVERT: 52e677918b0 Auto merge of #93668 - SUPERCILEX:path_alloc, r=joshtriplett REVERT: 36d22e6ce6e fixup lint name REVERT: df004434c9e allow `for_loop_over_fallibles` in a `core` test REVERT: 79de69136ce merge rustc history REVERT: 7d1680fdf67 Rollup merge of #102812 - est31:remove_lazy, r=dtolnay REVERT: f06d7dd04e7 Rollup merge of #99880 - compiler-errors:escape-ascii-is-not-exact-size-iterator, r=thomcc REVERT: da234f9b6fb std: optimize TLS on Windows REVERT: b0d04c34b75 Auto merge of #102315 - RalfJung:assert_unsafe_precondition, r=thomcc REVERT: 5ea7215b422 Remove empty core::lazy and std::lazy REVERT: dbe846797b1 use memset to initialize a readbuf REVERT: e82e28d4f68 Fix test (location_const_file) REVERT: 73faf9a7339 Auto merge of #2583 - RalfJung:rustup, r=oli-obk REVERT: ca820f1fcfc std: do not use dispatch semaphore under miri (yet) REVERT: eed6c503181 std: remove unused linker attribute REVERT: 1211bfc3fa9 Auto merge of #99505 - joboet:futex_once, r=thomcc REVERT: 2489d0dad54 Make tests capture the error printed by a Result return REVERT: ec99b8882d0 Auto merge of #102091 - RalfJung:const_err, r=oli-obk REVERT: 7b13a038d03 Rollup merge of #102760 - saethlin:dont-reinit-buffer, r=Mark-Simulacrum REVERT: afc50641517 Rollup merge of #102475 - RalfJung:unsafe, r=dtolnay REVERT: 555544f60a1 Rollup merge of #102300 - scottmcm:simpler-fold-closures, r=Mark-Simulacrum REVERT: 68785ad123c make const_err a hard error REVERT: 8a580910ed6 review feedback REVERT: 8dfdee03542 Improved documentation for `std::io::Error` REVERT: 568162dee10 add a few more assert_unsafe_precondition REVERT: 3db86c512aa std: use futex in `Once` REVERT: e136e3f5a6f Don't needless link to `libresolv` on Darwin in libstd REVERT: 1fa9179b46c Avoid defensive re-initialization of the BufReader buffer REVERT: e902ff0d09a std: add thread parking tests REVERT: 81dc973f8e3 std: use semaphore for thread parking on Apple platforms REVERT: d027f6e8232 Auto merge of #102741 - matthiaskrgr:rollup-63no5tz, r=matthiaskrgr REVERT: 559524a64b6 Fix handling of trailing bare CR in str::lines REVERT: 26d8acfe0cc Rename LinesAnyMap to LinesMap REVERT: 7c5efc295d1 Rollup merge of #102680 - dtolnay:btreesend, r=thomcc REVERT: 91559855fc1 Auto merge of #99497 - vladimir-ea:stdlib_os_api_watchos, r=thomcc REVERT: 577c5c94662 poll_fn and Unpin: fix pinning REVERT: 0651abec00b Fix whitespace REVERT: 74372ab0215 Prevent UB in child process after calling libc::fork REVERT: 18e43625960 Rollup merge of #102693 - BlackHoleFox:revert-apple-entropy-changes, r=thomcc REVERT: ff83dddb540 tidy REVERT: 76cc97c5f09 Fix overconstrained Send impls in btree internals REVERT: d91de5e61cc Add regression test for lifetimes in alloc internals autotraits REVERT: 832f84923a6 Add missing trailing `)]` REVERT: 8b92dd0aa50 Fix typo (missing `>`) REVERT: 55b4bff4772 Update library/core/src/num/nonzero.rs REVERT: 0f3b84d8c86 Revert "Use getentropy when possible on all Apple platforms" REVERT: a034dff8edf Rollup merge of #102574 - aDotInTheVoid:const_collections_with_hasher, r=oli-obk,fee1-dead REVERT: 7543dfa5876 A tiny fix for `define_client_side`. REVERT: d5bd342efee Interpret EH actions properly REVERT: 51dde333a39 Auto merge of #101768 - sunfishcode:sunfishcode/wasi-stdio-lock-asfd, r=joshtriplett REVERT: 1c85528eb0d Rollup merge of #102647 - oli-obk:tilde_const_bounds, r=fee1-dead REVERT: a198b61c885 Rollup merge of #101642 - SkiFire13:fix-inplace-collection-leak, r=the8472 REVERT: a55ae904deb Rollup merge of #101189 - daxpedda:ready-into-inner, r=joshtriplett REVERT: 0ab5f06c267 Only allow ~const bounds for traits with #[const_trait] REVERT: f40da81a0f9 fix backtrace small typo REVERT: 72e7ea3269f Rollup merge of #102628 - H4x5:master, r=scottmcm REVERT: 7c59fe06d0c Auto merge of #99099 - Stargateur:phantomdata_debug, r=joshtriplett REVERT: 0a334fa6781 Auto merge of #102632 - matthiaskrgr:rollup-h8s3zmo, r=matthiaskrgr REVERT: d759d60abcf Rollup merge of #101308 - nerdypepper:feature/is-ascii-octdigit, r=joshtriplett REVERT: 8cafaf786cb Rollup merge of #100470 - reitermarkus:patch-1, r=joshtriplett REVERT: c68aaaa2aca Rollup merge of #99460 - JanBeh:PR_asref_asmut_docs, r=joshtriplett REVERT: 651581ad80c Rollup merge of #99216 - duarten:master, r=joshtriplett REVERT: c2d1637c30d Rollup merge of #98218 - kpreid:nostdarc, r=joshtriplett REVERT: e4f876246c2 Clarify documentation REVERT: bc8a52a5c33 Reduce CString allocations in std as much as possible REVERT: 82f3c6a452b Change the parameter name of From::from to `value` REVERT: 883bbdd36e7 Rollup merge of #102607 - WaffleLapkin:docky_docky_slice_from_ptr_range, r=joshtriplett REVERT: 061874d2707 Rollup merge of #102569 - eduardosm:from_str-example, r=joshtriplett REVERT: b52d7b3d6b6 Reword "has no meaning" per suggestion REVERT: a42de3983a5 Add better assert messages for f32/f64 clamps REVERT: 59c4d7539ee Add SAFETY comments for AsFd implementations on stdin/stdout/stderr REVERT: 19808cce3b9 Add stability attributes. REVERT: 65875569b8c scoped threads: pass closure through MaybeUninit to avoid invalid dangling references REVERT: 5d278e6e13c Sync docs of `slice::{from_ptr_range, from_ptr_range_mut}` REVERT: 5835676d446 Document when `slice::from_ptr_range[_mut]` panic REVERT: 24a0e38c12e Do the `calloc` optimization for `Option` REVERT: b1ebef35303 Auto merge of #102586 - Dylan-DPC:rollup-g107h6z, r=Dylan-DPC REVERT: 4603b04226b Rollup merge of #102556 - WaffleLapkin:implied_by_btree_new, r=Mark-Simulacrum REVERT: f74c04a7d89 Rollup merge of #102098 - xfix:weak-upgrade-fetch-update, r=Mark-Simulacrum REVERT: 5064931e5aa Rollup merge of #100451 - hovinen:no-panic-on-result-err-in-test, r=Mark-Simulacrum REVERT: 1a18b05ca9a remove unneeded attributes REVERT: ea1cf0125df Auto merge of #98354 - camsteffen:is-some-and-by-value, r=m-ou-se REVERT: 96de5c8f492 add tests for panicking integer logarithms REVERT: 46a67b18446 always panic for invalid integer logarithm REVERT: 920d6a9e033 Make Hash{Set,Map}::with_hasher unstably const REVERT: 4206d37e5ca Auto merge of #102548 - nikic:inline-cell-replace, r=scottmcm REVERT: 6ad81b780d3 Improve `FromStr` example REVERT: c138c24ca87 Auto merge of #102535 - scottmcm:optimize-split-at-partition-point, r=thomcc REVERT: f9047c9c96a Rollup merge of #102405 - hkBst:patch-3, r=Mark-Simulacrum REVERT: d5dabcf0561 Rollup merge of #102313 - anirudh24seven:update_sleep_ms_doc, r=Mark-Simulacrum REVERT: 686e5f566e8 Make `feature(const_btree_len)` implied by `feature(const_btree_new)` REVERT: 7db26773221 Change feature name to is_some_and REVERT: e29eb2239c6 Change is_some_and to take by value REVERT: d7d90623580 Mark Cell::replace() as #[inline] REVERT: 917217709b4 Tell LLVM that `partition_point` returns a valid fencepost REVERT: 8fec6947e1a `SetFileTime` doesn't allow setting the file time to `0xFFFF_FFFF_FFFF_FFFF` REVERT: 09d95c9041f Error instead of panicking when setting file times if the passed `SystemTime` doesn't fit into the required type REVERT: 0c10b27f321 Detect and reject out-of-range integers in format string literals REVERT: 7dc7a69b886 Auto merge of #102520 - matthiaskrgr:rollup-7nreat0, r=matthiaskrgr REVERT: eb0e3723042 Add back ConstFnMutClosure::new, fix formatting REVERT: 3665e173190 Fixed Documentation for wrap_mut_2_imp REVERT: 2c24bc5de2f Added more const_closure functionality. REVERT: a121a37a45e Stabilize map_first_last REVERT: fc60cb6dbeb Standard library OS support for Apple WatchOS REVERT: 9c1190555ff Fix integer overflow in `format!("{:.0?}", Duration::MAX)` REVERT: 89c263a9000 unsafe keyword: trait examples and unsafe_op_in_unsafe_fn update REVERT: d20c18d4108 Rollup merge of #102452 - granolocks:grammar-tweak, r=thomcc REVERT: b6ef0002a20 Rollup merge of #102435 - GuillaumeGomez:improve-iterator-reduce-example, r=thomcc,vacuus REVERT: 58463109f69 Rollup merge of #102342 - jmillikin:nonzero-negation, r=scottmcm REVERT: a3e3a032cb7 Stabilize const_char_convert REVERT: 6085e198fe5 Split out from_u32_unchecked from const_char_convert REVERT: 9958b50cbee Stabilize `nonnull_slice_from_raw_parts` REVERT: 91ea864970d fix minor ungrammatical sentence REVERT: 5d5c2cc58dd Rollup merge of #102433 - RalfJung:temp-dir-typo, r=thomcc REVERT: a1d9b64e4c5 Rollup merge of #102368 - beetrees:nano-niche, r=joshtriplett REVERT: 40cde6929cf Rollup merge of #98368 - sunfishcode:sunfishcode/std-os-fd, r=joshtriplett REVERT: 09269fa2575 Add `is_empty()` method to `core::ffi::CStr`. REVERT: 8301d5684a9 Improve example of Iterator::reduce REVERT: 544b8bc7ae9 nonzero_negation_ops: `inline(always)` -> `inline`. REVERT: a009bf1ab62 nonzero_negation_ops: Set `issue = "102443"`. REVERT: a65e886b9d3 env::temp_dir: fix a typo REVERT: 37d4ec13d19 Auto merge of #100719 - CohenArthur:rust-safe-intrinsic-attribute, r=wesleywiser REVERT: 80f219f34bf Add a niche to `Duration`, unix `SystemTime`, and non-apple `Instant` REVERT: ed5d885cac2 std: never panic in `thread::park` and `thread::park_timeout` REVERT: ef0a0d5d75a Update result.rs REVERT: 46050f711ab Rollup merge of #102288 - mejrs:inner, r=compiler-errors REVERT: ecb3602d99a Rollup merge of #102232 - Urgau:stabilize-bench_black_box, r=TaKO8Ki REVERT: 96080d15b98 Sort mod REVERT: 5abb4fe8c3e Rollup merge of #101555 - jhpratt:stabilize-mixed_integer_ops, r=joshtriplett REVERT: fb00579bb65 Address feedback REVERT: 9478b5a095d Wrapper suggestions REVERT: d8f68340f6a Fix indent REVERT: 7b166fd8329 Add newlines REVERT: 16fcdfe386f Add test cases for const `Location` REVERT: 41847067188 Stabilize bench_black_box REVERT: d87631ea340 doc: rewrite doc for uint::{carrying_add,borrowing_sub} REVERT: 7164881f3ad core: Mark all safe intrinsics with #[rustc_safe_intrinsic] REVERT: e72e80078ac introduce `{char, u8}::is_ascii_octdigit` REVERT: 01894452d66 Add negation methods for signed non-zero integers. REVERT: 439664c7794 Auto merge of #102331 - notriddle:rollup-dmefd2d, r=notriddle REVERT: ba23db0b9d9 Auto merge of #102283 - GuillaumeGomez:option-code-example-unwrap-or-default, r=thomcc REVERT: 20ea35ebf3a Rollup merge of #102326 - yancyribbens:splin-mut-doc-change, r=thomcc REVERT: ed3329697d2 Rollup merge of #102322 - sigaloid:master, r=GuillaumeGomez REVERT: 4a6ef3fe9cf Rollup merge of #102283 - GuillaumeGomez:option-code-example-unwrap-or-default, r=thomcc REVERT: 66a4780b18b Use a macro to not have to copy-paste `ConstFnMutClosure::new(&mut fold, NeverShortCircuit::wrap_mut_2_imp)).0` everywhere REVERT: f9f70f6ce08 rustdoc: Update doc comment for splitn_mut to include mutable in the description REVERT: abf6a26043c Document that Display entails ToString REVERT: 3686de00e2b Update docs so that deprecated method points to relevant method REVERT: 832e622d754 Improve code example for Option::unwrap_or_default REVERT: fe1a37864a8 remove cfg(bootstrap) REVERT: 6e25eecd535 replace stabilization placeholders REVERT: a44e9a151e4 fs::get_path solarish version. REVERT: 8f1a0719a63 Auto merge of #102297 - fee1-dead-contrib:rollup-2np0cre, r=fee1-dead REVERT: c7436caaa87 Rollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum REVERT: e77339b7aa0 Rollup merge of #102263 - GuillaumeGomez:iterator-rposition-example, r=thomcc REVERT: e5bd305b112 Consistently write `RwLock` REVERT: 95790466a38 Rollup merge of #102259 - gimbles:patch-1, r=joshtriplett REVERT: 9cd4c448348 Rollup merge of #102245 - ink-feather-org:const_cmp_by, r=fee1-dead REVERT: 02860ea696d Rollup merge of #102200 - ink-feather-org:const_default_impls, r=fee1-dead REVERT: 4514c0793aa Rollup merge of #101800 - chriss0612:feat/const_split_at_mut, r=fee1-dead REVERT: cd35cf1dda7 Rollup merge of #98111 - eggyal:issue-97982, r=GuillaumeGomez REVERT: 20258a79fb2 Clarify Iterator::rposition code example REVERT: f1828f58aa3 Update option.rs REVERT: 8758211c98b Remove unused variable. REVERT: ddc36049d19 Auto merge of #99609 - workingjubilee:lossy-unix-strerror, r=thomcc REVERT: bfc24b532dc Auto merge of #98457 - japaric:gh98378, r=m-ou-se REVERT: 8ea901825a9 Auto merge of #102169 - scottmcm:constify-some-conditions, r=thomcc REVERT: cf5d64ce5fb Constify cmp_min_max_by REVERT: 283e5d647fe Add some more documentation REVERT: f9156a0089c Auto merge of #102234 - matthiaskrgr:rollup-5cb20l1, r=matthiaskrgr REVERT: 3b0d589e46f Rollup merge of #102186 - ink-feather-org:const_try_trait, r=fee1-dead REVERT: c0d8ca55e91 Rollup merge of #100823 - WaffleLapkin:less_offsets, r=scottmcm REVERT: 952fe9b5d35 Auto merge of #102167 - thomcc:exclusive-inline, r=scottmcm REVERT: b7d71a5ee4e Auto merge of #102223 - matthiaskrgr:rollup-wb1qdhk, r=matthiaskrgr REVERT: af105f842e6 Rollup merge of #102188 - flba-eb:doc_missed_at_rename, r=jyn514 REVERT: cc518c4ff3a Rollup merge of #102044 - ChrisDenton:BCrypt-system-rand, r=thomcc REVERT: 6548bbd141b Put back one of the `use`s for intra-doc mentions REVERT: 4524246c760 Auto merge of #100845 - timvermeulen:iter_compare, r=scottmcm REVERT: b0722b502d7 Stabilize const `BTree{Map,Set}::new` REVERT: b31b7446633 Constify Residual behind const_try REVERT: cde8f2c13df Remove unused `ConstFn(Once)Closure` structs. REVERT: 59ccc73f98a Added some spacing in const closure REVERT: 02c891b1a34 Added const Default impls for Arrays and Tuples. REVERT: b37cc8911fc Rollup merge of #102177 - inquisitivecrystal:std-doc-typo, r=Dylan-DPC REVERT: 46f5162241b Rollup merge of #102115 - Alfriadox:master, r=thomcc REVERT: a06d6cf99a9 Rollup merge of #102094 - GuillaumeGomez:bool-from-str-missing-docs, r=scottmcm REVERT: 9618c0d56a5 Fixed Doc-Tests REVERT: 436b8221c6d Update doc after renaming fn is_zero REVERT: 5a099dc1234 Constifed Try trait REVERT: d673bd6f338 Added const_closure REVERT: 186e438cf0d Fix a typo in `std`'s root docs REVERT: c4ef22e38aa rustfmt REVERT: 4c963c54131 Make ZST checks in core/alloc more readable REVERT: 48fde317d8a Add `#[inline]` to trivial functions on `core::sync::Exclusive` REVERT: fa667f983e3 Add `AsFd` implementations for stdio lock types on WASI. REVERT: 69421b5bfce Rollup merge of #102144 - chriss0612:const_convert_control_flow, r=scottmcm REVERT: 612b5bd65ac Derive Eq/PartialEq instead of manually implementing it REVERT: 685e9fc84af Constify {FormResidual, Try} for ControlFlow REVERT: e1f876f2ac3 Apply changes proposed in the review REVERT: 8c65a8fa0ec Rollup merge of #102131 - orlp:patch-1, r=thomcc REVERT: a77abba836b Rollup merge of #102036 - Patiga:remove-io-errorkind-other-use-in-std, r=Mark-Simulacrum REVERT: 3c2c1a8a402 Added which number is computed in compute_float. REVERT: d1d385ec5a0 Add missing assertion REVERT: bf87bed78a7 Auto merge of #100982 - fee1-dead-contrib:const-impl-requires-const-trait, r=oli-obk REVERT: f347095864f Remove trailing whitespace REVERT: 542d5d3840a Rollup merge of #102102 - GuillaumeGomez:doc-aliases-sized-trait, r=thomcc REVERT: 4132ca55ead Add examples to `bool::then` and `bool::then_some` REVERT: 3c9343641d5 Add `rustc_allow_const_fn_unstable` annotations to pre-existing `Layout` methods REVERT: 416d0610544 Add doc aliases on Sized trait REVERT: 4e8b4d8d8b0 Use fetch_update in sync::Weak::upgrade REVERT: 060bf5ce782 Rollup merge of #102058 - mqudsi:path_extension_docs, r=thomcc REVERT: cc9d9d0eba5 Rollup merge of #101995 - scottmcm:carrying-mul-example, r=Mark-Simulacrum REVERT: 857b3f4a96b Rollup merge of #89891 - ojeda:modular-alloc, r=Mark-Simulacrum REVERT: c4fd1a3e1df Add missing documentation for `bool::from_str` REVERT: 94c5afec5a8 Auto merge of #100214 - scottmcm:strict-range, r=thomcc REVERT: 7f8a5a4c32f Auto merge of #100581 - joboet:sync_rwlock_everywhere, r=thomcc REVERT: e6b0af97184 Add `ptr::Alignment` type REVERT: 8928ee2a9d8 Remove `RtlGenRandom` (take two) REVERT: 72df06cf4ae Clarify Path::extension() semantics in docs abstract REVERT: a3ac2328bbe Add the `#[derive_const]` attribute REVERT: d9216c5a5c0 Optimize `array::IntoIter` REVERT: 81313aed493 Remove use of `io::ErrorKind::Other` in std REVERT: a6994bbe0fc std: use `sync::RwLock` for internal statics REVERT: 2e826452ebe Rollup merge of #101798 - y86-dev:const_waker, r=lcnr REVERT: 14d90932c3c Rollup merge of #101389 - lukaslueg:rcgetmutdocs, r=m-ou-se REVERT: 09b9dfa797b Added tracking issue REVERT: 62b1959367d Document surprising and dangerous fs::Permissions behaviour on Unix REVERT: 3e25f540fb8 Add another example for `uN::carrying_mul` REVERT: 2db743d0d50 Auto merge of #101955 - jam1garner:fix-proc-macro-typo, r=petrochenkov REVERT: a190cd0d19c Move `unix_socket_abstract` feature API to `SocketAddrExt`. REVERT: 9d821580bbd Adjust `tcp_quickack` feature to allow other `os::linux::net` features. REVERT: 65fd5180445 Auto merge of #101816 - raldone01:cleanup/select_nth_unstable, r=Mark-Simulacrum REVERT: 3cfb1d9c89d Fix typo in proc_macro Span::eq REVERT: b10e2bdc7ed Auto merge of #101949 - matthiaskrgr:rollup-xu5cqnd, r=matthiaskrgr REVERT: cf49f728d14 Rollup merge of #101821 - thomcc:unicode-15, r=Manishearth REVERT: b3d71df3910 Add `Box<[T; N]>: TryFrom>` REVERT: 48e23bce559 Rollup merge of #101861 - wesleywiser:update_stdarch, r=Amanieu REVERT: 9877ff0f372 Rollup merge of #101672 - idigdoug:array_try_into, r=Mark-Simulacrum REVERT: 0335fbfc934 Auto merge of #101938 - Dylan-DPC:rollup-6vlohhs, r=Dylan-DPC REVERT: b64f69f8c9c Rollup merge of #101931 - msakuta:master, r=thomcc REVERT: caffcaa48cc Rollup merge of #93628 - est31:stabilize_let_else, r=joshtriplett REVERT: 28747f6e249 Auto merge of #101784 - reitermarkus:const-memchr, r=thomcc REVERT: 03f70379bbd Fix a typo in docstring REVERT: 19dfc08d435 Do not panic when a test function returns Result::Err. REVERT: 5126bc44654 Rollup merge of #101802 - chriss0612:const_fn_trait_ref_impls, r=fee1-dead REVERT: 53e3ce7ac31 Add `const_trait` to `Allocator` REVERT: 87cf983273b append_const_msg for std traits REVERT: 3c2f87e1298 Mark `Drop` with `#[const_trait]` REVERT: 8c8c6a04e37 Do not implement `Unpin` as const REVERT: 2471879f328 Prevent errors for stage0 rustc build REVERT: 06005831f14 Add more `const_trait` annotations REVERT: a11f973daf3 Add `const_trait`s REVERT: 55bcf27b4c7 Require `#[const_trait]` for `const` `impl`s REVERT: dc17b6b07bc Only enable the let_else feature on bootstrap REVERT: 9ee1fe3086b Update stdarch REVERT: 0bd9d3dee21 Rollup merge of #101810 - raldone01:feat/const_partial_eq_ordering, r=fee1-dead REVERT: 4e3375b5ab2 Rollup merge of #101559 - andrewpollack:add-backtrace-off-fuchsia, r=tmandry REVERT: 860cd23425c Adding backtrace off option for fuchsia targets REVERT: e7fa462c0e6 Make `core::mem::copy` const REVERT: a57e9b7619f Bump Unicode to version 15.0.0, regenerate tables REVERT: ceaeb451ce7 Cleanup closures. REVERT: 935ecb781a1 Warn about safety of `fetch_update` REVERT: 88a956c4854 Constify `PartialEq` for Ordering. REVERT: 6298fd15b8a Add const_slice_split_at_mut Feature gate. REVERT: 49cb73adbac Added Tracking Issue number. REVERT: c27d0c44f2f Made from_waker, waker, from_raw const REVERT: 0fe77e4d9c5 Constify impl Fn* &(mut) Fn* REVERT: c3e6d466e0e expand documentation on type conversion w.r.t. `UnsafeCell` REVERT: 9fec44bbab1 Simplify `const` `memchr`. REVERT: 612b705e52f Rollup merge of #101754 - NaokiM03:rename-log-to-ilog, r=Dylan-DPC REVERT: 03b3a871cc4 Rollup merge of #101745 - jay3332:patch-1, r=JohnTitor REVERT: 4416e41fb45 Fix doc of log function REVERT: c82f1abf73e Auto merge of #100640 - reitermarkus:socket-display-buffer, r=thomcc REVERT: d3fee08ecb5 Fix typo in concat_bytes documentation REVERT: 26e5325d4be Rollup merge of #100291 - WaffleLapkin:cstr_const_methods, r=oli-obk REVERT: f1f7e7ae093 Simplify `clippy` fix. REVERT: c918463ea63 Add `rustc_diagnostic_item` for IP addresses. REVERT: 11c6dbd21c0 Flatten `net` module again. REVERT: d8c97e3fa72 Move `net::parser` into `net::addr` module. REVERT: 21e7e89bf2d Add tests for `SockAddr` `Display`. REVERT: 430e9cf74db Use `DisplayBuffer` for socket addresses. REVERT: 2c809ef50a6 constify `CStr` methods REVERT: a322f39ee2d Rollup merge of #101671 - LingMan:ieee_754, r=Dylan-DPC REVERT: bf67b6b1b2a Rollup merge of #100767 - kadiwa4:escape_ascii, r=jackh726 REVERT: 211e5ff732f add description of the memory layout for `UnsafeCell` REVERT: 9ab29132e18 Auto merge of #100251 - compiler-errors:tuple-trait-2, r=jackh726 REVERT: b529b8d16aa Auto merge of #101442 - joboet:null_check_tcs, r=thomcc REVERT: 4302d9e58e5 Auto merge of #101299 - saethlin:vecdeque-drain-drop, r=thomcc REVERT: 1bd4e3cb915 std: check if TCS is a null pointer REVERT: fdcbae3c615 std: use correct clock in `park_timeout` on Horizon REVERT: a3516aead1b Auto merge of #101482 - joboet:netbsd_parker, r=sanxiyn REVERT: 8c988678c6d array docs - advertise how to get array from slice REVERT: 5a8565913aa Fix naming format of IEEE 754 standard REVERT: e9ecea65dae Auto merge of #101643 - ChrisDenton:alloc-link-kernel32, r=thomcc REVERT: 1f8b03e73b1 Alternate approach; just modify Drain REVERT: 94e537ae20c Remove &[T] from vec_deque::Drain REVERT: 8f14a6b43fd std: optimize thread parking on NetBSD REVERT: 932ff2f897e Make the one-liner more descriptive REVERT: 94b0e3eaaca Rollup merge of #101606 - akhi3030:patch-1, r=Dylan-DPC REVERT: bb37f698f1d Better documentation for env::home_dir()'s broken behaviour REVERT: 8280710d3f2 Update test REVERT: f74709ba10b Update documentation REVERT: b6da2fb9a1b Explicitly link kernel32.lib from alloc REVERT: fb4cfd31b5a Auto merge of #101483 - oli-obk:guaranteed_opt, r=fee1-dead REVERT: 305ffe1d414 Adapt inplace collection leak test to check for no leaks REVERT: 438c9cfc6a7 Fix leaking in inplace collection when destructor panics REVERT: 2e18efd439b Auto merge of #101617 - Dylan-DPC:rollup-iiy4ipc, r=Dylan-DPC REVERT: 797f26083b0 Rollup merge of #101529 - mousetail:patch-2, r=thomcc REVERT: 73653563fe0 Rollup merge of #101366 - ChrisDenton:unc-forward-slash, r=m-ou-se REVERT: 27950d3ff44 The `<*const T>::guaranteed_*` methods now return an option for the unknown case REVERT: 0534e9cd80d Rollup merge of #101529 - mousetail:patch-2, r=thomcc REVERT: e20cc7d4286 Rollup merge of #101495 - bjorn3:pause-no-sse2, r=Mark-Simulacrum REVERT: 1dea883b5a0 std: use futex-based locks and thread parker on Hermit REVERT: 8f5fb82acba doc: fix minor typo REVERT: c37a6acbf7c Rollup merge of #101556 - compiler-errors:tweak-generator-print, r=jackh726 REVERT: afd68a2cf41 Auto merge of #93873 - Stovent:big-ints, r=m-ou-se REVERT: f38e36e6132 Rollup merge of #101423 - mkroening:hermit-warnings, r=sanxiyn REVERT: 8d30c94b641 Rollup merge of #101422 - mkroening:hermit-file-time, r=joshtriplett REVERT: e4154a8e81e Generator return doesn't need to be a lang item REVERT: f648271b3ec Stabilize `#![feature(mixed_integer_ops)]` REVERT: 37239b82e4e Auto merge of #101544 - matthiaskrgr:rollup-4urx917, r=matthiaskrgr REVERT: 415943fbf3f Auto merge of #101476 - ChrisDenton:BCryptRandom-fix, r=thomcc REVERT: b0925d873a0 Typo REVERT: 7d1d2b11ec9 Use `CURRENT_RUSTC_VERSION` REVERT: 5b669527f9e Add doctest REVERT: ab287ecb573 stdio: Document no support for writing to non-blocking stdio/stderr REVERT: 49d839f5331 Don't break windows/rand for miri REVERT: 70705182815 This example was broken REVERT: dccec81dd2a Stabilize `nonzero_bits` REVERT: a1841809142 Rollup merge of #101481 - ChrisDenton:uwp-fix, r=thomcc REVERT: 824cbdd99c8 Open a BCrypt algorithm handle REVERT: e725af1df93 Compile spin_loop_hint as pause on x86 even without sse2 enabled REVERT: 0a2241e3a95 Auto merge of #100733 - scottmcm:inline-from-from-identity, r=m-ou-se REVERT: 88279fa5ddf Fix compile errors for uwp-windows-msvc targets REVERT: 884a694affe Rollup merge of #101412 - WaffleLapkin:improve_std_ptr_code_leftovers, r=scottmcm REVERT: c27dcf23023 Rollup merge of #101287 - Adam-Gleave:doc_bool_then_some, r=scottmcm REVERT: b229bc7f6f8 Rollup merge of #101426 - beetrees:dup-no-stdio, r=thomcc REVERT: 01dd295e851 Rollup merge of #101404 - joboet:always_cleanup_stdout, r=joshtriplett REVERT: 1a8866df9e8 separate the receiver from arguments in HIR under /clippy REVERT: bc38af87d66 Auto merge of #101439 - Dylan-DPC:rollup-2wf1mtj, r=Dylan-DPC REVERT: f33cbff8622 Rollup merge of #101391 - matthiaskrgr:perf0309, r=oli-obk REVERT: a9ed1770178 std: clarify semantics of SGX parker REVERT: a809765a23a std: fix cleanup for uninitialized stdout (#101375) REVERT: eb9d6432a98 Auto merge of #101414 - mystor:pm_nested_cross_thread, r=eddyb REVERT: 3080496b9cd Auto merge of #100759 - fee1-dead-contrib:const_eval_select_real_intrinsic, r=oli-obk,RalfJung REVERT: 685b07d8f53 Auto merge of #100576 - joboet:movable_const_remutex, r=Mark-Simulacrum REVERT: 8718191aa87 Hermit: Remove unused socklen_t (dead_code) REVERT: ae9793472e8 Hermit: Fix unused_imports REVERT: bc37f24001c Hermit: Add File::set_time stub REVERT: ac29cff7499 Auto merge of #93455 - asquared31415:vec-zero-opts, r=thomcc REVERT: e67b06836be proc_macro/bridge: use the cross-thread executor for nested proc-macros REVERT: fdde6139256 Rollup merge of #101401 - mx00s:expand-const, r=fee1-dead REVERT: d9a024c78dd Rollup merge of #101394 - CAD97:patch-3, r=Mark-Simulacrum REVERT: 3082a04d0a0 Rollup merge of #101385 - BartMassey-upstream:file-doc, r=thomcc REVERT: 3624bc9fd57 Rollup merge of #101322 - ChrisDenton:internal-doc, r=Mark-Simulacrum REVERT: 656fcd7dcab replace `as usize` casts with `usize::from` in slice sort REVERT: 2a76d3752a1 remove some integer casts from slice iter REVERT: eb1da6e3eda Address feedback from PR #101401 REVERT: cbe0085f8ba Make `char::is_lowercase` and `char::is_uppercase` const REVERT: 69c5b224491 Replace `offset` with `add` in `fmt/num.rs` & remove some casts REVERT: 6f310ef604c use `pointer::add` in memchr impl REVERT: e3930740fe6 Make code worling w/ pointers in `library/std/src/sys/sgx/abi/usercalls/alloc.rs` nicer REVERT: a475bb733d0 Auto merge of #101296 - compiler-errors:head-span-for-enclosing-scope, r=oli-obk REVERT: 833b462bd55 Add `inline(always)` to rt functions REVERT: b943d4080fc Add `inline(always)` to function generated by macro REVERT: 209b76acb0d Make `const_eval_select` a real intrinsic REVERT: 7a248416537 Don't duplicate file descriptors into stdio fds REVERT: e987eab6e5e Auto merge of #100726 - jswrenn:transmute, r=oli-obk REVERT: 8cf2c0adf70 Address nits, rename enclosing_scope => parent_label REVERT: f1ed8b70c0c Forbid mixing `System` with sytem allocator calls REVERT: 32e1e129827 more clippy::perf fixes REVERT: f33e3f38bd1 Tone down explanation on RefCell::get_mut REVERT: 7c64571b126 updated description of File struct in std::fs REVERT: 28f34614dd8 Auto merge of #101342 - saethlin:update-backtrace, r=Mark-Simulacrum REVERT: 0f90191f4d9 std: make `ReentrantMutex` movable and `const`; simplify `Stdout` initialization REVERT: d491530de7e Restore old behaviour on broken UNC paths REVERT: e2b5d414a5e Rollup merge of #101330 - wkordalski:hashset-drain-doc, r=jyn514 REVERT: 2d211eb83ec Rollup merge of #101325 - ChrisDenton:BCRYPT_RNG_ALG_HANDLE, r=thomcc REVERT: c75170e9f44 Rollup merge of #99736 - lopopolo:lopopolo/gh-80996-partial-stabilization-bounds-as-ref, r=dtolnay REVERT: d3dde3fde4a implement IsZero for Saturating and Wrapping REVERT: 8e57987d55e Fix compilation of the doc tests on Windows. REVERT: c6c3c3226b1 Auto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplett REVERT: bfa20b94435 Update backtrace REVERT: a49b9902909 Rollup merge of #101260 - ChrisDenton:attribute-tag, r=thomcc REVERT: a58f0b65c9e Fix `std::collections::HashSet::drain` documentation REVERT: 24598b6f174 Use `BCRYPT_RNG_ALG_HANDLE` by default REVERT: 389b57a48d8 Fix internal doc link REVERT: cf4c7415e9a Rollup merge of #99583 - shepmaster:provider-plus-plus, r=yaahc REVERT: eb57e31e09b Rollup merge of #97739 - a2aaron:let_underscore, r=estebank REVERT: 92fd27a65b4 Auto merge of #100395 - Dylan-DPC:rollup-ajrwo1s, r=Dylan-DPC REVERT: 759926c1ad1 Rollup merge of #101270 - m-ou-se:update-comment, r=joshtriplett REVERT: 993fbc3711d Rollup merge of #101190 - yjhn:patch-1, r=Mark-Simulacrum REVERT: bfd7dca691b Remove trailing whitespace REVERT: d2c1d2d485a Document eager evaluation of `bool::then_some` argument REVERT: 01550d22513 Sort tests at compile time, not at startup REVERT: b5cdcc06f48 Update outdated comment about output capturing in print_to. REVERT: c233ee62ecb Auto merge of #100707 - dzvon:fix-typo, r=davidtwco REVERT: 2faf17eaead unix_sigpipe: Make `sigpipe` param docs long-form REVERT: c6ea6ae62f2 Use `FILE_ATTRIBUTE_TAG_INFO` to get reparse tag REVERT: 9fca55f5d2f Auto merge of #100210 - mystor:proc_macro_diag_struct, r=eddyb REVERT: 1d3770d9f21 Rollup merge of #101236 - thomcc:winfs-nozero, r=ChrisDenton REVERT: 0b9878d55ae Rollup merge of #101229 - mgeisler:link-try-operator, r=thomcc REVERT: 9c058775e46 unix_sigpipe: Add docs for `init()` `sigpipe` param REVERT: 428ab149db1 unix_sigpipe: Inline compiler sigpipe constants in std REVERT: 60a5e3f4710 Rollup merge of #101237 - RalfJung:into-iter-zst, r=thomcc REVERT: a683619978d fix into_iter on ZST REVERT: 5ddeb995f13 Avoid needless buffer zeroing in `std::sys::windows::fs` REVERT: 94ff55e81f8 Correct typo REVERT: f40e918fe5f Fix a bunch of typo REVERT: eeeb41f7a35 Link “? operator” to relevant chapter in The Book REVERT: d332343b523 Rollup merge of #101171 - thomcc:fix-winfs-ub, r=ChrisDenton REVERT: 0c80360360d Rollup merge of #101011 - BlackHoleFox:apple-random-improvements, r=thomcc REVERT: 1dc4e00b95a Rollup merge of #100984 - ChrisDenton:reinstate-init, r=Mark-Simulacrum REVERT: 3c9b02e509e Rollup merge of #101193 - thomcc:win-stdio-nozero, r=ChrisDenton REVERT: a0268ec05b1 Rollup merge of #101159 - tspiteri:track-const-slice-split_at, r=Mark-Simulacrum REVERT: 6081987ee94 Rollup merge of #100892 - sunfishcode:wasi-stdio-asfd, r=joshtriplett REVERT: 827de29d58f Auto merge of #98919 - 5225225:stricter-invalid-value, r=RalfJung REVERT: 13b82636512 Avoid `MaybeUninit::uninit_array()` REVERT: 350360fb1c8 Fix UB in Windows `DirBuffIter` (provenance and alignment) REVERT: 83e2d2b25d3 Implement `Ready::into_inner()` REVERT: 0f0e0faada9 Avoid zeroing large stack buffers in stdio on Windows REVERT: bba7506a5e4 Make docs formulation more consistent for NonZero{int} REVERT: add65994284 Auto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPC REVERT: f243c3205b9 Replace `AlignedAs` with a more specific `Align8` type REVERT: 21ffddf67fe Fix UWP and use `AlignedReparseBuf` in `symlink_junction_inner` REVERT: fa525a8c606 Rollup merge of #95376 - WaffleLapkin:drain_keep_rest, r=dtolnay REVERT: c49b2e28940 Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrum REVERT: 5c87a7789a8 Fix some possible UB in std::sys::windows REVERT: 6533b9877ce Auto merge of #101167 - matthiaskrgr:rollup-yt3jdmp, r=matthiaskrgr REVERT: 3a92eddea7a Rollup merge of #101056 - kpreid:prim-doc, r=JohnTitor REVERT: 2712db234e0 add tracking issue number to const_slice_split_at_not_mut REVERT: 2dc782841dc Revert let_chains stabilization REVERT: 4556cf40532 Re-introduce `unstable` attributes. REVERT: 68cc63cbb3f Clarify that the `fd` module is supported on Unix and WASI. REVERT: b111ebbdb1d Make `std::os::fd` public. REVERT: 98a30c8ef2f Rollup merge of #100934 - a1phyr:improve_fmt_PadAdapter, r=Mark-Simulacrum REVERT: 37bbf6adc2b Rollup merge of #100819 - WaffleLapkin:use_ptr_byte_methods, r=scottmcm REVERT: 9ab4076dc97 Rollup merge of #100337 - camelid:stabilize-io_read_to_string, r=JohnTitor REVERT: f09dfce4ee5 Rollup merge of #98801 - joshtriplett:file-create-new, r=thomcc REVERT: 3e5ab4d6e46 Auto merge of #100786 - sunshowers:macos-posix-chdir, r=sunshowers REVERT: 6370bb17cf9 Rollup merge of #96334 - devnexen:socket_mark, r=dtolnay REVERT: 0765e9798b9 Rollup merge of #94890 - marmeladema:ip-addr-try-from-bytes, r=joshtriplett REVERT: da99cdfcecd Use posix_spawn for absolute paths on macOS REVERT: c69893c6239 Auto merge of #100578 - Urgau:float-next-up-down, r=scottmcm REVERT: f32fc588987 Stabilize `std::io::read_to_string` REVERT: 2fc7bc030f9 Support `#[unix_sigpipe = "inherit|sig_dfl|sig_ign"]` on `fn main()` REVERT: 99e615568f5 Auto merge of #100201 - RalfJung:thread-local-key, r=thomcc REVERT: 707ebf96683 fill-in tracking issue for `feature(drain_keep_rest)` REVERT: 765c254a0d1 add examples to `vec::Drain{,Filter}::keep_rest` docs REVERT: ccb127582ba Auto merge of #96324 - berendjan:set_tcp_quickack, r=dtolnay REVERT: cbdeb5aa880 fs::get_mode enable getting the data via fcntl/F_GETFL on major BSD supporting this flag. REVERT: d55546a9e67 Rollup merge of #100955 - nrc:chain, r=joshtriplett REVERT: dacda1596e8 Rollup merge of #100885 - mzohreva:mz/sgx-export-cancel-type, r=Mark-Simulacrum REVERT: 833ef37b3fc Rollup merge of #100520 - jakubdabek:patch-1, r=thomcc REVERT: 656cbcbf2ac Rollup merge of #100296 - BlackHoleFox:os-error-aliases, r=thomcc REVERT: 800ee372ca7 Rollup merge of #99570 - XrXr:box-from-slice-docs, r=thomcc REVERT: 3a3291b076d Rollup merge of #97015 - nrc:read-buf-cursor, r=Mark-Simulacrum REVERT: e695f9f2ff1 Auto merge of #92845 - Amanieu:std_personality, r=Mark-Simulacrum REVERT: 023d536a68d Reinstate preloading of some dll imports REVERT: 7b6a6d8a7d6 Auto merge of #96946 - WaffleLapkin:ptr_mask, r=scottmcm REVERT: 45006adced2 Partially stabilize `bound_as_ref` by stablizing `Bound::as_ref` REVERT: 106dc5afd62 Adjust backtrace stabilization version to CURRENT_RUSTC_VERSION REVERT: 02d44360979 Adjust ptr_const_cast stabilization version to CURRENT_RUSTC_VERSION REVERT: 65a3d6a1394 Rollup merge of #100953 - joshtriplett:write-docs, r=Mark-Simulacrum REVERT: 9725358d52a Rollup merge of #96240 - fee1-dead-contrib:stabilize_const_offset_from, r=Mark-Simulacrum REVERT: cdd2a95c71e Re-add some justification REVERT: 839e0d16a3c Creating uninitialized integers is UB REVERT: af6cad7aea8 Add the syntax of references to their documentation summary. REVERT: 4e71b394877 `alloc`: add unstable cfg features `no_rc` and `no_sync` REVERT: 38d83cd0105 Support parsing IP addresses from a byte string REVERT: b40bd9dff02 Rollup merge of #100128 - kpreid:waker-doc, r=thomcc REVERT: 2189552086d Rollup merge of #99742 - sigaloid:master, r=thomcc REVERT: 50a32cdbddf Rollup merge of #95005 - ssomers:btree_static_assert, r=thomcc REVERT: b15504d2251 constify `Location` methods REVERT: 88a076cb7a0 Auto merge of #101017 - JohnTitor:rollup-73f2fhb, r=JohnTitor REVERT: 28203985e12 Rollup merge of #100933 - a1phyr:cheap_assert_match_failed, r=JoshTriplett REVERT: 71e61c95fbd Rollup merge of #100604 - dtolnay:okorerr, r=m-ou-se REVERT: 5b406c05d77 Rollup merge of #100076 - tspiteri:const_slice_split_at, r=oli-obk REVERT: b969c34aecd Auto merge of #99487 - bmacnaughton:is_whitespace_updates, r=thomcc REVERT: ab911f0d3aa Use getentropy when possible on all Apple platforms REVERT: 7477d78d756 Auto merge of #100911 - tmiasko:update-stdarch, r=Amanieu REVERT: 9777def1f3e review REVERT: efa9031aa18 error::Error: remove some comments REVERT: b2c0e46ba4f Do not include `const_ptr_sub_ptr` in this stabilization REVERT: e03f0704612 Stabilize `const_ptr_offset_from`. REVERT: 5b71e7922e3 Rollup merge of #100921 - ChayimFriedman2:and-eager-eval, r=JohnTitor REVERT: 8fa4aaf9b5a Rollup merge of #99332 - jyn514:stabilize-label-break-value, r=petrochenkov REVERT: f612124bca6 Clarify comment to fit `as _` better REVERT: 8360d08f45b Rollup merge of #100922 - GuillaumeGomez:rewrite-error-index, r=notriddle REVERT: 2aa4a48816a Rollup merge of #100855 - IsaacCloos:master, r=joshtriplett REVERT: 4d97299671c Rollup merge of #100220 - scottmcm:fix-by-ref-sized, r=joshtriplett REVERT: 138b6117993 error::Error: rename the Demand arguments from req to demand REVERT: f9de84bbdc9 error::Error: rename the chain method to sources REVERT: 91ceb5b24ad Expand example to show how to implement qualified trait names REVERT: 8b9cbce2568 Update `write!` docs: can now import traits as `_` to avoid conflicts REVERT: bdf7ea7edf5 Remove some documentation duplicated between `writeln!` and `write!` REVERT: d389dd6622c Stabilize `#![feature(label_break_value)]` REVERT: b5670e6f827 Auto merge of #96869 - sunfishcode:main, r=joshtriplett REVERT: 46ac6182d9e Remove a packing branch from `fmt::builders::PadAdapter` REVERT: 48dc5aca062 Reduce code size of `assert_matches_failed` REVERT: f5534f69ee8 Auto merge of #99917 - yaahc:error-in-core-move, r=thomcc REVERT: 070a54a09ca Fix links to error codes REVERT: fbfcd583872 Add a warning about `Option/Result::and()` being eagerly evaluated REVERT: 2ba844cd8ff Make use of `[wrapping_]byte_{add,sub}` REVERT: 69038c6d6e2 Rollup merge of #100835 - devnexen:listener_followups, r=devnexen REVERT: b636f0c9ef0 Add `Provider::{would_be_satisfied_by_value_of,would_be_satisfied_by_ref_of}` REVERT: 30622ddbeb2 Remove aliases for old atomic intrinsics names REVERT: 38d965e020a Use renamed atomic intrinsics in panic_unwind REVERT: 836231ac807 Update stdarch submodule REVERT: ed217d70ae0 Support eager and lazy methods for providing references and values REVERT: 67f210519ac Update comment about personalities in panic_abort REVERT: ce3ffc6912b Remove custom frame info registration on i686-pc-windows-gnu REVERT: 73adc643c1a Move personality functions to std REVERT: bc8b3f8d639 Auto merge of #100782 - thomcc:fix-android-sigaddset, r=Mark-Simulacrum REVERT: 97540ebf01b Fix comment on the SEH personality function REVERT: cc5cd59d6a6 Remove out-of-context comment in `mem::MaybeUninit` documentation REVERT: 3c29907b243 Add `AsFd` implementations for stdio types on WASI. REVERT: 06a0fa41f06 Move error trait into core REVERT: 872a2d92be6 safe transmute: use `Assume` struct to provide analysis options REVERT: 94e4960019b Export Cancel from std::os::fortanix_sgx::usercalls::raw REVERT: b1478e1d389 net listen backlog update, follow-up from #97963. REVERT: fff6bdfdb6a Rollup merge of #100872 - JanBeh:PR_vec_default_alloc_doc, r=fee1-dead REVERT: 8acef32ba4e Rollup merge of #100820 - WaffleLapkin:use_ptr_is_aligned_methods, r=scottmcm REVERT: 0879587eed1 Rollup merge of #100331 - lo48576:try-reserve-preserve-on-failure, r=thomcc REVERT: 8249cad4e4c Rollup merge of #99957 - chotchki:ip-globally-reachable_rebase, r=Mark-Simulacrum REVERT: 9c2186a9af5 update and extend some comments, and cfg-out some unused code REVERT: 0fe68bd2244 std: use realstd fast key when building tests REVERT: 7b466f4f561 Add guarantee that Vec::default() does not alloc REVERT: 86815627e2c Rollup merge of #99386 - AngelicosPhosphoros:add_retain_test_maybeuninit, r=JohnTitor REVERT: 9ffe53c1ed6 Rollup merge of #93162 - camsteffen:std-prim-docs, r=Mark-Simulacrum REVERT: db67ccca6c9 Extra documentation for new formatting feature REVERT: 84e152114ed Use ptr::metadata in <[T]>::len implementation REVERT: 4afee561b8b Rollup merge of #100839 - nelsonjchen:consistent_child_stdin_field_desc, r=thomcc REVERT: 214b802fe0f Rollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcm REVERT: 4339fba2739 Rollup merge of #100821 - WaffleLapkin:ptr_add_docs, r=scottmcm REVERT: 5bfa715d61d Rollup merge of #100663 - clarfonthey:const-reverse, r=scottmcm REVERT: fdc6c907880 Rollup merge of #100556 - Alex-Velez:patch-1, r=scottmcm REVERT: d84322a8705 Make use of `pointer::is_aligned[_to]` REVERT: 4d37144b3dc Use internal iteration in `Iterator::{cmp_by, partial_cmp_by, eq_by}` REVERT: 0122fcbc2f1 Make doc for stdin field of process consistent REVERT: e396bce0a72 Fix redundant comparison REVERT: 6e92da6b6a4 fix nitpicks from review REVERT: 7cd758a4d85 fill in tracking issue for `feature(ptr_mask)` REVERT: 51f78674fe2 Add pointer masking convenience functions REVERT: 56343b0a1f8 Make some docs nicer wrt pointer offsets REVERT: ef0450585ca Replace most uses of `pointer::offset` with `add` and `sub` REVERT: d3c9631e3a2 Improve primitive/std docs separation and headers REVERT: 75338b5939e Remove useless pointer cast REVERT: 894efedc8af Auto merge of #100810 - matthiaskrgr:rollup-xep778s, r=matthiaskrgr REVERT: fcd5f749fcf Rollup merge of #100129 - RalfJung:miri-test-libstd, r=thomcc REVERT: 68a85875d27 Rollup merge of #97963 - devnexen:net_listener_neg, r=the8472 REVERT: 2cb10575a4b Rollup merge of #100710 - ChrisDenton:load-library, r=thomcc REVERT: 6c5cf4130c7 Rollup merge of #100642 - mzohreva:mz/update-sgx-abi-cancel-queue, r=Mark-Simulacrum REVERT: d69e981c1aa Rollup merge of #100585 - wooorm:patch-1, r=Mark-Simulacrum REVERT: c6380092f54 Rollup merge of #99544 - dylni:expose-utf8lossy, r=Mark-Simulacrum REVERT: 446b4b7b0b5 Expose `Utf8Lossy` as `Utf8Chunks` REVERT: 423d3e76a3b Fix generic bound of `SplitInclusive`'s `DoubleEndedIterator` impl REVERT: def12276dc6 Rollup merge of #100729 - thomcc:less-initialized, r=ChrisDenton REVERT: 9159f4c9aaf Rollup merge of #100383 - fortanix:raoul/aepic_leak_mitigation, r=cuviper REVERT: 3651c7debdc Use const instead of static REVERT: 590b20770a1 Simplify load/store REVERT: e01cba4377f Tracking issue for const_reverse REVERT: 5bfb456ebc5 Align android `sigaddset` impl with the reference impl from Bionic REVERT: 68531ea6edf use <[u8]>::escape_ascii instead of core::ascii::escape_default REVERT: a943acd13d6 Fix comment typo REVERT: a51ab052f15 Auto merge of #99541 - timvermeulen:flatten_cleanup, r=the8472 REVERT: 472cb76f1f1 Inline `>::from` REVERT: 59f5c5f0ee6 clarify lib.rs attribute structure REVERT: c3831c59c15 silence some unused-fn warnings in miri std builds REVERT: 10a98559f19 make many std tests work in Miri REVERT: e751a7f0df4 add some Miri-only tests REVERT: b76e699fdbf add miri-test-libstd support to libstd REVERT: 3814e4e12d4 Avoid zeroing a 1kb stack buffer on every call to `std::sys::windows::fill_utf16_buf` REVERT: 5e7aa9fac84 Auto merge of #98655 - nnethercote:dont-derive-PartialEq-ne, r=dtolnay REVERT: 677b7e8de08 Address reviewer comments REVERT: 3d23fb77caa Windows: Load synch functions together REVERT: 2906f08a20c Remove unstable Result::into_ok_or_err REVERT: 54af1f462a6 Rollup merge of #100661 - PunkyMunky64:patch-1, r=thomcc REVERT: edd3ee0613a Rollup merge of #100660 - PunkyMunky64:patch-2, r=thomcc REVERT: 4557de48534 Rollup merge of #100532 - RalfJung:unwind-miri, r=Mark-Simulacrum REVERT: 5dfde388140 Mitigate Stale Data Read for xAPIC vulnerability REVERT: cb4e95a9608 Make slice::reverse const REVERT: 2d56ff63127 Fixed a few documentation errors REVERT: 2abe27cbf1d Fixed a few documentation errors REVERT: f7dfde43354 Update src/test/assembly/x86_64-floating-point-clamp.rs REVERT: 8af9197f394 Update fortanix-sgx-abi and export some useful SGX usercall traits REVERT: 9a080d2b862 Simplify `IpDisplayBuffer` API. REVERT: fa2df13061a Use `MaybeUninit` for `IpDisplayBuffer`. REVERT: 8b9c148d198 Move `IpDisplayBuffer` into submodule. REVERT: 88794b3cf79 Add `IpDisplayBuffer` helper struct. REVERT: 041847ffa70 Refactor copying data to userspace REVERT: 7acb79879f7 Rollup merge of #100460 - cuviper:drop-llvm-12, r=nagisa REVERT: 443f90e06e5 Auto merge of #100007 - ChrisDenton:dtor-inline-never, r=michaelwoerister REVERT: d7fe67145af Optimize poison guards to ZSTs when panic=abort REVERT: ee095781a77 unwind: don't build dependency when building for Miri REVERT: 85f51a78128 Fix trailing space showing up in example REVERT: 4ae5f6cd5df Say that the identity holds only for all finite numbers (aka not NaN) REVERT: 58eb8d3f053 Semicolon after macro_rules definition. REVERT: 30bdf3e425b Float biteq macros can be unused if test is skipped. REVERT: fb5fe8edfae Skip next_up/down tests entirely on x87. REVERT: 478297f93eb Conditionally do not compile NaN roundtrip tests on x87 fp. REVERT: 93b85daa2c2 Added tracking issue numbers for float_next_up_down. REVERT: 2c5e66f4500 Ensure NaN references values go through function boundary for next_up/down. REVERT: 23740c1e10a Fixed float next_up/down 32-bit x87 float NaN roundtrip test case. REVERT: f6903cd3ecd Added next_up and next_down for f32/f64. REVERT: b444017f3bc Properly forward `ByRefSized::fold` to the inner iterator REVERT: 175c3b1f2e2 Auto merge of #96350 - austinabell:skip_optimization, r=Mark-Simulacrum REVERT: 3bb21a56bed Update the minimum external LLVM to 13 REVERT: 4cf12a0b1ea Rollup merge of #100249 - Meziu:master, r=joshtriplett REVERT: 049eb9ba9a6 fix(iter::skip): Optimize `next` and `nth` implementations of `Skip` REVERT: 67888a6daa2 Rollup merge of #100026 - WaffleLapkin:array-chunks, r=scottmcm REVERT: edf092e62fd Add mention of `BufReader` in `Read::bytes` docs REVERT: 7478b19850a Rollup merge of #100501 - RalfJung:miri-from-exposed-addr, r=Mark-Simulacrum REVERT: 8e66867a8e9 Rollup merge of #100407 - RalfJung:no-int2ptr, r=Mark-Simulacrum REVERT: 6c58de184ec nicer Miri backtraces for from_exposed_addr REVERT: 48439cf328c created tcpstream quickack trait for linux and android REVERT: c110dabc49a address review comments, add tracking issue REVERT: 2d64dd0e562 add Vec::push_within_capacity - fallible, does not allocate REVERT: 74c8d14da2e Tweak `FpCategory` example order. REVERT: 5f098696ffe Apply changes from rustfmt bump REVERT: 03855fdd542 Adjust cfgs REVERT: 10bf699d6b4 Clarify `array:from_fn` documentation REVERT: 3130a65bfec Rollup merge of #100255 - thedanvail:issue-98861-fix, r=joshtriplett REVERT: 90ad40fc387 Rollup merge of #100030 - WaffleLapkin:nice_pointer_sis, r=scottmcm REVERT: f37bab67834 Rollup merge of #100022 - joboet:faster_threadid, r=joshtriplett REVERT: 0dc5f013b85 fill-in tracking issue for `feature(iter_array_chunks)` REVERT: e9680b9f714 address review comments REVERT: 82cba72eb6b Auto merge of #99624 - vincenzopalazzo:macros/unix_error, r=Amanieu REVERT: 414a85ccd11 Rollup merge of #100418 - tbodt:stabilize-backtrace, r=dtolnay REVERT: b2f1c9b15fd Rollup merge of #100203 - compiler-errors:command-args-size-hint, r=m-ou-se REVERT: 2b263bc2dc9 Rollup merge of #100112 - RalfJung:assert_send_and_sync, r=m-ou-se REVERT: 8304b0b2c0a Rollup merge of #99511 - RalfJung:raw_eq, r=wesleywiser REVERT: 189e921c4ba Rollup merge of #99421 - Bryanskiy:android-crt-static, r=petrochenkov REVERT: 630e4e55016 Add stability attributes to BacktraceStatus variants REVERT: c35be99ab2d Rollup merge of #100287 - cuviper:no-linux-prctl, r=Mark-Simulacrum REVERT: 66e83eed13c Rollup merge of #100184 - Kixunil:stabilize_ptr_const_cast, r=m-ou-se REVERT: 0f7458d618f avoid some int2ptr casts in thread_local_key tests REVERT: ed5f44bfaca more typos REVERT: dc15d9aa1da Rollup merge of #100030 - WaffleLapkin:nice_pointer_sis, r=scottmcm REVERT: b760f2e8baa Rollup merge of #100007 - ChrisDenton:dtor-inline-never, r=michaelwoerister REVERT: 461b6bd6e68 Auto merge of #100298 - BlackHoleFox:hashmap_keygen_cleanup, r=Mark-Simulacrum REVERT: 59704d2f8f0 promote debug_assert to assert REVERT: 1e5e0471cb1 Auto merge of #99174 - scottmcm:reoptimize-layout-array, r=joshtriplett REVERT: d2ce2260f48 grammar REVERT: 12afff25951 add crt-static for android REVERT: 90524d2a064 Rollup merge of #100371 - xfix:inline-from-bytes-with-nul-unchecked-rt-impl, r=scottmcm REVERT: 43921a098cc Rollup merge of #100353 - theli-ua:master, r=joshtriplett REVERT: cff10712f89 Stabilize ptr_const_cast REVERT: 96090b2f021 std: optimize thread ID generation REVERT: 752a5ac7a09 Inline CStr::from_bytes_with_nul_unchecked::rt_impl REVERT: 90da4a987a7 Rollup merge of #100345 - vincenzopalazzo:macros/is_number_doc, r=joshtriplett REVERT: f7e9f7553c4 Rollup merge of #100332 - eholk:stabilize-ilog, r=scottmcm REVERT: 565f44768f1 Rollup merge of #99573 - tbodt:stabilize-backtrace, r=yaahc REVERT: c76ca6232dd Fix doc links in core::time::Duration::as_secs REVERT: 42d30f44148 Apply suggestions from code review REVERT: 39efb6b68bd docs: remove repetition REVERT: a4ad8781b33 Switching documentation to be more clear about potential errors REVERT: 22c25511aec Merge branch 'rust-lang:master' into issue-98861-fix REVERT: dfb33276a4d Rename integer log* methods to ilog* REVERT: 494a0175a05 move an `assert!` to the right place REVERT: 27e3354a70a Guarantee `try_reserve` preserves the contents on error REVERT: 2d3c27a51e6 Replace pointer casting in hashmap_random_keys with safe code REVERT: ebd860cbdf8 Update Duration::as_secs doc to point to as_secs_f64/32 for including fractional part REVERT: 6e27e1520b5 Add standard C error function aliases REVERT: 352303317de linux: Use `pthread_setname_np` instead of `prctl` REVERT: 6aa265b246a Adding more verbose documentation for `std::fmt::Write` REVERT: 82cc3359d45 Add Tuple marker trait REVERT: 09993feec19 Rollup merge of #100206 - RalfJung:miri-terminfo, r=thomcc REVERT: c12475ef9e7 Fix HorizonOS regression in FileTimes REVERT: 9b46cf7a563 test: skip terminfo parsing in Miri REVERT: 7f1acd94215 Rollup merge of #100175 - fxn:patch-1, r=Mark-Simulacrum REVERT: 90ab34badd8 Rollup merge of #100169 - WaffleLapkin:optimize_is_aligned_to, r=workingjubilee REVERT: 793ab478db0 Rollup merge of #100127 - ChrisDenton:remove-init, r=thomcc REVERT: f76b679d924 proc_macro/bridge: send diagnostics over the bridge as a struct REVERT: 0fd56a3ec9d provide correct size hint for unsupported platform CommandArgs REVERT: eb97960f634 ascii -> ASCII in code comment REVERT: 2026507feb7 non-linux platforms REVERT: 93aa20bb6c3 Optimize `pointer::as_aligned_to` REVERT: 9dd04db0581 improve documentation of `pointer::align_offset` REVERT: a8fc0a89b0e cleanup code w/ pointers in std a little REVERT: 7c47c1475a5 Move `rfold` logic into `iter_rfold` REVERT: 5d7bebdb274 Move `fold` logic to `iter_fold` method and reuse it in `count` and `last` REVERT: d75d154fc12 Move shared logic of `try_rfold` and `advance_back_by` into `iter_try_rfold` REVERT: 745162be4b9 Move shared logic of `try_fold` and `advance_by` into `iter_try_fold` REVERT: 5015690764c Add some docs for BorrowBuf REVERT: b27d4c0a2a1 std::io: migrate ReadBuf to BorrowBuf/BorrowCursor REVERT: a8e00e60d70 Update after code review REVERT: 85e520c390f kmc-solid: Add a stub implementation of `File::set_times` REVERT: 610884135fa Remove self-referential intra-doc links. REVERT: 17a75fe5d0f Document that `RawWakerVTable` functions must be thread-safe. REVERT: 5af2958536c Remove Windows function preloading REVERT: c4d74782465 Add visibility modifier to compat macro REVERT: befa69ac9ad FilesTimes support does not build for ESP-IDF REVERT: ab71e4efe37 actually call assert_send_and_sync REVERT: 69a07a7604d Auto merge of #100023 - saethlin:send-sync-chunksmut, r=m-ou-se REVERT: f7b2b8a3eec Rollup merge of #99800 - sandydoo:bugfix/wasm-futex, r=m-ou-se REVERT: 69d01a2c10d Rollup merge of #99614 - RalfJung:transmute-is-not-memcpy, r=thomcc REVERT: 5979d84c664 Rollup merge of #99371 - ChrisDenton:simplify-gen-random-keys, r=thomcc REVERT: 58f22f4a43b wordsmithing REVERT: 3183ef5a5c4 Stabilize backtrace REVERT: e3047afc7c0 Auto merge of #92268 - jswrenn:transmute, r=oli-obk REVERT: 7b32f6c5b2d make slice::{split_at,split_at_unchecked} const functions REVERT: e78cbefed2b Auto merge of #99977 - BlackHoleFox:cfte-cstr, r=thomcc REVERT: d85424cea7f Use `next_chunk` in `ArrayChunks` impl REVERT: cae2fc69bfb Auto merge of #100048 - matthiaskrgr:rollup-agimvm6, r=matthiaskrgr REVERT: f12bb7bcf51 Rollup merge of #100017 - solid-rs:patch/kmc-solid/adapt-to-78802, r=thomcc REVERT: 59b9f62cebf remove fn backtrace REVERT: 883dba5a1f5 Simplify `ArrayChunks::{,r}fold` impls REVERT: 4c956485585 Simplify `ArrayChunks::is_empty` REVERT: 46883f44369 Remove `Fuse` from `ArrayChunks` implementation REVERT: 57b0b208fdc Use `#[track_caller]` to make panic in `Iterator::array_chunks` nicer REVERT: 73359568b63 Remove incorrect impl `TrustedLen` for `ArrayChunks` REVERT: 60d9c7c06e6 Add back Send and Sync impls on ChunksMut iterators REVERT: 415e522565f Forward `ArrayChunks::next{,_back}` to `try_{for_each,rfold}` REVERT: 89be22f2f7b Remove `array::IntoIter::with_partial` -- an artifact of the past, once used to create an `IntoIter` from its parts REVERT: f6a6aedd0ff Use `array::IntoIter` for the `ArrayChunks` remainder REVERT: 2a9e9160426 Add `Iterator::array_chunks()` REVERT: 7bbfc2b9505 kmc-solid: Adapt to a recent change in the `IntoInner` impl of `SocketAddr` REVERT: 9aba70bc21f Auto merge of #98246 - joshtriplett:times, r=m-ou-se REVERT: d8310f8b7ae Never inline Windows dtor access REVERT: 5e86cda3990 Don't derive `PartialEq::ne`. REVERT: df60d32b508 Rollup merge of #99984 - ChrisDenton:fix-miri, r=Mark-Simulacrum REVERT: 5efbd57d271 Rollup merge of #99932 - madsmtm:fix-unwinding-debug-assertions, r=Amanieu REVERT: 69cf66951d4 Add validation to const fn CStr creation REVERT: 7ddaa526832 Make sure `symbol_name` is const evaluated REVERT: 0045acf8f94 Auto merge of #78802 - faern:simplify-socketaddr, r=joshtriplett REVERT: 13c703b48f6 Fix compat.rs for `cfg(miri)` REVERT: 3e45bbb4371 typo REVERT: 3781a15938b Auto merge of #99553 - ChrisDenton:lazy-compat-fn, r=Mark-Simulacrum REVERT: 00f3aa1e0aa Rollup merge of #99937 - ChrisDenton:fix-remove-dir-all-win-7, r=joshtriplett REVERT: 3431ed11537 Fix warnings in stubbed out set_times REVERT: 8fb7f2aae27 Original branch seems to have missed excluding the benchmark range from the globally reachable change REVERT: f01b1c1e2a6 Reincorporated changes from #87689 REVERT: f937e1c2ad4 Change `Ipv4Addr::is_global` to be in line with `Ipv6Addr::is_global` REVERT: 489d823d428 Fix `Ipv6Addr::is_global` to check for global reachability rather than global scope REVERT: 0b613244177 Reset directory iteration in remove_dir_all REVERT: 28ac0e31398 Fix unwinding when debug assertions are enabled REVERT: c84e46daedb Remove socklen_t from platforms where it's no longer used REVERT: dc31f079999 proc_macro: use crossbeam channels for the proc_macro cross-thread bridge REVERT: 3b3ccdd1699 Rollup merge of #99781 - workingjubilee:demo-string-from-cstr, r=thomcc REVERT: 808679f2ca6 EscapeAscii is not an ExactSizeIterator REVERT: 620ff66bb4b Rollup merge of #99689 - dtolnay:write, r=Mark-Simulacrum REVERT: 80c991d191f Rollup merge of #99628 - vincenzopalazzo:macros/is_number_doc, r=joshtriplett REVERT: 1dc7d0fe536 add more docs regarding ideographic numbers REVERT: f469214d9c9 Rollup merge of #99723 - bstrie:wasifd, r=yaahc REVERT: d83ab1ef98d Auto merge of #99182 - RalfJung:mitigate-uninit, r=scottmcm REVERT: 71f66b75fbf safe transmute: reference tracking issue REVERT: c131dfb62bb safe transmute: add `rustc_on_unimplemented` to `BikeshedIntrinsicFrom` REVERT: 1166797b877 Initial (incomplete) implementation of transmutability trait. REVERT: 2983d5a12ad Rollup merge of #94247 - saethlin:chunksmut-aliasing, r=the8472 REVERT: 8bdc6782aad Allow using stable os::fd::raw items through unstable os::wasi module REVERT: 70974d32090 Auto merge of #99802 - JohnTitor:rollup-uaklql1, r=JohnTitor REVERT: dcd70a9f6eb Rollup merge of #99704 - fee1-dead-contrib:add_self_tilde_const_trait, r=oli-obk REVERT: b6e02c9098b Auto merge of #98748 - saethlin:optimize-bufreader, r=Mark-Simulacrum REVERT: 83bb90478fc Fix futex module imports on wasm+atomics REVERT: 1ccd1614ed9 Auto merge of #99792 - JohnTitor:rollup-20i7ewx, r=JohnTitor REVERT: 0cb00679d28 Rollup merge of #98583 - joshtriplett:stabilize-windows-symlink-types, r=thomcc REVERT: c6af9c99c90 Clarify safety comments REVERT: 37103d7561a Auto merge of #98553 - the8472:next_chunk_opt, r=Mark-Simulacrum REVERT: 1d16507c1b2 Add Buffer::consume_with to enable direct buffer access with one check REVERT: d2311262a16 Explain how *mut [T] helps, and how we rely on the check in split_at_mut REVERT: 8cc4ccbc121 Force the Cow into a String REVERT: 1f09f051971 Use String::from_utf8_lossy in CStr demo REVERT: a2009b6b39b add test for vec::IntoIter::next_chunk() impl REVERT: cbc5cfb0937 Auto merge of #99574 - durin42:allocator-patch-redux, r=nikic REVERT: 92815441823 Optimized vec::IntoIter::next_chunk impl REVERT: 2ff2b55aeea Rollup merge of #99757 - asquared31415:patch-1, r=Dylan-DPC REVERT: 3f944849a2f Rollup merge of #99716 - sourcelliu:iomut, r=Mark-Simulacrum REVERT: 222b1443fa5 Add `Self: ~const Trait` to traits with `#[const_trait]` REVERT: 0520b11b777 codegen: use new {re,de,}allocator annotations in llvm REVERT: 2b713bbf37f Rewrite Windows `compat_fn` macro REVERT: 059eb39f295 Make `transmute_copy` docs read better REVERT: 982dbf84277 Rollup merge of #99692 - RalfJung:too-far, r=oli-obk REVERT: 483fbac63de Rollup merge of #98211 - devnexen:get_path_freebsd, r=Mark-Simulacrum REVERT: 01b50db76a4 Add comments about stdout locking REVERT: 9637cc17337 Implement `fs::get_path` for FreeBSD. REVERT: 1592a7f3bdc Rollup merge of #99703 - dtolnay:tokenstreamsizehint, r=petrochenkov REVERT: a91ffc42c7f Rollup merge of #99084 - RalfJung:write_bytes, r=thomcc REVERT: 648971ded55 Rollup merge of #98710 - mojave2:string, r=JohnTitor REVERT: 954a3029f2c Rollup merge of #92390 - fee1-dead-contrib:const_cmp, r=oli-obk REVERT: 5a9b467f912 Rollup merge of #99690 - RalfJung:miri-track-caller, r=Mark-Simulacrum REVERT: 9ebc81edfb9 Rollup merge of #95916 - solid-rs:feat-kmc-solid-abort, r=Mark-Simulacrum REVERT: c1c5883c351 Rollup merge of #95040 - frank-king:fix/94981, r=Mark-Simulacrum REVERT: b3f8c9b55c5 remove useless mut from examples REVERT: 9aba0156ba8 Expose size_hint() for TokenStream's iterator REVERT: aef4cc5f41d Auto merge of #97581 - AngelicosPhosphoros:improve_calloc_check_in_vec_macro_for_tuples, r=Mark-Simulacrum REVERT: 36aba53421f interpret, ptr_offset_from: refactor and test too-far-apart check REVERT: c7fc2b784b1 Support vec zero-alloc optimization for tuples and byte arrays REVERT: 0de4b596477 add miri-track-caller to some intrinsic-exposing methods REVERT: a8eeff8bb90 Revert write! and writeln! to late drop temporaries REVERT: c3eb5d85419 Rollup merge of #99657 - Phosra:patch-1, r=Dylan-DPC REVERT: 79ba6da517d Rename and document the new BufReader internals REVERT: 40576070e7e Allow Buffer methods to inline REVERT: 2af11879bc4 Remove some redundant checks from BufReader REVERT: 94992b026f9 add const hack comment REVERT: efcff5b4bfc Add issue numbers REVERT: dc308e9721f Constify a few const `(Partial)Ord` impls REVERT: 66c2cb72de1 Auto merge of #98674 - RalfJung:miri-stacktrace-pruning, r=Mark-Simulacrum REVERT: d9bbc5be11b Remove `mut` REVERT: 7c2eb10b584 Rollup merge of #99627 - saethlin:lock-once, r=eddyb REVERT: 873cb1ece2f Auto merge of #97925 - the8472:cgroupv1, r=joshtriplett REVERT: 06b107d4d35 say some more things about how transmute is UB REVERT: f668d3473ff Auto merge of #93397 - joshtriplett:sort-floats, r=Amanieu REVERT: 834299760e1 Lock stdout once when listing tests REVERT: 9afee229a59 [review] mention that runtime may scale with # of mountpoints REVERT: 3ed4422013c do not claim that transmute is like memcpy REVERT: 62bbc8bbfcf adjust UnsafeCell documentation REVERT: a6f01a97d9c Recover error strings on Unix from_lossy_utf8 REVERT: 4f98905dca7 Stub out `set_times` to return unsupported on Redox REVERT: f0a33a15c56 Auto merge of #99491 - workingjubilee:sync-psimd, r=workingjubilee REVERT: 0396f7a2655 Rollup merge of #99579 - CleanCut:expect-warning, r=joshtriplett REVERT: 03c8064ef56 Rollup merge of #98174 - Kixunil:rename_ptr_as_mut_const_to_cast, r=scottmcm REVERT: 86e4dfe1a43 document memory orderings of `thread::{park, unpark}` REVERT: a133a5f63b2 Auto merge of #99420 - RalfJung:vtable, r=oli-obk REVERT: 4d16d8c238f add same warning to Result::expect as Result::unwrap REVERT: 9565b7a02b4 Remove redundant lifetime bound from `impl Borrow for Cow` REVERT: 61795ae718e Box::from(slice): Clarify that contents are copied REVERT: 5bb632b0b85 Rollup merge of #99523 - cuviper:asfd_ptrs-1.64, r=jyn514 REVERT: 06473ebf590 Rollup merge of #99454 - benluelo:control-flow/continue-combinators, r=scottmcm REVERT: 41a6cd22eb9 Rollup merge of #99413 - steffahn:btree_dropck, r=m-ou-se REVERT: 6caabf9ca27 Rollup merge of #98707 - joboet:fuchsia_locks, r=m-ou-se REVERT: 673b27821f6 Rename `<*{mut,const} T>::as_{const,mut}` to `cast_` REVERT: cda80c2f469 fixup! docs: Improve AsRef / AsMut docs on blanket impls REVERT: 440be6a5407 remove unused import REVERT: df761a70626 Introduce core::simd trait imports in tests REVERT: 77797c5cfbf Sync core::simd up to rust-lang/portable-simd@2e081db92aa3ee0a4563bc28ce01bdad5b1b2efd REVERT: d81c8238bac add #inline REVERT: 4e404e50f17 various nits from review REVERT: d71b7ffdd71 use extern type for extra opaqueness REVERT: e37f64ca118 incorporate some review feedback REVERT: 6f952982f6a add intrinsic to access vtable size and align REVERT: 3e9875417e6 prune raw pointer read and write methods from Miri backtraces REVERT: 5b8d4190751 miri: prune some atomic operation details from stacktrace REVERT: 313211795b6 Add map_continue and continue_value combinators to ControlFlow REVERT: 2ffeeff16aa Fix the stable version of `AsFd for Arc` and `Box` REVERT: 0888cf4bd0c Rollup merge of #99516 - m-ou-se:proc-macro-tracked-tracking-issue, r=Mark-Simulacrum REVERT: b2d84651bf2 Use new tracking issue for proc_macro::tracked_*. REVERT: e00be119e36 fix typo REVERT: 9e0aa8eb983 make raw_eq precondition more restrictive REVERT: 83b1c172840 owner is not micro (correct typo) REVERT: a17afcc863d Rollup merge of #98101 - vladimir-ea:stdlib_watch_os, r=thomcc REVERT: 37a5a213fec Library changes for Apple WatchOS REVERT: ec65dbf8c84 Rollup merge of #99452 - Stargateur:fix/typo, r=JohnTitor REVERT: 05d4823d7b1 Rollup merge of #98916 - ChrisDenton:hiberfil.sys, r=thomcc REVERT: 6f2dd9faf30 generated code REVERT: 63f5e5275e9 fixup! docs: Improve AsRef / AsMut docs on blanket impls REVERT: c1ea95f3076 fixup! docs: Improve AsRef / AsMut docs on blanket impls REVERT: bdeb414fe62 Auto merge of #98180 - notriddle:notriddle/rustdoc-fn, r=petrochenkov,GuillaumeGomez REVERT: f89a1dc3476 Use `T` for all the function primitive docs lists REVERT: c70e1ff6837 Improve the function pointer docs REVERT: 866bc82a0ac Auto merge of #99462 - matthiaskrgr:rollup-ihhwaru, r=matthiaskrgr REVERT: 5b83bb115f7 Rollup merge of #99438 - WaffleLapkin:dont_wrap_in_non_zero, r=compiler-errors REVERT: fa24ffc320a Rollup merge of #99419 - yoshuawuyts:stabilize-task-ready, r=Mark-Simulacrum REVERT: 36a8142880e Auto merge of #98912 - nrc:provider-it, r=yaahc REVERT: 3cc9ce0331d docs: Improve AsRef / AsMut docs on blanket impls REVERT: 58544bbbdd0 Auto merge of #99451 - Dylan-DPC:rollup-ceghu18, r=Dylan-DPC REVERT: b79a6774e4b int_macros was only using to_xe_bytes_doc and not from_xe_bytes_doc REVERT: 73ddd7d9c80 Rollup merge of #99434 - timvermeulen:skip_next_non_fused, r=scottmcm REVERT: f197788af65 Rollup merge of #99335 - Dav1dde:fromstr-docs, r=JohnTitor REVERT: c6578b06cbe Auto merge of #98189 - mystor:fast_ident_literal, r=eddyb REVERT: 4bdf37b8b0b Suggest a fix for `NonZero*` <- `*` coercion error REVERT: dad38a502f8 Add note to test about `Unfuse` REVERT: ddf513c90af Fix `Skip::next` for non-fused inner iterators REVERT: f5f403c7d96 proc_macro: Move subspan to be a method on Span in the bridge REVERT: ea9bab0b20b proc_macro: stop using a remote object handle for Literal REVERT: 6e0b2dde060 proc_macro: stop using a remote object handle for Ident REVERT: 6080f8080be proc_macro: Specialize Punct::to_string REVERT: ad794178155 proc_macro: use fxhash within the proc_macro crate REVERT: 82efa0e040e Rollup merge of #99198 - RalfJung:alloc-null-ptr, r=JohnTitor REVERT: 992f1f9d9bc Rollup merge of #98839 - 5225225:assert_transmute_copy_size, r=thomcc REVERT: 25edb060c11 Ignore `hiberfil_sys` test in CI REVERT: 5b8e1429656 stabilize `core::task::ready!` REVERT: 2390796bb88 Add `PhantomData` marker for dropck to `BTreeMap` REVERT: 39b799be8cd Auto merge of #99223 - saethlin:panicless-split-mut, r=Mark-Simulacrum REVERT: d4eb0a08db8 std: panic instead of deadlocking in mutex implementation on Fuchsia REVERT: 6a6a1c863ee Use split_once in FromStr docs REVERT: 5d3c9e43844 Rollup merge of #99374 - TethysSvensson:patch-1, r=Dylan-DPC REVERT: b0eb0652cf2 Rollup merge of #98383 - m-ou-se:remove-memory-order-restrictions, r=joshtriplett REVERT: b50ffb28216 rustdoc: extend `#[doc(tuple_variadic)]` to fn pointers REVERT: 0846dcbec41 Add tests that check `Vec::retain` predicate execution order. REVERT: 3fe05e01f89 Fix for `rchunks_exact` doc REVERT: 26926753c93 Simplify Windows `hashmap_random_keys` REVERT: c5e7da85f89 Move SocketAddrCRepr to sys_common REVERT: 56123b33291 Rollup merge of #99306 - JohnTitor:stabilize-future-poll-fn, r=joshtriplett REVERT: a943d5adf5a Rollup merge of #99302 - yaahc:gma-tracking-issue, r=joshtriplett REVERT: 104d02be070 Rollup merge of #99088 - niklasf:stabilize-process_set_process_group, r=joshtriplett REVERT: da95af4d5b1 Rollup merge of #97915 - tbu-:pr_os_string_fmt_write, r=joshtriplett REVERT: 3131d32ecfe Rollup merge of #94927 - c410-f3r:stabilize-let-chains, r=joshtriplett REVERT: 087a7c162d9 Auto merge of #98866 - nagisa:nagisa/align-offset-wroom, r=Mark-Simulacrum REVERT: c2b9eaf1a7e Stabilize `let_chains` REVERT: ed93b1bda60 Add a special case for align_offset /w stride != 1 REVERT: ae22755d0ea Expand documentation for `process_group` REVERT: cb683460128 Update `since` version to 1.64 REVERT: aab337aa3fa Rollup merge of #99317 - yanchith:borrow-vec-ta-as-slice-t, r=Mark-Simulacrum REVERT: 12d0d10dac9 Parametrize a few more things REVERT: ae6b449818a Mark lifetimes explicitly REVERT: 1f047c41491 Parametrize BinaryHeap with Allocator REVERT: 071e40c1982 Rearrange slice::split_mut to remove bounds check REVERT: 26d68d58db5 Borrow Vec as [T] REVERT: c90fc6b9db2 Rollup merge of #99277 - joshtriplett:stabilize-core-cstr-alloc-cstring, r=Mark-Simulacrum REVERT: 283b24c65e4 Rollup merge of #99270 - rhysd:issue-99269, r=Mark-Simulacrum REVERT: d0309e07cb5 Rollup merge of #99264 - eltociear:patch-14, r=compiler-errors REVERT: 87f40dc0905 Rollup merge of #98662 - LucasDumont:document_fs_write, r=thomcc REVERT: aa7b8c60f07 Rollup merge of #98387 - NobodyXu:feature/std_io_Error_try_downgrade_inner, r=yaahc REVERT: 2d1aa573bd9 Stabilize `future_poll_fn` REVERT: 54cc7d020a7 add tracking issue to generic member access APIs REVERT: 0249e3cad01 Apply suggestions from code review REVERT: f6e06297e02 Mark stabilized intrinsics with `rustc_allowed_through_unstable_modules` REVERT: 25287eadeac Stabilize `core::ffi::CStr`, `alloc::ffi::CString`, and friends REVERT: c0978700444 Don't fall back to futimes on Android; it needs a newer API level than futimens REVERT: a55f5b30ce4 Also use fallback for futimens on Android REVERT: 5e7983a038c Return an error if trying to set a file timestamp to 0 on Windows REVERT: 1eeec706610 Add alias `File::set_modified` as shorthand REVERT: 37b57cb51d2 Support setting file accessed/modified timestamps REVERT: 023f10270e8 add `#[must_use]` to `Box::from_raw` REVERT: abbb68c5d55 Rollup merge of #99113 - WaffleLapkin:arc_simplify, r=Mark-Simulacrum REVERT: feecd3101ba Fix typo in mod.rs REVERT: 62aa0b398cf Improve example of `downcast` REVERT: 4213e8ab343 lint: remove unnecessary parentheses REVERT: 6e814083094 Auto merge of #99242 - Dylan-DPC:rollup-34bqdh8, r=Dylan-DPC REVERT: 513539998d8 add missing null ptr check in alloc example REVERT: 7b6d7e15782 add code examples REVERT: 08eb51227a7 doc: clearer and more correct Iterator::scan REVERT: fe178983d78 Rollup merge of #98072 - yaahc:generic-member-access, r=thomcc REVERT: 87e57f18525 Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillot REVERT: 03ded36c2ed Rollup merge of #98315 - joshtriplett:stabilize-core-ffi-c, r=Mark-Simulacrum REVERT: 5f6224ac506 Stabilize `core::ffi:c_*` and rexport in `std::ffi` REVERT: d3fe1beef2b Rename `std::io::Error::try_downcast_inner` to `downcast` REVERT: 5e78d984187 rustdoc REVERT: 0377f74b02c typo REVERT: a6fb8ef1c4d changes to wording REVERT: 658969971ec Re-optimize `Layout::array` REVERT: 68496dabf6d Auto merge of #99136 - CAD97:layout-faster, r=scottmcm REVERT: d0e61db94d2 docs: be less harsh in wording for Vec::from_raw_parts REVERT: a88155ef4d5 Rollup merge of #99011 - oli-obk:UnsoundCell, r=eddyb REVERT: 3a162e804a8 Rollup merge of #99148 - SOF3:clarify-xsize-bound, r=scottmcm REVERT: b690c6d43b5 Add a `File::create_new` constructor REVERT: 2dcf0285c49 mention mitigation in the docs REVERT: 4a4e7c045ba mem::uninitialized: mitigate many incorrect uses of this function REVERT: 33ec1d0efda std: fix issue with perma-locked mutexes on Fuchsia REVERT: 30c9499292b Remove duplication of layout size check REVERT: 9084952a831 apply suggestions from code review REVERT: 3882f0c13fd remove a dubious example REVERT: 24cab02a822 typo REVERT: fd9367b287e Add Read Impl for &Stdin REVERT: 48614232c2e Auto merge of #97841 - nvzqz:inline-encode-wide, r=thomcc REVERT: 70b6d8258b8 Add std::fs::write documentation precision REVERT: a147e004b89 Clarify that [iu]size bounds were only defined for the target arch REVERT: b378918eb68 Take advantage of known-valid-align in layout.rs REVERT: c96eefe8c06 Rollup merge of #99094 - AldaronLau:atomic-ptr-extra-space, r=Dylan-DPC REVERT: fd2c0c75b30 Auto merge of #99112 - matthiaskrgr:rollup-uv2zk4d, r=matthiaskrgr REVERT: c518f9ad7a5 Use `byte_sub` in [a]rc impl REVERT: 19a8d9595b7 Rollup merge of #99109 - WaffleLapkin:atomic_ti, r=Dylan-DPC REVERT: 2ff10bfd7bf Rollup merge of #99100 - Smittyvb:test-cli-binary-name, r=thomcc REVERT: e7e5cb3d155 fill new tracking issue for `feature(strict_provenance_atomic_ptr)` REVERT: 0e4f9a7c4ca Auto merge of #95295 - CAD97:layout-isize, r=scottmcm REVERT: 41e73789710 Auto merge of #97522 - xfix:stabilize-slice-from-raw-parts, r=dtolnay REVERT: 02fde867325 Fix binary name in help message for test binaries REVERT: 3d0ca2c4452 Auto merge of #98950 - ChrisDenton:getoverlapped-io, r=thomcc REVERT: 49c239cfff1 Add T to PhantomData impl Debug REVERT: 59e95f74fc9 Partially stabilize const_slice_from_raw_parts REVERT: 74d877edf7b Remove extra space in AtomicPtr::new docs REVERT: a0e14afa19d add a concrete example REVERT: 3d911382742 clarify how write_bytes can lead to UB due to invalid values REVERT: e98ae979494 Rollup merge of #99067 - est31:to_owned_link, r=Dylan-DPC REVERT: 860408d40d7 Document and stabilize process_set_process_group REVERT: 744356b81f5 Rollup merge of #99070 - tamird:update-tracking-issue, r=RalfJung REVERT: 1388d0855b5 Update integer_atomics tracking issue REVERT: d951f619ceb add rt flag to allowed internal unstable for RustcEncodable/Decodable REVERT: dc136667f50 add opt in attribute for stable-in-unstable items REVERT: 6159b026a19 revert changes to unicode stability REVERT: 79619514b31 Support unstable moves via stable in unstable items REVERT: bd5db1aee6f Intra-doc-link-ify reference to Clone::clone_from REVERT: 4c032419b69 Rollup merge of #98718 - yoshuawuyts:stabilize-into-future, r=yaahc REVERT: 5fbe1de2c5b Rollup merge of #97917 - AronParker:master, r=ChrisDenton REVERT: 8ad7f4a5b5b Fix doc build on unsupported oses REVERT: 28fe47808c3 `UnsafeCell` now has no niches, ever. REVERT: 76f90563333 changes from feedback REVERT: 3bbf74122ee doc additions REVERT: 292a74ec934 socket `set_mark` addition. REVERT: 43287148b52 Rollup merge of #98971 - MinnDevelopment:patch-1, r=Dylan-DPC REVERT: bd652ed7831 Rollup merge of #98939 - GuillaumeGomez:rustdoc-disamb-impls, r=notriddle REVERT: 4fc07b77075 Rollup merge of #96935 - thomcc:atomicptr-strict-prov, r=dtolnay REVERT: 798747e6c60 Tests for unsound Windows file methods REVERT: 6ce408cf7bb Windows: Fallback for overlapped I/O REVERT: bc16cd303d4 Use `rtabort!` instead of `process::abort` REVERT: 3da311a666c Fix typo in file descriptor docs REVERT: 9409e818525 Fix links in std/core documentation REVERT: 5dca2964491 Add `BufRead::skip_until` REVERT: 3e389a9da80 core::any: replace some unstable generic types with impl Trait REVERT: 8876d0a252f Test if `[try_]exists` can find `hiberfil.sys` REVERT: caa628c209f Add comment and simplify `hiberfil_sys` test REVERT: 9deaf76208e Rollup merge of #97712 - RalfJung:untyped, r=scottmcm REVERT: b031ad3def0 Windows: Use `FindFirstFileW` if `metadata` fails REVERT: 4510f181c3b `impl From for FileAttr` REVERT: ad0852230e4 Rollup merge of #97300 - ChayimFriedman2:patch-1, r=dtolnay REVERT: 0d147af9c4c Auto merge of #97437 - jyn514:impl-asrawfd-arc, r=dtolnay REVERT: ae6cc6c2d23 Add size assert in transmute_copy REVERT: c1e3c5fc1b3 Auto merge of #98755 - nnethercote:faster-vec-insert, r=cuviper REVERT: 60c77cc1664 Auto merge of #98673 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum REVERT: ea21cb2e574 Fix slice::ChunksMut aliasing REVERT: ab79c1dc4f9 Bump std::net::Incoming FusedIterator impl to Rust 1.64 REVERT: a25e95d7461 Auto merge of #97235 - nbdd0121:unwind, r=Amanieu REVERT: 86d46080ddf Adjust for rustfmt order change REVERT: 18f04f6be69 Rollup merge of #98585 - cuviper:covariant-thinbox, r=thomcc REVERT: f445caa35fc update cfg(bootstrap)s REVERT: 836821f2003 Rename AtomicPtr::fetch_{add,sub}{,_bytes} REVERT: 13281dd575e Allow arithmetic and certain bitwise ops on AtomicPtr REVERT: 645cda86443 Auto merge of #98730 - matthiaskrgr:rollup-2c4d4x5, r=matthiaskrgr REVERT: fae168eb57a Optimize `Vec::insert` for the case where `index == len`. REVERT: 42f354accdf Rollup merge of #98503 - RalfJung:scope-race, r=m-ou-se REVERT: 3ac5a5691ef Rollup merge of #97629 - guswynn:exclusive_struct, r=m-ou-se REVERT: 8c5567b84ab clarify that ExactSizeIterator::len returns the remaining length REVERT: f709ec058a6 Stabilize `into_future` REVERT: bd00ac2d8d6 correct the output of a `capacity` method example REVERT: 550fa11d4a8 std: use futex-based locks on Fuchsia REVERT: 6f2af2ae69d nit REVERT: 04c0a53b6c1 Revert isize::MAX changes to Layout helpers REVERT: 7464c5b23c3 Rollup merge of #98652 - ojeda:warning-free-no_global_oom_handling, r=joshtriplett REVERT: 87cbd8c7b48 Rollup merge of #98516 - dlrobertson:uefi_va_list, r=joshtriplett REVERT: 9c271bb7547 Rollup merge of #98479 - leocth:atomic-bool-fetch-not, r=joshtriplett REVERT: 84280680a38 Only enable new cmpxchg memory orderings in cfg(not(bootstrap)). REVERT: 434039869d8 Remove restrictions on compare-exchange memory ordering. REVERT: 89870fc1542 Rollup merge of #97423 - m-ou-se:memory-ordering-intrinsics, r=tmiasko REVERT: 2a52036ac6b alloc: fix `no_global_oom_handling` warnings REVERT: 151a8d81170 Follow C-RW-VALUE in std::io::Cursor example REVERT: 20cf070487d Auto merge of #98632 - matthiaskrgr:rollup-peg868d, r=matthiaskrgr REVERT: 191ce070051 Rollup merge of #98617 - ChrisDenton:const-unwrap, r=Mark-Simulacrum REVERT: aab4fec496a Auto merge of #98188 - mystor:fast_group_punct, r=eddyb REVERT: acd7a54d984 review changes REVERT: 9a1c14a9b7b Add a fixme comment REVERT: 3872a87d1c1 Remove feature `const_option` from std REVERT: a4a43ad462a Rollup merge of #98595 - cuviper:send-sync-thinbox, r=m-ou-se REVERT: 7d1b6134450 Rollup merge of #98555 - mkroening:hermit-lock-init, r=m-ou-se REVERT: 34743b9df7a Rollup merge of #98430 - camsteffen:flatten-refactor, r=joshtriplett REVERT: 943172197af Rename/restructure memory ordering intrinsics. REVERT: bf1983a1583 Auto merge of #98324 - conradludgate:write-vectored-vec, r=Mark-Simulacrum REVERT: 255e205a4b5 Implement `Send` and `Sync` for `ThinBox` REVERT: d2fabf8fe67 fix data race in thread::scope REVERT: 6060e253df7 Rollup merge of #98587 - RalfJung:core-tests, r=thomcc REVERT: b13fed329d4 Rollup merge of #98579 - RalfJung:alloc-tests, r=thomcc REVERT: b70062e78b5 Seal Windows `FileTypeExt` extension trait to allow adding future methods REVERT: 25c5bff14ae libcore tests: avoid int2ptr casts REVERT: 35d97f51a59 Make `ThinBox` covariant in `T` REVERT: 775fb63ad00 Stabilize Windows `FileTypeExt` with `is_symlink_dir` and `is_symlink_file` REVERT: e25f9a62a68 liballoc tests: avoid int2ptr cast REVERT: 218bf912f83 make Condvar, Mutex, RwLock const constructors work with unsupported impl REVERT: 019796517bc proc_macro: stop using a remote object handle for Group REVERT: 827dcc6cffd proc_macro: stop using a remote object handle for Punct REVERT: 9acd5daa20a Fix spelling in SAFETY comment REVERT: 095a090bb6d Auto merge of #98187 - mystor:fast_span_call_site, r=eddyb REVERT: ad15a0311b6 Hermit: Make Mutex::init a no-op REVERT: 8a8b5fc21aa Hermit: Fix initializing lazy locks REVERT: 0e1d3bc3bf4 Rollup merge of #98541 - Veykril:patch-2, r=Dylan-DPC REVERT: 28c8ea25c10 Rollup merge of #97908 - iago-lito:stabilize_nonzero_checked_ops_constness, r=scottmcm REVERT: 306622264ad Rollup merge of #97140 - joboet:solid_parker, r=m-ou-se REVERT: 4a0c2045c0f proc_macro: Rename ExpnContext to ExpnGlobals, and unify method on Server trait REVERT: 75aebc27696 attempt to optimise vectored write REVERT: 76e1987aa8a Auto merge of #98190 - nnethercote:optimize-derive-Debug-code, r=scottmcm REVERT: 1775f480498 Update `std::alloc::System` docs REVERT: f7bec194880 Update `since` to 1.64 (since we're after 1.63) REVERT: b746e2ffc55 forgot about the feature flag in the doctest REVERT: 7a72c0acb26 library: fix uefi va_list type definition REVERT: eb3f74d8f40 proc_macro: remove Context trait, and put span methods directly on Server REVERT: 62684fff56c temporarily remove tests because I'm not sure if we need them REVERT: 2de3bd65cfc Auto merge of #98486 - matthiaskrgr:rollup-u7m508x, r=matthiaskrgr REVERT: 18e7014c78d proc_macro: cache static spans in client's thread-local state REVERT: 40ea355166e Rollup merge of #98194 - m-ou-se:leak-locked-pthread-mutex, r=Amanieu REVERT: 34ab0fc994e Rollup merge of #98126 - fortanix:raoul/mitigate_stale_data_vulnerability, r=cuviper REVERT: c4c39b74abf Rollup merge of #96412 - ChrisDenton:remove-dir-all, r=thomcc REVERT: 55a1034ec1b Auto merge of #96820 - r-raymond:master, r=cuviper REVERT: b34bd7bbe08 Add feature gate `#![atomic_bool_fetch_not]` REVERT: 59805f24426 Auto merge of #93700 - rossmacarthur:ft/iter-next-chunk, r=m-ou-se REVERT: 9d93996cc7a add `fetch_not` method on `AtomicBool` REVERT: 4c3aa3daa8e scan mountinfo when hardcoded cgroupv1 mountpoints don't work REVERT: 00d1ec053fe Rollup merge of #98039 - tnballo:master, r=thomcc REVERT: c4da6f6dc45 Optimize the code produced by `derive(Debug)`. REVERT: 16be7af5d8f Fix BTreeSet's range API panic message, document REVERT: 6c75ee7eb97 Rollup merge of #98364 - RalfJung:arc-clone, r=Mark-Simulacrum REVERT: 48aa4de24cc Rollup merge of #96173 - jmaargh:jmaargh/with-capacity-doc-fix, r=Dylan-DPC REVERT: fe66e85ca27 Remove invalid doc comment on the size of an IP struct REVERT: de992d1043c Remove `is_known_utf8` checks from more tests where it's no longer set. REVERT: 374aba5ed24 Don't eagerly scan for `is_known_utf8` in `to_ascii_lowercase`/`uppercase`. REVERT: 2c821da224c Panic safety. REVERT: 29e6eaa27f0 Optimize `Wtf8Buf::into_string` for the case where it contains UTF-8. REVERT: a80ef85d975 Assign issue number to the new const_socketaddr REVERT: 0fd6876dd9b Add IP structural_match tests REVERT: b7fc560f8e4 Remove ntohs/htons in favor of to_be/from_be REVERT: a2cd63aaf30 Implement IpV{4,6}Addr structs with native Rust encoding REVERT: 757e3345f58 Represent SocketAddrV4 and SocketAddrV6 as Rust native encoding REVERT: f0253f0c022 add tracking issue for exclusive REVERT: e13969323f1 Use `unwrap` instead of `unwrap_unchecked` REVERT: 4d3546d9027 Refactor iter adapters with less macros REVERT: b877bb3f632 std: reimplement SGX thread joining to use `Parker` REVERT: ff01ccea68a std: rewrite SGX thread parker REVERT: a5032399307 Add new unit test `test_try_downcast_inner` REVERT: 63c9c6f6bd8 Add new unstable API `Error::try_downgrade_inner` REVERT: 9db755a2a0d Impl `io::error::repr_bitpacked::Repr::new` REVERT: 3f8cf82b170 Impl `io::error::repr_unpacked::Repr::new` REVERT: e79d605fd93 Address reviewer comments REVERT: 2527a8c5a0b Rollup merge of #98363 - RalfJung:btree-test-ref-alloc, r=thomcc REVERT: d28ec851075 Rollup merge of #97516 - RalfJung:atomics, r=joshtriplett REVERT: a8dee1d0563 Rollup merge of #96768 - m-ou-se:futex-fuchsia, r=tmandry REVERT: 663b5de1a15 clarify Arc::clone overflow check comment REVERT: ad5d9b983ab `impl AsFd for {Arc,Box}` REVERT: 55dd2c68ab0 `impl for {Arc,Box}` REVERT: 718027edd2a hedge our bets REVERT: 62f546f00ea remove use of &Alloc in btree tests REVERT: 9c0d5ec1743 Rollup merge of #98330 - conradludgate:io-slice-mut-docs, r=Dylan-DPC REVERT: 03ef7116364 Rollup merge of #98313 - m-ou-se:fix-comments, r=joshtriplett REVERT: 672de051a9f Rollup merge of #97269 - RalfJung:transmute, r=m-ou-se REVERT: 65cd9c23535 Rollup merge of #94033 - joshtriplett:documentation-is-running-better-go-catch-it, r=m-ou-se REVERT: ed5d0f6cea0 Use futex based thread parker on Fuchsia. REVERT: 6820a360145 update ioslice docs to use shared slices REVERT: 3af428eb376 Add `Iterator::next_chunk` REVERT: e05efbca64b Auto merge of #98307 - matthiaskrgr:rollup-rb3huha, r=matthiaskrgr REVERT: dc5c06de318 Add `[f32]::sort_floats` and `[f64]::sort_floats` REVERT: 23f25f71c1a Remove lies in comments. REVERT: 6abc72368f3 Improve docs for `is_running` to explain use case REVERT: 22c45ca55ce Rollup merge of #98296 - JohnTitor:generator-unstable-book-link, r=Dylan-DPC REVERT: 7891cb2afd0 Rollup merge of #98276 - compiler-errors:const-format-macro, r=oli-obk REVERT: abad4b831df Auto merge of #93765 - zhangyunhao116:heapsort, r=m-ou-se REVERT: 660db6c36de Add a link to the unstable book page on Generator doc comment REVERT: 1208f1c298f Rollup merge of #97837 - sunfishcode:sunfishcode/proc-self-mem, r=m-ou-se REVERT: 5fe16d7bcd6 Rollup merge of #97150 - ChrisDenton:stdio-create_pipe, r=m-ou-se REVERT: 3ac7a105641 Rollup merge of #97149 - ChrisDenton:win_async_pipes, r=m-ou-se REVERT: bab1386319c Rollup merge of #96719 - mbartlett21:patch-4, r=Dylan-DPC REVERT: 89c245b1938 Rollup merge of #96609 - ibraheemdev:arc-downcast-unchecked, r=m-ou-se REVERT: 18e3143e9c5 Rollup merge of #94855 - m-ou-se:advance-slice-panic-docs, r=kennytm REVERT: 74d740666ca Rollup merge of #93080 - SkiFire13:itermut-as_mut_slice, r=m-ou-se REVERT: 2b040143f63 Windows: `CommandExt::async_pipes` REVERT: 2c25c5de39d `Stdio::make_pipe` REVERT: 21b233990f2 Add tracking issue for `noop_waker` REVERT: b23e922dede Optimize heapsort REVERT: a14346c0b5f Show #![feature] in example. REVERT: c22d851eacb Leak pthreax_rwlock_t when it's dropped while locked. REVERT: 6e044aab14f Fix typo in `HashMap::drain` docs REVERT: 34df743bdab Mention formatting macros when encountering ArgumentV1::new in const REVERT: 1d57a21a305 Rollup merge of #98257 - kadiwa4:into_future_doc_typos, r=Dylan-DPC REVERT: 3fb5ee31793 Rollup merge of #97912 - Kixunil:stabilize_path_try_exists, r=dtolnay REVERT: 89a16d5ae79 Rollup merge of #95534 - jyn514:std-mem-copy, r=joshtriplett REVERT: 20c287e1fe2 Add `core::mem::copy` to complement `core::mem::drop`. REVERT: 7060d455438 Fix documentation for with_capacity and reserve families of methods REVERT: dfeee3d70ed Auto merge of #98224 - eddyb:proc-macro-spurious-repr, r=bjorn3 REVERT: aa9f817a5c0 typos in `IntoFuture` docs REVERT: 4771987a653 Rollup merge of #98233 - RalfJung:ref-alloc, r=thomcc REVERT: d608d96f455 Auto merge of #97791 - m-ou-se:const-locks, r=m-ou-se REVERT: 5b9cb6bb8d5 Add comment explaining why we use NonNull REVERT: 2628842ac98 Add safety comments REVERT: 87db8b03e39 Documentation typo REVERT: 0169cadbf0c *const to NonNull plus documentation REVERT: fe83ac3e370 Address comments REVERT: e6c9b8c2030 More formatting REVERT: dd3686a9a70 Formatting REVERT: b7ca5896f2a Make RwLockReadGuard covariant REVERT: 0ede9ca4d29 Auto merge of #97367 - WaffleLapkin:stabilize_checked_slice_to_str_conv, r=dtolnay REVERT: 664ee54814a Rollup merge of #98165 - WaffleLapkin:once_things_renamings, r=m-ou-se REVERT: e8d9b789a95 Auto merge of #97924 - cuviper:unguarded-poison, r=Mark-Simulacrum REVERT: 692f57c0885 make std not use &A: Allocator instance REVERT: 209d70e4279 make btree not use &A: Allocator instance REVERT: b29adaff216 Auto merge of #98004 - paolobarbolini:vecdeque-extend-trustedlen, r=the8472 REVERT: dec472caed3 proc_macro/bridge: remove `#[repr(C)]` from non-ABI-relevant types. REVERT: 3cae1708407 Auto merge of #98186 - mystor:tokenstream_as_vec_tt, r=eddyb REVERT: c3f635188d2 Auto merge of #98178 - RalfJung:btree-alloc, r=thomcc REVERT: df0e407f62e Document the conditional existence of `alloc::sync` and `alloc::task`. REVERT: a411056056e review fixups REVERT: d025f64f358 comments explaining why we have and don't have ManuallyDrop REVERT: 87a3760e87b Expose iter::ByRefSized as unstable feature and use it REVERT: 663a68f990f Add VecDeque::extend from TrustedLen specialization REVERT: 81d4e427fd1 Add VecDeque::extend TrustedLen benchmark REVERT: 74da3824334 Impl Termination for Infallible and then make the Result impls of Termination into a blanket REVERT: 42a8ed63c21 Stabilized Option::unzip() REVERT: 15079c73616 Move empty final TokenStream handling to server side of bridge REVERT: 7ae01fdb0c5 Rollup merge of #97844 - ChrisDenton:dont-panic, r=JohnTitor REVERT: c92b0c8cf29 Rollup merge of #95392 - Xuanwo:stablize_try_reserve_2, r=dtolnay REVERT: 90f2f7b8ea7 btree: avoid forcing the allocator to be a reference REVERT: 4a84b90fea3 Try to reduce codegen complexity of TokenStream's FromIterator and Extend impls REVERT: 3ab016ef40c proc_macro: reduce the number of messages required to create, extend, and iterate TokenStreams REVERT: 379d34d5b79 proc_macro: use macros to simplify aggregate Mark/Unmark definitions REVERT: 3fdf9af3e0c Auto merge of #98143 - cuviper:futex-rwlock-inline, r=thomcc REVERT: f276ca3d47a Rollup merge of #98169 - pierwill:dyn-disp, r=JohnTitor REVERT: 200cd548089 Rollup merge of #98118 - steffahn:scoped-threads-nll-test, r=m-ou-se REVERT: 2fd285c8258 Rollup merge of #97675 - nvzqz:unsized-needs-drop, r=dtolnay REVERT: a9f4bfeafc9 Move/rename `lazy::Sync{OnceCell,Lazy}` to `sync::{Once,Lazy}Lock` REVERT: 23d9838e98f Move/rename `lazy::{OnceCell, Lazy}` to `cell::{OnceCell, LazyCell}` REVERT: 3fb5694852a Keyword docs: Link to wikipedia article for dynamic dispatch REVERT: f4546717f00 Auto merge of #97842 - notriddle:notriddle/tuple-docs, r=jsha,GuillaumeGomez REVERT: fc0c86945ba Leak pthreax_mutex_t when it's dropped while locked. REVERT: a4834c8002e Rollup merge of #98125 - KarlWithK:entry_add_modify_doc, r=Dylan-DPC REVERT: dc5d0d04abd Auto merge of #98103 - exrook:btreemap-alloc, r=Amanieu REVERT: b086fd95ad2 std: Stabilize feature try_reserve_2 REVERT: 1ea26de0e5e Auto merge of #98152 - JohnTitor:rollup-osr17j6, r=JohnTitor REVERT: bf6f183ff44 Rollup merge of #98059 - tmiasko:inline-const-eval-select, r=Amanieu REVERT: 1d4c4c792dc Rollup merge of #97202 - joshtriplett:os-str-capacity-documentation, r=dtolnay REVERT: 0be896bf10b Auto merge of #97178 - sunfishcode:ownedfd-and-dup, r=joshtriplett REVERT: e77ade702fe Add `#[inline]` to small fns of futex `RwLock` REVERT: 8850ca806c2 Add the new stability attributes, for Windows. REVERT: 6485e5aad89 Revise the documentation for `try_clone`. REVERT: 21359b7d211 Add `BorrowedFd::try_clone_to_owned`. REVERT: dc00394d2bf Document that `BorrowedFd` may be used to do a `dup`. REVERT: ff2dbbe9da6 Auto merge of #95897 - AzureMarker:feature/horizon-std, r=nagisa REVERT: afcda3c3c92 Test `copy_to_userspace` function REVERT: 352414230ae std: relax memory orderings in `Parker` REVERT: 9c269d98b5f Test NLL fix of bad lifetime inference for reference captured in closure. REVERT: fb7e505e879 Ensure userspace allocation is 8-byte aligned REVERT: 93376da3c36 Mitigate MMIO stale data vulnerabilities REVERT: 1040c9012d0 change "1" to "c" to pass test REVERT: fc311f608d1 Unify copying data from enclave to userspace REVERT: b3d62041772 Add examples using `add_modify` to btree REVERT: d5499babe23 Add examples using `add_modify` to HashMap REVERT: 0fd3fcd4184 proc_macro: support encoding/decoding Vec REVERT: c6c508207db proc_macro: support encoding/decoding structs with type parameters REVERT: ecd4196ab19 Add a stability attribute to WASI's `try_clone()`. REVERT: fbc627d6aa1 Implement stabilization of `#[feature(io_safety)]`. REVERT: 3c73cc9c256 Clarify `[T]::select_nth_unstable*` return values REVERT: f2e1d5ffd4b rustdoc: change "variadic tuple" notation to look less like real syntax REVERT: f31c4d29afd btreemap-alloc: fix clear impl REVERT: 74228dbce4f BTreeMap: Add alloc param REVERT: 8c7ec2e898f Stabilize `Path::try_exists()` and improve doc REVERT: c076e07268d Auto merge of #78781 - eddyb:measureme-rdpmc, r=oli-obk REVERT: 0d991a8280d Rollup merge of #98042 - DrMeepster:winfred_std_changes, r=ChrisDenton REVERT: 0559111be5f Rollup merge of #97869 - ssomers:btree_comments, r=Dylan-DPC REVERT: 44124fdb008 Use a private type definition to reduce cfg noise REVERT: 36af571a9c3 Enable thread_local_dtor on horizon OS REVERT: a1c0c7d344c Update libc::stat field names REVERT: 003f39464a0 Enable argv support for horizon OS REVERT: dd4ac603369 Use the right wait_timeout implementation REVERT: 60f14d0d7c3 Lower listen backlog to fix accept crashes REVERT: 7b275dadf8d Horizon OS STD support REVERT: e18e87974c9 add inline(always) to option REVERT: 194c59273b9 fix broken doc comment REVERT: 448356cb6d2 remove outdated references REVERT: 48cc204411d Add provider API to error trait REVERT: 46672fdbcbd [perf] std: add missing `#[inline]` to `DefaultHasher::{new,default}`. REVERT: 7202eede6c3 Inline `const_eval_select` REVERT: a58e93a4667 Document an edge case of `str::split_once` REVERT: 90ed2881415 proc_macro: bypass RandomState to remove ASLR-like effects. REVERT: 4e412e5ae66 Auto merge of #98038 - TaKO8Ki:remove-unnecessary-space-in-doc, r=compiler-errors REVERT: 268e1635d36 remove an unnecessary space in doc REVERT: ff5a928ac83 Rollup merge of #97950 - eggyal:issue-97945, r=Dylan-DPC REVERT: d43b9fd6035 Rollup merge of #97992 - m-ou-se:stabilize-scoped-threads, r=joshtriplett REVERT: 8b323a6d364 Rollup merge of #97970 - dtolnay:terminate, r=joshtriplett REVERT: 4ba962249bf Rollup merge of #97921 - bvanjoi:docs-example-str-replace, r=Dylan-DPC REVERT: afb491559f7 Add docs to `maybe_tuple_doc!` REVERT: 16a6a411606 Update library/core/src/primitive_docs.rs REVERT: 405456958a6 Update library/std/src/primitive_docs.rs REVERT: 6c6c6181d47 fix compat_fn option method on miri REVERT: 2e8f6b2147b Auto merge of #97996 - matthiaskrgr:rollup-bvbjlid, r=matthiaskrgr REVERT: 5a1f3d1a1ac docs: make all the variadic impls use `(T, ...)` exactly REVERT: 52ab7126303 Add test case for #trait-implementations-1 link REVERT: 5d4bf8d5293 Re-add explicit list of traits to tuple docs, with limit notes REVERT: 12fd2d5137c Use relative path for addressing things in rust-lang/rust REVERT: ae07a119430 Fix incorrectly spelled "variadic" REVERT: ee8ec7121f8 Rollup merge of #97943 - Warrenren:master, r=Dylan-DPC REVERT: 317b63a11b9 Rollup merge of #97904 - est31:master, r=Dylan-DPC REVERT: 06675028d13 Stabilize scoped threads. REVERT: 5f8f2f449e2 Rollup merge of #97979 - ben0x539:providerdocs, r=Dylan-DPC REVERT: 085d76f60b8 Rollup merge of #97958 - mkroening:exit-status-docs, r=Dylan-DPC REVERT: e3ca352ad25 Fix typos in Provider API docs REVERT: 0d2d17f49ad Update cmp.rs REVERT: ba1de809564 Do not panic in Termination impl on closed stderr REVERT: 52c0f59d5f7 Rollup merge of #97940 - GuillaumeGomez:relative-link, r=Dylan-DPC REVERT: c287307b439 net listen backlog set to negative on Linux. REVERT: acda2609783 docs: Consistently mark ExitStatus as code REVERT: 83ba8f47f63 docs: Link to ExitCode instead of ExitStatus in ExitStatus REVERT: 01e300ae48f docs: Fix typo in ExitStatus REVERT: 7743dc1493e Clarify `#[derive(PartialEq)]` on enums REVERT: 2de8bdbc763 Make "windows_process_exit_code_from" unstable REVERT: 790240526c7 Incorporate warning for potential exit code ambiguities REVERT: ff39e00a6e3 Fix copy paste error REVERT: 1764cc77c17 Auto merge of #96837 - tmiasko:stdio-fcntl, r=joshtriplett REVERT: a0f80ed7757 line 1352, change self to (*self), other to (*other) REVERT: 3fb875fabe1 Use relative links instead of linking to doc.rust-lang.org when possible REVERT: 802651c3968 Auto merge of #97939 - JohnTitor:rollup-79pxupb, r=JohnTitor REVERT: 6b3509e7a30 Rollup merge of #97922 - paolobarbolini:no-vecdeque-extra-reserve, r=the8472 REVERT: bc3ff082cbc Rollup merge of #97888 - hoodmane:emscripten-eh-personality, r=Amanieu REVERT: 063f9a96df8 Rollup merge of #97876 - yoshuawuyts:into-future-docs, r=JohnTitor,yaahc REVERT: 3d771b73474 Auto merge of #95818 - petrochenkov:stabundle, r=wesleywiser REVERT: ef3d751ba1d Auto merge of #95770 - nrc:read-buf-builder, r=joshtriplett REVERT: ef5e01c401f Auto merge of #91970 - nrc:provide-any, r=scottmcm REVERT: 325568c9bb0 use fcntl fallback for additional poll-specific errors REVERT: b0dbf37b28f Stabilize the `bundle` native library modifier REVERT: 3cc01a380a3 add cgroupv1 support to available_parallelism REVERT: ca69eb0f07e Avoid `thread::panicking()` in non-poisoning methods of `Mutex` and `RwLock` REVERT: 1e556e152ba Remove redundant calls to reserve in impl Write for VecDeque REVERT: f1d9ba6d930 Add underscores to rust_eh_personality arguments to mark them as unused REVERT: 5f83671557b additional docs example for replace **all** of str REVERT: b7cb1c21cde Implement ExitCodeExt for Windows REVERT: 5e4e8c2a4e3 Auto merge of #97910 - JohnTitor:rollup-gu3k0xl, r=JohnTitor REVERT: 65d48151d3a Implement `fmt::Write` for `OsString` REVERT: e019d90d99f Grammar fix in the compile_error documentation REVERT: 945d0771ec2 Rollup merge of #95632 - evanrichter:master, r=joshtriplett REVERT: 289d42175c7 Auto merge of #97868 - ssomers:btree_from_sorted_iter, r=the8472 REVERT: 0bf832742ed Stabilize NonZero* checked operations constness. REVERT: 76cc343e0b0 Partial stabilization of "nonzero_unchecked_ops". REVERT: 09141cec1ad Fix bootstrap attr REVERT: ee8cc90597c rustdoc: fixed messed-up rustdoc auto trait impls REVERT: 8aa55d574d6 rustdoc: show tuple impls as `impl Trait for (T, ...)` REVERT: 88bffcb3239 Remove __gxx_personality_v0 declaration REVERT: 3c4a42cf68d Fix FFI-unwind unsoundness with mixed panic mode REVERT: 48bddb13a05 Rollup merge of #97871 - ChayimFriedman2:vec-iterator-unimplemented, r=compiler-errors REVERT: d4864550f98 Rollup merge of #97830 - LucasDumont:add-example-alloc, r=yaahc REVERT: 97de9d9e737 Fix formatter REVERT: c3d0258ef7d Don't use __gxx_personality_v0 in panic_unwind on emscripten target REVERT: c808a79655b Rollup merge of #97879 - hermitcore:condvar, r=Dylan-DPC REVERT: 69c10ccb44a Fix trailing whitespace. REVERT: f55559e9222 Reword the question in the section header too. REVERT: f2838e0de5c Update library/std/src/os/unix/io/mod.rs REVERT: dcb9cbcc5a5 Reword a question into a statement. REVERT: 21cebc8ea15 remove unneeded code REVERT: bdc260db04b update docs for `std::future::IntoFuture` REVERT: 80b8460e481 Stabilize `const_intrinsic_copy` REVERT: 3c0ab53194d Suggest using `iter()` or `into_iter()` for `Vec` REVERT: b374d0603ae BTreeSet: avoid intermediate sorting when collecting sorted iterators REVERT: 21b0ce3468a BTree: tweak internal comments REVERT: 307e75a7b9a Rollup merge of #97851 - saethlin:use-repr-c, r=thomcc REVERT: 2b967d70885 Use repr(C) when depending on struct layout in ptr tests REVERT: e76ae31f13b Windows: No panic if function not (yet) available REVERT: 07cc3f3726b [core] add Exclusive to sync REVERT: a6367e57b08 docs: show Clone and Copy on () doc pages REVERT: 772da4d9b62 Inline Windows `OsStrExt::encode_wide` REVERT: 2e1a5152c60 rustdoc: show auto/blanket docs for tuple and unit REVERT: d3e62110e1e docs: clean up trait docs for tuples REVERT: bb09b8fe748 Update library/std/src/os/unix/io/mod.rs REVERT: a28e2579cc5 Update library/std/src/os/unix/io/mod.rs REVERT: 72808c50b89 Update library/std/src/os/unix/io/mod.rs REVERT: d023096bb35 Update library/std/src/os/unix/io/mod.rs REVERT: bf31fcf1d63 Document Rust's stance on `/proc/self/mem` REVERT: ec8917ce1bd Rollup merge of #97821 - Nilstrieb:mutex-docs, r=Dylan-DPC REVERT: 839d40cb1d2 Rollup merge of #95948 - Nilstrieb:improve-cstr-safety-docs, r=RalfJung REVERT: f8e879e98d4 Improve the safety docs for `CStr` REVERT: 52624b4bd7b Update library/std/src/sync/mutex.rs REVERT: 300285fc1d4 Add std::alloc::set_alloc_error_hook example REVERT: 7d9d0c43edd Rollup merge of #97771 - rtzoeller:haiku_no_sigio, r=kennytm REVERT: f44344e790b Remove confusing sentence from `Mutex` docs REVERT: 778eb02026c Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakis REVERT: 50d171c6493 Rollup merge of #97700 - nzrq:patch-1, r=dtolnay REVERT: f4e65362f08 Apply suggestions from code review REVERT: 77a48c917bc Make {Mutex, Condvar, RwLock}::new() const. REVERT: 5f03379d432 Make all {Mutex, Condvar, RwLock}::new #[inline]. REVERT: 384770938d7 Address reviewer comments REVERT: efb6c2fa768 Add some more tests REVERT: 6c73bf54cee Add tracking issue number REVERT: fe0c89c12d3 Add examples to docs REVERT: 5be46614f57 Update docs REVERT: 5ec9869a0f2 Modify the signature of the request_* methods so that trait_upcasting is not required REVERT: 12d37f010ca Add the Provider api to core::any REVERT: ffd930cac66 Rollup merge of #97764 - RalfJung:strict, r=dtolnay REVERT: af44ccf47e1 Auto merge of #97710 - RalfJung:ptr-addr, r=thomcc REVERT: d5b9ed2c823 Remove SIGIO reference on Haiku REVERT: 496d5532bb3 use strict provenance APIs REVERT: 85c95cd3c3b promise that ptr::copy and ptr::swap are doing untyped copies REVERT: 0e44ef7bed4 change ptr::swap methods to do untyped copies REVERT: 7469492d6b3 Add vec::Drain{,Filter}::keep_rest REVERT: 5854359f70b std: solve priority issue for Parker REVERT: a0bcbfef662 Add diagnostic items to MutexGuard and RwLock Guards REVERT: 390641dee87 Update library/std/src/collections/hash/set.rs REVERT: ce0810b2ccd Auto merge of #97742 - matthiaskrgr:rollup-fr3j0t8, r=matthiaskrgr REVERT: 514c3a4098e Rollup merge of #97688 - RalfJung:test-const-cpy, r=Mark-Simulacrum REVERT: 188fdfaa93d Auto merge of #97191 - wesleywiser:main_thread_name, r=ChrisDenton REVERT: 4c1d600b0fe keep using poll as fast path and only use fcntl as fallback REVERT: 3f87c6b837d Rollup merge of #97647 - m-ou-se:lazy-box-locks, r=Amanieu REVERT: 5dd9bfa1670 Rollup merge of #96642 - thomcc:thinbox-zst-ugh, r=yaahc REVERT: e34213abcc5 Auto merge of #97604 - nnethercote:inline-bridge-Buffer-methods, r=eddyb REVERT: e2f2af367eb Update set.rs REVERT: 93032c1c5af Fully stabilize NLL REVERT: 79e4c5db4fd implement ptr.addr() via transmute REVERT: c0e1da97b80 Auto merge of #95833 - notriddle:notriddle/human-readable-signals, r=yaahc REVERT: 1405cbb92ff Add note to documentation of HashSet::intersection REVERT: 54dcdce3c23 Lazily allocate+initialize locks. REVERT: 01224227776 Use Drop instead of destroy() for locks. REVERT: c310cdde492 test const_copy to make sure bytewise pointer copies are working REVERT: 76d27ab8f81 Rollup merge of #97366 - WaffleLapkin:stabilize_array_slice_from_ref, r=dtolnay REVERT: 3ab81af4258 Make `std::mem::needs_drop` accept `?Sized` REVERT: 8c14093ce02 Fix MIPS-specific signal bug REVERT: 9c9706201f0 Rollup merge of #97655 - steffahn:better-pin-box-construction-docs, r=thomcc REVERT: b8bd9623f36 Auto merge of #97654 - Dylan-DPC:rollup-w6zrzxf, r=Dylan-DPC REVERT: 53f99bae8df Improve documentation for constructors of pinned `Box`es REVERT: 8bb49f5e2d1 Rollup merge of #97636 - nnethercote:revert-96682, r=dtolnay REVERT: df966faa473 Rollup merge of #97420 - WaffleLapkin:no_oxford_casts_qqq, r=Mark-Simulacrum REVERT: 00c8d58c381 Auto merge of #97293 - est31:remove_box, r=oli-obk REVERT: 989069e12ff Rollup merge of #97635 - rgwood:patch-1, r=ChrisDenton REVERT: 6bc30f3d23d Rollup merge of #97603 - ximon18:arc-make-mut-spelling-correction, r=GuillaumeGomez REVERT: b771221b479 Rollup merge of #97397 - JohnTitor:stabilize-box-into-pin, r=Mark-Simulacrum REVERT: 1e1aaf1b5b9 Auto merge of #97414 - LYF1999:yf/cachealign, r=Mark-Simulacrum REVERT: 433d04c9a51 Revert #96682. REVERT: 77d43e78190 Fix Windows file metadata docs REVERT: 4db5fa81bc0 Stabilize `box_into_pin` REVERT: 8d9ec1caa13 Rollup merge of #95594 - the8472:raw_slice_methods, r=yaahc REVERT: f3c8094a6d6 std: show signal number along with name REVERT: a0229b48463 Rollup merge of #97611 - azdavis:master, r=Dylan-DPC REVERT: 1c65d9ad6e8 Rollup merge of #97498 - ijchen:master, r=Mark-Simulacrum REVERT: dcad630c8a3 Rollup merge of #94647 - Urgau:hash-map-many-mut, r=Amanieu REVERT: 9eaa5c6b8a6 Update sync.rs REVERT: 5111f1e99fd Update sync.rs REVERT: b23af305e26 Tweak insert docs REVERT: e355415039b Auto merge of #97553 - nbdd0121:lib, r=Mark-Simulacrum REVERT: 190c76d16da use 128 cache align for m1 mac REVERT: 4630aabe823 Auto merge of #97435 - Patryk27:bump-compiler-builtins, r=Dylan-DPC REVERT: 569d9a2179a Use #[rustc_box] in alloc instead of box syntax REVERT: 60c1a401ac6 Inline `bridge::Buffer` methods. REVERT: 69f802e0514 Spelling correction. REVERT: c4c23282b43 Expose get_many_mut and get_many_unchecked_mut to HashMap REVERT: 8c99f3af245 Rollup merge of #97596 - WaffleLapkin:fixup_feature_name, r=compiler-errors REVERT: ccc12611e59 Rollup merge of #97578 - ojeda:checkpatch, r=JohnTitor REVERT: d4e0ee4d98b Rollup merge of #97316 - CAD97:bound-misbehavior, r=dtolnay REVERT: 64e413f2864 Fixup feature name to be more consistent with others REVERT: 4cac94ebe16 Auto merge of #97419 - WaffleLapkin:const_from_ptr_range, r=oli-obk REVERT: 61ac8c1bccf Auto merge of #97521 - SkiFire13:clarify-vec-as-ptr, r=Dylan-DPC REVERT: f8c2bdb8d6a alloc: remove repeated word in comment REVERT: d3fa1dec7ca Auto merge of #97526 - Nilstrieb:unicode-is-printable-fastpath, r=joshtriplett REVERT: b2d0c1a116c Add unicode fast path to `is_printable` REVERT: e34a3f794f0 Auto merge of #97574 - Dylan-DPC:rollup-jq850l6, r=Dylan-DPC REVERT: d4598d6d909 Rollup merge of #97569 - thomcc:fill_with_isnt_memset, r=Amanieu REVERT: b40f55937a8 Rollup merge of #97565 - lukas-code:patch-1, r=thomcc REVERT: 85d2d2017e1 Rollup merge of #97455 - JohnTitor:stabilize-toowned-clone-into, r=dtolnay REVERT: e6d8942528c Rollup merge of #97229 - Nilstrieb:doc-box-noalias, r=dtolnay REVERT: ab3f04acab0 Auto merge of #96881 - est31:join_osstr, r=dtolnay REVERT: 9c7fe9f490b BTreeSet->BTreeMap (fix copy/paste mistake in documentation) REVERT: 7e6c79dbcbf Fix typo uniqeness -> uniqueness REVERT: aca23c3646f Remove `memset` alias from `fill_with`. REVERT: 96d227516f3 Rollup merge of #89685 - DeveloperC286:iter_fields_to_private, r=oli-obk REVERT: e1a92543ab7 Update mut_ptr.rs REVERT: 2f6c69a2d76 Update intrinsics.rs REVERT: d3a6008bfb2 Remove too long example REVERT: 11bbfd0b27a Correct signed bit int documentation REVERT: ccd83664367 Implement carrying_add and borrowing_sub on signed numbers REVERT: c64b2d5889c Auto merge of #97480 - conradludgate:faster-format-literals, r=joshtriplett REVERT: dbfc34c70a5 Add `#[inline]` to `Vec`'s `Deref/DerefMut` REVERT: ec79883e4fb Rollup merge of #97545 - thomcc:sip-comment-safety, r=Dylan-DPC REVERT: b50b4e45630 Rollup merge of #97499 - est31:master, r=Dylan-DPC REVERT: 7b9f2dfaaa1 Rollup merge of #97494 - est31:remove_box_alloc_tests, r=Dylan-DPC REVERT: 805571ed762 Rename slice_from_ptr_range_const -> const_slice_from_ptr_range REVERT: 0032f061826 Add reexport of slice::from{,_mut}_ptr_range to alloc & std REVERT: e5ae8185d69 Make `from{,_mut}_ptr_range` const REVERT: 785943049ec Remove "sys isn't exported yet" phrase REVERT: f5604a686d6 Auto merge of #96964 - oli-obk:const_trait_mvp, r=compiler-errors REVERT: 8be74988918 Remove `#[default..]` and add `#[const_trait]` REVERT: fa0320e4463 Reword safety comments in core/hash/sip.rs REVERT: d1a980272c4 Auto merge of #97514 - WaffleLapkin:panick, r=Dylan-DPC REVERT: c9e86f3845a remove useless cold REVERT: fa7640a7e1e improve format impl for literals REVERT: 5026e8c9b63 Auto merge of #97214 - Mark-Simulacrum:stage0-bump, r=pietroalbini REVERT: a09d90f9715 Clarify the guarantees of Vec::as_ptr and Vec::as_mut_ptr when there's no allocation REVERT: 184101e4058 clarify how Rust atomics correspond to C++ atomics REVERT: 6c1288f2907 Fix typo (panick -> panic) REVERT: 29ee564f68d Remove `(fn(...) -> ...)` -> `usize` -> `*const ()` -> `usize` cast REVERT: 76cc662a576 protect `std::io::Take::limit` from overflow in `read` REVERT: a79126d638c Use Box::new() instead of box syntax in core tests REVERT: 0b9eb8f4a61 Use Box::new() instead of box syntax in std tests REVERT: f1bdbd67237 Rollup merge of #97482 - RalfJung:ptr-invalid, r=thomcc REVERT: 725b84bee83 Use Box::new() instead of box syntax in alloc tests REVERT: 39c2508fe27 Corrected EBNF grammar for from_str REVERT: 3c37221bf4d Auto merge of #97207 - RalfJung:backtrace, r=Mark-Simulacrum REVERT: b690de2bc5b Auto merge of #97461 - eddyb:proc-macro-less-payload, r=bjorn3 REVERT: 5aa4d259909 note to future self REVERT: 5d4e71a5a91 ptr::invalid is not equivalent to a int2ptr cast REVERT: de1b6aa4152 Rollup merge of #97448 - Xiretza:os-str-unix-doc, r=joshtriplett REVERT: cca4a3ff5a0 Rollup merge of #97034 - fee1-dead-contrib:layout-hash, r=dtolnay REVERT: e285e340e8c Rollup merge of #94640 - Pointerbender:issue-71146-partial-stabilization, r=yaahc REVERT: 9b8f532f7c7 Use `pointer::is_aligned` in ThinBox debug assert REVERT: ad266d6b868 Avoid zero-sized allocs in ThinBox if T and H are both ZSTs. REVERT: 4ed08f93d18 Rollup merge of #95214 - tbu-:pr_vec_append_doc, r=Mark-Simulacrum REVERT: a1fa46efcdb proc_macro: don't pass a client-side function pointer through the server. REVERT: ddb45f640f0 Stabilize `toowned_clone_into` REVERT: 6ff22d7dd38 Call the OS function to set the main thread's name on program init REVERT: c9748b63813 Finish bumping stage0 REVERT: 6e1be4f8e11 docs: Don't imply that OsStr on Unix is always UTF-8 REVERT: eaf5b6564ce Auto merge of #97004 - nnethercote:proc-macro-tweaks, r=eddyb REVERT: 8e0c04c7b97 Cut down `associated_item`. REVERT: 255c1fd09e6 Remove unnecessary blank line. REVERT: 5337be2275d Rename `b` as `buf` in several places. REVERT: 53ebd326519 Add some comments about `_marker` fields. REVERT: a66c8e2d680 Clarify a comment. REVERT: 0175f44f292 Make `Buffer` non-generic. REVERT: e22aebcbbe2 Improve formatting in `associated_item!` definition. REVERT: 054319058dc Add some comments. REVERT: e3e6ecb98e1 Fix a typo in a comment. REVERT: 211417474bd Auto merge of #97444 - compiler-errors:rollup-2gvdav6, r=compiler-errors REVERT: 3dc185198a5 Rollup merge of #96051 - newpavlov:duration_rounding, r=nagisa,joshtriplett REVERT: cd3073b2438 fmt REVERT: 781f9197ed1 fix nanos overflow for f64 REVERT: ba586c926a5 add debug asserts REVERT: 94319c142bc libcore: Add `iter::from_generator` which is like `iter::from_fn`, but for coroutines instead of functions REVERT: d0d06dfe357 Document the current aliasing rules for `Box`. REVERT: 03d9763ec39 library/std: Bump compiler_builtins REVERT: 9881cf09fd8 Rollup merge of #96033 - yaahc:expect-elaboration, r=scottmcm REVERT: 883f40b2224 Auto merge of #97046 - conradludgate:faster-ascii-case-conv-path, r=thomcc REVERT: 91618e76d23 improve case conversion happy path REVERT: 18feb91f4a2 Allow some internal instability REVERT: 0ad05b20d23 Auto merge of #96742 - m-ou-se:bsd-no-ancillary, r=joshtriplett REVERT: f53aca1a358 Disable unix::net::ancillary on BSD. REVERT: 2276a56b811 fix broken doctest REVERT: 2adb6b65f73 update option and result references to expect message docs REVERT: 6d03c7098f9 fix links REVERT: ed65f6583fa Auto merge of #94954 - SimonSapin:null-thin3, r=yaahc REVERT: 9a53f2f03b1 Rollup merge of #97233 - c410-f3r:assert-lib, r=scottmcm REVERT: e507b7ded39 Rollup merge of #97379 - ear7h:master, r=thomcc REVERT: 5b618ab7563 Rollup merge of #97026 - Nilstrieb:make-atomic-debug-relaxed, r=scottmcm REVERT: c3afb22a7bf add aliases for current_dir REVERT: 4990fcd8925 tweak doctests REVERT: cf705fbd6eb implement tie to even REVERT: 4e1539f8df4 explained unwrap vs expect REVERT: bea917974fc Rollup merge of #97364 - notriddle:continue-keyword, r=JohnTitor REVERT: e4bdbfaa975 Rollup merge of #97363 - wackbyte:sliceindex-doc-typo, r=JohnTitor REVERT: d4ebaaca68b Rollup merge of #93966 - rkuhn:patch-1, r=tmandry REVERT: a97d5ba0f1e Stabilize checked slice->str conversion functions REVERT: e2e7bec4ac0 Stabilize `{slice,array}::from_ref` REVERT: b49f7bad331 Fix weird indentation in continue_keyword docs REVERT: 284176a440c Fix a mistake in `SliceIndex`'s documentation REVERT: 1e8b29a1195 Rollup merge of #97321 - RalfJung:int-to-fnptr, r=Dylan-DPC REVERT: 41d203e5e3d Rollup merge of #97308 - JohnTitor:stabilize-cell-filter-map, r=Mark-Simulacrum REVERT: 27aa5f65810 Fix stabilization version of `Ipv6Addr::to_ipv4_mapped` REVERT: eeb06330e3f sync primitive_docs REVERT: 13e0f7210df explain how to turn integers into fn ptrs REVERT: 66d20d792f8 Auto merge of #97315 - Dylan-DPC:rollup-2wee2oz, r=Dylan-DPC REVERT: 2033aff6472 Put a bound on collection misbehavior REVERT: 624cb3145cf Rollup merge of #96129 - mattheww:2022-04_float_rounding, r=Dylan-DPC REVERT: 31a5521aff6 Auto merge of #92461 - rust-lang:const_tls_local_panic_count, r=Mark-Simulacrum REVERT: dc50b970833 Stabilize `cell_filter_map` REVERT: a1c21f898a3 Auto merge of #97304 - Dylan-DPC:rollup-qxrfddc, r=Dylan-DPC REVERT: bfd5376c50f Rollup merge of #97294 - jersou:patch-1, r=Dylan-DPC REVERT: c5b412502b9 Rollup merge of #97087 - Nilstrieb:clarify-slice-iteration-order, r=dtolnay REVERT: 421232a56fc Auto merge of #96100 - Raekye:master, r=dtolnay REVERT: 11b913e488a Auto merge of #96455 - dtolnay:writetmp, r=m-ou-se REVERT: 218b0208764 Implement `FusedIterator` for `std::net::[Into]Incoming` REVERT: 1de0c667f89 Auto merge of #96906 - tbu-:pr_stabilize_to_ipv4_mapped, r=dtolnay REVERT: 8692f2c9b9c Make write/print macros eagerly drop temporaries REVERT: d8587be3c77 std::time : fix doc variable name REVERT: bb8c0a35a98 small change REVERT: 4f48c6ea1b1 [RFC 2011] Library code REVERT: 2ab6c092533 adjust transmute const stabilization version REVERT: d766b3865fd Auto merge of #97265 - JohnTitor:rollup-kgthnjt, r=JohnTitor REVERT: 8b114713316 Rollup merge of #97245 - m-ou-se:rwlock-state-typo, r=JohnTitor REVERT: 889a5f461b2 Rollup merge of #97225 - cuviper:ref-display, r=scottmcm REVERT: f2380c1aad1 Rollup merge of #97144 - samziz:patch-1, r=Dylan-DPC REVERT: 04099e3dc49 Auto merge of #94119 - c410-f3r:array-again-and-again, r=scottmcm REVERT: b10962f5ce2 Expand the explanation of OsString capacity REVERT: 9a90045abfe Auto merge of #94530 - tmiasko:alignment-impls, r=dtolnay REVERT: c6016fd42bb Rollup merge of #97219 - RalfJung:ptr-invalid, r=thomcc REVERT: bc3db36f299 Rollup merge of #97190 - SylvainDe:master, r=Dylan-DPC REVERT: 8b12abefc5b Fix typo in futex RwLock::write_contended. REVERT: e3d1d51ac84 Auto merge of #96605 - Urgau:string-retain-codegen, r=thomcc REVERT: 69952acd3da Use GRND_INSECURE instead of /dev/urandom when possible REVERT: 3f2fa7a8e8d Update libc dependency of std to 0.2.126 REVERT: 554e48e76b3 Fix `Display` for `cell::{Ref,RefMut}` REVERT: 048b8d51011 Rollup merge of #97215 - AngelicosPhosphoros:add_hashtable_iteration_complexity_note, r=thomcc REVERT: fcec447c78b Rollup merge of #97187 - ajtribick:patch-1, r=thomcc REVERT: ccf2907c070 Add complexity estimation of iterating over HashSet and HashMap REVERT: da59c578558 make ptr::invalid not the same as a regular int2ptr cast REVERT: feeaa82683b Stabilize core::array::from_fn REVERT: 5ba6197aad8 Rollup merge of #97192 - sunfishcode:sunfishcode/rightmost, r=thomcc REVERT: 233d1b54f49 Auto merge of #96422 - tmccombs:mutex-unpoison, r=m-ou-se REVERT: a907c7f721c update libbacktrace REVERT: 77c35e28ac6 Remove references to guards in documentation for clear_poison REVERT: b8774af5c52 Auto merge of #97147 - Mark-Simulacrum:stage0-bump, r=pietroalbini REVERT: c64d5b69397 OsString: Consolidate all documentation about capacity in top-level docs REVERT: 68780491d22 Auto merge of #97027 - cuviper:yesalias-refcell, r=thomcc REVERT: 0ac6b0917e6 Say "last" instead of "rightmost" in the documentation for `std::str::rfind`. REVERT: 15f837e8ad0 Add implicit call to from_str via parse in documentation REVERT: 9629b762d8b impl Read and Write for VecDeque REVERT: 69560a2a477 Reverse condition in Vec::retain_mut doctest REVERT: c7a346eb14f Rollup merge of #97170 - benediktwerner:master, r=JohnTitor REVERT: 3a0396b3c41 Rollup merge of #97155 - alygin:patch-1, r=JohnTitor REVERT: e7a9c8d45d0 std: fix deadlock in `Parker` REVERT: d35e520eafd Remove unnecessay .report() on ExitCode REVERT: b641287f9b9 Change clear_poison to take the lock instead of a guard REVERT: 93083c0fc54 Auto merge of #97033 - nbdd0121:unwind3, r=Amanieu REVERT: bce6eaa7cd9 Auto merge of #97159 - JohnTitor:rollup-ibl51vw, r=JohnTitor REVERT: 0d7334fdb01 Rollup merge of #97131 - gimbles:patch-2, r=Dylan-DPC REVERT: 9bc329839a8 Rollup merge of #97127 - Mark-Simulacrum:revert-96441, r=m-ou-se REVERT: d67666223e1 Auto merge of #95643 - WaffleLapkin:ptr_convenience, r=joshtriplett REVERT: 3a11614df35 Fix doc typo REVERT: 57cdd9e3a48 std: Add capacity guarantees notes for OsString REVERT: c3b56222dc9 Stage-step cfgs REVERT: 46367498662 Fix rusty grammar in `std::error::Reporter` docs REVERT: 036d51ca045 std: use an event flag based thread parker on SOLID REVERT: f2094122855 Rollup merge of #97101 - coolreader18:exitcode-method-issue, r=yaahc REVERT: aa0d52c7c2a Rollup merge of #96917 - marti4d:master, r=ChrisDenton REVERT: 05e5a7f394d Update macros.rs REVERT: 5a64b89a00d Revert "Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se" REVERT: 49042aa6f90 bump stable version #94640 REVERT: 4d1bdcf526b Add tracking issue for ExitCode::exit_process REVERT: da3def87377 Add a comment for covariant `Ref` REVERT: 82b3064ec9c Remove outdated references to nll-rfc#40 REVERT: f4552e3c138 Improve error message for fallback RNG failure REVERT: 8108ee45a72 Clarify slice and Vec iteration order REVERT: 8500686b7e2 Allow `unused_macro_rules` in path tests REVERT: 3a8059964c0 Auto merge of #97053 - CAD97:realloc-clarification, r=dtolnay REVERT: 822b94db9b4 Auto merge of #97065 - gabriel-doriath-dohler:master, r=joshtriplett REVERT: 92fd0987297 Rename `eq_ignore_case` to `starts_with_ignore_case` REVERT: 67830b658bc Rollup merge of #97060 - bdbai:fix/uwphandle, r=ChrisDenton REVERT: 5feb6de9e45 Rollup merge of #96947 - sunfishcode:sunfishcode/rustc-nonnull-optimization-guaranteed, r=joshtriplett REVERT: e2692ee48c4 fix use of SetHandleInformation on UWP REVERT: 8e52c4dc483 Remove potentially misleading realloc parenthetical REVERT: 2a4a95e4af0 Auto merge of #94872 - mati865:mingw-llvm-target, r=petrochenkov REVERT: 88ab7f2c72d Auto merge of #97035 - JohnTitor:rollup-00ko07z, r=JohnTitor REVERT: a861975050c Implement `Hash` for `core::alloc::Layout` REVERT: 0ec464ff1aa Rollup merge of #95365 - mkroening:hermit-alloc-error-handler, r=joshtriplett REVERT: 43ba389da2a Auto merge of #95602 - scottmcm:faster-array-intoiter-fold, r=the8472 REVERT: 2f7f3db7bb6 Use re-export instead of inline wrapper in libunwind REVERT: 76481748995 Use Rust ABI for `__rust_start_panic` and `_{rdl,rg}_oom` REVERT: a07f20b518c Address review feedback REVERT: 100727dd12e Auto merge of #97013 - matthiaskrgr:rollup-c1pc6pc, r=matthiaskrgr REVERT: 36ebf3354c0 Change orderings of `Debug` for the Atomic types to `Relaxed`. REVERT: 0a3ca1e93b8 Use a pointer in cell::RefMut so it's not noalias REVERT: f5f2874103c Use a pointer in cell::Ref so it's not noalias REVERT: 9d44d59323c Auto merge of #95356 - coolreader18:exitstatus-exit-method, r= REVERT: 135d0025806 Guarantee less in docs REVERT: 3bdd84c1df3 Add ExitCode::exit_process example REVERT: 426443a8182 Add LLVM based mingw-w64 targets REVERT: f2f1068d18e Extend ptr::null and null_mut to all thin (including extern) types REVERT: 58cfc243ee7 Rollup merge of #97003 - nnethercote:rm-const_fn-attrs, r=fee1-dead REVERT: 77b1830fc8a Rollup merge of #96154 - lukaslueg:unreachablehint, r=scottmcm REVERT: f4322b9651b Slap #[inline] on all the ByRefSized methods, per the8472's suggestion REVERT: 7f90d073d56 Remove some unnecessary `rustc_allow_const_fn_unstable` attributes. REVERT: 73e7e7b9942 Rollup merge of #96932 - sunfishcode:sunfishcode/document-borrowed-handle, r=joshtriplett REVERT: 0891ec947a2 Rollup merge of #96860 - semarie:openbsd-futex-time64, r=cuviper REVERT: 545748016ed Fill-in tracking issues for features pointer_byte_offsets, const_pointer_byte_offsets and pointer_is_aligned REVERT: 28309bb014b Optimize `ptr.is_aligned_to()` REVERT: 594be770e50 Implement `ptr.is_aligned()` in terms of `.is_aligned_to()` REVERT: b9d1c63641b Lift the `Sized` requirement from convenience ptr fns REVERT: 5804e1b418c Add convenience functions to pointers REVERT: ebf72ae6034 Fix comment syntax. REVERT: 0cbdf4f5c5f Relax the wording about the meaning of -1. REVERT: f258923889c Auto merge of #95837 - scottmcm:ptr-offset-from-unsigned, r=oli-obk REVERT: 6d3dd4bab7f Apply CR suggestions; add real tracking issue REVERT: 03ff3c7534e Add a debug check for ordering, and check for isize overflow in CTFE REVERT: c95926750a6 Rename `unsigned_offset_from` to `sub_ptr` REVERT: edb3152ba91 Add `unsigned_offset_from` on pointers REVERT: a35366b9198 Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkov REVERT: 041f8070f71 Fix attribute name. REVERT: 10dd06e0d21 RawSocket is unsigned on Windows. REVERT: 8a319ec5349 Fix duplicate import on Windows. REVERT: b9bde57093f Add rustc_nonnull_optimization_guaranteed to Owned/Borrowed Fd/Socket REVERT: 095d5b5352e HandleOrNull can hold null, and HandleOrInvalid can hold INVALID_HANDLE_VALUE. REVERT: 8df6f26cfed Use `fcntl(fd, F_GETFD)` to detect if standard streams are open REVERT: 2cd0b7ccb78 Fix incorrect mentions of `OwnedFd` and `BorrowedFd` in Windows docs. REVERT: 757edc65b8d to_timespec could be unused by some targets REVERT: d94c9d1eae5 avoid using both Some() and ? on linux/android/freebsd code REVERT: 4635cd3b694 openbsd: convert futex timeout managment to Timespec usage REVERT: 840825f6788 Also document that `as_raw_handle` may return NULL. REVERT: 81f56c3cb09 Clarify what values `BorrowedHandle`, `OwnedHandle` etc. can hold. REVERT: b65394016d9 Auto merge of #96232 - sunfishcode:sunfishcode/io-safety-const-fns, r=joshtriplett REVERT: 2b0873d789d Also allow unused macro rules in stdarch REVERT: 68f55c80216 Recommend `Ipv6Addr::to_ipv4_mapped` over `Ipv6Addr::to_ipv4` REVERT: 9e010c9f445 Stabilize `Ipv6Addr::to_ipv4_mapped` REVERT: 792c37191f8 Make HashMap fall back to RtlGenRandom if BCryptGenRandom fails REVERT: d90cbdbd9d5 Rollup merge of #96861 - m-ou-se:std-use-prelude-2021, r=joshtriplett REVERT: 026c4ed4e26 Rollup merge of #96725 - nico-abram:win_tid, r=ChrisDenton REVERT: 40d48433532 Rollup merge of #96674 - bstrie:vardoc, r=thomcc REVERT: bff26c520d3 Expose process main_thread_handle on Windows REVERT: 1cb262170d9 Implement [OsStr]::join REVERT: 0cac39fdb0f Rollup merge of #96841 - thomcc:revert-osstr-join, r=m-ou-se REVERT: 32c5da0739b Rollup merge of #96008 - fmease:warn-on-useless-doc-hidden-on-assoc-impl-items, r=lcnr REVERT: 14a5c1fe996 Rollup merge of #95483 - golddranks:improve_float_docs, r=joshtriplett REVERT: d76cadf7718 Add `task::Waker::noop` REVERT: 7b41f12d779 Use Rust 2021 prelude in std itself. REVERT: 544a45b0dab Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors REVERT: 7853b8249f4 Auto merge of #96802 - gimbles:windows_slice, r=thomcc REVERT: d9bf5ddbdb0 Auto merge of #96846 - matthiaskrgr:rollup-yxu9ot9, r=matthiaskrgr REVERT: 38e09859592 Warn on unused doc(hidden) on trait impl items REVERT: a75e81a1e18 Rollup merge of #96828 - scottmcm:clarify-hasher-write, r=Amanieu REVERT: 4a9fd91f0c6 Auto merge of #96302 - Serial-ATA:more-diagnostic-items, r=manishearth REVERT: e51db4adab1 Revert "Implement [OsStr]::join", which was merged without FCP REVERT: f5d023e6a42 fix panic in Path::strip_prefix REVERT: ba395cd2814 Auto merge of #94206 - PrestonFrom:significant_drop, r=flip1995 REVERT: 05c8c66da4c Further elaborate the lack of guarantees from `Hasher` REVERT: e32ce2a9635 Rollup merge of #96671 - mgeisler:current-exe-docstring, r=Mark-Simulacrum REVERT: fd00bb46600 Rollup merge of #96586 - ear7h:master, r=joshtriplett REVERT: 0ea6ed89111 Rollup merge of #96336 - Nilstrieb:link-to-correct-as_mut-in-ptr-as_ref, r=JohnTitor REVERT: dd7a84bf06d Auto merge of #96657 - cuviper:time64, r=joshtriplett REVERT: 38a39c2d09c Fix a minor typo in the description of Formatter REVERT: 3231b8ae042 [fix] remove pub(crate) visibility REVERT: 0704f53d8b4 Rollup merge of #96701 - kraktus:alloc_example_2018_edition, r=Mark-Simulacrum REVERT: 561d0f4eeb3 Mark locks in std lib with clippy::has_significant_drop REVERT: 2b088399312 This is a pretty good start if you ask me REVERT: 351d8512b29 Share more unix SystemTime code REVERT: 65cde606b79 [feat] Make sys::windows::os_str::Slice repr(transparent) REVERT: 86098b44f11 Use statx's 64-bit times on 32-bit linux-gnu REVERT: ed2f6e6a2e2 Use __clock_gettime64 on 32-bit linux-gnu REVERT: 836abd370b2 unix: always use 64-bit Timespec REVERT: 923a7e72d88 Auto merge of #95183 - ibraheemdev:arc-count-acquire, r=Amanieu REVERT: e50dd83bc82 Auto merge of #94598 - scottmcm:prefix-free-hasher-methods, r=Amanieu REVERT: 6145a88a93b Clarify unreachable_unchecked docs REVERT: 1f3a2d90c81 Auto merge of #96510 - m-ou-se:futex-bsd, r=Amanieu REVERT: 56991dba358 For now, don't change the details of hashing a `str` REVERT: 200f29e0401 Add a dedicated length-prefixing method to `Hasher` REVERT: e401a2e6788 Rollup merge of #96744 - est31:join_osstr, r=thomcc REVERT: 611b5af02fa Rollup merge of #96639 - adpaco-aws:fix-offset-from-typo, r=scottmcm REVERT: a5a76aa46dc Rollup merge of #96174 - RalfJung:no-run-transmute, r=scottmcm REVERT: 35a1c3c885b Auto merge of #96520 - lcnr:general-incoherent-impls, r=petrochenkov REVERT: b63fa830c48 Implement [OsStr]::join REVERT: e53b0df818c Remove condvar::two_mutexes test. REVERT: 654993af0c1 Allow unused rules in some places in the compiler, library and tools REVERT: 02ca206c6e8 Rollup merge of #96682 - nnethercote:show-invisible-delims, r=petrochenkov REVERT: 5a40f010570 Rollup merge of #95843 - GuillaumeGomez:improve-new-cyclic-doc, r=m-ou-se REVERT: 1cc08c11ab1 Rollup merge of #95359 - jhpratt:int_roundings, r=joshtriplett REVERT: bf8c0788227 Auto merge of #96649 - tbu-:pr_to_ipv4_loopback_doc, r=m-ou-se REVERT: 14ea7d0a92a generalize "incoherent impls" impl for custom types REVERT: 29f25ab09f3 Auto merge of #96630 - m-ysk:fix/issue-88038, r=notriddle REVERT: f41fc5c06a2 Auto merge of #96626 - thomcc:rand-bump, r=m-ou-se REVERT: 9596511410b Update `int_roundings` methods from feedback REVERT: 79243ba65b7 Rollup merge of #96628 - joshtriplett:stabilize-then-some, r=m-ou-se REVERT: 2f82e72c5b2 Rollup merge of #96619 - akiekintveld:same_mutex_check_relaxed_ordering, r=m-ou-se REVERT: 05b376d9344 Rollup merge of #96616 - akiekintveld:min_stack_relaxed_ordering, r=joshtriplett REVERT: af11713dab7 Fix the generator example for `pin!()` REVERT: f5e97df13f1 Make it clear that `to_ipv4` returns an IPv4 address for the IPv6 loopback REVERT: c9e648f5110 slice: #[inline] a couple iterator methods. REVERT: 061a3401b53 Improve Rc::new_cyclic and Arc::new_cyclic documentation REVERT: e3e04bf8c1a update `jemallocator` example to use 2018 edition import syntax REVERT: 875e977487b Stabilize `bool::then_some` REVERT: 354b02cd9ea add caveat discussed in #74335 REVERT: 5e7be750029 Show invisible delimeters (within comments) when pretty printing. REVERT: 31c480c4c2c Auto merge of #96280 - lygstate:ffi-fixes, r=joshtriplett REVERT: 84726997f10 std::io: Modify some ReadBuf method signatures to return `&mut Self` REVERT: 72c5ae2cfc9 docs: add link explaining variance to NonNull docs REVERT: 4fa546106c9 Remove hard links from `env::current_exe` security example REVERT: 42b3a2451a2 Round timeouts up to infinite in futex_wait on DragonFlyBSD. REVERT: 90eeca514e8 Add #[cfg] in cfg_if for linux in unix/futex. REVERT: 1babc02daa4 Don't use futexes on netbsd. REVERT: e40eee99184 ignore a doctest for the non-exported macro REVERT: 544edfc0180 Update library/core/src/ffi/mod.rs REVERT: bf8b610e9ad This aligns the inline attributes of existing `__iterator_get_unchecked` with those of `next()` on adapters that have both. REVERT: e56ea1a1ae8 add benchmark REVERT: 9e356def093 Fix typo in `offset_from` documentation REVERT: 62c2ec7ccfa Fix nits REVERT: 8695be943b3 Auto merge of #96596 - scottmcm:limited-calloc, r=Mark-Simulacrum REVERT: febe644d799 Test leaking of BinaryHeap Drain iterators REVERT: 41d259951dd Slightly tighten leak-on-panic test cases REVERT: 57e15fb4470 Share testing utilities with non-btree test cases REVERT: c6137bd16ba Avoid use of `rand::thread_rng` in stdlib benchmarks REVERT: 14d789aff77 Tweak the calloc optimization to only apply to shortish-arrays REVERT: b3060622316 Add comment REVERT: 7462ee6afdc Fix formatting REVERT: 9d473f80647 Rollup merge of #96568 - EliasHolzmann:fmt_doc_fixes, r=joshtriplett REVERT: 2e188136903 Rollup merge of #96567 - alex-semenyuk:fix_docs_for_logs_func, r=Mark-Simulacrum REVERT: ca91ad4424b Rollup merge of #96222 - jmaargh:john-mark/clarify-from-raw-parts-docs, r=JohnTitor REVERT: f22436257b9 Rollup merge of #94126 - ssomers:alloc_prep_1, r=Mark-Simulacrum REVERT: 9b93c74b9ee Relax memory ordering used in SameMutexCheck REVERT: 465b8c3060d Relax memory ordering used in `min_stack` REVERT: 004e41b2432 Auto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomez REVERT: 0e6fe195c10 add `{Arc, Rc}::downcast_unchecked` REVERT: 1b78557e42a Improve codegen of String::retain method. REVERT: c4301d17fac std::fmt: Improved list of formatting macros REVERT: 35cee7947f9 std::fmt: Removed reference to Formatter::buf and other private fields REVERT: 7feca606c11 std::fmt: Fix the grammar documentation REVERT: 4346c0fd368 std::fmt: Added argument index comments to examples for specifying precision REVERT: 84e155f09bb std::fmt: Fixed documentation for specifying precision via `.*` REVERT: e82ce26ab03 Auto merge of #96376 - scottmcm:do-yeet, r=oli-obk REVERT: 157e8047206 Auto merge of #96078 - udoprog:refcounted-str-to-u8, r=dtolnay REVERT: 0d565b51c47 Bump shared_from_str to Rust 1.62.0 REVERT: b7b8d392345 Auto merge of #96490 - dtolnay:writetmpbackport, r=Mark-Simulacrum REVERT: 63d6b47a60a Auto merge of #95362 - scottmcm:calloc-arrays, r=Mark-Simulacrum REVERT: 349db1156ab Add `do yeet` expressions to allow experimentation in nightly REVERT: 36ff2ac11ca Fix some links in the standard library REVERT: 7f6bfad828a add aliases for std::fs::canonicalize REVERT: aac5ae8ec33 Auto merge of #96348 - overdrivenpotato:inline-location, r=the8472 REVERT: b4f109005c0 spicy REVERT: 95e9584141f Fix documentation for log functions int REVERT: c11ef86b397 Fix documentation for log functions unsigned int REVERT: 2154a923aff Disable pthread thread parker on futex platforms. REVERT: 807b8f19682 Always return false in futex_wake on {Free,DragonFly}BSD. REVERT: 962250a1e03 Update libc dependency of std to 0.2.125. REVERT: 2bc24c5ea4b Use futex-based locks and thread parker on FreeBSD. REVERT: 33441fe2370 Auto merge of #96489 - shepmaster:revert-vec-from-array-ref, r=yaahc REVERT: 7dc79d89bd0 Use futex-based locks and thread parker on DragonFlyBSD. REVERT: da17338fd13 Use futex-based locks and thread parker on NetBSD. REVERT: cdf55906e90 Use futex-based locks and thread parker on OpenBSD. REVERT: 7ddb7536b48 Rollup merge of #96492 - joshtriplett:revert-std-ffi-re-export, r=yaahc REVERT: a16f9a22db2 Rollup merge of #96481 - aDotInTheVoid:hashmap-docs-monospace, r=joshtriplett REVERT: 5ed14d4b102 Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se REVERT: c1d6b996407 Auto merge of #96393 - joboet:pthread_parker, r=thomcc REVERT: a6cff05da87 Add more diagnostic items REVERT: efcf0678cd3 Rollup merge of #96480 - user-simon:patch-1, r=Dylan-DPC REVERT: c3b5f86086b Rollup merge of #96433 - petrochenkov:delim, r=nnethercote REVERT: b68473c0feb Yield the thread when waiting to delete a file REVERT: 6b5554929dc std: simplify UNIX parker timeouts REVERT: 899cb3bfca1 Auto merge of #95904 - paolobarbolini:vecdeque-specextend, r=the8472 REVERT: 4deb35d1462 rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter` REVERT: d2793badd98 Add VecDeque::extend from vec::IntoIter and slice::Iter specializations REVERT: 375eaab522e Rollup merge of #96466 - compiler-errors:error-collect-array, r=davidtwco REVERT: 2d0fc9cf8ed Rollup merge of #96397 - AronParker:issue-96368-fix, r=dtolnay REVERT: 98c32a0e393 Revert "Re-export core::ffi types from std::ffi" REVERT: 2ff2ebf8b9b Remove use of reverted std::ffi::c_char REVERT: 401858f5742 Make [e]println macros eagerly drop temporaries (for backport) REVERT: af3fee83782 Revert "impl From<&[T; N]> and From<&mut [T; N]> for Vec" REVERT: 20e45c9706b Add VecDeque::extend benchmark REVERT: 1411209114f HashMap doc: Don't use monospace font for 'Entry Api' REVERT: 2907c52a20d Fixed grammatical error in example comment REVERT: f392dc2ccfd Note the importance of using sync pipes REVERT: 50deaaefc35 Add tracking issue number for mutex_unpoison REVERT: 773f31f77a3 Better error messages when collecting into `[T; n]` REVERT: 9fc57393f04 Auto merge of #96195 - sunfishcode:sunfishcode/handle-or-error-type, r=joshtriplett REVERT: 10445a841dc Windows: Make stdin pipes synchronous REVERT: 0220953e2f9 Add `set_inheritable` for Windows `Handle`s REVERT: b6765d9bb13 Rollup merge of #96415 - ehuss:git-io, r=bjorn3 REVERT: 9115483ded8 Rollup merge of #95949 - SoniEx2:patch-5, r=m-ou-se REVERT: 4e273763072 Rollup merge of #94022 - jongiddy:cow-into-owned-docs, r=Dylan-DPC REVERT: 6e25e77e138 Add functions to un-poison Mutex and RwLock REVERT: eff68b4b87e Retry deleting a directory REVERT: 8ceedba3556 Remove references to git.io REVERT: 984332fdced Rollup merge of #96149 - est31:remove_unused_macro_matchers, r=petrochenkov REVERT: c4b60f9e7d6 Rollup merge of #90312 - r00ster91:search, r=Dylan-DPC REVERT: 952b8d80966 Windows: Iterative `remove_dir_all` REVERT: 79c433118bb Make EncodeWide implement FusedIterator REVERT: 80d661ebd18 std: directly use pthread in UNIX parker implementation REVERT: d7be08bee30 Auto merge of #95246 - ChrisDenton:command-args, r=joshtriplett REVERT: 39c29c93688 Rollup merge of #96107 - Gumichocopengin8:test/vec-deque, r=Mark-Simulacrum REVERT: caa9f32d600 Auto merge of #94609 - esp-rs:esp-idf-stat-type-fixes, r=Mark-Simulacrum REVERT: 83614bdd923 test: add test cases for VecDeque REVERT: 0f0bb886d05 std: `::fmt` name the signal it died from REVERT: ad22d4b4565 Inline core::panic::Location methods REVERT: 348773fd81b Auto merge of #90602 - mbartlett21:const-intoiterator, r=oli-obk REVERT: c83caf76353 Auto merge of #95971 - workingjubilee:no-weird-fp-in-const, r=oli-obk REVERT: d49537ce7e3 Link to correct `as_mut` in docs for `pointer::as_ref` REVERT: 619cfb8611b Use const initializer for LOCAL_PANIC_COUNT REVERT: 6305f7f5822 Auto merge of #96314 - AronParker:issue-96297-fix, r=thomcc REVERT: f7074d98a5d Remove unnecessary const-time x87-related checks REVERT: d84bcd6ae1c Fix comments for float classify REVERT: f06923a43f9 Auto merge of #94887 - dylni:move-normpath-crate-impl-to-libstd, r=ChrisDenton REVERT: c6bc3e14776 Remove redundant type annotation REVERT: 9118a8cc652 Reduce allocations for path conversions on Windows REVERT: 6ae64ce820a library/core: Fixes implement of c_uint, c_long, c_ulong REVERT: 761ff0f10db Rollup merge of #96228 - mbartlett21:patch-4, r=thomcc REVERT: 7efa736e8f9 Rollup merge of #96193 - djkoloski:fuchsia_current_exe, r=tmandry REVERT: 585a66fcbeb Rollup merge of #96234 - goffrie:eloop, r=thomcc REVERT: 6f46fed856a Rollup merge of #96206 - m-ou-se:wasm-futex-locks, r=alexcrichton REVERT: 904cdefec3b Rollup merge of #96168 - chris-morgan:AddrParseError-description-improvements, r=joshtriplett REVERT: ef7035fee13 Rollup merge of #96167 - CAD97:weak-dlsym-less-ptr-crime, r=thomcc REVERT: 975c39cfc98 Auto merge of #96135 - petrochenkov:doclink6, r=GuillaumeGomez REVERT: 7d628920917 Change file locations to be links to GitHub REVERT: 1e885347ba1 remove_dir_all_recursive: treat ELOOP the same as ENOTDIR REVERT: e67d45b1ed8 Make `BorrowedFd::borrow_raw` a const fn. REVERT: b843562be12 Fix locations for intrinsics impls REVERT: 3ff5c6db98f Rollup merge of #96205 - m-ou-se:emscripten-futex-locks, r=thomcc REVERT: 93d877792a7 [fuchsia] Add implementation for `current_exe` REVERT: 92f74daec8a Clarify docs for from_raw_parts REVERT: ea81f6a1bae proc_macro: Add a workaround for rustdoc REVERT: 30a5df96375 espidf: fix stat REVERT: b2b98d7246d Rollup merge of #96089 - ojeda:no-vec-no_global_oom_handling, r=Mark-Simulacrum REVERT: 6dda90cec65 Use futex locks on emscripten. REVERT: 93836e52f9f Use futex locks on wasm+atomics. REVERT: 765b8374193 Make std::sys::wasm::futex consistent with unix::futex. REVERT: 4e0357d4ac8 Make std::sys::unix::futex consistent on emscripten. REVERT: 93c3f5c2eb6 Improve AddrParseError description REVERT: 7998786499f Add a comment explaining the `(())` idiom for empty structs. REVERT: 7e68319b1cc Split `NotHandle` into `NullHandleError` and `InvalidHandleError`. REVERT: c39407ad0b0 Move the `Error` impl for `NotHandle` out of platform-independent code. REVERT: fc680433401 Fix an incorrect word in a comment. REVERT: 3d4643496df Define a dedicated error type for `HandleOrNull` and `HandleOrInvalid`. REVERT: d458bc28e56 Auto merge of #92287 - JulianKnodt:slice_remainder, r=yaahc REVERT: 06de618ab78 Update library/core/src/result.rs REVERT: 48096ab795a Update library/core/src/result.rs REVERT: d28b40c3a20 Remove unused macro rules REVERT: 7623b062363 Rollup merge of #96156 - est31:use_from_le_bytes, r=Dylan-DPC REVERT: 88562e8831b Rollup merge of #96136 - thomcc:lifetime-wording, r=RalfJung REVERT: 5a1fa5b95eb mark ptr-int-transmute test as no_run REVERT: c70c43f51bb Auto merge of #96042 - m-ou-se:one-reentrant-mutex, r=Amanieu REVERT: d5ce7a16369 Remove forgotten reexport of ReentrantMutex in sys::unsupported. REVERT: bffe2bad706 Replace sys/unix/weak AtomicUsize with AtomicPtr REVERT: 36047921d8e Auto merge of #93530 - anonion0:pthread_sigmask_fix, r=JohnTitor REVERT: 99db9a8249a Replace u8to64_le macro with u64::from_le_bytes REVERT: 687ef71ec79 Auto merge of #96139 - erikdesjardins:revertinl2, r=Mark-Simulacrum REVERT: 2f4a7540df0 Expand core::hint::unreachable_unchecked() docs REVERT: 765f4fe9c46 Add slice::remainder REVERT: 5e8ca6d1276 move import to fix warning with emscripten target REVERT: 382968003e0 Revert "Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum" REVERT: 2bd250aaaf4 Auto merge of #96010 - eduardosm:Unique-on-top-of-NonNull, r=m-ou-se,tmiasko REVERT: 5628da4fcf8 Remove unnecessary function REVERT: a4d09221516 Improve Windows path prefix parsing REVERT: d511515c360 Reword clarification on lifetime for ptr->ref safety docs REVERT: a6fa42646c5 Auto merge of #96002 - nnethercote:speed-up-Vec-clear-2, r=m-ou-se REVERT: 6a26168886d Document the numeric value returned by string parsing for floats REVERT: 65cab187eed Document rounding for floating-point primitive operations REVERT: e2de3ce4d79 No need to check the assert all the time. REVERT: e10bdd2315b Rollup merge of #96081 - eduardosm:masks_usize_size_agnostic, r=yaahc REVERT: da8de02a216 Rollup merge of #96038 - beyarkay:patch-1, r=m-ou-se REVERT: 1efd46f3ab0 Use a single ReentrantMutex implementation on all platforms. REVERT: ce882336047 Rollup merge of #96099 - clarfonthey:maybeuninit_array_cleanup, r=dtolnay REVERT: eb891e760dd Rollup merge of #96070 - Gumichocopengin8:test/btree-map, r=thomcc REVERT: 3aa2481c789 Rollup merge of #95961 - RalfJung:gather-scatter, r=workingjubilee REVERT: 8b02a1fba0b `alloc`: make `vec!` unavailable under `no_global_oom_handling` REVERT: 87464fee35e Change `as_uninit_*` methods on `NonNull` from taking `self` by reference to taking `self` by value. This is consistent with the methods of the same names on primitive pointers. The returned lifetime was already previously unbounded. REVERT: 1bcb9691564 MaybeUninit array cleanup REVERT: e2eaed5c5f4 Auto merge of #95224 - mjbshaw:patch-1, r=yaahc REVERT: 4c24901e06b Rollup merge of #96040 - m-ou-se:futex-u32, r=Amanieu REVERT: d33135039d7 Rollup merge of #96034 - Gumichocopengin8:test/btree-set, r=Dylan-DPC REVERT: 3412a6bc993 Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelix REVERT: 8be7c4b1304 Rollup merge of #94457 - jhpratt:stabilize-derive_default_enum, r=davidtwco REVERT: 675b6323a16 update docs for option to crossreference to the result docs REVERT: ff86e1585cd Auto merge of #94079 - petrochenkov:cstr, r=joshtriplett REVERT: 1a5013c6655 Make some `usize`-typed masks definition agnostic to the size of `usize` REVERT: c881afffd28 Implement str to [u8] conversion for refcounted containers REVERT: 68d70d20493 Auto merge of #95841 - ChrisDenton:pipe-server, r=m-ou-se REVERT: 05ff04029f4 chore: formatting REVERT: 37683a51729 test: add try_insert() test cases for BTreeSet REVERT: cb546b9797e test: add get_key_value() test cases for BTreeSet REVERT: 00f23b7c114 test: add pop_first() pop_last() test cases for BTreeSet REVERT: e9440a96968 add should_panic annotations REVERT: 170bb9be61d library: Remove definitions and reexports of `strlen` from libstd REVERT: de8461fa3b4 Fix targets not supporting `target_has_atomic = "ptr"` REVERT: cc80e743c1b library: Use type aliases to make `CStr(ing)` in libcore/liballoc unstable REVERT: 550865124d9 library: Move `CStr` to libcore, and `CString` to liballoc REVERT: be7411e0327 add necessary text attribute to code block of panic output REVERT: 92b70c016b4 Use rounding in float to Duration conversion methods REVERT: 82b562ba627 Implement `core::ptr::Unique` on top of `NonNull` REVERT: 09c964947c0 Use u32 instead of i32 for futexes. REVERT: 59594e0559a Remove trailing whitespace REVERT: 90fccd46a76 docs: add link from zip to unzip REVERT: 7c9ec216695 Remove use of `#[rustc_deprecated]` REVERT: c45e10f6083 Bump stdarch REVERT: 9ec7360f1cf test: add remove() test cases for BTreeSet REVERT: 77870752ce4 test: add is_superset test cases for BTreeSet REVERT: 05c0aacc48d Add section on common message styles for Result::expect REVERT: 92e3db84380 Auto merge of #95958 - jhpratt:bump-stdarch, r=Dylan-DPC REVERT: c64f8171111 Auto merge of #96015 - Dylan-DPC:rollup-vhdprid, r=Dylan-DPC REVERT: 95a050a664d Rollup merge of #96006 - hkBst:patch-2, r=Dylan-DPC REVERT: fe9a3adf4a7 Rollup merge of #96005 - hkBst:patch-1, r=Dylan-DPC REVERT: 760574d4876 Rollup merge of #95962 - sourcefrog:doc-direntry, r=Dylan-DPC REVERT: af9efd7cc5c Auto merge of #95727 - m-ou-se:futex-reentrantmutex, r=Amanieu REVERT: 2d281047b6f Add a missing article REVERT: f6f25abc7f7 Add missing article to fix "few" to "a few". REVERT: 8a476c45aa8 Speed up Vec::clear(). REVERT: c701d51e90e Rollup merge of #95984 - wcampbell0x2a:fix-spelling, r=thomcc REVERT: 84752e1e336 Rollup merge of #95914 - c410-f3r:meta-vars, r=petrochenkov REVERT: b06734f4b1c Implement tuples using recursion REVERT: 4e54e0842c3 Fix spelling in docs for can_not_overflow REVERT: 64a1f9df1c6 portable-simd: use simd_arith_offset to avoid ptr-int transmutation REVERT: 1f464691b14 Rollup merge of #95947 - cuviper:default-box, r=dtolnay REVERT: 90725c65e65 Rollup merge of #95900 - o01eg:fix-wasm-doc, r=Mark-Simulacrum REVERT: d753999e2f3 Ban subnormals and NaNs in const {from,to}_bits REVERT: 2e8d561d6d5 Rectify float classification impls for weird FPUs REVERT: 43e6b5a6505 Add missing unsafe marker. REVERT: 9f59b20c99e Allow cvt_nz to be unused on some platforms. REVERT: 443cc232103 Add #[deny(unsafe_op_in_unsafe_fn)] to thread_local!(const). REVERT: 0ef51479277 Add debug asserts to futex ReentrantMutex impl. REVERT: 9c76f11f908 Initialize thread local with const{}. REVERT: e70c0b37da6 Move current_thread_unique_ptr to the only module that uses it. REVERT: f5c8995e409 Make current_thread_unique_ptr work during thread destruction. REVERT: a642c6a7dc5 Add futex-based ReentrantMutex on Linux. REVERT: 03bbcf75e23 Add current_thread_unique_ptr() in std::sys_common. REVERT: 45c04d323dd Auto merge of #95399 - gilescope:plan_b, r=scottmcm REVERT: 76b8a0ea769 Document that DirEntry holds the directory open REVERT: b2a24ff5ab8 Bump stdarch REVERT: 473c6122514 Auto merge of #93408 - liangyongrui:master, r=scottmcm REVERT: b4cbf8f9bf6 Implement Default for AssertUnwindSafe REVERT: 265345c08c8 impl const Default for Box<[T]> and Box REVERT: 2e411410b66 Rollup merge of #95895 - CAD97:patch-2, r=Dylan-DPC REVERT: f4338b63200 Rollup merge of #95894 - nyanpasu64:fix-pin-docs, r=Dylan-DPC REVERT: c9655a7e2c7 Rollup merge of #95801 - m-ou-se:futex-rwlock, r=Amanieu REVERT: 9872ff64889 Fix documentation for wasm32-unknown-unknown REVERT: 717837df9b8 Use is_ or has_ prefix for pure `-> bool` functions. REVERT: 9e3483990ad Use compare_exchange_weak in futex rwlock implementation. REVERT: acd2e9179c4 Add comments to futex rwlock implementation. REVERT: fbc611bbaa0 Add doc comments to futex operations. REVERT: a5b69a0d28a Rollup merge of #95917 - RalfJung:thin-box-test, r=dtolnay REVERT: f963fb88013 Rollup merge of #95743 - yaahc:binary-search-clarification, r=Mark-Simulacrum REVERT: c272de7cded better def of is signed in tests. REVERT: d6872924508 fix Layout struct member naming style REVERT: fd0958b3392 thin_box test: import from std, not alloc REVERT: 7747ffa501f kmc-solid: Use `abort` to abort a program REVERT: 4b86c1a9174 Clarify str::from_utf8_unchecked's invariants REVERT: 3d553994234 Fix formatting error in pin.rs docs REVERT: f28c8801f42 Rollup merge of #95566 - eduardosm:std_char_consts_and_methods, r=Mark-Simulacrum REVERT: da8ef4eea54 No need to use Default REVERT: 51b34e9061a Use Add, Sub, Mul traits instead of unsafe REVERT: 75aec964ec9 Auto merge of #95621 - saethlin:remove-mpsc-transmute, r=RalfJung REVERT: 26a1c21ce73 Rollup merge of #95831 - redzic:xor-uppercase, r=workingjubilee REVERT: dce83841f76 Rollup merge of #95817 - oconnor663:doc_comment2, r=yaahc REVERT: e8afa809bfd Rollup merge of #95805 - c410-f3r:meta-vars, r=petrochenkov REVERT: efd1af6ab4a Rollup merge of #95361 - scottmcm:valid-align, r=Mark-Simulacrum REVERT: afded7fa783 Rollup merge of #94794 - mlodato517:mlodato517-clarify-string-indexing-docs, r=Mark-Simulacrum REVERT: 9ca1fef6df3 Rework String UTF-8 Documentation REVERT: 06842600783 Rollup merge of #95802 - RalfJung:unused-win, r=Dylan-DPC REVERT: a7f48aa6cf3 Rollup merge of #95308 - bjorn3:more_stable_proc_macro, r=Mark-Simulacrum REVERT: 42e8d8e8556 Rollup merge of #95787 - yaahc:panic-doc-update-v2, r=dtolnay REVERT: 1b7c01df915 Remove ptr-int transmute in std::sync::mpsc REVERT: 61f91a1a24c Make non-power-of-two alignments a validity error in `Layout` REVERT: b9f0e9cdaf1 Use bitwise XOR in to_ascii_uppercase REVERT: 13c8e1fa5e8 hide another #[allow] directive from a docs example REVERT: 06e229f5cb5 Add ThinBox type for 1 stack pointer sized heap allocated trait objects REVERT: 00ffa394ede Fix typo in futex rwlock. REVERT: 4353d5d94c5 Left overs of #95761 REVERT: bf620ad88a6 fix some unused constant warning on some Windows targets REVERT: 6f884dfc3e4 Add futex-based RwLock on Linux. REVERT: 22f071bf6e9 Auto merge of #95798 - Dylan-DPC:rollup-51hx1wl, r=Dylan-DPC REVERT: 9405d6aaec6 Windows: Use a pipe relay for chaining pipes REVERT: fd1986291f4 Rollup merge of #95791 - oconnor663:doc_comment, r=thomcc REVERT: d7bfd9f55c8 Rollup merge of #95782 - ChrisDenton:pipe-buffer-size, r=thomcc REVERT: 7b8b355f58f Rollup merge of #95761 - c410-f3r:meta-var-stuff, r=petrochenkov REVERT: 9802ade9c8d Rollup merge of #95579 - Cyborus04:slice_flatten, r=scottmcm REVERT: 5ac7317623f Auto merge of #95775 - RalfJung:miri-windows-compat, r=ChrisDenton REVERT: c289c4d99bb add `<[[T; N]]>::flatten`, `<[[T; N]]>::flatten_mut`, and `Vec::<[T; N]>::into_flattened` REVERT: 2a74590f22a hide an #[allow] directive from the Arc::new_cyclic doc example REVERT: e0cafa6e883 Add documentation REVERT: 74c559b1a82 Stabilize `derive_default_enum` REVERT: cf751d413cf reword panic vs result section to remove recoverable vs unrecoverable framing REVERT: 83d59c30c00 Windows: Increase a pipe's buffer capacity to 64kb REVERT: 69671d45201 do not round-trip function pointer through integer REVERT: 2b35e15ce41 make windows compat_fn (crudely) work on Miri REVERT: 0fb0ce966b4 Kickstart the inner usage of macro_metavar_expr REVERT: 40639df44e8 Auto merge of #95760 - Dylan-DPC:rollup-uskzggh, r=Dylan-DPC REVERT: de4313f72ae Return status from futex_wake(). REVERT: 7a12188cf5e Rollup merge of #95757 - zofrex:gender-neutral-terms, r=dtolnay REVERT: ddee8e8dfb6 Rollup merge of #95753 - ChayimFriedman2:patch-1, r=dtolnay REVERT: 794da8bd253 Use gender neutral terms REVERT: f2447afcc85 Auto merge of #95678 - pietroalbini:pa-1.62.0-bootstrap, r=Mark-Simulacrum REVERT: c11d568899c Auto merge of #95748 - Dylan-DPC:rollup-t208j51, r=Dylan-DPC REVERT: cc85298e85a Correct safety reasoning in `str::make_ascii_{lower,upper}case()` REVERT: c40372276de Rollup merge of #95725 - hkBst:patch-1, r=Dylan-DPC REVERT: 142cde64b52 Rollup merge of #95708 - fee1-dead:doc_whitespace_trim, r=Dylan-DPC REVERT: 4b99f29bc48 Rollup merge of #95646 - mgeisler:mention-std-env-var, r=Dylan-DPC REVERT: dbe61087da0 Update library/core/src/slice/mod.rs REVERT: e94bc6ff7f9 remove exclamation mark REVERT: c69dee39052 Auto merge of #95688 - pfmooney:libc-update, r=Mark-Simulacrum REVERT: 795bd1949de add necessary closure for partition_point REVERT: dedab33f3d5 Rollup merge of #95735 - bjorn3:revert_inline_location_caller, r=compiler-errors REVERT: a53f3e630b8 Rollup merge of #95709 - nnethercote:improve-terse-test-output, r=Dylan-DPC REVERT: 94c624ad969 Rollup merge of #95626 - saethlin:pass-pointer-to-prctl, r=cuviper REVERT: dd586e4188d Rollup merge of #95185 - m-ou-se:stabilize-stdin-lines, r=Mark-Simulacrum REVERT: 2ba15b052ac Update binary_search example to instead redirect to partition_point REVERT: 6060a9b4dc8 Change trailing prctl arguments to c_ulong REVERT: 160a9660ebe Use PhantomData directly in Bridge REVERT: 355fd0a9f57 Revert "Mark Location::caller() as #[inline]" REVERT: bd02d680c6e Bump stabilization of stdin_forwarders to 1.62.0. REVERT: 76e7f6410dc Rename RWLock to RwLock in std::sys. REVERT: 84ef6f76413 Mention `std::env::var` in `env!` REVERT: b18a7e86459 Message: Chunks cannot have a size of zero. REVERT: 32f0fa74991 Auto merge of #95711 - Dylan-DPC:rollup-ujss3oi, r=Dylan-DPC REVERT: 41725b5208d Rollup merge of #95699 - SparkyPotato:master, r=dtolnay REVERT: d2a021f9cc7 Rollup merge of #95659 - anp:remove-link-print, r=tmandry REVERT: 78404df3717 Auto merge of #95469 - ChrisDenton:unsound-read-write, r=joshtriplett REVERT: 3e1e1631abe Improve terse test output. REVERT: 874f8361808 Update documentation for `trim*` and `is_whitespace` to include newlines REVERT: ccfbdf7d519 Auto merge of #95702 - Dylan-DPC:rollup-793rz6v, r=Dylan-DPC REVERT: 61c5c5d02bb trivial cfg(bootstrap) changes REVERT: d44636cfb62 Rollup merge of #95663 - notriddle:notriddle/unsafe-fn-closure, r=compiler-errors REVERT: 2b124dc0947 Rollup merge of #95547 - RalfJung:ptr-int-transmutes, r=scottmcm REVERT: a0912ea669c Rollup merge of #88025 - devnexen:netbsd_scm_creds, r=Amanieu REVERT: 981b4dbc294 Auto merge of #95035 - m-ou-se:futex-locks-on-linux, r=Amanieu REVERT: 1447564cb1e formatting REVERT: 463cb36eb61 cleanup REVERT: 0ee35a58a8a fix Vec leak with 0 capacity REVERT: 23a11f6890d diagnostics: tweak error message to give more rationale to unsafe Fn REVERT: 5fe389b35f4 Update libc to 0.2.121 REVERT: a31370ca511 Reword comment in futex condvar implementation. REVERT: e4bba3097a4 Rollup merge of #95660 - yaahc:panic-docs-update, r=Dylan-DPC REVERT: e28132c94da Mark unix::locks::futex::Mutex::new as #[inline]. REVERT: 911a030e72f Use rtabort REVERT: 2cb3c6d09b9 Make `synchronous_write` safe to call REVERT: acf515848be Document synchronicity REVERT: fffabafa5c2 Complete reads and writes synchronously or abort REVERT: 023b6d2602c Correct definition of `IO_STATUS_BLOCK` REVERT: dbc04c75282 Fix bogus tidy errors REVERT: 9d486d12a11 diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut REVERT: 5b63aa5c4fa Rollup merge of #95630 - declanvk:update-nonnull-doc, r=RalfJung REVERT: 6c61973dca1 Rollup merge of #95588 - RalfJung:strict-provenance, r=scottmcm REVERT: 4efdfe68d4a Rollup merge of #91873 - estebank:mention-impls-for-unsatisfied-trait, r=davidtwco REVERT: 9ecd1c9a3b8 Update panic docs to make it clearer when to use panic vs Result REVERT: 1d8e3ccca69 Rely on #[link] attribute for unwind on Fuchsia. REVERT: d5085716bea explicitly distinguish pointer::addr and pointer::expose_addr REVERT: 12b92fbe258 Mention implementers of unsatisfied trait REVERT: 7fc788e8dc4 Rollup merge of #95467 - ChrisDenton:async-read-pipe, r=joshtriplett REVERT: cce6338d33a Rollup merge of #95438 - m-ou-se:sync-unsafe-cell, r=joshtriplett REVERT: 7a7afe40c04 Rollup merge of #95431 - golddranks:stabilize_total_cmp, r=scottmcm REVERT: a38b02520e7 Rollup merge of #92942 - Xaeroxe:raw_arg, r=dtolnay REVERT: 0e70d567ce9 Correct calling convention REVERT: 1cf60129067 Bump windows CommandExt::raw_arg to 1.62 REVERT: af204ce9ba9 from_u32(0) can just be default() REVERT: 16d5de917d4 Stabilize total_cmp REVERT: 4e515963f2e Update library/std/src/sys/windows/pipe.rs REVERT: e0a1da26da9 Auto merge of #95031 - compiler-errors:param-env-cache, r=Aaron1011 REVERT: 3de1121d581 Add doc links referencing raw pointer methods REVERT: 2c87826465c ScmCredentials netbsd implementation. REVERT: 1a04acef125 Auto merge of #95619 - bjorn3:inline_location_caller, r=scottmcm REVERT: df46dc663cf Rollup merge of #95618 - adamse:master, r=dtolnay REVERT: ca2a9bd9367 Rollup merge of #95617 - saethlin:swap-test-invalidation, r=Dylan-DPC REVERT: cd27f9142d6 Don't cast thread name to an integer for prctl REVERT: 3206c67d9b7 Refer to the `exposed` versions of the methods instead REVERT: f6b29d4bb5b Fix &mut invalidation in ptr::swap doctest REVERT: ad1a5838f39 Auto merge of #95610 - createyourpersonalaccount:derefmut-docfix, r=Dylan-DPC REVERT: 3a953ab1d8d Mark Location::caller() as #[inline] REVERT: adf967abad1 core: document that the align_of* functions return the alignment in bytes REVERT: db20be20264 Auto merge of #92686 - saethlin:unsafe-debug-asserts, r=Amanieu REVERT: 2dbc8eb439f Update safety comments, make `split_at_mut` unsafe REVERT: 3c2d32aa70d Auto merge of #90791 - drmorr0:drmorr-memcmp-cint-cfg, r=petrochenkov REVERT: 50e91c0209c Improve doc example of DerefMut REVERT: 2488f157804 make memcmp return a value of c_int_width instead of i32 REVERT: 675d70613a9 Fix `array::IntoIter::fold` to use the optimized `Range::fold` REVERT: 9c98eca7abe Rollup merge of #95597 - dtolnay:threadlocalu8, r=Dylan-DPC REVERT: 5f3e7ef1327 Rollup merge of #95587 - m-ou-se:std-remove-associated-type-bounds, r=Dylan-DPC REVERT: 8edcfd891ac Refer to u8 by absolute path in expansion of thread_local REVERT: a8f049bf0d1 add tracking issue REVERT: c3b4b51e995 Additional `*mut [T]` methods REVERT: 2c3f31ff995 refine wording and describe alternatives REVERT: 503d2ac1f5d need guidence on testing REVERT: 8b49a0fb20a incorporating feedback REVERT: 656628a3eb8 Create 2024 edition REVERT: 2b17d6ccbba Deprecate the `ptr_to_from_bits` feature REVERT: 2e369963afa Rollup merge of #95557 - niluxv:issue-95533, r=dtolnay REVERT: 74c772b55ab Rollup merge of #95556 - declanvk:nonnull-provenance, r=dtolnay REVERT: c4a44575351 Rollup merge of #95354 - dtolnay:rustc_const_stable, r=lcnr REVERT: 832f8002409 Auto merge of #95552 - matthiaskrgr:rollup-bxminn9, r=matthiaskrgr REVERT: 601c9635560 Avoid duplication of doc comments in `std::char` constants and functions. REVERT: 73549721038 Rollup merge of #95546 - autumnontape:allocator-realloc-align-docs, r=Amanieu REVERT: 82df8e28d6c Rollup merge of #95532 - RalfJung:utf8_char_counts, r=Dylan-DPC REVERT: e071b6ce566 Rollup merge of #95528 - RalfJung:miri-is-too-slow, r=scottmcm REVERT: 6d40508e0dd Rollup merge of #95516 - RalfJung:ptrs-not-ints, r=dtolnay REVERT: 07da7c0599f Use MaybeUninit for clock_gettime's timespec. REVERT: 1ae5b72f85a Don't spin on contended mutexes. REVERT: 643222f1dbf Shuffle around #[inline] and #[cold] in mutex impl. REVERT: f154ddbb67a Add comment about futex_wait timeout. REVERT: 1a58048ea62 Fix `thread_local!` macro to be compatible with `no_implicit_prelude` REVERT: 74754f23d53 Remove need for associated_type_bounds in std. REVERT: e190368b1a9 Implement provenance preserving method on NonNull REVERT: dc5b41e8928 Rollup merge of #95032 - m-ou-se:std-features, r=yaahc REVERT: 801fd3ecebb caution against ptr-to-int transmutes REVERT: 07e6629774a add notes about alignment-altering reallocs to Allocator docs REVERT: 6eed4a85c1a Fix feature name of stable parts of strict_provenance REVERT: d2d0d3e9610 Adjust MaybeUninit feature names to avoid changing unstable one REVERT: 997be8de974 Adjust feature names that disagree on const stabilization version REVERT: 5c52b001d0d make utf8_char_counts test faster in Miri REVERT: cb2913bc9bb Categorize and sort unstable features in std. REVERT: 3928ea4d60a skip slow int_log tests in Miri REVERT: 4fdb6b7d5ad Rollup merge of #95520 - rust-lang:ptrtypo, r=lcnr REVERT: f190f8b4932 Rollup merge of #95384 - ehuss:doc-target_has_atomic-stabilized, r=Dylan-DPC REVERT: d9d078694fe Fix typos in core::ptr docs REVERT: 857a2eddcfa ptr_metadata test: avoid ptr-to-int transmutes REVERT: 05e7eddeea1 Rollup merge of #95505 - sunfishcode:sunfishcode/fix-openbsd, r=dtolnay REVERT: c70a6f32793 match std f32 primitive docs to core f32 primitive docs REVERT: ed8e5755f3f Further refine the disclaimer about NaN bit patterns. REVERT: f1955398dab Re-introduce "propagating NaN" to `maximum`/`minimum`, add "ignoring NaN" to `max`/`min`, add disclaimer about the "propagation". REVERT: 923116dbdce Rollup merge of #95491 - faern:stabilize-vec_retain_mut, r=yaahc REVERT: dc3f6a25b54 Rollup merge of #95130 - workingjubilee:stably-finished, r=m-ou-se REVERT: b186d284bd2 Remove antipattern from process::exit docs REVERT: 870f8be9843 Add ExitCode::exit_process() REVERT: 475820140de Improve wording of "NaN as a special value" top level explanation REVERT: fdf56b5b738 Fix library/std compilation on openbsd. REVERT: 5e25f98b856 Rollup merge of #95298 - jhorstmann:fix-double-drop-of-allocator-in-vec-into-iter, r=oli-obk REVERT: 7be6ad45e7e Stabilize native library modifier syntax and the `whole-archive` modifier specifically REVERT: 72d419c20a6 Stabilize feature vec_retain_mut on Vec and VecDeque REVERT: 7c75dd2bcfb Add references to explanation about portability to f{32,64}::{from,to}_{be,le,ne}_bytes REVERT: 0db498c0db3 Fix: is_sign_positive -> is_sign_negative REVERT: 426d0782804 Improve floating point documentation: REVERT: 7a23aa978df Auto merge of #94963 - lcnr:inherent-impls-std, r=oli-obk,m-ou-se REVERT: 08912a66353 Don't stabilize ScopedJoinHandle::is_finished yet. REVERT: 789158d50f2 Synchronize asynchronous pipe reads and writes REVERT: e534cbd5aa2 Auto merge of #95241 - Gankra:cleaned-provenance, r=workingjubilee REVERT: c5a56bad17a remove now unnecessary lang items REVERT: cac61fe046c rework implementation for inherent impls for builtin types REVERT: 0c2a46810ba Rollup merge of #95452 - yaahc:termination-version-correction, r=ehuss REVERT: b93d75ac4c4 Rollup merge of #95294 - sourcefrog:doc-copy, r=dtolnay REVERT: 67d9a0d6e56 Warn that platform-specific behavior may change REVERT: 9a30be661bd fix unix typedef REVERT: 9b62fc5499b fixup feature position in liballoc REVERT: 7e23e18d067 clarify that WASM has address spaces REVERT: 04e767c1cca fix doc link REVERT: d7f6cd3cf6a refine the definition of temporal provenance REVERT: c61b0128326 mark FIXMES for all the places found that are probably offset_from REVERT: 7c242c38da3 more review fixes to ptr docs REVERT: 76a0ea39b6a Add even more details to top-level pointer docs REVERT: 0a0c064567f cleanup some of the less terrifying library code REVERT: fe67cd8e416 clean up pointer docs REVERT: daae8a8cb9f revert changes that cast functions to raw pointers, portability hazard REVERT: b30a24f5545 Make some linux/unix APIs better conform to strict provenance. REVERT: 435e38a7a3e Make the stdlib largely conform to strict provenance. REVERT: 28cbb765863 Introduce experimental APIs for conforming to "strict provenance". REVERT: 2be3f131c31 fix since field version for termination stabilization REVERT: 24016500c7c Rollup merge of #95256 - thomcc:fix-unwind-safe, r=m-ou-se REVERT: c2e1accf6dd Rollup merge of #93840 - yaahc:termination-stabilization-celebration-station, r=joshtriplett REVERT: 0a8cb8665a4 Indicate the correct error code in the `compile_fail` block. REVERT: 483c4140a75 Add tracking issue for sync_unsafe_cell. REVERT: d60214a9c99 Auto merge of #95433 - Dylan-DPC:rollup-xdfit9h, r=Dylan-DPC REVERT: 15921bc8b9f Add SyncUnsafeCell. REVERT: 6c3ecc2eaf8 Auto merge of #94566 - yanganto:show-ignore-message, r=m-ou-se REVERT: a0f6ea14a25 Rollup merge of #94566 - yanganto:show-ignore-message, r=m-ou-se REVERT: 1724cdb2b99 Add debug assertions to some unsafe functions REVERT: 6bbbc6eac3a Remove unnecessary .as_ref(). REVERT: 4d315b80199 Refactor after review REVERT: c8bd8c95614 Auto merge of #95375 - MarcusCalhoun-Lopez:i686_apple_darwin, r=m-ou-se REVERT: 748076b3b2b Auto merge of #95249 - HeroicKatora:set-ptr-value, r=dtolnay REVERT: 4a1e4cd817d Fix build on i686-apple-darwin systems REVERT: f209ce167c8 Fix build on i686-apple-darwin systems REVERT: 5aee57a9652 Rollup merge of #95407 - xfix:inline-u8-is_utf8_char_boundary, r=scottmcm REVERT: 58394890c82 Rollup merge of #95397 - dtolnay:disclaimer, r=m-ou-se REVERT: b281689a7c5 Touch up ExitCode docs REVERT: 16047c2ceff Inline u8::is_utf8_char_boundary REVERT: 625bd5270bb Link to std::io's platform-specific behavior disclaimer REVERT: 21a06179b92 Rollup merge of #95098 - shepmaster:vec-from-array-ref, r=dtolnay REVERT: 7d8d4544512 Rollup merge of #95016 - janpaul123:patch-1, r=dtolnay REVERT: 9bc5a192f0f Rollup merge of #93755 - ChayimFriedman2:allow-comparing-vecs-with-different-allocators, r=dtolnay REVERT: 6224961a00d Rollup merge of #88375 - joshlf:patch-3, r=dtolnay REVERT: 85e316e2d84 Update target_has_atomic documentation for stabilization REVERT: a38976f7a0d Rollup merge of #95368 - lopopolo:lopopolo/string-try-reserve-exact-doc-typo, r=Dylan-DPC REVERT: caf027b5f43 Fix typo in `String::try_reserve_exact` docs REVERT: f23700fd5cf Use default alloc_error_handler for hermit REVERT: 8602dfc7bd8 Debug print char 0 as '\0' rather than '\u{0}' REVERT: bc8ce463f41 Support arrays of zeros in Vec's __rust_alloc_zeroed optimization REVERT: 31de1aa117c Bump const_ptr_offset stabilization to 1.61 REVERT: c5372a1cef9 Auto merge of #95274 - jendrikw:slice-must-use, r=Dylan-DPC REVERT: 72d12e65ce9 Using macro to avoid performance hit (thanks LingMan) REVERT: e5247a646f3 Update library/core/src/num/mod.rs REVERT: 5e98bc85a56 Better explanation REVERT: 84b6f8c6e89 Update library/core/src/num/mod.rs REVERT: 8d58eb2f888 removed likely REVERT: e8208b701d1 Update library/core/src/num/mod.rs REVERT: c34e749d128 Update library/core/src/num/mod.rs REVERT: f0d0fb6e06a add likely and clearer comments REVERT: 3ad4e471ad2 faster parsing when not possible to overflow REVERT: cc8d5885e03 Auto merge of #95326 - lupd:std-iter-doc, r=Dylan-DPC REVERT: 124b00ee343 add #[must_use] to functions of slice and its iterators. REVERT: 19641f19cd0 Remove mention of HashMap not offering iter_mut REVERT: b6d4430edd3 Add note about feature gates REVERT: 0ae89ba17a2 Check for `"` and `\` in a filename REVERT: bd7b0ef17e2 Avoid negative impls in the bridge REVERT: 61007e32d54 Remove usage of extern_types feature gate REVERT: 2d93897a1a6 Remove usage of panic_update_hook feature gate REVERT: 1f86b84ad2d Remove unused auto_traits feature gate REVERT: 3e1eb11085e Add another assertion without into_iter REVERT: be291a414f2 std::process docs: linkify references to output, spawn and status REVERT: 6aa246eca3f Add a test verifying the number of drop calls REVERT: c5f57171d7f Use ManuallyDrop::take instead of into_inner REVERT: 72dc647a64a Fix double drop of allocator in IntoIter impl of Vec REVERT: 823e394db7f Adjust tests for isize::MAX allocation always being checked REVERT: f68f1cbbe62 Enforce that layout size fits in isize in Layout REVERT: ae12c63c809 Document Linux kernel handoff in std::io::copy and std::fs::copy REVERT: 9a9a2324f0f Rollup merge of #95276 - FoseFx:clippy_trim_split_whitespace, r=flip1995 REVERT: be3ce2ff99b Auto merge of #94517 - aDotInTheVoid:inline_wrapping_next_power_two, r=yaahc REVERT: 71f4a75f174 add diagnostic items for clippy's REVERT: ac9d90edc05 add #[must_use] to functions of slice and its iterators. REVERT: a8612f27b07 Explicitly use CLOCK_MONOTONIC in futex_wait. REVERT: b209e94a45b Make Timespec available in sys::unix. REVERT: 0325198ef53 Use FUTEX_WAIT_BITSET rather than FUTEX_WAIT on Linux. REVERT: 4a87ae28692 Auto merge of #87667 - the8472:document-in-place-iter, r=yaahc REVERT: 0226a08d85b Add a `compile_fail` doctest to check that `io::Error: !UnwindSafe` REVERT: ba67ee343d6 Ensure io::Error's bitpacked repr doesn't accidentally impl UnwindSafe REVERT: 129b93181c9 fix some links, clarify documentation based on review feedback REVERT: 74c1f9c8f5c Refactor set_ptr_value as with_metadata_of REVERT: 91199234b4f Explicitly mention overflow is what we're checking REVERT: 5eeb8f939d5 Auto merge of #94901 - fee1-dead:destructable, r=oli-obk REVERT: b7c6aab1b3d Spin before blocking in Mutex::lock. REVERT: 824c21fa20b Update tests. REVERT: 55b11eafb5e Replace Linux Mutex and Condvar with futex based ones. REVERT: 79f439dedd3 Add futex_wake_all. REVERT: f3ae25b2b48 Return timeout status in futex_wait. REVERT: 6978a726caf Clarify that `Cow::into_owned` returns owned data REVERT: 450660793d3 Auto merge of #95235 - asquared31415:ptr_eq_typo, r=Dylan-DPC REVERT: 7ca93f8828c ptr::guaranteed_eq doc typo REVERT: 5fdaaa78102 Auto merge of #95173 - m-ou-se:sys-locks-module, r=dtolnay REVERT: 9b03b219c95 Add test for issue #95178 REVERT: 5a0e648c359 Command: handle exe and batch files separately REVERT: 3c30c6a7998 Refactor: Move argument building into args REVERT: b7f7e508805 Auto merge of #95223 - Dylan-DPC:rollup-idpb7ka, r=Dylan-DPC REVERT: 1d1c4870788 Format unsafe {} blocks REVERT: 66c35c91528 Optimize RcInnerPtr::inc_strong instruction count REVERT: dcc3c175b43 Rollup merge of #94713 - clarfonthey:is_char_surrogate, r=scottmcm REVERT: af11c712569 Rollup merge of #92955 - llogiq:cloned-side-effect-doc, r=yaahc REVERT: 574eb46fd3f Rollup merge of #91608 - workingjubilee:fold-neon-fp, r=nagisa,Amanieu REVERT: aaf2c5526ea Auto merge of #95088 - bjorn3:fix_test_variadic_fnptr, r=dtolnay REVERT: a49f9b9cda1 Fold aarch64 feature +fp into +neon REVERT: 560a537850a Limit test_variadic_fnptr to unix REVERT: 190b399c721 Remove impossible panic note from `Vec::append` REVERT: 7d625448e67 add perf side effect docs to `Iterator::cloned()` REVERT: 8c60dbc8242 Move std::sys::{mutex, condvar, rwlock} to std::sys::locks. REVERT: 5241edec430 add some fix REVERT: 2d22859bca5 fix the lint problem REVERT: 76a2bdfad3e update Termination trait docs REVERT: aa79b363e12 Auto merge of #95107 - r00ster91:fmt, r=joshtriplett REVERT: d31d1f7def5 Auto merge of #95158 - sunfishcode:sunfishcode/windows-8, r=joshtriplett REVERT: 5fea53eb339 Add u16::is_utf16_surrogate REVERT: 6ac492ecc5d rename internal helper trait AsIntoIter to AsVecIntoIter REVERT: acd4c3f9483 Stabilize Stdin::lines. REVERT: cf56b7ab65c weaken needlessly restrictive orderings on `Arc::*_count` REVERT: 27f0821bc1b add module-level documentation for vec's in-place iteration REVERT: d1d26a51696 move AsIntoIter helper trait and mark it as unsafe REVERT: bfc8a6338f3 rename module to better reflect its purpose REVERT: 9ab92010ee0 Move pthread locks to own module. REVERT: fdf44c13406 Rename `~const Drop` to `~const Destruct` REVERT: f6b03df3595 Add `Destructible` for replacing `~const Drop` REVERT: 4ba4aa08bc6 Add a testcase. REVERT: 283dfb3fa07 Preserve the Windows `GetLastError` error in `HandleOrInvalid`. REVERT: 52b76e46dcd Don't declare test_variadic_fnptr with two conflicting signatures REVERT: bffb4350252 Rollup merge of #95114 - ChrisDenton:symlink-test, r=the8472 REVERT: 27c5501d90c Auto merge of #92962 - frank-king:btree_entry_no_insert, r=Amanieu REVERT: cfd84624218 Rollup merge of #95110 - wmstack:patch-1, r=Dylan-DPC REVERT: f8b944f059a Rollup merge of #94989 - compiler-errors:stream-alias, r=Dylan-DPC REVERT: 60fe4962f1a Rollup merge of #94749 - RalfJung:remove-dir-all-miri, r=cuviper REVERT: 3361f7c6eef Stabilize thread::is_finished REVERT: 9702ad9cb91 Auto merge of #94372 - erikdesjardins:asrefinl, r=dtolnay REVERT: cc4b1270ada Skip a test if symlink creation is not possible REVERT: e2b05ea67a5 Rollup merge of #94991 - CAD97:const-weak-new, r=dtolnay REVERT: 16098e27052 Rollup merge of #94650 - ChrisDenton:windows-absolute-fix, r=dtolnay REVERT: 9fad18878e7 Rollup merge of #93858 - krallin:process-process_group, r=dtolnay REVERT: 1c657737d12 Improve formatting in macro REVERT: 239043a0a86 Provide more useful documentation of conversion methods REVERT: bebd214df74 Rollup merge of #94984 - ericseppanen:cstr_from_bytes, r=Mark-Simulacrum REVERT: 0afb9517cda Rollup merge of #93692 - mfrw:mfrw/document-keyword-in, r=dtolnay REVERT: 4fdc4fab539 Rollup merge of #93263 - sunfishcode:sunfishcode/detatched-console-handle, r=dtolnay REVERT: bb61df47639 Rollup merge of #92663 - cuviper:generic-write-cursor, r=dtolnay REVERT: d110cd63f3c Rollup merge of #92612 - atopia:update-lib-l4re, r=dtolnay REVERT: 597dbd6c58e Rollup merge of #92519 - ChrisDenton:command-maybe-verbatim, r=dtolnay REVERT: 34d0386e8cc impl From<&[T; N]> and From<&mut [T; N]> for Vec REVERT: 07c2152fe64 Make Weak::new const REVERT: e2cb1dd166b add CStr::from_bytes_until_nul REVERT: 6c5607a3746 Bump impl Write for Cursor<[u8; N]> to 1.61 REVERT: 757ca4d8dec Rollup merge of #95083 - danielhenrymantilla:patch-2, r=RalfJung REVERT: 189d2c26178 Rollup merge of #95058 - wcampbell0x2a:use-then-in-unix-process, r=dtolnay REVERT: acedd6cc9fa Rollup merge of #95017 - zachs18:cmp_ordering_derive_eq, r=Dylan-DPC REVERT: 42891651e56 Rollup merge of #94115 - scottmcm:iter-process-by-ref, r=yaahc REVERT: 72617aa1c2d Document that `Option` discriminant elision applies for any ABI REVERT: ea7d31032dc Auto merge of #88098 - Amanieu:oom_panic, r=nagisa REVERT: bf5574c42a1 feat: Add use of bool::then in sys/unix/process REVERT: 074295c2270 Rollup merge of #94960 - codehorseman:master, r=oli-obk REVERT: fbe64425872 Rollup merge of #93745 - tarcieri:stabilize-adx, r=cjgillot REVERT: dd85fd77113 Add test for StructuralEq for std::cmp::Ordering. REVERT: 8b2eee74d0f Derive Eq for std::cmp::Ordering, instead of using manual impl. REVERT: 0960df3f5c9 Docs: make Vec::from_raw_parts documentation less strict REVERT: 6518f466bcd BTree: evaluate static type-related check at compile time REVERT: 930c2df785a resolve the conflict in compiler/rustc_session/src/parse.rs REVERT: 4e3e6d48ed6 Add Stream alias for AsyncIterator REVERT: 8a34aaf2a61 Rollup merge of #94957 - iamzhangyong:explanation-read_line, r=Dylan-DPC REVERT: 815573352ed Rollup merge of #94868 - dtolnay:noblock, r=Dylan-DPC REVERT: cda4d4f0483 changed wording REVERT: 0070a9bc41c Rollup merge of #94947 - Dylan-DPC:fix/typos, r=oli-obk REVERT: 6f7af63de6d Improve the explanation about the behaviour of read_line REVERT: 2cfc6d78084 Unstably constify `impl IntoIterator for I: ~const Iterator` REVERT: b7cd932b834 fix typos REVERT: e9a43b69a87 Stabilize ADX target feature REVERT: 38abe83a68e Rollup merge of #90621 - adamgemmell:dev/stabilise-target-feature, r=Amanieu REVERT: 2f5cdd33b9f Add a `process_group` method to UNIX `CommandExt` REVERT: acce057ddcd Stabilise `aarch64_target_feature` REVERT: e5a5cc524d1 refactor: VecDeques Iter fields to private REVERT: f506bf4e079 Auto merge of #94916 - matthiaskrgr:rollup-s6zedfl, r=matthiaskrgr REVERT: 035ca1cc84d Rollup merge of #94816 - WaffleLapkin:atomic_get_mut_slice, r=Mark-Simulacrum REVERT: fb91bf09f25 Rollup merge of #93292 - nvzqz:nonzero-bits, r=dtolnay REVERT: e4f96d5ca1b Auto merge of #94738 - Urgau:rustbuild-check-cfg-values, r=Mark-Simulacrum REVERT: 454ef166f5a Use reduce_sum in as_simd example REVERT: 5f6f29a1890 Sync portable-simd to rust-lang/portable-simd@72df4c45056a8bc0d1b3f06fdc828722177f0763 REVERT: 522a73eb954 Use `Self::BITS` in `log2` implementation REVERT: c2a2f213fdc Implement `BITS` constant for non-zero integers REVERT: 63268b085b7 Format core and std macro rules, removing needless surrounding blocks REVERT: e93752fd163 Auto merge of #94860 - Dylan-DPC:rollup-n06j8h6, r=Dylan-DPC REVERT: 0a92cc7afa8 Rollup merge of #94838 - antonok-edm:float-parse-docs, r=Dylan-DPC REVERT: edf7baae1d1 Rollup merge of #94818 - yoshuawuyts:into-future-associated-type, r=joshtriplett REVERT: b52d6423ea8 Rollup merge of #87618 - GuillaumeGomez:std-char-types-doc, r=jyn514,camelid REVERT: cff7f23f6e4 Auto merge of #94472 - JmPotato:use_maybeuninit_for_vecdeque, r=m-ou-se REVERT: 8a3544aee73 Update tests. REVERT: 694561d1a60 Update advance and advance_slices docs. REVERT: 7e59c449746 Panic when advance_slices()'ing too far. REVERT: dd893eda1cb Rollup merge of #94842 - tspiteri:there-is-no-try, r=Dylan-DPC REVERT: f2b6dadb8c3 Rollup merge of #94776 - martingms:optimize-escape-default, r=nnethercote REVERT: 92771a82480 Rollup merge of #93283 - m1guelperez:master, r=Mark-Simulacrum REVERT: 3b38ef36cc4 Show ignore message in console and json output REVERT: 1721fbfa62b Classify BinaryHeap & LinkedList unit tests as such REVERT: 18cf45beb96 remove unnecessary try_opt for operations that cannot fail REVERT: 34862d767c3 make float parsing docs more comprehensive REVERT: 8a3b8fec9a0 Rollup merge of #94826 - allgoewer:fix-retain-documentation, r=yaahc REVERT: 6ae55a9f748 Rollup merge of #94765 - m-ou-se:is-some-and, r=Dylan-DPC REVERT: 859270d407f Rollup merge of #94356 - Thomasdezeeuw:stabilize_unix_socket_creation, r=dtolnay REVERT: c019dd48c6b Rollup merge of #93293 - nvzqz:nonzero-min-max, r=joshtriplett REVERT: bc417575a16 Improve doc wording for retain on some collections REVERT: 3c4b87b66ac Move note about 0 gap to signed integers REVERT: c4c736e01a5 Rollup merge of #94790 - RalfJung:portable-simd-miri, r=Dylan-DPC REVERT: 14befa08a2d Rollup merge of #93950 - T-O-R-U-S:use-modern-formatting-for-format!-macros, r=Mark-Simulacrum REVERT: f85725076a2 Add `Atomic*::get_mut_slice` REVERT: abaf92d7a8f Rename `IntoFuture::Future` to `IntoFuture::IntoFuture` REVERT: ae477a1595f Rollup merge of #94805 - oli-obk:drop_box, r=pnkfelix REVERT: 3b8cece45b9 Rollup merge of #94644 - m-ou-se:scoped-threads-drop-soundness, r=joshtriplett REVERT: 8884a5326c6 Rollup merge of #94587 - JKAnderson409:issue-90107-fix, r=scottmcm REVERT: 23fd2cb04ec Use implicit capture syntax in format_args REVERT: 8bc4d1f15d8 Revert accidental stabilization REVERT: d9853b6b108 Inline ::next REVERT: 918d0eee91f Rollup merge of #94746 - notriddle:notriddle/method-rustc-on-unimplemented, r=davidtwco REVERT: 0215813630f Rollup merge of #94657 - fee1-dead:const_slice_index, r=oli-obk REVERT: 58b9bca4fbc Rollup merge of #94635 - jhpratt:merge-deprecated-attrs, r=davidtwco REVERT: dec01175571 Let `try_collect` take advantage of `try_fold` overrides REVERT: 0c533ca5183 Use MaybeUninit in VecDeque to remove the undefined behavior of slice REVERT: 89b63b9c5c5 enable portable-simd doctests in Miri REVERT: 148a5b393ed Rollup merge of #94768 - fortanix:raoul/fix_close_read_wakes_up_test_sgx_platform, r=dtolnay REVERT: 5646314977b Rollup merge of #94763 - m-ou-se:scoped-threads-lifetime-docs, r=Mark-Simulacrum REVERT: a7f3256b780 Rollup merge of #93057 - frengor:iter_collect_into, r=m-ou-se REVERT: 836695ce8f8 Rollup merge of #92541 - asquared31415:from-docs, r=m-ou-se REVERT: 818c2da49b0 Rollup merge of #91804 - woppopo:const_clone, r=oli-obk REVERT: a92a80d7269 Add missing closing parenthesis REVERT: b197ed8283c Document NonZeroXxx layout guarantees REVERT: e6359ec7e36 New `deprecated_suggestion` feature, use in tests REVERT: 785038dff7c Use indexing instead of .get_unchecked() for LUT lookup REVERT: 58e24322c6a Add tracking issue REVERT: 131470fed1c diagnostics: use rustc_on_unimplemented to recommend `[].iter()` REVERT: ddf84997e09 Optimize ascii::escape_default by using a digit LUT REVERT: db8a7550d7e BTreeMap::entry: Avoid allocating if no insertion REVERT: 81f34a4239d Add documentation about lifetimes to thread::scope. REVERT: 5b88f0a618c Ignore `close_read_wakes_up` test on SGX platform REVERT: d6f42fdde05 add as_raw() method to L4Re's Socket mock REVERT: 113afd0ff73 put L4Re specifics into their own platform REVERT: a3d3c224c17 adapt L4Re network interface mock to #87329 REVERT: 07af27bec7d L4Re does not support sanitizing standard streams REVERT: e21985d4377 drop unused libc imports on L4Re REVERT: ba95f36a16d fix return value of LookupHost::port() REVERT: afefc6697c8 fix return values in L4Re networking stub REVERT: 60c15129ca5 Add soundness test for dropping scoped thread results before joining. REVERT: 1c955ae94fc Remove outdated comment. REVERT: 12cbe316bd1 Properly abort when thread result panics on drop. REVERT: dd63f523feb Fix soundness issue in scoped threads. REVERT: 03776fff196 Rename is_{some,ok,err}_with to is_{some,ok,err}_and. REVERT: c0e4beb6b5a Rollup merge of #94756 - ChrisDenton:unreachable, r=yaahc REVERT: 4fd2fa91b1a Rollup merge of #94699 - ssomers:btree_prune_insert, r=Dylan-DPC REVERT: 5ae005c9282 Auto merge of #94750 - cuviper:dirent64_min, r=joshtriplett REVERT: b8b9a7ebd4e docs REVERT: 63e60c9e02d Use `unreachable!` for an unreachable code path REVERT: d89ef87e292 Remove unexpected #[cfg(target_pointer_width = "8")] in tests REVERT: d8e94380114 Rollup merge of #94730 - msabansal:sabansal/b-atomic-mut-ptr, r=Dylan-DPC REVERT: 5b08fd37c48 Rollup merge of #94724 - cuviper:rmdirall-cstr, r=Dylan-DPC REVERT: d0bb08205c3 Rollup merge of #94723 - dtolnay:mustuse, r=Mark-Simulacrum REVERT: 0cb11fbaf70 Rollup merge of #94714 - ChrisDenton:win-close_read_wakes_up, r=Mark-Simulacrum REVERT: 9a5735330ac unix: reduce the size of DirEntry REVERT: bf5a94f3c5d remove_dir_all: use fallback implementation on Miri REVERT: eca900b93c8 Add core::hint::must_use REVERT: e10b1e1c6fa Rollup merge of #94712 - kckeiks:remove-rwlock-read-error-assumption, r=Mark-Simulacrum REVERT: ca9c4cbab92 Rollup merge of #94559 - m-ou-se:thread-scope-spawn-closure-without-arg, r=Mark-Simulacrum REVERT: 8e8edb2b1a7 Rollup merge of #92385 - clarfonthey:const_option, r=fee1-dead REVERT: 12d2bf3051d Fix for issue #93283 REVERT: e561228fa91 Reverted atomic-mut-ptr feature removal causing compilation break REVERT: 765cc7b2b08 unix: Avoid name conversions in `remove_dir_all_recursive` REVERT: f440994fd35 Enable `close_read_wakes_up` on Windows REVERT: 4e0d34fcc3a Use `f` instead of `|| f()`. REVERT: abe95bd0719 promot debug_assert to assert REVERT: 9811f69a4f4 Rollup merge of #93827 - eholk:stabilize-const_fn-features, r=wesleywiser REVERT: fa47fe78b34 Rollup merge of #93350 - gburgessiv:master, r=Mark-Simulacrum REVERT: ef09de86a98 Stabilize const_impl_trait as well REVERT: 180b1deeaf7 Stabilize const_fn_fn_ptr_basics and const_fn_trait_bound REVERT: 8340c4dbd2a Add missing documentation for std::char types REVERT: add7ecfe187 BTree: remove dead data needlessly complicating insert REVERT: 54b634c3e21 Auto merge of #94272 - tavianator:readdir-reclen-for-real, r=cuviper REVERT: 0e7074ee538 Rollup merge of #94671 - csmoe:pin-typo, r=m-ou-se REVERT: f598748fb92 fix pin doc typo REVERT: 86551f74a51 Rollup merge of #94649 - ChrisDenton:unix-absolute-fix, r=Dylan-DPC REVERT: 0645e930e02 Constify slice index for strings REVERT: 0504e4b0fe3 doc: `Iterator::partition` use partial type hints REVERT: de4c3f5769d Auto merge of #94648 - RalfJung:rollup-4iorcrd, r=RalfJung REVERT: a589cd58c11 Use as_os_str to compare exact paths REVERT: 44f4bf35ba6 Relax tests for Windows dos device names REVERT: 7df78c1c78f Use `as_os_str` to compare exact paths REVERT: 384840d1073 Unix `path::absolute`: Fix leading "." component REVERT: 55de2c63595 do not attempt to open cgroup files under Miri REVERT: ff7779e636c partially stabilize `(const_)slice_ptr_len` by stabilizing `NonNull::len` #71146 REVERT: a6d74d87f89 Small fixes in thread local code. REVERT: 54072ddfada Update documentation in thread/local.rs. REVERT: 76e161ec024 Add debug asserts in thread local cell set methods. REVERT: 52d6c737691 Add tracking issue number for local_key_cell_methods. REVERT: efe1517f878 Rename LocalKey's with_{ref,mut} to with_borrow{,_mut}. REVERT: 4923e16c028 Implement RFC 3184 - thread local cell methods. REVERT: 8a8b4011b2f Auto merge of #94546 - JmPotato:std-features-cleanup, r=m-ou-se REVERT: e6a1f54d6c7 Rollup merge of #94620 - pierwill:partialord-constistency, r=yaahc REVERT: 22ef25734e2 Rollup merge of #94446 - rusticstuff:remove_dir_all-illumos-fix, r=cuviper REVERT: e51cf6c0399 Clean up the std library's #![feature]s REVERT: a193eb63396 Auto merge of #94628 - Dylan-DPC:rollup-v2slupe, r=Dylan-DPC REVERT: 7105fa5102e Implement Copy, Clone, PartialEq and Eq for core::fmt::Alignment REVERT: f467afa6210 Rollup merge of #94618 - lewisclark:remove-stack-size-rounding, r=yaahc REVERT: c6f6e3ec158 Rollup merge of #94577 - RalfJung:simd-miri, r=scottmcm REVERT: cd1dfc2e593 Auto merge of #94298 - Urgau:rustbuild-check-cfg, r=Mark-Simulacrum REVERT: adb93f1d560 Edit docs on consistency of `PartialOrd` and `PartialEq` REVERT: 6d57725f3bf Don't round stack size up for created threads REVERT: f9863314617 Rollup merge of #94549 - m-ou-se:thread-is-finished, r=yaahc REVERT: a5d4ddf0b9a Rollup merge of #94236 - reez12g:add_track_caller_87707, r=yaahc REVERT: 5c547ca3e8a Add suggested changes to the docs REVERT: af612e8cf7b Make use statement visible REVERT: 29d884e618c Remove redundant code for handling NULL handles on Windows. REVERT: ca2bfedfed3 Fix a compilation error. REVERT: 7e1cbe70d91 Consistently present absent stdio handles on Windows as NULL handles. REVERT: 23a8774be55 Integrate macos x86-64 remove_dir_all() impl. Step 2: readd REVERT: 9c7a47ecd86 Integrate macos x86-64 remove_dir_all() impl. Step 1: remove REVERT: e1d627f18c7 remove_dir_all(): try recursing first instead of trying to unlink() REVERT: 607a23f54a5 Use '_ for irrelevant lifetimes in Debug impl. REVERT: 88fd9bb5674 Add #![allow(unexpected_cfgs)] in preparation of global --check-cfg REVERT: bbd919838ac Add #[track_caller] to track callers when initializing poisoned Once REVERT: 3f376d3318a Rollup merge of #94572 - sunfishcode:sunfishcode/handle-or, r=joshtriplett REVERT: 0232a2e2909 Rollup merge of #93965 - Mark-Simulacrum:owned-stdio, r=dtolnay REVERT: d7e02c07a60 Rollup merge of #88805 - krhancoc:master, r=dtolnay REVERT: f2258169725 Document new recommended use of method REVERT: 060e9688ba7 only disable SIMD for doctests in Miri (not for the stdlib build itself) REVERT: 6569c3cf320 Miri can run this test now REVERT: 6441553a953 fix a warning when building core tests with cfg(miri) REVERT: bef978b29eb Use `HandleOrNull` and `HandleOrInvalid` in the Windows FFI bindings. REVERT: ca1b5a56d2f Rollup merge of #94551 - darnuria:doc-map-backstick, r=dtolnay REVERT: 481a0c2efdf Rollup merge of #92697 - the8472:cgroups, r=joshtriplett REVERT: 0180abbf771 Fix doctests. REVERT: df58bd62ae1 Add -Z oom={panic,abort} command-line option REVERT: ed0694565cd Auto merge of #94512 - RalfJung:sdiv-ub, r=oli-obk REVERT: 8fc9bbbba32 Remove argument from closure in thread::Scope::spawn. REVERT: 5144fe9bf3c Remove unnecessary #![feature]s from doctest. REVERT: 3965c4d59e3 Update test. REVERT: cc96fcd47ba Rename JoinHandle::is_running to is_finished and update docs. REVERT: 20bcc145182 Doc: Fix use of quote instead of backstick in Adapter::map. REVERT: 36b4c8a0750 Rollup merge of #94534 - bstrie:cffistd, r=Mark-Simulacrum REVERT: 98bdab701ed Rollup merge of #93562 - sunfishcode:sunfishcode/io-docs, r=joshtriplett REVERT: 4dbe59b6daa Remove the comment about `FILE_FLAG_OVERLAPPED`. REVERT: 7c5339cef7c Rollup merge of #94529 - GuillaumeGomez:unused-doc-comments-blocks, r=estebank REVERT: 4525511bb01 Rollup merge of #93663 - sunfishcode:sunfishcode/as-raw-name, r=joshtriplett REVERT: 1986b282d0e Rollup merge of #93354 - sunfishcode:sunfishcode/document-borrowedfd-toowned, r=joshtriplett REVERT: 880d05b13fe update available_parallelism docs since cgroups and sched_getaffinity are now taken into account REVERT: 2bb87c846b9 hardcode /sys/fs/cgroup instead of doing a lookup via mountinfo REVERT: 22226f7ae2a Use cgroup quotas for calculating `available_parallelism` REVERT: cbfc632f3db Fix a broken doc link on Windows. REVERT: f99a63584ef Update stdarch submodule REVERT: e5be23bbcdc Fix unused_doc_comments lint errors REVERT: c6792144c12 Re-export core::ffi types from std::ffi REVERT: 902cdc461e2 merge the char signess list of archs with freebsd as it is the same REVERT: 809c0242957 update char signess for openbsd REVERT: 9d6055be6d4 Mark `uint::wrapping_next_power_of_two` as `#[inline]` REVERT: 478bffb6406 Miri/CTFE: properly treat overflow in (signed) division/rem as UB REVERT: 919ca767749 Temporarily make `CStr` not a link in the `c_char` docs REVERT: 371079f6f2d Provide C FFI types via core::ffi, not just in std REVERT: 986959b3144 Add a copy of cfg_if to core's internal_macros.rs REVERT: f701e0d6f3b Rollup merge of #94452 - workingjubilee:sync-simd-bitmasks, r=workingjubilee REVERT: 44421bbd59f Rollup merge of #94384 - cuviper:atomic-slice, r=dtolnay REVERT: 0836e0037ab Rollup merge of #94094 - chrisnc:tcp-nodelay-windows-bool, r=dtolnay REVERT: bb44c3dcd29 Rollup merge of #92399 - Veeupup:fix_vec_typo, r=Dylan-DPC REVERT: b9ce766d16c Sync rust-lang/portable-simd@5f49d4c8435a25d804b2f375e949cb25479f5be9 REVERT: 4dc7be45d12 Rollup merge of #89793 - ibraheemdev:from_ptr_range, r=m-ou-se REVERT: c8aefa67b8f add `slice::{from_ptr_range, from_mut_ptr_range}` REVERT: 2b06959ea22 Auto merge of #94412 - scottmcm:cfg-out-miri-from-swap, r=oli-obk REVERT: 2e35d247701 Stabilize unix_socket_creation REVERT: 3e21499c641 For MIRI, cfg out the swap logic from 94212 REVERT: 295b94821d1 Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum REVERT: 0a223a76881 Auto merge of #94385 - matthiaskrgr:rollup-4pwegqk, r=matthiaskrgr REVERT: 1dbce4ae212 Rollup merge of #94363 - aDotInTheVoid:fmt-needless-borrows, r=scottmcm REVERT: abe7099a366 Auto merge of #94342 - ibraheemdev:swap-regression, r=Dylan-DPC REVERT: 7c28e3c5ec3 Add Atomic*::from_mut_slice REVERT: 2fe4df5059a Make TLS __getit #[inline(always)] on non-Windows REVERT: 1a65fcf4924 Add #[inline] to trivial AsRef impls REVERT: 7ecd83e9b09 Auto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini REVERT: 8d631fb67ef Remove needless borrows from core::fmt REVERT: 26a34f15739 Re-add track_caller to panic_no_unwind in bootstrap REVERT: 558dec5e56c Switch bootstrap cfgs REVERT: 6c33b341208 Rename unix::net::SocketAddr::from_path to from_pathname REVERT: c63c7ba6fde Fix SGX docs build REVERT: 06eecbf3b84 Rollup merge of #94184 - ssomers:btree_tests, r=Dylan-DPC REVERT: 37e53d2261e Rollup merge of #92714 - yanganto:ignore-message, r=Mark-Simulacrum REVERT: 499ddac5b28 revert implementation of `slice::swap` REVERT: 631bcc477e9 Include ignore message in libtest output REVERT: 1892bb51bff Rollup merge of #94212 - scottmcm:swapper, r=dtolnay REVERT: e0f81e52b6d Rollup merge of #94300 - WaffleLapkin:patch-4, r=scottmcm REVERT: 2dbfe7be08c Rollup merge of #94283 - hellow554:stable_flow_control, r=Dylan-DPC REVERT: ad19511b396 Rollup merge of #94273 - Dylan-DPC:doc/errorkind, r=joshtriplett REVERT: 2d1c63212bb word wrpa REVERT: 79e8d22d3e7 word wrpa REVERT: 64f73c166dd Update library/std/src/io/error.rs REVERT: d63b77bcab1 Fix a typo in documentation of `array::IntoIter::new_unchecked` REVERT: 2fca5a7f063 fs: Don't dereference a pointer to a too-small allocation REVERT: 8f806625103 Rollup merge of #94264 - NyantasticUwU:patch-1, r=yaahc REVERT: a7e843d8e05 Rollup merge of #94240 - compiler-errors:pathbuf-display, r=lcnr REVERT: c1dc9cd67f0 Rollup merge of #94128 - mqy:master, r=Dylan-DPC REVERT: 122ea05b615 remove feature gate in control_flow examples REVERT: 783325672c0 add some more summary from pr discussion REVERT: 7ed06b0eab1 add some more summary from pr discussion REVERT: d3409270425 add matching to errorkind REVERT: b9e1b731529 Auto merge of #83706 - a1phyr:fix_vec_layout_calculation, r=JohnTitor REVERT: 360ad905118 Stabilize Termination and ExitCode REVERT: 1eea8df20cd Fix typo. REVERT: 36065661744 Rollup merge of #94179 - devnexen:getexecname_directcall, r=kennytm REVERT: f3b59caae9f Constify slice indexing REVERT: 32c89fa70b2 Suggest calling .display() on PathBuf too REVERT: bb0cca2dbba Rollup merge of #94220 - GuillaumeGomez:miniz-oxide-decl, r=Amanieu REVERT: f22a46ca9ce Rollup merge of #94186 - ehuss:pin-stable-1.61, r=m-ou-se REVERT: 973bd7231d5 Rollup merge of #91192 - r00ster91:futuredocs, r=GuillaumeGomez REVERT: 719c0d073db Correctly handle miniz_oxide extern crate declaration REVERT: 25846676376 Stop manually SIMDing in swap_nonoverlapping REVERT: 4e28741649a use `BOOL` for `TCP_NODELAY` `setsockopt` value on Windows REVERT: a254b729927 Remove assertion on output length for `getsockopt`. REVERT: 2af4c43d3e8 Fix `setsockopt` and `getsockopt` parameter names. REVERT: 5d147c8c4e9 Update pin_static_ref stabilization version. REVERT: 85dc49ed9b2 BTree: simplify test code REVERT: 55e7fd3207c improve wording of Waker::wake documentation REVERT: e4817655277 solarish current_exe using libc call directly REVERT: b3261df2fd6 Auto merge of #94174 - matthiaskrgr:rollup-snyrlhy, r=matthiaskrgr REVERT: 3b27dcd24fe Add collect_into REVERT: 61f666470c7 Rollup merge of #94122 - GuillaumeGomez:miniz-oxide-std, r=notriddle REVERT: 4cfcae18c9f Rollup merge of #94112 - digama0:patch-3, r=scottmcm REVERT: aab55977c08 Rollup merge of #94019 - hermitcore:target, r=Mark-Simulacrum REVERT: a7061fb4fda Rollup merge of #93686 - dbrgn:trim-on-byte-slices, r=joshtriplett REVERT: 71e3c3281b8 Rollup merge of #93580 - m-ou-se:stabilize-pin-static-ref, r=scottmcm REVERT: 4b4f53f75b1 Auto merge of #92911 - nbdd0121:unwind, r=Amanieu REVERT: 2f8627a0b54 Fix some confusing wording and improve slice-search-related docs REVERT: 30736afc68a Some improvements to the async docs REVERT: 9ab32254d51 Auto merge of #94148 - matthiaskrgr:rollup-jgea68f, r=matthiaskrgr REVERT: c22c9f7bbbf Rollup merge of #93979 - SUPERCILEX:debug_check, r=dtolnay REVERT: fa1e2a204cf Rollup merge of #93658 - cchiw:issue-77443-fix, r=joshtriplett REVERT: a93d48c8263 Rollup merge of #92902 - ssomers:docter_drain, r=yaahc REVERT: 6ae5ffe833c Auto merge of #94105 - 5225225:destabilise-entry-insert, r=Mark-Simulacrum REVERT: baf28a81a61 Collections: improve the documentation of drain members REVERT: 17c49720e4c Rollup merge of #93847 - solid-rs:fix-kmc-solid-fs-ts, r=yaahc REVERT: ebbb280827a rustdoc: several minor fixes REVERT: 46ddc809906 Fix miniz_oxide types showing up in std REVERT: 70cae2c28e4 Rollup merge of #93613 - crlf0710:rename_to_async_iter, r=yaahc REVERT: 98250701b7c fix REVERT: 4caed19ab14 Optimize char_try_from_u32 REVERT: 3cbaefcccbc Auto merge of #94095 - Amanieu:update_stdarch, r=dtolnay REVERT: fb5e1ab837c Destabilise entry_insert REVERT: 4f0bedab1d6 Rollup merge of #94041 - a-lafrance:try-collect, r=scottmcm REVERT: 1e61292cf41 Rollup merge of #93976 - SUPERCILEX:separator_str, r=yaahc REVERT: f00ca5b7c82 core: Implement trim functions on byte slices REVERT: 6d1ef8cba6e Fix documentation for is_X_feature_detected! REVERT: ca72427bb29 Keep the path after `program_exists` succeeds REVERT: cfc38dad835 Use verbatim paths for `process::Command` if necessary REVERT: 54542c776ac Rollup merge of #93479 - smoelius:master, r=yaahc REVERT: ef70e732a3d Rollup merge of #89869 - kpreid:from-doc, r=yaahc REVERT: c25afcbd7a6 Add MAIN_SEPARATOR_STR REVERT: ad3646c0d82 Add debug asserts to validate NUL terminator in c strings REVERT: 3d9aff8c390 Auto merge of #94040 - Mark-Simulacrum:destabilize-load-store, r=Amanieu REVERT: 5cbc463f4c2 Add a `try_collect()` helper method to `Iterator` REVERT: f38aeb40539 Auto merge of #91182 - ChrisDenton:command-broken-symlink, r=m-ou-se REVERT: d78dc411b35 Rollup merge of #93962 - joboet:branchless_slice_ord, r=Mark-Simulacrum REVERT: 1c33e7f2d7d Destabilize cfg(target_has_atomic_load_store = ...) REVERT: 62926340790 Rollup merge of #93949 - glaubitz:m68k-unwind, r=Mark-Simulacrum REVERT: 632b7cbed71 Rollup merge of #93899 - ssomers:vecdeque_naming, r=m-ou-se REVERT: 91681c992e4 remove compiler warnings REVERT: 8d31aeaa121 removing architecture requirements for RustyHermit REVERT: 733da66d135 Make [u8]::cmp implementation branchless REVERT: fecf53231f1 Add a comment to justify why the `pointer` field is `pub`. REVERT: 91da90ed4cb Replace `def_site`-&-privacy implementation with a stability-based one. REVERT: 12901db6d6f Improve documentation. REVERT: 781cfcc8044 Write {ui,} tests for `pin_macro` and `pin!` REVERT: e1635d57d0d Add a stack-`pin!`-ning macro to the `pin` module. REVERT: 539dbc5945a Maintain broken symlink behaviour for the Windows exe resolver REVERT: ea3d5cb1f9c Describe VecDeque with more consistent names REVERT: ffa4fc089d3 document expectations for Waker::wake REVERT: 9fb357bbfee Make default stdio lock() return 'static handles REVERT: 3f212f6f4cd Auto merge of #91673 - ChrisDenton:path-absolute, r=Mark-Simulacrum REVERT: 3779ceedc96 allow const_mut_refs REVERT: 0728143d495 stabilize const_ptr_offset REVERT: cd7deac4705 Rollup merge of #93930 - name1e5s:chore/docs, r=Mark-Simulacrum REVERT: 107799f7b63 Rollup merge of #93886 - clarfonthey:stable_ascii_escape, r=Mark-Simulacrum REVERT: f165034354e Rollup merge of #93851 - cyqsimon:option-examples, r=scottmcm REVERT: f2430f0f446 Rollup merge of #90532 - fee1-dead:improve-const-fn-err-msg, r=oli-obk REVERT: 8faea2aba6f Rollup merge of #89926 - the8472:saturate-instant, r=Mark-Simulacrum REVERT: 25e1358e857 Guard against unwinding in cleanup code REVERT: 59bb049fa34 Auto merge of #93696 - Amanieu:compiler-builtins-0.1.68, r=Mark-Simulacrum REVERT: 2bc7386d700 Capitalize "Rust" REVERT: 339b41fc0b0 Add panic docs describing old, current and possible future behavior REVERT: 8b38ce55487 Add caveat about the monotonicity guarantee by linking to the later section REVERT: cef6e3e2f3a make Instant::{duration_since, elapsed, sub} saturating and remove workarounds REVERT: 22342b2aae2 library/unwind: Define unwinder_private_data_size for m68k REVERT: ad0b4c3bb57 library/panic_unwind: Define UNWIND_DATA_REG for m68k REVERT: 6c2abe2d555 Stabilise inherent_ascii_escape (FCP in #77174) REVERT: 3ac23623b2f Fix signature of u8::escape_ascii REVERT: 392ed69735b Auto merge of #93697 - the8472:fix-windows-path-hash, r=Mark-Simulacrum REVERT: c375a11ee29 Fix typo REVERT: 5f6fcef85a4 Fix `shrink` and `capacity_from_bytes` REVERT: af0ca6deea7 Fix a layout miscalculation in alloc::RawVec REVERT: 927328f9f02 Improve error messages even more REVERT: 96d987ebf7a Add note on Windows path behaviour REVERT: 5c7f5603015 add link to format_args! when being mentioned in doc REVERT: 9c900e1bdc3 `Option::and_then` basic example: show failure REVERT: da05d78af00 `Result::and_then`: show type conversion REVERT: d47c683ae71 `Result::and_then`: improve basic example REVERT: 01b3a566e43 Auto merge of #93921 - matthiaskrgr:rollup-wn3jlxj, r=matthiaskrgr REVERT: 2d5bd0cf115 Rollup merge of #93888 - sunfishcode:sunfishcode/impl-asfd-for-ref, r=joshtriplett REVERT: 83e6166c1f2 Rollup merge of #93635 - GuillaumeGomez:missing-platform-spec-info, r=Amanieu REVERT: debdda9a948 Rollup merge of #90955 - JohnTitor:os-error-123-as-invalid-input, r=m-ou-se REVERT: b7992a4507d Auto merge of #90271 - adamgemmell:dev/feat-detect-stabilise, r=Amanieu REVERT: 86771e62f92 Add missing platform-specific information on current_dir and set_current_dir REVERT: 31ff08d60fa Implement `AsFd` for `&T` and `&mut T`. REVERT: c6027ad0ed1 Add negative example for `Result::and_then` REVERT: 900c65cb042 added space REVERT: af98717bf9a add cfg_panic bootstrap REVERT: 254610d4385 remove mention of cfg_panic from library tests REVERT: 43817c83200 replace feature expression (cfg_panic) in lib and remove expression from tests Rebase commit REVERT: efed9999dc8 Update stdarch submodule REVERT: 731aa8c68fe Move `is_aarch64_feature_detected!` to `simd_aarch64` feature and stabilise REVERT: cd1c4b2eac9 Rename to `InvalidFilename` REVERT: 57343d28231 Fix description of FilenameInvalid REVERT: 1e4606c01a2 Map `ERROR_INVALID_NAME` to `FilenameInvalid` REVERT: fc2c17c1334 Rename `FilenameTooLong` to `FilenameInvalid` REVERT: cfa49863dcb windows: Map `ERROR_INVALID_NAME` as `InvalidInput` REVERT: 6684f71a42a Rollup merge of #93843 - solid-rs:fix-kmc-solid-condvar, r=m-ou-se REVERT: 7c4aa212458 Rollup merge of #93824 - Amanieu:stable_cfg_target_has_atomic, r=davidtwco REVERT: 3209224ec70 More practical examples for `Result::and_then` REVERT: 38c7682c14a Use 0-based idx for array content REVERT: 4979f03b960 More practical examples for `Option::and_then` REVERT: 579e465ebfe kmc-solid: Use the filesystem thread-safety wrapper REVERT: 97da0f22599 kmc-solid: Wait queue should be sorted in the descending order of task priorities REVERT: 411983ff385 kmc-solid: Fix wait queue manipulation errors in the `Condvar` implementation REVERT: 95a7f5bb5d2 Rollup merge of #93799 - wooorm:patch-1, r=dtolnay REVERT: 4e55a6a8136 Bump compiler-builtins to 0.1.69 REVERT: 15f42253186 Stabilize cfg_target_has_atomic REVERT: 334485bcd33 Suggest collecting into `Vec<_>` when collecting into `[_]` REVERT: a983fca73e0 Fix typo in `std::fmt` docs REVERT: 8511d608926 Rollup merge of #93735 - m-ou-se:stabilize-int-abs-diff, r=joshtriplett REVERT: 74e41f859bb Rollup merge of #93445 - yaahc:exitcode-constructor, r=dtolnay REVERT: 4164c6d82af Auto merge of #93778 - matthiaskrgr:rollup-yfngdao, r=matthiaskrgr REVERT: ed13f0758d6 Rollup merge of #93206 - ChrisDenton:ntopenfile, r=nagisa REVERT: a4c624e29b8 Fix `absolute` issues REVERT: 4a84c53c35b `std::path::absolute` REVERT: 1c0fff70540 Auto merge of #93572 - scottmcm:generic-iter-process, r=yaahc REVERT: a208b2ac73b Rollup merge of #86497 - clarfonthey:nearest_char_boundary, r=scottmcm REVERT: 316a3b6dca5 Allow comparing `Vec`s with different allocators using `==` REVERT: 8c368a1887c Change `ResultShunt` to be generic over `Try` REVERT: 6fafee324c1 fix exclusive range error REVERT: 5809f577154 Auto merge of #87869 - thomcc:skinny-io-error, r=yaahc REVERT: 9cd60edde6a Add {floor,ceil}_char_boundary methods to str REVERT: aa7c629eb98 Auto merge of #93738 - m-ou-se:rollup-zjyd2et, r=m-ou-se REVERT: a96418cf977 Rollup merge of #93416 - name1e5s:chore/remove_allow_fail, r=m-ou-se REVERT: 3c6628456f7 Rollup merge of #93208 - kellerkindt:wrapping_int_assign_impl, r=m-ou-se REVERT: 560bf585328 Rollup merge of #92724 - inteon:cleanup, r=Mark-Simulacrum REVERT: 00dd025e21f Auto merge of #93719 - scottmcm:core-as-2021-everywhere, r=Mark-Simulacrum REVERT: 1070ddb46e8 Mark int_abs_diff as const stable. REVERT: 1a5260987f8 Stabilize int_abs_diff in 1.60.0. REVERT: e71aa2d990d Stabilize wrapping_int_assign_impl in 1.60.0. REVERT: 44ef2459f9f Auto merge of #93179 - Urgau:unreachable-2021, r=m-ou-se,oli-obk REVERT: 662da2bea2c Build libcore as 2021 in a few more places REVERT: 9abe48bba1a Auto merge of #93695 - matthiaskrgr:rollup-zslgooo, r=matthiaskrgr REVERT: e69f2f9bf67 Add From for ExitCode REVERT: 276f900bab5 rewrite from_bytes_with_nul to match code style in from_vec_with_nul REVERT: 7ce1e06cb2a Fix hashing for windows paths containing a CurDir component REVERT: 6626b5e4ad4 Rollup merge of #93489 - Amanieu:panic_no_unwind, r=nagisa REVERT: 243c299ebaa Rollup merge of #90998 - jhpratt:require-const-stability, r=oli-obk REVERT: db69574cdee Auto merge of #90414 - thomcc:count-chars-faster, r=nagisa REVERT: 3a23cc4375e keyword_docs: document use of `in` with `pub` keyword REVERT: d7c8f302336 Mark __rgl_oom and __rd_oom as "C-unwind" REVERT: 7313df32143 Allow handle_alloc_error to unwind REVERT: bbc48117a08 Fix comment grammar for `do_count_chars` REVERT: 9ec42446a5f Respond to review feedback, and improve implementation somewhat REVERT: 7a498c62450 Ensure non-power-of-two sizes are tested in the Chars::count test REVERT: ef8b99d5c4c Fix zh::SMALL string in core::str benchmarks REVERT: 0a78cb981cb Optimize `core::str::Chars::count` REVERT: 4706e7aed3c Add more tests for io::Error packing, and fix some comments that weren't quite accurate anymore REVERT: a32715ccfe9 Update documentation somewhat REVERT: e6c68b05dc6 Use wrapping pointer arithmetic in the bitpacked io::Error REVERT: 019cc6e9064 Elaborate some in the documentation and respond to some review comments REVERT: c9b0745ab02 Update library/std/src/io/error/repr_bitpacked.rs REVERT: d5adff6ffa7 Fix comment typos noticed by code review. REVERT: 45ede3fa4cd Address address comments, improve comments slightly REVERT: a009dbace1b Optimize io::error::Repr layout on 64 bit targets. REVERT: c6454583392 Hide Repr details from io::Error, and rework `io::Error::new_const`. REVERT: 49716b2b817 x.py fmt REVERT: ac49d822b62 Rename `BorrowedFd::borrow_raw_fd` to `BorrowedFd::borrow_raw`. REVERT: eb36a3884cb Rollup merge of #93612 - tspiteri:master, r=m-ou-se REVERT: 249f86df80e Rollup merge of #93495 - solid-rs:fix-kmc-solid-rtc-month, r=yaahc REVERT: 904941f669a Rollup merge of #91589 - derekdreery:arc_unwrap_or_clone, r=m-ou-se REVERT: 7cfebe48c58 doc: use U+2212 for minus sign in integer MIN/MAX text REVERT: 2b87cfe6e51 Rollup merge of #93585 - tamaroning:add_tests_for_92630, r=m-ou-se REVERT: 3e14c091dc3 Rollup merge of #93555 - ChrisDenton:fs-try-exists-doc, r=Mark-Simulacrum REVERT: 776a76e8cc7 Stabilize pin_static_ref. REVERT: 363ba41068b Add missing const stability attributes REVERT: 0a55e163d17 Rollup merge of #93600 - last-partizan:fix-junit-formatter, r=yaahc REVERT: b498f7154a0 Move `{core,std}::stream::Stream` to `{core,std}::async_iter::AsyncIterator`. REVERT: 81b3f51199e Add tracking issue and impl for `Rc`. REVERT: fafac0f5030 impl `Arc::unwrap_or_clone` REVERT: 172dd901bdd Auto merge of #93146 - workingjubilee:use-std-simd, r=Mark-Simulacrum REVERT: c3cd5f00178 Remove the documentation comment for `OwnedSocket::from_raw_socket`. REVERT: 918168c337b Auto merge of #93101 - Mark-Simulacrum:library-backtrace, r=yaahc REVERT: 60090130c16 fix: Remove extra newlines from junit output REVERT: e822528e859 Configure panic hook backtrace behavior REVERT: 64db2988aff add tests REVERT: f1c30f66622 Rollup merge of #93531 - TheColdVoid:patch-1, r=m-ou-se REVERT: 52a8722ba45 Rollup merge of #93493 - GKFX:char-docs-2, r=scottmcm REVERT: 7458d2adc86 x.py fmt REVERT: 681e1e4a518 Use `From`/`Into` rather than the traits they replaced. REVERT: 6877271f538 Fix errors. REVERT: 086d5c06f36 Fix unresolved doc links. REVERT: f9990b663b9 Fix two copy+pastos. REVERT: 183ff9ec819 Add missing `pub` keywords. REVERT: 65735e62f40 Update the documentation for `{As,Into,From}Raw{Fd,Handle,Socket}`. REVERT: ede32344051 Fix annotation of code blocks REVERT: 567b2c4f50f Auto merge of #93442 - yaahc:Termination-abstraction, r=Mark-Simulacrum REVERT: d41bc743f98 Link `try_exists` docs to `Path::exists` REVERT: 05178952049 Rollup merge of #93436 - dcsommer:master, r=Mark-Simulacrum REVERT: 31379fe3172 Rollup merge of #92584 - lcnr:query-stable-lint, r=estebank REVERT: fc07af59cf4 Rollup merge of #91828 - oxalica:feat/waker-getters, r=dtolnay REVERT: 0cc1d89d156 Auto merge of #86988 - thomcc:chunky-splitz-says-no-checking, r=the8472 REVERT: dc2a035369c add a rustc::query_stability lint REVERT: 165330b3b82 Rollup merge of #93504 - solid-rs:fix-kmc-solid-stack-size, r=nagisa REVERT: ab8e73ef053 Rollup merge of #93090 - jyn514:errorkind-asstr, r=dtolnay REVERT: 74f7c485354 Fix incorrect panic message in example REVERT: f5af555b193 Improve test coverage of {Chunks,RChunks,RChunksMut}::{next,next_back} REVERT: 78005643731 (#93493) Add items from code review REVERT: 4d408f69595 fix error handling for pthread_sigmask(3) REVERT: 6075c152253 add inline attribute to new method REVERT: fb90890d24f Take in account the unreachable! macro in the non_fmt_panic lint REVERT: 3860ad08c6c Fix invalid special casing of the unreachable! macro REVERT: d5d96445845 Auto merge of #93498 - matthiaskrgr:rollup-k5shwrc, r=matthiaskrgr REVERT: 0fdcc1fa9fd kmc-solid: Increase the default stack size REVERT: c809656f407 Rollup merge of #93494 - solid-rs:fix-kmc-solid-spawned-task-priority, r=Mark-Simulacrum REVERT: bf855fbb75b Rollup merge of #93485 - est31:remove_curly, r=joshtriplett REVERT: c5a3b8ea37a Rollup merge of #93480 - est31:remove_unstable_deprecated, r=Mark-Simulacrum REVERT: fa9e655d75b Rollup merge of #93471 - cuviper:direntry-file_type-stat, r=the8472 REVERT: 5bb169ab9c1 Rollup merge of #93462 - ChrisDenton:systime-doc, r=joshtriplett REVERT: d73bbf6bbe1 Rollup merge of #93403 - nagisa:total-cmp-review, r=joshtriplett REVERT: 0d090802203 Rollup merge of #93392 - GKFX:char-docs, r=scottmcm REVERT: 3b160569bc9 Rollup merge of #93347 - WaffleLapkin:better_char_decode_utf16_size_hint, r=dtolnay REVERT: 95af036dba8 kmc-solid: `SOLID_RTC_TIME::tm_mon` is 1-based REVERT: de5f366e211 kmc-solid: Inherit the calling task's base priority in `Thread::new` REVERT: 016cd37494c Auto merge of #90891 - nbdd0121:format, r=Mark-Simulacrum REVERT: b2cbd84323b (#93392) Update char::MAX docs and core::char::MAX REVERT: 5d429a3a18d Document char validity REVERT: 0ac57175c23 review the total_cmp documentation REVERT: a44460e8a4c Clarify safety of PanicInfo::can_unwind REVERT: 406c3239803 core: Remove some redundant {}s from the sorting code REVERT: b37cc2cc549 Rollup merge of #92887 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum REVERT: a8ed7dcd53a Use `optflag` for `--report-time` REVERT: 4936ee90459 Remove deprecated and unstable slice_partition_at_index functions REVERT: 44e4ca6f125 Fix an edge case in `chat::DecodeUtf16::size_hint` REVERT: 4d03fffbf26 unix: Use metadata for `DirEntry::file_type` fallback REVERT: 617146d797d Add Result::{ok, err, and, or, unwrap_or} as const REVERT: b842c44b367 Rollup merge of #93459 - tavianator:dirent-copy-only-reclen, r=cuviper REVERT: febc4f4ad2b Rollup merge of #93414 - Amanieu:std_arch_detect, r=m-ou-se REVERT: 370553e5a57 Rollup merge of #93256 - EFanZh:patch-1, r=joshtriplett REVERT: 081a60336d8 fs: Add a regression test for #93384 REVERT: c6c6d23736d fs: Don't copy d_name from struct dirent REVERT: 940a8387740 Document `SystemTime` platform precision REVERT: 231a387f8b1 Update compiler_builtins to fix duplicate symbols in `armv7-linux-androideabi` rlib REVERT: 00bdccd0770 Create `core::fmt::ArgumentV1` with generics instead of fn pointer REVERT: 7f7d450f295 Rollup merge of #93410 - solid-rs:feat-kmc-solid-net-dup, r=dtolnay REVERT: 460dc799b39 Rollup merge of #93236 - woppopo:const_nonnull_new, r=oli-obk REVERT: 99789a25062 Rollup merge of #92274 - woppopo:const_deallocate, r=oli-obk REVERT: bbc0de5ecaa Document about some behaviors of `const_(de)allocate` and add some tests. REVERT: a99545b5b3d Auto merge of #93351 - anp:fuchsia-remove-dir-all, r=tmandry REVERT: d2d269c8c52 Change Termination::report return type to ExitCode REVERT: 1f488e21fea Fix remove_dir_all on Fuchsia after CVE fix. REVERT: de1233cd07b Rollup merge of #93404 - rust-lang:scottmcm-patch-1, r=wesleywiser REVERT: b8209353ad2 Rollup merge of #93356 - pierwill:partialord-headline, r=dtolnay REVERT: 777a0cb2055 Rollup merge of #93353 - kellerkindt:saturating_int_assign_impl, r=joshtriplett REVERT: 4a2e6b41e72 Rollup merge of #93295 - ChrisDenton:tempdir-double-panic, r=dtolnay REVERT: 9a427f9b220 Rollup merge of #93239 - Thomasdezeeuw:socketaddr_creation, r=m-ou-se REVERT: 9e5338fd853 Rollup merge of #93158 - haraldh:wasi_sock_accept, r=dtolnay REVERT: 00c81685792 Rollup merge of #92611 - Amanieu:asm-reference, r=m-ou-se REVERT: 541d64f7350 update cfg(bootstrap)s REVERT: 5895e486030 Update tracking issue for unix_socket_creation REVERT: 225735955f7 Update stdarch submodule REVERT: 4cdc91f404e wasi: enable TcpListener and TcpStream REVERT: cabb087e9de wasi: update to wasi 0.11.0 REVERT: ee8bd61628f add allow_fail field in TestDesc to pass check REVERT: 9beb00923e4 remove allow_fail test flag REVERT: 00448211d40 Move unstable is_{arch}_feature_detected! macros to std::arch REVERT: 66b62f74781 Add a test case for using NonNull::new in const context REVERT: 27e8f2552da Fix wrong assumption in `DecodeUtf16::size_hint` REVERT: 5d1ed23e47a test_const_allocate_at_runtime REVERT: 5f44937d719 Edit docs introduction for `std::cmp::PartialOrd` REVERT: 38e3b4e6667 kmc-solid: Implement `FileDesc::duplicate` REVERT: a28bab622c9 Fix a typo from #92899 REVERT: 720f4abf55b Clarify documentation on char::MAX REVERT: 0f37540eb73 Rollup merge of #92899 - cameron1024:zip-docs, r=dtolnay REVERT: 4d8040668b9 Rollup merge of #91641 - dtolnay:cchar-if, r=Mark-Simulacrum REVERT: fd43c6d426e Touch up PR 92899 Iterator::zip docs REVERT: e72a9340892 pub use std::simd::StdFloat; REVERT: aa3b3f188eb Sync rust-lang/portable-simd@03f6fbb21e6050da2a05b3ce8f480c020b384916 REVERT: b2fa4690fc2 Use sockaddr_un in unix SocketAddr::from_path REVERT: 05f66e50b49 Make sockaddr_un safe and use copy_nonoverlapping REVERT: 3038a43f26e mention std::iter::zip in Iterator::zip docs REVERT: 307c64801ff Add documentation about `BorrowedFd::to_owned`. REVERT: 6b555c7b5d7 Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t> REVERT: 6223f99b667 Rollup merge of #92778 - tavianator:linux-readdir-no-r, r=joshtriplett REVERT: 5fb8680bf50 Rollup merge of #92256 - fee1-dead:improve-selection-err, r=oli-obk REVERT: 746304ca6f8 Rollup merge of #91861 - juniorbassani:use-from-array-in-collections-examples, r=yaahc REVERT: 9bf881839ee libunwind: readd link attrs to _Unwind_Backtrace REVERT: 57c96d16a28 Add a test for `char::DecodeUtf16::size_hint` REVERT: c018f65872c Make char::DecodeUtf16::size_hist more precise REVERT: c9b001eed95 Improve Duration::try_from_secs_f32/64 accuracy by directly processing exponent and mantissa REVERT: 529cc8f7b11 `const_deallocate`: Don't deallocate memory allocated in an another const. Does nothing at runtime. `const_allocate`: Returns a null pointer at runtime. REVERT: 2c5b4530a82 make Windows abort_internal Miri-compatible REVERT: b9e22ccc4b6 Add a minimal working `append_const_msg` argument REVERT: b9106e7146b Avoid double panics when using `TempDir` in tests REVERT: ad249d0276d Implement `MIN`/`MAX` constants for non-zero integers REVERT: 8f50907a514 Impl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}Assign<$t> for Wrapping<$t> REVERT: 35fa8d7ef25 Rollup merge of #88794 - sunfishcode:sunfishcode/try-clone, r=joshtriplett REVERT: d9a86409898 Rename SocketAddr::unix to from_path REVERT: f9c1ad21102 Rollup merge of #93152 - ivmarkov:master, r=m-ou-se REVERT: fce22ae2e43 Rollup merge of #92513 - Xuanwo:path-buf, r=dtolnay REVERT: 0833d6a98a2 Use `NtCreateFile` instead of `NtOpenFile` to open a file REVERT: ab26da5a3f9 Make `join!` description more accurate REVERT: aceb7168040 Rollup merge of #92555 - m-ou-se:scoped-threads, r=Amanieu REVERT: f674a6fc054 Add os::unix::net::SocketAddr::unix REVERT: bf487b38e4c Make `NonNull::new` `const` REVERT: 03243571847 Auto merge of #93220 - matthiaskrgr:rollup-9bkrlk0, r=matthiaskrgr REVERT: cabe0c50a5d Add `intrinsics::const_deallocate` REVERT: 006544eeed7 Rollup merge of #91122 - dtolnay:not, r=m-ou-se REVERT: 4963f5e6422 Rollup merge of #90666 - bdbai:arc_new_cyclic, r=m-ou-se REVERT: 6af0b3315ed Auto merge of #92998 - Amanieu:hashbrown12, r=Mark-Simulacrum REVERT: 85ad7ea807f Add test for thread::Scope invariance. REVERT: b5edf100d38 Update stabilization version of arc_new_cyclic REVERT: 65e4d4c980e Add tracking issue number for scoped_threads. REVERT: fd24d0ab2c2 Simplify Send/Sync of std::thread::Packet. REVERT: ea5d4610420 Rollup merge of #92828 - Amanieu:unwind-abort, r=dtolnay REVERT: b4950b70ef9 Rollup merge of #85967 - atopia:update-l4re-target, r=petrochenkov REVERT: e8ea91b816f Disable test_try_reserve on Android REVERT: 647930076eb Rollup merge of #93134 - tlyu:delete-stdin-split, r=Amanieu REVERT: b92fe076714 Rollup merge of #93109 - JakobDegen:arc-docs, r=m-ou-se REVERT: 8472ca7afbd Rollup merge of #92586 - esp-rs:bugfix/allocation-alignment-espidf, r=yaahc REVERT: 86e4baccd63 Update HashMap::try_reserve test to version from hashbrown REVERT: 29b9b431aff Update hashbrown to 0.12.0 REVERT: 1f11656d90f adapt L4Bender implementation REVERT: beece447246 Old versions of Android generate SIGSEGV from libc::abort REVERT: d66b923f628 fs: Use readdir() instead of readdir_r() on Android REVERT: 75ab453308b fs: Use readdir() instead of readdir_r() on Linux REVERT: d5be26077d0 fs: Implement more ReadDir methods in terms of name_cstr() REVERT: 8e69a1b3241 Fix STD compilation for the ESP-IDF target REVERT: 5df27119d04 delete `Stdin::split` forwarder REVERT: c2d6099600f Rollup merge of #93112 - pietroalbini:pa-cve-2022-21658-nightly, r=pietroalbini REVERT: 2c2afabd2dd Rollup merge of #92992 - kornelski:backtraceopt, r=Mark-Simulacrum REVERT: a0011b42574 Rollup merge of #89747 - Amanieu:maybeuninit_bytes, r=m-ou-se REVERT: b4b86e612b4 Fix compilation for a few tier 2 targets REVERT: ef6806f0fcc Remove unnecessary unsafe code in `Arc` deferred initialization examples. REVERT: 7f592165476 Correct docs in `Arc` and `Rc`. REVERT: c5e245aadd7 Update stabilization version of impl Not for ! REVERT: 57f7e6fec5d Auto merge of #92138 - AngelicosPhosphoros:try_smarter_vec_from_iter_48994_2, r=Mark-Simulacrum REVERT: a9099631c0f Write for Cursor with a custom Allocator REVERT: b4f5768af54 impl Write for Cursor<[u8; N]> REVERT: 59c03e58364 Refactor tests of Write for Cursor<_> REVERT: b0828602029 Add MaybeUninit::as_bytes REVERT: a112663e3c1 Add links to the reference and rust by example for asm! docs and lints REVERT: e25219fbaae `impl Display for io::ErrorKind` REVERT: 7d5ce354c9e Rollup merge of #92630 - steffahn:lift_bounds_on_BuildHasherDefault, r=yaahc REVERT: 3413e9e22e2 Implement `IterMut::as_mut_slice` REVERT: 85b1607278b Update std::fs::remove_dir_all documentation REVERT: ab6d975ceca Fix CVE-2022-21658 for WASI REVERT: 0c7106f3bba Fix CVE-2022-21658 for UNIX-like REVERT: 95bb379f41d Fix CVE-2022-21658 for Windows REVERT: 50255e7f3dc Improve estimation of capacity in Vec::from_iter REVERT: fa94f521e72 Rollup merge of #93051 - m-ou-se:is-some-with, r=yaahc REVERT: 85bc35007f1 Rollup merge of #92124 - AngelicosPhosphoros:remove_extra_alloc_in_cstring_new_35838, r=Mark-Simulacrum REVERT: 1f630565c40 Rollup merge of #89621 - digama0:patch-2, r=yaahc REVERT: 6745d0b1533 Fix is_some_with tests. REVERT: 4b4b2778945 Improve is_err_with example. REVERT: b31f7ca9d84 Add is_some_with tracking issue number. REVERT: a247c2805b1 Add Result::{is_ok_with, is_err_with}. REVERT: de24d4d8ab7 Add Option::is_some_with. REVERT: 737f3a719fb Rollup merge of #93035 - Amanieu:stdarch_fix, r=Mark-Simulacrum REVERT: 526a5d50c40 Rollup merge of #93026 - klensy:f-typo, r=scottmcm REVERT: b57442d1f6b Fix stdarch submodule pointing to commit outside tree REVERT: 187a7de43fe Replace iterator-based construction of collections by `Into` REVERT: 24e159398de fix typo in `max` description for f32/f64 REVERT: e3332c2741c Rollup merge of #93016 - Amanieu:vec_spare_capacity, r=Mark-Simulacrum REVERT: f516bc30bde Rollup merge of #92870 - llogiq:atomic_bool_sym, r=Manishearth REVERT: d6d08430a33 Rollup merge of #92866 - maxwase:does_exist_typo, r=Mark-Simulacrum REVERT: 40ac97f35d2 Stabilize vec_spare_capacity REVERT: 35133cfa9a5 Rollup merge of #92960 - scottmcm:carrying-bignum, r=Mark-Simulacrum REVERT: 5f52eb27853 Rollup merge of #92956 - scottmcm:nonzero-log2, r=dtolnay REVERT: 461f5078d5b Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu REVERT: 6cadaea9492 Rollup merge of #92981 - RalfJung:const_ptr_offset_from, r=dtolnay REVERT: 05906b38fe0 Rollup merge of #92977 - kornelski:popdoc, r=dtolnay REVERT: a8c66e088f1 Rollup merge of #92953 - azdavis:azdavis-copy-example, r=dtolnay REVERT: f95d43827c7 Help optimize out backtraces when disabled REVERT: aa07833d52a Change TerminatorKind::Abort to call the panic handler instead of aborting immediately. REVERT: 78c72d9e9cb Add PanicInfo::can_unwind which indicates whether a panic handler is allowed to trigger unwinding. REVERT: 512f0c1dc8e fix const_ptr_offset_from tracking issue REVERT: 1771625a4f9 Docs: recommend VecDeque instead of Vec::remove(0) REVERT: d01a79d5a35 Rollup merge of #92706 - umanwizard:btree, r=dtolnay REVERT: 123c4ab855c Rollup merge of #92619 - Alexendoo:macro-diagnostic-items, r=matthewjasper REVERT: 794f277f0b1 Auto merge of #92356 - kellerkindt:saturating_int_assign_impl, r=dtolnay REVERT: e78a1ac9651 Touch up stray comment in PR 92953 REVERT: 167ad14268d Clear up discriminants with more examples REVERT: 4eb3d433c7b Use `carrying_{mul|add}` in `num::bignum` REVERT: 2ae49336b19 Tweak btree iterator wording to not use 'yield' REVERT: 459ff6ce13c Auto merge of #92598 - Badel2:panic-update-hook, r=yaahc REVERT: ebad330382a Add `log2` and `log10` to `NonZeroU*` REVERT: fbed9f7ac18 Copy an example to PartialOrd as well REVERT: d818f2ad12d stabilize windows_process_extensions_raw_arg REVERT: bc2f19b7b8d Rollup merge of #92879 - compiler-errors:into_iter_unsound, r=dtolnay REVERT: 54a417ff773 Rollup merge of #92863 - camelid:read_to_string-rm-mut, r=m-ou-se REVERT: 91364813785 Rollup merge of #92775 - xfix:osstringext-inline, r=m-ou-se REVERT: 6d5ce17cc74 Rollup merge of #92747 - swenson:bignum-bit-length-optimization, r=scottmcm REVERT: c9b8412d76a Rollup merge of #92684 - ibraheemdev:patch-10, r=m-ou-se REVERT: 66d2ec7a8e8 Rollup merge of #92382 - clarfonthey:const_convert, r=scottmcm REVERT: 52eca2d9a7b Rollup merge of #92768 - ojeda:stabilize-maybe_uninit_extra, r=Mark-Simulacrum REVERT: 1bfa0eb2274 Add Sync bound to allocator parameter in vec::IntoIter REVERT: 6325b969c10 Add rustc_diagnostic_item attribute to AtomicBool REVERT: 9228f56ab65 Typos fix REVERT: 7d973044173 Set the allocation MIN_ALIGN for espidf to 4. REVERT: 4103e28cc1c fix stability attribute for `tcp::IntoIncoming` REVERT: 060055cba01 Remove `&mut` from `io::read_to_string` signature REVERT: bd10bb69ed4 Rollup merge of #91938 - yaahc:error-reporter, r=m-ou-se REVERT: 69cc7025acf Auto merge of #92553 - m-ou-se:thread-join-simplify, r=Mark-Simulacrum REVERT: db41828f0b5 Use the correct `cvt` for converting socket errors on Windows. REVERT: 640bba111e8 Remove deprecated LLVM-style inline assembly REVERT: 8a484a636dc Rollup merge of #92748 - david-perez:eliminate-boxed-wording-std-error, r=Mark-Simulacrum REVERT: f7ac9bb6b41 Rollup merge of #92720 - rosik:patch-1, r=m-ou-se REVERT: 4baa7299167 Rollup merge of #92709 - joshtriplett:file-options-docs, r=Mark-Simulacrum REVERT: 919131e6357 Rollup merge of #92328 - camelid:sentence, r=scottmcm REVERT: 1db4dcdf571 Address review comments REVERT: f47f015425c Inline std::os::unix::ffi::OsStringExt methods REVERT: 817456991ef Partially stabilize `maybe_uninit_extra` REVERT: f6680a1c5eb Auto merge of #92070 - rukai:replace_vec_into_iter_with_array_into_iter, r=Mark-Simulacrum REVERT: 2179283aa2d Simplify BigNum::bit_length() with log2() REVERT: bf4c64440c5 Improve documentation for File::options to give a more likely example REVERT: 692f1217921 Eliminate "boxed" wording in `std::error::Error` documentation REVERT: 96957793571 Simplification of BigNum::bit_length REVERT: 62864d742e3 Auto merge of #92719 - matthiaskrgr:rollup-tc7oqys, r=matthiaskrgr REVERT: c388408fb03 Fix doc formatting for time.rs REVERT: bdc55e258ac Rollup merge of #92602 - jsha:source-link-2, r=GuillaumeGomez REVERT: d167067ff7f Clarify explicitly that BTree{Map,Set} are ordered. REVERT: 5f846a53ea7 Compute most of Public/Exported access level in rustc_resolve REVERT: d9d75423432 Rollup merge of #92671 - WaffleLapkin:atomic_from_mut_unique_ref, r=m-ou-se REVERT: 0b78709c932 Rollup merge of #92657 - Kixunil:ptr_as_const_mut, r=m-ou-se REVERT: 43c6addaa79 export `tcp::IntoIncoming` REVERT: 1bbe8b9d7e0 eplace usages of vec![].into_iter with [].into_iter REVERT: 9f44b1c0eb3 Auto merge of #92068 - fee1-dead:libcore2021, r=m-ou-se REVERT: c18b21343c6 Implemented const casts of raw pointers REVERT: c302ded7694 Make source links look cleaner REVERT: 033ad92b6fe Make `Atomic*::from_mut` return `&mut Atomic*` REVERT: e38bd2c84d3 Rollup merge of #92632 - yoshuawuyts:stabilize-available-parallelism, r=joshtriplett REVERT: 026dffb4a13 Rollup merge of #92600 - asquared31415:float-must-use, r=joshtriplett REVERT: 079050e3f3e Rollup merge of #92568 - Mark-Simulacrum:non-exhaustive-variant-count, r=the8472 REVERT: 1bfec43fc81 Add safety comments to panic::(set/take/update)_hook REVERT: c869a0ad699 Change panic::update_hook to simplify usage REVERT: ec8c04944b5 silence tidy errors REVERT: 518cab7540d Implement `TryFrom` for `u8` REVERT: 7b8e671bb31 Implement panic::update_hook REVERT: 265094a26ac Also change PhantomData parameter of iter::Empty, and future::Pending REVERT: c30eccf1bbb Stabilize `#[feature(available_parallelism)]` REVERT: 80e8bb0e8f5 change PhantomData type for BuildHasherDefault REVERT: 6339a758d8c Rollup merge of #92620 - steffahn:remove_unused_ExtendDefault_struct, r=Mark-Simulacrum REVERT: 66542c7f2f1 remove unused ExtendDefault struct REVERT: 3acc0bd3e86 Add diagnostic items for macros REVERT: 985ead9f9c5 Rollup merge of #92288 - yescallop:patch-1, r=m-ou-se REVERT: 7d0b3ee34ca add some missing must use to float ops REVERT: 3cf074d8fb4 Auto merge of #92587 - matthiaskrgr:rollup-qnwa8qx, r=matthiaskrgr REVERT: cbc26dd446b Rollup merge of #92574 - luojia65:riscv-kernel-dev-rust, r=Amanieu REVERT: 969aefecb40 Rollup merge of #92483 - ksqsf:master, r=dtolnay REVERT: 6c0d91b4307 Rollup merge of #92388 - SpriteOvO:master, r=Mark-Simulacrum REVERT: d830359b699 Rollup merge of #92092 - saethlin:fix-sort-guards-sb, r=danielhenrymantilla REVERT: 103d332cee2 Mention *scoped* thread in panic message. REVERT: 82602a670d7 Note the invariance over 'env in Scope<'env>. REVERT: 6ccf3837a51 Fix missing .load() in Scope's Debug impl. REVERT: d1741b3146f Rename n_running_threads to num_running_threads. REVERT: d1e819626a2 Rollup merge of #92517 - ChrisDenton:explicit-path, r=dtolnay REVERT: 3fbf580bc69 Rollup merge of #92322 - alper:add_debug_trait_documentation, r=dtolnay REVERT: 06605773cd7 Add is_riscv_feature_detected!; modify impl of hint::spin_loop REVERT: 8180ac2f494 Clarify that ordering is unspecified REVERT: 6de2de5e401 Add note about non_exhaustive to variant_count REVERT: 657701fbcc9 Auto merge of #92560 - matthiaskrgr:rollup-jeli7ip, r=matthiaskrgr REVERT: d748edb83e1 Touch up Debug example from PR 92322 REVERT: 872870f2b3d Rollup merge of #92530 - dtolnay:contains, r=yaahc REVERT: 658a2f0b3a6 Rollup merge of #91587 - nrc:dispatchfromdyn-docs, r=yaahc REVERT: 8a5d8324af6 Update wording REVERT: e114065b737 Fix typo in Scope::spawn docs. REVERT: e9ee6da9d6f Fix typo in is_running() docs. REVERT: da4a58a3c5e Fix typo in documentation. REVERT: a8629343592 Use > rather than == for overflow check in scoped threads. REVERT: e0170fa41df Fix variance of thread::Scope. REVERT: 72955a481a1 Rollup merge of #92525 - zohnannor:patch-1, r=camelid REVERT: f8d1d13217c Rollup merge of #92456 - danielhenrymantilla:patch-1, r=petrochenkov REVERT: 6bb253374c8 Rollup merge of #91884 - woppopo:const_box, r=oli-obk REVERT: 44738479648 Rollup merge of #91754 - Patrick-Poitras:rm-4byte-minimum-stdio-windows, r=Mark-Simulacrum REVERT: 56a1c30629c Formatting. REVERT: 81275e79834 Simplify panicking mechanism of thread::scope. REVERT: b49143b232f Add documentation for scoped threads. REVERT: efb07a0cfd4 Add ScopedJoinHandle::is_running(). REVERT: cd951661a72 Implement RFC 3151: Scoped threads. REVERT: a2a8dd19381 Simpilfy thread::JoinInner. REVERT: ec333cbe345 Stabilize `result_cloned` and `result_copied` REVERT: cc1fb7761e7 mirror mention of intent of From REVERT: fb662a95120 Make the documentation of builtin macro attributes accessible REVERT: 71263c041a2 Move `contains` method of Option and Result lower in docs REVERT: 24e379cd59f Make `Receiver::into_iter` into a clickable link REVERT: 9679334c19a Fix a compile error when no_global_oom_handling REVERT: 6faa325a518 Add tracking issues (`const_box`, `const_alloc_error`) REVERT: b3ee794078b Rollup merge of #92444 - dtolnay:coremethods, r=joshtriplett REVERT: c3ab254de26 Rollup merge of #92409 - bjorn3:libtest_cleanups, r=m-ou-se REVERT: e238d443501 Explicitly pass `PATH` to the Windows exe resolver REVERT: bc1775511b0 std: Implement try_reserve and try_reserve_exact on PathBuf REVERT: de8d8a2d6e3 Auto merge of #91961 - kornelski:track_split_caller, r=joshtriplett REVERT: a50bea14a64 Auto merge of #92482 - matthiaskrgr:rollup-uso1zi0, r=matthiaskrgr REVERT: 2670185d376 Rollup merge of #92463 - thomcc:thats-not-how-its-pronounced, r=joshtriplett REVERT: aee559a96a0 Rollup merge of #91593 - upsuper-forks:hashmap-set-methods-bound, r=dtolnay REVERT: 8da07c9cf36 Rollup merge of #84083 - ltratt:threadid_doc_tweak, r=dtolnay REVERT: cff7935a82d Auto merge of #92396 - xfix:remove-commandenv-apply, r=Mark-Simulacrum REVERT: e9a51188e6d Rollup merge of #92469 - joshtriplett:test-number-fix, r=Mark-Simulacrum REVERT: 7f343d52783 Rollup merge of #92097 - saethlin:split-without-deref, r=the8472 REVERT: 2a8dac69cce Make tidy check for magic numbers that spell things REVERT: d85011b085c Clarify safety comment REVERT: 23af4c72eb9 Rollup merge of #92338 - Xuanwo:try_reserve, r=dtolnay REVERT: e055ab4d011 Remove pronunciation guide from Vec REVERT: 6538c07113b Remove needless allocation from example code of OsString REVERT: 6ae5f85cba6 Fix some copy/paste hysteresis in OsString try_reserve docs REVERT: f683848d9b2 Consolidate impl Option<&mut T> REVERT: 68f8dec3db4 Consolidate impl Option<&T> REVERT: e30e2276299 Move Option::as_deref_mut REVERT: 1aabb29aeab Move Option::as_deref REVERT: 047aafa4c23 Move Option::unwrap_or_default REVERT: 20b48e78f52 Consolidate impl Result<&mut T, E> REVERT: fe198749356 Consolidate impl Result<&T, E> REVERT: b377aa853a1 Move Result::into_err REVERT: ce4ddd4a174 Move Result::into_ok REVERT: c11074ab999 Move Result::expect_err and Result::unwrap_err REVERT: e9f88a8aa49 Move Result::unwrap_or_default REVERT: 7d68463f9db Move Result::expect and Result::unwrap REVERT: 0fffbdde601 Move Result::as_deref_mut REVERT: 52657875575 Move Result::as_deref REVERT: 0377319891b use generic params for arc_new_cyclic REVERT: b7920894dc4 Use `UnsafeCell::get_mut()` in `core::lazy::OnceCell::get_mut()` REVERT: 67b94b66a2c Remove unused allow deprecated REVERT: e19f52b0288 Remove unused feature gates from libtest REVERT: 78bb3f78956 Remove #![crate_name] attribute from libtest REVERT: f25aa7da1be Replace TDynBenchFn with Fn(&mut Bencher) REVERT: dc6c4872372 fix typo in btree/vec doc: Self -> self REVERT: 4166fd4ac9c Remove CommandEnv::apply REVERT: a9a4cea66f7 Address comments REVERT: 6cc9b61ded2 Auto merge of #92291 - AngelicosPhosphoros:typeid_inline_revert_92135, r=joshtriplett REVERT: e1c03bc5e33 Update library/std/src/ffi/os_str.rs REVERT: e606c729a2f Fix a minor mistake in `String::try_reserve_exact` examples REVERT: 525731a4dd3 Extend const_convert to rest of blanket core::convert impls REVERT: 90f0d74b6e1 Add {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}{,Assign}<$t> to Saturating<$t> REVERT: 28eb8ebf1ea Rollup merge of #92335 - ecstatic-morse:std-column-unicode, r=Manishearth REVERT: 39792a6f845 Implement support in wtf8 REVERT: 2f0de376dee Fix windows build REVERT: 734b4d55349 Add try_reserve for OsString REVERT: 2a8aa307985 Document units for `std::column` REVERT: aaee2674772 Rollup merge of #92307 - hiroshi-maybe:fix-minor-typos, r=camelid REVERT: b86f6c4f074 Rollup merge of #92264 - Shadlock0133:patch-1, r=the8472 REVERT: 56e28121191 Tweak sentence in `transmute` docs REVERT: 71979c271ce Add another implementation example to Debug trait REVERT: 90b9e8651d1 Little improves in CString `new` when creating from slice REVERT: 01d5a6e69f8 fix typo: intialized -> initialized REVERT: 8f3f3d09223 fix typo: the use f.pad -> then use f.pad REVERT: 58dec9b296d Reverts #92135 because perf regression REVERT: 2a1c2bdf527 Fix a pair of mistyped test cases in std::net::ip REVERT: cf15e9c1c4e Remove `maybe_uninit_extra` feature from Vec docs REVERT: c77ce8118ca Auto merge of #92135 - AngelicosPhosphoros:typeid_inline_74362, r=dtolnay REVERT: 62ef1e6b592 Auto merge of #92226 - woppopo:const_black_box, r=joshtriplett REVERT: ac5ebd37c6e Auto merge of #92220 - nnethercote:RawVec-dont-recompute-capacity, r=joshtriplett REVERT: f588d9da38b Rollup merge of #92121 - RalfJung:miri-core-test, r=kennytm REVERT: 7e91512217b Rollup merge of #90625 - Milo123459:ref-unwind-safe, r=dtolnay REVERT: 07c71e1941a Bless a few tests REVERT: f67719c5052 Constify `Box` methods REVERT: 063fc50f64f Constify `core::intrinsics::black_box` REVERT: bfb1718d27c Switch all libraries to the 2021 edition REVERT: 074f3958e15 Add const-stability to `panicking::panic_*` fns REVERT: 2f8a601a2a5 Auto merge of #92155 - m-ou-se:panic-fn, r=eddyb REVERT: 7b70526fcc3 Rollup merge of #92208 - ChrisDenton:win-bat-cmd, r=dtolnay REVERT: 086484ee1b8 Rollup merge of #92139 - dtolnay:backtrace, r=m-ou-se REVERT: 6fc13c1a347 Rollup merge of #92117 - solid-rs:fix-kmc-solid-read-buf, r=yaahc REVERT: 70a06474b79 Rollup merge of #88858 - spektom:to_lower_upper_rev, r=dtolnay REVERT: 3996e561b1a Update stability attribute for double ended case mapping iterators REVERT: 0d59d839de9 Fix tests REVERT: 6bb7071546c RawVec: don't recompute capacity after allocating. REVERT: c1c4913498a Use panic() instead of panic!() in some places in core. REVERT: b6b5edc60c4 Rollup merge of #92129 - RalfJung:join-handle-docs, r=jyn514 REVERT: 1b28b556245 Rollup merge of #91823 - woppopo:const_ptr_as_ref, r=lcnr REVERT: 50b5744abc4 Rollup merge of #90345 - passcod:entry-insert, r=dtolnay REVERT: 8b7e60a0504 kmc-solid: Add `std::sys::solid::fs::File::read_buf` REVERT: 3e64bda3caa Bump insert_entry stabilization to Rust 1.59 REVERT: 3071c0023ba Change Backtrace::enabled atomic from SeqCst to Relaxed REVERT: b3940902e5d Add `#[inline]` modifier to `TypeId::of` REVERT: a2e0614d6a7 impl RefUnwindSafe for Once REVERT: e9ed42e03d1 JoinHandle docs: add missing 'the' REVERT: 396fced2841 disable test with self-referential generator on Miri REVERT: d880611650d Implement split_at_spare_mut directly REVERT: dbc29916c37 paniced -> panicked REVERT: 6d63498b6f2 Rollup merge of #92071 - ajtribick:patch-1, r=the8472 REVERT: b6f7284346f Rollup merge of #92028 - petrochenkov:psimd, r=Mark-Simulacrum REVERT: 2e9dd1e2217 Rollup merge of #91141 - jhpratt:int_roundings, r=joshtriplett REVERT: 944a5be5801 Derive src pointers in sort drop guards from &T REVERT: 167e6ddc0b2 Rollup merge of #92063 - OverOrion:patch-1, r=jyn514 REVERT: 6c87ba9b323 Rollup merge of #92020 - Folyd:stream-unpin, r=m-ou-se REVERT: b767935617f Update example code for Vec::splice to change the length REVERT: 5521e963c49 Rollup merge of #92050 - r00ster91:patch-5, r=camelid REVERT: da672c62f66 docs: fix typo REVERT: ec1cbb09cdf Auto merge of #92062 - matthiaskrgr:rollup-en3p4sb, r=matthiaskrgr REVERT: da1d00eb575 Rollup merge of #92030 - rukai:stdlib2021, r=m-ou-se REVERT: a086f0d227e Rollup merge of #92025 - devnexen:revert-91553-anc_data_dfbsd, r=kennytm REVERT: 9c3dc0a80b0 Rollup merge of #91439 - ecstatic-morse:const-cmp-trait-default-methods, r=oli-obk REVERT: 87f6c86ba4a Rollup merge of #91928 - fee1-dead:constification1, r=oli-obk REVERT: b6c09de3cc4 Add space and 2 grave accents REVERT: 23fd691f787 Auto merge of #91838 - scottmcm:array-slice-eq-via-arrays-not-slices, r=dtolnay REVERT: c5215263308 Update stdlib to the 2021 edition REVERT: 0d67c583c29 Point to the tracking issue REVERT: 8c4fb055858 Constify (most) `Option` methods REVERT: f3dca5f8da1 Merge commit '533f0fc81ab9ba097779fcd27c8f9ea12261fef5' into psimd REVERT: bc31c4d70b7 Disable test on bootstrap compiler REVERT: e83c6d70a3a Test const impl of `cmp` traits REVERT: 0d16db194a7 Mark defaulted `PartialEq`/`PartialOrd` methods as const REVERT: 0232e1638dd Remove P: Unpin bound on impl Stream for Pin REVERT: 3d57ad59c81 attempt to make Report usable with Box dyn Error and fn main REVERT: 733b142fbc9 more docs improvements REVERT: 442bcbb24f0 Auto merge of #92003 - matthiaskrgr:rollup-obgv0rt, r=matthiaskrgr REVERT: 45f0f2e878d add a panicking example REVERT: cc23920ccd6 Update report output and fix examples REVERT: 0ac4f8618f3 Revert "socket ancillary data implementation for dragonflybsd." REVERT: ce72e4a80c3 Implement data and vtable getters for `RawWaker` REVERT: 9cde070f7e7 Quote bat script command line REVERT: feb1f08968c Rollup merge of #91947 - ibraheemdev:io-error-other, r=joshtriplett REVERT: 6e73292fc60 Rollup merge of #91796 - not-my-profile:fix-const_manually_drop-since, r=kennytm REVERT: 60f14a6be4f Fix SB problems in slice sorting REVERT: 07f233d242a Auto merge of #91996 - matthiaskrgr:rollup-8pdt8x7, r=matthiaskrgr REVERT: 07bf187f448 Rollup merge of #91986 - ayrtonm:bump-builtins, r=Amanieu REVERT: 88c59906261 Rollup merge of #91972 - RalfJung:pref-align-of, r=Mark-Simulacrum REVERT: 6a2a63c5d6a Rollup merge of #91951 - SparrowLii:master, r=Amanieu REVERT: 34edead8bc5 Auto merge of #91527 - the8472:retain-opt, r=dtolnay REVERT: d49e4ff308f Bump compiler-builtins to 0.1.66 REVERT: 0c7ba09f2b6 Modifications to buffer UTF-16 internally so that there is no longer a 4-byte buffer minimum. Include suggestions from @agausmann and @Mark-Simulacrum. REVERT: db819583d9e link to pref_align_of tracking issue REVERT: 180dd68f359 Auto merge of #91962 - matthiaskrgr:rollup-2g082jw, r=matthiaskrgr REVERT: 8c98b283e53 Rollup merge of #91918 - fee1-dead:constification0-the-great-constification-begins, r=oli-obk REVERT: f457baef119 Rollup merge of #91916 - steffahn:fix-typos, r=dtolnay REVERT: bc97720050f Auto merge of #91959 - matthiaskrgr:rollup-rhajuvw, r=matthiaskrgr REVERT: 2808742bf4e Track caller of slice split and swap REVERT: 3d18e318f9b Rollup merge of #91906 - anuvratsingh:remove_in_band_lifetimes_library_proc_macro, r=petrochenkov REVERT: 0cb3718cbb3 Rollup merge of #91886 - euclio:option-doc, r=dtolnay REVERT: 4fb853a6a5d Rollup merge of #91479 - scottmcm:slice-as-simd, r=workingjubilee REVERT: 4908220e2e0 Rollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, r=jackh726,pnkfelix REVERT: 3e9c678d606 Auto merge of #91752 - yaahc:track-caller-result, r=cuviper REVERT: 5d341ef03af Stabilize `destructuring_assignment` REVERT: 7d3f667417e Auto merge of #91945 - matthiaskrgr:rollup-jszf9zp, r=matthiaskrgr REVERT: a16f1fbe791 update stdarch REVERT: 1edda8182f5 add `io::Error::other` constructor REVERT: b99ccd80eea Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm REVERT: 91bc3c735e1 Rollup merge of #91859 - xkr47:patch-2, r=yaahc REVERT: a2423ca2710 Rollup merge of #90939 - estebank:wg-af-polish, r=tmandry REVERT: 3ba3b27a854 Auto merge of #91933 - matthiaskrgr:rollup-cw9qolb, r=matthiaskrgr REVERT: 28dec28bbc9 Update comments per review feedback REVERT: edc822d1819 Stabilize iter::zip. REVERT: 728c15a9f14 Update std::error::Report based on feedback REVERT: 76ad163b1a3 Auto merge of #91728 - Amanieu:stable_asm, r=joshtriplett REVERT: 246123eb6db Do array-slice equality via arrays, rather than always via slices REVERT: 67903e4be51 Rollup merge of #89825 - martinvonz:split-inclusive-empty, r=m-ou-se REVERT: ae170df9372 Constify `bool::then{,_some}` REVERT: da33388784c Fix a bunch of typos REVERT: 541e6b8f9ee Auto merge of #91902 - matthiaskrgr:rollup-hjjyhow, r=matthiaskrgr REVERT: b06d2b46aa8 made compiler happy REVERT: 2349ab863ca Rollup merge of #91851 - woppopo:const_maybeuninit_zeroed, r=yaahc REVERT: 851942c6644 Rollup merge of #91529 - TennyZhuang:try_reserve_binary_heap, r=yaahc REVERT: be1e2281c5f Auto merge of #91766 - scottmcm:more-array-raw-eq, r=yaahc REVERT: 8dc15d061a6 Auto merge of #91680 - saethlin:spare_capacity_mut-in-join, r=dtolnay REVERT: d587ec5bae5 core: minor `Option` doc correction REVERT: 6955702c9f6 Reduce verbosity for `?` on non-`Try` expressions REVERT: 327bd780c6f Stabilize arc_new_cyclic REVERT: 950217fc5bc [ReviewFix] Linguistics REVERT: 372ee16ce04 Iterator::cycle() — document empty iterator special case REVERT: 065344ab300 Stabilize const_cstr_unchecked REVERT: 1cd8474c843 Make `MaybeUninit::zeroed` `const` REVERT: 69d3a55fe3e Auto merge of #91841 - matthiaskrgr:rollup-zlhsg5a, r=matthiaskrgr REVERT: 555a304ca8a Rollup merge of #91824 - woppopo:const_ptr_write_bytes, r=oli-obk REVERT: 6be92f6d2db Rollup merge of #91749 - ssomers:btree_comments, r=Mark-Simulacrum REVERT: a7a8018c245 Rollup merge of #91091 - ecstatic-morse:control-flow-enum-is, r=m-ou-se REVERT: 73d29819159 Rollup merge of #91086 - rhysd:issue-91085, r=m-ou-se REVERT: e1fc30d5185 Auto merge of #91549 - fee1-dead:const_env, r=spastorino REVERT: 8f0abc91299 Address review feedback REVERT: 1c8e68365a2 Stabilize asm! and global_asm! REVERT: 383f88b2922 Rollup merge of #91814 - japm48:spelling-fix, r=RalfJung REVERT: e4169205661 Rollup merge of #91746 - ssomers:btree_tests, r=Mark-Simulacrum REVERT: 5df7bbf08ba Make `(*mut T)::write_bytes` `const` REVERT: 773899d8819 Make `PTR::as_ref` and similar methods `const`. REVERT: cbadd450b25 Revert "Auto merge of #89450 - usbalbin:const_try_revert, r=oli-obk" REVERT: 0e3981a1ab3 doc: fix typo in comments REVERT: 50f5dd20392 Rollup merge of #91806 - woppopo:const_unique, r=dtolnay REVERT: de30999936e Rollup merge of #91797 - the8472:fix-invalid-deref, r=Mark-Simulacrum REVERT: 88927788964 Rollup merge of #91737 - Manishearth:panic-immediate-stdlib, r=joshtriplett REVERT: 4f1c2e0ebd5 Rollup merge of #90081 - woppopo:const_write_bytes, r=oli-obk REVERT: 7fb4fbed1d7 Make `Unique`s methods `const` REVERT: f604f2d36ef Make some `Clone` impls `const` REVERT: ad9b7ce015d Auto merge of #91799 - matthiaskrgr:rollup-b38xx6i, r=matthiaskrgr REVERT: a8f123ad36b Rollup merge of #91721 - danielhenrymantilla:patch-1, r=joshtriplett REVERT: 5fd80e79c69 Rollup merge of #91548 - luojia65:hint-spin-loop-riscv, r=Amanieu REVERT: 29712ed99bb Rollup merge of #90741 - mbartlett21:patch-4, r=dtolnay REVERT: 6fd446806a9 Rollup merge of #90270 - woppopo:const_borrow_trait, r=dtolnay REVERT: 61fbf5f9283 Fix zero-sized reference to deallocated memory REVERT: 7000906cb2a Fix since attribute for const_manually_drop feature REVERT: 940b8bd2d02 Rollup merge of #91782 - maxwase:is_symlink_since_attribute, r=jyn514 REVERT: f85311e4e56 Rollup merge of #91711 - andrewbanchich:improve-zip-example, r=Mark-Simulacrum REVERT: e09aafa91e4 update feature gate REVERT: 06696a3895d add BinaryHeap::try_reserve and BinaryHeap::try_reserve_exact REVERT: b44e93b3057 Correct since attribute for feature REVERT: dee125fb77c Remove unnecessary bounds for some Hash{Map,Set} methods REVERT: 54e441e58dc Rollup merge of #91553 - devnexen:anc_data_dfbsd, r=yaahc REVERT: 6287902a20d Rollup merge of #91515 - jethrogb:rsplit_array, r=yaahc REVERT: 998681f03ec Rollup merge of #91127 - scottmcm:ptr_to_from_bits, r=dtolnay REVERT: 867e04aa55d Auto merge of #91761 - matthiaskrgr:rollup-bjowmvz, r=matthiaskrgr REVERT: ab95c7200ae Allow `memcmp` for more array comparisons REVERT: 976ad5f0776 Rollup merge of #91755 - not-my-profile:fix-const_linked_list_new-since, r=dtolnay REVERT: 31e5bde90b1 Rollup merge of #91709 - juniorbassani:use-from-array-in-set-examples, r=jyn514 REVERT: b17a1d70bf5 Rollup merge of #91697 - dtolnay:lossyfromstr, r=Mark-Simulacrum REVERT: 7cd766554be Rollup merge of #91686 - dalcde:patch-1, r=dtolnay REVERT: 5cc554f8903 Rollup merge of #91681 - WaffleLapkin:patch-3, r=scottmcm REVERT: 6a5ca543f0b Rollup merge of #91679 - ibraheemdev:stream-mod, r=Mark-Simulacrum REVERT: 16dcb5067c0 Rollup merge of #91646 - ibraheemdev:patch-9, r=dtolnay REVERT: c0db641bf92 Rollup merge of #91524 - rukai:fix_extend_from_slice_docs, r=dtolnay REVERT: 08fbb3fdba9 Rollup merge of #91482 - JosephTLyons:update-HashMap-and-BTreeMap-documentation, r=yaahc REVERT: e46dd9cbdd1 Rollup merge of #91325 - RalfJung:const_eval_select, r=dtolnay REVERT: 8b1f874c2c3 Rollup merge of #91105 - jplatte:stream-docs, r=dtolnay REVERT: 4f61642646d Rollup merge of #90897 - jhpratt:fix-incorrect-feature-flags, r=dtolnay REVERT: 41a0912acbc Add rsplit_array variants to slices and arrays REVERT: d62eb673410 Fix since attribute for const_linked_list_new feature REVERT: 32483dd6007 Readd track_caller to Result::from_residual REVERT: c0c124906df BTree: improve public descriptions and comments REVERT: d3a79db3c90 BTree: assert presence of derived functions REVERT: 7bb04017c4b BTree: rename compile-time assertions to match library/alloc/tests REVERT: a865ce71577 Update library/core/tests/future.rs REVERT: 3ea43c2e334 Add separate impl of unwrap_failed to avoid constructing trait objects REVERT: dc7e8b17702 inline Option panics on panic_immediate_abort REVERT: e0032eb608c inline slice panics on panic_immediate_abort REVERT: b534abe59b0 Improve std::iter::zip example. REVERT: 8587575d261 Add tests asserting the function-like semantics of `join!()` REVERT: 6e9f5eab6cc Fix missing `mut` typo REVERT: 937bfafbff2 Bring back the colon separators for the macro munching. REVERT: 5bcf72fb483 Fix two false positive lints REVERT: a4ef146bc7d Minor improvements to `future::join!`'s implementation REVERT: c384b9f42b0 Auto merge of #85157 - the8472:drain-drop-in-place, r=Mark-Simulacrum REVERT: 46a2f54492f Replace iterator-based set construction by *Set::From<[T; N]> REVERT: 8ea40b30070 Update stdarch dependency REVERT: 7c482fa4bf2 Auto merge of #81156 - DrMeepster:read_buf, r=joshtriplett REVERT: 6ad36117d65 Auto merge of #91692 - matthiaskrgr:rollup-u7dvh0n, r=matthiaskrgr REVERT: 99cdd6c0e04 Delete Utf8Lossy::from_str REVERT: b2daf44de1f Rollup merge of #89999 - talagrand:GetTempPath2, r=m-ou-se REVERT: 3c8763d1aaf Rollup merge of #87599 - Smittyvb:concat_bytes, r=Mark-Simulacrum REVERT: dbe7829d89b Rollup merge of #91645 - ibraheemdev:future-join, r=joshtriplett REVERT: 7ee9e0865b3 Fix `Vec::reserve_exact` documentation REVERT: 3f3b49859be fix typo in `intrinsics::raw_eq` docs REVERT: b39f80f8b63 Use `*mut [T]` instead of `[MaybeUninit]` REVERT: ca76eea39bc Use spare_capacity_mut instead of invalid unchecked indexing REVERT: 10bec9ee98b move core/stream/stream/mod.rs to core/stream/stream.rs REVERT: 01a6b96f7ac trim down expansion of `core::future::join` REVERT: 62b3c851ccc remove implicit .await from `core::future::join` REVERT: 8554bf51b0a Auto merge of #91656 - matthiaskrgr:rollup-lk96y6d, r=matthiaskrgr REVERT: bc4224bf916 Rollup merge of #91467 - ChrisDenton:confusing-os-string, r=Mark-Simulacrum REVERT: 515fbab26d6 Auto merge of #91512 - scottmcm:array-intoiter-advance, r=Mark-Simulacrum REVERT: 7195c96120c Work around Clippy false positive on `as c_char` REVERT: d3c54d3f06b correct typo REVERT: 14802f2d1ba fix documentation for `core::ready::Ready` REVERT: 90ef2780110 add tests for `core::future::join` REVERT: 78dbb9bbd2c generate `MaybeDone` futures inline `join` REVERT: 1b76637eb04 implement `core::future::join` REVERT: bf2b2116451 Auto merge of #91484 - workingjubilee:simd-remove-autosplats, r=Mark-Simulacrum REVERT: 6d59d4b92e6 Define c_char using cfg_if rather than repeating 40-line cfg REVERT: 25cdeefb99c core::ops::unsize: improve docs for DispatchFromDyn REVERT: 56e694bd403 Rollup merge of #91547 - TennyZhuang:suggest_try_reserve, r=scottmcm REVERT: 491b9896e9d s/from_raw_parts/new_unchecked/ REVERT: e6544d2e34e Implement concat_bytes! REVERT: da2a77af49f Add tracking issue; make `empty` const too (unstably) REVERT: 33eadaa1572 Move the doc test to edition2021 REVERT: cc111c54c46 Add `array::IntoIter::{empty, from_raw_parts}` REVERT: 51216169489 Add tracking issue number REVERT: cff3491de5a Auto merge of #91284 - t6:freebsd-riscv64, r=Amanieu REVERT: 30ec3c98089 socket ancillary data implementation for dragonflybsd. REVERT: 3b7c5f46ddb Auto merge of #88611 - m-ou-se:array-into-iter-new-deprecate, r=joshtriplett REVERT: 8145a57a38e Add spin_loop hint for RISC-V architecture REVERT: 0ac5ccc1683 doc: suggest try_reserve in try_reserve_exact REVERT: 6cdc31d2343 Rollup merge of #91355 - alexcrichton:stabilize-thread-local-const, r=m-ou-se REVERT: 975dffc6827 Rollup merge of #91215 - GuillaumeGomez:vec-deque-retain-mut, r=m-ou-se REVERT: 4985240e4a6 Rollup merge of #89642 - devnexen:macos_getenv_chng, r=m-ou-se REVERT: 660fe08c5be Update array::IntoIter::new deprecation version. REVERT: 32226798cea Update docs. REVERT: 7360abe4fb9 Use IntoIterator for array impl everywhere. REVERT: 52044e2a300 Swap body of array::IntoIter::new and IntoIterator::new. REVERT: f5da843c1e5 Deprecate array::IntoIter::new. REVERT: eb71aaa5653 Update stabilization version of try_from_mut_slice_to_array REVERT: 727d030925c Add documentation to more `From::from` implementations. REVERT: 432ab970d57 Optimize vec::retain performance REVERT: eae05f3fe29 update vec::retain benchmarks REVERT: f6d9efd0498 Fix Vec::extend_from_slice docs REVERT: 256826f1866 Make `Borrow` and `BorrowMut` impls `const` REVERT: 9b8456e3371 Rollup merge of #87054 - kit-981:master, r=scottmcm REVERT: afa3a5c6e36 Override `Iterator::advance(_back)_by` for `array::IntoIter` REVERT: 2b7a983577e Add a `try_reduce` method to the Iterator trait REVERT: 240a3705402 Rollup merge of #90851 - ibraheemdev:downcast-unchecked, r=scottmcm REVERT: f127587059f fix stability annotations for `Box::downcast` REVERT: de34f428596 Auto merge of #90737 - eholk:intofuture, r=tmandry REVERT: e93921e6c36 Auto merge of #91286 - scottmcm:residual-trait, r=joshtriplett REVERT: 2b6597aee52 Auto merge of #91486 - matthiaskrgr:rollup-699fo18, r=matthiaskrgr REVERT: 6ce8d009395 Rollup merge of #91474 - rtzoeller:dfly_set_errno, r=cuviper REVERT: fbbecfbe684 Rollup merge of #91453 - ChrisDenton:doc-win-tls-dtors, r=dtolnay REVERT: 5066f4a51ed Rollup merge of #91381 - Amanieu:android_libdl, r=petrochenkov REVERT: 486e40df28b Rollup merge of #90269 - woppopo:const_option_expect, r=yaahc REVERT: 25a238e2909 Rollup merge of #88906 - Kixunil:box-maybe-uninit-write, r=dtolnay REVERT: 6099b27c0ce Make `HashMap`s mutable again REVERT: 239d7f6f839 Auto merge of #91339 - cbarrete:vecdeque-remove-grow-check, r=Mark-Simulacrum REVERT: 5c40f5ff8ac Force splatting in SIMD test REVERT: 90acb0de59d Merge commit 'a8385522ade6f67853edac730b5bf164ddb298fd' into simd-remove-autosplats REVERT: 9ee848578a7 Add `[T]::as_simd(_mut)` REVERT: 2b47bc8e940 suppress warning about set_errno being unused on DragonFly REVERT: c1033e1e9fb Rollup merge of #91464 - ChrisDenton:doc-path-case-sensitivity, r=joshtriplett REVERT: 39cf891a1d3 Rollup merge of #91460 - ChrisDenton:doc-last-os-error, r=joshtriplett REVERT: 616802d7129 Rollup merge of #91444 - RalfJung:miri-tests, r=dtolnay REVERT: ddc3f18997f Emphasise that an OsStr[ing] is not necessarily a platform string REVERT: 3b83730cf47 Document file path case sensitivity REVERT: 873321de029 Code review feedback REVERT: a6e91e8ec07 Make array::{try_from_fn, try_map} and Iterator::try_find generic over Try REVERT: c23234b5e03 Document how `last_os_error` should be used REVERT: 3d8c490b6ac Use `BTreeMap::from()` instead of using `BTreeMap::new()` with `BTreeMap::insert()` REVERT: 9d12cd1cad8 Use `HashMap::from()` instead of using `HashMap::new()` with `HashMap::insert()` REVERT: ec19cc44901 Implement write() method for Box> REVERT: 42718a7e722 Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbini REVERT: 2f064296792 Document Windows TLS drop behaviour REVERT: 782ab34dd54 disable tests in Miri that take too long REVERT: aae4c5b23f7 Rollup merge of #88502 - ibraheemdev:slice-take, r=dtolnay REVERT: 3a279d54b21 Rollup merge of #91346 - ibraheemdev:result-inspect, r=dtolnay REVERT: bea0dd60b8c Rollup merge of #91340 - cr1901:no-atomic, r=Mark-Simulacrum REVERT: 00670ab5c7d Apply cfg-bootstrap switch REVERT: 760fa557017 Auto merge of #91352 - nnethercote:RawVec-reserve_for_push, r=dtolnay REVERT: 21cbef11af2 Rollup merge of #91383 - ScriptDevil:drop-while-doc-alias, r=joshtriplett REVERT: 14f5fb8a4f9 Rollup merge of #91323 - RalfJung:assert-type, r=oli-obk REVERT: bfccf875590 Add `drop_while` as doc alias to `Iterator::skip_while` REVERT: 362a3ca7335 Android: -ldl must appear after -lgcc when linking REVERT: d43264f8dfb Remove unnecessary check in VecDeque::grow REVERT: cf09ebf0a6b Auto merge of #91244 - dtolnay:lossy, r=Mark-Simulacrum REVERT: ef70ab1c604 Introduce `RawVec::reserve_for_push`. REVERT: 9489be0be35 CTFE: support assert_zero_valid and assert_uninit_valid REVERT: e2b0e74af34 std: Stabilize the `thread_local_const_init` feature REVERT: 443947bf5ab Rollup merge of #91049 - dimo414:patch-1, r=kennytm REVERT: 2a20c6e3ca7 add `Option::inspect` and `Result::{inspect, inspect_err}` REVERT: f6265dd8e2c Bump compiler_builtins to 0.1.55 to bring in fixes for targets lacking atomic support. REVERT: d49c568f204 Auto merge of #90681 - workingjubilee:update-libc, r=JohnTitor REVERT: b527681419a adjust some const_eval_select safety comments REVERT: 0fe26b3eb06 adjust const_eval_select documentation REVERT: 5793c2daeb3 Rollup merge of #90896 - jhpratt:stabilize_const_maybe_uninit, r=oli-obk REVERT: 27554ba015a Add test for const `MaybeUninit` REVERT: 2fc73d3ae1b Stabilize some `MaybeUninit` behavior as const REVERT: 3fafae8678a Auto merge of #91301 - scottmcm:stabilize-nonzero-ipot, r=nagisa REVERT: 97d7cfd16e9 Update libc to 0.2.108 REVERT: 0147d4a61bf Auto merge of #91241 - dtolnay:firstchunk, r=oli-obk REVERT: df52ac59479 Stabilize nonzero_is_power_of_two REVERT: 836c50ec3d5 Auto merge of #91288 - matthiaskrgr:rollup-yp5h41r, r=matthiaskrgr REVERT: cd46fb675d8 Auto merge of #89916 - the8472:advance_by-avoid-err-0, r=dtolnay REVERT: 344fbccdf05 Rollup merge of #91266 - jam1garner:fmt-ptr-fix, r=dtolnay REVERT: e4343c97e1d Rollup merge of #91057 - the8472:clarify-parallelism-steady-state, r=dtolnay REVERT: 0f354023dac Rollup merge of #90995 - the8472:hash-portability, r=dtolnay REVERT: efd1b50fd3b Rollup merge of #83791 - the8472:relax-zip-side-effect-guarantee, r=dtolnay REVERT: 2254cf35c0c Auto merge of #90846 - cuviper:weak, r=dtolnay REVERT: 81c88044501 Add riscv64gc-unknown-freebsd REVERT: 83629738784 Auto merge of #91269 - matthiaskrgr:rollup-jh8i8eh, r=matthiaskrgr REVERT: bc479028e2a Rollup merge of #91248 - alessandrod:compiler-builtins-bump-bpf, r=Mark-Simulacrum REVERT: e5d84a060f0 Rollup merge of #91240 - dtolnay:utf8width, r=Mark-Simulacrum REVERT: 617003582dd Auto merge of #91246 - nnethercote:faster-layout-array, r=dtolnay REVERT: a2ac9b596de Clarify safety comment on using i to index into self.source REVERT: 08b7fc3c006 Use non-generic inner function for pointer formatting REVERT: b4474e2d1ec Rollup merge of #91176 - hermitcore:spin, r=kennytm REVERT: 2923e3a7c7a Bump compiler-builtins to 0.1.53 REVERT: 4f755ed9b7a Add a unit test for zero-sized types in `RawVec`. REVERT: 6629c4cd30e Optimize `Layout::array`. REVERT: 43ec4d42d56 Use unchecked construction in `Layout::pad_to_align`. REVERT: 51d2ab424bc Eliminate bunch of copies of error codepath from Utf8LossyChunksIter REVERT: aa250c484eb Eliminate an unreachable codepath from String::from_utf8_lossy REVERT: 0c605856333 Saner formatting for UTF8_CHAR_WIDTH table REVERT: 55053510866 Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=estebank REVERT: bd71a5336e5 Implement VecDeque::retain_mut REVERT: 4407971dcad Rollup merge of #91151 - name1e5s:chore/process_test, r=m-ou-se REVERT: b843097ffc7 Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid REVERT: 14eacb92393 Rollup merge of #89542 - jhpratt:stabilize-duration-const-fns, r=oli-obk REVERT: 7eccbaa3707 Create rustdoc_internals feature gate REVERT: 91f9367e7ee Improving the readability REVERT: eeb68c79716 If the thread does not get the lock in the short term, yield the CPU REVERT: 56e2ae96426 Make `intrinsics::write_bytes` const REVERT: 024a03fb55b Apply suggestions from code review REVERT: 7c41a76d259 Add generator lang-item REVERT: b5d1cdab734 Rollup merge of #91153 - birkenfeld:kernel_copy_fallback, r=the8472 REVERT: 62b3af5de0b kernel_copy: avoid panic on unexpected OS error REVERT: 4ee2870bfec fix test in std::process on android REVERT: cf71c7a55a7 Use `derive_default_enum` in the compiler REVERT: c2cdb25ec68 Reintroduce `into_future` in `.await` desugaring REVERT: 375494d5030 Revert "Temporarily rename int_roundings functions to avoid conflicts" REVERT: 873d990efbb Partially stabilize `duration_consts_2` REVERT: 6ed794652d1 Auto merge of #91101 - birkenfeld:io_error_docs, r=Mark-Simulacrum REVERT: ba3f62df2e0 Intra-doc links apparently don't like pointers? REVERT: 7b2436562d8 Add `<*{const|mut} T>::{to|from}_bits` REVERT: a5a73b2577f impl Not for ! REVERT: 34566c64bf7 Test not never REVERT: 3e26a8d64e9 Auto merge of #90352 - camsteffen:for-loop-desugar, r=oli-obk REVERT: 44eab50dbc4 libcore: assume the input of `next_code_point` and `next_code_point_reverse` is UTF-8-like REVERT: 053bfddf66f Simplify for loop desugar REVERT: be3441c61b9 Fix method name reference in stream documentation REVERT: 7ae64b4ac39 Rollup merge of #91008 - Urgau:float-minimum-maximum, r=scottmcm REVERT: 9c5690b9185 Mention std::io::Error::from(ErrorKind) in Error::new() docs REVERT: 39f72bd1c58 Reborrow mut slice instead of converting it with `as_ref` REVERT: efc1c301692 fix doc links for `downcast_unchecked` REVERT: 626184a1651 Apply documentation suggestions from @est31 REVERT: 16c1051f6fc Auto merge of #91093 - matthiaskrgr:rollup-kovzwx0, r=matthiaskrgr REVERT: 039ad401c50 Rollup merge of #89741 - sdroege:arc-rc-from-inner-unsafe, r=Mark-Simulacrum REVERT: 9711f5bbb77 Add a caveat to std::os::windows::fs::symlink_file REVERT: 9dcb0b4483f Stabilize `ControlFlow::{is_break, is_continue}` REVERT: 4dc1eb58977 Auto merge of #87704 - ChrisDenton:win-resolve-exe, r=yaahc REVERT: 5b1b257e2cf Update version in `stable` attribute REVERT: a2df68797dc Implement `TryFrom<&'_ mut [T]>` for `[T; N]` REVERT: 5bbd7d86a50 Add similar note as LLVM does for minNum and maxNum functions REVERT: 48d5b4b2bfd Implement IEEE 754-2019 minimun and maximum functions for f32/f64 REVERT: 486ea780455 Auto merge of #91052 - ehuss:update-stdarch, r=Amanieu REVERT: 46648614cab document why we're not directly passing drop_ptr to drop_in_place REVERT: 014240ea104 replace vec::Drain drop loops with drop_in_place REVERT: 0ed9831fad6 Rollup merge of #91044 - r00ster91:x1b, r=joshtriplett REVERT: 865f69da1f8 Rollup merge of #88361 - WaffleLapkin:patch-2, r=jyn514 REVERT: 7b9d8da3a6e Expand available_parallelism docs in anticipation of cgroup quotas REVERT: c4765a12cb2 Update stdarch REVERT: 513d77fcd5e Turn all 0x1b_u8 into '\x1b' or b'\x1b' REVERT: 1e7768e17de Remove unnecessary doc links REVERT: bec21cd44d9 Fix Iterator::advance_by contract inconsistency REVERT: 32b7aea0251 Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-se REVERT: 1870990ca4b Rollup merge of #89258 - est31:const_char_convert, r=oli-obk REVERT: 093ad534de3 Auto merge of #90774 - alexcrichton:tweak-const, r=m-ou-se REVERT: 09ee0e8a55a Auto merge of #91019 - JohnTitor:rollup-q95ra7r, r=JohnTitor REVERT: b73ef565e80 Rollup merge of #90607 - WaffleLapkin:const_str_from_utf8, r=oli-obk REVERT: 9a381f32a16 Rollup merge of #90480 - r00ster91:remove, r=kennytm REVERT: 6185fad3500 Auto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplett REVERT: ce3bd8e7331 Fill in tracking issues for `const_str_from_utf8` and `const_str_from_utf8_unchecked_mut` features REVERT: e12ecf2fb26 Document non-guarantees for Hash REVERT: 8908dd506f7 Make slice->str conversion and related functions const REVERT: caef5e660f7 Rollup merge of #90772 - GuillaumeGomez:vec-retain-mut, r=joshtriplett REVERT: 5139a6dc423 Rollup merge of #90687 - jhpratt:const_panic, r=oli-obk REVERT: 76dca1617f4 Fill in tracking issue for feature `const_align_offset` REVERT: 3d29b4ce9a8 Mark `<*const _>::align_offset` and `<*mut _>::align_offset` as `const fn` REVERT: 392996e744d windows: Return the "Not Found" error when a path is empty REVERT: 3c9149e89c6 Rollup merge of #90909 - RalfJung:miri-no-portable-simd, r=workingjubilee REVERT: 04d71a7eac6 Rollup merge of #90848 - scottmcm:remove-signed-bigint-helpers, r=joshtriplett REVERT: 71eb05aaeb6 Rollup merge of #90835 - sunfishcode:sunfishcode/wasi-char-device, r=alexcrichton REVERT: e10118fd16b Rollup merge of #90790 - tamaroning:fix-lib-std-test, r=Mark-Simulacrum REVERT: f3f5349b1d2 Rollup merge of #88601 - ibraheemdev:termination-result-infallible, r=yaahc REVERT: fa3bcdb2823 Rollup merge of #85766 - workingjubilee:file-options, r=yaahc REVERT: b8828005a29 Auto merge of #90821 - scottmcm:new-slice-reverse, r=Mark-Simulacrum REVERT: 93973dc50dd Stabilize format_args_capture REVERT: aea95f97051 Give examples of format args capture in the fmt module documentation REVERT: d1350c718a2 Auto merge of #88282 - Neutron3529:patch-4, r=Mark-Simulacrum REVERT: 60256bef133 disable portable SIMD tests in Miri REVERT: 581e45b407e Auto merge of #90596 - the8472:path-hash-opt, r=Mark-Simulacrum REVERT: 7208f2f417e Fix incorrect feature flags REVERT: 53bb68e6705 Auto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obk REVERT: b2d6b409a58 Auto merge of #90542 - the8472:privatize-the-means-of-rawvec-production, r=joshtriplett REVERT: 72500ff89de Auto merge of #87264 - mystor:expand_literal, r=petrochenkov REVERT: 6a48cd52613 Auto merge of #90041 - jfrimmel:rt_copy_checks, r=Mark-Simulacrum REVERT: 1a6a8b9af39 add slice take methods REVERT: 8612d973b38 add tracking issue for `downcast_unchecked` REVERT: a1b3ebc47a0 add unchecked downcast methods REVERT: e4e6c22d6f8 Auto merge of #89167 - workingjubilee:use-simd, r=MarkSimulacrum REVERT: 93822e4e87a Remove bigint_helper_methods for *signed* types REVERT: 0187bd069a3 Test core::simd works REVERT: 11bbbe5031d Expose portable-simd as core::simd REVERT: 3ba8ad52bce Add 'library/portable-simd/' from commit '1ce1c645cf27c4acdefe6ec8a11d1f0491954a99' REVERT: 9609a1711ac Refactor weak symbols in std::sys::unix REVERT: 37da41722b0 proc_macro: Add an expand_expr method to TokenStream REVERT: 79ace3d2ff3 Rollup merge of #90798 - edmorley:doc-unreachable-custom-message, r=dtolnay REVERT: 7fdd8bcfc1b Rollup merge of #90704 - ijackson:exitstatus-comments, r=joshtriplett REVERT: af20b9989c1 Rollup merge of #90644 - est31:const_swap, r=Mark-Simulacrum REVERT: 778b80edc43 Rename WASI's `is_character_device` to `is_char_device`. REVERT: 13d626d7ece Add Vec::retain_mut REVERT: 1c946e89892 provide a `SpecExtend` trait for `Vec` The discussion is [here](https://internals.rust-lang.org/t/append-vec-to-binaryheap/15209/3) REVERT: aca7caab37e MIRI says `reverse` is UB, so replace it with an implementation that LLVM can vectorize REVERT: 5aa73d3ce75 `Prefix` can be case-insensitive, delegate to its Hash impl instead of trying to hash the raw bytes REVERT: ad5f94c9d57 process::ExitStatus: Discuss `exit` vs `_exit` in a comment. REVERT: 25b038aff4e unix::ExitStatus: Add comment saying that it's a wait status REVERT: 51e3cec95ab unix::ExitStatusExt: Correct reference to _exit system call REVERT: 5924aa3eef4 Document `unreachable!()` custom panic message REVERT: 05485d8e347 Auto merge of #88798 - sunfishcode:sunfishcode/windows-null-handles, r=joshtriplett REVERT: 44b3be3760e Auto merge of #90755 - scottmcm:spec-array-clone, r=jackh726 REVERT: 434646f9204 compare between Path instead of str REVERT: 4bcdee75971 Auto merge of #90784 - matthiaskrgr:rollup-car8g12, r=matthiaskrgr REVERT: c0ec3527976 Rollup merge of #89930 - cuviper:avoid-clone3, r=joshtriplett REVERT: ce3ffe9983b Moar #[inline] REVERT: 631701a379d std: Tweak expansion of thread-local const REVERT: 78c42b3b8db Update stdarch/dlmalloc REVERT: 251715c6eeb Update dlmalloc for libstd REVERT: 910d927d72a Update stdarch/compiler_builtins REVERT: 490056d40e0 Update more rustc/libtest things for wasm64 REVERT: a3ad0e32ecc Review comments REVERT: ed543cd994c Use `target_family = "wasm"` REVERT: 8637bfd1bf9 std: Get the standard library compiling for wasm64 REVERT: 1a26cafa5d4 Fix collection entry API documentation. REVERT: 0d93262a2ef Specialize array cloning for Copy types REVERT: 5ded967641c Rollup merge of #90751 - ehuss:update-books, r=ehuss REVERT: 52784cdce92 Rollup merge of #90748 - cuviper:track-setgroups, r=dtolnay REVERT: 8b860d6c7de Rollup merge of #90690 - solid-rs:fix-kmc-solid-asm-const, r=Mark-Simulacrum REVERT: ca03d0dc7ce Update books REVERT: 3b2ce3b8152 Add a real tracking issue for `CommandExt::groups` REVERT: 921d8c458e0 Format REVERT: 12015ea9604 Rename `Option::cloned` gate REVERT: 00daefb3d44 Make `Option::cloned` const fn. REVERT: c82b043d824 Auto merge of #90734 - matthiaskrgr:rollup-e1euotp, r=matthiaskrgr REVERT: 42508534bf3 remove redundant .iter() call since zip() takes an IntoIterator argument REVERT: cb3ad6d5d45 add fast path on Path::eq for exact equality REVERT: 6f4e8e292b6 optimize Hash for Path REVERT: 5f6d66a230d add benchmarks and tests for Hash and Eq impls on Path REVERT: c02bd7b85e1 Extend the const_swap feature REVERT: e3a66729b1b Stabilize File::options() REVERT: 88f655ef9ad Rollup merge of #90723 - asquared31415:box_docs, r=jyn514 REVERT: 6f6d832310f Auto merge of #86041 - bstrie:unmagic-array-copy, r=jackh726 REVERT: 534c5dd7548 Rollup merge of #87530 - bstrie:commentsync, r=bstrie REVERT: 7a1c14a47cc document Box and box_free connection REVERT: 619eb004834 Re-enable `copy[_nonoverlapping]()` runtime checks REVERT: 0505d62f5e6 Permit const assertions in stdlib REVERT: 00aeee6bbed Attempt to address perf regressions with #[inline] REVERT: 23c03d16733 Update Copy/Clone documentation WRT arrays REVERT: 00140869117 impl Copy/Clone for arrays in std, not in compiler REVERT: d2b55dda0d8 Add comments regarding superfluous `!Sync` impls REVERT: 4b870f44c0e Rollup merge of #90494 - Meziu:armv6k-3ds-target, r=sanxiyn REVERT: 13dbf6127ad kmc-solid: Avoid the use of `asm_const` REVERT: b4a9cb2f351 Auto merge of #89310 - joshtriplett:available-concurrency-affinity, r=m-ou-se REVERT: b542ba42af4 Auto merge of #90348 - Amanieu:asm_feature_gates, r=joshtriplett REVERT: c5cafd6ac15 Add features gates for experimental asm features REVERT: 83307dfe532 Stabilize `const_raw_ptr_deref` for `*const T` REVERT: a3fc02d635f use matches!() macro in more places REVERT: 8f6f0be4005 Auto merge of #90297 - dtolnay:dotzero, r=petrochenkov REVERT: 476e33b47d8 Also note tool expectations of fork vs clone3 REVERT: 9fded2056c8 Update another comment on fork vs. clone3 REVERT: 00521a05ab8 Only use `clone3` when needed for pidfd REVERT: f3ceaabec9f Reorder `widening_impl`s to make the doc clearer REVERT: 881f802f086 Add UnwindSafe to Once REVERT: 9555ea6c4e6 Auto merge of #90604 - mbartlett21:iterator-reexports, r=kennytm REVERT: 4af2c7c99fb Auto merge of #90577 - matthiaskrgr:clippy_perf_nov, r=petrochenkov REVERT: 279a6cd47e0 Fix `str::SplitInclusive` stabilisation date REVERT: e829b258896 Add feature to `alloc` so we can re-export. REVERT: b95be8ea179 Re-export `core::slice::EscapeAscii` REVERT: 2674ff81973 Re-export `core::slice::SplitInclusive[Mut]` REVERT: a4c292b19d3 Rollup merge of #90556 - scottmcm:carrying_comments, r=joshtriplett REVERT: feea8988bed clippy::perf fixes REVERT: f4c38f92e5e Add more text and examples to `carrying_{add|mul}" REVERT: 56f6e082123 Auto merge of #87467 - inquisitivecrystal:ref-unwind, r=dtolnay REVERT: c3f44a7c7e5 Auto merge of #90392 - solid-rs:fix-solid-support, r=Mark-Simulacrum REVERT: a9b7e87c7c2 Make RawVec private to alloc REVERT: 44ea2a32f6b formatting REVERT: dfa7a90241f fix change clobbered by rebase REVERT: 27b4536c642 implement review suggestions REVERT: 7ec719efd78 Update library/std/src/sys/unsupported/fs.rs REVERT: cdde31f4f38 add read_buf for &File REVERT: e73cd397e9d fix test failure from trying to assume_init too much REVERT: 63abe8cdca6 add safety comments REVERT: cf81d886cb9 Don't reinitialize here REVERT: d25d706c392 more efficent File::read_buf impl for windows and unix REVERT: 5dca3da8a49 consolidate 2 unsafe blocks into 1 REVERT: d528d0d66c2 read_buf REVERT: 3bdfd6ae5f1 Auto merge of #90421 - thomcc:friendship-ended-with-ssize_t-now-ptrdiff_t-is-my-best-friend, r=joshtriplett REVERT: 509915d2508 Implement `RefUnwindSafe` for `Rc` REVERT: 6b972a573dc Auto merge of #90442 - ChrisDenton:win-tls-dtor, r=alexcrichton REVERT: 3e0981d2175 Updated backtrace submodule REVERT: bf232622469 Auto merge of #90439 - m-ou-se:thread-is-running, r=Mark-Simulacrum REVERT: 91a3a31d8d2 mention `remove` in `swap_remove` REVERT: 7a51541cc9c Run destructors from existing tls callback REVERT: d48f60c9830 Add tracking issue for thread_is_running. REVERT: 2550f126a54 itron: Rename `itron::thread::{available_conccurrency -> available_parallelism}` REVERT: af0e4091468 Bump libc dependency of std to 0.2.106 REVERT: bd77a55506b Pull `self.v.len()` out in `RChunks::next` as suggested in review comments REVERT: ce87f39b3a6 Reference Chunks::next_back in more of the chunk iterators safety comments REVERT: 10f99df9f93 Address some issues in chunk iterator safety comments REVERT: f6f5e1726cf Carefully remove bounds checks from some chunk iterators REVERT: 35dd323afb3 Re-add `std::os::raw::c_ssize_t`, with more accurate documentation REVERT: 30cd132e2eb Windows: Resolve Command program without using the current directory REVERT: 8062908b75b Windows thread-local keyless drop REVERT: 1f016ba2e79 Auto merge of #86336 - camsteffen:char-array-pattern, r=joshtriplett REVERT: ec650cf5ac0 Add test for JoinHandle::is_running. REVERT: dfdaef9df22 Add JoinHandle::is_running. REVERT: d2a40209491 Rollup merge of #90431 - jkugelman:must-use-std-o-through-z, r=joshtriplett REVERT: 9c9f2f28350 Rollup merge of #90430 - jkugelman:must-use-std-a-through-n, r=joshtriplett REVERT: dcb73c74394 Rollup merge of #89786 - jkugelman:must-use-len-and-is_empty, r=joshtriplett REVERT: 5633bce6131 Rollup merge of #89068 - bjorn3:restructure_rt2, r=joshtriplett REVERT: 3b11d2d203a Rollup merge of #90427 - jkugelman:must-use-alloc-leak, r=joshtriplett REVERT: 77b42f5cacb Rollup merge of #89951 - ojeda:stable-unwrap_unchecked, r=dtolnay REVERT: 03e40b86c9a Rollup merge of #89897 - jkugelman:must-use-core, r=joshtriplett REVERT: 8ccfbf15fd3 Rollup merge of #89839 - jkugelman:must-use-mem-ptr-functions, r=joshtriplett REVERT: 0c38a2188c0 Rollup merge of #89835 - jkugelman:must-use-expensive-computations, r=joshtriplett REVERT: f76559eb400 Rollup merge of #89833 - jkugelman:must-use-rc-downgrade, r=joshtriplett REVERT: 05f3f9d670f Rollup merge of #89677 - maxwase:is-symlink-stabilization, r=joshtriplett REVERT: b22280134e3 Rollup merge of #89446 - chrismit3s:issue-88715-fix, r=joshtriplett REVERT: cb4c1eaccae Add #[must_use] to remaining std functions (A-N) REVERT: 4645f2452d1 Add #[must_use] to remaining std functions (O-Z) REVERT: 7dc28ffbb3e Add #[must_use] to alloc functions that would leak memory REVERT: 177d020e4c2 Auto merge of #90306 - kornelski:slicecloneasset, r=joshtriplett REVERT: 1046eeca79a Make std::thread::available_concurrency support process-limited number of CPUs REVERT: 878d745a9cf Update libc to 0.2.106 to get definitions for CPU_* REVERT: a72e5fbb96a Add #[must_use] to len and is_empty REVERT: 95b5646f646 Add #[must_use] to mem/ptr functions REVERT: 92213ac7ae7 Rollup merge of #90401 - mkroening:hermit-condvar, r=joshtriplett REVERT: 51a36b3fed9 Rollup merge of #89899 - jkugelman:must-use-alloc, r=joshtriplett REVERT: 2972537cc5e Rollup merge of #89789 - jkugelman:must-use-thread-builder, r=joshtriplett REVERT: 1e36249191e Add #[must_use] to remaining core functions REVERT: 95c41797a09 Replace `std::os::raw::c_ssize_t` with `std::os::raw::c_ptrdiff_t` REVERT: 7c4bb9f465e Auto merge of #90205 - mati865:link-modifiers-in-rustc, r=petrochenkov REVERT: 225af2a8375 Rollup merge of #90377 - WaffleLapkin:const_slice_from_raw_parts, r=oli-obk REVERT: 39c14c88a92 Rollup merge of #90371 - Veykril:patch-2, r=jyn514 REVERT: 8cd3747175d Rollup merge of #89876 - AlexApps99:const_ops, r=oli-obk REVERT: 9a7be4ad2a4 Use "rustc" for testing Command args REVERT: 56a545c325a Auto merge of #89174 - ChrisDenton:automatic-verbatim-paths, r=dtolnay REVERT: 04f8ef1268a Auto merge of #90346 - ferrocene:pa-short-circuit, r=oli-obk REVERT: 8613d1b94ca Apply changes proposed in the review REVERT: 7da246dd7f7 Use proper issue number for `feature(const_slice_from_raw_parts)` REVERT: 4bbbc3234d6 hermit: Implement Condvar::wait_timeout REVERT: ee1f6db4c3d Auto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnr REVERT: 8d0fea4dbce Rollup merge of #90336 - mbartlett21:patch-4, r=Mark-Simulacrum REVERT: bb81fabff5c Revert "Add rustc lint, warning when iterating over hashmaps" REVERT: f63dca12597 Make `core::slice::from_raw_parts[_mut]` const REVERT: ed6f8038e99 Fix incorrect doc link REVERT: d5d96d6a370 Fix broken doctest REVERT: 235e81a4bba Auto merge of #90347 - matthiaskrgr:rollup-rp2ms7j, r=matthiaskrgr REVERT: a594ce41b7b Format doctest REVERT: 5fb9602ab58 Add `rust` annotation to doctest REVERT: a840f206500 Attempt to fix tidy errors REVERT: 0d3adb18344 Rollup merge of #90344 - xfix:tracking-issue-const_cstr_unchecked, r=Mark-Simulacrum REVERT: 9e17b3e0fc0 Rollup merge of #90239 - r00ster91:patch-1, r=fee1-dead REVERT: c16cf87a604 Remove big O notation REVERT: 0d7c6b54034 Auto merge of #90273 - nbdd0121:const, r=fee1-dead REVERT: 7d651e0bce9 replace `&` with `&&` in {integer}::checked_rem REVERT: 9c309929e93 replace `&` with `&&` in {integer}::checked_div REVERT: 2c44a1763df replace `|` with `||` in string validation REVERT: 80be31aa3a4 replace `|` with `||` in {unsigned_int}::borrowing_sub REVERT: ff7be11104d replace `|` with `||` in {unsigned_int}::carrying_add REVERT: 6133c2563e1 Stabilise entry_insert REVERT: c2c1a0f7dab Update doctests for renames REVERT: d7db0546957 Expose HashMap:VacantEntry:insert_entry REVERT: 2cf8ecaec01 Rename HashMap:Entry:insert to :insert_entry REVERT: 894a3caa3dc Add tracking issue number to const_cstr_unchecked REVERT: b1f6facf2ca Rollup merge of #90154 - camelid:remove-getdefid, r=jyn514 REVERT: 712a56b205e Remove extra lines in examples for `Duration::try_from_secs_*` REVERT: a28df1590dc Clarify platform availability of GetTempPath2 REVERT: 7980ab31967 Auto merge of #90314 - matthiaskrgr:rollup-ag1js8n, r=matthiaskrgr REVERT: a7b9f1ec49f Rollup merge of #90296 - CAD97:rip-lerp, r=Mark-Simulacrum REVERT: de9cd7b4e7e Auto merge of #90290 - nyanpasu64:fix-string-as-mut-vec, r=m-ou-se REVERT: 5c6ffac48a4 track_caller for slice length assertions REVERT: 2729d2c59c3 Auto merge of #90284 - tonyyzy:patch-1, r=JohnTitor REVERT: 5ba14fae4c6 Remove redundant Aligner REVERT: 67b20603c37 Fix copy-paste error in String::as_mut_vec() docs REVERT: 278dd6e8781 Remove fNN::lerp - consensus unlikely REVERT: 7bdeb3e2582 Append .0 to unsuffixed float if it would otherwise become int token REVERT: 500af709cc1 remove requirement of T: Debug from Weak REVERT: 21c5f133582 Rollup merge of #90196 - yanok:master, r=scottmcm REVERT: b0c3e048275 Clean up special function const checks REVERT: 129dae4f7e2 Make `Option::expect` const REVERT: 655684b003d Auto merge of #90265 - GuillaumeGomez:rollup-gx3ficp, r=GuillaumeGomez REVERT: 22ccd4f87a6 Fixed missing double quote in the patch (slice.swap) REVERT: 1c1cabbbf07 Changed slice.swap documentation for better readability REVERT: 1230a9aba5f Auto merge of #90042 - pietroalbini:1.56-master, r=Mark-Simulacrum REVERT: 080fc6d4ca2 Fix and extend ControlFlow `traverse_inorder` example REVERT: 2e93f375d01 Rollup merge of #90162 - WaffleLapkin:const_array_slice_from_ref_mut, r=oli-obk REVERT: d5a019b7909 Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank REVERT: 343bcbd040b update cfg(bootstrap) REVERT: d4af767ea17 Add tests for `const_slice_from_ref` and `const_array_from_ref` REVERT: 585ec3599b0 Fix typo REVERT: fd466e9e2af Make sure `CreateDirectoryW` works for path lengths > 247 REVERT: e535a2372fe Fill tracking issue for `const_slice_from_ref` and `const_array_from_ref` REVERT: 6d439a26adb Repace use of `static_nobundle` with `native_link_modifiers` REVERT: de602fd7b68 Add caveat about changing parallelism and function call overhead REVERT: 753def5b3ea Update control_flow.rs REVERT: d28d10a0b0f Rollup merge of #90166 - smmalis37:patch-1, r=joshtriplett REVERT: 801ee20c9de Rollup merge of #90117 - calebsander:fix/rsplit-clone, r=yaahc REVERT: c4660f7b551 Rollup merge of #88300 - ijackson:exitstatusext-methods, r=yaahc REVERT: 291a1b2de9a Rollup merge of #83233 - jethrogb:split_array, r=yaahc REVERT: f1a3ffa23e3 docs: Escape brackets to satisfy the linkchecker REVERT: 730c1d77899 Auto merge of #90007 - xfix:inline-cstr-from-str, r=kennytm REVERT: df05b13bd0d Change `source` field to `error` REVERT: 5d8de704857 Have `pretty` and `show_backtrace` accept booleans REVERT: 1ba0667937b Apply suggestions from code review REVERT: d99f3f293c5 Try commiting again REVERT: c2fbd1dcfa1 Add comment documenting why we can't use a simpler solution REVERT: 35ae8b08591 Mark {array,slice}::{from_ref,from_mut} as const fn REVERT: b6ff9f832ed Rollup merge of #89944 - mbartlett21:patch-2, r=Mark-Simulacrum REVERT: cf286d10794 Rollup merge of #89665 - seanyoung:push-empty, r=m-ou-se REVERT: ea7ef39c72a Rollup merge of #88624 - kellerkindt:master, r=JohnTitor REVERT: 1420371fe5e Implement split_array and split_array_mut REVERT: 58d595a6ef0 Make RSplit: Clone not require T: Clone REVERT: 8c5f87a7a9e Added docs to internal_macro const REVERT: d7816353fc1 Added const versions of common numeric operations REVERT: 74d93b94902 Stabilize feature saturating_div for rust 1.58 REVERT: 89ad7b0fd05 Clarify undefined behaviour for binary heap, btree and hashset REVERT: 28110dc6e1a Rollup merge of #90099 - SkiFire13:fix-vec-swap-remove, r=dtolnay REVERT: d1b33a6529f Rollup merge of #90077 - woppopo:const_nonzero_from, r=oli-obk REVERT: f5a859faa73 Rollup merge of #90010 - rusticstuff:vecdeque_with_capacity_in_overflow, r=m-ou-se REVERT: 811a1a35a02 Rollup merge of #89292 - CleanCut:stabilize-cstring_from_vec_with_nul, r=JohnTitor REVERT: 7c5539792ed Rollup merge of #87440 - twetzel59:fix-barrier-no-op, r=yaahc REVERT: f257f5d73fc Rollup merge of #86984 - Smittyvb:ipv4-octal-zero, r=m-ou-se REVERT: 846d54916e2 fix 'since' version number REVERT: c70e6b4c06e stabilize CString::from_vec_with_nul[_unchecked] REVERT: 61543cef1e6 Prevent invalid values from existing in Vec::swap_remove REVERT: 11ca17f2ff8 Change `Duration::from_secs_*` underflow error REVERT: e8343eb48a0 Make `From` impls of NonZero integer const. I also changed the feature gate added to `From` impls of Atomic integer to `const_num_from_num` from `const_convert`. REVERT: e1453147984 Stabilize `option_result_unwrap_unchecked` REVERT: 137fdf13da8 Rollup merge of #90009 - woppopo:const_from_more, r=dtolnay REVERT: c68a25b42c2 Rollup merge of #88860 - nbdd0121:panic, r=m-ou-se REVERT: 8677aefafda Rollup merge of #88789 - the8472:rm-zip-bound, r=JohnTitor REVERT: 4b0c2ef71d6 Rollup merge of #87769 - m-ou-se:alloc-features-cleanup, r=yaahc,dtolnay REVERT: 1c82d347309 Rollup merge of #86479 - exphp-forks:float-debug-exponential, r=yaahc REVERT: 52a9b6730f2 Deduplicate panic_fmt REVERT: 76737cb0261 Reenable feature(nll) in alloc. REVERT: 69750b46fde Remove unused language #![feature]s from alloc. REVERT: 33e2b7fcc89 Remove unused library #![feature]s from alloc. REVERT: c660c176819 Sort and categorize #![feature]s in alloc. REVERT: ceb5925af0d Update std::env::temp_dir to use GetTempPath2 on Windows when available. REVERT: d7cbc385968 Auto merge of #90037 - matthiaskrgr:rollup-cdfhxtn, r=matthiaskrgr REVERT: 0c2173a3ab0 Rollup merge of #90034 - moxian:unzip-doc, r=cuviper REVERT: 90bbefc17bc Rollup merge of #89941 - hermitcore:kernel, r=joshtriplett REVERT: 4b7120a1b4f Auto merge of #89905 - matthiaskrgr:rev_89709_entirely, r=michaelwoerister REVERT: 462d9a04af7 Tiny tweak to Iterator::unzip() doc comment example. REVERT: ec0bcf7e569 Avoid overflow in `VecDeque::with_capacity_in()`. REVERT: 8df0fef0958 Make more `From` impls `const` REVERT: 5f4e62b39d7 Inline CStr::from_ptr REVERT: da95b7ee382 Rollup merge of #89996 - winterqt:bump-backtrace, r=Mark-Simulacrum REVERT: e9e4cf22a48 bump backtrace REVERT: 2aef71435f8 Rollup merge of #89977 - woppopo:result_const_as_mut, r=oli-obk REVERT: ae7a8b662d4 Rollup merge of #89945 - JohnTitor:we-now-specialize-clone-from-slice, r=the8472 REVERT: eb15663bb4f Make Result::as_mut const REVERT: f74aae95380 Auto merge of #88652 - AGSaidi:linux-aarch64-should-be-actually-monotonic, r=yaahc REVERT: 1ddfe523048 Rollup merge of #89953 - woppopo:option_const_as_mut, r=oli-obk REVERT: 4437a99f788 Rollup merge of #89507 - lopopolo:lopopolo/ordering-repr-i8, r=joshtriplett REVERT: 83c7a6fb041 Add `#![cfg_attr(bootstrap, feature(const_panic))]` to `library/core/tests/lib.rs` REVERT: 36e99c65d74 Make Option::as_mut const REVERT: e2b1a65f0b9 Remove a mention to `copy_from_slice` from `clone_from_slice` doc REVERT: 028c08c9e7d remove compiler warnings REVERT: a63f183d9a7 Rollup merge of #89925 - gilescope:update-docs-atomic-usage, r=m-ou-se REVERT: 4e3d8dc0f06 Rollup merge of #89921 - joshuaseaton:zircon-process, r=tmandry REVERT: 8d0d937edf9 Rollup merge of #89898 - Amanieu:remove_alloc_prelude, r=joshtriplett REVERT: 0344b46717f Rollup merge of #89509 - jhpratt:stabilize-const_unreachable_unchecked, r=oli-obk REVERT: cb09f6fa090 Make char conversion functions unstably const REVERT: c67fd9dc559 Auto merge of #85379 - mdaverde:uds-abstract, r=joshtriplett REVERT: 7715f8fe61b updating docs to reflect current situation REVERT: 542abac25f1 Auto merge of #84096 - m-ou-se:windows-bcrypt-random, r=dtolnay REVERT: 164bdebdf38 [fuchsia] Update process info struct REVERT: a9e06011861 Auto merge of #89337 - mbrubeck:vec-leak, r=m-ou-se REVERT: 1db5c404209 Add #[must_use] to remaining alloc functions REVERT: 13d7e6597a7 Auto merge of #88717 - tabokie:vecdeque-fast-append, r=m-ou-se REVERT: 97cf20c1261 Use BCryptGenRandom instead of RtlGenRandom on Windows. REVERT: 8fee4f9cb2b Auto merge of #88540 - ibraheemdev:swap-unchecked, r=kennytm REVERT: c488c6acd71 Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov" REVERT: 87eaeba1705 add a `rustc::query_stability` lint REVERT: 41b3e9522da Remove alloc::prelude REVERT: 52cb57c22c2 Rollup merge of #89878 - GuillaumeGomez:add-missing-cfg-hide, r=notriddle REVERT: ed7c390ab5a Rollup merge of #89873 - askoufis:patch-1, r=Mark-Simulacrum REVERT: eebd09d130e Rollup merge of #89433 - arlosi:stdin-fix, r=joshtriplett REVERT: 8731f8ce8db don't duplicate slice `panic_bounds_check` REVERT: 55b36829b1d Auto merge of #89247 - fee1-dead:const-eval-select, r=oli-obk REVERT: 191f9990838 Fix missing remaining compiler specific cfg information REVERT: 426f0bfc7f9 Ensure that pushing empty path works as before REVERT: fd4be639a64 Fix const stability REVERT: 9ecb3307a83 Avoid tupling at the callee REVERT: abaccf4632c Add missing word to `FromStr` trait docs REVERT: 48594ed7e2d Rollup merge of #89670 - yoshuawuyts:available-parallelism-docs, r=joshtriplett REVERT: 33ba43d4a76 Improve `std::thread::available_parallelism` docs REVERT: 94550ddcef4 Rollup merge of #89817 - m-ou-se:int-log-10-inline, r=the8472 REVERT: 9cc9dffb839 Rollup merge of #89814 - jkugelman:must-use-string-transforms-typo, r=joshtriplett REVERT: 7aa4e318c30 Rollup merge of #89794 - jkugelman:must-use-to_value-conversions, r=joshtriplett REVERT: 1623d762f32 Rollup merge of #89781 - Wilfred:patch-2, r=JohnTitor REVERT: 8a9d351ba29 Add #[must_use] to expensive computations REVERT: bd5e9bff9ad Auto merge of #89774 - the8472:inline-mut-iter-next, r=m-ou-se REVERT: a266a9f5560 Add #[must_use] to Rc::downgrade REVERT: 4f231b7e10f Merge branch 'master' into is-symlink-stabilization REVERT: 4a711779606 Make split_inclusive() on an empty slice yield an empty output REVERT: badab4efd0f Update library/std/src/thread/mod.rs REVERT: 3a5badf01ad Add #[inline] to int log10 functions. REVERT: bccd749f6f5 Remove potentially unsound note on reconstructing a leaked Vec. REVERT: 7c981fb1dcc Fix uppercase/lowercase error REVERT: 93e67371575 Rollup merge of #89799 - ast-ral:ready-method-spellck, r=joshtriplett REVERT: f9c8763cc24 Rollup merge of #89797 - jkugelman:must-use-is_condition-tests, r=joshtriplett REVERT: c9797d26246 Rollup merge of #89796 - jkugelman:must-use-non-mutating-verb-methods, r=joshtriplett REVERT: cb12bfe0f40 Rollup merge of #89778 - jkugelman:must-use-as_type-conversions, r=joshtriplett REVERT: a759dc995ca Mention Rust version in Vec::leak docs. REVERT: c134552ffd2 Auto merge of #89770 - jkugelman:must-use-from-and-into, r=joshtriplett REVERT: 2aaf7a1f316 Auto merge of #89769 - jkugelman:must-use-maybe-uninit-new, r=joshtriplett REVERT: 5e383ea3e26 Add const_eval_select intrinsic REVERT: 4f6ef9d6521 Update library/std/src/path.rs REVERT: 256a35d23eb fix minor spelling error in Poll::ready docs REVERT: 84fbd813cf6 Auto merge of #88788 - falk-hueffner:speedup-int-log10-branchless, r=joshtriplett REVERT: fb5d8edf50d Add #[must_use] to non-mutating verb methods REVERT: d6aa7be0b1b Add #[must_use] to is_condition tests REVERT: 2a28a815b29 Add #[must_use] to to_value conversions REVERT: 3ae48447d17 Add #[must_use] to From::from and Into::into REVERT: bac391a08c5 Rollup merge of #89785 - nbdd0121:master, r=Mark-Simulacrum REVERT: 913611d9339 Rollup merge of #89651 - ibraheemdev:poll-ready, r=dtolnay REVERT: af5455ae586 use fold instead of try_fold now that .by_ref().next() has been inlined REVERT: 9834f226884 Add #[must_use] to thread::Builder REVERT: bb7fc096c42 add slice::swap tests REVERT: a262b23aad2 improve slice::swap panic message REVERT: 810e495d8d3 use `swap_unchecked` in `slice::reverse` REVERT: 00fc9fa0702 enable `slice_swap_unchecked` feature in doc test REVERT: ae22d882f1b add `slice::swap_unchecked` REVERT: f33a1d102d7 Fix ICE 89775 REVERT: a0b24c9d6f1 Add missing words in `Infallible` docs REVERT: d04ae9dd01b Add library tracking issue for poll_ready feature REVERT: 6055544ea6b Update library/core/src/mem/maybe_uninit.rs REVERT: 43b3c535afe Add #[must_use] to as_type conversions REVERT: c83f61a418a Auto merge of #83908 - Flying-Toast:master, r=davidtwco REVERT: 33b21460d7a inline next() on &mut Iterator impl REVERT: 83055b76589 Auto merge of #89767 - GuillaumeGomez:rollup-sczixhk, r=GuillaumeGomez REVERT: 153838568ae Add #[must_use] to MaybeUninit::new REVERT: eeb32941efc Rollup merge of #89753 - jkugelman:must-use-from_value-conversions, r=joshtriplett REVERT: a734bf24eb2 Rollup merge of #89729 - jkugelman:must-use-core-std-constructors, r=joshtriplett REVERT: a45b27a5214 Rollup merge of #89726 - jkugelman:must-use-alloc-constructors, r=joshtriplett REVERT: c8a8823b373 Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov REVERT: 8b391d39157 Add enum_intrinsics_non_enums lint REVERT: 3928a4963ea Auto merge of #89755 - jkugelman:must-use-conversions-that-move-self, r=joshtriplett REVERT: 2c8ca0e4098 Add #[must_use] to conversions that move self REVERT: 6fb91ae488a Add #[must_use] to from_value conversions REVERT: 4cd578d206b Rollup merge of #89707 - clemenswasser:apply_clippy_suggestions, r=Mark-Simulacrum REVERT: 31a17e8c8e7 Mark `Arc::from_inner` / `Rc::from_inner` as unsafe REVERT: a6252379136 integrate I/O safety changes REVERT: fdf3a750406 cross-platform doctests REVERT: a41c3cbc7c8 moves use ptr within from_abstract_namespace fn REVERT: 1afe6182e7e Update tracking issue in stability refs REVERT: 31f3e6edda2 rustfmt REVERT: de9a9259711 Add abstract namespace support for Unix domain sockets REVERT: dd5eaff4931 Rollup merge of #89735 - bjorn3:stabilize_proc_macro_is_available, r=petrochenkov REVERT: 1f5fe209a75 Rollup merge of #89720 - jkugelman:must-use-math-operations, r=joshtriplett REVERT: 0a3b661b831 Rollup merge of #89719 - jkugelman:must-use-char-escape-methods, r=joshtriplett REVERT: f5e68edc952 Rollup merge of #89718 - jkugelman:must-use-is_condition-tests, r=joshtriplett REVERT: 52861e0230a Rollup merge of #89705 - nbdd0121:doc, r=GuillaumeGomez REVERT: 52e21a0fb01 Rollup merge of #89438 - pierwill:prefix-free-hash, r=Amanieu REVERT: e8f39699620 Rollup merge of #88713 - falk-hueffner:int-log10-documentation-fixes, r=scottmcm REVERT: d65dea49e99 Rollup merge of #88374 - joshlf:patch-2, r=JohnTitor REVERT: c1ed81ab603 Merge branch 'rust-lang:master' into must-use-alloc-constructors REVERT: 7eb30afc611 Apply clippy suggestions REVERT: aff1592856b Auto merge of #89219 - nickkuk:str_split_once_get_unchecked, r=Mark-Simulacrum REVERT: a94296e72e9 Stabilize proc_macro::is_available REVERT: 88e6cb5d50b Update core primitives_docs.rs up to date with std REVERT: 8c845553461 Update library/std/src/primitive_docs.rs REVERT: 6f961b34c4c Makes docs for references a little less confusing REVERT: a9af2efe8ef Auto merge of #88952 - skrap:add-armv7-uclibc, r=nagisa REVERT: e87aa650f15 Add #[must_use] to core and std constructors REVERT: 08e2ce30837 Add #[must_use] to alloc constructors REVERT: ea2c24177e0 Add #[must_use] to math and bit manipulation methods REVERT: 2edf53877b7 Add #[must_use] to char escape methods REVERT: 69065bce504 Add #[must_use] to is_condition tests REVERT: 984d132e120 Update library/core/src/hash/mod.rs REVERT: 1f8beb4da0b Apply clippy suggestions REVERT: fefbd7e6c65 Cfg hide no_global_oom_handling and no_fp_fmt_parse REVERT: ef8a672c0a7 Rollup merge of #89664 - timClicks:51430-document-boxed-conversions, r=m-ou-se REVERT: bc56bc6534d Rollup merge of #89614 - cuviper:unicode-14, r=joshtriplett REVERT: 2eccffc707c Rollup merge of #88436 - lf-:stabilize-command-access, r=yaahc REVERT: e9b6c73a333 Rollup merge of #87528 - :stack_overflow_obsd, r=joshtriplett REVERT: c952bcf1610 Rollup merge of #75644 - c410-f3r:array, r=yaahc REVERT: 77b68c6bfa1 Rollup merge of #89694 - jkugelman:must-use-string-transforms, r=joshtriplett REVERT: f3bc5fc68ad Rollup merge of #89693 - jkugelman:must-use-stdin-stdout-stderr-locks, r=joshtriplett REVERT: 2699e228b12 Rollup merge of #89678 - marcelo-gonzalez:master, r=joshtriplett REVERT: d15e65576eb Rollup merge of #88707 - sylvestre:split_example, r=yaahc REVERT: a3acaca208a Remove unnecessary hyphen REVERT: fedc5b0b50e Simplify wording REVERT: b2f7d86a83c Update library/core/src/num/mod.rs REVERT: 0ce8b661b13 Auto merge of #89582 - jkugelman:optimize-file-read-to-end, r=joshtriplett REVERT: 89180b98891 Add #[must_use] to string/char transformation methods REVERT: 827bfe7bf03 Add #[must_use] to stdin/stdout/stderr locks REVERT: a28b3c6a5d2 Fix minor std::thread documentation typo REVERT: e409cb0981e Stabilize `is_symlink()` for `Metadata` and `Path` REVERT: 95bb228b3ef Cfg hide more conditions for alloc REVERT: 5b97f97aa3c Cfg hide more conditions for core REVERT: e1efa73f003 Let stack_overflow::imp::cleanup call drop_handler directly REVERT: d3f54567f26 Also cfg flag auxiliar function REVERT: d342913fe14 Add documentation to boxed conversions REVERT: 10eaa0d0d00 Rollup merge of #89622 - m-ou-se:debug-assert-2021, r=estebank REVERT: 143dd75f53b Rollup merge of #89082 - smoelius:master, r=kennytm REVERT: 86fc0575150 Rollup merge of #88772 - orlp:result-map-or-else-docfix, r=yaahc REVERT: cbd5877a80a Auto merge of #89638 - rust-lang:revert-88548-intersperse, r=Mark-Simulacrum REVERT: 923bc1adf94 revert stabilization of `core::task::ready!` REVERT: af9e242b17a Optimize File::read_to_end and read_to_string REVERT: eae22a8d038 add `Poll::ready` REVERT: 7c10ced2601 environ on macos uses directly libc which has the correct signature. REVERT: f421ff46fd6 Revert "Stabilize `Iterator::intersperse()`" REVERT: 435bab7d6bd Rollup merge of #89596 - GuillaumeGomez:implicit-doc-cfg, r=jyn514 REVERT: c714233b789 Use correct edition for panic in [debug_]assert!() etc. REVERT: c88e64bc90d doc: guarantee call order for sort_by_cached_key REVERT: 53ab6bdc79a Regenerate tables for Unicode 14.0.0 REVERT: 82ac8a872a8 Rollup merge of #89531 - devnexen:stack_overflow_bsd_libc_upd, r=dtolnay REVERT: 6ca66c5fa43 Rollup merge of #89324 - yoshuawuyts:hardware-parallelism, r=m-ou-se REVERT: 901aee02e9a Rollup merge of #89245 - DeveloperC286:iter_mut_fields_to_private, r=joshtriplett REVERT: b17ce839bd9 Rollup merge of #89050 - DeveloperC286:drain_fields_to_private, r=joshtriplett REVERT: 53b2d99cd88 Rollup merge of #88523 - kpreid:category, r=yaahc REVERT: eaed836131a Rollup merge of #87601 - a1phyr:feature_uint_add_signed, r=kennytm REVERT: f70447271b3 Clean up code a bit: REVERT: 3a3d986392a Update libc to 0.2.103. REVERT: 23970bc1254 add platform support details file for armv7-unknown-linux-uclibc REVERT: 5a172b3a714 Add new target armv7-unknown-linux-uclibceabihf REVERT: f0be59343b1 Rebase Result::map_or_else doc wording on top of #89400. REVERT: f10a1731960 Apply suggestions from code review REVERT: 15047974414 Apply suggestions from code review REVERT: 971d9e11a74 Document the valid values for `HandleOrNull` and `HandleOrInvalid`. REVERT: 9d91d1d71a1 Fix compilation on WASI, which doesn't yet support `dup`. REVERT: 2d7a5aaf9a1 Rollup merge of #89502 - FabianWolff:issue-89493, r=joshtriplett REVERT: 5c0dcbbf517 Rollup merge of #89351 - tspiteri:wrapping_rem, r=dtolnay REVERT: 759e37b157a Rollup merge of #88828 - FabianWolff:issue-88585, r=dtolnay REVERT: 3904247a65b refactor: VecDeques IterMut fields to private REVERT: a437136bc53 refactor: VecDeques Drain fields to private REVERT: d65cd1fd8f5 Suppress some cfg from being shown in the stdlib docs REVERT: ebed464bf34 for signed overflowing remainder, delay comparing lhs with MIN REVERT: 2ad9d221fb9 Use get_unchecked in str::[r]split_once REVERT: 752d58d6a34 Rollup merge of #89462 - devnexen:haiku_thread_aff_build_fix, r=nagisa REVERT: 8393d004df9 Rollup merge of #89244 - DeveloperC286:pair_slices_fields_to_private, r=joshtriplett REVERT: 9a61c58e62d Rollup merge of #88651 - AGSaidi:monotonize-inner-64b-aarch64, r=dtolnay REVERT: c3cf85bb4f9 Rollup merge of #87631 - :solarish_upd_fs, r=joshtriplett REVERT: fa1e49964b8 library std, libc dependency update REVERT: df2380c1bcd Rollup merge of #89413 - matthewjasper:spec-marker-fix, r=nikomatsakis REVERT: e33a2331597 Rollup merge of #89270 - seanyoung:join_fold, r=m-ou-se REVERT: 11f71d13d4c Rollup merge of #88780 - orlp:int-abs-diff, r=m-ou-se REVERT: b615ac965a2 Rollup merge of #87993 - kornelski:try_reserve_stable, r=joshtriplett REVERT: 81c723331c1 Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett REVERT: c0c18f189c0 Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebank REVERT: b05ee0bee3a Rollup merge of #89443 - cuviper:btree-hash-len, r=dtolnay REVERT: 99b439e1892 Rollup merge of #89400 - Nitepone:nitepone/map-or-else-docfix, r=dtolnay REVERT: 9424167a7a3 Rollup merge of #88452 - xu-cheng:vecdeque-from-array, r=m-ou-se REVERT: 00b4b8e4db6 Rollup merge of #87091 - the8472:more-advance-by-impls, r=joshtriplett REVERT: a9aec89e04d Optimize `saturating_add_signed` REVERT: eb30d7e9af5 Auto merge of #88834 - the8472:char-count, r=joshtriplett REVERT: 3f25e449c9d Stabilize try_reserve REVERT: 1f5bbf27d2b Add doc aliases to `std::thread::available_parallelism` REVERT: 6b10b0dbe8c Auto merge of #89512 - Manishearth:rollup-meh9x7r, r=Manishearth REVERT: b151ff05784 Stabilize `const_panic` REVERT: 030c85c9347 Rollup merge of #89472 - nagisa:nagisa/wsa-cleanup, r=dtolnay REVERT: 8c01d0daac1 Rollup merge of #89401 - owengage:master, r=joshtriplett REVERT: 96326967987 Rollup merge of #89138 - newpavlov:patch-2, r=dtolnay REVERT: c2725c701b8 Rollup merge of #88370 - Seppel3210:master, r=dtolnay REVERT: a7b051d11d1 Rollup merge of #88353 - jhpratt:stabilize-array-as-ref, r=joshtriplett REVERT: b216324dd33 Rollup merge of #88305 - ijackson:exitstatus-debug, r=dtolnay REVERT: a8d7fee3c9c Rollup merge of #88286 - LeSeulArtichaut:unnecessary-unsafe-block-std, r=dtolnay REVERT: b526988da78 Rollup merge of #87910 - iago-lito:mark_unsafe_nonzero_arithmetics_as_const, r=joshtriplett REVERT: 32f3a629dc8 Rollup merge of #87679 - ssomers:btree_comments, r=joshtriplett REVERT: fca7003b293 Rollup merge of #86828 - lambinoo:67441-const-fn-copied-take-replace, r=joshtriplett REVERT: 1edbbd7d277 Rollup merge of #86434 - CDirkx:ipv6-benchmarking, r=joshtriplett REVERT: 276d5d4f828 Stabilize `unreachable_unchecked` as `const fn` REVERT: 2290b7f735b Auto merge of #89165 - jkugelman:read-to-end-overallocation, r=joshtriplett REVERT: 2a0df4eb096 Add `#[repr(i8)]` to `Ordering` REVERT: 6387167bb8e Use a test value that doesn't depend on the handling of even/odd rounding REVERT: 828e42ca530 Fix Lower/UpperExp formatting for integers and precision zero REVERT: b7ce04efd94 Revert suggested use of `unwrap_or` REVERT: b1868adeb19 Apply suggestions REVERT: 9b759d3646b Automatically convert paths to verbatim REVERT: b6b9d210ddc Re-export io::stdio::cleanup instead of wrap it REVERT: 40be92a79bd Use rtabort! instead of rtprintpanic! + abort_internal REVERT: afa84189b0f Update outdated comment REVERT: 3290eb68f78 Auto merge of #88086 - ssomers:btree_clone_testing, r=dtolnay REVERT: 6b9ab796f72 Added tracking issue numbers for int_abs_diff. REVERT: 38c4db34ede Skip platforms without unwinding support REVERT: 3b66e2a90f8 Auto merge of #87870 - WaffleLapkin:pub_split_at_unchecked, r=dtolnay REVERT: 909ef8f1d34 Auto merge of #89459 - tspiteri:idiv-overflow-bitand, r=kennytm REVERT: 9c8ce0291d9 Practice diagnostic message convention REVERT: 93ae74e847d Auto merge of #88060 - TennyZhuang:optimize-vec-retain, r=dtolnay REVERT: 96ff04163e9 Make diangostic item names consistent REVERT: 20fc42d6086 Run the #85441 regression test on MSVC only REVERT: 0182d17be5c Only register `WSACleanup` if `WSAStartup` is actually ever called REVERT: 1bbf3e40cf1 haiku thread affinity build fix REVERT: b08bebdf8fa Fix typo and change a word in ControlFlow docs REVERT: 1a0b7627466 Use bitand when checking for signed integer division overflow REVERT: 00034132792 Auto merge of #89450 - usbalbin:const_try_revert, r=oli-obk REVERT: 7224b68e1fa Revert "Auto merge of #86853 - usbalbin:const_try, r=oli-obk" REVERT: ddddce39a23 Add paragraph to ControlFlow docs to menion it works with the ? operator (#88715) REVERT: c519252bfa9 Include the length in BTree hashes REVERT: 716de68869c Call `libc::sigaction()` only on Android REVERT: e827d09b4a1 path.push() should work as expected on windows verbatim paths REVERT: 5e3d458e1a4 fix: edit description of "prefix-free" REVERT: 30d2515de0d Clarify a sentence in the documentation of Vec (#84488) REVERT: c9120317fe7 docs: `std::hash::Hash` should ensure prefix-free data REVERT: 3e7e60bf3ca Add methods to add/sub `uX` to/from `iX` REVERT: 2f5cf0e21ca Fix doc test REVERT: 8e30d7a9bd4 Apply suggestion for `overflowing_add_signed` REVERT: 3aa6f179120 Add functions to add unsigned and signed integers REVERT: 985909aecfe Fix ctrl-c causing reads of stdin to return empty on Windows. REVERT: e1422552c6c Auto merge of #89403 - camsteffen:fmt-unsafe-private, r=Mark-Simulacrum REVERT: 62ec3e681a2 Rollup merge of #89306 - devnexen:haiku_ncpus, r=nagisa REVERT: c821ea3fecc Rollup merge of #89303 - guswynn:std_suspend, r=dtolnay REVERT: bca70733e41 Fix standard library for min_specialization changes REVERT: fe5dc60ebb6 fix issues pointed out in review REVERT: fcc9b503b4d from review: code style REVERT: 4634631d4a8 implement advance_(back_)_by on more iterators REVERT: 631509ef176 Add private arg to fmt::UnsafeArg REVERT: 0bc0594af8f Check `allow_unstable` before checking environment variables REVERT: 16b95d74f62 Add truncate note to Vec::resize REVERT: 88f155b58ad Improve wording of `map_or_else` docs REVERT: d73c989fc7c Remove an unnecessary use of unwrap_unchecked REVERT: 9c0000f5ebf Improve previous commit REVERT: 7b755d04d02 Use reference instead of raw pointer REVERT: 772ac2d7d89 Add 'core::array::from_fn' and 'core::array::try_from_fn' REVERT: 4c4e1d122f6 Auto merge of #86853 - usbalbin:const_try, r=oli-obk REVERT: 0fb65f07cbd Rollup merge of #89335 - mbrubeck:range-is-sorted, r=cuviper REVERT: e17e12e7cad Rollup merge of #89315 - et342:cstr_from_vec_unchecked_doc, r=yaahc REVERT: a29f16213ed Rollup merge of #88412 - mdsn:slice-sort-safety, r=dtolnay REVERT: 685c04d4f4c Add tests REVERT: 7c3346a463e Implement #85440 REVERT: ac9d1e77bc9 Auto merge of #89011 - bjorn3:restructure_rt, r=dtolnay REVERT: f2bee6f0c4c Clean up unneeded explicit pointer cast REVERT: ad08179657b ref/refmut REVERT: b256c130019 Additional docs about Vec::leak behavior REVERT: addfafee87e Avoid allocations and copying in Vec::leak REVERT: 6846ad9eb29 Optimize is_sorted for Range and RangeInclusive REVERT: d4d72597477 Rollup merge of #89235 - yaahc:junit-formatting, r=kennytm REVERT: 4d17e5daba3 Rename `std::thread::available_onccurrency` to `std::thread::available_parallelism` REVERT: 067cb8ae5c9 Auto merge of #86191 - kawadakk:release-add-solid-support, r=nagisa,estebank,m-ou-se, REVERT: 78e64e9c69b Add SOLID targets REVERT: bc6f3952fcf Clarify that `CString::from_vec_unchecked` appends 0 byte. REVERT: 092a8b24763 Apply suggestions from code review REVERT: 0f776925f48 thread: implements available_concurrency on haiku REVERT: 3d28789dde4 lock types REVERT: faa9ded856f Auto merge of #89145 - rusticstuff:bump_stdarch, r=kennytm REVERT: f6022a107e4 Auto merge of #89144 - sexxi-goose:insig_stdlib, r=nikomatsakis REVERT: c35d9b15961 Rollup merge of #89216 - r00ster91:bigo, r=dtolnay REVERT: f96a3c430b6 Rollup merge of #89010 - est31:intra_doc_links, r=m-ou-se REVERT: c21079895cd Rollup merge of #88973 - lu-zero:std_detect-env_override, r=Amanieu REVERT: eed54a5b516 Auto merge of #88343 - steffahn:fix_code_spacing, r=jyn514 REVERT: 0253909a477 Expose the std_detect env_override feature REVERT: 94c0224f0b5 Apply 16 commits (squashed) REVERT: 76e76a56d80 refactor: VecDeques PairSlices fields to private REVERT: 42cc9e039fc Auto merge of #89030 - nbdd0121:box2, r=jonas-schievink REVERT: cf6f6345d53 Use Rvalue::ShallowInitBox for box expression REVERT: 2aa12e65a01 make junit output more consistent with default format REVERT: 129519c38c4 Rollup merge of #89210 - Takashiidobe:master, r=kennytm REVERT: b9433fcb1ad Auto merge of #88999 - Migi:master, r=oli-obk REVERT: c9782dbd51e unitalicize O(1) complexities REVERT: e8395cb93ce Merge branch 'rust-lang:master' into master REVERT: 79447fd1114 consistent big O notation REVERT: 631f7675235 Rollup merge of #89184 - joshtriplett:master, r=estebank REVERT: 0de76ef36de Rollup merge of #88612 - lovasoa:patch-1, r=m-ou-se REVERT: 5b674c3bf31 remove trailing whitespace REVERT: 61021a00c42 Add time complexities to linked_list.rs REVERT: 181cf0f8a95 Auto merge of #88587 - bdbai:fix/uwpio, r=joshtriplett REVERT: 3389662143c Auto merge of #89139 - camsteffen:write-perf, r=Mark-Simulacrum REVERT: 8734bc156a4 Reason safety for unsafe blocks for uwp stdin REVERT: 95a1f95fc3c Temporarily rename int_roundings functions to avoid conflicts REVERT: 8117ec4f7dc Update library/std/src/sync/mpsc/shared.rs REVERT: 2e9a8d7d980 Rollup merge of #89036 - nbdd0121:alloc, r=yaahc REVERT: cde47476598 PR fixup REVERT: 6a638101461 Fix read_to_end to not grow an exact size buffer REVERT: 1286e803623 Rollup merge of #89141 - mbartlett21:patch-2, r=kennytm REVERT: 639c23174b9 Rollup merge of #89114 - dequbed:c-char, r=yaahc REVERT: bfa7e257200 Rollup merge of #89086 - WaffleLapkin:stabilize_iter_map_while, r=kennytm REVERT: 88a8f950da1 Rollup merge of #89015 - klensy:escape-def, r=Mark-Simulacrum REVERT: c99abdb9b19 Use ZST for fmt unsafety REVERT: 4cf5860aae1 Re-export FromSecsError from `std` REVERT: ea69a014a2c Update stdarch submodule REVERT: e958b9d0023 2229: Annotate stdlib with insignficant dtors REVERT: 352bc49d4f3 Impl `Error` for `FromSecsError` without foreign type REVERT: 966ef72c203 Fix link in Ipv6Addr::to_ipv4 docs REVERT: 90ed3c4182e Mark unsafe NonZero*::unchecked_(add|mul) as const REVERT: a283855adc2 Auto merge of #88321 - glaubitz:m68k-linux, r=wesleywiser REVERT: fa8161e2d26 Fix a technicality regarding the size of C's `char` type REVERT: b9c6075cc54 Auto merge of #89089 - JohnTitor:rollup-6s6mccx, r=JohnTitor REVERT: 247a367f5ab Rollup merge of #89081 - ondra05:patch-1, r=dtolnay REVERT: aee72a56451 Rollup merge of #89053 - DeveloperC286:into_iter_fields_to_private, r=Mark-Simulacrum REVERT: dae1b0876e0 Rollup merge of #89051 - schctl:master, r=jyn514 REVERT: 606dc61fcf3 Rollup merge of #89017 - the8472:fix-u64-time-monotonizer, r=kennytm REVERT: c7e40ba5e08 Auto merge of #89031 - the8472:outline-once-cell-init-closure, r=Mark-Simulacrum REVERT: 5293be8a328 Fix typo REVERT: e397978d6b5 EscapeDefault: change `range` field to `Range`, reducing struct size 24 -> 6 bytes REVERT: 87cb56a7506 Auto merge of #88988 - Mark-Simulacrum:avoid-into-ok, r=nagisa REVERT: b8360f00046 refactor: VecDeques IntoIter fields to private REVERT: 7082d0f5d1c modify std::os docs to be more consistent REVERT: b329dd38268 use AtomicU64::fetch_update instead of handrolled RMW-loop REVERT: 93c4e5122a9 Stabilize `Iterator::map_while` REVERT: fb4329ac543 Rollup merge of #88954 - nbdd0121:panic3, r=oli-obk REVERT: 691f564be24 Rollup merge of #88953 - joshtriplett:chown, r=dtolnay REVERT: e7ee499490e library/std/env: Add 'm68k' to comment on ARCH constant REVERT: 3ee7a20af5d libstd: Add m68k for raw type definitions on Linux REVERT: bd6ebd17b3f Rollup merge of #88887 - fee1-dead:const-deref, r=oli-obk REVERT: 11e89f1cb7b Rollup merge of #88339 - piegamesde:master, r=joshtriplett REVERT: 9f9faa5ec03 Fix missing `no_global_oom_handling` cfg-gating REVERT: 7135c88fdf1 Don't inline OnceCell initialization closures REVERT: daf10c2fcc2 Optimize unnecessary check in Vec::retain REVERT: 2dd0665ec81 Add benchmark for Vec::retain REVERT: 6c7e47dde7b Rollup merge of #89009 - tatami4:master, r=Mark-Simulacrum REVERT: 31e31f64dc5 Rollup merge of #88986 - hargoniX:master, r=Mark-Simulacrum REVERT: 37272e939e3 Rollup merge of #88976 - notriddle:notriddle/cow-from-cstr-docs, r=Mark-Simulacrum REVERT: fcb4688e198 Rollup merge of #88928 - lefth:master, r=Mark-Simulacrum REVERT: c49af7efffd fix potential race in AtomicU64 time monotonizer REVERT: dc7b7074a0b Rustfmt REVERT: f38d47fe2be Merge two THREAD_INFO.with and following RefCell borrow REVERT: dbfa0f25d84 Replace a couple of asserts with rtassert! in rt code REVERT: 22f3f44cab5 Remove unused function REVERT: 5b3ef57621f Use const {} for the THREAD_INFO thread local REVERT: 33bab4e0be2 Optimize ThreadInfo::with REVERT: 5087bbda2b3 Remove an allocation from rt::init REVERT: c2ae5115586 Merge sys_common::rt into rt REVERT: 0109696c365 Add IntoIterator intra doc link to various collections REVERT: 9b4b3af0c96 Fix typo in `break` docs REVERT: a1b4c475e8b Add intra-doc-links to BinaryHeap rustdoc REVERT: 47341e84c0f Add intra-doc-links to LinkedList rustdoc REVERT: 7e049f3f95e Avoid codegen for Result::into_ok in lang_start REVERT: 1b459183f48 Make Duration's Debug format pad to width REVERT: 7e5e466124c Rollup merge of #88915 - joshlf:patch-4, r=kennytm REVERT: 796d072b7d7 Allow `panic!("{}", computed_str)` in const fn. REVERT: 9eea3ee78e5 Add tracking issue for unix_chown REVERT: b4acba3dbf2 Update the backtrace crate REVERT: 9a174353b80 docs(std): add docs for cof_from_cstr impls REVERT: 89015f260d9 Fix formatting REVERT: a759f3be9d6 Add tracking issue REVERT: 6a26ffc47d6 Updated for new const trait bounds syntax REVERT: e00c299715f Move tests to library/core/tests REVERT: 35503264480 Constly impl TryV2 and Residual for Option REVERT: f5ce93a14af Constly impl TryV2 and FromResidual for Result REVERT: 4d1ba13d636 Constify identify conversions REVERT: add283872c9 Auto merge of #88619 - GuillaumeGomez:simplify-std-os-reexports, r=Amanieu REVERT: bbdd4a8dc7d Const Deref REVERT: 78c2d4fea17 Add chown functions to std::os::unix::fs to change the owner and group of files REVERT: d1736d3e93f Document the closure arguments for `reduce`. REVERT: 1adc2abb747 `Wrapping` has the same layout and ABI as `T` REVERT: fe14a77a6f2 Rollup merge of #88722 - WaffleLapkin:unsafe_cell_const_get_mut, r=dtolnay REVERT: cfd4d84b745 Move fortanix module position in std::os reexports for alpha sort REVERT: 78dfc5f4e5f Remove usage of cfg_if in std/src/os/mod.rs REVERT: 98ce089f572 Simplify std::os module reexports to fix rustdoc linking issues REVERT: 58e1a23ad67 Fix linkcheck issues REVERT: ec8bb8ad997 Add primitive documentation to libcore REVERT: 8c1c4bc4025 Allow reverse iteration of lowercase'd/uppercase'd chars REVERT: c8451af06cd Rollup merge of #88849 - matthiaskrgr:clony_on_copy, r=petrochenkov REVERT: bc3483b6436 Rollup merge of #87904 - kpreid:unsize, r=jyn514 REVERT: ebf96758160 manually inline function REVERT: b6f5fe46096 don't clone types that are Copy (clippy::clone_on_copy) REVERT: c3d4654d65f optimization continuation byte validation of strings containing multibyte chars REVERT: df48803d81f optimize utf8_is_cont_byte() to speed up str.chars().count() REVERT: d7777a4785d benchmark for str.chars().count() REVERT: a45803537c8 Fill in the tracking issue for `#![feature(const_unsafecell_get_mut)]` REVERT: 0ca161b58d0 Use `libc::sigaction()` instead of `sys::signal()` to prevent a deadlock REVERT: ae2e101a40f Rollup merge of #88807 - jruderman:which_reverses, r=joshtriplett REVERT: 00cc7b755f5 Rollup merge of #88667 - kraktus:patch-1, r=dtolnay REVERT: 79f51dc2907 Rollup merge of #86165 - m-ou-se:proc-macro-span-shrink, r=dtolnay REVERT: 64b7d26123f Fix typo in docs for iterators REVERT: a36eda29946 Run fmt REVERT: dbbfc5e1424 Clarification of default socket flags used by Rust REVERT: 4982a13789f Fix Windows compilation errors. REVERT: 54dac98df52 Fix another Windows compilation error. REVERT: 9e27ac0edab Fix more Windows compilation errors. REVERT: c838c0f51f8 Fix assertion failures in `OwnedHandle` with `windows_subsystem`. REVERT: 8486fa3fb18 Fix Windows compilation errors. REVERT: b04b0d6986f Add a `try_clone()` function to `OwnedFd`. REVERT: f5b72a868d6 Added psadbw support for u8::abs_diff. REVERT: e01f88a6716 remove unnecessary bound on Zip specialization impl REVERT: f3d4a3eeb79 Cosmetic fixes. REVERT: 26fbaa71f95 Ignore automatically derived impls of `Clone` and `Debug` in dead code analysis REVERT: fb73c8fed23 Speed up integer log10. REVERT: 53403f14ae9 Added abs_diff for integer types. REVERT: 414598755b8 Bump stage0 compiler to 1.56 REVERT: a4fec388494 Rollup merge of #88712 - jhpratt:fix-int_rounding-docs, r=joshtriplett REVERT: ed611a7af89 Rollup merge of #88648 - kpreid:option, r=Mark-Simulacrum REVERT: c1bd82dd218 Rollup merge of #88594 - steffahn:more_symbolic_doc_aliases, r=joshtriplett REVERT: 6e8bbc9af72 Auto merge of #86943 - ptrojahn:suggest_derive, r=estebank REVERT: ddd5c5f077f rearrange to be panic safe REVERT: 0f8ae2d1369 Make `UnsafeCell::get_mut` const REVERT: 6266e5e3042 Optimize VecDeque::append REVERT: 1b88ef7417d Improve docs for int_log REVERT: 950b869a62b Fix docs for `uX::checked_next_multiple_of` REVERT: c5445becd8b Auto merge of #88448 - xu-cheng:btree-blk-build, r=Mark-Simulacrum REVERT: f6545bb0bbb String.split_terminator: Add an example when using a slice of chars REVERT: c84c4122a9e Suggest deriving traits if possible REVERT: 9aa5a7a2921 Rollup merge of #88673 - Qwaz:node-typo, r=jyn514 REVERT: 5744dac13ee Rollup merge of #88647 - ChrisDenton:win-symlink-docs, r=joshtriplett REVERT: 91478e70e68 Add benchmark for integer log10. REVERT: f45dac6177f rust fmt REVERT: 1ded5f8ccd5 Fix typo: needede -> needed REVERT: bc70c1eb350 Mention usage of `const` in raw pointer types at the top of the keyword's documentation page. REVERT: 5e7d702c7e9 Additional aliases for pointers REVERT: 46d3eb52cdf Tweak `write_fmt` doc. REVERT: d9ac40d4283 Change return type for T::{log,log2,log10} to u32. The value is at most 128, and this is consistent with using u32 for small values elsewhere (e.g. BITS, count_ones, leading_zeros). REVERT: 03cd78cc185 Rollup merge of #88432 - terrarier2111:patch-1, r=joshtriplett REVERT: 9ae75eca1d7 Auto merge of #88469 - patrick-gu:master, r=dtolnay REVERT: 132c4daf84f linux/aarch64 Now() should be actually_monotonic() REVERT: 6bcdc645152 Use the 64b inner:monotonize() implementation not the 128b one for aarch64 REVERT: 529b928ee48 Clarify what “a container” is in `FromIterator> for Option` doc. REVERT: e840bc7b216 Add sentence punctuation and links in `Option` docs. REVERT: fd94225e594 “Moves” instead of “copies” in ` as From>::from` doc. REVERT: a48b433e103 Document when to use Windows' `symlink_dir` vs. `symlink_file` REVERT: 804a31b0d0f Fix accidentally deleted part REVERT: f06c097f744 Add a missing backtick REVERT: 9853438a35e Remove excessive linking REVERT: f8e1eea5fbc simplify `impl Termination for Result` REVERT: a5ab04d19df Rollup merge of #88613 - m-ou-se:array-docs-2021, r=Amanieu REVERT: 8531864b797 Rollup merge of #88610 - m-ou-se:array-into-iter-docs, r=Amanieu REVERT: 2e1d4ce7e5a Rollup merge of #88579 - ast-ral:master, r=m-ou-se REVERT: 6c0cec2aa58 Rollup merge of #88507 - atsuzaki:slice-fill-maybeuninit-test, r=RalfJung REVERT: 15b2070945c Rollup merge of #88202 - azdavis:master, r=jyn514 REVERT: 5f300c8a143 Update primitive docs for rust 2021. REVERT: cbcb31044cb Add a better error message for #39364 REVERT: 8f3fe8f0797 Update outdated docs of array::IntoIter::new. REVERT: 6380087c660 implement `Termination` for `Result` REVERT: d3b6c59e345 Auto merge of #88596 - m-ou-se:rollup-cidzt4v, r=m-ou-se REVERT: 6e7f0e3121d Rollup merge of #88582 - jhpratt:int_roundings, r=joshtriplett REVERT: 1fa816ba4c6 Rollup merge of #88560 - klensy:formatter-pad-shrink, r=m-ou-se REVERT: 74deb979d98 Rollup merge of #88505 - ibraheemdev:use-unwrap-unchecked, r=kennytm REVERT: 47fe8ccaa1c Rollup merge of #88177 - joshtriplett:stabilize-chroot, r=m-ou-se REVERT: f65fba826e4 Auto merge of #87580 - ChrisDenton:win-arg-parse-2008, r=m-ou-se REVERT: 30fdc360035 Consistent placement of doc alias for primitives below the `doc(primitive…)` REVERT: 0f881f55482 Add "!" doc alias for `std::ops::Not` REVERT: 14f9893eb1e I/O safety for WinUWP REVERT: df5487b4332 Implement #88581 REVERT: d2bcf9ff2db remove redundant / misplaced sentence from docs REVERT: d978af01701 Auto merge of #83342 - Count-Count:win-console-incomplete-utf8, r=m-ou-se REVERT: 7b0dfc67e12 fix clippy lints REVERT: b4959cef44b `fmt::Formatter::pad`: don't call chars().count() more than one time REVERT: 4d1931acfb1 Rollup merge of #88551 - inquisitivecrystal:unsafe_cell_raw_get, r=m-ou-se REVERT: 582405d4614 Rollup merge of #88548 - inquisitivecrystal:intersperse, r=m-ou-se REVERT: 95c656870b0 Rollup merge of #88542 - tavianator:readdir_r-errno, r=jyn514 REVERT: 7a7ceebedf5 Rollup merge of #88040 - nbdd0121:btreemap, r=m-ou-se REVERT: a9c7d61bb9a Add a few tests for `UnsafeCell` REVERT: d7d1056d9e7 Stabilize `Iterator::intersperse()` REVERT: 89dfd0b77f4 Stabilize `UnsafeCell::raw_get()` REVERT: be4badb9554 Use the return value of readdir_r() instead of errno REVERT: a4899a37ffc Rollup merge of #88524 - soenkehahn:master, r=jyn514 REVERT: 59959ed2b89 Rollup merge of #88495 - ibraheemdev:tcp-linger, r=joshtriplett REVERT: cab64f91cd1 Rollup merge of #85017 - clarfonthey:carrying_widening, r=m-ou-se REVERT: bdf7958057f Move to the top of file REVERT: 0d9d7524b9f disable `tcp_linger` feature in `std` REVERT: 79437e07287 add safety annotation to `LinkedList::detach_all_nodes` REVERT: f168476dc1b Rollup merge of #88465 - marcospb19:master, r=joshtriplett REVERT: 08d395861a4 Rollup merge of #88394 - ChrisDenton:patch-1, r=joshtriplett REVERT: 1c23993d3cc Remove unnecessary `mut` from udp doctests REVERT: fa884e1f18f Expand documentation for `FpCategory`. REVERT: 86b94342be0 Add test case for using `slice::fill` with MaybeUninit REVERT: 81b21944a4d use `unwrap_unchecked` where possible REVERT: f63c3de57fa clean up `c::linger` conversion REVERT: 0d4bbd8337b add `TcpStream::set_linger` and `TcpStream::linger` REVERT: e228e0643e8 Adding examples to docs of std::time module REVERT: 04b1d235b4f Add links in docs for some primitive types REVERT: d89a4638b86 Rollup merge of #88381 - rtzoeller:dfly_stack_t_ss_sp_void, r=dtolnay REVERT: b5577017ddf const fn for option copied, take & replace + tests REVERT: 966a8452262 Auto merge of #88295 - alexcrichton:update-stdarch, r=kennytm REVERT: 954c86d95cb VecDeque: improve performance for From<[T; N]> REVERT: 6c7d6858181 add benchmark for From<[T; N]> in VecDeque REVERT: cfcace2598d BTreeSet::from_iter: use bulk building to improve the performance REVERT: e65ddc197d5 BTreeMap::from_iter: use bulk building to improve the performance REVERT: 1c918d7b443 add benchmark for BTreeMap::from_iter REVERT: 0f0a2774d21 Auto merge of #87921 - kellerkindt:master, r=kennytm REVERT: 1c4573e8135 std: Stabilize command_access REVERT: 9d1cacf024f Fix a typo in raw_vec REVERT: 5352f4fa547 Unimpl Shl{Assign} for signed Saturating types until the correct impl is clear REVERT: 59353de2826 Fix mentions of wrapping operations REVERT: 8cd81f0e271 Use wrapping shift for unsigned types REVERT: d04d1c018cf build llvm libunwind.a in rustbuild REVERT: 9ab791a152b Remove ignore-tidy-undocumented-unsafe from core::slice::sort REVERT: 2e8f1d59eae Handle stack_t.ss_sp type change for DragonFlyBSD REVERT: 27e799b68c3 Document `std::env::current_exe` rename behaviour REVERT: c85804203a1 Auto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearth REVERT: ebb8c125af8 Add carrying_add, borrowing_sub, widening_mul, carrying_mul methods to integers REVERT: b3a60ff4b0a Clarify that ManuallyDrop has same layout as T REVERT: 0fdd4ca2290 Fix documentation in Cell REVERT: 61837cb3846 Add TcpListener::into_incoming and IntoIncoming REVERT: 4b4b80241ba Add missing # Panics section to `Vec` method REVERT: 850f84668f8 Rollup merge of #88340 - thomcc:c_size_t, r=joshtriplett REVERT: c689c7551f5 Rollup merge of #88216 - kornelski:from_layout_err, r=kennytm REVERT: 075ac3df10b Auto merge of #87194 - eddyb:const-value-mangling, r=michaelwoerister,oli-obk REVERT: 6aa2b5731a3 Partially stabilize `array_methods` REVERT: 0bfa6ee70cb Auto merge of #88066 - LeSeulArtichaut:patterns-cleanups, r=nagisa REVERT: dc5181df139 Reference tracking issue REVERT: a9f04f79c8d Add `c_size_t` and `c_ssize_t` to `std::os::raw`. REVERT: a6765037ce5 Use if-let guards in the codebase REVERT: 1c49aad3fa5 Rollup merge of #88299 - ijackson:bufwriter, r=Mark-Simulacrum REVERT: cef38a1d3eb Rollup merge of #88298 - ijackson:errorkind-reorder, r=dtolnay REVERT: 9899eaeb51b Rollup merge of #88293 - est31:fix_grammar, r=Mark-Simulacrum REVERT: 154221c688d Rollup merge of #88291 - mdsn:partition-in-blocks-safety, r=Mark-Simulacrum REVERT: c3de3331575 Rollup merge of #88273 - jhpratt:update-iterator-docs, r=jyn514 REVERT: bb6b1109841 Rollup merge of #88226 - steffahn:an_rc, r=michaelwoerister REVERT: ad12880eb1d Rollup merge of #88223 - scottmcm:fix-alias, r=yaahc REVERT: 55623a25748 Rollup merge of #88156 - steffahn:arc_make_mut_and_weak, r=Mark-Simulacrum REVERT: 086b20930a0 Rollup merge of #87944 - oconnor663:as_array_of_cells, r=scottmcm REVERT: beed0af5d28 Add SAFETY comments to core::slice::sort::partition_in_blocks REVERT: 9c1473c8dd4 Make explanations of cross-references between `make_mut` and `get_mut` more accurate REVERT: 870cea743b9 Clarifiy weak pointers being diassociated… REVERT: 6a0db7e2323 Manual Debug for Unix ExitCode ExitStatus ExitStatusError REVERT: 954795fcf87 Stabilise unix_process_await_more, extra ExitStatusExt methods REVERT: 43454dfb3ee Stabilise BufWriter::into_parts REVERT: 2112e8ae8cc Update rustc-demangle to 0.1.21. REVERT: 499287e2b2f Fix tidy REVERT: e5712775d27 Update the stdarch submodule REVERT: 1fe9d265b28 Fix grammar REVERT: bd184a18d81 io::ErrorKind: rationalise ordering in main enum REVERT: 33de4b494a4 io::Error: alphabeticise the match in as_str() REVERT: f591d46c9f4 Remove unnecessary unsafe block in `process_unix` REVERT: 8b43be4fcb5 Fix typo “a Rc” → “an Rc” REVERT: 55596283522 Fix references to `ControlFlow` in docs REVERT: 354e691a280 Auto merge of #83302 - camsteffen:write-piece-unchecked, r=dtolnay REVERT: bd28ccf7777 Rollup merge of #88230 - steffahn:a_an, r=oli-obk REVERT: d0103cbf18c Auto merge of #88220 - sunfishcode:sunfishcode/unix-listener-io-safety, r=joshtriplett REVERT: 98ec7699820 Auto merge of #87598 - ccqpein:master, r=yaahc REVERT: 0e84d8db2b6 add Cell::as_array_of_cells, similar to Cell::as_slice_of_cells REVERT: 0f73875be19 Remove redundant conversions. REVERT: 17fc48f555b Fix typos “an”→“a” and a few different ones that appeared in the same search REVERT: 26c97485ce6 Fix more “a”/“an” typos REVERT: 06d1f59536a Fix more “a”/“an” typos REVERT: 433c5a2831e Fix typos “a”→“an” REVERT: 8adc0c18d0a Add doctests for 's into_values and into_keys methods REVERT: dbcc90b193f Auto merge of #88122 - Seppel3210:master, r=dtolnay REVERT: 0fbcde2560c Auto merge of #85166 - mbhall88:file-prefix, r=dtolnay REVERT: 1efa2fc8b65 Implement `AsFd` etc. for `UnixListener`. REVERT: 75af2100745 Auto merge of #88075 - Xuanwo:vec_deque_retain, r=dtolnay REVERT: 9abf9b6adb8 Don't stabilize creation of TryReserveError instances REVERT: 7b5b7f59108 Remove the `TryV2` alias REVERT: 7e776fe4b18 Add an example for deriving PartialOrd on enums REVERT: 36a8029a102 Auto merge of #83093 - the8472:smaller-instant-hammer, r=Amanieu REVERT: c4f54d1289e fix tests on wasm targets that have 32bit time_t and don't have threads REVERT: 8bdde1453f4 Auto merge of #87329 - sunfishcode:sunfishcode/io-safety, r=joshtriplett REVERT: 17c5991ce04 Auto merge of #86898 - the8472:path-cmp, r=dtolnay REVERT: ed9bbf599ec Stabilize std::os::unix::fs::chroot REVERT: 41f3b59dcd4 Fix doc test failures on Windows. REVERT: 7a17dd8231c Auto merge of #88165 - GuillaumeGomez:rollup-4o0v2ps, r=GuillaumeGomez REVERT: 0bf624f50bb Factor out a common `RawFd`/`AsRawFd`/etc for Unix and WASI. REVERT: 4a488568ed7 Fix syntax for non-doc comments, and use `crate::` instead of `std::`. REVERT: 7806ee8f857 Add I/O safety trait impls for process::Stdio and process::Child. REVERT: 2731d677be1 Use the correct `into_*` on Windows to avoid dropping a stdio handle. REVERT: 3e1819a848c Remove the `#![feature(io_safety)]` from lib.rs. REVERT: 3d2e0a09446 Fix an unused import warning. REVERT: f117ec62b37 Update PidFd for the new I/O safety APIs. REVERT: 67ad739835f Rename OptionFileHandle to HandleOrInvalid and make it just wrap an Option REVERT: 7180aec30c8 Don't encourage migration until io_safety is stablized. REVERT: 85cacac2f8c Factor out Unix and WASI fd code into a common module. REVERT: db5c50c8570 Synchronize minor differences between Unix and WASI implementations. REVERT: 25791eb599b Add more comments about the `INVALID_HANDLE_VALUE` situation. REVERT: 3f4b23abc1e Add comments about impls for File, TcpStream, ChildStdin, etc. REVERT: 3f17c1f19d8 Fix copypasta of "Unix" within the WASI directory. REVERT: 896fec5e95e Reword the description of dup2/dup3. REVERT: 58b739d7268 Add Safety comments to the `As*` for `Owned*` implementations. REVERT: db4d565f9c6 Add Owned*, Borrowed*, and As* to the preludes. REVERT: b3ede981a8e Rename `OwnedFd`'s private field to match it's debug output. REVERT: 76117a74377 Delete a spurious empty comment line. REVERT: 401d0e7d16c Add a comment about how `OwnedHandle` should not be used with registry handles. REVERT: 6b4b9deff18 Add a comment about `OptionFileHandle`. REVERT: 4d6db991465 Be more precise about `mmap` and undefined behavior. REVERT: 6b476d93e87 Add a test to ensure that RawFd is the size we assume it is. REVERT: adc48de081a Update library/std/src/os/windows/io/socket.rs REVERT: 360d7ad3fb0 Update library/std/src/os/windows/io/handle.rs REVERT: eac1d5c9047 Update library/std/src/os/unix/io/fd.rs REVERT: 8847664f0db I/O safety. REVERT: 58a38118fc4 Rollup merge of #87874 - schneems:schneems/tcpstream-iterator-type, r=Mark-Simulacrum REVERT: 708f5ef711e Auto merge of #88151 - alexcrichton:update-backtrace, r=Mark-Simulacrum REVERT: 3af2dacda2d Update the backtrace crate in libstd REVERT: 521dc777585 Adjust documentation of `Arc::make_mut` REVERT: 2c8a3e82666 Simplify saturating_div REVERT: 9389cc81246 Auto merge of #88002 - hermitcore:unbox-mutex, r=dtolnay REVERT: 6382ddbf90e Simplify Div impl for Saturating by using saturating_div REVERT: 4b76eb284f6 Add saturating_div to unsigned integer types REVERT: 0574b2d25e4 Add doctests to and fix saturating_div for signed integer types REVERT: 876ac36d985 Add and use saturating_div instead of impl inside Saturating REVERT: c866705d1aa Saturate negative division REVERT: 934c5d98fb1 Rollup merge of #88109 - inquisitivecrystal:env-docs, r=m-ou-se REVERT: e89903272d3 Rollup merge of #88031 - ibraheemdev:build-hasher-object-safe, r=m-ou-se REVERT: 27191c5df47 Rollup merge of #88012 - sunfishcode:sunfishcode/wasi-raw-fd-c-int, r=alexcrichton REVERT: 7b6495434d0 BTree: remove Ord bound from new REVERT: 495da7b487b Fix example in `Extend<(A, B)>` impl REVERT: 10c73b16b05 [review] fix comment REVERT: dc0f88c7baf BTree: refine some comments REVERT: b625e7eb40f Fix environment variable getter docs REVERT: 21f36384933 Constified `Default` implementations REVERT: b37a00fec17 Rollup merge of #88030 - fee1-dead:fixme, r=oli-obk REVERT: 356e25efc93 correct overflows in the backslide case, add test REVERT: 23d7c054aa0 Get piece unchecked in write REVERT: 454ca35b7ec Make Arguments constructors unsafe REVERT: ae7df6902ba Auto merge of #87050 - jyn514:no-doc-primitive, r=manishearth REVERT: ac956c7d2ec BTree: toughen panicky test of clone() REVERT: 9b2c322d5a6 Auto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiser REVERT: 1da84226901 Remove extra empty lines REVERT: 77f0c71cb9c feature gate doc(primitive) REVERT: 2043285ef05 Optimize unnecessary check in VecDeque::retain REVERT: 1d9700d476d Uplift the `invalid_atomic_ordering` lint from clippy to rustc REVERT: 94af162be1b Auto merge of #87696 - ssomers:btree_lazy_iterator_cleanup, r=Mark-Simulacrum REVERT: ca7fe41083a Apply suggestions from code review REVERT: d25253eb59c move object safety test to library/core REVERT: 283038aeb2f Allow the use of the deprecated llvm_asm! in black_box REVERT: f58211d817d Deprecate llvm_asm! REVERT: a0ba81a2691 Auto merge of #87974 - steffahn:slice_split_size_hints, r=dtolnay REVERT: 128ce90a95a make `BuildHasher` object safe REVERT: 3ad01844538 Assign FIXMEs to me and remove obsolete ones REVERT: 9aac95faf6d Auto merge of #87913 - a1phyr:vec_spec_clone_from, r=dtolnay REVERT: e6a64dc2ee0 Change WASI's `RawFd` from `u32` to `c_int` (`i32`). REVERT: 39298f54ed4 Improve wording, correct -> tight. REVERT: 69b215dc235 switch to the latest version of hermit-abi REVERT: 1a02488d0fc Consistent use of `impl Trait` arguments in the test's helper function. REVERT: bb78df80b7b allow incomplete features for now REVERT: b7d3052391e Moved ui test REVERT: 60f2e4a5391 Don't put hermit mutexes in a box. REVERT: 987b455faa8 Don't put hermit condvars in a box. REVERT: b3cf14dbf7a Don't put hermit rwlocks in a box. REVERT: da38886c7b4 Auto merge of #87980 - Manishearth:rollup-vkuix3y, r=Manishearth REVERT: 95f7114ef4c add benchmarks for 1, 2, 4, 8, 16 threads REVERT: 9a3e2a9936f where available use 64- or 128bit atomics instead of a Mutex to monotonize time REVERT: f39425f8e86 Rewrite test from previous commit but without using macros. REVERT: ad0ab4ad3b4 Auto merge of #87916 - nbdd0121:black_box, r=nagisa REVERT: c1d5da0eed6 Rollup merge of #87916 - nbdd0121:black_box, r=nagisa REVERT: 81f57bc66fe Test and fix size_hint for slice's [r]split* iterators REVERT: 9f3c9c15c4a Implement `black_box` using intrinsic REVERT: a15079ffb83 Auto merge of #87963 - GuillaumeGomez:rollup-e54sbez, r=GuillaumeGomez REVERT: 5c34743f89a Implement Neg only for signed Saturating types REVERT: d0f8f39638c Rollup merge of #87863 - ChrisDenton:command-env-path-fix, r=dtolnay REVERT: 5e694420bb5 Auto merge of #87666 - ivmarkov:master, r=Amanieu REVERT: e0d576ebe4a Add naive remainder impl to Saturating REVERT: fe203a12460 Add naive shift implementation to Saturating REVERT: 477308f3755 Replace doc test with doc macro call REVERT: 242e0304abb Like in Wrapping use shift in doctest REVERT: 63510d703d5 Add missing cfg attribute REVERT: 42adb2507fb Remove mentioning of modular arithmetic REVERT: 6397c6f43f6 Make all the impls for Staturating unstable saturating_int_impl REVERT: bd4cef119db Rollup merge of #85835 - Seppel3210:master, r=yaahc REVERT: 1d5bf95373d Auto merge of #87843 - kornelski:try_reserve, r=m-ou-se REVERT: 13c9c99aeba Weaken guarantee around advancing underlying iterators in zip REVERT: 581d6f8b927 Auto merge of #87892 - rust-lang:spec-fill-size-one-bye, r=the8472 REVERT: 6ad99a7cbb2 Specify maximum IP address length REVERT: 987f95313a4 Rollup merge of #87876 - lcnr:windows_no_panic, r=m-ou-se REVERT: 2ee81ef8c6e Rollup merge of #87848 - godmar:@godmar/thread-join-documentation-fix, r=joshtriplett REVERT: 6f777104c12 Rollup merge of #87636 - Kixiron:unzip-option, r=scottmcm REVERT: 251e8c0a1f7 Rollup merge of #86840 - usbalbin:const_from, r=oli-obk REVERT: 3415af28851 Fix missed tests REVERT: 235362a07e0 Rustfmt REVERT: 2ebc52ef54c Remove unused macros REVERT: 4273e381268 Add Saturating type (based on Wrapping type) REVERT: a3f362f4481 Specialize `Vec::clone_from` for `Copy` types REVERT: 64cea2f6708 STD support for the ESP-IDF framework REVERT: 74c0d39b88b Reword description of automatic impls of `Unsize`. REVERT: 876e5dda4c5 Remove size_of == 1 case from `fill` specialization. REVERT: bbc758c4935 Added tracking issue to unstable attribute REVERT: 12817e2aa3d Enabled unzip_option feature for core tests & unzip docs REVERT: 2374e5ac971 Added some basic tests for `Option::unzip()` and `Option::zip()` (I noticed that zip had no tests) REVERT: 8d951c5df14 Added the `Option::unzip()` method REVERT: 8a544689f52 add `windows` count test REVERT: c7c7365fb59 Auto merge of #87820 - elichai:patch-2, r=kennytm REVERT: ce45ad1adb6 ## Context REVERT: 82f89b9b9a1 Implement modern Windows arg parsing REVERT: c22a0db657b Update Windows arg parsing tests REVERT: 9687e6d0a32 Auto merge of #86879 - YohDeadfall:stabilize-vec-shrink-to, r=dtolnay REVERT: 096799b4bf9 Bump shrink_to stabilization to Rust 1.56 REVERT: 0d8af84aabe Make `<[T]>::split_at_unchecked` and `<[T]>::split_at_mut_unchecked` public REVERT: 4bea22c73fd Fix Windows Command::env("PATH") REVERT: 33caed0fb18 Auto merge of #87827 - eddyb:wrapperless-mem-replace, r=m-ou-se REVERT: bd722ea3396 Avoid using the `copy_nonoverlapping` wrapper through `mem::replace`. REVERT: 073727ba353 Auto merge of #87836 - tsoutsman:master, r=petrochenkov REVERT: 208b27eb38a Merge branch 'rust-lang:master' into master REVERT: 87fd6dc76d9 Auto merge of #86744 - ijackson:sink-default, r=dtolnay REVERT: a8073a08813 Add test for int to float REVERT: 7d97a29d452 Add tests REVERT: 010d8df43ad impl const From for num REVERT: 3fe288cd18a Rollup merge of #87842 - steffahn:hidden_broken_intra_doc, r=dtolnay REVERT: 40a889b2452 Rollup merge of #87838 - jetomit:add-readdir-note, r=dtolnay REVERT: e3606759bb1 removed references to parent/child from std::thread documentation REVERT: ed920504d73 Change proc_macro::Diagnostics docs REVERT: 1851a963175 Use assert_matches! instead of if let {} else REVERT: aff87b988db Inline from of TryReserveErrorKind REVERT: 96322d53baa Auto merge of #87810 - devnexen:haiku_os_simpl, r=Mark-Simulacrum REVERT: 0c0d1e1d344 Fix intra doc link in hidden doc of Iterator::__iterator_get_unchecked REVERT: 15d4d15bbed Document that fs::read_dir skips . and .. REVERT: f7297a8954a Auto merge of #87408 - kornelski:try_reserve_error, r=yaahc REVERT: 534c88780a5 Auto merge of #87774 - camelid:process-typo, r=jyn514 REVERT: 38c083fefb2 Replace read_to_string with read_line in Stdin example REVERT: 7efc1cff905 Rollup merge of #87809 - InnovativeInventor:pointer-typo, r=dtolnay REVERT: 82f0cb37483 Rollup merge of #87787 - hyd-dev:c-unwind, r=RalfJung REVERT: ff2e3bd770b Auto merge of #87777 - the8472:fix-mir-max-rss, r=oli-obk,joshtriplett REVERT: 4020fd93217 current_exe haiku code path simplification all of these part of libc REVERT: 3302ce4751f Auto merge of #87808 - JohnTitor:rollup-qqp79xs, r=JohnTitor REVERT: b268c604b26 Fix typo in the ptr documentation REVERT: 8a17230abc7 Rollup merge of #87780 - est31:intra_doc_links, r=jyn514 REVERT: ba6c7c47393 Rollup merge of #87759 - m-ou-se:linux-process-sealed, r=jyn514 REVERT: cda3bf32d3f Rollup merge of #87561 - devnexen:haiku_thread_build_fix, r=yaahc REVERT: b72d6a06a8b Auto merge of #87462 - ibraheemdev:tidy-file-length-ignore-comment, r=Mark-Simulacrum REVERT: 5b52f81b583 add Box::try_new_uninit_slice for symmetry REVERT: cbc4916215c remove cfg gate on `use RawVec` since it is now also used in fallible code REVERT: 6aef2ce6c6e Make rustfmt happy. REVERT: 1ea1ee16e05 Remove unnecessary #[unstable] from internal macro. REVERT: bace714fc28 Remove unused langauge #![feature]s from core. REVERT: 744a7270fa9 Remove unused library #![feature]s from core. REVERT: 4ef0c9c884a Sort and categorize lint and feature attributes in core. REVERT: 6562692d065 Use `C-unwind` ABI for `__rust_start_panic` in `panic_abort` REVERT: 87221c401d0 alloc: Use intra doc links for the reserve function REVERT: b845cfe8b1c add Box::try_new_zeroed_slice() REVERT: 7c17ff2b9d1 Auto merge of #86155 - alexcrichton:abort-on-unwind, r=nikomatsakis REVERT: 4558afd6c8a Fix typo REVERT: 82708184579 Auto merge of #87736 - the8472:inline-advance-by, r=Mark-Simulacrum REVERT: 929cd9fe292 Auto merge of #87150 - rusticstuff:simplify_wrapping_neg, r=m-ou-se REVERT: 2639edbb956 Re-use std::sealed::Sealed in os/linux/process. REVERT: d1f15097518 Auto merge of #87712 - est31:line-column-1-based, r=petrochenkov REVERT: f624ab9adf8 Rollup merge of #87729 - adamgemmell:dev/deprecate-crypto, r=Amanieu REVERT: ccbc23b242f Rollup merge of #87723 - frogtd:patch-3, r=JohnTitor REVERT: 1ff7fe6b4e4 Rollup merge of #87267 - dtolnay:negspace, r=Aaron1011 REVERT: 765f30ba167 Rollup merge of #81797 - yoshuawuyts:stream_from_iter, r=dtolnay REVERT: 24883cc8876 #[inline] slice::advance_by REVERT: 01e01698537 Update library/core/src/iter/traits/collect.rs REVERT: 55471ffd835 Remove space after negative sign in Literal to_string REVERT: b90d6368093 rustc: Fill out remaining parts of C-unwind ABI REVERT: 83f0c467a5c Update aarch64 runtime feature detection tests REVERT: 2ca01e16053 Update `stdarch` to deprecate `crypto` aarch64 target_feature REVERT: 1d9907deca8 Rollup merge of #87708 - the8472:canonical_v6, r=dtolnay REVERT: 7982d1afb38 Rollup merge of #87685 - notriddle:lazy-from-docs, r=dtolnay REVERT: 47f8d5af506 Use .contains instead of manual reimplementation. REVERT: df35e3714e2 Auto merge of #86335 - CDirkx:ipv4-in-ipv6, r=dtolnay REVERT: 60e7376768a Make the UTF-8 statement more explicit and explicitly test for it REVERT: 9b4c35f82fb Make columns 1 based REVERT: 86a5879ce89 Add convenience for handling ipv4-mapped addresses by canonicalizing them REVERT: 033ad70b681 Rollup merge of #87690 - sharnoff:mut-ptr-allocated-obj-link, r=Mark-Simulacrum REVERT: a55de479518 Rollup merge of #87654 - jesyspa:issue-87238-option-result-doc, r=scottmcm REVERT: 48946a2bb42 BTree: merge the complication introduced by #81486 and #86031 REVERT: ab2177909ca os current_exe using same approach as linux to get always the full absolute path but in case of failure (e.g. prcfs not mounted) still using getexecname. REVERT: 54c780713a6 Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum REVERT: fa6d3727267 Add missing "allocated object" doc link REVERT: a27e5a59bcb Auto merge of #87689 - JohnTitor:rollup-ns38b56, r=JohnTitor REVERT: ccbf22b1e1b Rollup merge of #87653 - RalfJung:dont-run-ub, r=kennytm REVERT: a102a4a1f73 Rollup merge of #87644 - Flying-Toast:vec-remove-note, r=the8472 REVERT: 6893f191936 Rollup merge of #87629 - steffahn:consistent_adapter_spelling, r=m-ou-se REVERT: 248fcbde903 Rollup merge of #86936 - CDirkx:ipv6-multicast, r=JohnTitor REVERT: 86b771efbea Rollup merge of #86593 - jhpratt:stabilize-const_slice_first_last, r=m-ou-se REVERT: 90f81d1eb7a Rollup merge of #86509 - CDirkx:os_str, r=m-ou-se REVERT: 953d33dadbf Rollup merge of #86439 - CDirkx:ip-protocol-assignment, r=m-ou-se REVERT: b76986a92ba Rollup merge of #86183 - inquisitivecrystal:env-nul, r=m-ou-se REVERT: 65c4fa4da98 Auto merge of #85272 - ChayimFriedman2:matches-leading-pipe, r=m-ou-se REVERT: a34911e6538 Auto merge of #86031 - ssomers:btree_lazy_iterator, r=Mark-Simulacrum REVERT: cf0e67f5b74 Write docs for SyncOnceCell From and Default impl REVERT: c58305cd665 Auto merge of #87622 - pietroalbini:bump-bootstrap, r=Mark-Simulacrum REVERT: 34899d43210 Auto merge of #81825 - voidc:pidfd, r=joshtriplett REVERT: f1a6e843169 Update const_slice_first_last_not_mut stable version. REVERT: 4f00a80028d bump bootstrap compiler to 1.55 REVERT: ab74cd9f3a4 Add documentation for the order of Option and Result REVERT: 99c95a18f0d Add dummy FileDesc struct for doc target REVERT: 71f6c56a082 Auto merge of #84662 - dtolnay:unwindsafe, r=Amanieu REVERT: d57cfc0f641 Fix unused sync::atomic import on targets without atomics REVERT: 6c22b55988e Relocate Arc and Rc UnwindSafe impls REVERT: 01e28e6fbcf mark a UB doctest as no_run REVERT: 4a7aa461184 Auto merge of #87387 - the8472:slice-iter-advance_by, r=scottmcm REVERT: 69370e50f23 Auto merge of #87488 - kornelski:track-remove, r=dtolnay REVERT: 4df5e9ab58f Recommend `swap_remove` in `Vec::remove` docs REVERT: 2069383476a Rollup merge of #87609 - LukasKalbertodt:improve-array-map-docs, r=m-ou-se REVERT: bd2e87e510e Rollup merge of #87547 - GuillaumeGomez:nonnull-examples, r=kennytm REVERT: 645603794fd Rollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkov REVERT: f45aab21565 Fix some broken rustdoc links in core::panic documentation REVERT: 788b7580b24 Fix comment referring to formerly-above code REVERT: cb2985347ad Fix undocumented unsafe in AssertUnwindSafe impls REVERT: 5a2755b49d8 Move UnwindSafe, RefUnwindSafe, AssertUnwindSafe to core REVERT: 2efb81f05f1 Fix separation of public vs internal parts of Location REVERT: 2a8212b8311 Split core::panic module to subdirectory REVERT: c4d211a3e62 Consistent spelling of "adapter" in the standard library REVERT: 315622ae016 Add missing examples for NonNull REVERT: 82f4176266a Rollup merge of #87602 - wesleywiser:partially_fix_short_backtraces_windows_optimized, r=dtolnay REVERT: fc6975fb702 Rollup merge of #87594 - devnexen:netbsd_fs_getfiledescriptor_path, r=joshtriplett REVERT: c7640f79196 Rollup merge of #87585 - GuillaumeGomez:char-types-doc, r=joshtriplett REVERT: ab7185d3c73 Rollup merge of #87574 - cuviper:retain-examples, r=joshtriplett REVERT: 9a6f848223e Rollup merge of #87522 - frogtd:patch-1, r=yaahc REVERT: 177e17efbc1 Rollup merge of #87052 - phlopsi:patch-1, r=jyn514 REVERT: 54ea4992d76 Auto merge of #87445 - amalik18:issue-83584-fix, r=kennytm REVERT: 9a1e8609dcf Add docs about performance and `Iterator::map` to `[T; N]::map` REVERT: abde70ab613 rfc3052: Remove authors field from Cargo manifests REVERT: 1d8dd805b9d [backtraces]: look for the `begin` symbol only after seeing `end` REVERT: c1e3a48fb51 fs File get_path procfs usage for netbsd same as linux. REVERT: 27538feba9a Rename feature gate bufwriter_into_parts from bufwriter_into_raw_parts REVERT: b0f1ed067e4 BufWriter: rename `into_parts` from `into_raw_parts` REVERT: ee1e5527ddc BufWriter: actually export WriterPanicked error REVERT: 111bdb8009c Add missing links for core::char types REVERT: ac1919f094e Auto merge of #86664 - m-ou-se:uninit-track-caller, r=JohnTitor REVERT: 0d0cdc86fa1 Auto merge of #86998 - m-ou-se:const-panic-fmt-as-str, r=oli-obk REVERT: 67586dd1cf7 Fix may not to appropriate might not or must not REVERT: c1e029f3419 Fix may not to appropriate might not or must not REVERT: 3c3bb4c1a46 Auto merge of #85874 - steffahn:fix_unsound_zip_optimization, r=yaahc REVERT: 781905de7ca Update the examples in `String` and `VecDeque::retain` REVERT: 1e2234989f9 Add char array without ref Pattern impl REVERT: f9d6f79cb9b impl Pattern for char array REVERT: e719913bb3b Rollup merge of #87565 - ibraheemdev:patch-7, r=scottmcm REVERT: b1add590c78 Rollup merge of #86839 - D1mon:patch-1, r=JohnTitor REVERT: 4223eb30c79 Rollup merge of #81363 - jonhoo:no-unpin-in-pin-future-impl, r=m-ou-se REVERT: 00a57c6352e Rollup merge of #81050 - yoshuawuyts:stabilize-task-ready, r=m-ou-se REVERT: f9d7568df1a Use backticks when referring to `core::future::Ready` in panic message REVERT: 89ae23da1ca Add some doc aliases REVERT: e1458721f78 thread set_name haiku implementation. REVERT: 9c77c2cc35f Update stable version of ready!() macro. REVERT: 4d870bef609 Extend documentation of const_format_args!(). REVERT: be89f05d436 Improve comments about const panic handling REVERT: 5adb8e721b2 Make const_fmt_args!() work during bootstrap. REVERT: afd833bde36 Use unreachable_unchecked in const_panic_fmt. REVERT: e9ffecf6e68 Add new const_format_args!() macro and use it in panics. REVERT: a6d6426f004 Make const panic!("..") work in Rust 2021. REVERT: d2d9408eb58 Add #[track_caller] for some function in core::mem. REVERT: b85c7289a20 Documentation improvements REVERT: c2944bd691d Make `SpecInPlaceCollect` use `TrustedRandomAccessNoCoerce` REVERT: 6ea9eb03650 Remove redundant bounds on get_unchecked for vec_deque iterators, and run fmt REVERT: f9ccdd82522 Add back TrustedRandomAccess-specialization for Vec, but only without coercions REVERT: 8ad4557ab89 Change __iterator_get_unchecked to work with TrustedRandomAccessNoCoerce REVERT: 54ee3eed59b Add TrustedRandomAccessNoCoerce supertrait without requirements or guarantees about subtype coercions REVERT: d2791d162ae Improve documentation of TrustedRandomAccess REVERT: 97f12411702 Remove unsound TrustedRandomAccess implementations REVERT: 33b6ebb41a0 stack overflow handler specific openbsd fix. REVERT: 731acaebce7 Rollup merge of #87523 - frogtd:patch-2, r=dtolnay REVERT: 20eca70f08e Rollup merge of #87507 - jethrogb:jb/sgx-unmoveable-mutex, r=dtolnay REVERT: f93355be9fd Rollup merge of #87501 - spastorino:remove-min-tait, r=oli-obk REVERT: a5b5ac61a3a Rollup merge of #87500 - Smittyvb:min-max-docs, r=kennytm REVERT: 666069d00e3 Rollup merge of #87330 - inquisitivecrystal:extend-reserve, r=JohnTitor REVERT: 95deb966dce Auto merge of #86735 - jhpratt:rfc-3107, r=petrochenkov REVERT: 5a2809d40df remove unneeded stringify REVERT: 64a7d0d7973 Update tests REVERT: 64870b09fb0 Update range.rs REVERT: 52ff3d8c9ac Stabilize `const_fn_union` REVERT: e1834ab4ee9 Stabilize `const_fn_transmute` REVERT: 283fc655c24 Fix assert in diy_float REVERT: 994d5ac6357 Permit deriving default on enums with `#[default]` REVERT: fac481053e7 Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default REVERT: 182a9ef5c36 Use type_alias_impl_trait instead of min in compiler and lib REVERT: 119957734cd Auto merge of #87509 - JohnTitor:rollup-8iqn6cl, r=JohnTitor REVERT: 72e0be054a2 Rollup merge of #87494 - midgleyc:comment-typos, r=joshtriplett REVERT: 6d4a0fd591f Rollup merge of #87446 - devnexen:macos_update, r=dtolnay REVERT: 9abc8fa4efb Rollup merge of #87354 - Wind-River:2021_master, r=kennytm REVERT: f3326610246 Auto merge of #87431 - the8472:array-iter-fold, r=kennytm REVERT: f9e3793f1f4 Add warning to SGX mutex implementation REVERT: 7a04669ab76 Revert "SGX mutex is movable" REVERT: b35c70ce934 Auto merge of #85305 - MarcusDunn:master, r=pnkfelix REVERT: 8a5bbf99f03 Auto merge of #87062 - poliorcetics:fix-85462, r=dtolnay REVERT: dd631d40073 Document math behind MIN/MAX consts on integers REVERT: 35e8ad3447a from review: add a comment why try_fold was chosen instead of fold REVERT: 98f59bc9a06 fix typo: whenver -> whenever REVERT: 2577b2fab00 Track caller of Vec::remove() REVERT: 8ae6a3da333 Auto merge of #87430 - devnexen:netbsd_ucred_enabled, r=joshtriplett REVERT: 3da84b82146 ignore comments in tidy-filelength REVERT: 3c5680a0e84 Auto merge of #86595 - a1phyr:allocator_api_for_vecdeque, r=Amanieu REVERT: 8ff5763c3cc macos current_exe using directly libc instead. REVERT: cb525510042 Auto merge of #84111 - bstrie:hashfrom, r=joshtriplett REVERT: d52719bfcd2 Hide allocator details from TryReserveError REVERT: ef4ab2f3b4a Remove unnecessary condition in Barrier::wait() REVERT: b92271c11c5 implement fold() on array::IntoIter to improve flatten().collect() perf REVERT: 81bee980965 Rollup merge of #87422 - mgeier:doc-strip-feature-attribute, r=LeSeulArtichaut REVERT: 7d2cf6192b1 Rollup merge of #87410 - jonas-schievink:doc-hidden-format_args_nl, r=nagisa REVERT: d6cb4985bd9 Rollup merge of #87395 - ericonr:patch-1, r=joshtriplett REVERT: 24315b67f23 netbsd enabled ucred REVERT: 32783264313 DOC: remove unnecessary feature crate attribute from example code REVERT: 9ca228c99a9 Auto merge of #84589 - In-line:zircon-thread-name, r=JohnTitor REVERT: ba2287dcf3d Fix parameter names in std::env documentation. REVERT: 588de7005fd Rollup merge of #87255 - RalfJung:miri-test-libcore, r=Mark-Simulacrum REVERT: dcec01bfbb9 Rollup merge of #87175 - inquisitivecrystal:inner-error, r=kennytm REVERT: 2806700fcca Rollup merge of #87171 - Alexendoo:bufwriter-option, r=Mark-Simulacrum REVERT: 303087fd391 Rollup merge of #86790 - janikrabe:retain-iter-order-doc, r=m-ou-se REVERT: bb1ce8f6d2c Add `#[unstable]` on new functions REVERT: 5c09f28ca7c Add unstable attribute for `A` in `Drain` and `IntoIter` REVERT: b1dd632a44f Add support for custom allocator in `VecDeque` REVERT: ca9a52e8fcd Mark `format_args_nl` as `#[doc(hidden)]` REVERT: 1ed16bf31ca Stabilize core::task::ready! REVERT: e795344e2e5 Rollup merge of #87034 - mgeier:doc-step_by, r=JohnTitor REVERT: dd6ced33b3a Fix whitespace REVERT: ab1773aa01f Add tests REVERT: b13923e013c Implement slice::{Iter, IterMut}::{advance_by, advance_back_by} REVERT: c40c7d319cb Remove Option from BufWriter REVERT: 2a9f7e85a10 Rollup merge of #87343 - steffahn:fix_unsound_zip_optimization_only_regression_fix, r=cuviper REVERT: b79fef804b9 VxWorks does provide sigemptyset and sigaddset REVERT: cff9855539f Disable glibc tests on vxworks REVERT: 656c70a8d56 Rollup merge of #81864 - ijackson:globalalloc-example, r=Amanieu REVERT: bf65ac5cd7e Rollup merge of #87279 - sunfishcode:document-unix-argv, r=RalfJung REVERT: ab30859117b Remove unsound TrustedRandomAccess implementations REVERT: 92ba5c92d93 docs: GlobalAlloc: Make example only require 4096-aligned static REVERT: 3fb34ea7372 Add tracking issue and link to man-page REVERT: 23170a1ac2f Add PidFd type and seal traits REVERT: 049d429e198 Typo fix REVERT: 8aa4b33e4cb Add Linux-specific pidfd process extensions REVERT: fe219fb69ea Auto merge of #86847 - tlyu:stdin-forwarders, r=joshtriplett REVERT: 3dda4992a11 Auto merge of #87168 - the8472:flatten-len, r=scottmcm REVERT: d57b8a963fc Use hashbrown's `extend_reserve()` in `HashMap` REVERT: 0759d399b36 Auto merge of #87247 - crlf0710:merge-libterm-into-libtest, r=nagisa REVERT: fa50c6ce318 docs: GlobalAlloc: completely replace example with one that works REVERT: 7cc5db8b308 replace Option combinators with try block REVERT: b336cd67219 Add comments explaining the unix command-line argument support. REVERT: 9f2bf7a7e34 Rollup merge of #87236 - sunfishcode:avoid-locking-args, r=joshtriplett REVERT: c206391e720 Rollup merge of #87227 - bstrie:asm2arch, r=Amanieu REVERT: d9b2bc7df6b Auto merge of #87196 - oxalica:option-insert-must-use, r=joshtriplett REVERT: 248abe16d5a Move asm! and global_asm! to core::arch REVERT: 78bf760d8c3 better support for running libcore and liballoc tests with Miri REVERT: 81af0d64263 Remove unused stuff and switch to pub(crate) whenever possible. REVERT: 4f2bdb7936e Fix compilation errors. REVERT: 03caa7a9e92 Move `library/term/src` to `library/test/src/term/`. REVERT: c3c7e4acd7b Rollup merge of #87183 - RalfJung:option-doctest, r=jyn514 REVERT: cd2b5fc781b Rollup merge of #87170 - xFrednet:clippy-5393-add-diagnostic-items, r=Manishearth,oli-obk REVERT: a4242e330cb x.py fmt REVERT: 0af12f1f894 Remove an unnecessary `Mutex` around argument initialization. REVERT: 16d8a2a8952 Remove args cleanup code. REVERT: 0b60fbff8bd Auto merge of #86761 - Alexhuszagh:master, r=estebank REVERT: 58e1c3d2dc9 Changed dec2flt to use the Eisel-Lemire algorithm. REVERT: 27c518bb134 Auto merge of #87195 - yaahc:move-assert_matches-again, r=oli-obk REVERT: 0dccdb36f18 i sweat to god REVERT: 43565f64ffb pls this time REVERT: a78ea3f0c3f implement ConstSizeIntoIterator for &[T;N] in addition to [T;N] REVERT: 4df050cbc0e Rollup merge of #87174 - inquisitivecrystal:array-map, r=kennytm REVERT: a9d505f8f61 rename specializing trait to ConstSizeIntoIterator REVERT: 26fd2cf08d1 Mark `Option::insert` as must_use REVERT: ca478c10449 rename assert_matches module REVERT: 6a966d977ea fix typo in compile_fail doctest REVERT: 2de26ae3eeb Rollup merge of #87138 - dhwthompson:fix-range-invariant, r=JohnTitor REVERT: 737ab39a29b Stabilize `into_parts()` and `into_error()` REVERT: 2fb00b8f071 Stabilize `[T; N]::map()` REVERT: 236f5e5202a Added diagnostic items to structs and traits for Clippy REVERT: 88a3b6fd231 Added diagnostic items to functions for Clippy REVERT: f02305a19ad implement TrustedLen for Flatten/FlatMap if the U: IntoIterator == [T; N] REVERT: 312e791bf5f Allow leading pipe in `matches!()` patterns. REVERT: 0efde43c854 Rollup merge of #87127 - poliorcetics:ptr-rotate-safety, r=scottmcm REVERT: d8abb0e2bd0 Rollup merge of #87081 - a1phyr:add_wasi_ext_tracking_issue, r=dtolnay REVERT: 07334cf73ce Rollup merge of #86947 - m-ou-se:assert-matches-to-submodule, r=yaahc REVERT: cf849dfe6ed Added Arc::try_pin REVERT: 5552bf7a011 Make wrapping_neg() use wrapping_sub(), #[inline(always)] REVERT: e5b98aa3dff Auto merge of #86765 - cuviper:fuse-less-specialized, r=joshtriplett REVERT: fa8f9209fc1 Correct invariant documentation for `steps_between` REVERT: 9b0d89cccd5 Rollup merge of #87027 - petrochenkov:builderhelp, r=oli-obk REVERT: b4ab5a4b6ba Add safety comments in private core::slice::rotate::ptr_rotate function REVERT: a8a088fa3e5 Auto merge of #87118 - JohnTitor:rollup-8ltidsq, r=JohnTitor REVERT: 365d5a92f3a DOC: Add missing arguments to hypothetical code for step_by() REVERT: 23f9bff85eb Auto merge of #86211 - tlyu:option-result-overviews, r=joshtriplett REVERT: 28d75e652d8 Rollup merge of #87099 - JohnTitor:upgrade-cc-crate, r=alexcrichton REVERT: 5c4be72e3f7 Rollup merge of #87090 - ssomers:btree_comments, r=the8472 REVERT: 069c226c247 expand: Support helper attributes for built-in derive macros REVERT: f9471909339 Upgrade `cc` crate to 1.0.69 REVERT: 09ddb5716aa add Stdin::lines, Stdin::split forwarder methods REVERT: 25720c6b6b1 Rollup merge of #86846 - tlyu:stdio-locked-tracking, r=joshtriplett REVERT: 2043dbf72e9 Rollup merge of #86811 - soerenmeier:remove_remaining, r=yaahc REVERT: 6884ade99c2 Rollup merge of #86344 - est31:maybe-uninit-extra, r=RalfJung REVERT: e5891d552d2 Make BTreeSet::split_off name elements like other set methods do REVERT: 217598c640c Use the write function in some more places REVERT: 56f91eeade0 Add tracking issue number to `wasi_ext` REVERT: f41b4381b5c Rollup merge of #87045 - jhpratt:fix-tracking-issue, r=jyn514 REVERT: 16dd992c91b Rollup merge of #86951 - cyberia-ng:fp-negative-zero-sqrt-docs, r=Mark-Simulacrum REVERT: 27b13adb01e Add test for the fix REVERT: ba2adacfcf4 Fix #85462 by adding a marker flag REVERT: 9d70cfd963d Add example with a bunch of leading zeos REVERT: 734255444a2 Simplify leading zero checks REVERT: e3062918d37 Optimize fmt::PadAdapter::wrap REVERT: 9c49ab15e54 Fix tracking issue for `bool_to_option` REVERT: 44db504fe89 Auto merge of #85953 - inquisitivecrystal:weak-linkat-in-fs-hardlink, r=joshtriplett REVERT: 70d3b11ccd4 Make tests pass on old macos REVERT: 8b890fbcba1 Change `weak!` and `linkat!` to macros 2.0 REVERT: b1e45a657ae Rollup merge of #87011 - RalfJung:thread-id-supply-shortage, r=nagisa REVERT: a76b05c6a6c rename variable REVERT: 14cc9b96d47 avoid reentrant lock acquire when ThreadIds run out REVERT: e571676b5d1 Update docs for `fs::hard_link` REVERT: ff4161c36e6 Fix linker error REVERT: 7a0d9a23d57 Reject too-long IPs quicker REVERT: 5aec7f6d7b7 Clarify docs on what IPv4 octal addresses are REVERT: d6d32614454 Debug formatting of raw_arg() REVERT: 2abfe1f4c95 Use AsRef in CommandExt for raw_arg REVERT: ae0ed2dbe78 Unescaped command-line arguments for Windows REVERT: 944f75f9fee Test escaping of trialing slashes in Windows command-line args REVERT: ae4dbbd851d Auto merge of #85828 - scottmcm:raw-eq, r=oli-obk REVERT: 9baf2127906 Auto merge of #86904 - m-ou-se:prelude-collision-check-trait, r=nikomatsakis REVERT: 562a09e5146 PR feedback REVERT: 04d1c9d0499 Stop generating `alloca`s+`memcmp` for simple array equality REVERT: 13aa59519f4 Move the `PartialEq` and `Eq` impls for arrays to a separate file REVERT: 5de354da289 BTree: lazily locate leaves in rangeless iterators REVERT: 6c5bd1ce03f Auto merge of #86930 - tspiteri:int_log10, r=kennytm REVERT: 0e21ae6c079 Disallow octal zeros in IPv4 addresses REVERT: bdf671b5274 Auto merge of #86982 - GuillaumeGomez:rollup-7sbye3c, r=GuillaumeGomez REVERT: 9b33b152d81 Rollup merge of #86789 - janikrabe:btreeset-drainfilter-doc, r=kennytm REVERT: a8024c77e5c Rollup merge of #86726 - sexxi-goose:use-diagnostic-item-for-rfc2229-migration, r=nikomatsakis REVERT: ba3641381bd Auto merge of #86520 - ssomers:btree_iterators_checked_unwrap, r=Mark-Simulacrum REVERT: c59fb276ca8 Auto merge of #86823 - the8472:opt-chunk-tra, r=kennytm REVERT: 42ac3660047 Rollup merge of #86956 - cuviper:unalias-every, r=m-ou-se REVERT: d4315ef6def Rollup merge of #86955 - Swordelf2:patch-1, r=cuviper REVERT: 6162735391b Rollup merge of #86917 - notriddle:notriddle/from-try-reserve-error, r=JohnTitor REVERT: d3e0f534e3a Move [debug_]assert_matches to mod {core, std}::assert. REVERT: cf79cf26259 Revert "Add "every" as a doc alias for "all"." REVERT: b01fd99ddef Fix typo in `ops::Drop` docs REVERT: c7e0a13c117 Clarify behaviour of f64 and f32::sqrt when argument is negative zero REVERT: 9e712f2a61f Check FromIterator trait impl in prelude collision check. REVERT: 977e38752bc Add documentation for `Ipv6MulticastScope` REVERT: dfd7f8b26cf special case for integer log10 REVERT: da00b3496bd test integer log10 values close to all powers of 10 REVERT: 1470bd83b17 Rollup merge of #86916 - godmar:@godmar/thread-yield-documentation-fix, r=joshtriplett REVERT: 07158ed7405 Rollup merge of #86906 - juniorbassani:update-sync-docs, r=yaahc REVERT: d665123ac8f Rollup merge of #86880 - m-ou-se:test-manuallydrop-clone-from, r=Mark-Simulacrum REVERT: c7fc4f62c10 Rollup merge of #86717 - rylev:rename, r=nikomatsakis REVERT: 39d749b3fa7 Rollup merge of #80918 - yoshuawuyts:int-log2, r=m-ou-se REVERT: 5d82a84b933 Add doc comment for `impl From for TryReserveError` REVERT: f4d900d00f2 rewrote documentation for thread::yield_now() REVERT: 6dfefea1dbe add Ord tests for Path comparisons REVERT: 26931b028cc optimize {Path,PathBuf,Components}::{cmp,partial_cmp} for shared prefixes REVERT: 868ee15feab Add s to non_fmt_panic REVERT: 3e0a049a563 Change or_patterns_back_compat lint to rust_2021_incompatible_or_patterns REVERT: 4ed98bb8546 Fix typo in core::sync::atomic::compiler_fence example REVERT: 7569a7bfcef Replace deprecated compare_and_swap by compare_exchange_weak in core::sync::atomic::fence example REVERT: 2e691bd9899 Stabilize Vec::shrink_to REVERT: 5054894b850 Improve env var getter docs REVERT: 495210568a7 Make `getenv` return an Option instead of a Result REVERT: 44849d99b52 Change env var getters to error recoverably REVERT: 95946aafe90 use Eq::eq instead of Iterator::eq implementation REVERT: ae56454b3ff Rollup merge of #86852 - Amanieu:remove_doc_aliases, r=joshtriplett REVERT: 1e93109fe9d Rollup merge of #86794 - inquisitivecrystal:seek-rewind, r=m-ou-se REVERT: 95b197fd18f Rollup merge of #85377 - ijackson:abort-docs, r=m-ou-se REVERT: 2c763a1b350 Rollup merge of #83581 - arennow:dir_entry_ext_unix_borrow_name, r=m-ou-se REVERT: fe031321112 Auto merge of #84560 - cjgillot:inline-iter, r=m-ou-se REVERT: 46b4d277185 Test ManuallyDrop::clone_from. REVERT: 1b3b1443f89 s/die/terminate/ in abort documentation. REVERT: 1d00015be12 Use american spelling for behaviour REVERT: a5de292a400 Talk about "terminate" rather than "die" REVERT: 295e5f5796a Talk about invalid instructions rather than debug traps REVERT: 3467938b74b abort docs: Document buffer non-flushing REVERT: f13febf54cc abort docs: Do not claim that intrinsics::abort is always a debug trap REVERT: 27c5058e9f8 aborts: Clarify documentation and comments REVERT: 74f885e1fbc Auto merge of #86875 - JohnTitor:rollup-fuefamw, r=JohnTitor REVERT: 19c56744f87 Rollup merge of #86864 - GuillaumeGomez:example-write-vectored, r=JohnTitor REVERT: 229496bc48f Rollup merge of #86858 - JohnTitor:stabilize-string-drain-as-str, r=Mark-Simulacrum REVERT: 6c728fb7089 Auto merge of #86598 - yoshuawuyts:poll-method-docs, r=JohnTitor REVERT: 3aa413e978a Add missing code example for Write::write_vectored REVERT: ef863e0e598 Auto merge of #86048 - nbdd0121:no_floating_point, r=Amanieu REVERT: 0e349fb3026 Auto merge of #86213 - jhpratt:stabilize-const-from_utf8_unchecked, r=JohnTitor REVERT: 79a1befb794 Stabilize `string_drain_as_str` REVERT: e4a9e30235b Auto merge of #86833 - crlf0710:remove-std-raw-mod, r=SimonSapin REVERT: 410dec899de Auto merge of #85270 - ChrisDenton:win-env-case, r=m-ou-se REVERT: 988ad2dbf4f stdio_locked: add tracking issue REVERT: c9c4b17caf0 Auto merge of #86810 - ojeda:alloc-gate, r=dtolnay REVERT: a8b71566621 Auto merge of #86799 - tlyu:stdio-locked, r=joshtriplett REVERT: 66e73a5a483 Remove the deprecated `core::raw` and `std::raw` module. REVERT: 125ce7c12e2 Auto merge of #79965 - ijackson:moreerrnos, r=joshtriplett REVERT: 3d572b58789 Move `os_str_bytes` to `sys::unix` and reuse it on other platforms. REVERT: 84c6f128031 optimize chunks and chunks_mut REVERT: d73878b9776 stdio_locked: updates based on feedback REVERT: 7c5df470a1c Rollup merge of #86807 - tversteeg:patch-1, r=bjorn3 REVERT: eadc765f32a Rollup merge of #86803 - xfix:remove-unnecessary-ampersand-from-command-args-calls, r=joshtriplett REVERT: 02c3c6c3858 Rollup merge of #86308 - bstrie:intrinsafe, r=JohnTitor REVERT: a74e6c50a85 Rollup merge of #85001 - CDirkx:bytestring, r=JohnTitor REVERT: 165282a45bd Rollup merge of #84029 - drahnr:master, r=petrochenkov REVERT: 6306df9461a Remove unstable `Cursor::remaining` REVERT: 7c5ca139ee9 alloc: `no_global_oom_handling`: disable `new()`s, `pin()`s, etc. REVERT: d561555930a Auto merge of #86806 - GuillaumeGomez:rollup-pr5r37w, r=GuillaumeGomez REVERT: 03e7b17009f Fix double import in wasm thread REVERT: aaa4d5762cb Rollup merge of #86797 - inquisitivecrystal:bound-cloned, r=jyn514 REVERT: 80ef0636c41 Rollup merge of #86714 - iwahbe:add-linked-list-cursor-end-methods, r=Amanieu REVERT: c5786a32197 Auto merge of #85746 - m-ou-se:io-error-other, r=joshtriplett REVERT: 7827dbf868b add track_path::path fn for proc-macro usage REVERT: fdbc11a84d3 add owned locked stdio handles REVERT: 11a522ea875 Stabilize `Bound::cloned()` REVERT: b08847a5fd4 Stabilize `Seek::rewind` REVERT: c81e8085a1f Rollup merge of #86785 - lf-:dead-code, r=Mark-Simulacrum REVERT: f4964968b63 Rollup merge of #86783 - mark-i-m:mutex-drop-unsized, r=Xanewok REVERT: 3f89efd2945 Document iteration order of `retain` functions REVERT: e1fdab929a0 Update BTreeSet::drain_filter documentation REVERT: 832d44709e6 Implement changes suggested by @Amanieu REVERT: 2e0e61a4547 proc_macro/bridge: Remove dead code Slice type REVERT: 641873e9eac Make the specialized Fuse still deal with None REVERT: 2c77ad73e49 Remove "length" doc aliases REVERT: 111e8819f7e Remove "delete" doc aliases REVERT: 2585af31d29 Remove alloc/malloc/calloc/realloc doc aliases REVERT: bccebd51250 alloc: `RawVec::shrink` can be in `no_global_oom_handling`. REVERT: e5d397dd799 impl Default, Copy, Clone for std::io::Sink and Empty REVERT: 0321eef895f Rename variable REVERT: d370f722964 Use diagnostic items to check for Send, UnwindSafe and RefUnwindSafe traits REVERT: cae76944897 Remove lang items Send, UnwindSafe and RefUnwindSafe REVERT: 7bba99bc8ff Add non-mutable methods to `Cursor` REVERT: dbbe7e3632b add head/tail methods to linked list mutable cursor REVERT: 3c74c3443c3 Update to new bootstrap compiler REVERT: 1d70b30eab1 Auto merge of #82624 - ojeda:rwlock-example-deadlock, r=JohnTitor REVERT: 01758cdc766 Auto merge of #86655 - jonas-schievink:const-arguments-as-str, r=kennytm REVERT: 789d9a9c398 Add reference to tracking issue #86302 for const_ptr_write REVERT: 1d4fdd5bf01 Add reference to issue for const_intrinsic_copy in ptr::write REVERT: a5471546b4a Revert "Revert tests added by PR 81167." REVERT: fe60485cf3f Revert "Revert effects of PRs 81167 and 83091." REVERT: 66d3141999f Make `fmt::Arguments::as_str` unstably const REVERT: a68a5b97c20 Auto merge of #86586 - Smittyvb:https-everywhere, r=petrochenkov REVERT: 32866e71465 Auto merge of #86637 - ehuss:spellings, r=dtolnay REVERT: 5df4a45ec31 Fix a few misspellings. REVERT: e89f6082229 Add Integer::{log,log2,log10} variants REVERT: 1690c3aa606 Rollup merge of #86592 - jhpratt:non_exhaustive, r=JohnTitor REVERT: cd6fb91df80 Auto merge of #86151 - scottmcm:simple-hash-of, r=joshtriplett REVERT: aab776c2eab Fix grammar mistake REVERT: 4d6b75c04f4 Add another example REVERT: 76431201ef0 Document the various methods of `core::task::Poll` REVERT: d74aa4e7c7b Auto merge of #86467 - ChrisDenton:win-env-clear, r=JohnTitor REVERT: ecaa3335ca1 Partially stabilize `const_slice_first_last` REVERT: 09632563f6a Test that `env_clear` works on Windows REVERT: 9eb308c3756 Use `hash_one` to simplify some other doctests REVERT: 66f99670551 Add tracking issue and rename to hash_one REVERT: d87cbce3582 Add `BuildHasher::hash_of` as unstable REVERT: bce72d60022 Use `#[non_exhaustive]` where appropriate REVERT: 0e2d9fe8bdf Rollup merge of #86415 - Kmeakin:iterator-associativity-docs, r=dtolnay REVERT: 2b39c8ef886 Use HTTPS links where possible REVERT: 05951c26e8d Add `core::stream::from_iter` REVERT: 72a3c9eed03 Auto merge of #86386 - inquisitivecrystal:better-errors-for-display-traits-v3, r=estebank REVERT: a35c1172735 Rollup merge of #86521 - the8472:add-footgun-comments, r=RalfJung REVERT: 00f6c728214 Add comments around code where ordering is important due for panic-safety REVERT: 9b76d36cbf7 Auto merge of #84910 - eopb:stabilize_int_error_matching, r=yaahc REVERT: 59c6ef31342 postpone stabilizaton by one release REVERT: b5ab48db6fb Change Debug unimplemented message per request REVERT: e4901abb5de Auto merge of #86527 - JohnTitor:rollup-cbu78g4, r=JohnTitor REVERT: 03b807eebe2 Rollup merge of #86367 - m-ou-se:fix-abs-comment, r=scottmcm REVERT: fd9ce15ffb3 Rollup merge of #86114 - JDuchniewicz:feat/panic-frame-fmt, r=yaahc REVERT: 7cce128ed90 Rollup merge of #86037 - soerenmeier:cursor_remaining, r=yaahc REVERT: 9f864f964a0 Rollup merge of #85182 - CDirkx:available_concurrency, r=JohnTitor REVERT: 43324c71f34 Rollup merge of #85054 - jethrogb:jb/sgx-inline-asm, r=Amanieu REVERT: 00b09480836 Auto merge of #86383 - shamatar:slice_len_lowering, r=bjorn3 REVERT: 6cc015f9621 BTree: consistently avoid unwrap_unchecked in iterators REVERT: a07db1e85e1 Rollup merge of #86495 - r00ster91:patch-11, r=petrochenkov REVERT: 95da1b3dadc Merge `sys_common::bytestring` into `os_str_bytes` REVERT: 9dd07017d41 Use `Unsupported` on platforms where `available_concurrency` is not implemented. REVERT: 35023bf5a6a Move `available_concurrency` implementation to `sys` REVERT: 239689f18cd Auto merge of #86502 - JohnTitor:rollup-wge0f3x, r=JohnTitor REVERT: 1c588eb8bb2 Rollup merge of #86452 - the8472:fix-zip-drop-safety, r=m-ou-se REVERT: 8e6d6686686 Rollup merge of #85637 - RalfJung:partial-ord, r=m-ou-se REVERT: d8453211362 Auto merge of #85980 - ssomers:btree_cleanup_LeafRange, r=Mark-Simulacrum REVERT: 4d78cd64af3 Improve documentation REVERT: 3485d90252b Auto merge of #84967 - CDirkx:os_str_ext, r=m-ou-se REVERT: 91568246c2f Squashed implementation of the pass REVERT: cf4b8722925 Add documentation/example to Extend impl REVERT: 3e11999aa40 disable test on platforms that don't support unwinding REVERT: 5560ae18de3 Add comment to `std::os::unix::ffi::os_str` explaining that the module is reused on other platforms. REVERT: 98085cfa517 Make `os_str_bytes::{Buf, Slice}` `pub` and `repr(transparent)` REVERT: c63a0d456d1 Move `OsStringExt` and `OsStrExt` to `std::os` REVERT: 0db3c7dbda7 Auto merge of #86463 - fee1-dead:fixed-encode_wide, r=m-ou-se REVERT: 453a8753409 Automatic exponential formatting in Debug REVERT: 9f263d61fdc Auto merge of #86433 - paolobarbolini:string-overlapping, r=m-ou-se REVERT: fb3e0ac4d23 Auto merge of #86034 - nagisa:nagisa/rt-soundness, r=m-ou-se REVERT: ee71247c455 Clarify that certain intrinsics are not unsafe REVERT: 6b8c4d961cc Remove `Ipv4Addr::is_ietf_protocol_assignment` REVERT: 2a48d83b58c Change entry point to 🛡️ against 💥 💥-payloads REVERT: 4c561f90fc9 Windows: Fix `Command::env_clear` so it works REVERT: 4e6616c3e8f Auto merge of #86426 - hi-rustin:rustin-patch-lint-warn, r=Aaron1011 REVERT: f2be6b73706 Account for self.extra in size_hint for EncodeWide REVERT: 1862bbfd016 Rollup merge of #86453 - akiselev:patch-1, r=dtolnay REVERT: a206e0e7710 Rollup merge of #86397 - Eosis:alter-cell-docs, r=JohnTitor REVERT: 988ef3390ec Rollup merge of #86359 - fee1-dead:f64-junit-formatter, r=JohnTitor REVERT: e618983480b Rollup merge of #86136 - m-ou-se:proc-macro-open-close-span, r=m-ou-se REVERT: 208fe522f21 Fixed typo `BorroeError` => `BorrowError` in RefCell docs REVERT: 87c6e48a9bd fix panic-safety in specialized Zip::next_back REVERT: b1aa3fc817c Auto merge of #85815 - YuhanLiin:buf-read-data-left, r=m-ou-se REVERT: 04bdf515acb Auto merge of #85747 - maxwase:path-symlinks-methods, r=m-ou-se REVERT: dbff11f3002 Add `IpAddr::is_benchmarking` REVERT: 387527acff3 Add `Ipv6Addr::is_benchmarking` REVERT: 57fcf182899 Use `copy_nonoverlapping` to copy `bytes` in `String::insert_bytes` REVERT: 37444f03789 Lint for unused borrows as part of UNUSED_MUST_USE REVERT: 1ff146a8a00 Rollup merge of #86357 - de-vri-es:simplify-repeated-cfg-ifs, r=m-ou-se REVERT: 3c258b06066 Rollup merge of #86202 - a1phyr:spec_io_bytes_size_hint, r=m-ou-se REVERT: dd6291c0306 Rollup merge of #85925 - clarfonthey:lerp, r=m-ou-se REVERT: ca5fb844e7a Document associativity of iterator folds. REVERT: 1d596312fd8 Rely on libc for correct integer types in os/unix/net/ancillary.rs. REVERT: 3c787ffcf7c Rollup merge of #86389 - kpreid:sum, r=scottmcm REVERT: 452c6f5605a Rollup merge of #85970 - jsha:remove-methods-implementors, r=GuillaumeGomez REVERT: 5833c69d942 Rollup merge of #85802 - Thomasdezeeuw:ioslice-advance, r=m-ou-se REVERT: f505d46c30d Rollup merge of #85663 - fee1-dead:document-arc-from, r=m-ou-se REVERT: 7cace2f7f92 Alter std::cell::Cell::get_mut documentation REVERT: f2a9b963b7a Fix comment about rustc_inherit_overflow_checks in abs(). REVERT: 83bb464040e Add doc(hidden) to all __iterator_get_unchecked REVERT: c04ad02f083 Make `sum()` and `product()` hyperlinks refer to `Iterator` methods. REVERT: 624386c7e24 Rollup merge of #86372 - snoyberg:patch-1, r=jonas-schievink REVERT: 1964bc5426b Rollup merge of #86141 - amorison:link-ref-in-doc-dyn-keyword, r=kennytm REVERT: c62e3d6fb4b Rollup merge of #86140 - scottmcm:array-hash-facepalm, r=kennytm REVERT: 2184a4c099e Use as_secs_f64 in JunitFormatter REVERT: b4fa6dc47d4 Typo correction: s/is/its REVERT: 7bb3bb0c200 Auto merge of #86179 - the8472:revere-path-cmp, r=kennytm REVERT: 1262a775aa0 Improve errors for missing Debug and Display impls REVERT: fdf3a2f9d1e Rollup merge of #86209 - tlyu:option-doc-typos, r=JohnTitor REVERT: d530eec8d51 Rollup merge of #86200 - qwerty01:clone-doc-update, r=JohnTitor REVERT: 684af02d407 Auto merge of #85820 - CDirkx:is_unicast_site_local, r=joshtriplett REVERT: bbc24693e90 Split MaybeUninit::write into new feature gate and stabilize it REVERT: e8e3ccf6957 Auto merge of #85406 - VillSnow:integrate_binary_search, r=JohnTitor REVERT: 89a4d838af0 Rollup merge of #86314 - Veykril:patch-2, r=JohnTitor REVERT: 5ce23d1a142 Rollup merge of #86294 - m-ou-se:edition-prelude-modules, r=joshtriplett REVERT: ce5e3271318 Rollup merge of #86220 - est31:maybe-uninit-extra, r=RalfJung REVERT: 70b50631af6 Rollup merge of #85792 - mjptree:refactor-windows-sockets, r=JohnTitor REVERT: 1b63a90dd24 Rollup merge of #85608 - scottmcm:stabilize-control-flow-enum-basics, r=m-ou-se REVERT: 45dc8389a9a Rollup merge of #82179 - mbartlett21:patch-5, r=joshtriplett REVERT: 08139753bf2 Rollup merge of #80269 - pickfire:patch-4, r=joshtriplett REVERT: 096afb6a178 Update keyword_docs.rs REVERT: cb4e1a2df55 Mention nested unzip in its documentation REVERT: c494c3467ef Stabilize {std, core}::prelude::rust_*. REVERT: 049c5b9f9b1 Auto merge of #86273 - JohnTitor:stabilize-maybe-uninit-ref, r=RalfJung REVERT: e19e03c84ae Improve maybe_uninit_extra docs REVERT: bf04c1bbbe1 Auto merge of #85758 - petertodd:2021-revert-manuallydrop-clone-from, r=m-ou-se REVERT: bd93489eddf run tidy REVERT: 339f50d2706 stabilize `int_error_matching` REVERT: b2da5dbf1de Stabilize `maybe_uninit_ref` REVERT: 174b4ab97bf Auto merge of #86233 - JohnTitor:stabilize-simd-x86-bittest, r=Amanieu REVERT: a9c13c744e1 Merge branch 'master' of https://github.com/rust-lang/rust REVERT: 26aa7a4e374 Update `stdarch` submodule to stabilize `simd_x86_bittest` feature REVERT: 287cfbf5834 Auto merge of #82703 - iago-lito:nonzero_add_mul_pow, r=m-ou-se REVERT: a308789d033 Remove "generic type" in boxed.rs REVERT: 1fe52f3a034 Stabilize `str::from_utf8_unchecked` as `const` REVERT: 79c2fed12a9 Auto merge of #86204 - alexcrichton:wasm-simd-stable, r=Amanieu REVERT: 39eeca3c954 std: Stabilize wasm simd intrinsics REVERT: 33d0a402532 Auto merge of #85630 - gilescope:to_digit_speedup3, r=nagisa REVERT: 4bb2411d05b Specialize `io::Bytes::size_hint` for more types REVERT: 72965c0337e Updates `Clone` docs for `Copy` comparison. REVERT: 755b709a282 Rollup merge of #86111 - spookyvision:master, r=JohnTitor REVERT: dfc7aa3cf63 Rollup merge of #86051 - erer1243:update_move_keyword_docs, r=Mark-Simulacrum REVERT: 6ab90521c33 Updated code examples and wording git-subtree-dir: library git-subtree-split: 3e6029532f5ceafb5428725f651179c6de7f6e1e --- Cargo.lock | 146 +- Cargo.toml | 4 +- alloc/Cargo.toml | 32 +- alloc/src/alloc.rs | 39 +- alloc/src/borrow.rs | 18 +- alloc/src/boxed.rs | 211 +- alloc/src/boxed/convert.rs | 32 +- alloc/src/boxed/thin.rs | 22 +- alloc/src/bstr.rs | 682 +++ alloc/src/collections/binary_heap/mod.rs | 98 +- alloc/src/collections/btree/append.rs | 10 +- alloc/src/collections/btree/borrow.rs | 10 +- .../collections/btree/dedup_sorted_iter.rs | 4 +- alloc/src/collections/btree/fix.rs | 13 +- alloc/src/collections/btree/map.rs | 40 +- alloc/src/collections/btree/map/entry.rs | 110 +- alloc/src/collections/btree/mem.rs | 4 +- alloc/src/collections/btree/merge_iter.rs | 10 +- alloc/src/collections/btree/mod.rs | 4 +- alloc/src/collections/btree/navigate.rs | 72 +- alloc/src/collections/btree/node.rs | 217 +- alloc/src/collections/btree/node/tests.rs | 12 +- alloc/src/collections/btree/remove.rs | 2 +- alloc/src/collections/btree/search.rs | 21 +- alloc/src/collections/btree/set.rs | 123 +- alloc/src/collections/btree/set/entry.rs | 388 ++ alloc/src/collections/btree/set/tests.rs | 16 +- alloc/src/collections/btree/split.rs | 8 +- alloc/src/collections/linked_list.rs | 18 +- alloc/src/collections/linked_list/tests.rs | 30 +- alloc/src/collections/mod.rs | 24 + alloc/src/collections/vec_deque/mod.rs | 71 +- .../src/collections/vec_deque/spec_extend.rs | 2 + .../collections/vec_deque/spec_from_iter.rs | 1 + alloc/src/collections/vec_deque/tests.rs | 7 +- alloc/src/ffi/c_str.rs | 64 +- alloc/src/ffi/mod.rs | 2 +- alloc/src/fmt.rs | 2 + alloc/src/lib.rs | 68 +- alloc/src/macros.rs | 30 +- alloc/src/{raw_vec.rs => raw_vec/mod.rs} | 107 +- alloc/src/raw_vec/tests.rs | 3 +- alloc/src/rc.rs | 342 +- alloc/src/slice.rs | 187 +- alloc/src/str.rs | 3 - alloc/src/string.rs | 390 +- alloc/src/sync.rs | 86 +- alloc/src/task.rs | 1 - alloc/src/testing/mod.rs | 3 - alloc/src/vec/drain.rs | 2 +- alloc/src/vec/extract_if.rs | 58 +- alloc/src/vec/in_place_collect.rs | 26 +- alloc/src/vec/in_place_drop.rs | 2 +- alloc/src/vec/into_iter.rs | 9 +- alloc/src/vec/is_zero.rs | 15 +- alloc/src/vec/mod.rs | 268 +- alloc/tests/rc.rs | 260 - alloctests/Cargo.toml | 47 + {alloc => alloctests}/benches/binary_heap.rs | 0 {alloc => alloctests}/benches/btree/map.rs | 25 +- {alloc => alloctests}/benches/btree/mod.rs | 0 {alloc => alloctests}/benches/btree/set.rs | 8 +- {alloc => alloctests}/benches/lib.rs | 3 +- {alloc => alloctests}/benches/linked_list.rs | 0 {alloc => alloctests}/benches/slice.rs | 49 +- {alloc => alloctests}/benches/str.rs | 0 {alloc => alloctests}/benches/string.rs | 0 {alloc => alloctests}/benches/vec.rs | 13 +- {alloc => alloctests}/benches/vec_deque.rs | 0 .../benches/vec_deque_append.rs | 0 alloctests/lib.rs | 93 + .../src => alloctests}/testing/crash_test.rs | 20 +- alloctests/testing/mod.rs | 3 + .../src => alloctests}/testing/ord_chaos.rs | 10 +- {alloc/src => alloctests}/testing/rng.rs | 6 +- .../tests/alloc_test.rs | 5 +- {alloc => alloctests}/tests/arc.rs | 5 +- {alloc => alloctests}/tests/autotraits.rs | 0 {alloc => alloctests}/tests/borrow.rs | 0 {alloc => alloctests}/tests/boxed.rs | 2 +- {alloc => alloctests}/tests/btree_set_hash.rs | 0 {alloc => alloctests}/tests/c_str.rs | 0 .../tests.rs => alloctests/tests/c_str2.rs | 9 +- .../tests/collections/binary_heap.rs | 10 +- alloctests/tests/collections/mod.rs | 1 + {alloc => alloctests}/tests/const_fns.rs | 0 {alloc => alloctests}/tests/cow_str.rs | 0 {alloc => alloctests}/tests/fmt.rs | 0 {alloc => alloctests}/tests/heap.rs | 0 {alloc => alloctests}/tests/lib.rs | 38 +- {alloc => alloctests}/tests/linked_list.rs | 0 .../tests/misc_tests.rs | 0 .../src/rc/tests.rs => alloctests/tests/rc.rs | 280 +- {alloc => alloctests}/tests/slice.rs | 5 +- {alloc => alloctests}/tests/sort/ffi_types.rs | 0 .../tests/sort/known_good_stable_sort.rs | 6 +- {alloc => alloctests}/tests/sort/mod.rs | 0 {alloc => alloctests}/tests/sort/patterns.rs | 8 +- {alloc => alloctests}/tests/sort/tests.rs | 11 +- {alloc => alloctests}/tests/sort/zipf.rs | 4 +- {alloc => alloctests}/tests/str.rs | 192 +- {alloc => alloctests}/tests/string.rs | 35 +- .../sync/tests.rs => alloctests/tests/sync.rs | 15 +- {alloc => alloctests}/tests/task.rs | 0 alloctests/tests/testing/crash_test.rs | 80 + alloctests/tests/testing/mod.rs | 1 + {alloc => alloctests}/tests/thin_box.rs | 3 +- {alloc => alloctests}/tests/vec.rs | 108 +- {alloc => alloctests}/tests/vec_deque.rs | 39 + .../tests/vec_deque_alloc_error.rs | 0 backtrace | 2 +- core/Cargo.toml | 19 +- core/src/alloc/global.rs | 2 +- core/src/alloc/layout.rs | 23 +- core/src/alloc/mod.rs | 58 +- core/src/any.rs | 132 +- core/src/arch.rs | 36 +- core/src/array/iter.rs | 8 +- core/src/array/mod.rs | 27 +- core/src/bool.rs | 49 + core/src/bstr.rs | 583 ++ core/src/cell.rs | 130 +- core/src/cell/lazy.rs | 4 +- core/src/cell/once.rs | 65 +- core/src/char/convert.rs | 16 +- core/src/char/methods.rs | 50 +- core/src/char/mod.rs | 10 + core/src/clone.rs | 67 +- core/src/cmp.rs | 202 +- core/src/contracts.rs | 20 + core/src/convert/mod.rs | 3 +- core/src/error.rs | 32 +- core/src/escape.rs | 22 +- core/src/ffi/c_str.rs | 135 +- core/src/ffi/mod.rs | 152 +- core/src/ffi/primitives.rs | 181 + core/src/ffi/va_list.rs | 46 +- core/src/fmt/builders.rs | 1 + core/src/fmt/float.rs | 18 +- core/src/fmt/mod.rs | 534 +- core/src/fmt/num.rs | 164 +- core/src/fmt/rt.rs | 58 +- core/src/future/async_drop.rs | 3 +- core/src/future/future.rs | 2 +- core/src/future/mod.rs | 8 +- core/src/hash/mod.rs | 11 +- core/src/hash/sip.rs | 6 +- core/src/hint.rs | 234 +- core/src/intrinsics/fallback.rs | 150 + core/src/intrinsics/mir.rs | 33 + core/src/intrinsics/mod.rs | 2712 ++++----- core/src/intrinsics/simd.rs | 1382 ++--- core/src/io/borrowed_buf.rs | 14 +- core/src/iter/adapters/filter_map.rs | 4 +- core/src/iter/adapters/flatten.rs | 34 +- core/src/iter/adapters/map_windows.rs | 4 +- core/src/iter/adapters/zip.rs | 8 +- core/src/iter/mod.rs | 6 +- core/src/iter/sources.rs | 2 +- core/src/iter/sources/from_fn.rs | 6 +- core/src/iter/sources/once.rs | 3 +- core/src/iter/sources/once_with.rs | 14 +- core/src/iter/sources/successors.rs | 15 +- core/src/iter/traits/collect.rs | 354 +- core/src/iter/traits/iterator.rs | 36 +- core/src/lib.rs | 54 +- core/src/macros/mod.rs | 149 +- core/src/marker.rs | 299 +- core/src/marker/variance.rs | 272 + core/src/mem/maybe_uninit.rs | 641 +- core/src/mem/mod.rs | 69 +- core/src/mem/transmutability.rs | 11 +- core/src/net/display_buffer.rs | 10 +- core/src/net/ip_addr.rs | 85 +- core/src/net/socket_addr.rs | 16 +- core/src/num/bignum.rs | 5 +- core/src/num/dec2flt/common.rs | 27 +- core/src/num/dec2flt/decimal.rs | 419 +- core/src/num/dec2flt/decimal_seq.rs | 379 ++ core/src/num/dec2flt/float.rs | 272 +- core/src/num/dec2flt/fpu.rs | 9 +- core/src/num/dec2flt/lemire.rs | 22 +- core/src/num/dec2flt/mod.rs | 37 +- core/src/num/dec2flt/number.rs | 88 - core/src/num/dec2flt/parse.rs | 10 +- core/src/num/dec2flt/slow.rs | 28 +- core/src/num/dec2flt/table.rs | 9 +- core/src/num/f128.rs | 21 +- core/src/num/f16.rs | 21 +- core/src/num/f32.rs | 64 +- core/src/num/f64.rs | 50 +- core/src/num/flt2dec/mod.rs | 48 +- core/src/num/flt2dec/strategy/dragon.rs | 10 +- core/src/num/flt2dec/strategy/grisu.rs | 10 +- core/src/num/int_log10.rs | 28 +- core/src/num/int_macros.rs | 225 +- core/src/num/int_sqrt.rs | 8 +- core/src/num/mod.rs | 431 +- core/src/num/niche_types.rs | 178 + core/src/num/nonzero.rs | 214 +- core/src/num/overflow_panic.rs | 16 +- core/src/num/uint_macros.rs | 372 +- core/src/num/wrapping.rs | 38 +- core/src/ops/arith.rs | 16 +- core/src/ops/async_function.rs | 19 +- core/src/ops/bit.rs | 2 +- core/src/ops/control_flow.rs | 38 +- core/src/ops/deref.rs | 58 +- core/src/ops/drop.rs | 3 +- core/src/ops/index_range.rs | 14 +- core/src/ops/mod.rs | 7 +- core/src/ops/range.rs | 266 +- core/src/ops/try_trait.rs | 7 +- core/src/option.rs | 21 +- core/src/panic.rs | 3 +- core/src/panic/panic_info.rs | 2 +- core/src/panicking.rs | 47 +- core/src/pat.rs | 64 +- core/src/pin.rs | 42 +- core/src/prelude/mod.rs | 51 +- core/src/prelude/{common.rs => v1.rs} | 15 +- core/src/primitive_docs.rs | 52 +- core/src/ptr/alignment.rs | 25 +- core/src/ptr/const_ptr.rs | 143 +- core/src/ptr/metadata.rs | 10 +- core/src/ptr/mod.rs | 156 +- core/src/ptr/mut_ptr.rs | 170 +- core/src/ptr/non_null.rs | 178 +- core/src/ptr/unique.rs | 1 - core/src/range.rs | 31 +- core/src/result.rs | 21 +- core/src/slice/ascii.rs | 74 +- core/src/slice/cmp.rs | 6 +- core/src/slice/iter.rs | 103 +- core/src/slice/iter/macros.rs | 39 +- core/src/slice/memchr.rs | 9 +- core/src/slice/mod.rs | 694 ++- core/src/slice/raw.rs | 12 +- core/src/slice/rotate.rs | 336 +- core/src/slice/sort/shared/pivot.rs | 4 +- core/src/slice/sort/shared/smallsort.rs | 47 +- core/src/slice/sort/stable/drift.rs | 4 +- core/src/slice/sort/stable/merge.rs | 2 +- core/src/slice/sort/stable/mod.rs | 30 +- core/src/slice/sort/stable/quicksort.rs | 6 +- core/src/slice/sort/unstable/quicksort.rs | 10 +- core/src/str/converts.rs | 7 +- core/src/str/count.rs | 2 +- core/src/str/lossy.rs | 4 +- core/src/str/mod.rs | 190 +- core/src/str/pattern.rs | 5 +- core/src/str/validations.rs | 3 +- core/src/sync/atomic.rs | 452 +- core/src/task/wake.rs | 23 +- core/src/time.rs | 101 +- core/src/ub_checks.rs | 8 +- core/src/unicode/mod.rs | 2 + core/src/unicode/printable.py | 53 +- core/src/unicode/unicode_data.rs | 3 - core/src/unsafe_binder.rs | 25 + core/tests/fmt/mod.rs | 45 - core/tests/num/dec2flt/float.rs | 33 - core/tests/num/i128.rs | 1 - core/tests/num/i16.rs | 1 - core/tests/num/i64.rs | 1 - core/tests/num/i8.rs | 1 - core/tests/num/uint_macros.rs | 306 - coretests/Cargo.toml | 27 + {core => coretests}/benches/any.rs | 0 {core => coretests}/benches/array.rs | 0 {core => coretests}/benches/ascii.rs | 0 {core => coretests}/benches/ascii/is_ascii.rs | 53 +- {core => coretests}/benches/char/methods.rs | 0 {core => coretests}/benches/char/mod.rs | 0 {core => coretests}/benches/fmt.rs | 13 +- {core => coretests}/benches/hash/mod.rs | 0 {core => coretests}/benches/hash/sip.rs | 0 {core => coretests}/benches/iter.rs | 5 +- {core => coretests}/benches/lib.rs | 0 .../benches/net/addr_parser.rs | 0 {core => coretests}/benches/net/mod.rs | 0 .../benches/num/dec2flt/mod.rs | 0 .../benches/num/flt2dec/mod.rs | 0 .../benches/num/flt2dec/strategy/dragon.rs | 0 .../benches/num/flt2dec/strategy/grisu.rs | 0 .../benches/num/int_log/mod.rs | 8 +- .../benches/num/int_pow/mod.rs | 6 +- .../benches/num/int_sqrt/mod.rs | 9 +- {core => coretests}/benches/num/mod.rs | 0 {core => coretests}/benches/ops.rs | 0 {core => coretests}/benches/pattern.rs | 0 {core => coretests}/benches/slice.rs | 8 +- {core => coretests}/benches/str.rs | 0 {core => coretests}/benches/str/char_count.rs | 0 {core => coretests}/benches/str/corpora.rs | 0 {core => coretests}/benches/str/debug.rs | 0 {core => coretests}/benches/str/iter.rs | 0 {core => coretests}/benches/tuple.rs | 0 coretests/lib.rs | 1 + {core => coretests}/tests/alloc.rs | 1 - {core => coretests}/tests/any.rs | 8 + {core => coretests}/tests/array.rs | 0 {core => coretests}/tests/ascii.rs | 0 {core => coretests}/tests/ascii_char.rs | 12 + {core => coretests}/tests/asserting.rs | 0 {core => coretests}/tests/async_iter/mod.rs | 0 {core => coretests}/tests/atomic.rs | 2 - {core => coretests}/tests/bool.rs | 8 +- coretests/tests/bstr.rs | 52 + {core => coretests}/tests/cell.rs | 0 {core => coretests}/tests/char.rs | 3 +- {core => coretests}/tests/clone.rs | 0 {core => coretests}/tests/cmp.rs | 0 {core => coretests}/tests/const_ptr.rs | 0 {core => coretests}/tests/convert.rs | 0 {core => coretests}/tests/error.rs | 0 {core => coretests}/tests/ffi.rs | 0 {core => coretests}/tests/ffi/cstr.rs | 0 {core => coretests}/tests/fmt/builders.rs | 0 {core => coretests}/tests/fmt/float.rs | 0 coretests/tests/fmt/mod.rs | 82 + {core => coretests}/tests/fmt/num.rs | 0 {core => coretests}/tests/future.rs | 0 {core => coretests}/tests/hash/mod.rs | 18 +- {core => coretests}/tests/hash/sip.rs | 4 +- {core => coretests}/tests/intrinsics.rs | 68 + {core => coretests}/tests/io/borrowed_buf.rs | 4 +- {core => coretests}/tests/io/mod.rs | 0 .../tests/iter/adapters/array_chunks.rs | 0 .../tests/iter/adapters/by_ref_sized.rs | 0 .../tests/iter/adapters/chain.rs | 0 .../tests/iter/adapters/cloned.rs | 0 .../tests/iter/adapters/copied.rs | 0 .../tests/iter/adapters/cycle.rs | 0 .../tests/iter/adapters/enumerate.rs | 0 .../tests/iter/adapters/filter.rs | 0 .../tests/iter/adapters/filter_map.rs | 0 .../tests/iter/adapters/flat_map.rs | 0 .../tests/iter/adapters/flatten.rs | 0 .../tests/iter/adapters/fuse.rs | 0 .../tests/iter/adapters/inspect.rs | 0 .../tests/iter/adapters/intersperse.rs | 0 .../tests/iter/adapters/map.rs | 0 .../tests/iter/adapters/map_windows.rs | 9 +- .../tests/iter/adapters/mod.rs | 0 .../tests/iter/adapters/peekable.rs | 0 .../tests/iter/adapters/scan.rs | 0 .../tests/iter/adapters/skip.rs | 0 .../tests/iter/adapters/skip_while.rs | 0 .../tests/iter/adapters/step_by.rs | 0 .../tests/iter/adapters/take.rs | 2 +- .../tests/iter/adapters/take_while.rs | 0 .../tests/iter/adapters/zip.rs | 0 {core => coretests}/tests/iter/mod.rs | 0 {core => coretests}/tests/iter/range.rs | 0 {core => coretests}/tests/iter/sources.rs | 0 .../tests/iter/traits/accum.rs | 0 .../tests/iter/traits/double_ended.rs | 0 .../tests/iter/traits/iterator.rs | 25 + {core => coretests}/tests/iter/traits/mod.rs | 0 {core => coretests}/tests/iter/traits/step.rs | 0 {core => coretests}/tests/lazy.rs | 0 {core => coretests}/tests/lib.rs | 28 +- {core => coretests}/tests/macros.rs | 53 +- {core => coretests}/tests/manually_drop.rs | 0 {core => coretests}/tests/mem.rs | 34 +- {core => coretests}/tests/net/ip_addr.rs | 10 + {core => coretests}/tests/net/mod.rs | 0 {core => coretests}/tests/net/parser.rs | 0 {core => coretests}/tests/net/socket_addr.rs | 0 {core => coretests}/tests/nonzero.rs | 101 +- {core => coretests}/tests/num/bignum.rs | 0 {core => coretests}/tests/num/const_from.rs | 0 coretests/tests/num/dec2flt/decimal.rs | 28 + coretests/tests/num/dec2flt/decimal_seq.rs | 30 + coretests/tests/num/dec2flt/float.rs | 73 + .../tests/num/dec2flt/lemire.rs | 10 +- {core => coretests}/tests/num/dec2flt/mod.rs | 2 + .../tests/num/dec2flt/parse.rs | 41 +- .../tests/num/float_iter_sum_identity.rs | 0 .../tests/num/flt2dec/estimator.rs | 0 {core => coretests}/tests/num/flt2dec/mod.rs | 32 +- .../tests/num/flt2dec/random.rs | 12 +- .../tests/num/flt2dec/strategy/dragon.rs | 0 .../tests/num/flt2dec/strategy/grisu.rs | 0 coretests/tests/num/i128.rs | 1 + coretests/tests/num/i16.rs | 1 + {core => coretests}/tests/num/i32.rs | 2 +- coretests/tests/num/i64.rs | 1 + coretests/tests/num/i8.rs | 1 + {core => coretests}/tests/num/ieee754.rs | 0 {core => coretests}/tests/num/int_log.rs | 75 +- {core => coretests}/tests/num/int_macros.rs | 298 +- {core => coretests}/tests/num/int_sqrt.rs | 0 {core => coretests}/tests/num/midpoint.rs | 0 {core => coretests}/tests/num/mod.rs | 0 {core => coretests}/tests/num/nan.rs | 0 {core => coretests}/tests/num/ops.rs | 52 +- {core => coretests}/tests/num/u128.rs | 0 {core => coretests}/tests/num/u16.rs | 0 {core => coretests}/tests/num/u32.rs | 0 {core => coretests}/tests/num/u64.rs | 0 {core => coretests}/tests/num/u8.rs | 0 coretests/tests/num/uint_macros.rs | 519 ++ {core => coretests}/tests/num/wrapping.rs | 2 - {core => coretests}/tests/ops.rs | 0 {core => coretests}/tests/ops/control_flow.rs | 0 .../tests/ops/from_residual.rs | 0 {core => coretests}/tests/option.rs | 0 {core => coretests}/tests/panic.rs | 0 {core => coretests}/tests/panic/location.rs | 0 {core => coretests}/tests/pattern.rs | 0 {core => coretests}/tests/pin.rs | 4 +- {core => coretests}/tests/pin_macro.rs | 0 {core => coretests}/tests/ptr.rs | 103 +- {core => coretests}/tests/result.rs | 0 {core => coretests}/tests/simd.rs | 0 {core => coretests}/tests/slice.rs | 222 +- {core => coretests}/tests/str.rs | 0 {core => coretests}/tests/str_lossy.rs | 0 {core => coretests}/tests/task.rs | 0 {core => coretests}/tests/time.rs | 0 {core => coretests}/tests/tuple.rs | 0 {core => coretests}/tests/unicode.rs | 0 {core => coretests}/tests/waker.rs | 0 panic_abort/src/android.rs | 18 +- panic_abort/src/lib.rs | 35 +- panic_abort/src/zkvm.rs | 6 +- panic_unwind/Cargo.toml | 5 +- panic_unwind/src/dummy.rs | 4 +- panic_unwind/src/emcc.rs | 67 +- panic_unwind/src/gcc.rs | 46 +- panic_unwind/src/hermit.rs | 20 +- panic_unwind/src/lib.rs | 17 +- panic_unwind/src/miri.rs | 10 +- panic_unwind/src/seh.rs | 124 +- portable-simd/.github/workflows/ci.yml | 125 +- portable-simd/.github/workflows/doc.yml | 2 +- portable-simd/.gitignore | 1 + portable-simd/Cargo.toml | 6 + portable-simd/Cross.toml | 2 + portable-simd/crates/core_simd/Cargo.toml | 3 +- .../crates/core_simd/src/lane_count.rs | 8 +- portable-simd/crates/core_simd/src/lib.rs | 4 +- portable-simd/crates/core_simd/src/masks.rs | 55 - .../crates/core_simd/src/masks/bitmask.rs | 17 - .../crates/core_simd/src/masks/full_masks.rs | 63 +- portable-simd/crates/core_simd/src/ops.rs | 26 +- .../crates/core_simd/src/ops/deref.rs | 3 - .../crates/core_simd/src/ops/unary.rs | 2 - .../crates/core_simd/src/simd/cmp/eq.rs | 2 +- .../crates/core_simd/src/simd/num/float.rs | 31 +- .../crates/core_simd/src/simd/num/int.rs | 43 +- .../crates/core_simd/src/simd/num/uint.rs | 42 +- .../core_simd/src/simd/ptr/const_ptr.rs | 21 + .../crates/core_simd/src/simd/ptr/mut_ptr.rs | 21 + portable-simd/crates/core_simd/src/swizzle.rs | 257 +- .../crates/core_simd/src/swizzle_dyn.rs | 59 +- portable-simd/crates/core_simd/src/vector.rs | 43 +- portable-simd/crates/core_simd/src/vendor.rs | 3 + .../crates/core_simd/src/vendor/arm.rs | 13 +- .../core_simd/src/vendor/loongarch64.rs | 31 + .../crates/core_simd/tests/layout.rs | 35 + portable-simd/crates/core_simd/tests/masks.rs | 43 - .../crates/core_simd/tests/ops_macros.rs | 38 + .../crates/core_simd/tests/swizzle.rs | 18 + portable-simd/crates/test_helpers/Cargo.toml | 3 - portable-simd/crates/test_helpers/src/lib.rs | 216 +- portable-simd/rust-toolchain.toml | 3 + portable-simd/subtree-sync.sh | 52 + proc_macro/src/bridge/arena.rs | 2 +- proc_macro/src/bridge/closure.rs | 6 +- proc_macro/src/bridge/fxhash.rs | 12 +- proc_macro/src/bridge/rpc.rs | 4 +- proc_macro/src/bridge/selfless_reify.rs | 4 +- proc_macro/src/bridge/symbol.rs | 6 - proc_macro/src/lib.rs | 82 +- proc_macro/src/quote.rs | 149 +- profiler_builtins/Cargo.toml | 5 +- profiler_builtins/src/lib.rs | 12 +- rtstartup/rsbegin.rs | 9 +- rtstartup/rsend.rs | 3 +- std/Cargo.toml | 37 +- std/benches/lib.rs | 2 + std/benches/path.rs | 114 + std/benches/time.rs | 46 + std/build.rs | 9 +- std/src/alloc.rs | 10 +- std/src/backtrace.rs | 1 + std/src/bstr.rs | 4 + std/src/collections/hash/map.rs | 91 +- std/src/collections/hash/set.rs | 47 +- std/src/env.rs | 48 +- std/src/env/tests.rs | 120 - std/src/error.rs | 3 - std/src/f128.rs | 101 +- std/src/f16.rs | 101 +- std/src/f32.rs | 78 +- std/src/f64.rs | 78 +- std/src/ffi/mod.rs | 12 +- std/src/ffi/os_str.rs | 72 +- std/src/ffi/os_str/tests.rs | 2 +- std/src/fs.rs | 179 +- std/src/fs/tests.rs | 91 +- std/src/io/buffered/bufreader.rs | 6 +- std/src/io/buffered/bufreader/buffer.rs | 8 +- std/src/io/buffered/bufwriter.rs | 4 +- std/src/io/buffered/linewritershim.rs | 9 +- std/src/io/buffered/tests.rs | 18 +- std/src/io/copy/tests.rs | 1 + std/src/io/cursor.rs | 108 +- std/src/io/error.rs | 87 +- std/src/io/error/repr_bitpacked.rs | 9 +- std/src/io/error/tests.rs | 11 +- std/src/io/impls.rs | 122 +- std/src/io/mod.rs | 40 +- std/src/io/pipe.rs | 260 + std/src/{ => io}/pipe/tests.rs | 5 +- std/src/io/stdio.rs | 38 +- std/src/io/stdio/tests.rs | 7 +- std/src/io/tests.rs | 6 +- std/src/io/util.rs | 33 +- std/src/keyword_docs.rs | 187 +- std/src/lib.rs | 63 +- std/src/macros.rs | 15 - std/src/net/ip_addr.rs | 29 - std/src/net/mod.rs | 2 +- std/src/net/socket_addr.rs | 47 +- std/src/net/tcp.rs | 3 +- std/src/net/test.rs | 40 +- std/src/net/udp.rs | 7 +- std/src/net/udp/tests.rs | 12 +- std/src/num.rs | 28 - std/src/os/darwin/mod.rs | 2 +- std/src/os/emscripten/fs.rs | 2 +- std/src/os/emscripten/raw.rs | 2 - std/src/os/fd/net.rs | 4 +- std/src/os/fd/owned.rs | 46 +- std/src/os/fd/raw.rs | 13 +- std/src/os/fd/tests.rs | 1 - std/src/os/hermit/io/net.rs | 2 +- std/src/os/hurd/fs.rs | 2 +- std/src/os/hurd/mod.rs | 1 + std/src/os/solid/io.rs | 39 +- std/src/os/unix/fs.rs | 5 + std/src/os/unix/fs/tests.rs | 4 +- std/src/os/unix/io/tests.rs | 1 - std/src/os/unix/net/addr.rs | 10 +- std/src/os/unix/net/listener.rs | 2 +- std/src/os/unix/net/tests.rs | 2 +- std/src/os/unix/net/ucred.rs | 14 +- std/src/os/wasi/fs.rs | 16 +- std/src/os/wasi/io/fd.rs | 9 - std/src/os/wasi/io/mod.rs | 4 + std/src/os/wasi/io/raw.rs | 20 - std/src/os/wasi/io/{fd => }/tests.rs | 1 - std/src/os/windows/io/handle.rs | 8 + std/src/os/windows/io/raw.rs | 8 +- std/src/os/windows/io/socket.rs | 49 +- std/src/os/windows/io/tests.rs | 1 - std/src/os/windows/process.rs | 324 +- std/src/os/xous/ffi.rs | 8 +- std/src/os/xous/ffi/definitions.rs | 66 +- std/src/os/xous/services/log.rs | 4 +- std/src/panic.rs | 8 +- std/src/panicking.rs | 56 +- std/src/path.rs | 27 +- std/src/pipe.rs | 128 - std/src/prelude/mod.rs | 60 +- std/src/prelude/{common.rs => v1.rs} | 15 +- std/src/process.rs | 71 +- std/src/process/tests.rs | 149 +- std/src/rt.rs | 75 +- std/src/sync/barrier.rs | 64 +- std/src/sync/lazy_lock.rs | 8 +- std/src/sync/mod.rs | 56 +- std/src/sync/mpmc/mod.rs | 25 +- std/src/sync/mpmc/tests.rs | 734 +-- std/src/sync/mpmc/waker.rs | 2 +- std/src/sync/{mpsc/mod.rs => mpsc.rs} | 13 +- std/src/sync/once_lock.rs | 73 +- std/src/sync/poison.rs | 122 +- std/src/sync/{ => poison}/condvar.rs | 7 +- std/src/sync/{ => poison}/mutex.rs | 145 +- std/src/sync/{ => poison}/once.rs | 9 +- std/src/sync/{ => poison}/rwlock.rs | 131 +- std/src/sync/reentrant_lock.rs | 8 +- std/src/sys/alloc/sgx.rs | 6 +- std/src/sys/alloc/unix.rs | 2 +- std/src/sys/alloc/wasm.rs | 4 +- std/src/sys/alloc/windows/tests.rs | 5 +- std/src/sys/alloc/xous.rs | 4 +- std/src/sys/anonymous_pipe/unix.rs | 3 +- std/src/sys/anonymous_pipe/unsupported.rs | 3 +- std/src/sys/anonymous_pipe/windows.rs | 4 +- std/src/sys/backtrace.rs | 26 +- std/src/sys/cmath.rs | 16 +- .../{sys_common/fs.rs => sys/fs/common.rs} | 2 +- .../sys/{pal/hermit/fs.rs => fs/hermit.rs} | 38 +- std/src/sys/fs/mod.rs | 28 + std/src/sys/{pal/solid/fs.rs => fs/solid.rs} | 41 +- std/src/sys/fs/uefi.rs | 319 + std/src/sys/{pal/unix/fs.rs => fs/unix.rs} | 222 +- std/src/sys/{pal/unix/fs => fs/unix}/tests.rs | 2 +- .../unsupported/fs.rs => fs/unsupported.rs} | 4 + std/src/sys/{pal/wasi/fs.rs => fs/wasi.rs} | 199 +- .../sys/{pal/windows/fs.rs => fs/windows.rs} | 193 +- .../fs => fs/windows}/remove_dir_all.rs | 2 +- .../{pal/solid/io.rs => io/io_slice/iovec.rs} | 13 +- .../io.rs => io/io_slice/unsupported.rs} | 4 - .../{pal/wasi/io.rs => io/io_slice/wasi.rs} | 8 - .../unix/io.rs => io/io_slice/windows.rs} | 39 +- std/src/sys/io/is_terminal/hermit.rs | 6 + std/src/sys/io/is_terminal/isatty.rs | 6 + std/src/sys/io/is_terminal/unsupported.rs | 3 + .../io.rs => io/is_terminal/windows.rs} | 85 +- std/src/sys/io/mod.rs | 44 + std/src/sys/mod.rs | 4 + .../{pal/sgx/net.rs => net/connection/sgx.rs} | 37 +- .../net.rs => sys/net/connection/socket.rs} | 235 +- .../connection/socket/hermit.rs} | 25 +- .../net.rs => net/connection/socket/solid.rs} | 34 +- .../net/connection/socket}/tests.rs | 0 .../net.rs => net/connection/socket/unix.rs} | 29 +- .../connection/socket/wasip2.rs} | 13 +- .../connection/socket/windows.rs} | 38 +- .../net.rs => net/connection/uefi/mod.rs} | 35 - .../net.rs => net/connection/unsupported.rs} | 35 - .../wasi/net.rs => net/connection/wasip1.rs} | 40 +- .../xous/net => net/connection/xous}/dns.rs | 5 +- std/src/sys/net/connection/xous/mod.rs | 48 + .../connection/xous}/tcplistener.rs | 40 +- .../net => net/connection/xous}/tcpstream.rs | 56 +- .../xous/net => net/connection/xous}/udp.rs | 71 +- std/src/sys/net/mod.rs | 41 + std/src/sys/os_str/bytes.rs | 91 +- std/src/sys/os_str/wtf8.rs | 112 +- std/src/sys/pal/common/small_c_string.rs | 2 +- std/src/sys/pal/hermit/fd.rs | 21 +- std/src/sys/pal/hermit/io.rs | 87 - std/src/sys/pal/hermit/mod.rs | 14 +- std/src/sys/pal/hermit/os.rs | 4 +- std/src/sys/pal/hermit/stdio.rs | 97 - std/src/sys/pal/hermit/thread.rs | 4 +- std/src/sys/pal/hermit/time.rs | 2 +- std/src/sys/pal/itron/abi.rs | 2 +- std/src/sys/pal/itron/thread.rs | 2 +- std/src/sys/pal/itron/time/tests.rs | 30 +- std/src/sys/pal/sgx/abi/mem.rs | 2 +- std/src/sys/pal/sgx/abi/mod.rs | 10 +- std/src/sys/pal/sgx/abi/panic.rs | 2 +- std/src/sys/pal/sgx/abi/reloc.rs | 2 +- std/src/sys/pal/sgx/abi/thread.rs | 2 +- std/src/sys/pal/sgx/abi/tls/mod.rs | 6 +- std/src/sys/pal/sgx/abi/usercalls/alloc.rs | 42 +- std/src/sys/pal/sgx/abi/usercalls/raw.rs | 2 +- std/src/sys/pal/sgx/args.rs | 2 +- std/src/sys/pal/sgx/fd.rs | 2 +- std/src/sys/pal/sgx/libunwind_integration.rs | 18 +- std/src/sys/pal/sgx/mod.rs | 12 +- std/src/sys/pal/sgx/os.rs | 4 +- std/src/sys/pal/sgx/thread.rs | 2 +- std/src/sys/pal/solid/abi/fs.rs | 2 +- std/src/sys/pal/solid/abi/mod.rs | 10 +- std/src/sys/pal/solid/abi/sockets.rs | 2 +- std/src/sys/pal/solid/error.rs | 3 +- std/src/sys/pal/solid/mod.rs | 6 +- std/src/sys/pal/solid/os.rs | 4 +- std/src/sys/pal/solid/time.rs | 2 +- std/src/sys/pal/teeos/mod.rs | 18 +- std/src/sys/pal/teeos/os.rs | 4 +- std/src/sys/pal/teeos/thread.rs | 4 +- std/src/sys/pal/uefi/args.rs | 1 - std/src/sys/pal/uefi/helpers.rs | 162 +- std/src/sys/pal/uefi/mod.rs | 11 +- std/src/sys/pal/uefi/os.rs | 163 +- std/src/sys/pal/uefi/process.rs | 84 +- std/src/sys/pal/uefi/tests.rs | 2 +- std/src/sys/pal/uefi/time.rs | 2 +- std/src/sys/pal/unix/args.rs | 4 +- std/src/sys/pal/unix/fd.rs | 5 +- std/src/sys/pal/unix/futex.rs | 6 +- std/src/sys/pal/unix/kernel_copy.rs | 20 +- std/src/sys/pal/unix/kernel_copy/tests.rs | 2 +- std/src/sys/pal/unix/l4re.rs | 564 -- std/src/sys/pal/unix/linux/pidfd/tests.rs | 4 +- std/src/sys/pal/unix/mod.rs | 32 +- std/src/sys/pal/unix/os.rs | 41 +- .../sys/pal/unix/process/process_common.rs | 7 +- .../sys/pal/unix/process/process_fuchsia.rs | 16 +- std/src/sys/pal/unix/process/process_unix.rs | 53 +- .../sys/pal/unix/process/process_vxworks.rs | 2 +- std/src/sys/pal/unix/process/zircon.rs | 4 +- std/src/sys/pal/unix/stack_overflow.rs | 47 +- std/src/sys/pal/unix/sync/condvar.rs | 172 + std/src/sys/pal/unix/sync/mod.rs | 16 + std/src/sys/pal/unix/sync/mutex.rs | 135 + std/src/sys/pal/unix/thread.rs | 68 +- std/src/sys/pal/unix/thread_parking.rs | 2 +- std/src/sys/pal/unix/time.rs | 46 +- std/src/sys/pal/unix/weak.rs | 7 +- std/src/sys/pal/unsupported/mod.rs | 4 - std/src/sys/pal/unsupported/os.rs | 4 +- std/src/sys/pal/wasi/fd.rs | 8 +- std/src/sys/pal/wasi/mod.rs | 10 +- std/src/sys/pal/wasi/os.rs | 4 +- std/src/sys/pal/wasi/thread.rs | 25 +- std/src/sys/pal/wasip2/cabi_realloc.rs | 2 +- std/src/sys/pal/wasip2/mod.rs | 7 - std/src/sys/pal/wasm/mod.rs | 10 +- std/src/sys/pal/windows/api.rs | 4 +- std/src/sys/pal/windows/args.rs | 4 +- std/src/sys/pal/windows/args/tests.rs | 8 +- std/src/sys/pal/windows/c.rs | 25 +- std/src/sys/pal/windows/c/bindings.txt | 5207 +++++++++-------- std/src/sys/pal/windows/c/windows_sys.rs | 305 +- std/src/sys/pal/windows/compat.rs | 2 +- std/src/sys/pal/windows/futex.rs | 4 +- std/src/sys/pal/windows/mod.rs | 16 +- std/src/sys/pal/windows/os.rs | 9 +- std/src/sys/pal/windows/pipe.rs | 2 +- std/src/sys/pal/windows/process.rs | 129 +- std/src/sys/pal/windows/process/tests.rs | 10 +- std/src/sys/pal/windows/stack_overflow.rs | 8 +- std/src/sys/pal/windows/stack_overflow_uwp.rs | 4 +- std/src/sys/pal/windows/thread.rs | 1 + std/src/sys/pal/xous/mod.rs | 6 - std/src/sys/pal/xous/net/mod.rs | 83 - std/src/sys/pal/xous/os.rs | 8 +- std/src/sys/pal/zkvm/abi.rs | 2 +- std/src/sys/pal/zkvm/mod.rs | 9 +- std/src/sys/pal/zkvm/os.rs | 4 +- std/src/sys/path/mod.rs | 8 +- std/src/sys/path/sgx.rs | 4 + std/src/sys/path/uefi.rs | 105 + std/src/sys/path/unix.rs | 11 + std/src/sys/path/unsupported_backslash.rs | 4 + std/src/sys/path/windows.rs | 6 +- std/src/sys/personality/dwarf/eh.rs | 5 +- std/src/sys/personality/dwarf/mod.rs | 4 +- std/src/sys/personality/gcc.rs | 4 +- std/src/sys/personality/mod.rs | 2 +- std/src/sys/random/arc4random.rs | 2 +- std/src/sys/random/espidf.rs | 2 +- std/src/sys/random/fuchsia.rs | 2 +- std/src/sys/random/teeos.rs | 2 +- std/src/sys/random/windows.rs | 2 +- std/src/sys/stdio/mod.rs | 38 + .../sys/{pal/sgx/stdio.rs => stdio/sgx.rs} | 22 +- .../{pal/solid/stdio.rs => stdio/solid.rs} | 2 +- .../{pal/teeos/stdio.rs => stdio/teeos.rs} | 0 .../sys/{pal/uefi/stdio.rs => stdio/uefi.rs} | 2 +- .../sys/{pal/unix/stdio.rs => stdio/unix.rs} | 35 +- .../stdio.rs => stdio/unsupported.rs} | 0 .../sys/{pal/wasi/stdio.rs => stdio/wasi.rs} | 11 +- .../windows/stdio.rs => stdio/windows.rs} | 45 +- .../windows/stdio => stdio/windows}/tests.rs | 0 .../sys/{pal/xous/stdio.rs => stdio/xous.rs} | 2 +- .../sys/{pal/zkvm/stdio.rs => stdio/zkvm.rs} | 15 +- std/src/sys/sync/condvar/no_threads.rs | 7 +- std/src/sys/sync/condvar/pthread.rs | 210 +- std/src/sys/sync/condvar/sgx.rs | 8 +- std/src/sys/sync/mutex/no_threads.rs | 1 - std/src/sys/sync/mutex/pthread.rs | 157 +- std/src/sys/sync/mutex/sgx.rs | 4 +- std/src/sys/sync/mutex/windows7.rs | 2 +- std/src/sys/sync/once/futex.rs | 2 +- std/src/sys/sync/once/no_threads.rs | 3 +- std/src/sys/sync/once/queue.rs | 3 +- std/src/sys/sync/once_box.rs | 25 +- std/src/sys/sync/rwlock/no_threads.rs | 1 - std/src/sys/sync/thread_parking/darwin.rs | 2 +- std/src/sys/sync/thread_parking/pthread.rs | 167 +- std/src/sys/sync/thread_parking/windows7.rs | 8 +- .../thread_local/destructors/linux_like.rs | 2 +- std/src/sys/thread_local/guard/apple.rs | 2 +- std/src/sys/thread_local/guard/windows.rs | 2 +- std/src/sys/thread_local/key/racy.rs | 1 - std/src/sys/thread_local/key/unix.rs | 20 + std/src/sys/thread_local/key/xous.rs | 17 +- std/src/sys/thread_local/mod.rs | 5 +- std/src/sys/thread_local/os.rs | 5 +- std/src/sys_common/io.rs | 49 - std/src/sys_common/mod.rs | 16 - std/src/sys_common/process.rs | 8 +- std/src/sys_common/wtf8.rs | 104 +- std/src/sys_common/wtf8/tests.rs | 111 +- std/src/test_helpers.rs | 65 + std/src/thread/current.rs | 55 +- std/src/thread/local.rs | 74 +- std/src/thread/mod.rs | 297 +- std/src/thread/tests.rs | 4 +- std/src/time.rs | 13 +- std/tests/common/mod.rs | 2 +- std/tests/env.rs | 218 +- std/tests/env_modify.rs | 184 + std/{src/error/tests.rs => tests/error.rs} | 10 +- .../f128/tests.rs => tests/floats/f128.rs} | 10 +- std/{src/f16/tests.rs => tests/floats/f16.rs} | 7 +- std/{src/f32/tests.rs => tests/floats/f32.rs} | 8 +- std/{src/f64/tests.rs => tests/floats/f64.rs} | 10 +- std/tests/floats/lib.rs | 42 + std/tests/istr.rs | 4 +- std/{src/num/tests.rs => tests/num.rs} | 6 +- std/{src/panic/tests.rs => tests/panic.rs} | 8 +- std/{src/path/tests.rs => tests/path.rs} | 153 +- std/tests/pipe_subprocess.rs | 5 +- std/tests/process_spawning.rs | 3 +- std/tests/seq-compare.rs | 22 +- std/tests/switch-stdout.rs | 4 +- .../tests.rs => tests/sync/barrier.rs} | 6 +- .../tests.rs => tests/sync/condvar.rs} | 10 +- .../tests.rs => tests/sync/lazy_lock.rs} | 12 +- std/tests/sync/lib.rs | 31 + std/tests/sync/mpmc.rs | 729 +++ .../sync/mpsc/tests.rs => tests/sync/mpsc.rs} | 5 +- .../sync_tests.rs => tests/sync/mpsc_sync.rs} | 9 +- .../mutex/tests.rs => tests/sync/mutex.rs} | 167 +- .../sync/once/tests.rs => tests/sync/once.rs} | 12 +- .../tests.rs => tests/sync/once_lock.rs} | 22 +- .../tests.rs => tests/sync/reentrant_lock.rs} | 7 +- .../rwlock/tests.rs => tests/sync/rwlock.rs} | 190 +- .../thread_local}/dynamic_tests.rs | 6 +- std/tests/thread_local/lib.rs | 4 + .../local => tests/thread_local}/tests.rs | 10 +- std/{src/time/tests.rs => tests/time.rs} | 55 +- std/tests/win_delete_self.rs | 9 + stdarch | 2 +- sysroot/Cargo.toml | 12 +- test/Cargo.toml | 6 +- test/src/cli.rs | 10 +- test/src/console.rs | 23 +- test/src/formatters/json.rs | 2 +- test/src/formatters/junit.rs | 10 +- test/src/formatters/pretty.rs | 26 +- test/src/formatters/terse.rs | 20 +- test/src/helpers/concurrency.rs | 2 +- test/src/helpers/mod.rs | 6 +- test/src/helpers/shuffle.rs | 4 +- test/src/lib.rs | 10 +- test/src/options.rs | 2 +- test/src/stats/tests.rs | 6 +- test/src/term.rs | 2 +- test/src/term/terminfo/mod.rs | 2 +- test/src/term/terminfo/parser/compiled.rs | 2 +- test/src/term/terminfo/searcher/tests.rs | 8 +- test/src/term/win.rs | 2 +- test/src/test_result.rs | 6 +- test/src/tests.rs | 38 +- test/src/time.rs | 30 +- unwind/Cargo.toml | 7 +- unwind/src/lib.rs | 54 +- unwind/src/libunwind.rs | 50 +- unwind/src/unwinding.rs | 6 +- windows_targets/src/lib.rs | 4 +- 855 files changed, 27838 insertions(+), 18038 deletions(-) create mode 100644 alloc/src/bstr.rs create mode 100644 alloc/src/collections/btree/set/entry.rs rename alloc/src/{raw_vec.rs => raw_vec/mod.rs} (90%) delete mode 100644 alloc/src/testing/mod.rs delete mode 100644 alloc/tests/rc.rs create mode 100644 alloctests/Cargo.toml rename {alloc => alloctests}/benches/binary_heap.rs (100%) rename {alloc => alloctests}/benches/btree/map.rs (95%) rename {alloc => alloctests}/benches/btree/mod.rs (100%) rename {alloc => alloctests}/benches/btree/set.rs (97%) rename {alloc => alloctests}/benches/lib.rs (85%) rename {alloc => alloctests}/benches/linked_list.rs (100%) rename {alloc => alloctests}/benches/slice.rs (85%) rename {alloc => alloctests}/benches/str.rs (100%) rename {alloc => alloctests}/benches/string.rs (100%) rename {alloc => alloctests}/benches/vec.rs (98%) rename {alloc => alloctests}/benches/vec_deque.rs (100%) rename {alloc => alloctests}/benches/vec_deque_append.rs (100%) create mode 100644 alloctests/lib.rs rename {alloc/src => alloctests}/testing/crash_test.rs (86%) create mode 100644 alloctests/testing/mod.rs rename {alloc/src => alloctests}/testing/ord_chaos.rs (90%) rename {alloc/src => alloctests}/testing/rng.rs (83%) rename alloc/src/alloc/tests.rs => alloctests/tests/alloc_test.rs (93%) rename {alloc => alloctests}/tests/arc.rs (98%) rename {alloc => alloctests}/tests/autotraits.rs (100%) rename {alloc => alloctests}/tests/borrow.rs (100%) rename {alloc => alloctests}/tests/boxed.rs (99%) rename {alloc => alloctests}/tests/btree_set_hash.rs (100%) rename {alloc => alloctests}/tests/c_str.rs (100%) rename alloc/src/ffi/c_str/tests.rs => alloctests/tests/c_str2.rs (97%) rename alloc/src/collections/binary_heap/tests.rs => alloctests/tests/collections/binary_heap.rs (98%) create mode 100644 alloctests/tests/collections/mod.rs rename {alloc => alloctests}/tests/const_fns.rs (100%) rename {alloc => alloctests}/tests/cow_str.rs (100%) rename {alloc => alloctests}/tests/fmt.rs (100%) rename {alloc => alloctests}/tests/heap.rs (100%) rename {alloc => alloctests}/tests/lib.rs (67%) rename {alloc => alloctests}/tests/linked_list.rs (100%) rename alloc/src/tests.rs => alloctests/tests/misc_tests.rs (100%) rename alloc/src/rc/tests.rs => alloctests/tests/rc.rs (66%) rename {alloc => alloctests}/tests/slice.rs (99%) rename {alloc => alloctests}/tests/sort/ffi_types.rs (100%) rename {alloc => alloctests}/tests/sort/known_good_stable_sort.rs (98%) rename {alloc => alloctests}/tests/sort/mod.rs (100%) rename {alloc => alloctests}/tests/sort/patterns.rs (96%) rename {alloc => alloctests}/tests/sort/tests.rs (99%) rename {alloc => alloctests}/tests/sort/zipf.rs (98%) rename {alloc => alloctests}/tests/str.rs (96%) rename {alloc => alloctests}/tests/string.rs (96%) rename alloc/src/sync/tests.rs => alloctests/tests/sync.rs (98%) rename {alloc => alloctests}/tests/task.rs (100%) create mode 100644 alloctests/tests/testing/crash_test.rs create mode 100644 alloctests/tests/testing/mod.rs rename {alloc => alloctests}/tests/thin_box.rs (99%) rename {alloc => alloctests}/tests/vec.rs (96%) rename {alloc => alloctests}/tests/vec_deque.rs (98%) rename {alloc => alloctests}/tests/vec_deque_alloc_error.rs (100%) create mode 100644 core/src/bstr.rs create mode 100644 core/src/contracts.rs create mode 100644 core/src/ffi/primitives.rs create mode 100644 core/src/intrinsics/fallback.rs create mode 100644 core/src/marker/variance.rs create mode 100644 core/src/num/dec2flt/decimal_seq.rs delete mode 100644 core/src/num/dec2flt/number.rs create mode 100644 core/src/num/niche_types.rs rename core/src/prelude/{common.rs => v1.rs} (88%) create mode 100644 core/src/unsafe_binder.rs delete mode 100644 core/tests/fmt/mod.rs delete mode 100644 core/tests/num/dec2flt/float.rs delete mode 100644 core/tests/num/i128.rs delete mode 100644 core/tests/num/i16.rs delete mode 100644 core/tests/num/i64.rs delete mode 100644 core/tests/num/i8.rs delete mode 100644 core/tests/num/uint_macros.rs create mode 100644 coretests/Cargo.toml rename {core => coretests}/benches/any.rs (100%) rename {core => coretests}/benches/array.rs (100%) rename {core => coretests}/benches/ascii.rs (100%) rename {core => coretests}/benches/ascii/is_ascii.rs (56%) rename {core => coretests}/benches/char/methods.rs (100%) rename {core => coretests}/benches/char/mod.rs (100%) rename {core => coretests}/benches/fmt.rs (90%) rename {core => coretests}/benches/hash/mod.rs (100%) rename {core => coretests}/benches/hash/sip.rs (100%) rename {core => coretests}/benches/iter.rs (98%) rename {core => coretests}/benches/lib.rs (100%) rename {core => coretests}/benches/net/addr_parser.rs (100%) rename {core => coretests}/benches/net/mod.rs (100%) rename {core => coretests}/benches/num/dec2flt/mod.rs (100%) rename {core => coretests}/benches/num/flt2dec/mod.rs (100%) rename {core => coretests}/benches/num/flt2dec/strategy/dragon.rs (100%) rename {core => coretests}/benches/num/flt2dec/strategy/grisu.rs (100%) rename {core => coretests}/benches/num/int_log/mod.rs (92%) rename {core => coretests}/benches/num/int_pow/mod.rs (93%) rename {core => coretests}/benches/num/int_sqrt/mod.rs (86%) rename {core => coretests}/benches/num/mod.rs (100%) rename {core => coretests}/benches/ops.rs (100%) rename {core => coretests}/benches/pattern.rs (100%) rename {core => coretests}/benches/slice.rs (96%) rename {core => coretests}/benches/str.rs (100%) rename {core => coretests}/benches/str/char_count.rs (100%) rename {core => coretests}/benches/str/corpora.rs (100%) rename {core => coretests}/benches/str/debug.rs (100%) rename {core => coretests}/benches/str/iter.rs (100%) rename {core => coretests}/benches/tuple.rs (100%) create mode 100644 coretests/lib.rs rename {core => coretests}/tests/alloc.rs (99%) rename {core => coretests}/tests/any.rs (92%) rename {core => coretests}/tests/array.rs (100%) rename {core => coretests}/tests/ascii.rs (100%) rename {core => coretests}/tests/ascii_char.rs (74%) rename {core => coretests}/tests/asserting.rs (100%) rename {core => coretests}/tests/async_iter/mod.rs (100%) rename {core => coretests}/tests/atomic.rs (99%) rename {core => coretests}/tests/bool.rs (96%) create mode 100644 coretests/tests/bstr.rs rename {core => coretests}/tests/cell.rs (100%) rename {core => coretests}/tests/char.rs (99%) rename {core => coretests}/tests/clone.rs (100%) rename {core => coretests}/tests/cmp.rs (100%) rename {core => coretests}/tests/const_ptr.rs (100%) rename {core => coretests}/tests/convert.rs (100%) rename {core => coretests}/tests/error.rs (100%) rename {core => coretests}/tests/ffi.rs (100%) rename {core => coretests}/tests/ffi/cstr.rs (100%) rename {core => coretests}/tests/fmt/builders.rs (100%) rename {core => coretests}/tests/fmt/float.rs (100%) create mode 100644 coretests/tests/fmt/mod.rs rename {core => coretests}/tests/fmt/num.rs (100%) rename {core => coretests}/tests/future.rs (100%) rename {core => coretests}/tests/hash/mod.rs (90%) rename {core => coretests}/tests/hash/sip.rs (99%) rename {core => coretests}/tests/intrinsics.rs (62%) rename {core => coretests}/tests/io/borrowed_buf.rs (96%) rename {core => coretests}/tests/io/mod.rs (100%) rename {core => coretests}/tests/iter/adapters/array_chunks.rs (100%) rename {core => coretests}/tests/iter/adapters/by_ref_sized.rs (100%) rename {core => coretests}/tests/iter/adapters/chain.rs (100%) rename {core => coretests}/tests/iter/adapters/cloned.rs (100%) rename {core => coretests}/tests/iter/adapters/copied.rs (100%) rename {core => coretests}/tests/iter/adapters/cycle.rs (100%) rename {core => coretests}/tests/iter/adapters/enumerate.rs (100%) rename {core => coretests}/tests/iter/adapters/filter.rs (100%) rename {core => coretests}/tests/iter/adapters/filter_map.rs (100%) rename {core => coretests}/tests/iter/adapters/flat_map.rs (100%) rename {core => coretests}/tests/iter/adapters/flatten.rs (100%) rename {core => coretests}/tests/iter/adapters/fuse.rs (100%) rename {core => coretests}/tests/iter/adapters/inspect.rs (100%) rename {core => coretests}/tests/iter/adapters/intersperse.rs (100%) rename {core => coretests}/tests/iter/adapters/map.rs (100%) rename {core => coretests}/tests/iter/adapters/map_windows.rs (98%) rename {core => coretests}/tests/iter/adapters/mod.rs (100%) rename {core => coretests}/tests/iter/adapters/peekable.rs (100%) rename {core => coretests}/tests/iter/adapters/scan.rs (100%) rename {core => coretests}/tests/iter/adapters/skip.rs (100%) rename {core => coretests}/tests/iter/adapters/skip_while.rs (100%) rename {core => coretests}/tests/iter/adapters/step_by.rs (100%) rename {core => coretests}/tests/iter/adapters/take.rs (99%) rename {core => coretests}/tests/iter/adapters/take_while.rs (100%) rename {core => coretests}/tests/iter/adapters/zip.rs (100%) rename {core => coretests}/tests/iter/mod.rs (100%) rename {core => coretests}/tests/iter/range.rs (100%) rename {core => coretests}/tests/iter/sources.rs (100%) rename {core => coretests}/tests/iter/traits/accum.rs (100%) rename {core => coretests}/tests/iter/traits/double_ended.rs (100%) rename {core => coretests}/tests/iter/traits/iterator.rs (96%) rename {core => coretests}/tests/iter/traits/mod.rs (100%) rename {core => coretests}/tests/iter/traits/step.rs (100%) rename {core => coretests}/tests/lazy.rs (100%) rename {core => coretests}/tests/lib.rs (89%) rename {core => coretests}/tests/macros.rs (72%) rename {core => coretests}/tests/manually_drop.rs (100%) rename {core => coretests}/tests/mem.rs (95%) rename {core => coretests}/tests/net/ip_addr.rs (99%) rename {core => coretests}/tests/net/mod.rs (100%) rename {core => coretests}/tests/net/parser.rs (100%) rename {core => coretests}/tests/net/socket_addr.rs (100%) rename {core => coretests}/tests/nonzero.rs (79%) rename {core => coretests}/tests/num/bignum.rs (100%) rename {core => coretests}/tests/num/const_from.rs (100%) create mode 100644 coretests/tests/num/dec2flt/decimal.rs create mode 100644 coretests/tests/num/dec2flt/decimal_seq.rs create mode 100644 coretests/tests/num/dec2flt/float.rs rename {core => coretests}/tests/num/dec2flt/lemire.rs (84%) rename {core => coretests}/tests/num/dec2flt/mod.rs (99%) rename {core => coretests}/tests/num/dec2flt/parse.rs (91%) rename {core => coretests}/tests/num/float_iter_sum_identity.rs (100%) rename {core => coretests}/tests/num/flt2dec/estimator.rs (100%) rename {core => coretests}/tests/num/flt2dec/mod.rs (98%) rename {core => coretests}/tests/num/flt2dec/random.rs (94%) rename {core => coretests}/tests/num/flt2dec/strategy/dragon.rs (100%) rename {core => coretests}/tests/num/flt2dec/strategy/grisu.rs (100%) create mode 100644 coretests/tests/num/i128.rs create mode 100644 coretests/tests/num/i16.rs rename {core => coretests}/tests/num/i32.rs (97%) create mode 100644 coretests/tests/num/i64.rs create mode 100644 coretests/tests/num/i8.rs rename {core => coretests}/tests/num/ieee754.rs (100%) rename {core => coretests}/tests/num/int_log.rs (68%) rename {core => coretests}/tests/num/int_macros.rs (50%) rename {core => coretests}/tests/num/int_sqrt.rs (100%) rename {core => coretests}/tests/num/midpoint.rs (100%) rename {core => coretests}/tests/num/mod.rs (100%) rename {core => coretests}/tests/num/nan.rs (100%) rename {core => coretests}/tests/num/ops.rs (81%) rename {core => coretests}/tests/num/u128.rs (100%) rename {core => coretests}/tests/num/u16.rs (100%) rename {core => coretests}/tests/num/u32.rs (100%) rename {core => coretests}/tests/num/u64.rs (100%) rename {core => coretests}/tests/num/u8.rs (100%) create mode 100644 coretests/tests/num/uint_macros.rs rename {core => coretests}/tests/num/wrapping.rs (99%) rename {core => coretests}/tests/ops.rs (100%) rename {core => coretests}/tests/ops/control_flow.rs (100%) rename {core => coretests}/tests/ops/from_residual.rs (100%) rename {core => coretests}/tests/option.rs (100%) rename {core => coretests}/tests/panic.rs (100%) rename {core => coretests}/tests/panic/location.rs (100%) rename {core => coretests}/tests/pattern.rs (100%) rename {core => coretests}/tests/pin.rs (96%) rename {core => coretests}/tests/pin_macro.rs (100%) rename {core => coretests}/tests/ptr.rs (90%) rename {core => coretests}/tests/result.rs (100%) rename {core => coretests}/tests/simd.rs (100%) rename {core => coretests}/tests/slice.rs (92%) rename {core => coretests}/tests/str.rs (100%) rename {core => coretests}/tests/str_lossy.rs (100%) rename {core => coretests}/tests/task.rs (100%) rename {core => coretests}/tests/time.rs (100%) rename {core => coretests}/tests/tuple.rs (100%) rename {core => coretests}/tests/unicode.rs (100%) rename {core => coretests}/tests/waker.rs (100%) create mode 100644 portable-simd/Cross.toml create mode 100644 portable-simd/crates/core_simd/src/vendor/loongarch64.rs create mode 100644 portable-simd/crates/core_simd/tests/layout.rs create mode 100644 portable-simd/rust-toolchain.toml create mode 100755 portable-simd/subtree-sync.sh create mode 100644 std/benches/path.rs create mode 100644 std/benches/time.rs create mode 100644 std/src/bstr.rs delete mode 100644 std/src/env/tests.rs create mode 100644 std/src/io/pipe.rs rename std/src/{ => io}/pipe/tests.rs (78%) delete mode 100644 std/src/os/wasi/io/fd.rs delete mode 100644 std/src/os/wasi/io/raw.rs rename std/src/os/wasi/io/{fd => }/tests.rs (93%) delete mode 100644 std/src/pipe.rs rename std/src/prelude/{common.rs => v1.rs} (90%) rename std/src/sync/{mpsc/mod.rs => mpsc.rs} (99%) rename std/src/sync/{ => poison}/condvar.rs (99%) rename std/src/sync/{ => poison}/mutex.rs (84%) rename std/src/sync/{ => poison}/once.rs (98%) rename std/src/sync/{ => poison}/rwlock.rs (91%) rename std/src/{sys_common/fs.rs => sys/fs/common.rs} (96%) rename std/src/sys/{pal/hermit/fs.rs => fs/hermit.rs} (94%) create mode 100644 std/src/sys/fs/mod.rs rename std/src/sys/{pal/solid/fs.rs => fs/solid.rs} (94%) create mode 100644 std/src/sys/fs/uefi.rs rename std/src/sys/{pal/unix/fs.rs => fs/unix.rs} (92%) rename std/src/sys/{pal/unix/fs => fs/unix}/tests.rs (98%) rename std/src/sys/{pal/unsupported/fs.rs => fs/unsupported.rs} (98%) rename std/src/sys/{pal/wasi/fs.rs => fs/wasi.rs} (81%) rename std/src/sys/{pal/windows/fs.rs => fs/windows.rs} (89%) rename std/src/sys/{pal/windows/fs => fs/windows}/remove_dir_all.rs (99%) rename std/src/sys/{pal/solid/io.rs => io/io_slice/iovec.rs} (90%) rename std/src/sys/{pal/unsupported/io.rs => io/io_slice/unsupported.rs} (94%) rename std/src/sys/{pal/wasi/io.rs => io/io_slice/wasi.rs} (90%) rename std/src/sys/{pal/unix/io.rs => io/io_slice/windows.rs} (52%) create mode 100644 std/src/sys/io/is_terminal/hermit.rs create mode 100644 std/src/sys/io/is_terminal/isatty.rs create mode 100644 std/src/sys/io/is_terminal/unsupported.rs rename std/src/sys/{pal/windows/io.rs => io/is_terminal/windows.rs} (54%) create mode 100644 std/src/sys/io/mod.rs rename std/src/sys/{pal/sgx/net.rs => net/connection/sgx.rs} (94%) rename std/src/{sys_common/net.rs => sys/net/connection/socket.rs} (81%) rename std/src/sys/{pal/hermit/net.rs => net/connection/socket/hermit.rs} (94%) rename std/src/sys/{pal/solid/net.rs => net/connection/socket/solid.rs} (92%) rename std/src/{sys_common/net => sys/net/connection/socket}/tests.rs (100%) rename std/src/sys/{pal/unix/net.rs => net/connection/socket/unix.rs} (96%) rename std/src/sys/{pal/wasip2/net.rs => net/connection/socket/wasip2.rs} (96%) rename std/src/sys/{pal/windows/net.rs => net/connection/socket/windows.rs} (92%) rename std/src/sys/{pal/teeos/net.rs => net/connection/uefi/mod.rs} (90%) rename std/src/sys/{pal/unsupported/net.rs => net/connection/unsupported.rs} (90%) rename std/src/sys/{pal/wasi/net.rs => net/connection/wasip1.rs} (93%) rename std/src/sys/{pal/xous/net => net/connection/xous}/dns.rs (94%) create mode 100644 std/src/sys/net/connection/xous/mod.rs rename std/src/sys/{pal/xous/net => net/connection/xous}/tcplistener.rs (83%) rename std/src/sys/{pal/xous/net => net/connection/xous}/tcpstream.rs (85%) rename std/src/sys/{pal/xous/net => net/connection/xous}/udp.rs (84%) create mode 100644 std/src/sys/net/mod.rs delete mode 100644 std/src/sys/pal/hermit/io.rs delete mode 100644 std/src/sys/pal/hermit/stdio.rs delete mode 100644 std/src/sys/pal/unix/l4re.rs create mode 100644 std/src/sys/pal/unix/sync/condvar.rs create mode 100644 std/src/sys/pal/unix/sync/mod.rs create mode 100644 std/src/sys/pal/unix/sync/mutex.rs delete mode 100644 std/src/sys/pal/xous/net/mod.rs create mode 100644 std/src/sys/path/uefi.rs create mode 100644 std/src/sys/stdio/mod.rs rename std/src/sys/{pal/sgx/stdio.rs => stdio/sgx.rs} (68%) rename std/src/sys/{pal/solid/stdio.rs => stdio/solid.rs} (98%) rename std/src/sys/{pal/teeos/stdio.rs => stdio/teeos.rs} (100%) rename std/src/sys/{pal/uefi/stdio.rs => stdio/uefi.rs} (98%) rename std/src/sys/{pal/unix/stdio.rs => stdio/unix.rs} (56%) rename std/src/sys/{pal/unsupported/stdio.rs => stdio/unsupported.rs} (100%) rename std/src/sys/{pal/wasi/stdio.rs => stdio/wasi.rs} (87%) rename std/src/sys/{pal/windows/stdio.rs => stdio/windows.rs} (92%) rename std/src/sys/{pal/windows/stdio => stdio/windows}/tests.rs (100%) rename std/src/sys/{pal/xous/stdio.rs => stdio/xous.rs} (98%) rename std/src/sys/{pal/zkvm/stdio.rs => stdio/zkvm.rs} (72%) delete mode 100644 std/src/sys_common/io.rs create mode 100644 std/src/test_helpers.rs create mode 100644 std/tests/env_modify.rs rename std/{src/error/tests.rs => tests/error.rs} (98%) rename std/{src/f128/tests.rs => tests/floats/f128.rs} (99%) rename std/{src/f16/tests.rs => tests/floats/f16.rs} (99%) rename std/{src/f32/tests.rs => tests/floats/f32.rs} (99%) rename std/{src/f64/tests.rs => tests/floats/f64.rs} (98%) create mode 100644 std/tests/floats/lib.rs rename std/{src/num/tests.rs => tests/num.rs} (98%) rename std/{src/panic/tests.rs => tests/panic.rs} (89%) rename std/{src/path/tests.rs => tests/path.rs} (93%) rename std/{src/sync/barrier/tests.rs => tests/sync/barrier.rs} (89%) rename std/{src/sync/condvar/tests.rs => tests/sync/condvar.rs} (97%) rename std/{src/sync/lazy_lock/tests.rs => tests/sync/lazy_lock.rs} (93%) create mode 100644 std/tests/sync/lib.rs create mode 100644 std/tests/sync/mpmc.rs rename std/{src/sync/mpsc/tests.rs => tests/sync/mpsc.rs} (99%) rename std/{src/sync/mpsc/sync_tests.rs => tests/sync/mpsc_sync.rs} (99%) rename std/{src/sync/mutex/tests.rs => tests/sync/mutex.rs} (68%) rename std/{src/sync/once/tests.rs => tests/sync/once.rs} (94%) rename std/{src/sync/once_lock/tests.rs => tests/sync/once_lock.rs} (91%) rename std/{src/sync/reentrant_lock/tests.rs => tests/sync/reentrant_lock.rs} (91%) rename std/{src/sync/rwlock/tests.rs => tests/sync/rwlock.rs} (80%) rename std/{src/thread/local => tests/thread_local}/dynamic_tests.rs (89%) create mode 100644 std/tests/thread_local/lib.rs rename std/{src/thread/local => tests/thread_local}/tests.rs (98%) rename std/{src/time/tests.rs => tests/time.rs} (81%) create mode 100644 std/tests/win_delete_self.rs diff --git a/Cargo.lock b/Cargo.lock index 55851daaf2a80..8f174f284724f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,21 +4,21 @@ version = 4 [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "compiler_builtins", - "gimli 0.29.0", + "gimli", "rustc-std-workspace-alloc", "rustc-std-workspace-core", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" dependencies = [ "compiler_builtins", "rustc-std-workspace-core", @@ -30,15 +30,21 @@ version = "0.0.0" dependencies = [ "compiler_builtins", "core", - "rand", - "rand_xorshift", ] [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "alloctests" +version = "0.0.0" +dependencies = [ + "rand", + "rand_xorshift", +] [[package]] name = "cc" @@ -61,9 +67,9 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.138" +version = "0.1.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53f0ea7fff95b51f84371588f06062557e96bbe363d2b36218ddb806f3ca8611" +checksum = "abc30f1766d387c35f2405e586d3e7a88230dc728ff78cd1d0bc59ae0b63154b" dependencies = [ "cc", "rustc-std-workspace-core", @@ -72,6 +78,10 @@ dependencies = [ [[package]] name = "core" version = "0.0.0" + +[[package]] +name = "coretests" +version = "0.0.0" dependencies = [ "rand", "rand_xorshift", @@ -111,17 +121,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "gimli" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - [[package]] name = "gimli" version = "0.31.1" @@ -135,9 +134,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "allocator-api2", "compiler_builtins", @@ -147,9 +146,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" +checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e" dependencies = [ "compiler_builtins", "rustc-std-workspace-alloc", @@ -158,9 +157,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.162" +version = "0.2.170" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" dependencies = [ "rustc-std-workspace-core", ] @@ -177,11 +176,11 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ - "adler", + "adler2", "compiler_builtins", "rustc-std-workspace-alloc", "rustc-std-workspace-core", @@ -189,9 +188,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.5" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "compiler_builtins", "memchr", @@ -222,6 +221,15 @@ dependencies = [ "unwind", ] +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + [[package]] name = "proc_macro" version = "0.0.0" @@ -235,8 +243,15 @@ name = "profiler_builtins" version = "0.0.0" dependencies = [ "cc", - "compiler_builtins", - "core", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", ] [[package]] @@ -262,24 +277,28 @@ dependencies = [ [[package]] name = "rand" -version = "0.8.5" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_core", + "zerocopy", ] [[package]] name = "rand_core" -version = "0.6.4" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" +dependencies = [ + "zerocopy", +] [[package]] name = "rand_xorshift" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" dependencies = [ "rand_core", ] @@ -361,6 +380,17 @@ dependencies = [ "rustc-std-workspace-core", ] +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "sysroot" version = "0.0.0" @@ -381,6 +411,12 @@ dependencies = [ "std", ] +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + [[package]] name = "unicode-width" version = "0.1.14" @@ -405,12 +441,12 @@ dependencies = [ [[package]] name = "unwinding" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637d511437df708cee34bdec7ba2f1548d256b7acf3ff20e0a1c559f9bf3a987" +checksum = "51f06a05848f650946acef3bf525fe96612226b61f74ae23ffa4e98bfbb8ab3c" dependencies = [ "compiler_builtins", - "gimli 0.31.1", + "gimli", "rustc-std-workspace-core", ] @@ -501,3 +537,23 @@ name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.8.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa91407dacce3a68c56de03abe2760159582b846c6a4acd2f456618087f12713" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06718a168365cad3d5ff0bb133aad346959a2074bd4a85c121255a11304a8626" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index e744cfe5e0f57..4d5955593ffcd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,8 @@ resolver = "1" members = [ "std", "sysroot", + "coretests", + "alloctests", ] exclude = [ @@ -32,7 +34,7 @@ codegen-units = 10000 [profile.release.package] addr2line.debug = 0 addr2line.opt-level = "s" -adler.debug = 0 +adler2.debug = 0 gimli.debug = 0 gimli.opt-level = "s" miniz_oxide.debug = 0 diff --git a/alloc/Cargo.toml b/alloc/Cargo.toml index 3464047d4ee9e..dbdf292433bea 100644 --- a/alloc/Cargo.toml +++ b/alloc/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["public-dependency"] + [package] name = "alloc" version = "0.0.0" @@ -8,31 +10,13 @@ autotests = false autobenches = false edition = "2021" -[dependencies] -core = { path = "../core" } -compiler_builtins = { version = "=0.1.138", features = ['rustc-dep-of-std'] } - -[dev-dependencies] -rand = { version = "0.8.5", default-features = false, features = ["alloc"] } -rand_xorshift = "0.3.0" - -[[test]] -name = "alloctests" -path = "tests/lib.rs" +[lib] +test = false +bench = false -[[test]] -name = "vec_deque_alloc_error" -path = "tests/vec_deque_alloc_error.rs" - -[[bench]] -name = "allocbenches" -path = "benches/lib.rs" -test = true - -[[bench]] -name = "vec_deque_append_bench" -path = "benches/vec_deque_append.rs" -harness = false +[dependencies] +core = { path = "../core", public = true } +compiler_builtins = { version = "=0.1.151", features = ['rustc-dep-of-std'] } [features] compiler-builtins-mem = ['compiler_builtins/mem'] diff --git a/alloc/src/alloc.rs b/alloc/src/alloc.rs index 04b7315e650a2..2f752f6eb3940 100644 --- a/alloc/src/alloc.rs +++ b/alloc/src/alloc.rs @@ -5,15 +5,10 @@ #[stable(feature = "alloc_module", since = "1.28.0")] #[doc(inline)] pub use core::alloc::*; -#[cfg(not(test))] use core::hint; -#[cfg(not(test))] use core::ptr::{self, NonNull}; -#[cfg(test)] -mod tests; - -extern "Rust" { +unsafe extern "Rust" { // These are the magic symbols to call the global allocator. rustc generates // them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute // (the code expanding that attribute macro generates those functions), or to call @@ -47,14 +42,10 @@ extern "Rust" { /// accessed through the [free functions in `alloc`](self#functions). #[unstable(feature = "allocator_api", issue = "32838")] #[derive(Copy, Clone, Default, Debug)] -#[cfg(not(test))] // the compiler needs to know when a Box uses the global allocator vs a custom one #[lang = "global_alloc_ty"] pub struct Global; -#[cfg(test)] -pub use std::alloc::Global; - /// Allocates memory with the global allocator. /// /// This function forwards calls to the [`GlobalAlloc::alloc`] method @@ -183,7 +174,6 @@ pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 { } } -#[cfg(not(test))] impl Global { #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces @@ -249,7 +239,6 @@ impl Global { } #[unstable(feature = "allocator_api", issue = "32838")] -#[cfg(not(test))] unsafe impl Allocator for Global { #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces @@ -267,8 +256,14 @@ unsafe impl Allocator for Global { #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces unsafe fn deallocate(&self, ptr: NonNull, layout: Layout) { if layout.size() != 0 { - // SAFETY: `layout` is non-zero in size, - // other conditions must be upheld by the caller + // SAFETY: + // * We have checked that `layout` is non-zero in size. + // * The caller is obligated to provide a layout that "fits", and in this case, + // "fit" always means a layout that is equal to the original, because our + // `allocate()`, `grow()`, and `shrink()` implementations never returns a larger + // allocation than requested. + // * Other conditions must be upheld by the caller, as per `Allocator::deallocate()`'s + // safety documentation. unsafe { dealloc(ptr.as_ptr(), layout) } } } @@ -342,8 +337,8 @@ unsafe impl Allocator for Global { } } -/// The allocator for unique pointers. -#[cfg(all(not(no_global_oom_handling), not(test)))] +/// The allocator for `Box`. +#[cfg(not(no_global_oom_handling))] #[lang = "exchange_malloc"] #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces @@ -358,7 +353,7 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 { // # Allocation error handler #[cfg(not(no_global_oom_handling))] -extern "Rust" { +unsafe extern "Rust" { // This is the magic symbol to call the global alloc error handler. rustc generates // it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the // default implementations below (`__rdl_oom`) otherwise. @@ -392,7 +387,7 @@ extern "Rust" { /// [no_std]: https://doc.rust-lang.org/reference/names/preludes.html#the-no_std-attribute #[stable(feature = "global_alloc", since = "1.28.0")] #[rustc_const_unstable(feature = "const_alloc_error", issue = "92523")] -#[cfg(all(not(no_global_oom_handling), not(test)))] +#[cfg(not(no_global_oom_handling))] #[cold] #[optimize(size)] pub const fn handle_alloc_error(layout: Layout) -> ! { @@ -416,11 +411,7 @@ pub const fn handle_alloc_error(layout: Layout) -> ! { ct_error(layout) } -// For alloc test `std::alloc::handle_alloc_error` can be used directly. -#[cfg(all(not(no_global_oom_handling), test))] -pub use std::alloc::handle_alloc_error; - -#[cfg(all(not(no_global_oom_handling), not(test)))] +#[cfg(not(no_global_oom_handling))] #[doc(hidden)] #[allow(unused_attributes)] #[unstable(feature = "alloc_internals", issue = "none")] @@ -429,7 +420,7 @@ pub mod __alloc_error_handler { // `#[alloc_error_handler]`. #[rustc_std_internal_symbol] pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! { - extern "Rust" { + unsafe extern "Rust" { // This symbol is emitted by rustc next to __rust_alloc_error_handler. // Its value depends on the -Zoom={panic,abort} compiler option. static __rust_alloc_error_handler_should_panic: u8; diff --git a/alloc/src/borrow.rs b/alloc/src/borrow.rs index dbfd2e74abee6..07f51b7614ff8 100644 --- a/alloc/src/borrow.rs +++ b/alloc/src/borrow.rs @@ -32,7 +32,7 @@ where /// implementing the `Clone` trait. But `Clone` works only for going from `&T` /// to `T`. The `ToOwned` trait generalizes `Clone` to construct owned data /// from any borrow of a given type. -#[cfg_attr(not(test), rustc_diagnostic_item = "ToOwned")] +#[rustc_diagnostic_item = "ToOwned"] #[stable(feature = "rust1", since = "1.0.0")] pub trait ToOwned { /// The resulting type after obtaining ownership. @@ -54,7 +54,7 @@ pub trait ToOwned { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[must_use = "cloning is often expensive and is not expected to have side effects"] - #[cfg_attr(not(test), rustc_diagnostic_item = "to_owned_method")] + #[rustc_diagnostic_item = "to_owned_method"] fn to_owned(&self) -> Self::Owned; /// Uses borrowed data to replace owned data, usually by cloning. @@ -175,7 +175,7 @@ where /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "Cow")] +#[rustc_diagnostic_item = "Cow"] pub enum Cow<'a, B: ?Sized + 'a> where B: ToOwned, @@ -340,8 +340,18 @@ where } } +// `Cow<'_, T>` can only implement `DerefPure` if `>` (and `BorrowMut`) is trusted. +// For now, we restrict `DerefPure for Cow` to `T: Sized` (`T as Borrow` is trusted), +// `str` (`String as Borrow` is trusted) and `[T]` (`Vec as Borrow<[T]>` is trusted). +// In the future, a `BorrowPure` trait analogous to `DerefPure` might generalize this. #[unstable(feature = "deref_pure_trait", issue = "87121")] -unsafe impl DerefPure for Cow<'_, B> where B::Owned: Borrow {} +unsafe impl DerefPure for Cow<'_, T> {} +#[cfg(not(no_global_oom_handling))] +#[unstable(feature = "deref_pure_trait", issue = "87121")] +unsafe impl DerefPure for Cow<'_, str> {} +#[cfg(not(no_global_oom_handling))] +#[unstable(feature = "deref_pure_trait", issue = "87121")] +unsafe impl DerefPure for Cow<'_, [T]> {} #[stable(feature = "rust1", since = "1.0.0")] impl Eq for Cow<'_, B> where B: Eq + ToOwned {} diff --git a/alloc/src/boxed.rs b/alloc/src/boxed.rs index ee60ec0fbacbe..e77caad65401b 100644 --- a/alloc/src/boxed.rs +++ b/alloc/src/boxed.rs @@ -24,7 +24,7 @@ //! Creating a recursive data structure: //! //! ``` -//! ##[allow(dead_code)] +//! # #[allow(dead_code)] //! #[derive(Debug)] //! enum List { //! Cons(T, Box>), @@ -97,12 +97,12 @@ //! #[repr(C)] //! pub struct Foo; //! -//! #[no_mangle] +//! #[unsafe(no_mangle)] //! pub extern "C" fn foo_new() -> Box { //! Box::new(Foo) //! } //! -//! #[no_mangle] +//! #[unsafe(no_mangle)] //! pub extern "C" fn foo_delete(_: Option>) {} //! ``` //! @@ -191,9 +191,7 @@ use core::error::{self, Error}; use core::fmt; use core::future::Future; use core::hash::{Hash, Hasher}; -#[cfg(not(bootstrap))] -use core::marker::PointerLike; -use core::marker::{Tuple, Unsize}; +use core::marker::{PointerLike, Tuple, Unsize}; use core::mem::{self, SizedTypeProperties}; use core::ops::{ AsyncFn, AsyncFnMut, AsyncFnOnce, CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut, @@ -227,7 +225,7 @@ pub use thin::ThinBox; #[fundamental] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_insignificant_dtor] -#[cfg_attr(not(bootstrap), doc(search_unbox))] +#[doc(search_unbox)] // The declaration of the `Box` struct must be kept in sync with the // compiler or ICEs will happen. pub struct Box< @@ -235,6 +233,14 @@ pub struct Box< #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, >(Unique, A); +/// Constructs a `Box` by calling the `exchange_malloc` lang item and moving the argument into +/// the newly allocated memory. This is an intrinsic to avoid unnecessary copies. +/// +/// This is the surface syntax for `box ` expressions. +#[rustc_intrinsic] +#[unstable(feature = "liballoc_internals", issue = "none")] +pub fn box_new(x: T) -> Box; + impl Box { /// Allocates memory on the heap and then places `x` into it. /// @@ -252,8 +258,7 @@ impl Box { #[rustc_diagnostic_item = "box_new"] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn new(x: T) -> Self { - #[rustc_box] - Box::new(x) + return box_new(x); } /// Constructs a new box with uninitialized contents. @@ -262,13 +267,9 @@ impl Box { /// /// ``` /// let mut five = Box::::new_uninit(); - /// - /// let five = unsafe { - /// // Deferred initialization: - /// five.as_mut_ptr().write(5); - /// - /// five.assume_init() - /// }; + /// // Deferred initialization: + /// five.write(5); + /// let five = unsafe { five.assume_init() }; /// /// assert_eq!(*five, 5) /// ``` @@ -349,13 +350,9 @@ impl Box { /// #![feature(allocator_api)] /// /// let mut five = Box::::try_new_uninit()?; - /// - /// let five = unsafe { - /// // Deferred initialization: - /// five.as_mut_ptr().write(5); - /// - /// five.assume_init() - /// }; + /// // Deferred initialization: + /// five.write(5); + /// let five = unsafe { five.assume_init() }; /// /// assert_eq!(*five, 5); /// # Ok::<(), std::alloc::AllocError>(()) @@ -417,10 +414,8 @@ impl Box { A: Allocator, { let mut boxed = Self::new_uninit_in(alloc); - unsafe { - boxed.as_mut_ptr().write(x); - boxed.assume_init() - } + boxed.write(x); + unsafe { boxed.assume_init() } } /// Allocates memory in the given allocator then places `x` into it, @@ -445,10 +440,8 @@ impl Box { A: Allocator, { let mut boxed = Self::try_new_uninit_in(alloc)?; - unsafe { - boxed.as_mut_ptr().write(x); - Ok(boxed.assume_init()) - } + boxed.write(x); + unsafe { Ok(boxed.assume_init()) } } /// Constructs a new box with uninitialized contents in the provided allocator. @@ -461,13 +454,9 @@ impl Box { /// use std::alloc::System; /// /// let mut five = Box::::new_uninit_in(System); - /// - /// let five = unsafe { - /// // Deferred initialization: - /// five.as_mut_ptr().write(5); - /// - /// five.assume_init() - /// }; + /// // Deferred initialization: + /// five.write(5); + /// let five = unsafe { five.assume_init() }; /// /// assert_eq!(*five, 5) /// ``` @@ -499,13 +488,9 @@ impl Box { /// use std::alloc::System; /// /// let mut five = Box::::try_new_uninit_in(System)?; - /// - /// let five = unsafe { - /// // Deferred initialization: - /// five.as_mut_ptr().write(5); - /// - /// five.assume_init() - /// }; + /// // Deferred initialization: + /// five.write(5); + /// let five = unsafe { five.assume_init() }; /// /// assert_eq!(*five, 5); /// # Ok::<(), std::alloc::AllocError>(()) @@ -651,15 +636,11 @@ impl Box<[T]> { /// /// ``` /// let mut values = Box::<[u32]>::new_uninit_slice(3); - /// - /// let values = unsafe { - /// // Deferred initialization: - /// values[0].as_mut_ptr().write(1); - /// values[1].as_mut_ptr().write(2); - /// values[2].as_mut_ptr().write(3); - /// - /// values.assume_init() - /// }; + /// // Deferred initialization: + /// values[0].write(1); + /// values[1].write(2); + /// values[2].write(3); + /// let values = unsafe {values.assume_init() }; /// /// assert_eq!(*values, [1, 2, 3]) /// ``` @@ -704,13 +685,11 @@ impl Box<[T]> { /// #![feature(allocator_api)] /// /// let mut values = Box::<[u32]>::try_new_uninit_slice(3)?; - /// let values = unsafe { - /// // Deferred initialization: - /// values[0].as_mut_ptr().write(1); - /// values[1].as_mut_ptr().write(2); - /// values[2].as_mut_ptr().write(3); - /// values.assume_init() - /// }; + /// // Deferred initialization: + /// values[0].write(1); + /// values[1].write(2); + /// values[2].write(3); + /// let values = unsafe { values.assume_init() }; /// /// assert_eq!(*values, [1, 2, 3]); /// # Ok::<(), std::alloc::AllocError>(()) @@ -763,6 +742,26 @@ impl Box<[T]> { }; unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, Global).into_box(len)) } } + + /// Converts the boxed slice into a boxed array. + /// + /// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type. + /// + /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. + #[unstable(feature = "slice_as_array", issue = "133508")] + #[inline] + #[must_use] + pub fn into_array(self) -> Option> { + if self.len() == N { + let ptr = Self::into_raw(self) as *mut [T; N]; + + // SAFETY: The underlying array of a slice has the exact same layout as an actual array `[T; N]` if `N` is equal to the slice's length. + let me = unsafe { Box::from_raw(ptr) }; + Some(me) + } else { + None + } + } } impl Box<[T], A> { @@ -776,15 +775,11 @@ impl Box<[T], A> { /// use std::alloc::System; /// /// let mut values = Box::<[u32], _>::new_uninit_slice_in(3, System); - /// - /// let values = unsafe { - /// // Deferred initialization: - /// values[0].as_mut_ptr().write(1); - /// values[1].as_mut_ptr().write(2); - /// values[2].as_mut_ptr().write(3); - /// - /// values.assume_init() - /// }; + /// // Deferred initialization: + /// values[0].write(1); + /// values[1].write(2); + /// values[2].write(3); + /// let values = unsafe { values.assume_init() }; /// /// assert_eq!(*values, [1, 2, 3]) /// ``` @@ -835,13 +830,11 @@ impl Box<[T], A> { /// use std::alloc::System; /// /// let mut values = Box::<[u32], _>::try_new_uninit_slice_in(3, System)?; - /// let values = unsafe { - /// // Deferred initialization: - /// values[0].as_mut_ptr().write(1); - /// values[1].as_mut_ptr().write(2); - /// values[2].as_mut_ptr().write(3); - /// values.assume_init() - /// }; + /// // Deferred initialization: + /// values[0].write(1); + /// values[1].write(2); + /// values[2].write(3); + /// let values = unsafe { values.assume_init() }; /// /// assert_eq!(*values, [1, 2, 3]); /// # Ok::<(), std::alloc::AllocError>(()) @@ -921,13 +914,9 @@ impl Box, A> { /// /// ``` /// let mut five = Box::::new_uninit(); - /// - /// let five: Box = unsafe { - /// // Deferred initialization: - /// five.as_mut_ptr().write(5); - /// - /// five.assume_init() - /// }; + /// // Deferred initialization: + /// five.write(5); + /// let five: Box = unsafe { five.assume_init() }; /// /// assert_eq!(*five, 5) /// ``` @@ -948,8 +937,6 @@ impl Box, A> { /// # Examples /// /// ``` - /// #![feature(box_uninit_write)] - /// /// let big_box = Box::<[usize; 1024]>::new_uninit(); /// /// let mut array = [0; 1024]; @@ -965,7 +952,7 @@ impl Box, A> { /// assert_eq!(*x, i); /// } /// ``` - #[unstable(feature = "box_uninit_write", issue = "129397")] + #[stable(feature = "box_uninit_write", since = "CURRENT_RUSTC_VERSION")] #[inline] pub fn write(mut boxed: Self, value: T) -> Box { unsafe { @@ -992,15 +979,11 @@ impl Box<[mem::MaybeUninit], A> { /// /// ``` /// let mut values = Box::<[u32]>::new_uninit_slice(3); - /// - /// let values = unsafe { - /// // Deferred initialization: - /// values[0].as_mut_ptr().write(1); - /// values[1].as_mut_ptr().write(2); - /// values[2].as_mut_ptr().write(3); - /// - /// values.assume_init() - /// }; + /// // Deferred initialization: + /// values[0].write(1); + /// values[1].write(2); + /// values[2].write(3); + /// let values = unsafe { values.assume_init() }; /// /// assert_eq!(*values, [1, 2, 3]) /// ``` @@ -1027,6 +1010,8 @@ impl Box { /// memory problems. For example, a double-free may occur if the /// function is called twice on the same raw pointer. /// + /// The raw pointer must point to a block of memory allocated by the global allocator. + /// /// The safety conditions are described in the [memory layout] section. /// /// # Examples @@ -1053,7 +1038,6 @@ impl Box { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[stable(feature = "box_raw", since = "1.4.0")] #[inline] #[must_use = "call `drop(Box::from_raw(ptr))` if you intend to drop the `Box`"] @@ -1075,6 +1059,8 @@ impl Box { /// memory problems. For example, a double-free may occur if the /// function is called twice on the same `NonNull` pointer. /// + /// The non-null pointer must point to a block of memory allocated by the global allocator. + /// /// The safety conditions are described in the [memory layout] section. /// /// # Examples @@ -1106,7 +1092,6 @@ impl Box { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")] #[inline] #[must_use = "call `drop(Box::from_non_null(ptr))` if you intend to drop the `Box`"] @@ -1130,6 +1115,7 @@ impl Box { /// memory problems. For example, a double-free may occur if the /// function is called twice on the same raw pointer. /// + /// The raw pointer must point to a block of memory allocated by `alloc`. /// /// # Examples /// @@ -1162,7 +1148,6 @@ impl Box { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[unstable(feature = "allocator_api", issue = "32838")] #[rustc_const_unstable(feature = "const_box", issue = "92521")] #[inline] @@ -1184,6 +1169,7 @@ impl Box { /// memory problems. For example, a double-free may occur if the /// function is called twice on the same raw pointer. /// + /// The non-null pointer must point to a block of memory allocated by `alloc`. /// /// # Examples /// @@ -1215,7 +1201,6 @@ impl Box { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[unstable(feature = "allocator_api", issue = "32838")] // #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")] #[rustc_const_unstable(feature = "const_box", issue = "92521")] @@ -1502,7 +1487,7 @@ impl Box { /// [`as_ptr`]: Self::as_ptr #[unstable(feature = "box_as_ptr", issue = "129090")] #[rustc_never_returns_null_ptr] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[inline] pub fn as_mut_ptr(b: &mut Self) -> *mut T { // This is a primitive deref, not going through `DerefMut`, and therefore not materializing @@ -1551,7 +1536,7 @@ impl Box { /// [`as_ptr`]: Self::as_ptr #[unstable(feature = "box_as_ptr", issue = "129090")] #[rustc_never_returns_null_ptr] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[inline] pub fn as_ptr(b: &Self) -> *const T { // This is a primitive deref, not going through `DerefMut`, and therefore not materializing @@ -1689,7 +1674,20 @@ impl Default for Box { /// Creates a `Box`, with the `Default` value for T. #[inline] fn default() -> Self { - Box::write(Box::new_uninit(), T::default()) + let mut x: Box> = Box::new_uninit(); + unsafe { + // SAFETY: `x` is valid for writing and has the same layout as `T`. + // If `T::default()` panics, dropping `x` will just deallocate the Box as `MaybeUninit` + // does not have a destructor. + // + // We use `ptr::write` as `MaybeUninit::write` creates + // extra stack copies of `T` in debug mode. + // + // See https://github.com/rust-lang/rust/issues/136043 for more context. + ptr::write(&raw mut *x as *mut T, T::default()); + // SAFETY: `x` was just initialized above. + x.assume_init() + } } } @@ -1987,7 +1985,7 @@ impl + ?Sized, A: Allocator> Fn for Box { } } -#[unstable(feature = "async_fn_traits", issue = "none")] +#[stable(feature = "async_closure", since = "1.85.0")] impl + ?Sized, A: Allocator> AsyncFnOnce for Box { type Output = F::Output; type CallOnceFuture = F::CallOnceFuture; @@ -1997,7 +1995,7 @@ impl + ?Sized, A: Allocator> AsyncFnOnce } } -#[unstable(feature = "async_fn_traits", issue = "none")] +#[stable(feature = "async_closure", since = "1.85.0")] impl + ?Sized, A: Allocator> AsyncFnMut for Box { type CallRefFuture<'a> = F::CallRefFuture<'a> @@ -2009,7 +2007,7 @@ impl + ?Sized, A: Allocator> AsyncFnMut f } } -#[unstable(feature = "async_fn_traits", issue = "none")] +#[stable(feature = "async_closure", since = "1.85.0")] impl + ?Sized, A: Allocator> AsyncFn for Box { extern "rust-call" fn async_call(&self, args: Args) -> Self::CallRefFuture<'_> { F::async_call(self, args) @@ -2134,6 +2132,5 @@ impl Error for Box { } } -#[cfg(not(bootstrap))] #[unstable(feature = "pointer_like_trait", issue = "none")] impl PointerLike for Box {} diff --git a/alloc/src/boxed/convert.rs b/alloc/src/boxed/convert.rs index 4430fff66775c..8062658020239 100644 --- a/alloc/src/boxed/convert.rs +++ b/alloc/src/boxed/convert.rs @@ -110,7 +110,7 @@ impl From<&[T]> for Box<[T]> { } #[cfg(not(no_global_oom_handling))] -#[stable(feature = "box_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "box_from_mut_slice", since = "1.84.0")] impl From<&mut [T]> for Box<[T]> { /// Converts a `&mut [T]` into a `Box<[T]>` /// @@ -171,7 +171,7 @@ impl From<&str> for Box { } #[cfg(not(no_global_oom_handling))] -#[stable(feature = "box_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "box_from_mut_slice", since = "1.84.0")] impl From<&mut str> for Box { /// Converts a `&mut str` into a `Box` /// @@ -529,7 +529,6 @@ impl<'a, E: Error + 'a> From for Box { /// ``` /// use std::error::Error; /// use std::fmt; - /// use std::mem; /// /// #[derive(Debug)] /// struct AnError; @@ -543,9 +542,9 @@ impl<'a, E: Error + 'a> From for Box { /// impl Error for AnError {} /// /// let an_error = AnError; - /// assert!(0 == mem::size_of_val(&an_error)); + /// assert!(0 == size_of_val(&an_error)); /// let a_boxed_error = Box::::from(an_error); - /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// assert!(size_of::>() == size_of_val(&a_boxed_error)) /// ``` fn from(err: E) -> Box { Box::new(err) @@ -563,7 +562,6 @@ impl<'a, E: Error + Send + Sync + 'a> From for Box From for Box::from(an_error); /// assert!( - /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// size_of::>() == size_of_val(&a_boxed_error)) /// ``` fn from(err: E) -> Box { Box::new(err) @@ -600,12 +598,11 @@ impl<'a> From for Box { /// /// ``` /// use std::error::Error; - /// use std::mem; /// /// let a_string_error = "a string error".to_string(); /// let a_boxed_error = Box::::from(a_string_error); /// assert!( - /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// size_of::>() == size_of_val(&a_boxed_error)) /// ``` #[inline] fn from(err: String) -> Box { @@ -644,11 +641,10 @@ impl<'a> From for Box { /// /// ``` /// use std::error::Error; - /// use std::mem; /// /// let a_string_error = "a string error".to_string(); /// let a_boxed_error = Box::::from(a_string_error); - /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// assert!(size_of::>() == size_of_val(&a_boxed_error)) /// ``` fn from(str_err: String) -> Box { let err1: Box = From::from(str_err); @@ -668,12 +664,11 @@ impl<'a> From<&str> for Box { /// /// ``` /// use std::error::Error; - /// use std::mem; /// /// let a_str_error = "a str error"; /// let a_boxed_error = Box::::from(a_str_error); /// assert!( - /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// size_of::>() == size_of_val(&a_boxed_error)) /// ``` #[inline] fn from(err: &str) -> Box { @@ -692,11 +687,10 @@ impl<'a> From<&str> for Box { /// /// ``` /// use std::error::Error; - /// use std::mem; /// /// let a_str_error = "a str error"; /// let a_boxed_error = Box::::from(a_str_error); - /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// assert!(size_of::>() == size_of_val(&a_boxed_error)) /// ``` fn from(err: &str) -> Box { From::from(String::from(err)) @@ -712,13 +706,12 @@ impl<'a, 'b> From> for Box { /// /// ``` /// use std::error::Error; - /// use std::mem; /// use std::borrow::Cow; /// /// let a_cow_str_error = Cow::from("a str error"); /// let a_boxed_error = Box::::from(a_cow_str_error); /// assert!( - /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// size_of::>() == size_of_val(&a_boxed_error)) /// ``` fn from(err: Cow<'b, str>) -> Box { From::from(String::from(err)) @@ -734,12 +727,11 @@ impl<'a, 'b> From> for Box { /// /// ``` /// use std::error::Error; - /// use std::mem; /// use std::borrow::Cow; /// /// let a_cow_str_error = Cow::from("a str error"); /// let a_boxed_error = Box::::from(a_cow_str_error); - /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// assert!(size_of::>() == size_of_val(&a_boxed_error)) /// ``` fn from(err: Cow<'b, str>) -> Box { From::from(String::from(err)) diff --git a/alloc/src/boxed/thin.rs b/alloc/src/boxed/thin.rs index 78e5aec09b18d..21425b9846e42 100644 --- a/alloc/src/boxed/thin.rs +++ b/alloc/src/boxed/thin.rs @@ -9,9 +9,8 @@ use core::intrinsics::const_allocate; use core::marker::PhantomData; #[cfg(not(no_global_oom_handling))] use core::marker::Unsize; -use core::mem; #[cfg(not(no_global_oom_handling))] -use core::mem::SizedTypeProperties; +use core::mem::{self, SizedTypeProperties}; use core::ops::{Deref, DerefMut}; use core::ptr::{self, NonNull, Pointee}; @@ -30,7 +29,6 @@ use crate::alloc::{self, Layout, LayoutError}; /// let five = ThinBox::new(5); /// let thin_slice = ThinBox::<[i32]>::new_unsize([1, 2, 3, 4]); /// -/// use std::mem::{size_of, size_of_val}; /// let size_of_ptr = size_of::<*const ()>(); /// assert_eq!(size_of_ptr, size_of_val(&five)); /// assert_eq!(size_of_ptr, size_of_val(&thin_slice)); @@ -114,7 +112,7 @@ impl ThinBox { where T: Unsize, { - if mem::size_of::() == 0 { + if size_of::() == 0 { let ptr = WithOpaqueHeader::new_unsize_zst::(value); ThinBox { ptr, _marker: PhantomData } } else { @@ -283,9 +281,7 @@ impl WithHeader { let ptr = if layout.size() == 0 { // Some paranoia checking, mostly so that the ThinBox tests are // more able to catch issues. - debug_assert!( - value_offset == 0 && mem::size_of::() == 0 && mem::size_of::() == 0 - ); + debug_assert!(value_offset == 0 && size_of::() == 0 && size_of::() == 0); layout.dangling() } else { let ptr = alloc::alloc(layout); @@ -315,7 +311,7 @@ impl WithHeader { Dyn: Pointee + ?Sized, T: Unsize, { - assert!(mem::size_of::() == 0); + assert!(size_of::() == 0); const fn max(a: usize, b: usize) -> usize { if a > b { a } else { b } @@ -329,18 +325,16 @@ impl WithHeader { // FIXME: just call `WithHeader::alloc_layout` with size reset to 0. // Currently that's blocked on `Layout::extend` not being `const fn`. - let alloc_align = - max(mem::align_of::(), mem::align_of::<::Metadata>()); + let alloc_align = max(align_of::(), align_of::<::Metadata>()); - let alloc_size = - max(mem::align_of::(), mem::size_of::<::Metadata>()); + let alloc_size = max(align_of::(), size_of::<::Metadata>()); unsafe { // SAFETY: align is power of two because it is the maximum of two alignments. let alloc: *mut u8 = const_allocate(alloc_size, alloc_align); let metadata_offset = - alloc_size.checked_sub(mem::size_of::<::Metadata>()).unwrap(); + alloc_size.checked_sub(size_of::<::Metadata>()).unwrap(); // SAFETY: adding offset within the allocation. let metadata_ptr: *mut ::Metadata = alloc.add(metadata_offset).cast(); @@ -421,7 +415,7 @@ impl WithHeader { } const fn header_size() -> usize { - mem::size_of::() + size_of::() } fn alloc_layout(value_layout: Layout) -> Result<(Layout, usize), LayoutError> { diff --git a/alloc/src/bstr.rs b/alloc/src/bstr.rs new file mode 100644 index 0000000000000..338c7ac7f8876 --- /dev/null +++ b/alloc/src/bstr.rs @@ -0,0 +1,682 @@ +//! The `ByteStr` and `ByteString` types and trait implementations. + +// This could be more fine-grained. +#![cfg(not(no_global_oom_handling))] + +use core::borrow::{Borrow, BorrowMut}; +#[unstable(feature = "bstr", issue = "134915")] +pub use core::bstr::ByteStr; +use core::bstr::{impl_partial_eq, impl_partial_eq_n, impl_partial_eq_ord}; +use core::cmp::Ordering; +use core::ops::{ + Deref, DerefMut, DerefPure, Index, IndexMut, Range, RangeFrom, RangeFull, RangeInclusive, + RangeTo, RangeToInclusive, +}; +use core::str::FromStr; +use core::{fmt, hash}; + +use crate::borrow::{Cow, ToOwned}; +use crate::boxed::Box; +#[cfg(not(no_rc))] +use crate::rc::Rc; +use crate::string::String; +#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))] +use crate::sync::Arc; +use crate::vec::Vec; + +/// A wrapper for `Vec` representing a human-readable string that's conventionally, but not +/// always, UTF-8. +/// +/// Unlike `String`, this type permits non-UTF-8 contents, making it suitable for user input, +/// non-native filenames (as `Path` only supports native filenames), and other applications that +/// need to round-trip whatever data the user provides. +/// +/// A `ByteString` owns its contents and can grow and shrink, like a `Vec` or `String`. For a +/// borrowed byte string, see [`ByteStr`](../../std/bstr/struct.ByteStr.html). +/// +/// `ByteString` implements `Deref` to `&Vec`, so all methods available on `&Vec` are +/// available on `ByteString`. Similarly, `ByteString` implements `DerefMut` to `&mut Vec`, +/// so you can modify a `ByteString` using any method available on `&mut Vec`. +/// +/// The `Debug` and `Display` implementations for `ByteString` are the same as those for `ByteStr`, +/// showing invalid UTF-8 as hex escapes or the Unicode replacement character, respectively. +#[unstable(feature = "bstr", issue = "134915")] +#[repr(transparent)] +#[derive(Clone)] +#[doc(alias = "BString")] +pub struct ByteString(pub Vec); + +impl ByteString { + #[inline] + pub(crate) fn as_bytes(&self) -> &[u8] { + &self.0 + } + + #[inline] + pub(crate) fn as_bytestr(&self) -> &ByteStr { + ByteStr::new(&self.0) + } + + #[inline] + pub(crate) fn as_mut_bytestr(&mut self) -> &mut ByteStr { + ByteStr::from_bytes_mut(&mut self.0) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Deref for ByteString { + type Target = Vec; + + #[inline] + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl DerefMut for ByteString { + #[inline] + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +#[unstable(feature = "deref_pure_trait", issue = "87121")] +unsafe impl DerefPure for ByteString {} + +#[unstable(feature = "bstr", issue = "134915")] +impl fmt::Debug for ByteString { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(self.as_bytestr(), f) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl fmt::Display for ByteString { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(self.as_bytestr(), f) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl AsRef<[u8]> for ByteString { + #[inline] + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl AsRef for ByteString { + #[inline] + fn as_ref(&self) -> &ByteStr { + self.as_bytestr() + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl AsMut<[u8]> for ByteString { + #[inline] + fn as_mut(&mut self) -> &mut [u8] { + &mut self.0 + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl AsMut for ByteString { + #[inline] + fn as_mut(&mut self) -> &mut ByteStr { + self.as_mut_bytestr() + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Borrow<[u8]> for ByteString { + #[inline] + fn borrow(&self) -> &[u8] { + &self.0 + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Borrow for ByteString { + #[inline] + fn borrow(&self) -> &ByteStr { + self.as_bytestr() + } +} + +// `impl Borrow for Vec` omitted to avoid inference failures +// `impl Borrow for String` omitted to avoid inference failures + +#[unstable(feature = "bstr", issue = "134915")] +impl BorrowMut<[u8]> for ByteString { + #[inline] + fn borrow_mut(&mut self) -> &mut [u8] { + &mut self.0 + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl BorrowMut for ByteString { + #[inline] + fn borrow_mut(&mut self) -> &mut ByteStr { + self.as_mut_bytestr() + } +} + +// `impl BorrowMut for Vec` omitted to avoid inference failures + +#[unstable(feature = "bstr", issue = "134915")] +impl Default for ByteString { + fn default() -> Self { + ByteString(Vec::new()) + } +} + +// Omitted due to inference failures +// +// #[unstable(feature = "bstr", issue = "134915")] +// impl<'a, const N: usize> From<&'a [u8; N]> for ByteString { +// #[inline] +// fn from(s: &'a [u8; N]) -> Self { +// ByteString(s.as_slice().to_vec()) +// } +// } +// +// #[unstable(feature = "bstr", issue = "134915")] +// impl From<[u8; N]> for ByteString { +// #[inline] +// fn from(s: [u8; N]) -> Self { +// ByteString(s.as_slice().to_vec()) +// } +// } +// +// #[unstable(feature = "bstr", issue = "134915")] +// impl<'a> From<&'a [u8]> for ByteString { +// #[inline] +// fn from(s: &'a [u8]) -> Self { +// ByteString(s.to_vec()) +// } +// } +// +// #[unstable(feature = "bstr", issue = "134915")] +// impl From> for ByteString { +// #[inline] +// fn from(s: Vec) -> Self { +// ByteString(s) +// } +// } + +#[unstable(feature = "bstr", issue = "134915")] +impl From for Vec { + #[inline] + fn from(s: ByteString) -> Self { + s.0 + } +} + +// Omitted due to inference failures +// +// #[unstable(feature = "bstr", issue = "134915")] +// impl<'a> From<&'a str> for ByteString { +// #[inline] +// fn from(s: &'a str) -> Self { +// ByteString(s.as_bytes().to_vec()) +// } +// } +// +// #[unstable(feature = "bstr", issue = "134915")] +// impl From for ByteString { +// #[inline] +// fn from(s: String) -> Self { +// ByteString(s.into_bytes()) +// } +// } + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> From<&'a ByteStr> for ByteString { + #[inline] + fn from(s: &'a ByteStr) -> Self { + ByteString(s.0.to_vec()) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> From for Cow<'a, ByteStr> { + #[inline] + fn from(s: ByteString) -> Self { + Cow::Owned(s) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> From<&'a ByteString> for Cow<'a, ByteStr> { + #[inline] + fn from(s: &'a ByteString) -> Self { + Cow::Borrowed(s.as_bytestr()) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl FromIterator for ByteString { + #[inline] + fn from_iter>(iter: T) -> Self { + ByteString(iter.into_iter().collect::().into_bytes()) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl FromIterator for ByteString { + #[inline] + fn from_iter>(iter: T) -> Self { + ByteString(iter.into_iter().collect()) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> FromIterator<&'a str> for ByteString { + #[inline] + fn from_iter>(iter: T) -> Self { + ByteString(iter.into_iter().collect::().into_bytes()) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> FromIterator<&'a [u8]> for ByteString { + #[inline] + fn from_iter>(iter: T) -> Self { + let mut buf = Vec::new(); + for b in iter { + buf.extend_from_slice(b); + } + ByteString(buf) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> FromIterator<&'a ByteStr> for ByteString { + #[inline] + fn from_iter>(iter: T) -> Self { + let mut buf = Vec::new(); + for b in iter { + buf.extend_from_slice(&b.0); + } + ByteString(buf) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl FromIterator for ByteString { + #[inline] + fn from_iter>(iter: T) -> Self { + let mut buf = Vec::new(); + for mut b in iter { + buf.append(&mut b.0); + } + ByteString(buf) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl FromStr for ByteString { + type Err = core::convert::Infallible; + + #[inline] + fn from_str(s: &str) -> Result { + Ok(ByteString(s.as_bytes().to_vec())) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index for ByteString { + type Output = u8; + + #[inline] + fn index(&self, idx: usize) -> &u8 { + &self.0[idx] + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index for ByteString { + type Output = ByteStr; + + #[inline] + fn index(&self, _: RangeFull) -> &ByteStr { + self.as_bytestr() + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index> for ByteString { + type Output = ByteStr; + + #[inline] + fn index(&self, r: Range) -> &ByteStr { + ByteStr::from_bytes(&self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index> for ByteString { + type Output = ByteStr; + + #[inline] + fn index(&self, r: RangeInclusive) -> &ByteStr { + ByteStr::from_bytes(&self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index> for ByteString { + type Output = ByteStr; + + #[inline] + fn index(&self, r: RangeFrom) -> &ByteStr { + ByteStr::from_bytes(&self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index> for ByteString { + type Output = ByteStr; + + #[inline] + fn index(&self, r: RangeTo) -> &ByteStr { + ByteStr::from_bytes(&self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index> for ByteString { + type Output = ByteStr; + + #[inline] + fn index(&self, r: RangeToInclusive) -> &ByteStr { + ByteStr::from_bytes(&self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut for ByteString { + #[inline] + fn index_mut(&mut self, idx: usize) -> &mut u8 { + &mut self.0[idx] + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut for ByteString { + #[inline] + fn index_mut(&mut self, _: RangeFull) -> &mut ByteStr { + self.as_mut_bytestr() + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut> for ByteString { + #[inline] + fn index_mut(&mut self, r: Range) -> &mut ByteStr { + ByteStr::from_bytes_mut(&mut self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut> for ByteString { + #[inline] + fn index_mut(&mut self, r: RangeInclusive) -> &mut ByteStr { + ByteStr::from_bytes_mut(&mut self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut> for ByteString { + #[inline] + fn index_mut(&mut self, r: RangeFrom) -> &mut ByteStr { + ByteStr::from_bytes_mut(&mut self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut> for ByteString { + #[inline] + fn index_mut(&mut self, r: RangeTo) -> &mut ByteStr { + ByteStr::from_bytes_mut(&mut self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut> for ByteString { + #[inline] + fn index_mut(&mut self, r: RangeToInclusive) -> &mut ByteStr { + ByteStr::from_bytes_mut(&mut self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl hash::Hash for ByteString { + #[inline] + fn hash(&self, state: &mut H) { + self.0.hash(state); + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Eq for ByteString {} + +#[unstable(feature = "bstr", issue = "134915")] +impl PartialEq for ByteString { + #[inline] + fn eq(&self, other: &ByteString) -> bool { + self.0 == other.0 + } +} + +macro_rules! impl_partial_eq_ord_cow { + ($lhs:ty, $rhs:ty) => { + #[allow(unused_lifetimes)] + #[unstable(feature = "bstr", issue = "134915")] + impl<'a> PartialEq<$rhs> for $lhs { + #[inline] + fn eq(&self, other: &$rhs) -> bool { + let other: &[u8] = (&**other).as_ref(); + PartialEq::eq(self.as_bytes(), other) + } + } + + #[allow(unused_lifetimes)] + #[unstable(feature = "bstr", issue = "134915")] + impl<'a> PartialEq<$lhs> for $rhs { + #[inline] + fn eq(&self, other: &$lhs) -> bool { + let this: &[u8] = (&**self).as_ref(); + PartialEq::eq(this, other.as_bytes()) + } + } + + #[allow(unused_lifetimes)] + #[unstable(feature = "bstr", issue = "134915")] + impl<'a> PartialOrd<$rhs> for $lhs { + #[inline] + fn partial_cmp(&self, other: &$rhs) -> Option { + let other: &[u8] = (&**other).as_ref(); + PartialOrd::partial_cmp(self.as_bytes(), other) + } + } + + #[allow(unused_lifetimes)] + #[unstable(feature = "bstr", issue = "134915")] + impl<'a> PartialOrd<$lhs> for $rhs { + #[inline] + fn partial_cmp(&self, other: &$lhs) -> Option { + let this: &[u8] = (&**self).as_ref(); + PartialOrd::partial_cmp(this, other.as_bytes()) + } + } + }; +} + +// PartialOrd with `Vec` omitted to avoid inference failures +impl_partial_eq!(ByteString, Vec); +// PartialOrd with `[u8]` omitted to avoid inference failures +impl_partial_eq!(ByteString, [u8]); +// PartialOrd with `&[u8]` omitted to avoid inference failures +impl_partial_eq!(ByteString, &[u8]); +// PartialOrd with `String` omitted to avoid inference failures +impl_partial_eq!(ByteString, String); +// PartialOrd with `str` omitted to avoid inference failures +impl_partial_eq!(ByteString, str); +// PartialOrd with `&str` omitted to avoid inference failures +impl_partial_eq!(ByteString, &str); +impl_partial_eq_ord!(ByteString, ByteStr); +impl_partial_eq_ord!(ByteString, &ByteStr); +// PartialOrd with `[u8; N]` omitted to avoid inference failures +impl_partial_eq_n!(ByteString, [u8; N]); +// PartialOrd with `&[u8; N]` omitted to avoid inference failures +impl_partial_eq_n!(ByteString, &[u8; N]); +impl_partial_eq_ord_cow!(ByteString, Cow<'_, ByteStr>); +impl_partial_eq_ord_cow!(ByteString, Cow<'_, str>); +impl_partial_eq_ord_cow!(ByteString, Cow<'_, [u8]>); + +#[unstable(feature = "bstr", issue = "134915")] +impl Ord for ByteString { + #[inline] + fn cmp(&self, other: &ByteString) -> Ordering { + Ord::cmp(&self.0, &other.0) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl PartialOrd for ByteString { + #[inline] + fn partial_cmp(&self, other: &ByteString) -> Option { + PartialOrd::partial_cmp(&self.0, &other.0) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl ToOwned for ByteStr { + type Owned = ByteString; + + #[inline] + fn to_owned(&self) -> ByteString { + ByteString(self.0.to_vec()) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl TryFrom for String { + type Error = crate::string::FromUtf8Error; + + #[inline] + fn try_from(s: ByteString) -> Result { + String::from_utf8(s.0) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> TryFrom<&'a ByteString> for &'a str { + type Error = crate::str::Utf8Error; + + #[inline] + fn try_from(s: &'a ByteString) -> Result { + crate::str::from_utf8(s.0.as_slice()) + } +} + +// Additional impls for `ByteStr` that require types from `alloc`: + +#[unstable(feature = "bstr", issue = "134915")] +impl Clone for Box { + #[inline] + fn clone(&self) -> Self { + Self::from(Box::<[u8]>::from(&self.0)) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> { + #[inline] + fn from(s: &'a ByteStr) -> Self { + Cow::Borrowed(s) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl From> for Box { + #[inline] + fn from(s: Box<[u8]>) -> Box { + // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. + unsafe { Box::from_raw(Box::into_raw(s) as _) } + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl From> for Box<[u8]> { + #[inline] + fn from(s: Box) -> Box<[u8]> { + // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. + unsafe { Box::from_raw(Box::into_raw(s) as _) } + } +} + +#[unstable(feature = "bstr", issue = "134915")] +#[cfg(not(no_rc))] +impl From> for Rc { + #[inline] + fn from(s: Rc<[u8]>) -> Rc { + // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. + unsafe { Rc::from_raw(Rc::into_raw(s) as _) } + } +} + +#[unstable(feature = "bstr", issue = "134915")] +#[cfg(not(no_rc))] +impl From> for Rc<[u8]> { + #[inline] + fn from(s: Rc) -> Rc<[u8]> { + // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. + unsafe { Rc::from_raw(Rc::into_raw(s) as _) } + } +} + +#[unstable(feature = "bstr", issue = "134915")] +#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))] +impl From> for Arc { + #[inline] + fn from(s: Arc<[u8]>) -> Arc { + // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. + unsafe { Arc::from_raw(Arc::into_raw(s) as _) } + } +} + +#[unstable(feature = "bstr", issue = "134915")] +#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))] +impl From> for Arc<[u8]> { + #[inline] + fn from(s: Arc) -> Arc<[u8]> { + // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. + unsafe { Arc::from_raw(Arc::into_raw(s) as _) } + } +} + +// PartialOrd with `Vec` omitted to avoid inference failures +impl_partial_eq!(ByteStr, Vec); +// PartialOrd with `String` omitted to avoid inference failures +impl_partial_eq!(ByteStr, String); +impl_partial_eq_ord_cow!(&'a ByteStr, Cow<'a, ByteStr>); +impl_partial_eq_ord_cow!(&'a ByteStr, Cow<'a, str>); +impl_partial_eq_ord_cow!(&'a ByteStr, Cow<'a, [u8]>); + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> TryFrom<&'a ByteStr> for String { + type Error = core::str::Utf8Error; + + #[inline] + fn try_from(s: &'a ByteStr) -> Result { + Ok(core::str::from_utf8(&s.0)?.into()) + } +} diff --git a/alloc/src/collections/binary_heap/mod.rs b/alloc/src/collections/binary_heap/mod.rs index 59f10b09c73fd..63828b482b9a9 100644 --- a/alloc/src/collections/binary_heap/mod.rs +++ b/alloc/src/collections/binary_heap/mod.rs @@ -153,10 +153,9 @@ use core::{fmt, ptr}; use crate::alloc::Global; use crate::collections::TryReserveError; use crate::slice; -use crate::vec::{self, AsVecIntoIter, Vec}; - -#[cfg(test)] -mod tests; +#[cfg(not(test))] +use crate::vec::AsVecIntoIter; +use crate::vec::{self, Vec}; /// A priority queue implemented with a binary heap. /// @@ -362,6 +361,74 @@ impl DerefMut for PeekMut<'_, T, A> { } impl<'a, T: Ord, A: Allocator> PeekMut<'a, T, A> { + /// Sifts the current element to its new position. + /// + /// Afterwards refers to the new element. Returns if the element changed. + /// + /// ## Examples + /// + /// The condition can be used to upper bound all elements in the heap. When only few elements + /// are affected, the heap's sort ensures this is faster than a reconstruction from the raw + /// element list and requires no additional allocation. + /// + /// ``` + /// #![feature(binary_heap_peek_mut_refresh)] + /// use std::collections::BinaryHeap; + /// + /// let mut heap: BinaryHeap = (0..128).collect(); + /// let mut peek = heap.peek_mut().unwrap(); + /// + /// loop { + /// *peek = 99; + /// + /// if !peek.refresh() { + /// break; + /// } + /// } + /// + /// // Post condition, this is now an upper bound. + /// assert!(*peek < 100); + /// ``` + /// + /// When the element remains the maximum after modification, the peek remains unchanged: + /// + /// ``` + /// #![feature(binary_heap_peek_mut_refresh)] + /// use std::collections::BinaryHeap; + /// + /// let mut heap: BinaryHeap = [1, 2, 3].into(); + /// let mut peek = heap.peek_mut().unwrap(); + /// + /// assert_eq!(*peek, 3); + /// *peek = 42; + /// + /// // When we refresh, the peek is updated to the new maximum. + /// assert!(!peek.refresh(), "42 is even larger than 3"); + /// assert_eq!(*peek, 42); + /// ``` + #[unstable(feature = "binary_heap_peek_mut_refresh", issue = "138355")] + #[must_use = "is equivalent to dropping and getting a new PeekMut except for return information"] + pub fn refresh(&mut self) -> bool { + // The length of the underlying heap is unchanged by sifting down. The value stored for leak + // amplification thus remains accurate. We erase the leak amplification firstly because the + // operation is then equivalent to constructing a new PeekMut and secondly this avoids any + // future complication where original_len being non-empty would be interpreted as the heap + // having been leak amplified instead of checking the heap itself. + if let Some(original_len) = self.original_len.take() { + // SAFETY: This is how many elements were in the Vec at the time of + // the BinaryHeap::peek_mut call. + unsafe { self.heap.data.set_len(original_len.get()) }; + + // The length of the heap did not change by sifting, upholding our own invariants. + + // SAFETY: PeekMut is only instantiated for non-empty heaps. + (unsafe { self.heap.sift_down(0) }) != 0 + } else { + // The element was not modified. + false + } + } + /// Removes the peeked value from the heap and returns it. #[stable(feature = "binary_heap_peek_mut_pop", since = "1.18.0")] pub fn pop(mut this: PeekMut<'a, T, A>) -> T { @@ -452,7 +519,7 @@ impl BinaryHeap { /// /// The binary heap will be able to hold at least `capacity` elements without /// reallocating. This method is allowed to allocate for more elements than - /// `capacity`. If `capacity` is 0, the binary heap will not allocate. + /// `capacity`. If `capacity` is zero, the binary heap will not allocate. /// /// # Examples /// @@ -486,7 +553,6 @@ impl BinaryHeap { /// heap.push(4); /// ``` #[unstable(feature = "allocator_api", issue = "32838")] - #[rustc_const_unstable(feature = "const_binary_heap_new_in", issue = "125961")] #[must_use] pub const fn new_in(alloc: A) -> BinaryHeap { BinaryHeap { data: Vec::new_in(alloc) } @@ -496,7 +562,7 @@ impl BinaryHeap { /// /// The binary heap will be able to hold at least `capacity` elements without /// reallocating. This method is allowed to allocate for more elements than - /// `capacity`. If `capacity` is 0, the binary heap will not allocate. + /// `capacity`. If `capacity` is zero, the binary heap will not allocate. /// /// # Examples /// @@ -535,8 +601,7 @@ impl BinaryHeap { /// heap.push(1); /// heap.push(5); /// heap.push(2); - /// { - /// let mut val = heap.peek_mut().unwrap(); + /// if let Some(mut val) = heap.peek_mut() { /// *val = 0; /// } /// assert_eq!(heap.peek(), Some(&2)); @@ -675,6 +740,8 @@ impl BinaryHeap { /// # Safety /// /// The caller must guarantee that `pos < self.len()`. + /// + /// Returns the new position of the element. unsafe fn sift_up(&mut self, start: usize, pos: usize) -> usize { // Take out the value at `pos` and create a hole. // SAFETY: The caller guarantees that pos < self.len() @@ -701,10 +768,12 @@ impl BinaryHeap { /// Take an element at `pos` and move it down the heap, /// while its children are larger. /// + /// Returns the new position of the element. + /// /// # Safety /// /// The caller must guarantee that `pos < end <= self.len()`. - unsafe fn sift_down_range(&mut self, pos: usize, end: usize) { + unsafe fn sift_down_range(&mut self, pos: usize, end: usize) -> usize { // SAFETY: The caller guarantees that pos < end <= self.len(). let mut hole = unsafe { Hole::new(&mut self.data, pos) }; let mut child = 2 * hole.pos() + 1; @@ -724,7 +793,7 @@ impl BinaryHeap { // SAFETY: child is now either the old child or the old child+1 // We already proven that both are < self.len() and != hole.pos() if hole.element() >= unsafe { hole.get(child) } { - return; + return hole.pos(); } // SAFETY: same as above. @@ -739,16 +808,18 @@ impl BinaryHeap { // child == 2 * hole.pos() + 1 != hole.pos(). unsafe { hole.move_to(child) }; } + + hole.pos() } /// # Safety /// /// The caller must guarantee that `pos < self.len()`. - unsafe fn sift_down(&mut self, pos: usize) { + unsafe fn sift_down(&mut self, pos: usize) -> usize { let len = self.len(); // SAFETY: pos < len is guaranteed by the caller and // obviously len = self.len() <= self.len(). - unsafe { self.sift_down_range(pos, len) }; + unsafe { self.sift_down_range(pos, len) } } /// Take an element at `pos` and move it all the way down the heap, @@ -1605,6 +1676,7 @@ unsafe impl InPlaceIterable for IntoIter { const MERGE_BY: Option> = NonZero::new(1); } +#[cfg(not(test))] unsafe impl AsVecIntoIter for IntoIter { type Item = I; diff --git a/alloc/src/collections/btree/append.rs b/alloc/src/collections/btree/append.rs index d137d2721ee4f..091376d5d685b 100644 --- a/alloc/src/collections/btree/append.rs +++ b/alloc/src/collections/btree/append.rs @@ -16,7 +16,7 @@ impl Root { /// a `BTreeMap`, both iterators should produce keys in strictly ascending /// order, each greater than all keys in the tree, including any keys /// already in the tree upon entry. - pub fn append_from_sorted_iters( + pub(super) fn append_from_sorted_iters( &mut self, left: I, right: I, @@ -36,8 +36,12 @@ impl Root { /// Pushes all key-value pairs to the end of the tree, incrementing a /// `length` variable along the way. The latter makes it easier for the /// caller to avoid a leak when the iterator panicks. - pub fn bulk_push(&mut self, iter: I, length: &mut usize, alloc: A) - where + pub(super) fn bulk_push( + &mut self, + iter: I, + length: &mut usize, + alloc: A, + ) where I: Iterator, { let mut cur_node = self.borrow_mut().last_leaf_edge().into_node(); diff --git a/alloc/src/collections/btree/borrow.rs b/alloc/src/collections/btree/borrow.rs index 000b9bd0fab42..e848ac3f2d192 100644 --- a/alloc/src/collections/btree/borrow.rs +++ b/alloc/src/collections/btree/borrow.rs @@ -11,7 +11,7 @@ use core::ptr::NonNull; /// the compiler to follow. A `DormantMutRef` allows you to check borrowing /// yourself, while still expressing its stacked nature, and encapsulating /// the raw pointer code needed to do this without undefined behavior. -pub struct DormantMutRef<'a, T> { +pub(super) struct DormantMutRef<'a, T> { ptr: NonNull, _marker: PhantomData<&'a mut T>, } @@ -23,7 +23,7 @@ impl<'a, T> DormantMutRef<'a, T> { /// Capture a unique borrow, and immediately reborrow it. For the compiler, /// the lifetime of the new reference is the same as the lifetime of the /// original reference, but you promise to use it for a shorter period. - pub fn new(t: &'a mut T) -> (&'a mut T, Self) { + pub(super) fn new(t: &'a mut T) -> (&'a mut T, Self) { let ptr = NonNull::from(t); // SAFETY: we hold the borrow throughout 'a via `_marker`, and we expose // only this reference, so it is unique. @@ -37,7 +37,7 @@ impl<'a, T> DormantMutRef<'a, T> { /// /// The reborrow must have ended, i.e., the reference returned by `new` and /// all pointers and references derived from it, must not be used anymore. - pub unsafe fn awaken(self) -> &'a mut T { + pub(super) unsafe fn awaken(self) -> &'a mut T { // SAFETY: our own safety conditions imply this reference is again unique. unsafe { &mut *self.ptr.as_ptr() } } @@ -48,7 +48,7 @@ impl<'a, T> DormantMutRef<'a, T> { /// /// The reborrow must have ended, i.e., the reference returned by `new` and /// all pointers and references derived from it, must not be used anymore. - pub unsafe fn reborrow(&mut self) -> &'a mut T { + pub(super) unsafe fn reborrow(&mut self) -> &'a mut T { // SAFETY: our own safety conditions imply this reference is again unique. unsafe { &mut *self.ptr.as_ptr() } } @@ -59,7 +59,7 @@ impl<'a, T> DormantMutRef<'a, T> { /// /// The reborrow must have ended, i.e., the reference returned by `new` and /// all pointers and references derived from it, must not be used anymore. - pub unsafe fn reborrow_shared(&self) -> &'a T { + pub(super) unsafe fn reborrow_shared(&self) -> &'a T { // SAFETY: our own safety conditions imply this reference is again unique. unsafe { &*self.ptr.as_ptr() } } diff --git a/alloc/src/collections/btree/dedup_sorted_iter.rs b/alloc/src/collections/btree/dedup_sorted_iter.rs index cd6a88f329125..6bcf0bca519af 100644 --- a/alloc/src/collections/btree/dedup_sorted_iter.rs +++ b/alloc/src/collections/btree/dedup_sorted_iter.rs @@ -6,7 +6,7 @@ use core::iter::Peekable; /// Used by [`BTreeMap::bulk_build_from_sorted_iter`][1]. /// /// [1]: crate::collections::BTreeMap::bulk_build_from_sorted_iter -pub struct DedupSortedIter +pub(super) struct DedupSortedIter where I: Iterator, { @@ -17,7 +17,7 @@ impl DedupSortedIter where I: Iterator, { - pub fn new(iter: I) -> Self { + pub(super) fn new(iter: I) -> Self { Self { iter: iter.peekable() } } } diff --git a/alloc/src/collections/btree/fix.rs b/alloc/src/collections/btree/fix.rs index 09edea3555ad5..b0c6759794691 100644 --- a/alloc/src/collections/btree/fix.rs +++ b/alloc/src/collections/btree/fix.rs @@ -57,7 +57,10 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> { /// /// This method does not expect ancestors to already be underfull upon entry /// and panics if it encounters an empty ancestor. - pub fn fix_node_and_affected_ancestors(mut self, alloc: A) -> bool { + pub(super) fn fix_node_and_affected_ancestors( + mut self, + alloc: A, + ) -> bool { loop { match self.fix_node_through_parent(alloc.clone()) { Ok(Some(parent)) => self = parent.forget_type(), @@ -70,7 +73,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> { impl Root { /// Removes empty levels on the top, but keeps an empty leaf if the entire tree is empty. - pub fn fix_top(&mut self, alloc: A) { + pub(super) fn fix_top(&mut self, alloc: A) { while self.height() > 0 && self.len() == 0 { self.pop_internal_level(alloc.clone()); } @@ -79,7 +82,7 @@ impl Root { /// Stocks up or merge away any underfull nodes on the right border of the /// tree. The other nodes, those that are not the root nor a rightmost edge, /// must already have at least MIN_LEN elements. - pub fn fix_right_border(&mut self, alloc: A) { + pub(super) fn fix_right_border(&mut self, alloc: A) { self.fix_top(alloc.clone()); if self.len() > 0 { self.borrow_mut().last_kv().fix_right_border_of_right_edge(alloc.clone()); @@ -88,7 +91,7 @@ impl Root { } /// The symmetric clone of `fix_right_border`. - pub fn fix_left_border(&mut self, alloc: A) { + pub(super) fn fix_left_border(&mut self, alloc: A) { self.fix_top(alloc.clone()); if self.len() > 0 { self.borrow_mut().first_kv().fix_left_border_of_left_edge(alloc.clone()); @@ -99,7 +102,7 @@ impl Root { /// Stocks up any underfull nodes on the right border of the tree. /// The other nodes, those that are neither the root nor a rightmost edge, /// must be prepared to have up to MIN_LEN elements stolen. - pub fn fix_right_border_of_plentiful(&mut self) { + pub(super) fn fix_right_border_of_plentiful(&mut self) { let mut cur_node = self.borrow_mut(); while let Internal(internal) = cur_node.force() { // Check if rightmost child is underfull. diff --git a/alloc/src/collections/btree/map.rs b/alloc/src/collections/btree/map.rs index 213924d1d0203..78b7da9d6b3ee 100644 --- a/alloc/src/collections/btree/map.rs +++ b/alloc/src/collections/btree/map.rs @@ -289,7 +289,7 @@ impl Clone for BTreeMap { } } -/// Internal functionality for `BTreeSet`. +// Internal functionality for `BTreeSet`. impl BTreeMap { pub(super) fn replace(&mut self, key: K) -> Option where @@ -308,11 +308,38 @@ impl BTreeMap { alloc: (*map.alloc).clone(), _marker: PhantomData, } - .insert(SetValZST::default()); + .insert(SetValZST); None } } } + + pub(super) fn get_or_insert_with(&mut self, q: &Q, f: F) -> &K + where + K: Borrow + Ord, + Q: Ord, + F: FnOnce(&Q) -> K, + { + let (map, dormant_map) = DormantMutRef::new(self); + let root_node = + map.root.get_or_insert_with(|| Root::new((*map.alloc).clone())).borrow_mut(); + match root_node.search_tree(q) { + Found(handle) => handle.into_kv_mut().0, + GoDown(handle) => { + let key = f(q); + assert!(*key.borrow() == *q, "new value is not equal"); + VacantEntry { + key, + handle: Some(handle), + dormant_map, + alloc: (*map.alloc).clone(), + _marker: PhantomData, + } + .insert_entry(SetValZST) + .into_key() + } + } + } } /// An iterator over the entries of a `BTreeMap`. @@ -2262,6 +2289,10 @@ impl FusedIterator for RangeMut<'_, K, V> {} #[stable(feature = "rust1", since = "1.0.0")] impl FromIterator<(K, V)> for BTreeMap { + /// Constructs a `BTreeMap` from an iterator of key-value pairs. + /// + /// If the iterator produces any pairs with equal keys, + /// all but one of the corresponding values will be dropped. fn from_iter>(iter: T) -> BTreeMap { let mut inputs: Vec<_> = iter.into_iter().collect(); @@ -2376,7 +2407,10 @@ where #[stable(feature = "std_collections_from_array", since = "1.56.0")] impl From<[(K, V); N]> for BTreeMap { - /// Converts a `[(K, V); N]` into a `BTreeMap<(K, V)>`. + /// Converts a `[(K, V); N]` into a `BTreeMap`. + /// + /// If any entries in the array have equal keys, + /// all but one of the corresponding values will be dropped. /// /// ``` /// use std::collections::BTreeMap; diff --git a/alloc/src/collections/btree/map/entry.rs b/alloc/src/collections/btree/map/entry.rs index 75bb86916a887..ea8fa363c3805 100644 --- a/alloc/src/collections/btree/map/entry.rs +++ b/alloc/src/collections/btree/map/entry.rs @@ -269,6 +269,31 @@ impl<'a, K: Ord, V, A: Allocator + Clone> Entry<'a, K, V, A> { Vacant(entry) => Vacant(entry), } } + + /// Sets the value of the entry, and returns an `OccupiedEntry`. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_entry_insert)] + /// use std::collections::BTreeMap; + /// + /// let mut map: BTreeMap<&str, String> = BTreeMap::new(); + /// let entry = map.entry("poneyland").insert_entry("hoho".to_string()); + /// + /// assert_eq!(entry.key(), &"poneyland"); + /// ``` + #[inline] + #[unstable(feature = "btree_entry_insert", issue = "65225")] + pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, A> { + match self { + Occupied(mut entry) => { + entry.insert(value); + entry + } + Vacant(entry) => entry.insert_entry(value), + } + } } impl<'a, K: Ord, V: Default, A: Allocator + Clone> Entry<'a, K, V, A> { @@ -348,41 +373,61 @@ impl<'a, K: Ord, V, A: Allocator + Clone> VacantEntry<'a, K, V, A> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_confusables("push", "put")] - pub fn insert(mut self, value: V) -> &'a mut V { - let out_ptr = match self.handle { + pub fn insert(self, value: V) -> &'a mut V { + self.insert_entry(value).into_mut() + } + + /// Sets the value of the entry with the `VacantEntry`'s key, + /// and returns an `OccupiedEntry`. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_entry_insert)] + /// use std::collections::BTreeMap; + /// use std::collections::btree_map::Entry; + /// + /// let mut map: BTreeMap<&str, u32> = BTreeMap::new(); + /// + /// if let Entry::Vacant(o) = map.entry("poneyland") { + /// let entry = o.insert_entry(37); + /// assert_eq!(entry.get(), &37); + /// } + /// assert_eq!(map["poneyland"], 37); + /// ``` + #[unstable(feature = "btree_entry_insert", issue = "65225")] + pub fn insert_entry(mut self, value: V) -> OccupiedEntry<'a, K, V, A> { + let handle = match self.handle { None => { // SAFETY: There is no tree yet so no reference to it exists. - let map = unsafe { self.dormant_map.awaken() }; - let mut root = NodeRef::new_leaf(self.alloc.clone()); - let val_ptr = root.borrow_mut().push(self.key, value); - map.root = Some(root.forget_type()); - map.length = 1; - val_ptr - } - Some(handle) => { - let new_handle = - handle.insert_recursing(self.key, value, self.alloc.clone(), |ins| { - drop(ins.left); - // SAFETY: Pushing a new root node doesn't invalidate - // handles to existing nodes. - let map = unsafe { self.dormant_map.reborrow() }; - let root = map.root.as_mut().unwrap(); // same as ins.left - root.push_internal_level(self.alloc).push(ins.kv.0, ins.kv.1, ins.right) - }); - - // Get the pointer to the value - let val_ptr = new_handle.into_val_mut(); - - // SAFETY: We have consumed self.handle. - let map = unsafe { self.dormant_map.awaken() }; - map.length += 1; - val_ptr + let map = unsafe { self.dormant_map.reborrow() }; + let root = map.root.insert(NodeRef::new_leaf(self.alloc.clone()).forget_type()); + // SAFETY: We *just* created the root as a leaf, and we're + // stacking the new handle on the original borrow lifetime. + unsafe { + let mut leaf = root.borrow_mut().cast_to_leaf_unchecked(); + leaf.push_with_handle(self.key, value) + } } + Some(handle) => handle.insert_recursing(self.key, value, self.alloc.clone(), |ins| { + drop(ins.left); + // SAFETY: Pushing a new root node doesn't invalidate + // handles to existing nodes. + let map = unsafe { self.dormant_map.reborrow() }; + let root = map.root.as_mut().unwrap(); // same as ins.left + root.push_internal_level(self.alloc.clone()).push(ins.kv.0, ins.kv.1, ins.right) + }), }; - // Now that we have finished growing the tree using borrowed references, - // dereference the pointer to a part of it, that we picked up along the way. - unsafe { &mut *out_ptr } + // SAFETY: modifying the length doesn't invalidate handles to existing nodes. + unsafe { self.dormant_map.reborrow().length += 1 }; + + OccupiedEntry { + handle: handle.forget_node_type(), + dormant_map: self.dormant_map, + alloc: self.alloc, + _marker: PhantomData, + } } } @@ -404,6 +449,11 @@ impl<'a, K: Ord, V, A: Allocator + Clone> OccupiedEntry<'a, K, V, A> { self.handle.reborrow().into_kv().0 } + /// Converts the entry into a reference to its key. + pub(crate) fn into_key(self) -> &'a K { + self.handle.into_kv_mut().0 + } + /// Take ownership of the key and value from the map. /// /// # Examples diff --git a/alloc/src/collections/btree/mem.rs b/alloc/src/collections/btree/mem.rs index d738c5c47b4cc..4643c4133d55d 100644 --- a/alloc/src/collections/btree/mem.rs +++ b/alloc/src/collections/btree/mem.rs @@ -6,7 +6,7 @@ use core::{intrinsics, mem, ptr}; /// If a panic occurs in the `change` closure, the entire process will be aborted. #[allow(dead_code)] // keep as illustration and for future use #[inline] -pub fn take_mut(v: &mut T, change: impl FnOnce(T) -> T) { +pub(super) fn take_mut(v: &mut T, change: impl FnOnce(T) -> T) { replace(v, |value| (change(value), ())) } @@ -15,7 +15,7 @@ pub fn take_mut(v: &mut T, change: impl FnOnce(T) -> T) { /// /// If a panic occurs in the `change` closure, the entire process will be aborted. #[inline] -pub fn replace(v: &mut T, change: impl FnOnce(T) -> (T, R)) -> R { +pub(super) fn replace(v: &mut T, change: impl FnOnce(T) -> (T, R)) -> R { struct PanicGuard; impl Drop for PanicGuard { fn drop(&mut self) { diff --git a/alloc/src/collections/btree/merge_iter.rs b/alloc/src/collections/btree/merge_iter.rs index 7f23d93b990f5..5077062e25d87 100644 --- a/alloc/src/collections/btree/merge_iter.rs +++ b/alloc/src/collections/btree/merge_iter.rs @@ -4,7 +4,7 @@ use core::iter::FusedIterator; /// Core of an iterator that merges the output of two strictly ascending iterators, /// for instance a union or a symmetric difference. -pub struct MergeIterInner { +pub(super) struct MergeIterInner { a: I, b: I, peeked: Option>, @@ -40,7 +40,7 @@ where impl MergeIterInner { /// Creates a new core for an iterator merging a pair of sources. - pub fn new(a: I, b: I) -> Self { + pub(super) fn new(a: I, b: I) -> Self { MergeIterInner { a, b, peeked: None } } @@ -51,7 +51,7 @@ impl MergeIterInner { /// the sources are not strictly ascending). If neither returned option /// contains a value, iteration has finished and subsequent calls will /// return the same empty pair. - pub fn nexts Ordering>( + pub(super) fn nexts Ordering>( &mut self, cmp: Cmp, ) -> (Option, Option) @@ -74,7 +74,7 @@ impl MergeIterInner { b_next = self.b.next(); } } - if let (Some(ref a1), Some(ref b1)) = (&a_next, &b_next) { + if let (Some(a1), Some(b1)) = (&a_next, &b_next) { match cmp(a1, b1) { Ordering::Less => self.peeked = b_next.take().map(Peeked::B), Ordering::Greater => self.peeked = a_next.take().map(Peeked::A), @@ -85,7 +85,7 @@ impl MergeIterInner { } /// Returns a pair of upper bounds for the `size_hint` of the final iterator. - pub fn lens(&self) -> (usize, usize) + pub(super) fn lens(&self) -> (usize, usize) where I: ExactSizeIterator, { diff --git a/alloc/src/collections/btree/mod.rs b/alloc/src/collections/btree/mod.rs index b8667d09c33b3..6651480667391 100644 --- a/alloc/src/collections/btree/mod.rs +++ b/alloc/src/collections/btree/mod.rs @@ -2,13 +2,13 @@ mod append; mod borrow; mod dedup_sorted_iter; mod fix; -pub mod map; +pub(super) mod map; mod mem; mod merge_iter; mod navigate; mod node; mod remove; mod search; -pub mod set; +pub(super) mod set; mod set_val; mod split; diff --git a/alloc/src/collections/btree/navigate.rs b/alloc/src/collections/btree/navigate.rs index 14b7d4ad71f86..b2a7de74875d9 100644 --- a/alloc/src/collections/btree/navigate.rs +++ b/alloc/src/collections/btree/navigate.rs @@ -7,7 +7,7 @@ use super::node::{Handle, NodeRef, marker}; use super::search::SearchBound; use crate::alloc::Allocator; // `front` and `back` are always both `None` or both `Some`. -pub struct LeafRange { +pub(super) struct LeafRange { front: Option, marker::Edge>>, back: Option, marker::Edge>>, } @@ -25,7 +25,7 @@ impl Default for LeafRange { } impl LeafRange { - pub fn none() -> Self { + pub(super) fn none() -> Self { LeafRange { front: None, back: None } } @@ -34,7 +34,7 @@ impl LeafRange { } /// Temporarily takes out another, immutable equivalent of the same range. - pub fn reborrow(&self) -> LeafRange, K, V> { + pub(super) fn reborrow(&self) -> LeafRange, K, V> { LeafRange { front: self.front.as_ref().map(|f| f.reborrow()), back: self.back.as_ref().map(|b| b.reborrow()), @@ -44,24 +44,24 @@ impl LeafRange { impl<'a, K, V> LeafRange, K, V> { #[inline] - pub fn next_checked(&mut self) -> Option<(&'a K, &'a V)> { + pub(super) fn next_checked(&mut self) -> Option<(&'a K, &'a V)> { self.perform_next_checked(|kv| kv.into_kv()) } #[inline] - pub fn next_back_checked(&mut self) -> Option<(&'a K, &'a V)> { + pub(super) fn next_back_checked(&mut self) -> Option<(&'a K, &'a V)> { self.perform_next_back_checked(|kv| kv.into_kv()) } } impl<'a, K, V> LeafRange, K, V> { #[inline] - pub fn next_checked(&mut self) -> Option<(&'a K, &'a mut V)> { + pub(super) fn next_checked(&mut self) -> Option<(&'a K, &'a mut V)> { self.perform_next_checked(|kv| unsafe { ptr::read(kv) }.into_kv_valmut()) } #[inline] - pub fn next_back_checked(&mut self) -> Option<(&'a K, &'a mut V)> { + pub(super) fn next_back_checked(&mut self) -> Option<(&'a K, &'a mut V)> { self.perform_next_back_checked(|kv| unsafe { ptr::read(kv) }.into_kv_valmut()) } } @@ -124,7 +124,7 @@ impl LazyLeafHandle { } // `front` and `back` are always both `None` or both `Some`. -pub struct LazyLeafRange { +pub(super) struct LazyLeafRange { front: Option>, back: Option>, } @@ -142,12 +142,12 @@ impl<'a, K: 'a, V: 'a> Clone for LazyLeafRange, K, V> { } impl LazyLeafRange { - pub fn none() -> Self { + pub(super) fn none() -> Self { LazyLeafRange { front: None, back: None } } /// Temporarily takes out another, immutable equivalent of the same range. - pub fn reborrow(&self) -> LazyLeafRange, K, V> { + pub(super) fn reborrow(&self) -> LazyLeafRange, K, V> { LazyLeafRange { front: self.front.as_ref().map(|f| f.reborrow()), back: self.back.as_ref().map(|b| b.reborrow()), @@ -157,24 +157,24 @@ impl LazyLeafRange { impl<'a, K, V> LazyLeafRange, K, V> { #[inline] - pub unsafe fn next_unchecked(&mut self) -> (&'a K, &'a V) { + pub(super) unsafe fn next_unchecked(&mut self) -> (&'a K, &'a V) { unsafe { self.init_front().unwrap().next_unchecked() } } #[inline] - pub unsafe fn next_back_unchecked(&mut self) -> (&'a K, &'a V) { + pub(super) unsafe fn next_back_unchecked(&mut self) -> (&'a K, &'a V) { unsafe { self.init_back().unwrap().next_back_unchecked() } } } impl<'a, K, V> LazyLeafRange, K, V> { #[inline] - pub unsafe fn next_unchecked(&mut self) -> (&'a K, &'a mut V) { + pub(super) unsafe fn next_unchecked(&mut self) -> (&'a K, &'a mut V) { unsafe { self.init_front().unwrap().next_unchecked() } } #[inline] - pub unsafe fn next_back_unchecked(&mut self) -> (&'a K, &'a mut V) { + pub(super) unsafe fn next_back_unchecked(&mut self) -> (&'a K, &'a mut V) { unsafe { self.init_back().unwrap().next_back_unchecked() } } } @@ -190,7 +190,7 @@ impl LazyLeafRange { } #[inline] - pub unsafe fn deallocating_next_unchecked( + pub(super) unsafe fn deallocating_next_unchecked( &mut self, alloc: A, ) -> Handle, marker::KV> { @@ -200,7 +200,7 @@ impl LazyLeafRange { } #[inline] - pub unsafe fn deallocating_next_back_unchecked( + pub(super) unsafe fn deallocating_next_back_unchecked( &mut self, alloc: A, ) -> Handle, marker::KV> { @@ -210,7 +210,7 @@ impl LazyLeafRange { } #[inline] - pub fn deallocating_end(&mut self, alloc: A) { + pub(super) fn deallocating_end(&mut self, alloc: A) { if let Some(front) = self.take_front() { front.deallocating_end(alloc) } @@ -313,7 +313,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> /// /// The result is meaningful only if the tree is ordered by key, like the tree /// in a `BTreeMap` is. - pub fn range_search(self, range: R) -> LeafRange, K, V> + pub(super) fn range_search(self, range: R) -> LeafRange, K, V> where Q: ?Sized + Ord, K: Borrow, @@ -324,7 +324,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> } /// Finds the pair of leaf edges delimiting an entire tree. - pub fn full_range(self) -> LazyLeafRange, K, V> { + pub(super) fn full_range(self) -> LazyLeafRange, K, V> { full_range(self, self) } } @@ -339,7 +339,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> /// /// # Safety /// Do not use the duplicate handles to visit the same KV twice. - pub fn range_search(self, range: R) -> LeafRange, K, V> + pub(super) fn range_search(self, range: R) -> LeafRange, K, V> where Q: ?Sized + Ord, K: Borrow, @@ -351,7 +351,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> /// Splits a unique reference into a pair of leaf edges delimiting the full range of the tree. /// The results are non-unique references allowing mutation (of values only), so must be used /// with care. - pub fn full_range(self) -> LazyLeafRange, K, V> { + pub(super) fn full_range(self) -> LazyLeafRange, K, V> { // We duplicate the root NodeRef here -- we will never visit the same KV // twice, and never end up with overlapping value references. let self2 = unsafe { ptr::read(&self) }; @@ -363,7 +363,7 @@ impl NodeRef { /// Splits a unique reference into a pair of leaf edges delimiting the full range of the tree. /// The results are non-unique references allowing massively destructive mutation, so must be /// used with the utmost care. - pub fn full_range(self) -> LazyLeafRange { + pub(super) fn full_range(self) -> LazyLeafRange { // We duplicate the root NodeRef here -- we will never access it in a way // that overlaps references obtained from the root. let self2 = unsafe { ptr::read(&self) }; @@ -377,7 +377,7 @@ impl /// Given a leaf edge handle, returns [`Result::Ok`] with a handle to the neighboring KV /// on the right side, which is either in the same leaf node or in an ancestor node. /// If the leaf edge is the last one in the tree, returns [`Result::Err`] with the root node. - pub fn next_kv( + pub(super) fn next_kv( self, ) -> Result< Handle, marker::KV>, @@ -398,7 +398,7 @@ impl /// Given a leaf edge handle, returns [`Result::Ok`] with a handle to the neighboring KV /// on the left side, which is either in the same leaf node or in an ancestor node. /// If the leaf edge is the first one in the tree, returns [`Result::Err`] with the root node. - pub fn next_back_kv( + pub(super) fn next_back_kv( self, ) -> Result< Handle, marker::KV>, @@ -627,7 +627,9 @@ impl NodeRef Handle, marker::Edge> { + pub(super) fn first_leaf_edge( + self, + ) -> Handle, marker::Edge> { let mut node = self; loop { match node.force() { @@ -640,7 +642,9 @@ impl NodeRef Handle, marker::Edge> { + pub(super) fn last_leaf_edge( + self, + ) -> Handle, marker::Edge> { let mut node = self; loop { match node.force() { @@ -651,7 +655,7 @@ impl NodeRef { +pub(super) enum Position { Leaf(NodeRef), Internal(NodeRef), InternalKV, @@ -661,7 +665,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> /// Visits leaf nodes and internal KVs in order of ascending keys, and also /// visits internal nodes as a whole in a depth first order, meaning that /// internal nodes precede their individual KVs and their child nodes. - pub fn visit_nodes_in_order(self, mut visit: F) + pub(super) fn visit_nodes_in_order(self, mut visit: F) where F: FnMut(Position, K, V>), { @@ -693,7 +697,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> } /// Calculates the number of elements in a (sub)tree. - pub fn calc_length(self) -> usize { + pub(super) fn calc_length(self) -> usize { let mut result = 0; self.visit_nodes_in_order(|pos| match pos { Position::Leaf(node) => result += node.len(), @@ -708,7 +712,9 @@ impl Handle, marker::KV> { /// Returns the leaf edge closest to a KV for forward navigation. - pub fn next_leaf_edge(self) -> Handle, marker::Edge> { + pub(super) fn next_leaf_edge( + self, + ) -> Handle, marker::Edge> { match self.force() { Leaf(leaf_kv) => leaf_kv.right_edge(), Internal(internal_kv) => { @@ -719,7 +725,7 @@ impl } /// Returns the leaf edge closest to a KV for backward navigation. - pub fn next_back_leaf_edge( + pub(super) fn next_back_leaf_edge( self, ) -> Handle, marker::Edge> { match self.force() { @@ -735,7 +741,7 @@ impl impl NodeRef { /// Returns the leaf edge corresponding to the first point at which the /// given bound is true. - pub fn lower_bound( + pub(super) fn lower_bound( self, mut bound: SearchBound<&Q>, ) -> Handle, marker::Edge> @@ -758,7 +764,7 @@ impl NodeRef( + pub(super) fn upper_bound( self, mut bound: SearchBound<&Q>, ) -> Handle, marker::Edge> diff --git a/alloc/src/collections/btree/node.rs b/alloc/src/collections/btree/node.rs index 64a13bb6a0b3a..37f784a322cad 100644 --- a/alloc/src/collections/btree/node.rs +++ b/alloc/src/collections/btree/node.rs @@ -40,8 +40,8 @@ use crate::alloc::{Allocator, Layout}; use crate::boxed::Box; const B: usize = 6; -pub const CAPACITY: usize = 2 * B - 1; -pub const MIN_LEN_AFTER_SPLIT: usize = B - 1; +pub(super) const CAPACITY: usize = 2 * B - 1; +pub(super) const MIN_LEN_AFTER_SPLIT: usize = B - 1; const KV_IDX_CENTER: usize = B - 1; const EDGE_IDX_LEFT_OF_CENTER: usize = B - 1; const EDGE_IDX_RIGHT_OF_CENTER: usize = B; @@ -179,7 +179,7 @@ type BoxedNode = NonNull>; /// as the returned reference is used. /// The methods supporting insert bend this rule by returning a raw pointer, /// i.e., a reference without any lifetime. -pub struct NodeRef { +pub(super) struct NodeRef { /// The number of levels that the node and the level of leaves are apart, a /// constant of the node that cannot be entirely described by `Type`, and that /// the node itself does not store. We only need to store the height of the root @@ -195,7 +195,7 @@ pub struct NodeRef { /// The root node of an owned tree. /// /// Note that this does not have a destructor, and must be cleaned up manually. -pub type Root = NodeRef; +pub(super) type Root = NodeRef; impl<'a, K: 'a, V: 'a, Type> Copy for NodeRef, K, V, Type> {} impl<'a, K: 'a, V: 'a, Type> Clone for NodeRef, K, V, Type> { @@ -213,7 +213,7 @@ unsafe impl Send for NodeRef unsafe impl Send for NodeRef {} impl NodeRef { - pub fn new_leaf(alloc: A) -> Self { + pub(super) fn new_leaf(alloc: A) -> Self { Self::from_new_leaf(LeafNode::new(alloc)) } @@ -274,7 +274,7 @@ impl NodeRef { /// The number of edges is `len() + 1`. /// Note that, despite being safe, calling this function can have the side effect /// of invalidating mutable references that unsafe code has created. - pub fn len(&self) -> usize { + pub(super) fn len(&self) -> usize { // Crucially, we only access the `len` field here. If BorrowType is marker::ValMut, // there might be outstanding mutable references to values that we must not invalidate. unsafe { usize::from((*Self::as_leaf_ptr(self)).len) } @@ -285,12 +285,12 @@ impl NodeRef { /// root on top, the number says at which elevation the node appears. /// If you picture trees with leaves on top, the number says how high /// the tree extends above the node. - pub fn height(&self) -> usize { + pub(super) fn height(&self) -> usize { self.height } /// Temporarily takes out another, immutable reference to the same node. - pub fn reborrow(&self) -> NodeRef, K, V, Type> { + pub(super) fn reborrow(&self) -> NodeRef, K, V, Type> { NodeRef { height: self.height, node: self.node, _marker: PhantomData } } @@ -315,7 +315,7 @@ impl NodeRef /// /// `edge.descend().ascend().unwrap()` and `node.ascend().unwrap().descend()` should /// both, upon success, do nothing. - pub fn ascend( + pub(super) fn ascend( self, ) -> Result, marker::Edge>, Self> { const { @@ -335,24 +335,24 @@ impl NodeRef .ok_or(self) } - pub fn first_edge(self) -> Handle { + pub(super) fn first_edge(self) -> Handle { unsafe { Handle::new_edge(self, 0) } } - pub fn last_edge(self) -> Handle { + pub(super) fn last_edge(self) -> Handle { let len = self.len(); unsafe { Handle::new_edge(self, len) } } /// Note that `self` must be nonempty. - pub fn first_kv(self) -> Handle { + pub(super) fn first_kv(self) -> Handle { let len = self.len(); assert!(len > 0); unsafe { Handle::new_kv(self, 0) } } /// Note that `self` must be nonempty. - pub fn last_kv(self) -> Handle { + pub(super) fn last_kv(self) -> Handle { let len = self.len(); assert!(len > 0); unsafe { Handle::new_kv(self, len - 1) } @@ -381,11 +381,9 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef, K, V, Type> { } /// Borrows a view into the keys stored in the node. - pub fn keys(&self) -> &[K] { + pub(super) fn keys(&self) -> &[K] { let leaf = self.into_leaf(); - unsafe { - MaybeUninit::slice_assume_init_ref(leaf.keys.get_unchecked(..usize::from(leaf.len))) - } + unsafe { leaf.keys.get_unchecked(..usize::from(leaf.len)).assume_init_ref() } } } @@ -393,7 +391,7 @@ impl NodeRef { /// Similar to `ascend`, gets a reference to a node's parent node, but also /// deallocates the current node in the process. This is unsafe because the /// current node will still be accessible despite being deallocated. - pub unsafe fn deallocate_and_ascend( + pub(super) unsafe fn deallocate_and_ascend( self, alloc: A, ) -> Option, marker::Edge>> { @@ -445,7 +443,7 @@ impl<'a, K, V, Type> NodeRef, K, V, Type> { /// Returns a dormant copy of this node with its lifetime erased which can /// be reawakened later. - pub fn dormant(&self) -> NodeRef { + pub(super) fn dormant(&self) -> NodeRef { NodeRef { height: self.height, node: self.node, _marker: PhantomData } } } @@ -457,7 +455,7 @@ impl NodeRef { /// /// The reborrow must have ended, i.e., the reference returned by `new` and /// all pointers and references derived from it, must not be used anymore. - pub unsafe fn awaken<'a>(self) -> NodeRef, K, V, Type> { + pub(super) unsafe fn awaken<'a>(self) -> NodeRef, K, V, Type> { NodeRef { height: self.height, node: self.node, _marker: PhantomData } } } @@ -538,7 +536,7 @@ impl<'a, K, V, Type> NodeRef, K, V, Type> { impl<'a, K: 'a, V: 'a, Type> NodeRef, K, V, Type> { /// Borrows exclusive access to the length of the node. - pub fn len_mut(&mut self) -> &mut u16 { + pub(super) fn len_mut(&mut self) -> &mut u16 { &mut self.as_leaf_mut().len } } @@ -580,14 +578,14 @@ impl NodeRef { impl NodeRef { /// Returns a new owned tree, with its own root node that is initially empty. - pub fn new(alloc: A) -> Self { + pub(super) fn new(alloc: A) -> Self { NodeRef::new_leaf(alloc).forget_type() } /// Adds a new internal node with a single edge pointing to the previous root node, /// make that new node the root node, and return it. This increases the height by 1 /// and is the opposite of `pop_internal_level`. - pub fn push_internal_level( + pub(super) fn push_internal_level( &mut self, alloc: A, ) -> NodeRef, K, V, marker::Internal> { @@ -602,11 +600,11 @@ impl NodeRef { /// no cleanup is done on any of the keys, values and other children. /// This decreases the height by 1 and is the opposite of `push_internal_level`. /// - /// Requires exclusive access to the `NodeRef` object but not to the root node; - /// it will not invalidate other handles or references to the root node. + /// Does not invalidate any handles or references pointing into the subtree + /// rooted at the first child of `self`. /// /// Panics if there is no internal level, i.e., if the root node is a leaf. - pub fn pop_internal_level(&mut self, alloc: A) { + pub(super) fn pop_internal_level(&mut self, alloc: A) { assert!(self.height > 0); let top = self.node; @@ -630,18 +628,18 @@ impl NodeRef { /// Mutably borrows the owned root node. Unlike `reborrow_mut`, this is safe /// because the return value cannot be used to destroy the root, and there /// cannot be other references to the tree. - pub fn borrow_mut(&mut self) -> NodeRef, K, V, Type> { + pub(super) fn borrow_mut(&mut self) -> NodeRef, K, V, Type> { NodeRef { height: self.height, node: self.node, _marker: PhantomData } } /// Slightly mutably borrows the owned root node. - pub fn borrow_valmut(&mut self) -> NodeRef, K, V, Type> { + pub(super) fn borrow_valmut(&mut self) -> NodeRef, K, V, Type> { NodeRef { height: self.height, node: self.node, _marker: PhantomData } } /// Irreversibly transitions to a reference that permits traversal and offers /// destructive methods and little else. - pub fn into_dying(self) -> NodeRef { + pub(super) fn into_dying(self) -> NodeRef { NodeRef { height: self.height, node: self.node, _marker: PhantomData } } } @@ -653,7 +651,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::Leaf> { /// # Safety /// /// The returned handle has an unbound lifetime. - pub unsafe fn push_with_handle<'b>( + pub(super) unsafe fn push_with_handle<'b>( &mut self, key: K, val: V, @@ -674,7 +672,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::Leaf> { /// Adds a key-value pair to the end of the node, and returns /// the mutable reference of the inserted value. - pub fn push(&mut self, key: K, val: V) -> *mut V { + pub(super) fn push(&mut self, key: K, val: V) -> *mut V { // SAFETY: The unbound handle is no longer accessible. unsafe { self.push_with_handle(key, val).into_val_mut() } } @@ -683,7 +681,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::Leaf> { impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::Internal> { /// Adds a key-value pair, and an edge to go to the right of that pair, /// to the end of the node. - pub fn push(&mut self, key: K, val: V, edge: Root) { + pub(super) fn push(&mut self, key: K, val: V, edge: Root) { assert!(edge.height == self.height - 1); let len = self.len_mut(); @@ -701,21 +699,21 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::Internal> { impl NodeRef { /// Removes any static information asserting that this node is a `Leaf` node. - pub fn forget_type(self) -> NodeRef { + pub(super) fn forget_type(self) -> NodeRef { NodeRef { height: self.height, node: self.node, _marker: PhantomData } } } impl NodeRef { /// Removes any static information asserting that this node is an `Internal` node. - pub fn forget_type(self) -> NodeRef { + pub(super) fn forget_type(self) -> NodeRef { NodeRef { height: self.height, node: self.node, _marker: PhantomData } } } impl NodeRef { /// Checks whether a node is an `Internal` node or a `Leaf` node. - pub fn force( + pub(super) fn force( self, ) -> ForceResult< NodeRef, @@ -739,7 +737,9 @@ impl NodeRef { impl<'a, K, V> NodeRef, K, V, marker::LeafOrInternal> { /// Unsafely asserts to the compiler the static information that this node is a `Leaf`. - unsafe fn cast_to_leaf_unchecked(self) -> NodeRef, K, V, marker::Leaf> { + pub(super) unsafe fn cast_to_leaf_unchecked( + self, + ) -> NodeRef, K, V, marker::Leaf> { debug_assert!(self.height == 0); NodeRef { height: self.height, node: self.node, _marker: PhantomData } } @@ -759,7 +759,7 @@ impl<'a, K, V> NodeRef, K, V, marker::LeafOrInternal> { /// a child node, these represent the spaces where child pointers would go between the key-value /// pairs. For example, in a node with length 2, there would be 3 possible edge locations - one /// to the left of the node, one between the two pairs, and one at the right of the node. -pub struct Handle { +pub(super) struct Handle { node: Node, idx: usize, _marker: PhantomData, @@ -776,12 +776,12 @@ impl Clone for Handle { impl Handle { /// Retrieves the node that contains the edge or key-value pair this handle points to. - pub fn into_node(self) -> Node { + pub(super) fn into_node(self) -> Node { self.node } /// Returns the position of this handle in the node. - pub fn idx(&self) -> usize { + pub(super) fn idx(&self) -> usize { self.idx } } @@ -789,17 +789,17 @@ impl Handle { impl Handle, marker::KV> { /// Creates a new handle to a key-value pair in `node`. /// Unsafe because the caller must ensure that `idx < node.len()`. - pub unsafe fn new_kv(node: NodeRef, idx: usize) -> Self { + pub(super) unsafe fn new_kv(node: NodeRef, idx: usize) -> Self { debug_assert!(idx < node.len()); Handle { node, idx, _marker: PhantomData } } - pub fn left_edge(self) -> Handle, marker::Edge> { + pub(super) fn left_edge(self) -> Handle, marker::Edge> { unsafe { Handle::new_edge(self.node, self.idx) } } - pub fn right_edge(self) -> Handle, marker::Edge> { + pub(super) fn right_edge(self) -> Handle, marker::Edge> { unsafe { Handle::new_edge(self.node, self.idx + 1) } } } @@ -817,7 +817,9 @@ impl Handle, HandleType> { /// Temporarily takes out another immutable handle on the same location. - pub fn reborrow(&self) -> Handle, K, V, NodeType>, HandleType> { + pub(super) fn reborrow( + &self, + ) -> Handle, K, V, NodeType>, HandleType> { // We can't use Handle::new_kv or Handle::new_edge because we don't know our type Handle { node: self.node.reborrow(), idx: self.idx, _marker: PhantomData } } @@ -829,7 +831,7 @@ impl<'a, K, V, NodeType, HandleType> Handle, K, V, NodeT /// dangerous. /// /// For details, see `NodeRef::reborrow_mut`. - pub unsafe fn reborrow_mut( + pub(super) unsafe fn reborrow_mut( &mut self, ) -> Handle, K, V, NodeType>, HandleType> { // We can't use Handle::new_kv or Handle::new_edge because we don't know our type @@ -839,7 +841,9 @@ impl<'a, K, V, NodeType, HandleType> Handle, K, V, NodeT /// Returns a dormant copy of this handle which can be reawakened later. /// /// See `DormantMutRef` for more details. - pub fn dormant(&self) -> Handle, HandleType> { + pub(super) fn dormant( + &self, + ) -> Handle, HandleType> { Handle { node: self.node.dormant(), idx: self.idx, _marker: PhantomData } } } @@ -851,7 +855,9 @@ impl Handle(self) -> Handle, K, V, NodeType>, HandleType> { + pub(super) unsafe fn awaken<'a>( + self, + ) -> Handle, K, V, NodeType>, HandleType> { Handle { node: unsafe { self.node.awaken() }, idx: self.idx, _marker: PhantomData } } } @@ -859,13 +865,15 @@ impl Handle Handle, marker::Edge> { /// Creates a new handle to an edge in `node`. /// Unsafe because the caller must ensure that `idx <= node.len()`. - pub unsafe fn new_edge(node: NodeRef, idx: usize) -> Self { + pub(super) unsafe fn new_edge(node: NodeRef, idx: usize) -> Self { debug_assert!(idx <= node.len()); Handle { node, idx, _marker: PhantomData } } - pub fn left_kv(self) -> Result, marker::KV>, Self> { + pub(super) fn left_kv( + self, + ) -> Result, marker::KV>, Self> { if self.idx > 0 { Ok(unsafe { Handle::new_kv(self.node, self.idx - 1) }) } else { @@ -873,7 +881,9 @@ impl Handle, mar } } - pub fn right_kv(self) -> Result, marker::KV>, Self> { + pub(super) fn right_kv( + self, + ) -> Result, marker::KV>, Self> { if self.idx < self.node.len() { Ok(unsafe { Handle::new_kv(self.node, self.idx) }) } else { @@ -882,7 +892,7 @@ impl Handle, mar } } -pub enum LeftOrRight { +pub(super) enum LeftOrRight { Left(T), Right(T), } @@ -1036,7 +1046,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Leaf>, mark /// If the returned result is some `SplitResult`, the `left` field will be the root node. /// The returned pointer points to the inserted value, which in the case of `SplitResult` /// is in the `left` or `right` tree. - pub fn insert_recursing( + pub(super) fn insert_recursing( self, key: K, value: V, @@ -1080,7 +1090,7 @@ impl /// /// `edge.descend().ascend().unwrap()` and `node.ascend().unwrap().descend()` should /// both, upon success, do nothing. - pub fn descend(self) -> NodeRef { + pub(super) fn descend(self) -> NodeRef { const { assert!(BorrowType::TRAVERSAL_PERMIT); } @@ -1099,7 +1109,7 @@ impl } impl<'a, K: 'a, V: 'a, NodeType> Handle, K, V, NodeType>, marker::KV> { - pub fn into_kv(self) -> (&'a K, &'a V) { + pub(super) fn into_kv(self) -> (&'a K, &'a V) { debug_assert!(self.idx < self.node.len()); let leaf = self.node.into_leaf(); let k = unsafe { leaf.keys.get_unchecked(self.idx).assume_init_ref() }; @@ -1109,17 +1119,17 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle, K, V, NodeTyp } impl<'a, K: 'a, V: 'a, NodeType> Handle, K, V, NodeType>, marker::KV> { - pub fn key_mut(&mut self) -> &mut K { + pub(super) fn key_mut(&mut self) -> &mut K { unsafe { self.node.key_area_mut(self.idx).assume_init_mut() } } - pub fn into_val_mut(self) -> &'a mut V { + pub(super) fn into_val_mut(self) -> &'a mut V { debug_assert!(self.idx < self.node.len()); let leaf = self.node.into_leaf_mut(); unsafe { leaf.vals.get_unchecked_mut(self.idx).assume_init_mut() } } - pub fn into_kv_mut(self) -> (&'a mut K, &'a mut V) { + pub(super) fn into_kv_mut(self) -> (&'a mut K, &'a mut V) { debug_assert!(self.idx < self.node.len()); let leaf = self.node.into_leaf_mut(); let k = unsafe { leaf.keys.get_unchecked_mut(self.idx).assume_init_mut() }; @@ -1129,13 +1139,13 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle, K, V, NodeType> } impl<'a, K, V, NodeType> Handle, K, V, NodeType>, marker::KV> { - pub fn into_kv_valmut(self) -> (&'a K, &'a mut V) { + pub(super) fn into_kv_valmut(self) -> (&'a K, &'a mut V) { unsafe { self.node.into_key_val_mut_at(self.idx) } } } impl<'a, K: 'a, V: 'a, NodeType> Handle, K, V, NodeType>, marker::KV> { - pub fn kv_mut(&mut self) -> (&mut K, &mut V) { + pub(super) fn kv_mut(&mut self) -> (&mut K, &mut V) { debug_assert!(self.idx < self.node.len()); // We cannot call separate key and value methods, because calling the second one // invalidates the reference returned by the first. @@ -1148,7 +1158,7 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle, K, V, NodeType> } /// Replaces the key and value that the KV handle refers to. - pub fn replace_kv(&mut self, k: K, v: V) -> (K, V) { + pub(super) fn replace_kv(&mut self, k: K, v: V) -> (K, V) { let (key, val) = self.kv_mut(); (mem::replace(key, k), mem::replace(val, v)) } @@ -1158,7 +1168,7 @@ impl Handle, marker::KV> /// Extracts the key and value that the KV handle refers to. /// # Safety /// The node that the handle refers to must not yet have been deallocated. - pub unsafe fn into_key_val(mut self) -> (K, V) { + pub(super) unsafe fn into_key_val(mut self) -> (K, V) { debug_assert!(self.idx < self.node.len()); let leaf = self.node.as_leaf_dying(); unsafe { @@ -1172,7 +1182,7 @@ impl Handle, marker::KV> /// # Safety /// The node that the handle refers to must not yet have been deallocated. #[inline] - pub unsafe fn drop_key_val(mut self) { + pub(super) unsafe fn drop_key_val(mut self) { // Run the destructor of the value even if the destructor of the key panics. struct Dropper<'a, T>(&'a mut MaybeUninit); impl Drop for Dropper<'_, T> { @@ -1231,7 +1241,10 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Leaf>, mark /// - The key and value pointed to by this handle are extracted. /// - All the key-value pairs to the right of this handle are put into a newly /// allocated node. - pub fn split(mut self, alloc: A) -> SplitResult<'a, K, V, marker::Leaf> { + pub(super) fn split( + mut self, + alloc: A, + ) -> SplitResult<'a, K, V, marker::Leaf> { let mut new_node = LeafNode::new(alloc); let kv = self.split_leaf_data(&mut new_node); @@ -1242,7 +1255,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Leaf>, mark /// Removes the key-value pair pointed to by this handle and returns it, along with the edge /// that the key-value pair collapsed into. - pub fn remove( + pub(super) fn remove( mut self, ) -> ((K, V), Handle, K, V, marker::Leaf>, marker::Edge>) { let old_len = self.node.len(); @@ -1263,7 +1276,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Internal>, /// - The key and value pointed to by this handle are extracted. /// - All the edges and key-value pairs to the right of this handle are put into /// a newly allocated node. - pub fn split( + pub(super) fn split( mut self, alloc: A, ) -> SplitResult<'a, K, V, marker::Internal> { @@ -1287,14 +1300,14 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Internal>, /// Represents a session for evaluating and performing a balancing operation /// around an internal key-value pair. -pub struct BalancingContext<'a, K, V> { +pub(super) struct BalancingContext<'a, K, V> { parent: Handle, K, V, marker::Internal>, marker::KV>, left_child: NodeRef, K, V, marker::LeafOrInternal>, right_child: NodeRef, K, V, marker::LeafOrInternal>, } impl<'a, K, V> Handle, K, V, marker::Internal>, marker::KV> { - pub fn consider_for_balancing(self) -> BalancingContext<'a, K, V> { + pub(super) fn consider_for_balancing(self) -> BalancingContext<'a, K, V> { let self1 = unsafe { ptr::read(&self) }; let self2 = unsafe { ptr::read(&self) }; BalancingContext { @@ -1320,7 +1333,7 @@ impl<'a, K, V> NodeRef, K, V, marker::LeafOrInternal> { /// typically faster, since we only need to shift the node's N elements to /// the right, instead of shifting at least N of the sibling's elements to /// the left. - pub fn choose_parent_kv(self) -> Result>, Self> { + pub(super) fn choose_parent_kv(self) -> Result>, Self> { match unsafe { ptr::read(&self) }.ascend() { Ok(parent_edge) => match parent_edge.left_kv() { Ok(left_parent_kv) => Ok(LeftOrRight::Left(BalancingContext { @@ -1343,25 +1356,25 @@ impl<'a, K, V> NodeRef, K, V, marker::LeafOrInternal> { } impl<'a, K, V> BalancingContext<'a, K, V> { - pub fn left_child_len(&self) -> usize { + pub(super) fn left_child_len(&self) -> usize { self.left_child.len() } - pub fn right_child_len(&self) -> usize { + pub(super) fn right_child_len(&self) -> usize { self.right_child.len() } - pub fn into_left_child(self) -> NodeRef, K, V, marker::LeafOrInternal> { + pub(super) fn into_left_child(self) -> NodeRef, K, V, marker::LeafOrInternal> { self.left_child } - pub fn into_right_child(self) -> NodeRef, K, V, marker::LeafOrInternal> { + pub(super) fn into_right_child(self) -> NodeRef, K, V, marker::LeafOrInternal> { self.right_child } /// Returns whether merging is possible, i.e., whether there is enough room /// in a node to combine the central KV with both adjacent child nodes. - pub fn can_merge(&self) -> bool { + pub(super) fn can_merge(&self) -> bool { self.left_child.len() + 1 + self.right_child.len() <= CAPACITY } } @@ -1435,7 +1448,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { /// the left child node and returns the shrunk parent node. /// /// Panics unless we `.can_merge()`. - pub fn merge_tracking_parent( + pub(super) fn merge_tracking_parent( self, alloc: A, ) -> NodeRef, K, V, marker::Internal> { @@ -1446,7 +1459,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { /// the left child node and returns that child node. /// /// Panics unless we `.can_merge()`. - pub fn merge_tracking_child( + pub(super) fn merge_tracking_child( self, alloc: A, ) -> NodeRef, K, V, marker::LeafOrInternal> { @@ -1458,7 +1471,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { /// where the tracked child edge ended up, /// /// Panics unless we `.can_merge()`. - pub fn merge_tracking_child_edge( + pub(super) fn merge_tracking_child_edge( self, track_edge_idx: LeftOrRight, alloc: A, @@ -1481,7 +1494,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { /// of the parent, while pushing the old parent key-value pair into the right child. /// Returns a handle to the edge in the right child corresponding to where the original /// edge specified by `track_right_edge_idx` ended up. - pub fn steal_left( + pub(super) fn steal_left( mut self, track_right_edge_idx: usize, ) -> Handle, K, V, marker::LeafOrInternal>, marker::Edge> { @@ -1493,7 +1506,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { /// of the parent, while pushing the old parent key-value pair onto the left child. /// Returns a handle to the edge in the left child specified by `track_left_edge_idx`, /// which didn't move. - pub fn steal_right( + pub(super) fn steal_right( mut self, track_left_edge_idx: usize, ) -> Handle, K, V, marker::LeafOrInternal>, marker::Edge> { @@ -1502,7 +1515,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { } /// This does stealing similar to `steal_left` but steals multiple elements at once. - pub fn bulk_steal_left(&mut self, count: usize) { + pub(super) fn bulk_steal_left(&mut self, count: usize) { assert!(count > 0); unsafe { let left_node = &mut self.left_child; @@ -1565,7 +1578,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { } /// The symmetric clone of `bulk_steal_left`. - pub fn bulk_steal_right(&mut self, count: usize) { + pub(super) fn bulk_steal_right(&mut self, count: usize) { assert!(count > 0); unsafe { let left_node = &mut self.left_child; @@ -1630,7 +1643,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { } impl Handle, marker::Edge> { - pub fn forget_node_type( + pub(super) fn forget_node_type( self, ) -> Handle, marker::Edge> { unsafe { Handle::new_edge(self.node.forget_type(), self.idx) } @@ -1638,7 +1651,7 @@ impl Handle, marker::E } impl Handle, marker::Edge> { - pub fn forget_node_type( + pub(super) fn forget_node_type( self, ) -> Handle, marker::Edge> { unsafe { Handle::new_edge(self.node.forget_type(), self.idx) } @@ -1646,7 +1659,7 @@ impl Handle, marke } impl Handle, marker::KV> { - pub fn forget_node_type( + pub(super) fn forget_node_type( self, ) -> Handle, marker::KV> { unsafe { Handle::new_kv(self.node.forget_type(), self.idx) } @@ -1655,7 +1668,7 @@ impl Handle, marker::K impl Handle, Type> { /// Checks whether the underlying node is an `Internal` node or a `Leaf` node. - pub fn force( + pub(super) fn force( self, ) -> ForceResult< Handle, Type>, @@ -1674,7 +1687,7 @@ impl Handle Handle, K, V, marker::LeafOrInternal>, Type> { /// Unsafely asserts to the compiler the static information that the handle's node is a `Leaf`. - pub unsafe fn cast_to_leaf_unchecked( + pub(super) unsafe fn cast_to_leaf_unchecked( self, ) -> Handle, K, V, marker::Leaf>, Type> { let node = unsafe { self.node.cast_to_leaf_unchecked() }; @@ -1685,7 +1698,7 @@ impl<'a, K, V, Type> Handle, K, V, marker::LeafOrInterna impl<'a, K, V> Handle, K, V, marker::LeafOrInternal>, marker::Edge> { /// Move the suffix after `self` from one node to another one. `right` must be empty. /// The first edge of `right` remains unchanged. - pub fn move_suffix( + pub(super) fn move_suffix( &mut self, right: &mut NodeRef, K, V, marker::LeafOrInternal>, ) { @@ -1728,13 +1741,13 @@ impl<'a, K, V> Handle, K, V, marker::LeafOrInternal>, ma } } -pub enum ForceResult { +pub(super) enum ForceResult { Leaf(Leaf), Internal(Internal), } /// Result of insertion, when a node needed to expand beyond its capacity. -pub struct SplitResult<'a, K, V, NodeType> { +pub(super) struct SplitResult<'a, K, V, NodeType> { // Altered node in existing tree with elements and edges that belong to the left of `kv`. pub left: NodeRef, K, V, NodeType>, // Some key and value that existed before and were split off, to be inserted elsewhere. @@ -1744,32 +1757,32 @@ pub struct SplitResult<'a, K, V, NodeType> { } impl<'a, K, V> SplitResult<'a, K, V, marker::Leaf> { - pub fn forget_node_type(self) -> SplitResult<'a, K, V, marker::LeafOrInternal> { + pub(super) fn forget_node_type(self) -> SplitResult<'a, K, V, marker::LeafOrInternal> { SplitResult { left: self.left.forget_type(), kv: self.kv, right: self.right.forget_type() } } } impl<'a, K, V> SplitResult<'a, K, V, marker::Internal> { - pub fn forget_node_type(self) -> SplitResult<'a, K, V, marker::LeafOrInternal> { + pub(super) fn forget_node_type(self) -> SplitResult<'a, K, V, marker::LeafOrInternal> { SplitResult { left: self.left.forget_type(), kv: self.kv, right: self.right.forget_type() } } } -pub mod marker { +pub(super) mod marker { use core::marker::PhantomData; - pub enum Leaf {} - pub enum Internal {} - pub enum LeafOrInternal {} + pub(crate) enum Leaf {} + pub(crate) enum Internal {} + pub(crate) enum LeafOrInternal {} - pub enum Owned {} - pub enum Dying {} - pub enum DormantMut {} - pub struct Immut<'a>(PhantomData<&'a ()>); - pub struct Mut<'a>(PhantomData<&'a mut ()>); - pub struct ValMut<'a>(PhantomData<&'a mut ()>); + pub(crate) enum Owned {} + pub(crate) enum Dying {} + pub(crate) enum DormantMut {} + pub(crate) struct Immut<'a>(PhantomData<&'a ()>); + pub(crate) struct Mut<'a>(PhantomData<&'a mut ()>); + pub(crate) struct ValMut<'a>(PhantomData<&'a mut ()>); - pub trait BorrowType { + pub(crate) trait BorrowType { /// If node references of this borrow type allow traversing to other /// nodes in the tree, this constant is set to `true`. It can be used /// for a compile-time assertion. @@ -1788,8 +1801,8 @@ pub mod marker { impl<'a> BorrowType for ValMut<'a> {} impl BorrowType for DormantMut {} - pub enum KV {} - pub enum Edge {} + pub(crate) enum KV {} + pub(crate) enum Edge {} } /// Inserts a value into a slice of initialized elements followed by one uninitialized element. diff --git a/alloc/src/collections/btree/node/tests.rs b/alloc/src/collections/btree/node/tests.rs index 4d2fa0f094171..7d1a2ea480943 100644 --- a/alloc/src/collections/btree/node/tests.rs +++ b/alloc/src/collections/btree/node/tests.rs @@ -6,7 +6,7 @@ use crate::string::String; impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> { // Asserts that the back pointer in each reachable node points to its parent. - pub fn assert_back_pointers(self) { + pub(crate) fn assert_back_pointers(self) { if let ForceResult::Internal(node) = self.force() { for idx in 0..=node.len() { let edge = unsafe { Handle::new_edge(node, idx) }; @@ -20,7 +20,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> // Renders a multi-line display of the keys in order and in tree hierarchy, // picturing the tree growing sideways from its root on the left to its // leaves on the right. - pub fn dump_keys(self) -> String + pub(crate) fn dump_keys(self) -> String where K: Debug, { @@ -92,8 +92,8 @@ fn test_partial_eq() { #[cfg(target_arch = "x86_64")] #[cfg_attr(any(miri, randomized_layouts), ignore)] // We'd like to run Miri with layout randomization fn test_sizes() { - assert_eq!(core::mem::size_of::>(), 16); - assert_eq!(core::mem::size_of::>(), 16 + CAPACITY * 2 * 8); - assert_eq!(core::mem::size_of::>(), 16 + (CAPACITY + 1) * 8); - assert_eq!(core::mem::size_of::>(), 16 + (CAPACITY * 3 + 1) * 8); + assert_eq!(size_of::>(), 16); + assert_eq!(size_of::>(), 16 + CAPACITY * 2 * 8); + assert_eq!(size_of::>(), 16 + (CAPACITY + 1) * 8); + assert_eq!(size_of::>(), 16 + (CAPACITY * 3 + 1) * 8); } diff --git a/alloc/src/collections/btree/remove.rs b/alloc/src/collections/btree/remove.rs index 56f2824b782bd..9d870b86f34a0 100644 --- a/alloc/src/collections/btree/remove.rs +++ b/alloc/src/collections/btree/remove.rs @@ -10,7 +10,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::LeafOrInter /// the leaf edge corresponding to that former pair. It's possible this empties /// a root node that is internal, which the caller should pop from the map /// holding the tree. The caller should also decrement the map's length. - pub fn remove_kv_tracking( + pub(super) fn remove_kv_tracking( self, handle_emptied_internal_root: F, alloc: A, diff --git a/alloc/src/collections/btree/search.rs b/alloc/src/collections/btree/search.rs index 22e015edac3d2..96e5bf108024b 100644 --- a/alloc/src/collections/btree/search.rs +++ b/alloc/src/collections/btree/search.rs @@ -8,7 +8,7 @@ use SearchResult::*; use super::node::ForceResult::*; use super::node::{Handle, NodeRef, marker}; -pub enum SearchBound { +pub(super) enum SearchBound { /// An inclusive bound to look for, just like `Bound::Included(T)`. Included(T), /// An exclusive bound to look for, just like `Bound::Excluded(T)`. @@ -20,7 +20,7 @@ pub enum SearchBound { } impl SearchBound { - pub fn from_range(range_bound: Bound) -> Self { + pub(super) fn from_range(range_bound: Bound) -> Self { match range_bound { Bound::Included(t) => Included(t), Bound::Excluded(t) => Excluded(t), @@ -29,12 +29,12 @@ impl SearchBound { } } -pub enum SearchResult { +pub(super) enum SearchResult { Found(Handle, marker::KV>), GoDown(Handle, marker::Edge>), } -pub enum IndexResult { +pub(super) enum IndexResult { KV(usize), Edge(usize), } @@ -46,7 +46,7 @@ impl NodeRef( + pub(super) fn search_tree( mut self, key: &Q, ) -> SearchResult @@ -80,7 +80,7 @@ impl NodeRef( + pub(super) fn search_tree_for_bifurcation<'r, Q: ?Sized, R>( mut self, range: &'r R, ) -> Result< @@ -156,7 +156,7 @@ impl NodeRef( + pub(super) fn find_lower_bound_edge<'r, Q>( self, bound: SearchBound<&'r Q>, ) -> (Handle, SearchBound<&'r Q>) @@ -170,7 +170,7 @@ impl NodeRef( + pub(super) fn find_upper_bound_edge<'r, Q>( self, bound: SearchBound<&'r Q>, ) -> (Handle, SearchBound<&'r Q>) @@ -192,7 +192,10 @@ impl NodeRef { /// /// The result is meaningful only if the tree is ordered by key, like the tree /// in a `BTreeMap` is. - pub fn search_node(self, key: &Q) -> SearchResult + pub(super) fn search_node( + self, + key: &Q, + ) -> SearchResult where Q: Ord, K: Borrow, diff --git a/alloc/src/collections/btree/set.rs b/alloc/src/collections/btree/set.rs index 8daee6030c270..041f80c1f2c52 100644 --- a/alloc/src/collections/btree/set.rs +++ b/alloc/src/collections/btree/set.rs @@ -7,12 +7,17 @@ use core::iter::{FusedIterator, Peekable}; use core::mem::ManuallyDrop; use core::ops::{BitAnd, BitOr, BitXor, Bound, RangeBounds, Sub}; -use super::map::{BTreeMap, Keys}; +use super::map::{self, BTreeMap, Keys}; use super::merge_iter::MergeIterInner; use super::set_val::SetValZST; use crate::alloc::{Allocator, Global}; use crate::vec::Vec; +mod entry; + +#[unstable(feature = "btree_set_entry", issue = "133549")] +pub use self::entry::{Entry, OccupiedEntry, VacantEntry}; + /// An ordered set based on a B-Tree. /// /// See [`BTreeMap`]'s documentation for a detailed discussion of this collection's performance @@ -928,6 +933,109 @@ impl BTreeSet { self.map.replace(value) } + /// Inserts the given `value` into the set if it is not present, then + /// returns a reference to the value in the set. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::BTreeSet; + /// + /// let mut set = BTreeSet::from([1, 2, 3]); + /// assert_eq!(set.len(), 3); + /// assert_eq!(set.get_or_insert(2), &2); + /// assert_eq!(set.get_or_insert(100), &100); + /// assert_eq!(set.len(), 4); // 100 was inserted + /// ``` + #[inline] + #[unstable(feature = "btree_set_entry", issue = "133549")] + pub fn get_or_insert(&mut self, value: T) -> &T + where + T: Ord, + { + self.map.entry(value).insert_entry(SetValZST).into_key() + } + + /// Inserts a value computed from `f` into the set if the given `value` is + /// not present, then returns a reference to the value in the set. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::BTreeSet; + /// + /// let mut set: BTreeSet = ["cat", "dog", "horse"] + /// .iter().map(|&pet| pet.to_owned()).collect(); + /// + /// assert_eq!(set.len(), 3); + /// for &pet in &["cat", "dog", "fish"] { + /// let value = set.get_or_insert_with(pet, str::to_owned); + /// assert_eq!(value, pet); + /// } + /// assert_eq!(set.len(), 4); // a new "fish" was inserted + /// ``` + #[inline] + #[unstable(feature = "btree_set_entry", issue = "133549")] + pub fn get_or_insert_with(&mut self, value: &Q, f: F) -> &T + where + T: Borrow + Ord, + Q: Ord, + F: FnOnce(&Q) -> T, + { + self.map.get_or_insert_with(value, f) + } + + /// Gets the given value's corresponding entry in the set for in-place manipulation. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::BTreeSet; + /// use std::collections::btree_set::Entry::*; + /// + /// let mut singles = BTreeSet::new(); + /// let mut dupes = BTreeSet::new(); + /// + /// for ch in "a short treatise on fungi".chars() { + /// if let Vacant(dupe_entry) = dupes.entry(ch) { + /// // We haven't already seen a duplicate, so + /// // check if we've at least seen it once. + /// match singles.entry(ch) { + /// Vacant(single_entry) => { + /// // We found a new character for the first time. + /// single_entry.insert() + /// } + /// Occupied(single_entry) => { + /// // We've already seen this once, "move" it to dupes. + /// single_entry.remove(); + /// dupe_entry.insert(); + /// } + /// } + /// } + /// } + /// + /// assert!(!singles.contains(&'t') && dupes.contains(&'t')); + /// assert!(singles.contains(&'u') && !dupes.contains(&'u')); + /// assert!(!singles.contains(&'v') && !dupes.contains(&'v')); + /// ``` + #[inline] + #[unstable(feature = "btree_set_entry", issue = "133549")] + pub fn entry(&mut self, value: T) -> Entry<'_, T, A> + where + T: Ord, + { + match self.map.entry(value) { + map::Entry::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }), + map::Entry::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }), + } + } + /// If the set contains an element equal to the value, removes it from the /// set and drops it. Returns whether such an element was present. /// @@ -1334,20 +1442,20 @@ impl BTreeSet { /// /// let mut set = BTreeSet::from([1, 2, 3, 4]); /// - /// let mut cursor = unsafe { set.upper_bound_mut(Bound::Included(&3)) }; + /// let mut cursor = set.upper_bound_mut(Bound::Included(&3)); /// assert_eq!(cursor.peek_prev(), Some(&3)); /// assert_eq!(cursor.peek_next(), Some(&4)); /// - /// let mut cursor = unsafe { set.upper_bound_mut(Bound::Excluded(&3)) }; + /// let mut cursor = set.upper_bound_mut(Bound::Excluded(&3)); /// assert_eq!(cursor.peek_prev(), Some(&2)); /// assert_eq!(cursor.peek_next(), Some(&3)); /// - /// let mut cursor = unsafe { set.upper_bound_mut(Bound::Unbounded) }; + /// let mut cursor = set.upper_bound_mut(Bound::Unbounded); /// assert_eq!(cursor.peek_prev(), Some(&4)); /// assert_eq!(cursor.peek_next(), None); /// ``` #[unstable(feature = "btree_cursors", issue = "107540")] - pub unsafe fn upper_bound_mut(&mut self, bound: Bound<&Q>) -> CursorMut<'_, T, A> + pub fn upper_bound_mut(&mut self, bound: Bound<&Q>) -> CursorMut<'_, T, A> where T: Borrow + Ord, Q: Ord, @@ -1383,6 +1491,11 @@ impl BTreeSet { impl From<[T; N]> for BTreeSet { /// Converts a `[T; N]` into a `BTreeSet`. /// + /// If the array contains any equal values, + /// all but one will be dropped. + /// + /// # Examples + /// /// ``` /// use std::collections::BTreeSet; /// diff --git a/alloc/src/collections/btree/set/entry.rs b/alloc/src/collections/btree/set/entry.rs new file mode 100644 index 0000000000000..a60d22f9ece71 --- /dev/null +++ b/alloc/src/collections/btree/set/entry.rs @@ -0,0 +1,388 @@ +use core::fmt::{self, Debug}; + +use Entry::*; + +use super::{SetValZST, map}; +use crate::alloc::{Allocator, Global}; + +/// A view into a single entry in a set, which may either be vacant or occupied. +/// +/// This `enum` is constructed from the [`entry`] method on [`BTreeSet`]. +/// +/// [`BTreeSet`]: super::BTreeSet +/// [`entry`]: super::BTreeSet::entry +/// +/// # Examples +/// +/// ``` +/// #![feature(btree_set_entry)] +/// +/// use std::collections::btree_set::BTreeSet; +/// +/// let mut set = BTreeSet::new(); +/// set.extend(["a", "b", "c"]); +/// assert_eq!(set.len(), 3); +/// +/// // Existing value (insert) +/// let entry = set.entry("a"); +/// let _raw_o = entry.insert(); +/// assert_eq!(set.len(), 3); +/// // Nonexistent value (insert) +/// set.entry("d").insert(); +/// +/// // Existing value (or_insert) +/// set.entry("b").or_insert(); +/// // Nonexistent value (or_insert) +/// set.entry("e").or_insert(); +/// +/// println!("Our BTreeSet: {:?}", set); +/// assert!(set.iter().eq(&["a", "b", "c", "d", "e"])); +/// ``` +#[unstable(feature = "btree_set_entry", issue = "133549")] +pub enum Entry< + 'a, + T, + #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, +> { + /// An occupied entry. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::btree_set::{Entry, BTreeSet}; + /// + /// let mut set = BTreeSet::from(["a", "b"]); + /// + /// match set.entry("a") { + /// Entry::Vacant(_) => unreachable!(), + /// Entry::Occupied(_) => { } + /// } + /// ``` + #[unstable(feature = "btree_set_entry", issue = "133549")] + Occupied(OccupiedEntry<'a, T, A>), + + /// A vacant entry. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::btree_set::{Entry, BTreeSet}; + /// + /// let mut set = BTreeSet::new(); + /// + /// match set.entry("a") { + /// Entry::Occupied(_) => unreachable!(), + /// Entry::Vacant(_) => { } + /// } + /// ``` + #[unstable(feature = "btree_set_entry", issue = "133549")] + Vacant(VacantEntry<'a, T, A>), +} + +#[unstable(feature = "btree_set_entry", issue = "133549")] +impl Debug for Entry<'_, T, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Vacant(ref v) => f.debug_tuple("Entry").field(v).finish(), + Occupied(ref o) => f.debug_tuple("Entry").field(o).finish(), + } + } +} + +/// A view into an occupied entry in a `BTreeSet`. +/// It is part of the [`Entry`] enum. +/// +/// # Examples +/// +/// ``` +/// #![feature(btree_set_entry)] +/// +/// use std::collections::btree_set::{Entry, BTreeSet}; +/// +/// let mut set = BTreeSet::new(); +/// set.extend(["a", "b", "c"]); +/// +/// let _entry_o = set.entry("a").insert(); +/// assert_eq!(set.len(), 3); +/// +/// // Existing key +/// match set.entry("a") { +/// Entry::Vacant(_) => unreachable!(), +/// Entry::Occupied(view) => { +/// assert_eq!(view.get(), &"a"); +/// } +/// } +/// +/// assert_eq!(set.len(), 3); +/// +/// // Existing key (take) +/// match set.entry("c") { +/// Entry::Vacant(_) => unreachable!(), +/// Entry::Occupied(view) => { +/// assert_eq!(view.remove(), "c"); +/// } +/// } +/// assert_eq!(set.get(&"c"), None); +/// assert_eq!(set.len(), 2); +/// ``` +#[unstable(feature = "btree_set_entry", issue = "133549")] +pub struct OccupiedEntry< + 'a, + T, + #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, +> { + pub(super) inner: map::OccupiedEntry<'a, T, SetValZST, A>, +} + +#[unstable(feature = "btree_set_entry", issue = "133549")] +impl Debug for OccupiedEntry<'_, T, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("OccupiedEntry").field("value", self.get()).finish() + } +} + +/// A view into a vacant entry in a `BTreeSet`. +/// It is part of the [`Entry`] enum. +/// +/// # Examples +/// +/// ``` +/// #![feature(btree_set_entry)] +/// +/// use std::collections::btree_set::{Entry, BTreeSet}; +/// +/// let mut set = BTreeSet::<&str>::new(); +/// +/// let entry_v = match set.entry("a") { +/// Entry::Vacant(view) => view, +/// Entry::Occupied(_) => unreachable!(), +/// }; +/// entry_v.insert(); +/// assert!(set.contains("a") && set.len() == 1); +/// +/// // Nonexistent key (insert) +/// match set.entry("b") { +/// Entry::Vacant(view) => view.insert(), +/// Entry::Occupied(_) => unreachable!(), +/// } +/// assert!(set.contains("b") && set.len() == 2); +/// ``` +#[unstable(feature = "btree_set_entry", issue = "133549")] +pub struct VacantEntry< + 'a, + T, + #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, +> { + pub(super) inner: map::VacantEntry<'a, T, SetValZST, A>, +} + +#[unstable(feature = "btree_set_entry", issue = "133549")] +impl Debug for VacantEntry<'_, T, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("VacantEntry").field(self.get()).finish() + } +} + +impl<'a, T: Ord, A: Allocator + Clone> Entry<'a, T, A> { + /// Sets the value of the entry, and returns an `OccupiedEntry`. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::BTreeSet; + /// + /// let mut set = BTreeSet::new(); + /// let entry = set.entry("horseyland").insert(); + /// + /// assert_eq!(entry.get(), &"horseyland"); + /// ``` + #[inline] + #[unstable(feature = "btree_set_entry", issue = "133549")] + pub fn insert(self) -> OccupiedEntry<'a, T, A> { + match self { + Occupied(entry) => entry, + Vacant(entry) => entry.insert_entry(), + } + } + + /// Ensures a value is in the entry by inserting if it was vacant. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::BTreeSet; + /// + /// let mut set = BTreeSet::new(); + /// + /// // nonexistent key + /// set.entry("poneyland").or_insert(); + /// assert!(set.contains("poneyland")); + /// + /// // existing key + /// set.entry("poneyland").or_insert(); + /// assert!(set.contains("poneyland")); + /// assert_eq!(set.len(), 1); + /// ``` + #[inline] + #[unstable(feature = "btree_set_entry", issue = "133549")] + pub fn or_insert(self) { + if let Vacant(entry) = self { + entry.insert(); + } + } + + /// Returns a reference to this entry's value. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::BTreeSet; + /// + /// let mut set = BTreeSet::new(); + /// set.entry("poneyland").or_insert(); + /// + /// // existing key + /// assert_eq!(set.entry("poneyland").get(), &"poneyland"); + /// // nonexistent key + /// assert_eq!(set.entry("horseland").get(), &"horseland"); + /// ``` + #[inline] + #[unstable(feature = "btree_set_entry", issue = "133549")] + pub fn get(&self) -> &T { + match *self { + Occupied(ref entry) => entry.get(), + Vacant(ref entry) => entry.get(), + } + } +} + +impl<'a, T: Ord, A: Allocator + Clone> OccupiedEntry<'a, T, A> { + /// Gets a reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::btree_set::{Entry, BTreeSet}; + /// + /// let mut set = BTreeSet::new(); + /// set.entry("poneyland").or_insert(); + /// + /// match set.entry("poneyland") { + /// Entry::Vacant(_) => panic!(), + /// Entry::Occupied(entry) => assert_eq!(entry.get(), &"poneyland"), + /// } + /// ``` + #[inline] + #[unstable(feature = "btree_set_entry", issue = "133549")] + pub fn get(&self) -> &T { + self.inner.key() + } + + /// Takes the value out of the entry, and returns it. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::BTreeSet; + /// use std::collections::btree_set::Entry; + /// + /// let mut set = BTreeSet::new(); + /// set.entry("poneyland").or_insert(); + /// + /// if let Entry::Occupied(o) = set.entry("poneyland") { + /// assert_eq!(o.remove(), "poneyland"); + /// } + /// + /// assert_eq!(set.contains("poneyland"), false); + /// ``` + #[inline] + #[unstable(feature = "btree_set_entry", issue = "133549")] + pub fn remove(self) -> T { + self.inner.remove_entry().0 + } +} + +impl<'a, T: Ord, A: Allocator + Clone> VacantEntry<'a, T, A> { + /// Gets a reference to the value that would be used when inserting + /// through the `VacantEntry`. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::BTreeSet; + /// + /// let mut set = BTreeSet::new(); + /// assert_eq!(set.entry("poneyland").get(), &"poneyland"); + /// ``` + #[inline] + #[unstable(feature = "btree_set_entry", issue = "133549")] + pub fn get(&self) -> &T { + self.inner.key() + } + + /// Take ownership of the value. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::btree_set::{Entry, BTreeSet}; + /// + /// let mut set = BTreeSet::new(); + /// + /// match set.entry("poneyland") { + /// Entry::Occupied(_) => panic!(), + /// Entry::Vacant(v) => assert_eq!(v.into_value(), "poneyland"), + /// } + /// ``` + #[inline] + #[unstable(feature = "btree_set_entry", issue = "133549")] + pub fn into_value(self) -> T { + self.inner.into_key() + } + + /// Sets the value of the entry with the VacantEntry's value. + /// + /// # Examples + /// + /// ``` + /// #![feature(btree_set_entry)] + /// + /// use std::collections::BTreeSet; + /// use std::collections::btree_set::Entry; + /// + /// let mut set = BTreeSet::new(); + /// + /// if let Entry::Vacant(o) = set.entry("poneyland") { + /// o.insert(); + /// } + /// assert!(set.contains("poneyland")); + /// ``` + #[inline] + #[unstable(feature = "btree_set_entry", issue = "133549")] + pub fn insert(self) { + self.inner.insert(SetValZST); + } + + #[inline] + fn insert_entry(self) -> OccupiedEntry<'a, T, A> { + OccupiedEntry { inner: self.inner.insert_entry(SetValZST) } + } +} diff --git a/alloc/src/collections/btree/set/tests.rs b/alloc/src/collections/btree/set/tests.rs index 990044e069f64..d538ef707eb93 100644 --- a/alloc/src/collections/btree/set/tests.rs +++ b/alloc/src/collections/btree/set/tests.rs @@ -132,9 +132,11 @@ fn test_difference() { check_difference(&[1, 3, 5, 9, 11], &[3, 6, 9], &[1, 5, 11]); check_difference(&[1, 3, 5, 9, 11], &[0, 1], &[3, 5, 9, 11]); check_difference(&[1, 3, 5, 9, 11], &[11, 12], &[1, 3, 5, 9]); - check_difference(&[-5, 11, 22, 33, 40, 42], &[-12, -5, 14, 23, 34, 38, 39, 50], &[ - 11, 22, 33, 40, 42, - ]); + check_difference( + &[-5, 11, 22, 33, 40, 42], + &[-12, -5, 14, 23, 34, 38, 39, 50], + &[11, 22, 33, 40, 42], + ); if cfg!(miri) { // Miri is too slow @@ -250,9 +252,11 @@ fn test_union() { check_union(&[], &[], &[]); check_union(&[1, 2, 3], &[2], &[1, 2, 3]); check_union(&[2], &[1, 2, 3], &[1, 2, 3]); - check_union(&[1, 3, 5, 9, 11, 16, 19, 24], &[-2, 1, 5, 9, 13, 19], &[ - -2, 1, 3, 5, 9, 11, 13, 16, 19, 24, - ]); + check_union( + &[1, 3, 5, 9, 11, 16, 19, 24], + &[-2, 1, 5, 9, 13, 19], + &[-2, 1, 3, 5, 9, 11, 13, 16, 19, 24], + ); } #[test] diff --git a/alloc/src/collections/btree/split.rs b/alloc/src/collections/btree/split.rs index c188ed1da6113..87a79e6cf3f93 100644 --- a/alloc/src/collections/btree/split.rs +++ b/alloc/src/collections/btree/split.rs @@ -8,7 +8,7 @@ use super::search::SearchResult::*; impl Root { /// Calculates the length of both trees that result from splitting up /// a given number of distinct key-value pairs. - pub fn calc_split_length( + pub(super) fn calc_split_length( total_num: usize, root_a: &Root, root_b: &Root, @@ -31,7 +31,11 @@ impl Root { /// and if the ordering of `Q` corresponds to that of `K`. /// If `self` respects all `BTreeMap` tree invariants, then both /// `self` and the returned tree will respect those invariants. - pub fn split_off(&mut self, key: &Q, alloc: A) -> Self + pub(super) fn split_off( + &mut self, + key: &Q, + alloc: A, + ) -> Self where K: Borrow, { diff --git a/alloc/src/collections/linked_list.rs b/alloc/src/collections/linked_list.rs index ca0ea1ec8b2ba..3183268b4b32e 100644 --- a/alloc/src/collections/linked_list.rs +++ b/alloc/src/collections/linked_list.rs @@ -1140,7 +1140,6 @@ impl LinkedList { /// Splitting a list into evens and odds, reusing the original list: /// /// ``` - /// #![feature(extract_if)] /// use std::collections::LinkedList; /// /// let mut numbers: LinkedList = LinkedList::new(); @@ -1152,7 +1151,7 @@ impl LinkedList { /// assert_eq!(evens.into_iter().collect::>(), vec![2, 4, 6, 8, 14]); /// assert_eq!(odds.into_iter().collect::>(), vec![1, 3, 5, 9, 11, 13, 15]); /// ``` - #[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] + #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] pub fn extract_if(&mut self, filter: F) -> ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, @@ -1932,16 +1931,14 @@ impl<'a, T, A: Allocator> CursorMut<'a, T, A> { } /// An iterator produced by calling `extract_if` on LinkedList. -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct ExtractIf< 'a, T: 'a, F: 'a, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, -> where - F: FnMut(&mut T) -> bool, -{ +> { list: &'a mut LinkedList, it: Option>>, pred: F, @@ -1949,7 +1946,7 @@ pub struct ExtractIf< old_len: usize, } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, @@ -1978,11 +1975,8 @@ where } } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] -impl fmt::Debug for ExtractIf<'_, T, F> -where - F: FnMut(&mut T) -> bool, -{ +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] +impl fmt::Debug for ExtractIf<'_, T, F> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("ExtractIf").field(&self.list).finish() } diff --git a/alloc/src/collections/linked_list/tests.rs b/alloc/src/collections/linked_list/tests.rs index b7d4f8512a0f2..812fe229a0fc5 100644 --- a/alloc/src/collections/linked_list/tests.rs +++ b/alloc/src/collections/linked_list/tests.rs @@ -58,7 +58,7 @@ fn list_from(v: &[T]) -> LinkedList { v.iter().cloned().collect() } -pub fn check_links(list: &LinkedList) { +fn check_links(list: &LinkedList) { unsafe { let mut len = 0; let mut last_ptr: Option<&Node> = None; @@ -696,9 +696,10 @@ fn test_cursor_mut_insert() { cursor.splice_after(p); cursor.splice_before(q); check_links(&m); - assert_eq!(m.iter().cloned().collect::>(), &[ - 200, 201, 202, 203, 1, 100, 101, 102, 103, 8, 2, 3, 4, 5, 6 - ]); + assert_eq!( + m.iter().cloned().collect::>(), + &[200, 201, 202, 203, 1, 100, 101, 102, 103, 8, 2, 3, 4, 5, 6] + ); let mut cursor = m.cursor_front_mut(); cursor.move_prev(); let tmp = cursor.split_before(); @@ -915,9 +916,10 @@ fn extract_if_complex() { assert_eq!(removed, vec![2, 4, 6, 18, 20, 22, 24, 26, 34, 36]); assert_eq!(list.len(), 14); - assert_eq!(list.into_iter().collect::>(), vec![ - 1, 7, 9, 11, 13, 15, 17, 27, 29, 31, 33, 35, 37, 39 - ]); + assert_eq!( + list.into_iter().collect::>(), + vec![1, 7, 9, 11, 13, 15, 17, 27, 29, 31, 33, 35, 37, 39] + ); } { @@ -932,9 +934,10 @@ fn extract_if_complex() { assert_eq!(removed, vec![2, 4, 6, 18, 20, 22, 24, 26, 34, 36]); assert_eq!(list.len(), 13); - assert_eq!(list.into_iter().collect::>(), vec![ - 7, 9, 11, 13, 15, 17, 27, 29, 31, 33, 35, 37, 39 - ]); + assert_eq!( + list.into_iter().collect::>(), + vec![7, 9, 11, 13, 15, 17, 27, 29, 31, 33, 35, 37, 39] + ); } { @@ -949,9 +952,10 @@ fn extract_if_complex() { assert_eq!(removed, vec![2, 4, 6, 18, 20, 22, 24, 26, 34, 36]); assert_eq!(list.len(), 11); - assert_eq!(list.into_iter().collect::>(), vec![ - 7, 9, 11, 13, 15, 17, 27, 29, 31, 33, 35 - ]); + assert_eq!( + list.into_iter().collect::>(), + vec![7, 9, 11, 13, 15, 17, 27, 29, 31, 33, 35] + ); } { diff --git a/alloc/src/collections/mod.rs b/alloc/src/collections/mod.rs index 020cf4d736510..fac4d1a65abcb 100644 --- a/alloc/src/collections/mod.rs +++ b/alloc/src/collections/mod.rs @@ -1,5 +1,8 @@ //! Collection types. +// Note: This module is also included in the alloctests crate using #[path] to +// run the tests. See the comment there for an explanation why this is the case. + #![stable(feature = "rust1", since = "1.0.0")] #[cfg(not(no_global_oom_handling))] @@ -24,41 +27,54 @@ pub mod btree_map { pub mod btree_set { //! An ordered set based on a B-Tree. #[stable(feature = "rust1", since = "1.0.0")] + #[cfg(not(test))] pub use super::btree::set::*; } +#[cfg(not(test))] use core::fmt::Display; #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] +#[cfg(not(test))] pub use binary_heap::BinaryHeap; #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] +#[cfg(not(test))] pub use btree_map::BTreeMap; #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] +#[cfg(not(test))] pub use btree_set::BTreeSet; #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] +#[cfg(not(test))] pub use linked_list::LinkedList; #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] +#[cfg(not(test))] pub use vec_deque::VecDeque; +#[cfg(not(test))] use crate::alloc::{Layout, LayoutError}; /// The error type for `try_reserve` methods. #[derive(Clone, PartialEq, Eq, Debug)] #[stable(feature = "try_reserve", since = "1.57.0")] +#[cfg(not(test))] pub struct TryReserveError { kind: TryReserveErrorKind, } +#[cfg(test)] +pub use realalloc::collections::TryReserveError; + +#[cfg(not(test))] impl TryReserveError { /// Details about the allocation that caused the error #[inline] @@ -80,6 +96,7 @@ impl TryReserveError { reason = "Uncertain how much info should be exposed", issue = "48043" )] +#[cfg(not(test))] pub enum TryReserveErrorKind { /// Error due to the computed capacity exceeding the collection's maximum /// (usually `isize::MAX` bytes). @@ -103,11 +120,15 @@ pub enum TryReserveErrorKind { }, } +#[cfg(test)] +pub use realalloc::collections::TryReserveErrorKind; + #[unstable( feature = "try_reserve_kind", reason = "Uncertain how much info should be exposed", issue = "48043" )] +#[cfg(not(test))] impl From for TryReserveError { #[inline] fn from(kind: TryReserveErrorKind) -> Self { @@ -116,6 +137,7 @@ impl From for TryReserveError { } #[unstable(feature = "try_reserve_kind", reason = "new API", issue = "48043")] +#[cfg(not(test))] impl From for TryReserveErrorKind { /// Always evaluates to [`TryReserveErrorKind::CapacityOverflow`]. #[inline] @@ -125,6 +147,7 @@ impl From for TryReserveErrorKind { } #[stable(feature = "try_reserve", since = "1.57.0")] +#[cfg(not(test))] impl Display for TryReserveError { fn fmt( &self, @@ -152,4 +175,5 @@ trait SpecExtend { } #[stable(feature = "try_reserve", since = "1.57.0")] +#[cfg(not(test))] impl core::error::Error for TryReserveError {} diff --git a/alloc/src/collections/vec_deque/mod.rs b/alloc/src/collections/vec_deque/mod.rs index cf51a84bb6f24..f8844e2d3a5cb 100644 --- a/alloc/src/collections/vec_deque/mod.rs +++ b/alloc/src/collections/vec_deque/mod.rs @@ -645,6 +645,7 @@ impl VecDeque { /// initialized rather than only supporting `0..len`. Requires that /// `initialized.start` ≤ `initialized.end` ≤ `capacity`. #[inline] + #[cfg(not(test))] pub(crate) unsafe fn from_contiguous_raw_parts_in( ptr: *mut T, initialized: Range, @@ -823,6 +824,7 @@ impl VecDeque { /// assert!(buf.capacity() >= 11); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "vecdeque_reserve")] #[track_caller] pub fn reserve(&mut self, additional: usize) { let new_cap = self.len.checked_add(additional).expect("capacity overflow"); @@ -1735,6 +1737,52 @@ impl VecDeque { } } + /// Removes and returns the first element from the deque if the predicate + /// returns `true`, or [`None`] if the predicate returns false or the deque + /// is empty (the predicate will not be called in that case). + /// + /// # Examples + /// + /// ``` + /// #![feature(vec_deque_pop_if)] + /// use std::collections::VecDeque; + /// + /// let mut deque: VecDeque = vec![0, 1, 2, 3, 4].into(); + /// let pred = |x: &mut i32| *x % 2 == 0; + /// + /// assert_eq!(deque.pop_front_if(pred), Some(0)); + /// assert_eq!(deque, [1, 2, 3, 4]); + /// assert_eq!(deque.pop_front_if(pred), None); + /// ``` + #[unstable(feature = "vec_deque_pop_if", issue = "135889")] + pub fn pop_front_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option { + let first = self.front_mut()?; + if predicate(first) { self.pop_front() } else { None } + } + + /// Removes and returns the last element from the deque if the predicate + /// returns `true`, or [`None`] if the predicate returns false or the deque + /// is empty (the predicate will not be called in that case). + /// + /// # Examples + /// + /// ``` + /// #![feature(vec_deque_pop_if)] + /// use std::collections::VecDeque; + /// + /// let mut deque: VecDeque = vec![0, 1, 2, 3, 4].into(); + /// let pred = |x: &mut i32| *x % 2 == 0; + /// + /// assert_eq!(deque.pop_back_if(pred), Some(4)); + /// assert_eq!(deque, [0, 1, 2, 3]); + /// assert_eq!(deque.pop_back_if(pred), None); + /// ``` + #[unstable(feature = "vec_deque_pop_if", issue = "135889")] + pub fn pop_back_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option { + let first = self.back_mut()?; + if predicate(first) { self.pop_back() } else { None } + } + /// Prepends an element to the deque. /// /// # Examples @@ -1869,7 +1917,7 @@ impl VecDeque { /// /// # Panics /// - /// Panics if `index` is greater than deque's length + /// Panics if `index` is strictly greater than deque's length /// /// # Examples /// @@ -1884,6 +1932,9 @@ impl VecDeque { /// /// vec_deque.insert(1, 'd'); /// assert_eq!(vec_deque, &['a', 'd', 'b', 'c']); + /// + /// vec_deque.insert(4, 'e'); + /// assert_eq!(vec_deque, &['a', 'd', 'b', 'c', 'e']); /// ``` #[stable(feature = "deque_extras_15", since = "1.5.0")] #[track_caller] @@ -1928,13 +1979,13 @@ impl VecDeque { /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); - /// buf.push_back(1); - /// buf.push_back(2); - /// buf.push_back(3); - /// assert_eq!(buf, [1, 2, 3]); + /// buf.push_back('a'); + /// buf.push_back('b'); + /// buf.push_back('c'); + /// assert_eq!(buf, ['a', 'b', 'c']); /// - /// assert_eq!(buf.remove(1), Some(2)); - /// assert_eq!(buf, [1, 3]); + /// assert_eq!(buf.remove(1), Some('b')); + /// assert_eq!(buf, ['a', 'c']); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_confusables("delete", "take")] @@ -1982,10 +2033,10 @@ impl VecDeque { /// ``` /// use std::collections::VecDeque; /// - /// let mut buf: VecDeque<_> = [1, 2, 3].into(); + /// let mut buf: VecDeque<_> = ['a', 'b', 'c'].into(); /// let buf2 = buf.split_off(1); - /// assert_eq!(buf, [1]); - /// assert_eq!(buf2, [2, 3]); + /// assert_eq!(buf, ['a']); + /// assert_eq!(buf2, ['b', 'c']); /// ``` #[inline] #[must_use = "use `.truncate()` if you don't need the other half"] diff --git a/alloc/src/collections/vec_deque/spec_extend.rs b/alloc/src/collections/vec_deque/spec_extend.rs index d246385ca8419..7c7072c4c3a1b 100644 --- a/alloc/src/collections/vec_deque/spec_extend.rs +++ b/alloc/src/collections/vec_deque/spec_extend.rs @@ -3,6 +3,7 @@ use core::slice; use super::VecDeque; use crate::alloc::Allocator; +#[cfg(not(test))] use crate::vec; // Specialization trait used for VecDeque::extend @@ -78,6 +79,7 @@ where } } +#[cfg(not(test))] impl SpecExtend> for VecDeque { #[track_caller] fn spec_extend(&mut self, mut iterator: vec::IntoIter) { diff --git a/alloc/src/collections/vec_deque/spec_from_iter.rs b/alloc/src/collections/vec_deque/spec_from_iter.rs index 1efe84d6d7d7d..c80a30c2103dd 100644 --- a/alloc/src/collections/vec_deque/spec_from_iter.rs +++ b/alloc/src/collections/vec_deque/spec_from_iter.rs @@ -19,6 +19,7 @@ where } } +#[cfg(not(test))] impl SpecFromIter> for VecDeque { #[inline] fn spec_from_iter(iterator: crate::vec::IntoIter) -> Self { diff --git a/alloc/src/collections/vec_deque/tests.rs b/alloc/src/collections/vec_deque/tests.rs index 6328b3b4db867..c90679f179775 100644 --- a/alloc/src/collections/vec_deque/tests.rs +++ b/alloc/src/collections/vec_deque/tests.rs @@ -562,9 +562,10 @@ fn make_contiguous_head_to_end() { tester.push_front(i as char); } - assert_eq!(tester, [ - 'P', 'O', 'N', 'M', 'L', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K' - ]); + assert_eq!( + tester, + ['P', 'O', 'N', 'M', 'L', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'] + ); // ABCDEFGHIJKPONML let expected_start = 0; diff --git a/alloc/src/ffi/c_str.rs b/alloc/src/ffi/c_str.rs index d91682b796e4f..f6743c6571095 100644 --- a/alloc/src/ffi/c_str.rs +++ b/alloc/src/ffi/c_str.rs @@ -1,8 +1,5 @@ //! [`CString`] and its related types. -#[cfg(test)] -mod tests; - use core::borrow::Borrow; use core::ffi::{CStr, c_char}; use core::num::NonZero; @@ -13,7 +10,6 @@ use core::{fmt, mem, ops, ptr, slice}; use crate::borrow::{Cow, ToOwned}; use crate::boxed::Box; use crate::rc::Rc; -use crate::slice::hack::into_vec; use crate::string::String; #[cfg(target_has_atomic = "ptr")] use crate::sync::Arc; @@ -106,7 +102,7 @@ use crate::vec::Vec; /// of `CString` instances can lead to invalid memory accesses, memory leaks, /// and other memory errors. #[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone)] -#[cfg_attr(not(test), rustc_diagnostic_item = "cstring_type")] +#[rustc_diagnostic_item = "cstring_type"] #[stable(feature = "alloc_c_string", since = "1.64.0")] pub struct CString { // Invariant 1: the slice ends with a zero byte and has a length of at least one. @@ -384,7 +380,7 @@ impl CString { /// fn some_extern_function(s: *mut c_char); /// } /// - /// let c_string = CString::new("Hello!").expect("CString::new failed"); + /// let c_string = CString::from(c"Hello!"); /// let raw = c_string.into_raw(); /// unsafe { /// some_extern_function(raw); @@ -400,7 +396,7 @@ impl CString { // information about the size of the allocation is correct on Rust's // side. unsafe { - extern "C" { + unsafe extern "C" { /// Provided by libc or compiler_builtins. fn strlen(s: *const c_char) -> usize; } @@ -429,7 +425,7 @@ impl CString { /// ``` /// use std::ffi::CString; /// - /// let c_string = CString::new("foo").expect("CString::new failed"); + /// let c_string = CString::from(c"foo"); /// /// let ptr = c_string.into_raw(); /// @@ -487,14 +483,14 @@ impl CString { /// ``` /// use std::ffi::CString; /// - /// let c_string = CString::new("foo").expect("CString::new failed"); + /// let c_string = CString::from(c"foo"); /// let bytes = c_string.into_bytes(); /// assert_eq!(bytes, vec![b'f', b'o', b'o']); /// ``` #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "cstring_into", since = "1.7.0")] pub fn into_bytes(self) -> Vec { - let mut vec = into_vec(self.into_inner()); + let mut vec = self.into_inner().into_vec(); let _nul = vec.pop(); debug_assert_eq!(_nul, Some(0u8)); vec @@ -508,14 +504,14 @@ impl CString { /// ``` /// use std::ffi::CString; /// - /// let c_string = CString::new("foo").expect("CString::new failed"); + /// let c_string = CString::from(c"foo"); /// let bytes = c_string.into_bytes_with_nul(); /// assert_eq!(bytes, vec![b'f', b'o', b'o', b'\0']); /// ``` #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "cstring_into", since = "1.7.0")] pub fn into_bytes_with_nul(self) -> Vec { - into_vec(self.into_inner()) + self.into_inner().into_vec() } /// Returns the contents of this `CString` as a slice of bytes. @@ -530,7 +526,7 @@ impl CString { /// ``` /// use std::ffi::CString; /// - /// let c_string = CString::new("foo").expect("CString::new failed"); + /// let c_string = CString::from(c"foo"); /// let bytes = c_string.as_bytes(); /// assert_eq!(bytes, &[b'f', b'o', b'o']); /// ``` @@ -550,7 +546,7 @@ impl CString { /// ``` /// use std::ffi::CString; /// - /// let c_string = CString::new("foo").expect("CString::new failed"); + /// let c_string = CString::from(c"foo"); /// let bytes = c_string.as_bytes_with_nul(); /// assert_eq!(bytes, &[b'f', b'o', b'o', b'\0']); /// ``` @@ -568,7 +564,7 @@ impl CString { /// ``` /// use std::ffi::{CString, CStr}; /// - /// let c_string = CString::new(b"foo".to_vec()).expect("CString::new failed"); + /// let c_string = CString::from(c"foo"); /// let cstr = c_string.as_c_str(); /// assert_eq!(cstr, /// CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed")); @@ -576,7 +572,7 @@ impl CString { #[inline] #[must_use] #[stable(feature = "as_c_str", since = "1.20.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "cstring_as_c_str")] + #[rustc_diagnostic_item = "cstring_as_c_str"] pub fn as_c_str(&self) -> &CStr { &*self } @@ -586,12 +582,9 @@ impl CString { /// # Examples /// /// ``` - /// use std::ffi::{CString, CStr}; - /// - /// let c_string = CString::new(b"foo".to_vec()).expect("CString::new failed"); + /// let c_string = c"foo".to_owned(); /// let boxed = c_string.into_boxed_c_str(); - /// assert_eq!(&*boxed, - /// CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed")); + /// assert_eq!(boxed.to_bytes_with_nul(), b"foo\0"); /// ``` #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "into_boxed_c_str", since = "1.20.0")] @@ -658,7 +651,7 @@ impl CString { /// assert_eq!( /// CString::from_vec_with_nul(b"abc\0".to_vec()) /// .expect("CString::from_vec_with_nul failed"), - /// CString::new(b"abc".to_vec()).expect("CString::new failed") + /// c"abc".to_owned() /// ); /// ``` /// @@ -761,7 +754,6 @@ impl<'a> From> for CString { } } -#[cfg(not(test))] #[stable(feature = "box_from_c_str", since = "1.17.0")] impl From<&CStr> for Box { /// Converts a `&CStr` into a `Box`, @@ -772,8 +764,7 @@ impl From<&CStr> for Box { } } -#[cfg(not(test))] -#[stable(feature = "box_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "box_from_mut_slice", since = "1.84.0")] impl From<&mut CStr> for Box { /// Converts a `&mut CStr` into a `Box`, /// by copying the contents into a newly allocated [`Box`]. @@ -851,7 +842,6 @@ impl TryFrom for String { } } -#[cfg(not(test))] #[stable(feature = "more_box_slice_clone", since = "1.29.0")] impl Clone for Box { #[inline] @@ -921,7 +911,7 @@ impl From<&CStr> for Arc { } #[cfg(target_has_atomic = "ptr")] -#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "shared_from_mut_slice", since = "1.84.0")] impl From<&mut CStr> for Arc { /// Converts a `&mut CStr` into a `Arc`, /// by copying the contents into a newly allocated [`Arc`]. @@ -953,7 +943,7 @@ impl From<&CStr> for Rc { } } -#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "shared_from_mut_slice", since = "1.84.0")] impl From<&mut CStr> for Rc { /// Converts a `&mut CStr` into a `Rc`, /// by copying the contents into a newly allocated [`Rc`]. @@ -971,12 +961,12 @@ impl Default for Rc { /// This may or may not share an allocation with other Rcs on the same thread. #[inline] fn default() -> Self { - let c_str: &CStr = Default::default(); - Rc::from(c_str) + let rc = Rc::<[u8]>::from(*b"\0"); + // `[u8]` has the same layout as `CStr`, and it is `NUL` terminated. + unsafe { Rc::from_raw(Rc::into_raw(rc) as *const CStr) } } } -#[cfg(not(test))] #[stable(feature = "default_box_extra", since = "1.17.0")] impl Default for Box { fn default() -> Box { @@ -1085,7 +1075,7 @@ impl ToOwned for CStr { } fn clone_into(&self, target: &mut CString) { - let mut b = into_vec(mem::take(&mut target.inner)); + let mut b = mem::take(&mut target.inner).into_vec(); self.to_bytes_with_nul().clone_into(&mut b); target.inner = b.into_boxed_slice(); } @@ -1118,7 +1108,6 @@ impl AsRef for CString { } } -#[cfg(not(test))] impl CStr { /// Converts a `CStr` into a [Cow]<[str]>. /// @@ -1168,11 +1157,12 @@ impl CStr { /// # Examples /// /// ``` - /// use std::ffi::CString; + /// use std::ffi::{CStr, CString}; /// - /// let c_string = CString::new(b"foo".to_vec()).expect("CString::new failed"); - /// let boxed = c_string.into_boxed_c_str(); - /// assert_eq!(boxed.into_c_string(), CString::new("foo").expect("CString::new failed")); + /// let boxed: Box = Box::from(c"foo"); + /// let c_string: CString = c"foo".to_owned(); + /// + /// assert_eq!(boxed.into_c_string(), c_string); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "`self` will be dropped if the result is not used"] diff --git a/alloc/src/ffi/mod.rs b/alloc/src/ffi/mod.rs index 4f9dc40a3cfc9..695d7ad07cf76 100644 --- a/alloc/src/ffi/mod.rs +++ b/alloc/src/ffi/mod.rs @@ -83,7 +83,7 @@ #[doc(inline)] #[stable(feature = "alloc_c_string", since = "1.64.0")] pub use self::c_str::CString; -#[doc(no_inline)] +#[doc(inline)] #[stable(feature = "alloc_c_string", since = "1.64.0")] pub use self::c_str::{FromVecWithNulError, IntoStringError, NulError}; diff --git a/alloc/src/fmt.rs b/alloc/src/fmt.rs index 695dddb25eeb4..e40de13f3d4a9 100644 --- a/alloc/src/fmt.rs +++ b/alloc/src/fmt.rs @@ -596,6 +596,8 @@ pub use core::fmt::{Arguments, write}; pub use core::fmt::{Binary, Octal}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::fmt::{Debug, Display}; +#[unstable(feature = "formatting_options", issue = "118117")] +pub use core::fmt::{DebugAsHex, FormattingOptions, Sign}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; #[stable(feature = "rust1", since = "1.0.0")] diff --git a/alloc/src/lib.rs b/alloc/src/lib.rs index 041ff37897f05..f0cdb1e4e0f78 100644 --- a/alloc/src/lib.rs +++ b/alloc/src/lib.rs @@ -56,6 +56,7 @@ //! [`Rc`]: rc //! [`RefCell`]: core::cell +#![allow(incomplete_features)] #![allow(unused_attributes)] #![stable(feature = "alloc", since = "1.36.0")] #![doc( @@ -88,12 +89,10 @@ #![allow(rustdoc::redundant_explicit_links)] #![warn(rustdoc::unescaped_backticks)] #![deny(ffi_unwind_calls)] +#![warn(unreachable_pub)] // // Library features: // tidy-alphabetical-start -#![cfg_attr(not(no_global_oom_handling), feature(const_alloc_error))] -#![cfg_attr(not(no_global_oom_handling), feature(const_btree_len))] -#![cfg_attr(test, feature(str_as_str))] #![feature(alloc_layout_extra)] #![feature(allocator_api)] #![feature(array_chunks)] @@ -101,29 +100,27 @@ #![feature(array_windows)] #![feature(ascii_char)] #![feature(assert_matches)] -#![feature(async_closure)] #![feature(async_fn_traits)] #![feature(async_iterator)] -#![feature(box_uninit_write)] +#![feature(bstr)] +#![feature(bstr_internals)] +#![feature(char_max_len)] #![feature(clone_to_uninit)] #![feature(coerce_unsized)] -#![feature(const_align_of_val)] -#![feature(const_box)] #![feature(const_eval_select)] #![feature(const_heap)] -#![feature(const_maybe_uninit_write)] -#![feature(const_size_of_val)] -#![feature(const_vec_string_slice)] #![feature(core_intrinsics)] #![feature(deprecated_suggestion)] #![feature(deref_pure_trait)] #![feature(dispatch_from_dyn)] +#![feature(ergonomic_clones)] #![feature(error_generic_member_access)] #![feature(exact_size_is_empty)] #![feature(extend_one)] #![feature(extend_one_unchecked)] #![feature(fmt_internals)] #![feature(fn_traits)] +#![feature(formatting_options)] #![feature(hasher_prefixfree_extras)] #![feature(inplace_iteration)] #![feature(iter_advance_by)] @@ -133,13 +130,13 @@ #![feature(local_waker)] #![feature(maybe_uninit_slice)] #![feature(maybe_uninit_uninit_array_transpose)] +#![feature(nonnull_provenance)] #![feature(panic_internals)] #![feature(pattern)] #![feature(pin_coerce_unsized_trait)] #![feature(pointer_like_trait)] #![feature(ptr_internals)] #![feature(ptr_metadata)] -#![feature(ptr_sub_ptr)] #![feature(set_ptr_value)] #![feature(sized_type_properties)] #![feature(slice_from_ptr_range)] @@ -149,6 +146,7 @@ #![feature(slice_range)] #![feature(std_internals)] #![feature(str_internals)] +#![feature(temporary_niche_types)] #![feature(trusted_fused)] #![feature(trusted_len)] #![feature(trusted_random_access)] @@ -158,25 +156,20 @@ #![feature(unicode_internals)] #![feature(unsize)] #![feature(unwrap_infallible)] -#![feature(vec_pop_if)] // tidy-alphabetical-end // // Language features: // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(strict_provenance))] -#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] -#![cfg_attr(not(test), feature(coroutine_trait))] -#![cfg_attr(test, feature(panic_update_hook))] -#![cfg_attr(test, feature(test))] #![feature(allocator_internals)] #![feature(allow_internal_unstable)] #![feature(cfg_sanitize)] #![feature(const_precise_live_drops)] -#![feature(const_try)] +#![feature(coroutine_trait)] #![feature(decl_macro)] #![feature(dropck_eyepatch)] #![feature(fundamental)] #![feature(hashmap_internals)] +#![feature(intrinsics)] #![feature(lang_items)] #![feature(min_specialization)] #![feature(multiple_supertrait_upcastable)] @@ -188,6 +181,7 @@ #![feature(slice_internals)] #![feature(staged_api)] #![feature(stmt_expr_attributes)] +#![feature(strict_provenance_lints)] #![feature(unboxed_closures)] #![feature(unsized_fn_params)] #![feature(with_negative_coherence)] @@ -203,15 +197,6 @@ // from other crates, but since this can only appear for lang items, it doesn't seem worth fixing. #![feature(intra_doc_pointers)] -// Allow testing this library -#[cfg(test)] -#[macro_use] -extern crate std; -#[cfg(test)] -extern crate test; -#[cfg(test)] -mod testing; - // Module with internal macros used by other modules (needs to be included before other modules). #[macro_use] mod macros; @@ -219,7 +204,6 @@ mod macros; mod raw_vec; // Heaps provided for low-level allocation strategies - pub mod alloc; // Primitive types using the heaps above @@ -227,13 +211,10 @@ pub mod alloc; // Need to conditionally define the mod from `boxed.rs` to avoid // duplicating the lang-items when building in test cfg; but also need // to allow code to have `use boxed::Box;` declarations. -#[cfg(not(test))] -pub mod boxed; -#[cfg(test)] -mod boxed { - pub use std::boxed::Box; -} pub mod borrow; +pub mod boxed; +#[unstable(feature = "bstr", issue = "134915")] +pub mod bstr; pub mod collections; #[cfg(all(not(no_rc), not(no_sync), not(no_global_oom_handling)))] pub mod ffi; @@ -247,8 +228,6 @@ pub mod string; pub mod sync; #[cfg(all(not(no_global_oom_handling), not(no_rc), not(no_sync)))] pub mod task; -#[cfg(test)] -mod tests; pub mod vec; #[doc(hidden)] @@ -257,20 +236,3 @@ pub mod __export { pub use core::format_args; pub use core::hint::must_use; } - -#[cfg(test)] -#[allow(dead_code)] // Not used in all configurations -pub(crate) mod test_helpers { - /// Copied from `std::test_helpers::test_rng`, since these tests rely on the - /// seed not being the same for every RNG invocation too. - pub(crate) fn test_rng() -> rand_xorshift::XorShiftRng { - use std::hash::{BuildHasher, Hash, Hasher}; - let mut hasher = std::hash::RandomState::new().build_hasher(); - std::panic::Location::caller().hash(&mut hasher); - let hc64 = hasher.finish(); - let seed_vec = - hc64.to_le_bytes().into_iter().chain(0u8..8).collect::>(); - let seed: [u8; 16] = seed_vec.as_slice().try_into().unwrap(); - rand::SeedableRng::from_seed(seed) - } -} diff --git a/alloc/src/macros.rs b/alloc/src/macros.rs index 8c6a367869ce0..214192b8c9a9b 100644 --- a/alloc/src/macros.rs +++ b/alloc/src/macros.rs @@ -34,7 +34,7 @@ /// be mindful of side effects. /// /// [`Vec`]: crate::vec::Vec -#[cfg(all(not(no_global_oom_handling), not(test)))] +#[cfg(not(no_global_oom_handling))] #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "vec_macro"] @@ -48,33 +48,13 @@ macro_rules! vec { ); ($($x:expr),+ $(,)?) => ( <[_]>::into_vec( - // This rustc_box is not required, but it produces a dramatic improvement in compile - // time when constructing arrays with many elements. - #[rustc_box] - $crate::boxed::Box::new([$($x),+]) + // Using the intrinsic produces a dramatic improvement in stack usage for + // unoptimized programs using this code path to construct large Vecs. + $crate::boxed::box_new([$($x),+]) ) ); } -// HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is -// required for this macro definition, is not available. Instead use the -// `slice::into_vec` function which is only available with cfg(test) -// NB see the slice::hack module in slice.rs for more information -#[cfg(all(not(no_global_oom_handling), test))] -#[allow(unused_macro_rules)] -macro_rules! vec { - () => ( - $crate::vec::Vec::new() - ); - ($elem:expr; $n:expr) => ( - $crate::vec::from_elem($elem, $n) - ); - ($($x:expr),*) => ( - $crate::slice::into_vec($crate::boxed::Box::new([$($x),*])) - ); - ($($x:expr,)*) => (vec![$($x),*]) -} - /// Creates a `String` using interpolation of runtime expressions. /// /// The first argument `format!` receives is a format string. This must be a string @@ -121,7 +101,7 @@ macro_rules! vec { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] #[allow_internal_unstable(hint_must_use, liballoc_internals)] -#[cfg_attr(not(test), rustc_diagnostic_item = "format_macro")] +#[rustc_diagnostic_item = "format_macro"] macro_rules! format { ($($arg:tt)*) => { $crate::__export::must_use({ diff --git a/alloc/src/raw_vec.rs b/alloc/src/raw_vec/mod.rs similarity index 90% rename from alloc/src/raw_vec.rs rename to alloc/src/raw_vec/mod.rs index 85a9120c7e255..99ebc5c4bfca8 100644 --- a/alloc/src/raw_vec.rs +++ b/alloc/src/raw_vec/mod.rs @@ -1,4 +1,8 @@ #![unstable(feature = "raw_vec_internals", reason = "unstable const warnings", issue = "none")] +#![cfg_attr(test, allow(dead_code))] + +// Note: This module is also included in the alloctests crate using #[path] to +// run the tests. See the comment there for an explanation why this is the case. use core::marker::PhantomData; use core::mem::{ManuallyDrop, MaybeUninit, SizedTypeProperties}; @@ -33,21 +37,15 @@ enum AllocInit { Zeroed, } -#[repr(transparent)] -#[cfg_attr(target_pointer_width = "16", rustc_layout_scalar_valid_range_end(0x7fff))] -#[cfg_attr(target_pointer_width = "32", rustc_layout_scalar_valid_range_end(0x7fff_ffff))] -#[cfg_attr(target_pointer_width = "64", rustc_layout_scalar_valid_range_end(0x7fff_ffff_ffff_ffff))] -struct Cap(usize); +type Cap = core::num::niche_types::UsizeNoHighBit; -impl Cap { - const ZERO: Cap = unsafe { Cap(0) }; +const ZERO_CAP: Cap = unsafe { Cap::new_unchecked(0) }; - /// `Cap(cap)`, except if `T` is a ZST then `Cap::ZERO`. - /// - /// # Safety: cap must be <= `isize::MAX`. - unsafe fn new(cap: usize) -> Self { - if T::IS_ZST { Cap::ZERO } else { unsafe { Self(cap) } } - } +/// `Cap(cap)`, except if `T` is a ZST then `Cap::ZERO`. +/// +/// # Safety: cap must be <= `isize::MAX`. +unsafe fn new_cap(cap: usize) -> Cap { + if T::IS_ZST { ZERO_CAP } else { unsafe { Cap::new_unchecked(cap) } } } /// A low-level utility for more ergonomically allocating, reallocating, and deallocating @@ -103,8 +101,7 @@ impl RawVec { /// `RawVec` with capacity `usize::MAX`. Useful for implementing /// delayed allocation. #[must_use] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "raw_vec_internals_const", since = "1.81"))] - pub const fn new() -> Self { + pub(crate) const fn new() -> Self { Self::new_in(Global) } @@ -127,7 +124,7 @@ impl RawVec { #[must_use] #[inline] #[track_caller] - pub fn with_capacity(capacity: usize) -> Self { + pub(crate) fn with_capacity(capacity: usize) -> Self { Self { inner: RawVecInner::with_capacity(capacity, T::LAYOUT), _marker: PhantomData } } @@ -136,7 +133,7 @@ impl RawVec { #[must_use] #[inline] #[track_caller] - pub fn with_capacity_zeroed(capacity: usize) -> Self { + pub(crate) fn with_capacity_zeroed(capacity: usize) -> Self { Self { inner: RawVecInner::with_capacity_zeroed_in(capacity, Global, T::LAYOUT), _marker: PhantomData, @@ -179,8 +176,7 @@ impl RawVec { /// Like `new`, but parameterized over the choice of allocator for /// the returned `RawVec`. #[inline] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "raw_vec_internals_const", since = "1.81"))] - pub const fn new_in(alloc: A) -> Self { + pub(crate) const fn new_in(alloc: A) -> Self { Self { inner: RawVecInner::new_in(alloc, align_of::()), _marker: PhantomData } } @@ -189,7 +185,7 @@ impl RawVec { #[cfg(not(no_global_oom_handling))] #[inline] #[track_caller] - pub fn with_capacity_in(capacity: usize, alloc: A) -> Self { + pub(crate) fn with_capacity_in(capacity: usize, alloc: A) -> Self { Self { inner: RawVecInner::with_capacity_in(capacity, alloc, T::LAYOUT), _marker: PhantomData, @@ -199,7 +195,7 @@ impl RawVec { /// Like `try_with_capacity`, but parameterized over the choice of /// allocator for the returned `RawVec`. #[inline] - pub fn try_with_capacity_in(capacity: usize, alloc: A) -> Result { + pub(crate) fn try_with_capacity_in(capacity: usize, alloc: A) -> Result { match RawVecInner::try_with_capacity_in(capacity, alloc, T::LAYOUT) { Ok(inner) => Ok(Self { inner, _marker: PhantomData }), Err(e) => Err(e), @@ -211,7 +207,7 @@ impl RawVec { #[cfg(not(no_global_oom_handling))] #[inline] #[track_caller] - pub fn with_capacity_zeroed_in(capacity: usize, alloc: A) -> Self { + pub(crate) fn with_capacity_zeroed_in(capacity: usize, alloc: A) -> Self { Self { inner: RawVecInner::with_capacity_zeroed_in(capacity, alloc, T::LAYOUT), _marker: PhantomData, @@ -230,7 +226,7 @@ impl RawVec { /// /// Note, that the requested capacity and `self.capacity()` could differ, as /// an allocator could overallocate and return a greater memory block than requested. - pub unsafe fn into_box(self, len: usize) -> Box<[MaybeUninit], A> { + pub(crate) unsafe fn into_box(self, len: usize) -> Box<[MaybeUninit], A> { // Sanity-check one half of the safety requirement (we cannot check the other half). debug_assert!( len <= self.capacity(), @@ -255,11 +251,11 @@ impl RawVec { /// If the `ptr` and `capacity` come from a `RawVec` created via `alloc`, then this is /// guaranteed. #[inline] - pub unsafe fn from_raw_parts_in(ptr: *mut T, capacity: usize, alloc: A) -> Self { + pub(crate) unsafe fn from_raw_parts_in(ptr: *mut T, capacity: usize, alloc: A) -> Self { // SAFETY: Precondition passed to the caller unsafe { let ptr = ptr.cast(); - let capacity = Cap::new::(capacity); + let capacity = new_cap::(capacity); Self { inner: RawVecInner::from_raw_parts_in(ptr, capacity, alloc), _marker: PhantomData, @@ -273,11 +269,11 @@ impl RawVec { /// /// See [`RawVec::from_raw_parts_in`]. #[inline] - pub unsafe fn from_nonnull_in(ptr: NonNull, capacity: usize, alloc: A) -> Self { + pub(crate) unsafe fn from_nonnull_in(ptr: NonNull, capacity: usize, alloc: A) -> Self { // SAFETY: Precondition passed to the caller unsafe { let ptr = ptr.cast(); - let capacity = Cap::new::(capacity); + let capacity = new_cap::(capacity); Self { inner: RawVecInner::from_nonnull_in(ptr, capacity, alloc), _marker: PhantomData } } } @@ -286,12 +282,12 @@ impl RawVec { /// `Unique::dangling()` if `capacity == 0` or `T` is zero-sized. In the former case, you must /// be careful. #[inline] - pub const fn ptr(&self) -> *mut T { + pub(crate) const fn ptr(&self) -> *mut T { self.inner.ptr() } #[inline] - pub fn non_null(&self) -> NonNull { + pub(crate) fn non_null(&self) -> NonNull { self.inner.non_null() } @@ -299,13 +295,13 @@ impl RawVec { /// /// This will always be `usize::MAX` if `T` is zero-sized. #[inline] - pub const fn capacity(&self) -> usize { + pub(crate) const fn capacity(&self) -> usize { self.inner.capacity(size_of::()) } /// Returns a shared reference to the allocator backing this `RawVec`. #[inline] - pub fn allocator(&self) -> &A { + pub(crate) fn allocator(&self) -> &A { self.inner.allocator() } @@ -331,7 +327,7 @@ impl RawVec { #[cfg(not(no_global_oom_handling))] #[inline] #[track_caller] - pub fn reserve(&mut self, len: usize, additional: usize) { + pub(crate) fn reserve(&mut self, len: usize, additional: usize) { self.inner.reserve(len, additional, T::LAYOUT) } @@ -340,12 +336,16 @@ impl RawVec { #[cfg(not(no_global_oom_handling))] #[inline(never)] #[track_caller] - pub fn grow_one(&mut self) { + pub(crate) fn grow_one(&mut self) { self.inner.grow_one(T::LAYOUT) } /// The same as `reserve`, but returns on errors instead of panicking or aborting. - pub fn try_reserve(&mut self, len: usize, additional: usize) -> Result<(), TryReserveError> { + pub(crate) fn try_reserve( + &mut self, + len: usize, + additional: usize, + ) -> Result<(), TryReserveError> { self.inner.try_reserve(len, additional, T::LAYOUT) } @@ -368,12 +368,12 @@ impl RawVec { /// Aborts on OOM. #[cfg(not(no_global_oom_handling))] #[track_caller] - pub fn reserve_exact(&mut self, len: usize, additional: usize) { + pub(crate) fn reserve_exact(&mut self, len: usize, additional: usize) { self.inner.reserve_exact(len, additional, T::LAYOUT) } /// The same as `reserve_exact`, but returns on errors instead of panicking or aborting. - pub fn try_reserve_exact( + pub(crate) fn try_reserve_exact( &mut self, len: usize, additional: usize, @@ -394,7 +394,7 @@ impl RawVec { #[cfg(not(no_global_oom_handling))] #[track_caller] #[inline] - pub fn shrink_to_fit(&mut self, cap: usize) { + pub(crate) fn shrink_to_fit(&mut self, cap: usize) { self.inner.shrink_to_fit(cap, T::LAYOUT) } } @@ -409,11 +409,10 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for RawVec { impl RawVecInner { #[inline] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "raw_vec_internals_const", since = "1.81"))] const fn new_in(alloc: A, align: usize) -> Self { let ptr = unsafe { core::mem::transmute(align) }; // `cap: 0` means "unallocated". zero-sized types are ignored. - Self { ptr, cap: Cap::ZERO, alloc } + Self { ptr, cap: ZERO_CAP, alloc } } #[cfg(not(no_global_oom_handling))] @@ -423,7 +422,7 @@ impl RawVecInner { match Self::try_allocate_in(capacity, AllocInit::Uninitialized, alloc, elem_layout) { Ok(this) => { unsafe { - // Make it more obvious that a subsquent Vec::reserve(capacity) will not allocate. + // Make it more obvious that a subsequent Vec::reserve(capacity) will not allocate. hint::assert_unchecked(!this.needs_to_grow(0, capacity, elem_layout)); } this @@ -485,8 +484,12 @@ impl RawVecInner { // Allocators currently return a `NonNull<[u8]>` whose length // matches the size requested. If that ever changes, the capacity - // here should change to `ptr.len() / mem::size_of::()`. - Ok(Self { ptr: Unique::from(ptr.cast()), cap: unsafe { Cap(capacity) }, alloc }) + // here should change to `ptr.len() / size_of::()`. + Ok(Self { + ptr: Unique::from(ptr.cast()), + cap: unsafe { Cap::new_unchecked(capacity) }, + alloc, + }) } #[inline] @@ -511,7 +514,7 @@ impl RawVecInner { #[inline] const fn capacity(&self, elem_size: usize) -> usize { - if elem_size == 0 { usize::MAX } else { self.cap.0 } + if elem_size == 0 { usize::MAX } else { self.cap.as_inner() } } #[inline] @@ -521,7 +524,7 @@ impl RawVecInner { #[inline] fn current_memory(&self, elem_layout: Layout) -> Option<(NonNull, Layout)> { - if elem_layout.size() == 0 || self.cap.0 == 0 { + if elem_layout.size() == 0 || self.cap.as_inner() == 0 { None } else { // We could use Layout::array here which ensures the absence of isize and usize overflows @@ -529,7 +532,7 @@ impl RawVecInner { // has already been allocated so we know it can't overflow and currently Rust does not // support such types. So we can do better by skipping some checks and avoid an unwrap. unsafe { - let alloc_size = elem_layout.size().unchecked_mul(self.cap.0); + let alloc_size = elem_layout.size().unchecked_mul(self.cap.as_inner()); let layout = Layout::from_size_align_unchecked(alloc_size, elem_layout.align()); Some((self.ptr.into(), layout)) } @@ -565,7 +568,7 @@ impl RawVecInner { #[inline] #[track_caller] fn grow_one(&mut self, elem_layout: Layout) { - if let Err(err) = self.grow_amortized(self.cap.0, 1, elem_layout) { + if let Err(err) = self.grow_amortized(self.cap.as_inner(), 1, elem_layout) { handle_error(err); } } @@ -628,9 +631,9 @@ impl RawVecInner { unsafe fn set_ptr_and_cap(&mut self, ptr: NonNull<[u8]>, cap: usize) { // Allocators currently return a `NonNull<[u8]>` whose length matches // the size requested. If that ever changes, the capacity here should - // change to `ptr.len() / mem::size_of::()`. + // change to `ptr.len() / size_of::()`. self.ptr = Unique::from(ptr.cast()); - self.cap = unsafe { Cap(cap) }; + self.cap = unsafe { Cap::new_unchecked(cap) }; } fn grow_amortized( @@ -653,7 +656,7 @@ impl RawVecInner { // This guarantees exponential growth. The doubling cannot overflow // because `cap <= isize::MAX` and the type of `cap` is `usize`. - let cap = cmp::max(self.cap.0 * 2, required_cap); + let cap = cmp::max(self.cap.as_inner() * 2, required_cap); let cap = cmp::max(min_non_zero_cap(elem_layout.size()), cap); let new_layout = layout_array(cap, elem_layout)?; @@ -722,7 +725,7 @@ impl RawVecInner { unsafe { self.alloc.deallocate(ptr, layout) }; self.ptr = unsafe { Unique::new_unchecked(ptr::without_provenance_mut(elem_layout.align())) }; - self.cap = Cap::ZERO; + self.cap = ZERO_CAP; } else { let ptr = unsafe { // Layout cannot overflow here because it would have @@ -757,7 +760,9 @@ impl RawVecInner { } } -#[inline(never)] +// not marked inline(never) since we want optimizers to be able to observe the specifics of this +// function, see tests/codegen/vec-reserve-extend.rs. +#[cold] fn finish_grow( new_layout: Layout, current_memory: Option<(NonNull, Layout)>, diff --git a/alloc/src/raw_vec/tests.rs b/alloc/src/raw_vec/tests.rs index d78ded104fb09..700fa922739d6 100644 --- a/alloc/src/raw_vec/tests.rs +++ b/alloc/src/raw_vec/tests.rs @@ -1,4 +1,3 @@ -use core::mem::size_of; use std::cell::Cell; use super::*; @@ -93,7 +92,7 @@ fn zst_sanity(v: &RawVec) { fn zst() { let cap_err = Err(crate::collections::TryReserveErrorKind::CapacityOverflow.into()); - assert_eq!(std::mem::size_of::(), 0); + assert_eq!(size_of::(), 0); // All these different ways of creating the RawVec produce the same thing. diff --git a/alloc/src/rc.rs b/alloc/src/rc.rs index 3a9bd1b5bf119..fc1cee28d0334 100644 --- a/alloc/src/rc.rs +++ b/alloc/src/rc.rs @@ -245,6 +245,7 @@ use core::any::Any; use core::cell::Cell; #[cfg(not(no_global_oom_handling))] use core::clone::CloneToUninit; +use core::clone::UseCloned; use core::cmp::Ordering; use core::hash::{Hash, Hasher}; use core::intrinsics::abort; @@ -252,6 +253,7 @@ use core::intrinsics::abort; use core::iter; use core::marker::{PhantomData, Unsize}; use core::mem::{self, ManuallyDrop, align_of_val_raw}; +use core::num::NonZeroUsize; use core::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn, LegacyReceiver}; use core::panic::{RefUnwindSafe, UnwindSafe}; #[cfg(not(no_global_oom_handling))] @@ -261,23 +263,17 @@ use core::ptr::{self, NonNull, drop_in_place}; #[cfg(not(no_global_oom_handling))] use core::slice::from_raw_parts_mut; use core::{borrow, fmt, hint}; -#[cfg(test)] -use std::boxed::Box; #[cfg(not(no_global_oom_handling))] use crate::alloc::handle_alloc_error; use crate::alloc::{AllocError, Allocator, Global, Layout}; use crate::borrow::{Cow, ToOwned}; -#[cfg(not(test))] use crate::boxed::Box; #[cfg(not(no_global_oom_handling))] use crate::string::String; #[cfg(not(no_global_oom_handling))] use crate::vec::Vec; -#[cfg(test)] -mod tests; - // This is repr(C) to future-proof against possible field-reordering, which // would interfere with otherwise safe [into|from]_raw() of transmutable // inner types. @@ -307,8 +303,8 @@ fn rc_inner_layout_for_value_layout(layout: Layout) -> Layout { /// `value.get_mut()`. This avoids conflicts with methods of the inner type `T`. /// /// [get_mut]: Rc::get_mut -#[cfg_attr(not(bootstrap), doc(search_unbox))] -#[cfg_attr(not(test), rustc_diagnostic_item = "Rc")] +#[doc(search_unbox)] +#[rustc_diagnostic_item = "Rc"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_insignificant_dtor] pub struct Rc< @@ -795,7 +791,7 @@ impl Rc { let uninit_ptr: NonNull<_> = (unsafe { &mut *uninit_raw_ptr }).into(); let init_ptr: NonNull> = uninit_ptr.cast(); - let weak = Weak { ptr: init_ptr, alloc: alloc }; + let weak = Weak { ptr: init_ptr, alloc }; // It's important we don't give up ownership of the weak pointer, or // else the memory might be freed by the time `data_fn` returns. If @@ -1084,6 +1080,26 @@ impl Rc<[T]> { )) } } + + /// Converts the reference-counted slice into a reference-counted array. + /// + /// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type. + /// + /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. + #[unstable(feature = "slice_as_array", issue = "133508")] + #[inline] + #[must_use] + pub fn into_array(self) -> Option> { + if self.len() == N { + let ptr = Self::into_raw(self) as *const [T; N]; + + // SAFETY: The underlying array of a slice has the exact same layout as an actual array `[T; N]` if `N` is equal to the slice's length. + let me = unsafe { Rc::from_raw(ptr) }; + Some(me) + } else { + None + } + } } impl Rc<[T], A> { @@ -1441,18 +1457,18 @@ impl Rc { /// Provides a raw pointer to the data. /// /// The counts are not affected in any way and the `Rc` is not consumed. The pointer is valid - /// for as long there are strong counts in the `Rc`. + /// for as long as there are strong counts in the `Rc`. /// /// # Examples /// /// ``` /// use std::rc::Rc; /// - /// let x = Rc::new("hello".to_owned()); + /// let x = Rc::new(0); /// let y = Rc::clone(&x); /// let x_ptr = Rc::as_ptr(&x); /// assert_eq!(x_ptr, Rc::as_ptr(&y)); - /// assert_eq!(unsafe { &*x_ptr }, "hello"); + /// assert_eq!(unsafe { *x_ptr }, 0); /// ``` #[stable(feature = "weak_into_raw", since = "1.45.0")] #[rustc_never_returns_null_ptr] @@ -1769,7 +1785,7 @@ impl Rc { /// let x: Rc<&str> = Rc::new("Hello, world!"); /// { /// let s = String::from("Oh, no!"); - /// let mut y: Rc<&str> = x.clone().into(); + /// let mut y: Rc<&str> = x.clone(); /// unsafe { /// // this is Undefined Behavior, because x's inner type /// // is &'long str, not &'short str @@ -2232,12 +2248,20 @@ impl Deref for Rc { #[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] unsafe impl PinCoerceUnsized for Rc {} +//#[unstable(feature = "unique_rc_arc", issue = "112566")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +unsafe impl PinCoerceUnsized for UniqueRc {} + #[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] unsafe impl PinCoerceUnsized for Weak {} #[unstable(feature = "deref_pure_trait", issue = "87121")] unsafe impl DerefPure for Rc {} +//#[unstable(feature = "unique_rc_arc", issue = "112566")] +#[unstable(feature = "deref_pure_trait", issue = "87121")] +unsafe impl DerefPure for UniqueRc {} + #[unstable(feature = "legacy_receiver_trait", issue = "none")] impl LegacyReceiver for Rc {} @@ -2304,6 +2328,9 @@ impl Clone for Rc { } } +#[unstable(feature = "ergonomic_clones", issue = "132290")] +impl UseCloned for Rc {} + #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] impl Default for Rc { @@ -2321,11 +2348,10 @@ impl Default for Rc { fn default() -> Rc { unsafe { Self::from_inner( - Box::leak(Box::write(Box::new_uninit(), RcInner { - strong: Cell::new(1), - weak: Cell::new(1), - value: T::default(), - })) + Box::leak(Box::write( + Box::new_uninit(), + RcInner { strong: Cell::new(1), weak: Cell::new(1), value: T::default() }, + )) .into(), ) } @@ -2340,7 +2366,9 @@ impl Default for Rc { /// This may or may not share an allocation with other Rcs on the same thread. #[inline] fn default() -> Self { - Rc::from("") + let rc = Rc::<[u8]>::default(); + // `[u8]` has the same layout as `str`. + unsafe { Rc::from_raw(Rc::into_raw(rc) as *const str) } } } @@ -2659,7 +2687,7 @@ impl From<&[T]> for Rc<[T]> { } #[cfg(not(no_global_oom_handling))] -#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "shared_from_mut_slice", since = "1.84.0")] impl From<&mut [T]> for Rc<[T]> { /// Allocates a reference-counted slice and fills it by cloning `v`'s items. /// @@ -2698,7 +2726,7 @@ impl From<&str> for Rc { } #[cfg(not(no_global_oom_handling))] -#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "shared_from_mut_slice", since = "1.84.0")] impl From<&mut str> for Rc { /// Allocates a reference-counted string slice and copies `v` into it. /// @@ -2954,7 +2982,7 @@ impl> ToRcSlice for I { /// /// [`upgrade`]: Weak::upgrade #[stable(feature = "rc_weak", since = "1.4.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "RcWeak")] +#[rustc_diagnostic_item = "RcWeak"] pub struct Weak< T: ?Sized, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, @@ -2999,12 +3027,7 @@ impl Weak { #[rustc_const_stable(feature = "const_weak_new", since = "1.73.0")] #[must_use] pub const fn new() -> Weak { - Weak { - ptr: unsafe { - NonNull::new_unchecked(ptr::without_provenance_mut::>(usize::MAX)) - }, - alloc: Global, - } + Weak { ptr: NonNull::without_provenance(NonZeroUsize::MAX), alloc: Global } } } @@ -3026,12 +3049,7 @@ impl Weak { #[inline] #[unstable(feature = "allocator_api", issue = "32838")] pub fn new_in(alloc: A) -> Weak { - Weak { - ptr: unsafe { - NonNull::new_unchecked(ptr::without_provenance_mut::>(usize::MAX)) - }, - alloc, - } + Weak { ptr: NonNull::without_provenance(NonZeroUsize::MAX), alloc } } } @@ -3476,6 +3494,9 @@ impl Clone for Weak { } } +#[unstable(feature = "ergonomic_clones", issue = "132290")] +impl UseCloned for Weak {} + #[stable(feature = "rc_weak", since = "1.4.0")] impl fmt::Debug for Weak { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -3684,22 +3705,266 @@ fn data_offset_align(align: usize) -> usize { /// previous example, `UniqueRc` allows for more flexibility in the construction of cyclic data, /// including fallible or async constructors. #[unstable(feature = "unique_rc_arc", issue = "112566")] -#[derive(Debug)] pub struct UniqueRc< T: ?Sized, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, > { ptr: NonNull>, - phantom: PhantomData>, + // Define the ownership of `RcInner` for drop-check + _marker: PhantomData>, + // Invariance is necessary for soundness: once other `Weak` + // references exist, we already have a form of shared mutability! + _marker2: PhantomData<*mut T>, alloc: A, } +// Not necessary for correctness since `UniqueRc` contains `NonNull`, +// but having an explicit negative impl is nice for documentation purposes +// and results in nicer error messages. +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl !Send for UniqueRc {} + +// Not necessary for correctness since `UniqueRc` contains `NonNull`, +// but having an explicit negative impl is nice for documentation purposes +// and results in nicer error messages. +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl !Sync for UniqueRc {} + #[unstable(feature = "unique_rc_arc", issue = "112566")] impl, U: ?Sized, A: Allocator> CoerceUnsized> for UniqueRc { } +//#[unstable(feature = "unique_rc_arc", issue = "112566")] +#[unstable(feature = "dispatch_from_dyn", issue = "none")] +impl, U: ?Sized> DispatchFromDyn> for UniqueRc {} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl fmt::Display for UniqueRc { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(&**self, f) + } +} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl fmt::Debug for UniqueRc { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&**self, f) + } +} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl fmt::Pointer for UniqueRc { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Pointer::fmt(&(&raw const **self), f) + } +} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl borrow::Borrow for UniqueRc { + fn borrow(&self) -> &T { + &**self + } +} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl borrow::BorrowMut for UniqueRc { + fn borrow_mut(&mut self) -> &mut T { + &mut **self + } +} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl AsRef for UniqueRc { + fn as_ref(&self) -> &T { + &**self + } +} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl AsMut for UniqueRc { + fn as_mut(&mut self) -> &mut T { + &mut **self + } +} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl Unpin for UniqueRc {} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl PartialEq for UniqueRc { + /// Equality for two `UniqueRc`s. + /// + /// Two `UniqueRc`s are equal if their inner values are equal. + /// + /// # Examples + /// + /// ``` + /// #![feature(unique_rc_arc)] + /// use std::rc::UniqueRc; + /// + /// let five = UniqueRc::new(5); + /// + /// assert!(five == UniqueRc::new(5)); + /// ``` + #[inline] + fn eq(&self, other: &Self) -> bool { + PartialEq::eq(&**self, &**other) + } + + /// Inequality for two `UniqueRc`s. + /// + /// Two `UniqueRc`s are not equal if their inner values are not equal. + /// + /// # Examples + /// + /// ``` + /// #![feature(unique_rc_arc)] + /// use std::rc::UniqueRc; + /// + /// let five = UniqueRc::new(5); + /// + /// assert!(five != UniqueRc::new(6)); + /// ``` + #[inline] + fn ne(&self, other: &Self) -> bool { + PartialEq::ne(&**self, &**other) + } +} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl PartialOrd for UniqueRc { + /// Partial comparison for two `UniqueRc`s. + /// + /// The two are compared by calling `partial_cmp()` on their inner values. + /// + /// # Examples + /// + /// ``` + /// #![feature(unique_rc_arc)] + /// use std::rc::UniqueRc; + /// use std::cmp::Ordering; + /// + /// let five = UniqueRc::new(5); + /// + /// assert_eq!(Some(Ordering::Less), five.partial_cmp(&UniqueRc::new(6))); + /// ``` + #[inline(always)] + fn partial_cmp(&self, other: &UniqueRc) -> Option { + (**self).partial_cmp(&**other) + } + + /// Less-than comparison for two `UniqueRc`s. + /// + /// The two are compared by calling `<` on their inner values. + /// + /// # Examples + /// + /// ``` + /// #![feature(unique_rc_arc)] + /// use std::rc::UniqueRc; + /// + /// let five = UniqueRc::new(5); + /// + /// assert!(five < UniqueRc::new(6)); + /// ``` + #[inline(always)] + fn lt(&self, other: &UniqueRc) -> bool { + **self < **other + } + + /// 'Less than or equal to' comparison for two `UniqueRc`s. + /// + /// The two are compared by calling `<=` on their inner values. + /// + /// # Examples + /// + /// ``` + /// #![feature(unique_rc_arc)] + /// use std::rc::UniqueRc; + /// + /// let five = UniqueRc::new(5); + /// + /// assert!(five <= UniqueRc::new(5)); + /// ``` + #[inline(always)] + fn le(&self, other: &UniqueRc) -> bool { + **self <= **other + } + + /// Greater-than comparison for two `UniqueRc`s. + /// + /// The two are compared by calling `>` on their inner values. + /// + /// # Examples + /// + /// ``` + /// #![feature(unique_rc_arc)] + /// use std::rc::UniqueRc; + /// + /// let five = UniqueRc::new(5); + /// + /// assert!(five > UniqueRc::new(4)); + /// ``` + #[inline(always)] + fn gt(&self, other: &UniqueRc) -> bool { + **self > **other + } + + /// 'Greater than or equal to' comparison for two `UniqueRc`s. + /// + /// The two are compared by calling `>=` on their inner values. + /// + /// # Examples + /// + /// ``` + /// #![feature(unique_rc_arc)] + /// use std::rc::UniqueRc; + /// + /// let five = UniqueRc::new(5); + /// + /// assert!(five >= UniqueRc::new(5)); + /// ``` + #[inline(always)] + fn ge(&self, other: &UniqueRc) -> bool { + **self >= **other + } +} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl Ord for UniqueRc { + /// Comparison for two `UniqueRc`s. + /// + /// The two are compared by calling `cmp()` on their inner values. + /// + /// # Examples + /// + /// ``` + /// #![feature(unique_rc_arc)] + /// use std::rc::UniqueRc; + /// use std::cmp::Ordering; + /// + /// let five = UniqueRc::new(5); + /// + /// assert_eq!(Ordering::Less, five.cmp(&UniqueRc::new(6))); + /// ``` + #[inline] + fn cmp(&self, other: &UniqueRc) -> Ordering { + (**self).cmp(&**other) + } +} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl Eq for UniqueRc {} + +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl Hash for UniqueRc { + fn hash(&self, state: &mut H) { + (**self).hash(state); + } +} + // Depends on A = Global impl UniqueRc { /// Creates a new `UniqueRc`. @@ -3735,7 +4000,7 @@ impl UniqueRc { }, alloc, )); - Self { ptr: ptr.into(), phantom: PhantomData, alloc } + Self { ptr: ptr.into(), _marker: PhantomData, _marker2: PhantomData, alloc } } } @@ -3791,9 +4056,6 @@ impl Deref for UniqueRc { } } -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] -unsafe impl PinCoerceUnsized for UniqueRc {} - #[unstable(feature = "unique_rc_arc", issue = "112566")] impl DerefMut for UniqueRc { fn deref_mut(&mut self) -> &mut T { diff --git a/alloc/src/slice.rs b/alloc/src/slice.rs index e3c7835f1d10b..7c5d22e1ee9be 100644 --- a/alloc/src/slice.rs +++ b/alloc/src/slice.rs @@ -8,15 +8,12 @@ //! A few functions are provided to create a slice from a value reference //! or from a raw pointer. #![stable(feature = "rust1", since = "1.0.0")] -// Many of the usings in this module are only used in the test configuration. -// It's cleaner to just turn off the unused_imports warning than to fix them. -#![cfg_attr(test, allow(unused_imports, dead_code))] use core::borrow::{Borrow, BorrowMut}; #[cfg(not(no_global_oom_handling))] use core::cmp::Ordering::{self, Less}; #[cfg(not(no_global_oom_handling))] -use core::mem::{self, MaybeUninit}; +use core::mem::MaybeUninit; #[cfg(not(no_global_oom_handling))] use core::ptr; #[unstable(feature = "array_chunks", issue = "74985")] @@ -27,6 +24,8 @@ pub use core::slice::ArrayChunksMut; pub use core::slice::ArrayWindows; #[stable(feature = "inherent_ascii_escape", since = "1.60.0")] pub use core::slice::EscapeAscii; +#[stable(feature = "get_many_mut", since = "1.86.0")] +pub use core::slice::GetDisjointMutError; #[stable(feature = "slice_get_slice", since = "1.28.0")] pub use core::slice::SliceIndex; #[cfg(not(no_global_oom_handling))] @@ -61,16 +60,6 @@ pub use core::slice::{range, try_range}; //////////////////////////////////////////////////////////////////////////////// // Basic slice extension methods //////////////////////////////////////////////////////////////////////////////// - -// HACK(japaric) needed for the implementation of `vec!` macro during testing -// N.B., see the `hack` module in this file for more details. -#[cfg(test)] -pub use hack::into_vec; -// HACK(japaric) needed for the implementation of `Vec::clone` during testing -// N.B., see the `hack` module in this file for more details. -#[cfg(test)] -pub use hack::to_vec; - use crate::alloc::Allocator; #[cfg(not(no_global_oom_handling))] use crate::alloc::Global; @@ -79,97 +68,6 @@ use crate::borrow::ToOwned; use crate::boxed::Box; use crate::vec::Vec; -// HACK(japaric): With cfg(test) `impl [T]` is not available, these three -// functions are actually methods that are in `impl [T]` but not in -// `core::slice::SliceExt` - we need to supply these functions for the -// `test_permutations` test -pub(crate) mod hack { - use core::alloc::Allocator; - - use crate::boxed::Box; - use crate::vec::Vec; - - // We shouldn't add inline attribute to this since this is used in - // `vec!` macro mostly and causes perf regression. See #71204 for - // discussion and perf results. - #[allow(missing_docs)] - pub fn into_vec(b: Box<[T], A>) -> Vec { - unsafe { - let len = b.len(); - let (b, alloc) = Box::into_raw_with_allocator(b); - Vec::from_raw_parts_in(b as *mut T, len, len, alloc) - } - } - - #[cfg(not(no_global_oom_handling))] - #[allow(missing_docs)] - #[inline] - pub fn to_vec(s: &[T], alloc: A) -> Vec { - T::to_vec(s, alloc) - } - - #[cfg(not(no_global_oom_handling))] - pub trait ConvertVec { - fn to_vec(s: &[Self], alloc: A) -> Vec - where - Self: Sized; - } - - #[cfg(not(no_global_oom_handling))] - impl ConvertVec for T { - #[inline] - default fn to_vec(s: &[Self], alloc: A) -> Vec { - struct DropGuard<'a, T, A: Allocator> { - vec: &'a mut Vec, - num_init: usize, - } - impl<'a, T, A: Allocator> Drop for DropGuard<'a, T, A> { - #[inline] - fn drop(&mut self) { - // SAFETY: - // items were marked initialized in the loop below - unsafe { - self.vec.set_len(self.num_init); - } - } - } - let mut vec = Vec::with_capacity_in(s.len(), alloc); - let mut guard = DropGuard { vec: &mut vec, num_init: 0 }; - let slots = guard.vec.spare_capacity_mut(); - // .take(slots.len()) is necessary for LLVM to remove bounds checks - // and has better codegen than zip. - for (i, b) in s.iter().enumerate().take(slots.len()) { - guard.num_init = i; - slots[i].write(b.clone()); - } - core::mem::forget(guard); - // SAFETY: - // the vec was allocated and initialized above to at least this length. - unsafe { - vec.set_len(s.len()); - } - vec - } - } - - #[cfg(not(no_global_oom_handling))] - impl ConvertVec for T { - #[inline] - fn to_vec(s: &[Self], alloc: A) -> Vec { - let mut v = Vec::with_capacity_in(s.len(), alloc); - // SAFETY: - // allocated above with the capacity of `s`, and initialize to `s.len()` in - // ptr::copy_to_non_overlapping below. - unsafe { - s.as_ptr().copy_to_nonoverlapping(v.as_mut_ptr(), s.len()); - v.set_len(s.len()); - } - v - } - } -} - -#[cfg(not(test))] impl [T] { /// Sorts the slice, preserving initial order of equal elements. /// @@ -443,7 +341,7 @@ impl [T] { // Avoids binary-size usage in cases where the alignment doesn't work out to make this // beneficial or on 32-bit platforms. let is_using_u32_as_idx_type_helpful = - const { mem::size_of::<(K, u32)>() < mem::size_of::<(K, usize)>() }; + const { size_of::<(K, u32)>() < size_of::<(K, usize)>() }; // It's possible to instantiate this for u8 and u16 but, doing so is very wasteful in terms // of compile-times and binary-size, the peak saved heap memory for u16 is (u8 + u16) -> 4 @@ -498,8 +396,64 @@ impl [T] { where T: Clone, { - // N.B., see the `hack` module in this file for more details. - hack::to_vec(self, alloc) + return T::to_vec(self, alloc); + + trait ConvertVec { + fn to_vec(s: &[Self], alloc: A) -> Vec + where + Self: Sized; + } + + impl ConvertVec for T { + #[inline] + default fn to_vec(s: &[Self], alloc: A) -> Vec { + struct DropGuard<'a, T, A: Allocator> { + vec: &'a mut Vec, + num_init: usize, + } + impl<'a, T, A: Allocator> Drop for DropGuard<'a, T, A> { + #[inline] + fn drop(&mut self) { + // SAFETY: + // items were marked initialized in the loop below + unsafe { + self.vec.set_len(self.num_init); + } + } + } + let mut vec = Vec::with_capacity_in(s.len(), alloc); + let mut guard = DropGuard { vec: &mut vec, num_init: 0 }; + let slots = guard.vec.spare_capacity_mut(); + // .take(slots.len()) is necessary for LLVM to remove bounds checks + // and has better codegen than zip. + for (i, b) in s.iter().enumerate().take(slots.len()) { + guard.num_init = i; + slots[i].write(b.clone()); + } + core::mem::forget(guard); + // SAFETY: + // the vec was allocated and initialized above to at least this length. + unsafe { + vec.set_len(s.len()); + } + vec + } + } + + impl ConvertVec for T { + #[inline] + fn to_vec(s: &[Self], alloc: A) -> Vec { + let mut v = Vec::with_capacity_in(s.len(), alloc); + // SAFETY: + // allocated above with the capacity of `s`, and initialize to `s.len()` in + // ptr::copy_to_non_overlapping below. + unsafe { + s.as_ptr().copy_to_nonoverlapping(v.as_mut_ptr(), s.len()); + v.set_len(s.len()); + } + v + } + } } /// Converts `self` into a vector without clones or allocation. @@ -519,10 +473,13 @@ impl [T] { #[rustc_allow_incoherent_impl] #[stable(feature = "rust1", since = "1.0.0")] #[inline] - #[cfg_attr(not(test), rustc_diagnostic_item = "slice_into_vec")] + #[rustc_diagnostic_item = "slice_into_vec"] pub fn into_vec(self: Box) -> Vec { - // N.B., see the `hack` module in this file for more details. - hack::into_vec(self) + unsafe { + let len = self.len(); + let (b, alloc) = Box::into_raw_with_allocator(self); + Vec::from_raw_parts_in(b as *mut T, len, len, alloc) + } } /// Creates a vector by copying a slice `n` times. @@ -663,7 +620,6 @@ impl [T] { } } -#[cfg(not(test))] impl [u8] { /// Returns a vector containing a copy of this slice where each byte /// is mapped to its ASCII upper case equivalent. @@ -880,14 +836,9 @@ impl SpecCloneIntoVec for [T] { #[stable(feature = "rust1", since = "1.0.0")] impl ToOwned for [T] { type Owned = Vec; - #[cfg(not(test))] - fn to_owned(&self) -> Vec { - self.to_vec() - } - #[cfg(test)] fn to_owned(&self) -> Vec { - hack::to_vec(self, Global) + self.to_vec() } fn clone_into(&self, target: &mut Vec) { diff --git a/alloc/src/str.rs b/alloc/src/str.rs index 6fee8d3fe3346..0664f2c3cf2c1 100644 --- a/alloc/src/str.rs +++ b/alloc/src/str.rs @@ -219,7 +219,6 @@ impl ToOwned for str { } /// Methods for string slices. -#[cfg(not(test))] impl str { /// Converts a `Box` into a `Box<[u8]>` without copying or allocating. /// @@ -631,7 +630,6 @@ pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box { #[unstable(feature = "str_internals", issue = "none")] #[doc(hidden)] #[inline] -#[cfg(not(test))] #[cfg(not(no_global_oom_handling))] pub fn convert_while_ascii(s: &str, convert: fn(&u8) -> u8) -> (String, &str) { // Process the input in chunks of 16 bytes to enable auto-vectorization. @@ -704,7 +702,6 @@ pub fn convert_while_ascii(s: &str, convert: fn(&u8) -> u8) -> (String, &str) { } } #[inline] -#[cfg(not(test))] #[cfg(not(no_global_oom_handling))] #[allow(dead_code)] /// Faster implementation of string replacement for ASCII to ASCII cases. diff --git a/alloc/src/string.rs b/alloc/src/string.rs index e0576c2551545..9236f5cb8d1f0 100644 --- a/alloc/src/string.rs +++ b/alloc/src/string.rs @@ -62,10 +62,10 @@ use crate::alloc::Allocator; use crate::borrow::{Cow, ToOwned}; use crate::boxed::Box; use crate::collections::TryReserveError; -use crate::str::{self, Chars, Utf8Error, from_utf8_unchecked_mut}; +use crate::str::{self, CharIndices, Chars, Utf8Error, from_utf8_unchecked_mut}; #[cfg(not(no_global_oom_handling))] use crate::str::{FromStr, from_boxed_utf8_unchecked}; -use crate::vec::Vec; +use crate::vec::{self, Vec}; /// A UTF-8–encoded, growable string. /// @@ -119,8 +119,6 @@ use crate::vec::Vec; /// the same `char`s: /// /// ``` -/// use std::mem; -/// /// // `s` is ASCII which represents each `char` as one byte /// let s = "hello"; /// assert_eq!(s.len(), 5); @@ -128,7 +126,7 @@ use crate::vec::Vec; /// // A `char` array with the same contents would be longer because /// // every `char` is four bytes /// let s = ['h', 'e', 'l', 'l', 'o']; -/// let size: usize = s.into_iter().map(|c| mem::size_of_val(&c)).sum(); +/// let size: usize = s.into_iter().map(|c| size_of_val(&c)).sum(); /// assert_eq!(size, 20); /// /// // However, for non-ASCII strings, the difference will be smaller @@ -137,7 +135,7 @@ use crate::vec::Vec; /// assert_eq!(s.len(), 20); /// /// let s = ['💖', '💖', '💖', '💖', '💖']; -/// let size: usize = s.into_iter().map(|c| mem::size_of_val(&c)).sum(); +/// let size: usize = s.into_iter().map(|c| size_of_val(&c)).sum(); /// assert_eq!(size, 20); /// ``` /// @@ -358,7 +356,7 @@ use crate::vec::Vec; /// [`as_str()`]: String::as_str #[derive(PartialEq, PartialOrd, Eq, Ord)] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), lang = "String")] +#[lang = "String"] pub struct String { vec: Vec, } @@ -440,7 +438,7 @@ impl String { /// ``` #[inline] #[rustc_const_stable(feature = "const_string_new", since = "1.39.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "string_new")] + #[rustc_diagnostic_item = "string_new"] #[stable(feature = "rust1", since = "1.0.0")] #[must_use] pub const fn new() -> String { @@ -503,17 +501,6 @@ impl String { Ok(String { vec: Vec::try_with_capacity(capacity)? }) } - // HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is - // required for this method definition, is not available. Since we don't - // require this method for testing purposes, I'll just stub it - // NB see the slice::hack module in slice.rs for more information - #[inline] - #[cfg(test)] - #[allow(missing_docs)] - pub fn from_str(_: &str) -> String { - panic!("not available with cfg(test)"); - } - /// Converts a vector of bytes to a `String`. /// /// A string ([`String`]) is made of bytes ([`u8`]), and a vector of bytes @@ -572,7 +559,7 @@ impl String { /// [`into_bytes`]: String::into_bytes #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "string_from_utf8")] + #[rustc_diagnostic_item = "string_from_utf8"] pub fn from_utf8(vec: Vec) -> Result { match str::from_utf8(&vec) { Ok(..) => Ok(String { vec }), @@ -712,8 +699,8 @@ impl String { } } - /// Decode a UTF-16–encoded vector `v` into a `String`, returning [`Err`] - /// if `v` contains any invalid data. + /// Decode a native endian UTF-16–encoded vector `v` into a `String`, + /// returning [`Err`] if `v` contains any invalid data. /// /// # Examples /// @@ -745,8 +732,8 @@ impl String { Ok(ret) } - /// Decode a UTF-16–encoded slice `v` into a `String`, replacing - /// invalid data with [the replacement character (`U+FFFD`)][U+FFFD]. + /// Decode a native endian UTF-16–encoded slice `v` into a `String`, + /// replacing invalid data with [the replacement character (`U+FFFD`)][U+FFFD]. /// /// Unlike [`from_utf8_lossy`] which returns a [`Cow<'a, str>`], /// `from_utf16_lossy` returns a `String` since the UTF-16 to UTF-8 @@ -777,8 +764,8 @@ impl String { .collect() } - /// Decode a UTF-16LE–encoded vector `v` into a `String`, returning [`Err`] - /// if `v` contains any invalid data. + /// Decode a UTF-16LE–encoded vector `v` into a `String`, + /// returning [`Err`] if `v` contains any invalid data. /// /// # Examples /// @@ -852,8 +839,8 @@ impl String { } } - /// Decode a UTF-16BE–encoded vector `v` into a `String`, returning [`Err`] - /// if `v` contains any invalid data. + /// Decode a UTF-16BE–encoded vector `v` into a `String`, + /// returning [`Err`] if `v` contains any invalid data. /// /// # Examples /// @@ -966,11 +953,8 @@ impl String { /// This is highly unsafe, due to the number of invariants that aren't /// checked: /// - /// * The memory at `buf` needs to have been previously allocated by the - /// same allocator the standard library uses, with a required alignment of exactly 1. - /// * `length` needs to be less than or equal to `capacity`. - /// * `capacity` needs to be the correct value. - /// * The first `length` bytes at `buf` need to be valid UTF-8. + /// * all safety requirements for [`Vec::::from_raw_parts`]. + /// * all safety requirements for [`String::from_utf8_unchecked`]. /// /// Violating these may cause problems like corrupting the allocator's /// internal data structures. For example, it is normally **not** safe to @@ -1059,7 +1043,8 @@ impl String { #[inline] #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] + #[rustc_allow_const_fn_unstable(const_precise_live_drops)] pub const fn into_bytes(self) -> Vec { self.vec } @@ -1076,8 +1061,8 @@ impl String { #[inline] #[must_use] #[stable(feature = "string_as_str", since = "1.7.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "string_as_str")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_diagnostic_item = "string_as_str"] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] pub const fn as_str(&self) -> &str { // SAFETY: String contents are stipulated to be valid UTF-8, invalid contents are an error // at construction. @@ -1099,8 +1084,8 @@ impl String { #[inline] #[must_use] #[stable(feature = "string_as_str", since = "1.7.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "string_as_mut_str")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_diagnostic_item = "string_as_mut_str"] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] pub const fn as_mut_str(&mut self) -> &mut str { // SAFETY: String contents are stipulated to be valid UTF-8, invalid contents are an error // at construction. @@ -1122,7 +1107,7 @@ impl String { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_confusables("append", "push")] - #[cfg_attr(not(test), rustc_diagnostic_item = "string_push_str")] + #[rustc_diagnostic_item = "string_push_str"] pub fn push_str(&mut self, string: &str) { self.vec.extend_from_slice(string.as_bytes()) } @@ -1137,7 +1122,6 @@ impl String { /// # Examples /// /// ``` - /// #![feature(string_extend_from_within)] /// let mut string = String::from("abcde"); /// /// string.extend_from_within(2..); @@ -1150,7 +1134,7 @@ impl String { /// assert_eq!(string, "abcdecdeabecde"); /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "string_extend_from_within", issue = "103806")] + #[stable(feature = "string_extend_from_within", since = "CURRENT_RUSTC_VERSION")] pub fn extend_from_within(&mut self, src: R) where R: RangeBounds, @@ -1175,7 +1159,7 @@ impl String { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] pub const fn capacity(&self) -> usize { self.vec.capacity() } @@ -1419,7 +1403,9 @@ impl String { pub fn push(&mut self, ch: char) { match ch.len_utf8() { 1 => self.vec.push(ch as u8), - _ => self.vec.extend_from_slice(ch.encode_utf8(&mut [0; 4]).as_bytes()), + _ => { + self.vec.extend_from_slice(ch.encode_utf8(&mut [0; char::MAX_LEN_UTF8]).as_bytes()) + } } } @@ -1439,7 +1425,7 @@ impl String { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] pub const fn as_bytes(&self) -> &[u8] { self.vec.as_slice() } @@ -1716,7 +1702,7 @@ impl String { #[rustc_confusables("set")] pub fn insert(&mut self, idx: usize, ch: char) { assert!(self.is_char_boundary(idx)); - let mut bits = [0; 4]; + let mut bits = [0; char::MAX_LEN_UTF8]; let bits = ch.encode_utf8(&mut bits).as_bytes(); unsafe { @@ -1759,7 +1745,7 @@ impl String { #[cfg(not(no_global_oom_handling))] #[inline] #[stable(feature = "insert_str", since = "1.16.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "string_insert_str")] + #[rustc_diagnostic_item = "string_insert_str"] pub fn insert_str(&mut self, idx: usize, string: &str) { assert!(self.is_char_boundary(idx)); @@ -1793,7 +1779,7 @@ impl String { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] pub const unsafe fn as_mut_vec(&mut self) -> &mut Vec { &mut self.vec } @@ -1815,7 +1801,7 @@ impl String { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] #[rustc_confusables("length", "size")] pub const fn len(&self) -> usize { self.vec.len() @@ -1835,7 +1821,7 @@ impl String { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] pub const fn is_empty(&self) -> bool { self.len() == 0 } @@ -1952,6 +1938,61 @@ impl String { Drain { start, end, iter: chars_iter, string: self_ptr } } + /// Converts a `String` into an iterator over the [`char`]s of the string. + /// + /// As a string consists of valid UTF-8, we can iterate through a string + /// by [`char`]. This method returns such an iterator. + /// + /// It's important to remember that [`char`] represents a Unicode Scalar + /// Value, and might not match your idea of what a 'character' is. Iteration + /// over grapheme clusters may be what you actually want. That functionality + /// is not provided by Rust's standard library, check crates.io instead. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(string_into_chars)] + /// + /// let word = String::from("goodbye"); + /// + /// let mut chars = word.into_chars(); + /// + /// assert_eq!(Some('g'), chars.next()); + /// assert_eq!(Some('o'), chars.next()); + /// assert_eq!(Some('o'), chars.next()); + /// assert_eq!(Some('d'), chars.next()); + /// assert_eq!(Some('b'), chars.next()); + /// assert_eq!(Some('y'), chars.next()); + /// assert_eq!(Some('e'), chars.next()); + /// + /// assert_eq!(None, chars.next()); + /// ``` + /// + /// Remember, [`char`]s might not match your intuition about characters: + /// + /// ``` + /// #![feature(string_into_chars)] + /// + /// let y = String::from("y̆"); + /// + /// let mut chars = y.into_chars(); + /// + /// assert_eq!(Some('y'), chars.next()); // not 'y̆' + /// assert_eq!(Some('\u{0306}'), chars.next()); + /// + /// assert_eq!(None, chars.next()); + /// ``` + /// + /// [`char`]: prim@char + #[inline] + #[must_use = "`self` will be dropped if the result is not used"] + #[unstable(feature = "string_into_chars", issue = "133125")] + pub fn into_chars(self) -> IntoChars { + IntoChars { bytes: self.into_bytes().into_iter() } + } + /// Removes the specified range in the string, /// and replaces it with the given string. /// The given string doesn't need to be the same length as the range. @@ -2387,6 +2428,32 @@ impl<'a> Extend> for String { } } +#[cfg(not(no_global_oom_handling))] +#[unstable(feature = "ascii_char", issue = "110998")] +impl Extend for String { + fn extend>(&mut self, iter: I) { + self.vec.extend(iter.into_iter().map(|c| c.to_u8())); + } + + #[inline] + fn extend_one(&mut self, c: core::ascii::Char) { + self.vec.push(c.to_u8()); + } +} + +#[cfg(not(no_global_oom_handling))] +#[unstable(feature = "ascii_char", issue = "110998")] +impl<'a> Extend<&'a core::ascii::Char> for String { + fn extend>(&mut self, iter: I) { + self.extend(iter.into_iter().cloned()); + } + + #[inline] + fn extend_one(&mut self, c: &'a core::ascii::Char) { + self.vec.push(c.to_u8()); + } +} + /// A convenience impl that delegates to the impl for `&str`. /// /// # Examples @@ -2647,7 +2714,7 @@ impl FromStr for String { /// implementation for free. /// /// [`Display`]: fmt::Display -#[cfg_attr(not(test), rustc_diagnostic_item = "ToString")] +#[rustc_diagnostic_item = "ToString"] #[stable(feature = "rust1", since = "1.0.0")] pub trait ToString { /// Converts the given value to a `String`. @@ -2662,7 +2729,7 @@ pub trait ToString { /// ``` #[rustc_conversion_suggestion] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "to_string_method")] + #[rustc_diagnostic_item = "to_string_method"] fn to_string(&self) -> String; } @@ -2675,14 +2742,28 @@ pub trait ToString { #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] impl ToString for T { + #[inline] + fn to_string(&self) -> String { + ::spec_to_string(self) + } +} + +#[cfg(not(no_global_oom_handling))] +trait SpecToString { + fn spec_to_string(&self) -> String; +} + +#[cfg(not(no_global_oom_handling))] +impl SpecToString for T { // A common guideline is to not inline generic functions. However, // removing `#[inline]` from this method causes non-negligible regressions. // See , the last attempt // to try to remove it. #[inline] - default fn to_string(&self) -> String { + default fn spec_to_string(&self) -> String { let mut buf = String::new(); - let mut formatter = core::fmt::Formatter::new(&mut buf); + let mut formatter = + core::fmt::Formatter::new(&mut buf, core::fmt::FormattingOptions::new()); // Bypass format_args!() to avoid write_str with zero-length strs fmt::Display::fmt(self, &mut formatter) .expect("a Display implementation returned an error unexpectedly"); @@ -2690,42 +2771,34 @@ impl ToString for T { } } -#[doc(hidden)] #[cfg(not(no_global_oom_handling))] -#[unstable(feature = "ascii_char", issue = "110998")] -impl ToString for core::ascii::Char { +impl SpecToString for core::ascii::Char { #[inline] - fn to_string(&self) -> String { + fn spec_to_string(&self) -> String { self.as_str().to_owned() } } -#[doc(hidden)] #[cfg(not(no_global_oom_handling))] -#[stable(feature = "char_to_string_specialization", since = "1.46.0")] -impl ToString for char { +impl SpecToString for char { #[inline] - fn to_string(&self) -> String { - String::from(self.encode_utf8(&mut [0; 4])) + fn spec_to_string(&self) -> String { + String::from(self.encode_utf8(&mut [0; char::MAX_LEN_UTF8])) } } -#[doc(hidden)] #[cfg(not(no_global_oom_handling))] -#[stable(feature = "bool_to_string_specialization", since = "1.68.0")] -impl ToString for bool { +impl SpecToString for bool { #[inline] - fn to_string(&self) -> String { + fn spec_to_string(&self) -> String { String::from(if *self { "true" } else { "false" }) } } -#[doc(hidden)] #[cfg(not(no_global_oom_handling))] -#[stable(feature = "u8_to_string_specialization", since = "1.54.0")] -impl ToString for u8 { +impl SpecToString for u8 { #[inline] - fn to_string(&self) -> String { + fn spec_to_string(&self) -> String { let mut buf = String::with_capacity(3); let mut n = *self; if n >= 10 { @@ -2741,12 +2814,10 @@ impl ToString for u8 { } } -#[doc(hidden)] #[cfg(not(no_global_oom_handling))] -#[stable(feature = "i8_to_string_specialization", since = "1.54.0")] -impl ToString for i8 { +impl SpecToString for i8 { #[inline] - fn to_string(&self) -> String { + fn spec_to_string(&self) -> String { let mut buf = String::with_capacity(4); if self.is_negative() { buf.push('-'); @@ -2787,11 +2858,9 @@ macro_rules! to_string_expr_wrap_in_deref { macro_rules! to_string_str { {$($($x:ident)*),+} => { $( - #[doc(hidden)] - #[stable(feature = "str_to_string_specialization", since = "1.9.0")] - impl ToString for to_string_str_wrap_in_ref!($($x)*) { + impl SpecToString for to_string_str_wrap_in_ref!($($x)*) { #[inline] - fn to_string(&self) -> String { + fn spec_to_string(&self) -> String { String::from(to_string_expr_wrap_in_deref!(self ; $($x)*)) } } @@ -2815,32 +2884,26 @@ to_string_str! { x, } -#[doc(hidden)] #[cfg(not(no_global_oom_handling))] -#[stable(feature = "cow_str_to_string_specialization", since = "1.17.0")] -impl ToString for Cow<'_, str> { +impl SpecToString for Cow<'_, str> { #[inline] - fn to_string(&self) -> String { + fn spec_to_string(&self) -> String { self[..].to_owned() } } -#[doc(hidden)] #[cfg(not(no_global_oom_handling))] -#[stable(feature = "string_to_string_specialization", since = "1.17.0")] -impl ToString for String { +impl SpecToString for String { #[inline] - fn to_string(&self) -> String { + fn spec_to_string(&self) -> String { self.to_owned() } } -#[doc(hidden)] #[cfg(not(no_global_oom_handling))] -#[stable(feature = "fmt_arguments_to_string_specialization", since = "1.71.0")] -impl ToString for fmt::Arguments<'_> { +impl SpecToString for fmt::Arguments<'_> { #[inline] - fn to_string(&self) -> String { + fn spec_to_string(&self) -> String { crate::fmt::format(*self) } } @@ -2906,7 +2969,6 @@ impl From<&String> for String { } // note: test pulls in std, which causes errors here -#[cfg(not(test))] #[stable(feature = "string_from_box", since = "1.18.0")] impl From> for String { /// Converts the given boxed `str` slice to a [`String`]. @@ -3078,6 +3140,24 @@ impl From for Vec { } } +#[stable(feature = "try_from_vec_u8_for_string", since = "CURRENT_RUSTC_VERSION")] +impl TryFrom> for String { + type Error = FromUtf8Error; + /// Converts the given [`Vec`] into a [`String`] if it contains valid UTF-8 data. + /// + /// # Examples + /// + /// ``` + /// let s1 = b"hello world".to_vec(); + /// let v1 = String::try_from(s1).unwrap(); + /// assert_eq!(v1, "hello world"); + /// + /// ``` + fn try_from(bytes: Vec) -> Result { + Self::from_utf8(bytes) + } +} + #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Write for String { @@ -3094,6 +3174,134 @@ impl fmt::Write for String { } } +/// An iterator over the [`char`]s of a string. +/// +/// This struct is created by the [`into_chars`] method on [`String`]. +/// See its documentation for more. +/// +/// [`char`]: prim@char +/// [`into_chars`]: String::into_chars +#[cfg_attr(not(no_global_oom_handling), derive(Clone))] +#[must_use = "iterators are lazy and do nothing unless consumed"] +#[unstable(feature = "string_into_chars", issue = "133125")] +pub struct IntoChars { + bytes: vec::IntoIter, +} + +#[unstable(feature = "string_into_chars", issue = "133125")] +impl fmt::Debug for IntoChars { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("IntoChars").field(&self.as_str()).finish() + } +} + +impl IntoChars { + /// Views the underlying data as a subslice of the original data. + /// + /// # Examples + /// + /// ``` + /// #![feature(string_into_chars)] + /// + /// let mut chars = String::from("abc").into_chars(); + /// + /// assert_eq!(chars.as_str(), "abc"); + /// chars.next(); + /// assert_eq!(chars.as_str(), "bc"); + /// chars.next(); + /// chars.next(); + /// assert_eq!(chars.as_str(), ""); + /// ``` + #[unstable(feature = "string_into_chars", issue = "133125")] + #[must_use] + #[inline] + pub fn as_str(&self) -> &str { + // SAFETY: `bytes` is a valid UTF-8 string. + unsafe { str::from_utf8_unchecked(self.bytes.as_slice()) } + } + + /// Consumes the `IntoChars`, returning the remaining string. + /// + /// # Examples + /// + /// ``` + /// #![feature(string_into_chars)] + /// + /// let chars = String::from("abc").into_chars(); + /// assert_eq!(chars.into_string(), "abc"); + /// + /// let mut chars = String::from("def").into_chars(); + /// chars.next(); + /// assert_eq!(chars.into_string(), "ef"); + /// ``` + #[cfg(not(no_global_oom_handling))] + #[unstable(feature = "string_into_chars", issue = "133125")] + #[inline] + pub fn into_string(self) -> String { + // Safety: `bytes` are kept in UTF-8 form, only removing whole `char`s at a time. + unsafe { String::from_utf8_unchecked(self.bytes.collect()) } + } + + #[inline] + fn iter(&self) -> CharIndices<'_> { + self.as_str().char_indices() + } +} + +#[unstable(feature = "string_into_chars", issue = "133125")] +impl Iterator for IntoChars { + type Item = char; + + #[inline] + fn next(&mut self) -> Option { + let mut iter = self.iter(); + match iter.next() { + None => None, + Some((_, ch)) => { + let offset = iter.offset(); + // `offset` is a valid index. + let _ = self.bytes.advance_by(offset); + Some(ch) + } + } + } + + #[inline] + fn count(self) -> usize { + self.iter().count() + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + self.iter().size_hint() + } + + #[inline] + fn last(mut self) -> Option { + self.next_back() + } +} + +#[unstable(feature = "string_into_chars", issue = "133125")] +impl DoubleEndedIterator for IntoChars { + #[inline] + fn next_back(&mut self) -> Option { + let len = self.as_str().len(); + let mut iter = self.iter(); + match iter.next_back() { + None => None, + Some((idx, ch)) => { + // `idx` is a valid index. + let _ = self.bytes.advance_back_by(len - idx); + Some(ch) + } + } + } +} + +#[unstable(feature = "string_into_chars", issue = "133125")] +impl FusedIterator for IntoChars {} + /// A draining iterator for `String`. /// /// This struct is created by the [`drain`] method on [`String`]. See its diff --git a/alloc/src/sync.rs b/alloc/src/sync.rs index da2d6bb3bce24..4999319f618e4 100644 --- a/alloc/src/sync.rs +++ b/alloc/src/sync.rs @@ -11,6 +11,7 @@ use core::any::Any; #[cfg(not(no_global_oom_handling))] use core::clone::CloneToUninit; +use core::clone::UseCloned; use core::cmp::Ordering; use core::hash::{Hash, Hasher}; use core::intrinsics::abort; @@ -18,6 +19,7 @@ use core::intrinsics::abort; use core::iter; use core::marker::{PhantomData, Unsize}; use core::mem::{self, ManuallyDrop, align_of_val_raw}; +use core::num::NonZeroUsize; use core::ops::{CoerceUnsized, Deref, DerefPure, DispatchFromDyn, LegacyReceiver}; use core::panic::{RefUnwindSafe, UnwindSafe}; use core::pin::{Pin, PinCoerceUnsized}; @@ -39,9 +41,6 @@ use crate::string::String; #[cfg(not(no_global_oom_handling))] use crate::vec::Vec; -#[cfg(test)] -mod tests; - /// A soft limit on the amount of references that may be made to an `Arc`. /// /// Going above this limit will abort your program (although not @@ -235,8 +234,8 @@ macro_rules! acquire { /// counting in general. /// /// [rc_examples]: crate::rc#examples -#[cfg_attr(not(bootstrap), doc(search_unbox))] -#[cfg_attr(not(test), rustc_diagnostic_item = "Arc")] +#[doc(search_unbox)] +#[rustc_diagnostic_item = "Arc"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_insignificant_dtor] pub struct Arc< @@ -313,7 +312,7 @@ impl Arc { /// /// [`upgrade`]: Weak::upgrade #[stable(feature = "arc_weak", since = "1.4.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "ArcWeak")] +#[rustc_diagnostic_item = "ArcWeak"] pub struct Weak< T: ?Sized, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, @@ -787,7 +786,7 @@ impl Arc { let uninit_ptr: NonNull<_> = (unsafe { &mut *uninit_raw_ptr }).into(); let init_ptr: NonNull> = uninit_ptr.cast(); - let weak = Weak { ptr: init_ptr, alloc: alloc }; + let weak = Weak { ptr: init_ptr, alloc }; // It's important we don't give up ownership of the weak pointer, or // else the memory might be freed by the time `data_fn` returns. If @@ -1206,6 +1205,26 @@ impl Arc<[T]> { )) } } + + /// Converts the reference-counted slice into a reference-counted array. + /// + /// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type. + /// + /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. + #[unstable(feature = "slice_as_array", issue = "133508")] + #[inline] + #[must_use] + pub fn into_array(self) -> Option> { + if self.len() == N { + let ptr = Self::into_raw(self) as *const [T; N]; + + // SAFETY: The underlying array of a slice has the exact same layout as an actual array `[T; N]` if `N` is equal to the slice's length. + let me = unsafe { Arc::from_raw(ptr) }; + Some(me) + } else { + None + } + } } impl Arc<[T], A> { @@ -1379,6 +1398,8 @@ impl Arc { /// different types. See [`mem::transmute`][transmute] for more information /// on what restrictions apply in this case. /// + /// The raw pointer must point to a block of memory allocated by the global allocator. + /// /// The user of `from_raw` has to make sure a specific value of `T` is only /// dropped once. /// @@ -1434,7 +1455,8 @@ impl Arc { /// /// The pointer must have been obtained through `Arc::into_raw`, and the /// associated `Arc` instance must be valid (i.e. the strong count must be at - /// least 1) for the duration of this method. + /// least 1) for the duration of this method, and `ptr` must point to a block of memory + /// allocated by the global allocator. /// /// # Examples /// @@ -1468,7 +1490,8 @@ impl Arc { /// /// The pointer must have been obtained through `Arc::into_raw`, and the /// associated `Arc` instance must be valid (i.e. the strong count must be at - /// least 1) when invoking this method. This method can be used to release the final + /// least 1) when invoking this method, and `ptr` must point to a block of memory + /// allocated by the global allocator. This method can be used to release the final /// `Arc` and backing storage, but **should not** be called after the final `Arc` has been /// released. /// @@ -2175,6 +2198,9 @@ impl Clone for Arc { } } +#[unstable(feature = "ergonomic_clones", issue = "132290")] +impl UseCloned for Arc {} + #[stable(feature = "rust1", since = "1.0.0")] impl Deref for Arc { type Target = T; @@ -2252,7 +2278,7 @@ impl Arc { #[inline] #[stable(feature = "arc_unique", since = "1.4.0")] pub fn make_mut(this: &mut Self) -> &mut T { - let size_of_val = mem::size_of_val::(&**this); + let size_of_val = size_of_val::(&**this); // Note that we hold both a strong reference and a weak reference. // Thus, releasing our strong reference only will not, by itself, cause @@ -2451,7 +2477,7 @@ impl Arc { /// let x: Arc<&str> = Arc::new("Hello, world!"); /// { /// let s = String::from("Oh, no!"); - /// let mut y: Arc<&str> = x.clone().into(); + /// let mut y: Arc<&str> = x.clone(); /// unsafe { /// // this is Undefined Behavior, because x's inner type /// // is &'long str, not &'short str @@ -2670,12 +2696,7 @@ impl Weak { #[rustc_const_stable(feature = "const_weak_new", since = "1.73.0")] #[must_use] pub const fn new() -> Weak { - Weak { - ptr: unsafe { - NonNull::new_unchecked(ptr::without_provenance_mut::>(usize::MAX)) - }, - alloc: Global, - } + Weak { ptr: NonNull::without_provenance(NonZeroUsize::MAX), alloc: Global } } } @@ -2700,12 +2721,7 @@ impl Weak { #[inline] #[unstable(feature = "allocator_api", issue = "32838")] pub fn new_in(alloc: A) -> Weak { - Weak { - ptr: unsafe { - NonNull::new_unchecked(ptr::without_provenance_mut::>(usize::MAX)) - }, - alloc, - } + Weak { ptr: NonNull::without_provenance(NonZeroUsize::MAX), alloc } } } @@ -2728,7 +2744,7 @@ impl Weak { /// # Safety /// /// The pointer must have originated from the [`into_raw`] and must still own its potential - /// weak reference. + /// weak reference, and must point to a block of memory allocated by global allocator. /// /// It is allowed for the strong count to be 0 at the time of calling this. Nevertheless, this /// takes ownership of one weak reference currently represented as a raw pointer (the weak @@ -3146,6 +3162,9 @@ impl Clone for Weak { } } +#[unstable(feature = "ergonomic_clones", issue = "132290")] +impl UseCloned for Weak {} + #[stable(feature = "downgraded_weak", since = "1.10.0")] impl Default for Weak { /// Constructs a new `Weak`, without allocating memory. @@ -3454,11 +3473,14 @@ impl Default for Arc { fn default() -> Arc { unsafe { Self::from_inner( - Box::leak(Box::write(Box::new_uninit(), ArcInner { - strong: atomic::AtomicUsize::new(1), - weak: atomic::AtomicUsize::new(1), - data: T::default(), - })) + Box::leak(Box::write( + Box::new_uninit(), + ArcInner { + strong: atomic::AtomicUsize::new(1), + weak: atomic::AtomicUsize::new(1), + data: T::default(), + }, + )) .into(), ) } @@ -3529,7 +3551,7 @@ impl Default for Arc<[T]> { /// This may or may not share an allocation with other Arcs. #[inline] fn default() -> Self { - if mem::align_of::() <= MAX_STATIC_INNER_SLICE_ALIGNMENT { + if align_of::() <= MAX_STATIC_INNER_SLICE_ALIGNMENT { // We take a reference to the whole struct instead of the ArcInner<[u8; 1]> inside it so // we don't shrink the range of bytes the ptr is allowed to access under Stacked Borrows. // (Miri complains on 32-bit targets with Arc<[Align16]> otherwise.) @@ -3618,7 +3640,7 @@ impl From<&[T]> for Arc<[T]> { } #[cfg(not(no_global_oom_handling))] -#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "shared_from_mut_slice", since = "1.84.0")] impl From<&mut [T]> for Arc<[T]> { /// Allocates a reference-counted slice and fills it by cloning `v`'s items. /// @@ -3657,7 +3679,7 @@ impl From<&str> for Arc { } #[cfg(not(no_global_oom_handling))] -#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "shared_from_mut_slice", since = "1.84.0")] impl From<&mut str> for Arc { /// Allocates a reference-counted `str` and copies `v` into it. /// diff --git a/alloc/src/task.rs b/alloc/src/task.rs index 0f8e74300a491..b4116f4988b64 100644 --- a/alloc/src/task.rs +++ b/alloc/src/task.rs @@ -199,7 +199,6 @@ fn raw_waker(waker: Arc) -> RawWaker { /// /// ```rust /// #![feature(local_waker)] -/// #![feature(noop_waker)] /// use std::task::{LocalWake, ContextBuilder, LocalWaker, Waker}; /// use std::future::Future; /// use std::pin::Pin; diff --git a/alloc/src/testing/mod.rs b/alloc/src/testing/mod.rs deleted file mode 100644 index 7a094f8a59522..0000000000000 --- a/alloc/src/testing/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod crash_test; -pub mod ord_chaos; -pub mod rng; diff --git a/alloc/src/vec/drain.rs b/alloc/src/vec/drain.rs index 9362cef2a1b00..8705a9c3d2679 100644 --- a/alloc/src/vec/drain.rs +++ b/alloc/src/vec/drain.rs @@ -232,7 +232,7 @@ impl Drop for Drain<'_, T, A> { // it from the original vec but also avoid creating a &mut to the front since that could // invalidate raw pointers to it which some unsafe code might rely on. let vec_ptr = vec.as_mut().as_mut_ptr(); - let drop_offset = drop_ptr.sub_ptr(vec_ptr); + let drop_offset = drop_ptr.offset_from_unsigned(vec_ptr); let to_drop = ptr::slice_from_raw_parts_mut(vec_ptr.add(drop_offset), drop_len); ptr::drop_in_place(to_drop); } diff --git a/alloc/src/vec/extract_if.rs b/alloc/src/vec/extract_if.rs index 72d51e8904488..be869553ef4e1 100644 --- a/alloc/src/vec/extract_if.rs +++ b/alloc/src/vec/extract_if.rs @@ -1,3 +1,4 @@ +use core::ops::{Range, RangeBounds}; use core::{ptr, slice}; use super::Vec; @@ -11,12 +12,10 @@ use crate::alloc::{Allocator, Global}; /// # Example /// /// ``` -/// #![feature(extract_if)] -/// /// let mut v = vec![0, 1, 2]; -/// let iter: std::vec::ExtractIf<'_, _, _> = v.extract_if(|x| *x % 2 == 0); +/// let iter: std::vec::ExtractIf<'_, _, _> = v.extract_if(.., |x| *x % 2 == 0); /// ``` -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] #[derive(Debug)] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct ExtractIf< @@ -24,24 +23,32 @@ pub struct ExtractIf< T, F, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, -> where - F: FnMut(&mut T) -> bool, -{ - pub(super) vec: &'a mut Vec, +> { + vec: &'a mut Vec, /// The index of the item that will be inspected by the next call to `next`. - pub(super) idx: usize, + idx: usize, + /// Elements at and beyond this point will be retained. Must be equal or smaller than `old_len`. + end: usize, /// The number of items that have been drained (removed) thus far. - pub(super) del: usize, + del: usize, /// The original length of `vec` prior to draining. - pub(super) old_len: usize, + old_len: usize, /// The filter test predicate. - pub(super) pred: F, + pred: F, } -impl ExtractIf<'_, T, F, A> -where - F: FnMut(&mut T) -> bool, -{ +impl<'a, T, F, A: Allocator> ExtractIf<'a, T, F, A> { + pub(super) fn new>(vec: &'a mut Vec, pred: F, range: R) -> Self { + let old_len = vec.len(); + let Range { start, end } = slice::range(range, ..old_len); + + // Guard against the vec getting leaked (leak amplification) + unsafe { + vec.set_len(0); + } + ExtractIf { vec, idx: start, del: 0, end, old_len, pred } + } + /// Returns a reference to the underlying allocator. #[unstable(feature = "allocator_api", issue = "32838")] #[inline] @@ -50,7 +57,7 @@ where } } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, @@ -59,7 +66,7 @@ where fn next(&mut self) -> Option { unsafe { - while self.idx < self.old_len { + while self.idx < self.end { let i = self.idx; let v = slice::from_raw_parts_mut(self.vec.as_mut_ptr(), self.old_len); let drained = (self.pred)(&mut v[i]); @@ -82,24 +89,15 @@ where } fn size_hint(&self) -> (usize, Option) { - (0, Some(self.old_len - self.idx)) + (0, Some(self.end - self.idx)) } } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] -impl Drop for ExtractIf<'_, T, F, A> -where - F: FnMut(&mut T) -> bool, -{ +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] +impl Drop for ExtractIf<'_, T, F, A> { fn drop(&mut self) { unsafe { if self.idx < self.old_len && self.del > 0 { - // This is a pretty messed up state, and there isn't really an - // obviously right thing to do. We don't want to keep trying - // to execute `pred`, so we just backshift all the unprocessed - // elements and tell the vec that they still exist. The backshift - // is required to prevent a double-drop of the last successfully - // drained item prior to a panic in the predicate. let ptr = self.vec.as_mut_ptr(); let src = ptr.add(self.idx); let dst = src.sub(self.del); diff --git a/alloc/src/vec/in_place_collect.rs b/alloc/src/vec/in_place_collect.rs index a7dba16944e7d..b98a118048f2d 100644 --- a/alloc/src/vec/in_place_collect.rs +++ b/alloc/src/vec/in_place_collect.rs @@ -171,7 +171,7 @@ const fn in_place_collectible( ) -> bool { // Require matching alignments because an alignment-changing realloc is inefficient on many // system allocators and better implementations would require the unstable Allocator trait. - if const { SRC::IS_ZST || DEST::IS_ZST || mem::align_of::() != mem::align_of::() } { + if const { SRC::IS_ZST || DEST::IS_ZST || align_of::() != align_of::() } { return false; } @@ -181,7 +181,7 @@ const fn in_place_collectible( // e.g. // - 1 x [u8; 4] -> 4x u8, via flatten // - 4 x u8 -> 1x [u8; 4], via array_chunks - mem::size_of::() * step_merge.get() >= mem::size_of::() * step_expand.get() + size_of::() * step_merge.get() >= size_of::() * step_expand.get() } // Fall back to other from_iter impls if an overflow occurred in the step merge/expansion // tracking. @@ -190,7 +190,7 @@ const fn in_place_collectible( } const fn needs_realloc(src_cap: usize, dst_cap: usize) -> bool { - if const { mem::align_of::() != mem::align_of::() } { + if const { align_of::() != align_of::() } { // FIXME(const-hack): use unreachable! once that works in const panic!("in_place_collectible() prevents this"); } @@ -199,8 +199,8 @@ const fn needs_realloc(src_cap: usize, dst_cap: usize) -> bool { // the caller will have calculated a `dst_cap` that is an integer multiple of // `src_cap` without remainder. if const { - let src_sz = mem::size_of::(); - let dest_sz = mem::size_of::(); + let src_sz = size_of::(); + let dest_sz = size_of::(); dest_sz != 0 && src_sz % dest_sz == 0 } { return false; @@ -208,7 +208,7 @@ const fn needs_realloc(src_cap: usize, dst_cap: usize) -> bool { // type layouts don't guarantee a fit, so do a runtime check to see if // the allocations happen to match - src_cap > 0 && src_cap * mem::size_of::() != dst_cap * mem::size_of::() + src_cap > 0 && src_cap * size_of::() != dst_cap * size_of::() } /// This provides a shorthand for the source type since local type aliases aren't a thing. @@ -262,7 +262,7 @@ where inner.buf.cast::(), inner.end as *const T, // SAFETY: the multiplication can not overflow, since `inner.cap * size_of::()` is the size of the allocation. - inner.cap.unchecked_mul(mem::size_of::()) / mem::size_of::(), + inner.cap.unchecked_mul(size_of::()) / size_of::(), ) }; @@ -310,14 +310,14 @@ where debug_assert_ne!(dst_cap, 0); unsafe { // The old allocation exists, therefore it must have a valid layout. - let src_align = mem::align_of::(); - let src_size = mem::size_of::().unchecked_mul(src_cap); + let src_align = align_of::(); + let src_size = size_of::().unchecked_mul(src_cap); let old_layout = Layout::from_size_align_unchecked(src_size, src_align); // The allocation must be equal or smaller for in-place iteration to be possible // therefore the new layout must be ≤ the old one and therefore valid. - let dst_align = mem::align_of::(); - let dst_size = mem::size_of::().unchecked_mul(dst_cap); + let dst_align = align_of::(); + let dst_size = size_of::().unchecked_mul(dst_cap); let new_layout = Layout::from_size_align_unchecked(dst_size, dst_align); let result = alloc.shrink(dst_buf.cast(), old_layout, new_layout); @@ -325,7 +325,7 @@ where dst_buf = reallocated.cast::(); } } else { - debug_assert_eq!(src_cap * mem::size_of::(), dst_cap * mem::size_of::()); + debug_assert_eq!(src_cap * size_of::(), dst_cap * size_of::()); } mem::forget(dst_guard); @@ -379,7 +379,7 @@ where let sink = self.try_fold::<_, _, Result<_, !>>(sink, write_in_place_with_drop(end)).into_ok(); // iteration succeeded, don't drop head - unsafe { ManuallyDrop::new(sink).dst.sub_ptr(dst_buf) } + unsafe { ManuallyDrop::new(sink).dst.offset_from_unsigned(dst_buf) } } } diff --git a/alloc/src/vec/in_place_drop.rs b/alloc/src/vec/in_place_drop.rs index 4d5b4e47d39e4..997c4c7525b5a 100644 --- a/alloc/src/vec/in_place_drop.rs +++ b/alloc/src/vec/in_place_drop.rs @@ -14,7 +14,7 @@ pub(super) struct InPlaceDrop { impl InPlaceDrop { fn len(&self) -> usize { - unsafe { self.dst.sub_ptr(self.inner) } + unsafe { self.dst.offset_from_unsigned(self.inner) } } } diff --git a/alloc/src/vec/into_iter.rs b/alloc/src/vec/into_iter.rs index 9a6745fdbc0a3..3eee988b6c9d1 100644 --- a/alloc/src/vec/into_iter.rs +++ b/alloc/src/vec/into_iter.rs @@ -179,7 +179,7 @@ impl IntoIter { // say that they're all at the beginning of the "allocation". 0..this.len() } else { - this.ptr.sub_ptr(this.buf)..this.end.sub_ptr(buf) + this.ptr.offset_from_unsigned(this.buf)..this.end.offset_from_unsigned(buf) }; let cap = this.cap; let alloc = ManuallyDrop::take(&mut this.alloc); @@ -230,7 +230,7 @@ impl Iterator for IntoIter { let exact = if T::IS_ZST { self.end.addr().wrapping_sub(self.ptr.as_ptr().addr()) } else { - unsafe { non_null!(self.end, T).sub_ptr(self.ptr) } + unsafe { non_null!(self.end, T).offset_from_unsigned(self.ptr) } }; (exact, Some(exact)) } @@ -472,14 +472,9 @@ where #[cfg(not(no_global_oom_handling))] #[stable(feature = "vec_into_iter_clone", since = "1.8.0")] impl Clone for IntoIter { - #[cfg(not(test))] fn clone(&self) -> Self { self.as_slice().to_vec_in(self.alloc.deref().clone()).into_iter() } - #[cfg(test)] - fn clone(&self) -> Self { - crate::slice::to_vec(self.as_slice(), self.alloc.deref().clone()).into_iter() - } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/alloc/src/vec/is_zero.rs b/alloc/src/vec/is_zero.rs index ba57d940d8c99..a3ddd6f6e230e 100644 --- a/alloc/src/vec/is_zero.rs +++ b/alloc/src/vec/is_zero.rs @@ -40,19 +40,8 @@ impl_is_zero!(char, |x| x == '\0'); impl_is_zero!(f32, |x: f32| x.to_bits() == 0); impl_is_zero!(f64, |x: f64| x.to_bits() == 0); -unsafe impl IsZero for *const T { - #[inline] - fn is_zero(&self) -> bool { - (*self).is_null() - } -} - -unsafe impl IsZero for *mut T { - #[inline] - fn is_zero(&self) -> bool { - (*self).is_null() - } -} +// `IsZero` cannot be soundly implemented for pointers because of provenance +// (see #135338). unsafe impl IsZero for [T; N] { #[inline] diff --git a/alloc/src/vec/mod.rs b/alloc/src/vec/mod.rs index 990b7e8f76127..da9a77154f9b5 100644 --- a/alloc/src/vec/mod.rs +++ b/alloc/src/vec/mod.rs @@ -56,7 +56,6 @@ #[cfg(not(no_global_oom_handling))] use core::cmp; use core::cmp::Ordering; -use core::fmt; use core::hash::{Hash, Hasher}; #[cfg(not(no_global_oom_handling))] use core::iter; @@ -65,8 +64,9 @@ use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties}; use core::ops::{self, Index, IndexMut, Range, RangeBounds}; use core::ptr::{self, NonNull}; use core::slice::{self, SliceIndex}; +use core::{fmt, intrinsics}; -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] pub use self::extract_if::ExtractIf; use crate::alloc::{Allocator, Global}; use crate::borrow::{Cow, ToOwned}; @@ -293,7 +293,7 @@ mod spec_extend; /// on an empty Vec, it will not allocate memory. Similarly, if you store zero-sized /// types inside a `Vec`, it will not allocate space for them. *Note that in this case /// the `Vec` might not report a [`capacity`] of 0*. `Vec` will allocate if and only -/// if [mem::size_of::\]\() * [capacity]\() > 0. In general, `Vec`'s allocation +/// if [size_of::\]\() * [capacity]\() > 0. In general, `Vec`'s allocation /// details are very subtle --- if you intend to allocate memory using a `Vec` /// and use it for something else (either to pass to unsafe code, or to build your /// own memory-backed collection), be sure to deallocate this memory by using @@ -355,11 +355,20 @@ mod spec_extend; /// and it may prove desirable to use a non-constant growth factor. Whatever /// strategy is used will of course guarantee *O*(1) amortized [`push`]. /// -/// `vec![x; n]`, `vec![a, b, c, d]`, and -/// [`Vec::with_capacity(n)`][`Vec::with_capacity`], will all produce a `Vec` -/// with at least the requested capacity. If [len] == [capacity], -/// (as is the case for the [`vec!`] macro), then a `Vec` can be converted to -/// and from a [`Box<[T]>`][owned slice] without reallocating or moving the elements. +/// It is guaranteed, in order to respect the intentions of the programmer, that +/// all of `vec![e_1, e_2, ..., e_n]`, `vec![x; n]`, and [`Vec::with_capacity(n)`] produce a `Vec` +/// that requests an allocation of the exact size needed for precisely `n` elements from the allocator, +/// and no other size (such as, for example: a size rounded up to the nearest power of 2). +/// The allocator will return an allocation that is at least as large as requested, but it may be larger. +/// +/// It is guaranteed that the [`Vec::capacity`] method returns a value that is at least the requested capacity +/// and not more than the allocated capacity. +/// +/// The method [`Vec::shrink_to_fit`] will attempt to discard excess capacity an allocator has given to a `Vec`. +/// If [len] == [capacity], then a `Vec` can be converted +/// to and from a [`Box<[T]>`][owned slice] without reallocating or moving the elements. +/// `Vec` exploits this fact as much as reasonable when implementing common conversions +/// such as [`into_boxed_slice`]. /// /// `Vec` will not specifically overwrite any data that is removed from it, /// but also won't specifically preserve it. Its uninitialized memory is @@ -383,16 +392,19 @@ mod spec_extend; /// [`shrink_to`]: Vec::shrink_to /// [capacity]: Vec::capacity /// [`capacity`]: Vec::capacity -/// [mem::size_of::\]: core::mem::size_of +/// [`Vec::capacity`]: Vec::capacity +/// [size_of::\]: size_of /// [len]: Vec::len /// [`len`]: Vec::len /// [`push`]: Vec::push /// [`insert`]: Vec::insert /// [`reserve`]: Vec::reserve +/// [`Vec::with_capacity(n)`]: Vec::with_capacity /// [`MaybeUninit`]: core::mem::MaybeUninit /// [owned slice]: Box +/// [`into_boxed_slice`]: Vec::into_boxed_slice #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "Vec")] +#[rustc_diagnostic_item = "Vec"] #[rustc_insignificant_dtor] pub struct Vec { buf: RawVec, @@ -416,7 +428,7 @@ impl Vec { /// ``` #[inline] #[rustc_const_stable(feature = "const_vec_new", since = "1.39.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "vec_new")] + #[rustc_diagnostic_item = "vec_new"] #[stable(feature = "rust1", since = "1.0.0")] #[must_use] pub const fn new() -> Self { @@ -427,7 +439,7 @@ impl Vec { /// /// The vector will be able to hold at least `capacity` elements without /// reallocating. This method is allowed to allocate for more elements than - /// `capacity`. If `capacity` is 0, the vector will not allocate. + /// `capacity`. If `capacity` is zero, the vector will not allocate. /// /// It is important to note that although the returned vector has the /// minimum *capacity* specified, the vector will have a zero *length*. For @@ -477,7 +489,7 @@ impl Vec { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[must_use] - #[cfg_attr(not(test), rustc_diagnostic_item = "vec_with_capacity")] + #[rustc_diagnostic_item = "vec_with_capacity"] #[track_caller] pub fn with_capacity(capacity: usize) -> Self { Self::with_capacity_in(capacity, Global) @@ -487,7 +499,7 @@ impl Vec { /// /// The vector will be able to hold at least `capacity` elements without /// reallocating. This method is allowed to allocate for more elements than - /// `capacity`. If `capacity` is 0, the vector will not allocate. + /// `capacity`. If `capacity` is zero, the vector will not allocate. /// /// # Errors /// @@ -745,7 +757,7 @@ impl Vec { /// /// The vector will be able to hold at least `capacity` elements without /// reallocating. This method is allowed to allocate for more elements than - /// `capacity`. If `capacity` is 0, the vector will not allocate. + /// `capacity`. If `capacity` is zero, the vector will not allocate. /// /// It is important to note that although the returned vector has the /// minimum *capacity* specified, the vector will have a zero *length*. For @@ -808,7 +820,7 @@ impl Vec { /// /// The vector will be able to hold at least `capacity` elements without /// reallocating. This method is allowed to allocate for more elements than - /// `capacity`. If `capacity` is 0, the vector will not allocate. + /// `capacity`. If `capacity` is zero, the vector will not allocate. /// /// # Errors /// @@ -1242,7 +1254,7 @@ impl Vec { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] pub const fn capacity(&self) -> usize { self.buf.capacity() } @@ -1267,6 +1279,7 @@ impl Vec { #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] #[track_caller] + #[rustc_diagnostic_item = "vec_reserve"] pub fn reserve(&mut self, additional: usize) { self.buf.reserve(self.len, additional); } @@ -1555,12 +1568,12 @@ impl Vec { /// ``` #[inline] #[stable(feature = "vec_as_slice", since = "1.7.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "vec_as_slice")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_diagnostic_item = "vec_as_slice"] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] pub const fn as_slice(&self) -> &[T] { // SAFETY: `slice::from_raw_parts` requires pointee is a contiguous, aligned buffer of size // `len` containing properly-initialized `T`s. Data must not be mutated for the returned - // lifetime. Further, `len * mem::size_of::` <= `ISIZE::MAX`, and allocation does not + // lifetime. Further, `len * size_of::` <= `isize::MAX`, and allocation does not // "wrap" through overflowing memory addresses. // // * Vec API guarantees that self.buf: @@ -1587,12 +1600,12 @@ impl Vec { /// ``` #[inline] #[stable(feature = "vec_as_slice", since = "1.7.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "vec_as_mut_slice")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_diagnostic_item = "vec_as_mut_slice"] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] pub const fn as_mut_slice(&mut self) -> &mut [T] { // SAFETY: `slice::from_raw_parts_mut` requires pointee is a contiguous, aligned buffer of // size `len` containing properly-initialized `T`s. Data must not be accessed through any - // other pointer for the returned lifetime. Further, `len * mem::size_of::` <= + // other pointer for the returned lifetime. Further, `len * size_of::` <= // `ISIZE::MAX` and allocation does not "wrap" through overflowing memory addresses. // // * Vec API guarantees that self.buf: @@ -1660,9 +1673,9 @@ impl Vec { /// [`as_ptr`]: Vec::as_ptr /// [`as_non_null`]: Vec::as_non_null #[stable(feature = "vec_as_ptr", since = "1.37.0")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] #[rustc_never_returns_null_ptr] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[inline] pub const fn as_ptr(&self) -> *const T { // We shadow the slice method of the same name to avoid going through @@ -1723,9 +1736,9 @@ impl Vec { /// [`as_ptr`]: Vec::as_ptr /// [`as_non_null`]: Vec::as_non_null #[stable(feature = "vec_as_ptr", since = "1.37.0")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] #[rustc_never_returns_null_ptr] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[inline] pub const fn as_mut_ptr(&mut self) -> *mut T { // We shadow the slice method of the same name to avoid going through @@ -1824,7 +1837,10 @@ impl Vec { /// /// # Examples /// - /// This method can be useful for situations in which the vector + /// See [`spare_capacity_mut()`] for an example with safe + /// initialization of capacity elements and use of this method. + /// + /// `set_len()` can be useful for situations in which the vector /// is serving as a buffer for other code, particularly over FFI: /// /// ```no_run @@ -1833,7 +1849,7 @@ impl Vec { /// # // don't use this as a starting point for a real library. /// # pub struct StreamWrapper { strm: *mut std::ffi::c_void } /// # const Z_OK: i32 = 0; - /// # extern "C" { + /// # unsafe extern "C" { /// # fn deflateGetDictionary( /// # strm: *mut std::ffi::c_void, /// # dictionary: *mut u8, @@ -1884,6 +1900,8 @@ impl Vec { /// /// Normally, here, one would use [`clear`] instead to correctly drop /// the contents and thus not leak memory. + /// + /// [`spare_capacity_mut()`]: Vec::spare_capacity_mut #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn set_len(&mut self, new_len: usize) { @@ -1953,11 +1971,11 @@ impl Vec { /// # Examples /// /// ``` - /// let mut vec = vec![1, 2, 3]; - /// vec.insert(1, 4); - /// assert_eq!(vec, [1, 4, 2, 3]); - /// vec.insert(4, 5); - /// assert_eq!(vec, [1, 4, 2, 3, 5]); + /// let mut vec = vec!['a', 'b', 'c']; + /// vec.insert(1, 'd'); + /// assert_eq!(vec, ['a', 'd', 'b', 'c']); + /// vec.insert(4, 'e'); + /// assert_eq!(vec, ['a', 'd', 'b', 'c', 'e']); /// ``` /// /// # Time complexity @@ -2024,9 +2042,9 @@ impl Vec { /// # Examples /// /// ``` - /// let mut v = vec![1, 2, 3]; - /// assert_eq!(v.remove(1), 2); - /// assert_eq!(v, [1, 3]); + /// let mut v = vec!['a', 'b', 'c']; + /// assert_eq!(v.remove(1), 'b'); + /// assert_eq!(v, ['a', 'c']); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[track_caller] @@ -2493,7 +2511,7 @@ impl Vec { /// Takes *O*(1) time. #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "vec_pop")] + #[rustc_diagnostic_item = "vec_pop"] pub fn pop(&mut self) -> Option { if self.len == 0 { None @@ -2506,15 +2524,13 @@ impl Vec { } } - /// Removes and returns the last element in a vector if the predicate + /// Removes and returns the last element from a vector if the predicate /// returns `true`, or [`None`] if the predicate returns false or the vector - /// is empty. + /// is empty (the predicate will not be called in that case). /// /// # Examples /// /// ``` - /// #![feature(vec_pop_if)] - /// /// let mut vec = vec![1, 2, 3, 4]; /// let pred = |x: &mut i32| *x % 2 == 0; /// @@ -2522,13 +2538,10 @@ impl Vec { /// assert_eq!(vec, [1, 2, 3]); /// assert_eq!(vec.pop_if(pred), None); /// ``` - #[unstable(feature = "vec_pop_if", issue = "122741")] - pub fn pop_if(&mut self, f: F) -> Option - where - F: FnOnce(&mut T) -> bool, - { + #[stable(feature = "vec_pop_if", since = "1.86.0")] + pub fn pop_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option { let last = self.last_mut()?; - if f(last) { self.pop() } else { None } + if predicate(last) { self.pop() } else { None } } /// Moves all the elements of `other` into `self`, leaving `other` empty. @@ -2569,9 +2582,11 @@ impl Vec { self.len += count; } - /// Removes the specified range from the vector in bulk, returning all - /// removed elements as an iterator. If the iterator is dropped before - /// being fully consumed, it drops the remaining removed elements. + /// Removes the subslice indicated by the given range from the vector, + /// returning a double-ended iterator over the removed subslice. + /// + /// If the iterator is dropped before being fully consumed, + /// it drops the remaining removed elements. /// /// The returned iterator keeps a mutable borrow on the vector to optimize /// its implementation. @@ -2672,10 +2687,17 @@ impl Vec { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] #[rustc_confusables("length", "size")] pub const fn len(&self) -> usize { - self.len + let len = self.len; + + // SAFETY: The maximum capacity of `Vec` is `isize::MAX` bytes, so the maximum value can + // be returned is `usize::checked_div(size_of::()).unwrap_or(usize::MAX)`, which + // matches the definition of `T::MAX_SLICE_LEN`. + unsafe { intrinsics::assume(len <= T::MAX_SLICE_LEN) }; + + len } /// Returns `true` if the vector contains no elements. @@ -2690,8 +2712,8 @@ impl Vec { /// assert!(!v.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "vec_is_empty")] - #[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")] + #[rustc_diagnostic_item = "vec_is_empty"] + #[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")] pub const fn is_empty(&self) -> bool { self.len() == 0 } @@ -2715,10 +2737,10 @@ impl Vec { /// # Examples /// /// ``` - /// let mut vec = vec![1, 2, 3]; + /// let mut vec = vec!['a', 'b', 'c']; /// let vec2 = vec.split_off(1); - /// assert_eq!(vec, [1]); - /// assert_eq!(vec2, [2, 3]); + /// assert_eq!(vec, ['a']); + /// assert_eq!(vec2, ['b', 'c']); /// ``` #[cfg(not(no_global_oom_handling))] #[inline] @@ -2982,9 +3004,9 @@ impl Vec { /// vec.resize(3, "world"); /// assert_eq!(vec, ["hello", "world", "world"]); /// - /// let mut vec = vec![1, 2, 3, 4]; - /// vec.resize(2, 0); - /// assert_eq!(vec, [1, 2]); + /// let mut vec = vec!['a', 'b', 'c', 'd']; + /// vec.resize(2, '_'); + /// assert_eq!(vec, ['a', 'b']); /// ``` #[cfg(not(no_global_oom_handling))] #[stable(feature = "vec_resize", since = "1.5.0")] @@ -3004,10 +3026,9 @@ impl Vec { /// Iterates over the slice `other`, clones each element, and then appends /// it to this `Vec`. The `other` slice is traversed in-order. /// - /// Note that this function is same as [`extend`] except that it is - /// specialized to work with slices instead. If and when Rust gets - /// specialization this function will likely be deprecated (but still - /// available). + /// Note that this function is the same as [`extend`], + /// except that it also works with slice elements that are Clone but not Copy. + /// If Rust gets specialization this function may be deprecated. /// /// # Examples /// @@ -3025,26 +3046,29 @@ impl Vec { self.spec_extend(other.iter()) } - /// Copies elements from `src` range to the end of the vector. + /// Given a range `src`, clones a slice of elements in that range and appends it to the end. + /// + /// `src` must be a range that can form a valid subslice of the `Vec`. /// /// # Panics /// - /// Panics if the starting point is greater than the end point or if - /// the end point is greater than the length of the vector. + /// Panics if starting index is greater than the end index + /// or if the index is greater than the length of the vector. /// /// # Examples /// /// ``` - /// let mut vec = vec![0, 1, 2, 3, 4]; - /// - /// vec.extend_from_within(2..); - /// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4]); + /// let mut characters = vec!['a', 'b', 'c', 'd', 'e']; + /// characters.extend_from_within(2..); + /// assert_eq!(characters, ['a', 'b', 'c', 'd', 'e', 'c', 'd', 'e']); /// - /// vec.extend_from_within(..2); - /// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1]); + /// let mut numbers = vec![0, 1, 2, 3, 4]; + /// numbers.extend_from_within(..2); + /// assert_eq!(numbers, [0, 1, 2, 3, 4, 0, 1]); /// - /// vec.extend_from_within(4..8); - /// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1, 4, 2, 3, 4]); + /// let mut strings = vec![String::from("hello"), String::from("world"), String::from("!")]; + /// strings.extend_from_within(1..=2); + /// assert_eq!(strings, ["hello", "world", "!", "world", "!"]); /// ``` #[cfg(not(no_global_oom_handling))] #[stable(feature = "vec_extend_from_within", since = "1.53.0")] @@ -3169,7 +3193,7 @@ impl Vec { #[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "vec_from_elem")] +#[rustc_diagnostic_item = "vec_from_elem"] #[track_caller] pub fn from_elem(elem: T, n: usize) -> Vec { ::from_elem(elem, n, Global) @@ -3269,23 +3293,12 @@ unsafe impl ops::DerefPure for Vec {} #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] impl Clone for Vec { - #[cfg(not(test))] #[track_caller] fn clone(&self) -> Self { let alloc = self.allocator().clone(); <[T]>::to_vec_in(&**self, alloc) } - // HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is - // required for this method definition, is not available. Instead use the - // `slice::to_vec` function which is only available with cfg(test) - // NB see the slice::hack module in slice.rs for more information - #[cfg(test)] - fn clone(&self) -> Self { - let alloc = self.allocator().clone(); - crate::slice::to_vec(&**self, alloc) - } - /// Overwrites the contents of `self` with a clone of the contents of `source`. /// /// This method is preferred over simply assigning `source.clone()` to `self`, @@ -3572,7 +3585,7 @@ impl Vec { /// with the given `replace_with` iterator and yields the removed items. /// `replace_with` does not need to be the same length as `range`. /// - /// `range` is removed even if the iterator is not consumed until the end. + /// `range` is removed even if the `Splice` iterator is not consumed before it is dropped. /// /// It is unspecified how many elements are removed from the vector /// if the `Splice` value is leaked. @@ -3598,8 +3611,18 @@ impl Vec { /// let mut v = vec![1, 2, 3, 4]; /// let new = [7, 8, 9]; /// let u: Vec<_> = v.splice(1..3, new).collect(); - /// assert_eq!(v, &[1, 7, 8, 9, 4]); - /// assert_eq!(u, &[2, 3]); + /// assert_eq!(v, [1, 7, 8, 9, 4]); + /// assert_eq!(u, [2, 3]); + /// ``` + /// + /// Using `splice` to insert new items into a vector efficiently at a specific position + /// indicated by an empty range: + /// + /// ``` + /// let mut v = vec![1, 5]; + /// let new = [2, 3, 4]; + /// v.splice(1..1, new); + /// assert_eq!(v, [1, 2, 3, 4, 5]); /// ``` #[cfg(not(no_global_oom_handling))] #[inline] @@ -3612,12 +3635,15 @@ impl Vec { Splice { drain: self.drain(range), replace_with: replace_with.into_iter() } } - /// Creates an iterator which uses a closure to determine if an element should be removed. + /// Creates an iterator which uses a closure to determine if element in the range should be removed. /// /// If the closure returns true, then the element is removed and yielded. /// If the closure returns false, the element will remain in the vector and will not be yielded /// by the iterator. /// + /// Only elements that fall in the provided range are considered for extraction, but any elements + /// after the range will still have to be moved if any element has been extracted. + /// /// If the returned `ExtractIf` is not exhausted, e.g. because it is dropped without iterating /// or the iteration short-circuits, then the remaining elements will be retained. /// Use [`retain`] with a negated predicate if you do not need the returned iterator. @@ -3627,10 +3653,12 @@ impl Vec { /// Using this method is equivalent to the following code: /// /// ``` + /// # use std::cmp::min; /// # let some_predicate = |x: &mut i32| { *x == 2 || *x == 3 || *x == 6 }; /// # let mut vec = vec![1, 2, 3, 4, 5, 6]; - /// let mut i = 0; - /// while i < vec.len() { + /// # let range = 1..4; + /// let mut i = range.start; + /// while i < min(vec.len(), range.end) { /// if some_predicate(&mut vec[i]) { /// let val = vec.remove(i); /// // your code here @@ -3645,36 +3673,42 @@ impl Vec { /// But `extract_if` is easier to use. `extract_if` is also more efficient, /// because it can backshift the elements of the array in bulk. /// - /// Note that `extract_if` also lets you mutate every element in the filter closure, - /// regardless of whether you choose to keep or remove it. + /// Note that `extract_if` also lets you mutate the elements passed to the filter closure, + /// regardless of whether you choose to keep or remove them. + /// + /// # Panics + /// + /// If `range` is out of bounds. /// /// # Examples /// /// Splitting an array into evens and odds, reusing the original allocation: /// /// ``` - /// #![feature(extract_if)] /// let mut numbers = vec![1, 2, 3, 4, 5, 6, 8, 9, 11, 13, 14, 15]; /// - /// let evens = numbers.extract_if(|x| *x % 2 == 0).collect::>(); + /// let evens = numbers.extract_if(.., |x| *x % 2 == 0).collect::>(); /// let odds = numbers; /// /// assert_eq!(evens, vec![2, 4, 6, 8, 14]); /// assert_eq!(odds, vec![1, 3, 5, 9, 11, 13, 15]); /// ``` - #[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] - pub fn extract_if(&mut self, filter: F) -> ExtractIf<'_, T, F, A> + /// + /// Using the range argument to only process a part of the vector: + /// + /// ``` + /// let mut items = vec![0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 2]; + /// let ones = items.extract_if(7.., |x| *x == 1).collect::>(); + /// assert_eq!(items, vec![0, 0, 0, 0, 0, 0, 0, 2, 2, 2]); + /// assert_eq!(ones.len(), 3); + /// ``` + #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] + pub fn extract_if(&mut self, range: R, filter: F) -> ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, + R: RangeBounds, { - let old_len = self.len(); - - // Guard against us getting leaked (leak amplification) - unsafe { - self.set_len(0); - } - - ExtractIf { vec: self, idx: 0, del: 0, old_len, pred: filter } + ExtractIf::new(self, filter, range) } } @@ -3809,15 +3843,10 @@ impl From<&[T]> for Vec { /// ``` /// assert_eq!(Vec::from(&[1, 2, 3][..]), vec![1, 2, 3]); /// ``` - #[cfg(not(test))] #[track_caller] fn from(s: &[T]) -> Vec { s.to_vec() } - #[cfg(test)] - fn from(s: &[T]) -> Vec { - crate::slice::to_vec(s, Global) - } } #[cfg(not(no_global_oom_handling))] @@ -3830,15 +3859,10 @@ impl From<&mut [T]> for Vec { /// ``` /// assert_eq!(Vec::from(&mut [1, 2, 3][..]), vec![1, 2, 3]); /// ``` - #[cfg(not(test))] #[track_caller] fn from(s: &mut [T]) -> Vec { s.to_vec() } - #[cfg(test)] - fn from(s: &mut [T]) -> Vec { - crate::slice::to_vec(s, Global) - } } #[cfg(not(no_global_oom_handling))] @@ -3883,16 +3907,10 @@ impl From<[T; N]> for Vec { /// ``` /// assert_eq!(Vec::from([1, 2, 3]), vec![1, 2, 3]); /// ``` - #[cfg(not(test))] #[track_caller] fn from(s: [T; N]) -> Vec { <[T]>::into_vec(Box::new(s)) } - - #[cfg(test)] - fn from(s: [T; N]) -> Vec { - crate::slice::into_vec(Box::new(s)) - } } #[stable(feature = "vec_from_cow_slice", since = "1.14.0")] @@ -3921,7 +3939,6 @@ where } // note: test pulls in std, which causes errors here -#[cfg(not(test))] #[stable(feature = "vec_from_box", since = "1.18.0")] impl From> for Vec { /// Converts a boxed slice into a vector by transferring ownership of @@ -3940,7 +3957,6 @@ impl From> for Vec { // note: test pulls in std, which causes errors here #[cfg(not(no_global_oom_handling))] -#[cfg(not(test))] #[stable(feature = "box_from_vec", since = "1.20.0")] impl From> for Box<[T], A> { /// Converts a vector into a boxed slice. diff --git a/alloc/tests/rc.rs b/alloc/tests/rc.rs deleted file mode 100644 index 451765d724283..0000000000000 --- a/alloc/tests/rc.rs +++ /dev/null @@ -1,260 +0,0 @@ -use std::any::Any; -use std::cell::{Cell, RefCell}; -use std::iter::TrustedLen; -use std::mem; -use std::rc::{Rc, Weak}; - -#[test] -fn uninhabited() { - enum Void {} - let mut a = Weak::::new(); - a = a.clone(); - assert!(a.upgrade().is_none()); - - let mut a: Weak = a; // Unsizing - a = a.clone(); - assert!(a.upgrade().is_none()); -} - -#[test] -fn slice() { - let a: Rc<[u32; 3]> = Rc::new([3, 2, 1]); - let a: Rc<[u32]> = a; // Unsizing - let b: Rc<[u32]> = Rc::from(&[3, 2, 1][..]); // Conversion - assert_eq!(a, b); - - // Exercise is_dangling() with a DST - let mut a = Rc::downgrade(&a); - a = a.clone(); - assert!(a.upgrade().is_some()); -} - -#[test] -fn trait_object() { - let a: Rc = Rc::new(4); - let a: Rc = a; // Unsizing - - // Exercise is_dangling() with a DST - let mut a = Rc::downgrade(&a); - a = a.clone(); - assert!(a.upgrade().is_some()); - - let mut b = Weak::::new(); - b = b.clone(); - assert!(b.upgrade().is_none()); - let mut b: Weak = b; // Unsizing - b = b.clone(); - assert!(b.upgrade().is_none()); -} - -#[test] -fn float_nan_ne() { - let x = Rc::new(f32::NAN); - assert!(x != x); - assert!(!(x == x)); -} - -#[test] -fn partial_eq() { - struct TestPEq(RefCell); - impl PartialEq for TestPEq { - fn eq(&self, other: &TestPEq) -> bool { - *self.0.borrow_mut() += 1; - *other.0.borrow_mut() += 1; - true - } - } - let x = Rc::new(TestPEq(RefCell::new(0))); - assert!(x == x); - assert!(!(x != x)); - assert_eq!(*x.0.borrow(), 4); -} - -#[test] -fn eq() { - #[derive(Eq)] - struct TestEq(RefCell); - impl PartialEq for TestEq { - fn eq(&self, other: &TestEq) -> bool { - *self.0.borrow_mut() += 1; - *other.0.borrow_mut() += 1; - true - } - } - let x = Rc::new(TestEq(RefCell::new(0))); - assert!(x == x); - assert!(!(x != x)); - assert_eq!(*x.0.borrow(), 0); -} - -const SHARED_ITER_MAX: u16 = 100; - -fn assert_trusted_len(_: &I) {} - -#[test] -fn shared_from_iter_normal() { - // Exercise the base implementation for non-`TrustedLen` iterators. - { - // `Filter` is never `TrustedLen` since we don't - // know statically how many elements will be kept: - let iter = (0..SHARED_ITER_MAX).filter(|x| x % 2 == 0).map(Box::new); - - // Collecting into a `Vec` or `Rc<[T]>` should make no difference: - let vec = iter.clone().collect::>(); - let rc = iter.collect::>(); - assert_eq!(&*vec, &*rc); - - // Clone a bit and let these get dropped. - { - let _rc_2 = rc.clone(); - let _rc_3 = rc.clone(); - let _rc_4 = Rc::downgrade(&_rc_3); - } - } // Drop what hasn't been here. -} - -#[test] -fn shared_from_iter_trustedlen_normal() { - // Exercise the `TrustedLen` implementation under normal circumstances - // where `size_hint()` matches `(_, Some(exact_len))`. - { - let iter = (0..SHARED_ITER_MAX).map(Box::new); - assert_trusted_len(&iter); - - // Collecting into a `Vec` or `Rc<[T]>` should make no difference: - let vec = iter.clone().collect::>(); - let rc = iter.collect::>(); - assert_eq!(&*vec, &*rc); - assert_eq!(mem::size_of::>() * SHARED_ITER_MAX as usize, mem::size_of_val(&*rc)); - - // Clone a bit and let these get dropped. - { - let _rc_2 = rc.clone(); - let _rc_3 = rc.clone(); - let _rc_4 = Rc::downgrade(&_rc_3); - } - } // Drop what hasn't been here. - - // Try a ZST to make sure it is handled well. - { - let iter = (0..SHARED_ITER_MAX).map(drop); - let vec = iter.clone().collect::>(); - let rc = iter.collect::>(); - assert_eq!(&*vec, &*rc); - assert_eq!(0, mem::size_of_val(&*rc)); - { - let _rc_2 = rc.clone(); - let _rc_3 = rc.clone(); - let _rc_4 = Rc::downgrade(&_rc_3); - } - } -} - -#[test] -#[should_panic = "I've almost got 99 problems."] -fn shared_from_iter_trustedlen_panic() { - // Exercise the `TrustedLen` implementation when `size_hint()` matches - // `(_, Some(exact_len))` but where `.next()` drops before the last iteration. - let iter = (0..SHARED_ITER_MAX).map(|val| match val { - 98 => panic!("I've almost got 99 problems."), - _ => Box::new(val), - }); - assert_trusted_len(&iter); - let _ = iter.collect::>(); - - panic!("I am unreachable."); -} - -#[test] -fn shared_from_iter_trustedlen_no_fuse() { - // Exercise the `TrustedLen` implementation when `size_hint()` matches - // `(_, Some(exact_len))` but where the iterator does not behave in a fused manner. - struct Iter(std::vec::IntoIter>>); - - unsafe impl TrustedLen for Iter {} - - impl Iterator for Iter { - fn size_hint(&self) -> (usize, Option) { - (2, Some(2)) - } - - type Item = Box; - - fn next(&mut self) -> Option { - self.0.next().flatten() - } - } - - let vec = vec![Some(Box::new(42)), Some(Box::new(24)), None, Some(Box::new(12))]; - let iter = Iter(vec.into_iter()); - assert_trusted_len(&iter); - assert_eq!(&[Box::new(42), Box::new(24)], &*iter.collect::>()); -} - -#[test] -fn weak_may_dangle() { - fn hmm<'a>(val: &'a mut Weak<&'a str>) -> Weak<&'a str> { - val.clone() - } - - // Without #[may_dangle] we get: - let mut val = Weak::new(); - hmm(&mut val); - // ~~~~~~~~ borrowed value does not live long enough - // - // `val` dropped here while still borrowed - // borrow might be used here, when `val` is dropped and runs the `Drop` code for type `std::rc::Weak` -} - -/// Test that a panic from a destructor does not leak the allocation. -#[test] -#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] -fn panic_no_leak() { - use std::alloc::{AllocError, Allocator, Global, Layout}; - use std::panic::{AssertUnwindSafe, catch_unwind}; - use std::ptr::NonNull; - - struct AllocCount(Cell); - unsafe impl Allocator for AllocCount { - fn allocate(&self, layout: Layout) -> Result, AllocError> { - self.0.set(self.0.get() + 1); - Global.allocate(layout) - } - unsafe fn deallocate(&self, ptr: NonNull, layout: Layout) { - self.0.set(self.0.get() - 1); - unsafe { Global.deallocate(ptr, layout) } - } - } - - struct PanicOnDrop; - impl Drop for PanicOnDrop { - fn drop(&mut self) { - panic!("PanicOnDrop"); - } - } - - let alloc = AllocCount(Cell::new(0)); - let rc = Rc::new_in(PanicOnDrop, &alloc); - assert_eq!(alloc.0.get(), 1); - - let panic_message = catch_unwind(AssertUnwindSafe(|| drop(rc))).unwrap_err(); - assert_eq!(*panic_message.downcast_ref::<&'static str>().unwrap(), "PanicOnDrop"); - assert_eq!(alloc.0.get(), 0); -} - -#[allow(unused)] -mod pin_coerce_unsized { - use alloc::rc::{Rc, UniqueRc}; - use core::pin::Pin; - - pub trait MyTrait {} - impl MyTrait for String {} - - // Pin coercion should work for Rc - pub fn pin_rc(arg: Pin>) -> Pin> { - arg - } - pub fn pin_unique_rc(arg: Pin>) -> Pin> { - arg - } -} diff --git a/alloctests/Cargo.toml b/alloctests/Cargo.toml new file mode 100644 index 0000000000000..306375f5f01cc --- /dev/null +++ b/alloctests/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "alloctests" +version = "0.0.0" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/rust.git" +description = "Tests for the Rust Allocation Library" +autotests = false +autobenches = false +edition = "2021" + +[lib] +path = "lib.rs" +test = true +bench = true +doc = false + +[dev-dependencies] +rand = { version = "0.9.0", default-features = false, features = ["alloc"] } +rand_xorshift = "0.4.0" + +[[test]] +name = "alloctests" +path = "tests/lib.rs" + +[[test]] +name = "vec_deque_alloc_error" +path = "tests/vec_deque_alloc_error.rs" + +[[bench]] +name = "allocbenches" +path = "benches/lib.rs" +test = true + +[[bench]] +name = "vec_deque_append_bench" +path = "benches/vec_deque_append.rs" +harness = false + +[lints.rust.unexpected_cfgs] +level = "warn" +check-cfg = [ + 'cfg(bootstrap)', + 'cfg(no_global_oom_handling)', + 'cfg(no_rc)', + 'cfg(no_sync)', + 'cfg(randomized_layouts)', +] diff --git a/alloc/benches/binary_heap.rs b/alloctests/benches/binary_heap.rs similarity index 100% rename from alloc/benches/binary_heap.rs rename to alloctests/benches/binary_heap.rs diff --git a/alloc/benches/btree/map.rs b/alloctests/benches/btree/map.rs similarity index 95% rename from alloc/benches/btree/map.rs rename to alloctests/benches/btree/map.rs index b8119c9f0ebf4..20f02dc3a968a 100644 --- a/alloc/benches/btree/map.rs +++ b/alloctests/benches/btree/map.rs @@ -9,19 +9,19 @@ macro_rules! map_insert_rand_bench { ($name: ident, $n: expr, $map: ident) => { #[bench] pub fn $name(b: &mut Bencher) { - let n: usize = $n; + let n: u32 = $n; let mut map = $map::new(); // setup let mut rng = crate::bench_rng(); for _ in 0..n { - let i = rng.gen::() % n; + let i = rng.random::() % n; map.insert(i, i); } // measure b.iter(|| { - let k = rng.gen::() % n; + let k = rng.random::() % n; map.insert(k, k); map.remove(&k); }); @@ -57,13 +57,13 @@ macro_rules! map_from_iter_rand_bench { ($name: ident, $n: expr, $map: ident) => { #[bench] pub fn $name(b: &mut Bencher) { - let n: usize = $n; + let n: u32 = $n; // setup let mut rng = crate::bench_rng(); - let mut vec = Vec::with_capacity(n); + let mut vec = Vec::with_capacity(n as usize); for _ in 0..n { - let i = rng.gen::() % n; + let i = rng.random::() % n; vec.push((i, i)); } @@ -102,11 +102,11 @@ macro_rules! map_find_rand_bench { #[bench] pub fn $name(b: &mut Bencher) { let mut map = $map::new(); - let n: usize = $n; + let n: u32 = $n; // setup let mut rng = crate::bench_rng(); - let mut keys: Vec<_> = (0..n).map(|_| rng.gen::() % n).collect(); + let mut keys: Vec<_> = (0..n).map(|_| rng.random::() % n).collect(); for &k in &keys { map.insert(k, k); @@ -115,9 +115,9 @@ macro_rules! map_find_rand_bench { keys.shuffle(&mut rng); // measure - let mut i = 0; + let mut i = 0u32; b.iter(|| { - let t = map.get(&keys[i]); + let t = map.get(&keys[i as usize]); i = (i + 1) % n; black_box(t); }) @@ -171,7 +171,7 @@ fn bench_iteration(b: &mut Bencher, size: i32) { let mut rng = crate::bench_rng(); for _ in 0..size { - map.insert(rng.gen(), rng.gen()); + map.insert(rng.random(), rng.random()); } b.iter(|| { @@ -201,7 +201,7 @@ fn bench_iteration_mut(b: &mut Bencher, size: i32) { let mut rng = crate::bench_rng(); for _ in 0..size { - map.insert(rng.gen(), rng.gen()); + map.insert(rng.random(), rng.random()); } b.iter(|| { @@ -353,6 +353,7 @@ pub fn iter_10k(b: &mut Bencher) { } #[bench] +#[cfg_attr(target_os = "emscripten", ignore)] // hits an OOM pub fn iter_1m(b: &mut Bencher) { bench_iter(b, 1_000, 1_000_000); } diff --git a/alloc/benches/btree/mod.rs b/alloctests/benches/btree/mod.rs similarity index 100% rename from alloc/benches/btree/mod.rs rename to alloctests/benches/btree/mod.rs diff --git a/alloc/benches/btree/set.rs b/alloctests/benches/btree/set.rs similarity index 97% rename from alloc/benches/btree/set.rs rename to alloctests/benches/btree/set.rs index 09d72c7206469..5aa395b4d52ac 100644 --- a/alloc/benches/btree/set.rs +++ b/alloctests/benches/btree/set.rs @@ -3,13 +3,13 @@ use std::collections::BTreeSet; use rand::Rng; use test::Bencher; -fn random(n: usize) -> BTreeSet { +fn random(n: u32) -> BTreeSet { let mut rng = crate::bench_rng(); let mut set = BTreeSet::new(); - while set.len() < n { - set.insert(rng.gen()); + while set.len() < n as usize { + set.insert(rng.random()); } - assert_eq!(set.len(), n); + assert_eq!(set.len(), n as usize); set } diff --git a/alloc/benches/lib.rs b/alloctests/benches/lib.rs similarity index 85% rename from alloc/benches/lib.rs rename to alloctests/benches/lib.rs index c1907361f93e1..2633154318c13 100644 --- a/alloc/benches/lib.rs +++ b/alloctests/benches/lib.rs @@ -4,8 +4,7 @@ #![feature(iter_next_chunk)] #![feature(repr_simd)] #![feature(slice_partition_dedup)] -#![cfg_attr(bootstrap, feature(strict_provenance))] -#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] +#![feature(strict_provenance_lints)] #![feature(test)] #![deny(fuzzy_provenance_casts)] diff --git a/alloc/benches/linked_list.rs b/alloctests/benches/linked_list.rs similarity index 100% rename from alloc/benches/linked_list.rs rename to alloctests/benches/linked_list.rs diff --git a/alloc/benches/slice.rs b/alloctests/benches/slice.rs similarity index 85% rename from alloc/benches/slice.rs rename to alloctests/benches/slice.rs index 48c74c4491dc8..27b0e6fac0adb 100644 --- a/alloc/benches/slice.rs +++ b/alloctests/benches/slice.rs @@ -1,7 +1,7 @@ -use std::{mem, ptr}; +use std::ptr; use rand::Rng; -use rand::distributions::{Alphanumeric, DistString, Standard}; +use rand::distr::{Alphanumeric, SampleString, StandardUniform}; use test::{Bencher, black_box}; #[bench] @@ -156,7 +156,7 @@ fn random_inserts(b: &mut Bencher) { let mut v = vec![(0, 0); 30]; for _ in 0..100 { let l = v.len(); - v.insert(rng.gen::() % (l + 1), (1, 1)); + v.insert(rng.random::() as usize % (l + 1), (1, 1)); } }) } @@ -168,7 +168,7 @@ fn random_removes(b: &mut Bencher) { let mut v = vec![(0, 0); 130]; for _ in 0..100 { let l = v.len(); - v.remove(rng.gen::() % l); + v.remove(rng.random::() as usize % l); } }) } @@ -183,20 +183,20 @@ fn gen_descending(len: usize) -> Vec { fn gen_random(len: usize) -> Vec { let mut rng = crate::bench_rng(); - (&mut rng).sample_iter(&Standard).take(len).collect() + (&mut rng).sample_iter(&StandardUniform).take(len).collect() } fn gen_random_bytes(len: usize) -> Vec { let mut rng = crate::bench_rng(); - (&mut rng).sample_iter(&Standard).take(len).collect() + (&mut rng).sample_iter(&StandardUniform).take(len).collect() } fn gen_mostly_ascending(len: usize) -> Vec { let mut rng = crate::bench_rng(); let mut v = gen_ascending(len); for _ in (0usize..).take_while(|x| x * x <= len) { - let x = rng.gen::() % len; - let y = rng.gen::() % len; + let x = rng.random::() as usize % len; + let y = rng.random::() as usize % len; v.swap(x, y); } v @@ -206,8 +206,8 @@ fn gen_mostly_descending(len: usize) -> Vec { let mut rng = crate::bench_rng(); let mut v = gen_descending(len); for _ in (0usize..).take_while(|x| x * x <= len) { - let x = rng.gen::() % len; - let y = rng.gen::() % len; + let x = rng.random::() as usize % len; + let y = rng.random::() as usize % len; v.swap(x, y); } v @@ -217,15 +217,15 @@ fn gen_strings(len: usize) -> Vec { let mut rng = crate::bench_rng(); let mut v = vec![]; for _ in 0..len { - let n = rng.gen::() % 20 + 1; - v.push(Alphanumeric.sample_string(&mut rng, n)); + let n = rng.random::() % 20 + 1; + v.push(Alphanumeric.sample_string(&mut rng, n as usize)); } v } fn gen_big_random(len: usize) -> Vec<[u64; 16]> { let mut rng = crate::bench_rng(); - (&mut rng).sample_iter(&Standard).map(|x| [x; 16]).take(len).collect() + (&mut rng).sample_iter(&StandardUniform).map(|x| [x; 16]).take(len).collect() } macro_rules! sort { @@ -234,7 +234,7 @@ macro_rules! sort { fn $name(b: &mut Bencher) { let v = $gen($len); b.iter(|| v.clone().$f()); - b.bytes = $len * mem::size_of_val(&$gen(1)[0]) as u64; + b.bytes = $len * size_of_val(&$gen(1)[0]) as u64; } }; } @@ -246,7 +246,7 @@ macro_rules! sort_strings { let v = $gen($len); let v = v.iter().map(|s| &**s).collect::>(); b.iter(|| v.clone().$f()); - b.bytes = $len * mem::size_of::<&str>() as u64; + b.bytes = $len * size_of::<&str>() as u64; } }; } @@ -268,7 +268,7 @@ macro_rules! sort_expensive { }); black_box(count); }); - b.bytes = $len * mem::size_of_val(&$gen(1)[0]) as u64; + b.bytes = $len * size_of_val(&$gen(1)[0]) as u64; } }; } @@ -279,7 +279,7 @@ macro_rules! sort_lexicographic { fn $name(b: &mut Bencher) { let v = $gen($len); b.iter(|| v.clone().$f(|x| x.to_string())); - b.bytes = $len * mem::size_of_val(&$gen(1)[0]) as u64; + b.bytes = $len * size_of_val(&$gen(1)[0]) as u64; } }; } @@ -322,7 +322,7 @@ macro_rules! reverse { fn $name(b: &mut Bencher) { // odd length and offset by 1 to be as unaligned as possible let n = 0xFFFFF; - let mut v: Vec<_> = (0..1 + (n / mem::size_of::<$ty>() as u64)).map($f).collect(); + let mut v: Vec<_> = (0..1 + (n / size_of::<$ty>() as u64)).map($f).collect(); b.iter(|| black_box(&mut v[1..]).reverse()); b.bytes = n; } @@ -346,7 +346,7 @@ macro_rules! rotate { ($name:ident, $gen:expr, $len:expr, $mid:expr) => { #[bench] fn $name(b: &mut Bencher) { - let size = mem::size_of_val(&$gen(1)[0]); + let size = size_of_val(&$gen(1)[0]); let mut v = $gen($len * 8 / size); b.iter(|| black_box(&mut v).rotate_left(($mid * 8 + size - 1) / size)); b.bytes = (v.len() * size) as u64; @@ -366,14 +366,25 @@ rotate!(rotate_medium_half, gen_random, 9158, 9158 / 2); rotate!(rotate_medium_half_plus_one, gen_random, 9158, 9158 / 2 + 1); // Intended to use more RAM than the machine has cache +#[cfg(not(target_os = "emscripten"))] // hits an OOM rotate!(rotate_huge_by1, gen_random, 5 * 1024 * 1024, 1); +#[cfg(not(target_os = "emscripten"))] // hits an OOM rotate!(rotate_huge_by9199_u64, gen_random, 5 * 1024 * 1024, 9199); +#[cfg(not(target_os = "emscripten"))] // hits an OOM rotate!(rotate_huge_by9199_bytes, gen_random_bytes, 5 * 1024 * 1024, 9199); +#[cfg(not(target_os = "emscripten"))] // hits an OOM rotate!(rotate_huge_by9199_strings, gen_strings, 5 * 1024 * 1024, 9199); +#[cfg(not(target_os = "emscripten"))] // hits an OOM rotate!(rotate_huge_by9199_big, gen_big_random, 5 * 1024 * 1024, 9199); +#[cfg(not(target_os = "emscripten"))] // hits an OOM rotate!(rotate_huge_by1234577_u64, gen_random, 5 * 1024 * 1024, 1234577); +#[cfg(not(target_os = "emscripten"))] // hits an OOM rotate!(rotate_huge_by1234577_bytes, gen_random_bytes, 5 * 1024 * 1024, 1234577); +#[cfg(not(target_os = "emscripten"))] // hits an OOM rotate!(rotate_huge_by1234577_strings, gen_strings, 5 * 1024 * 1024, 1234577); +#[cfg(not(target_os = "emscripten"))] // hits an OOM rotate!(rotate_huge_by1234577_big, gen_big_random, 5 * 1024 * 1024, 1234577); +#[cfg(not(target_os = "emscripten"))] // hits an OOM rotate!(rotate_huge_half, gen_random, 5 * 1024 * 1024, 5 * 1024 * 1024 / 2); +#[cfg(not(target_os = "emscripten"))] // hits an OOM rotate!(rotate_huge_half_plus_one, gen_random, 5 * 1024 * 1024, 5 * 1024 * 1024 / 2 + 1); diff --git a/alloc/benches/str.rs b/alloctests/benches/str.rs similarity index 100% rename from alloc/benches/str.rs rename to alloctests/benches/str.rs diff --git a/alloc/benches/string.rs b/alloctests/benches/string.rs similarity index 100% rename from alloc/benches/string.rs rename to alloctests/benches/string.rs diff --git a/alloc/benches/vec.rs b/alloctests/benches/vec.rs similarity index 98% rename from alloc/benches/vec.rs rename to alloctests/benches/vec.rs index d29ffae9d70b1..1dab71fa1f4f4 100644 --- a/alloc/benches/vec.rs +++ b/alloctests/benches/vec.rs @@ -547,6 +547,11 @@ fn bench_in_place_collect_droppable(b: &mut Bencher) { }) } +// node.js gives out of memory error to use with length 1_100_000 +#[cfg(target_os = "emscripten")] +const LEN: usize = 4096; + +#[cfg(not(target_os = "emscripten"))] const LEN: usize = 16384; #[bench] @@ -664,7 +669,7 @@ fn random_sorted_fill(mut seed: u32, buf: &mut [u32]) { // This algorithm was used for Vecs prior to Rust 1.52. fn bench_dedup_slice_truncate(b: &mut Bencher, sz: usize) { let mut template = vec![0u32; sz]; - b.bytes = std::mem::size_of_val(template.as_slice()) as u64; + b.bytes = size_of_val(template.as_slice()) as u64; random_sorted_fill(0x43, &mut template); let mut vec = template.clone(); @@ -686,7 +691,7 @@ fn bench_dedup_slice_truncate(b: &mut Bencher, sz: usize) { // Measures performance of Vec::dedup on random data. fn bench_vec_dedup_random(b: &mut Bencher, sz: usize) { let mut template = vec![0u32; sz]; - b.bytes = std::mem::size_of_val(template.as_slice()) as u64; + b.bytes = size_of_val(template.as_slice()) as u64; random_sorted_fill(0x43, &mut template); let mut vec = template.clone(); @@ -703,7 +708,7 @@ fn bench_vec_dedup_random(b: &mut Bencher, sz: usize) { // Measures performance of Vec::dedup when there is no items removed fn bench_vec_dedup_none(b: &mut Bencher, sz: usize) { let mut template = vec![0u32; sz]; - b.bytes = std::mem::size_of_val(template.as_slice()) as u64; + b.bytes = size_of_val(template.as_slice()) as u64; template.chunks_exact_mut(2).for_each(|w| { w[0] = black_box(0); w[1] = black_box(5); @@ -724,7 +729,7 @@ fn bench_vec_dedup_none(b: &mut Bencher, sz: usize) { // Measures performance of Vec::dedup when there is all items removed fn bench_vec_dedup_all(b: &mut Bencher, sz: usize) { let mut template = vec![0u32; sz]; - b.bytes = std::mem::size_of_val(template.as_slice()) as u64; + b.bytes = size_of_val(template.as_slice()) as u64; template.iter_mut().for_each(|w| { *w = black_box(0); }); diff --git a/alloc/benches/vec_deque.rs b/alloctests/benches/vec_deque.rs similarity index 100% rename from alloc/benches/vec_deque.rs rename to alloctests/benches/vec_deque.rs diff --git a/alloc/benches/vec_deque_append.rs b/alloctests/benches/vec_deque_append.rs similarity index 100% rename from alloc/benches/vec_deque_append.rs rename to alloctests/benches/vec_deque_append.rs diff --git a/alloctests/lib.rs b/alloctests/lib.rs new file mode 100644 index 0000000000000..6ce8a6d9ca174 --- /dev/null +++ b/alloctests/lib.rs @@ -0,0 +1,93 @@ +#![cfg(test)] +#![allow(unused_attributes)] +#![unstable(feature = "alloctests", issue = "none")] +#![no_std] +// Lints: +#![deny(unsafe_op_in_unsafe_fn)] +#![warn(deprecated_in_future)] +#![warn(missing_debug_implementations)] +#![allow(explicit_outlives_requirements)] +#![allow(internal_features)] +#![allow(rustdoc::redundant_explicit_links)] +#![warn(rustdoc::unescaped_backticks)] +#![deny(ffi_unwind_calls)] +// +// Library features: +// tidy-alphabetical-start +#![feature(alloc_layout_extra)] +#![feature(allocator_api)] +#![feature(array_into_iter_constructors)] +#![feature(assert_matches)] +#![feature(core_intrinsics)] +#![feature(exact_size_is_empty)] +#![feature(extend_one)] +#![feature(extend_one_unchecked)] +#![feature(hasher_prefixfree_extras)] +#![feature(inplace_iteration)] +#![feature(iter_advance_by)] +#![feature(iter_next_chunk)] +#![feature(maybe_uninit_slice)] +#![feature(maybe_uninit_uninit_array_transpose)] +#![feature(ptr_internals)] +#![feature(sized_type_properties)] +#![feature(slice_iter_mut_as_mut_slice)] +#![feature(slice_ptr_get)] +#![feature(slice_range)] +#![feature(std_internals)] +#![feature(temporary_niche_types)] +#![feature(trusted_fused)] +#![feature(trusted_len)] +#![feature(trusted_random_access)] +#![feature(try_reserve_kind)] +#![feature(try_trait_v2)] +// tidy-alphabetical-end +// +// Language features: +// tidy-alphabetical-start +#![feature(cfg_sanitize)] +#![feature(dropck_eyepatch)] +#![feature(lang_items)] +#![feature(min_specialization)] +#![feature(negative_impls)] +#![feature(never_type)] +#![feature(optimize_attribute)] +#![feature(rustc_allow_const_fn_unstable)] +#![feature(rustc_attrs)] +#![feature(staged_api)] +#![feature(test)] +#![rustc_preserve_ub_checks] +// tidy-alphabetical-end + +// Allow testing this library +extern crate alloc as realalloc; +#[macro_use] +extern crate std; +#[cfg(test)] +extern crate test; +mod testing; +use realalloc::*; + +// We are directly including collections and raw_vec here as both use non-public +// methods and fields in tests and as such need to have the types to test in the +// same crate as the tests themself. +#[path = "../alloc/src/collections/mod.rs"] +mod collections; + +#[path = "../alloc/src/raw_vec/mod.rs"] +mod raw_vec; + +#[allow(dead_code)] // Not used in all configurations +pub(crate) mod test_helpers { + /// Copied from `std::test_helpers::test_rng`, since these tests rely on the + /// seed not being the same for every RNG invocation too. + pub(crate) fn test_rng() -> rand_xorshift::XorShiftRng { + use std::hash::{BuildHasher, Hash, Hasher}; + let mut hasher = std::hash::RandomState::new().build_hasher(); + std::panic::Location::caller().hash(&mut hasher); + let hc64 = hasher.finish(); + let seed_vec = + hc64.to_le_bytes().into_iter().chain(0u8..8).collect::>(); + let seed: [u8; 16] = seed_vec.as_slice().try_into().unwrap(); + rand::SeedableRng::from_seed(seed) + } +} diff --git a/alloc/src/testing/crash_test.rs b/alloctests/testing/crash_test.rs similarity index 86% rename from alloc/src/testing/crash_test.rs rename to alloctests/testing/crash_test.rs index 684bac60d9a86..8e00e4f41e5d6 100644 --- a/alloc/src/testing/crash_test.rs +++ b/alloctests/testing/crash_test.rs @@ -11,7 +11,7 @@ use crate::fmt::Debug; // the `Debug` trait is the only thing we use from `crate /// Crash test dummies are identified and ordered by an id, so they can be used /// as keys in a BTreeMap. #[derive(Debug)] -pub struct CrashTestDummy { +pub(crate) struct CrashTestDummy { pub id: usize, cloned: AtomicUsize, dropped: AtomicUsize, @@ -20,7 +20,7 @@ pub struct CrashTestDummy { impl CrashTestDummy { /// Creates a crash test dummy design. The `id` determines order and equality of instances. - pub fn new(id: usize) -> CrashTestDummy { + pub(crate) fn new(id: usize) -> CrashTestDummy { CrashTestDummy { id, cloned: AtomicUsize::new(0), @@ -31,34 +31,34 @@ impl CrashTestDummy { /// Creates an instance of a crash test dummy that records what events it experiences /// and optionally panics. - pub fn spawn(&self, panic: Panic) -> Instance<'_> { + pub(crate) fn spawn(&self, panic: Panic) -> Instance<'_> { Instance { origin: self, panic } } /// Returns how many times instances of the dummy have been cloned. - pub fn cloned(&self) -> usize { + pub(crate) fn cloned(&self) -> usize { self.cloned.load(SeqCst) } /// Returns how many times instances of the dummy have been dropped. - pub fn dropped(&self) -> usize { + pub(crate) fn dropped(&self) -> usize { self.dropped.load(SeqCst) } /// Returns how many times instances of the dummy have had their `query` member invoked. - pub fn queried(&self) -> usize { + pub(crate) fn queried(&self) -> usize { self.queried.load(SeqCst) } } #[derive(Debug)] -pub struct Instance<'a> { +pub(crate) struct Instance<'a> { origin: &'a CrashTestDummy, panic: Panic, } #[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum Panic { +pub(crate) enum Panic { Never, InClone, InDrop, @@ -66,12 +66,12 @@ pub enum Panic { } impl Instance<'_> { - pub fn id(&self) -> usize { + pub(crate) fn id(&self) -> usize { self.origin.id } /// Some anonymous query, the result of which is already given. - pub fn query(&self, result: R) -> R { + pub(crate) fn query(&self, result: R) -> R { self.origin.queried.fetch_add(1, SeqCst); if self.panic == Panic::InQuery { panic!("panic in `query`"); diff --git a/alloctests/testing/mod.rs b/alloctests/testing/mod.rs new file mode 100644 index 0000000000000..c8457daf93e5a --- /dev/null +++ b/alloctests/testing/mod.rs @@ -0,0 +1,3 @@ +pub(crate) mod crash_test; +pub(crate) mod ord_chaos; +pub(crate) mod rng; diff --git a/alloc/src/testing/ord_chaos.rs b/alloctests/testing/ord_chaos.rs similarity index 90% rename from alloc/src/testing/ord_chaos.rs rename to alloctests/testing/ord_chaos.rs index 96ce7c1579046..55e1ae5e3deaa 100644 --- a/alloc/src/testing/ord_chaos.rs +++ b/alloctests/testing/ord_chaos.rs @@ -4,7 +4,7 @@ use std::ptr; // Minimal type with an `Ord` implementation violating transitivity. #[derive(Debug)] -pub enum Cyclic3 { +pub(crate) enum Cyclic3 { A, B, C, @@ -37,16 +37,16 @@ impl Eq for Cyclic3 {} // Controls the ordering of values wrapped by `Governed`. #[derive(Debug)] -pub struct Governor { +pub(crate) struct Governor { flipped: Cell, } impl Governor { - pub fn new() -> Self { + pub(crate) fn new() -> Self { Governor { flipped: Cell::new(false) } } - pub fn flip(&self) { + pub(crate) fn flip(&self) { self.flipped.set(!self.flipped.get()); } } @@ -55,7 +55,7 @@ impl Governor { // (assuming that `T` respects total order), but can suddenly be made to invert // that total order. #[derive(Debug)] -pub struct Governed<'a, T>(pub T, pub &'a Governor); +pub(crate) struct Governed<'a, T>(pub T, pub &'a Governor); impl PartialOrd for Governed<'_, T> { fn partial_cmp(&self, other: &Self) -> Option { diff --git a/alloc/src/testing/rng.rs b/alloctests/testing/rng.rs similarity index 83% rename from alloc/src/testing/rng.rs rename to alloctests/testing/rng.rs index ecf543bee035a..77d3348f38a5d 100644 --- a/alloc/src/testing/rng.rs +++ b/alloctests/testing/rng.rs @@ -1,5 +1,5 @@ /// XorShiftRng -pub struct DeterministicRng { +pub(crate) struct DeterministicRng { count: usize, x: u32, y: u32, @@ -8,12 +8,12 @@ pub struct DeterministicRng { } impl DeterministicRng { - pub fn new() -> Self { + pub(crate) fn new() -> Self { DeterministicRng { count: 0, x: 0x193a6754, y: 0xa8a7d469, z: 0x97830e05, w: 0x113ba7bb } } /// Guarantees that each returned number is unique. - pub fn next(&mut self) -> u32 { + pub(crate) fn next(&mut self) -> u32 { self.count += 1; assert!(self.count <= 70029); let x = self.x; diff --git a/alloc/src/alloc/tests.rs b/alloctests/tests/alloc_test.rs similarity index 93% rename from alloc/src/alloc/tests.rs rename to alloctests/tests/alloc_test.rs index 5d6077f057a2c..1e722d667955c 100644 --- a/alloc/src/alloc/tests.rs +++ b/alloctests/tests/alloc_test.rs @@ -1,10 +1,9 @@ -use super::*; +use alloc::alloc::*; +use alloc::boxed::Box; extern crate test; use test::Bencher; -use crate::boxed::Box; - #[test] fn allocate_zeroed() { unsafe { diff --git a/alloc/tests/arc.rs b/alloctests/tests/arc.rs similarity index 98% rename from alloc/tests/arc.rs rename to alloctests/tests/arc.rs index a259c0131ecdf..0baa50f439b37 100644 --- a/alloc/tests/arc.rs +++ b/alloctests/tests/arc.rs @@ -1,7 +1,6 @@ use std::any::Any; use std::cell::{Cell, RefCell}; use std::iter::TrustedLen; -use std::mem; use std::sync::{Arc, Weak}; #[test] @@ -129,7 +128,7 @@ fn shared_from_iter_trustedlen_normal() { let vec = iter.clone().collect::>(); let rc = iter.collect::>(); assert_eq!(&*vec, &*rc); - assert_eq!(mem::size_of::>() * SHARED_ITER_MAX as usize, mem::size_of_val(&*rc)); + assert_eq!(size_of::>() * SHARED_ITER_MAX as usize, size_of_val(&*rc)); // Clone a bit and let these get dropped. { @@ -145,7 +144,7 @@ fn shared_from_iter_trustedlen_normal() { let vec = iter.clone().collect::>(); let rc = iter.collect::>(); assert_eq!(&*vec, &*rc); - assert_eq!(0, mem::size_of_val(&*rc)); + assert_eq!(0, size_of_val(&*rc)); { let _rc_2 = rc.clone(); let _rc_3 = rc.clone(); diff --git a/alloc/tests/autotraits.rs b/alloctests/tests/autotraits.rs similarity index 100% rename from alloc/tests/autotraits.rs rename to alloctests/tests/autotraits.rs diff --git a/alloc/tests/borrow.rs b/alloctests/tests/borrow.rs similarity index 100% rename from alloc/tests/borrow.rs rename to alloctests/tests/borrow.rs diff --git a/alloc/tests/boxed.rs b/alloctests/tests/boxed.rs similarity index 99% rename from alloc/tests/boxed.rs rename to alloctests/tests/boxed.rs index 6a8ba5c92fb30..94389cf2de933 100644 --- a/alloc/tests/boxed.rs +++ b/alloctests/tests/boxed.rs @@ -4,7 +4,7 @@ use core::mem::MaybeUninit; use core::ptr::NonNull; #[test] -#[cfg_attr(not(bootstrap), expect(dangling_pointers_from_temporaries))] +#[expect(dangling_pointers_from_temporaries)] fn uninitialized_zero_size_box() { assert_eq!( &*Box::<()>::new_uninit() as *const _, diff --git a/alloc/tests/btree_set_hash.rs b/alloctests/tests/btree_set_hash.rs similarity index 100% rename from alloc/tests/btree_set_hash.rs rename to alloctests/tests/btree_set_hash.rs diff --git a/alloc/tests/c_str.rs b/alloctests/tests/c_str.rs similarity index 100% rename from alloc/tests/c_str.rs rename to alloctests/tests/c_str.rs diff --git a/alloc/src/ffi/c_str/tests.rs b/alloctests/tests/c_str2.rs similarity index 97% rename from alloc/src/ffi/c_str/tests.rs rename to alloctests/tests/c_str2.rs index 8b7172b3f20a9..0f4c27fa12322 100644 --- a/alloc/src/ffi/c_str/tests.rs +++ b/alloctests/tests/c_str2.rs @@ -1,11 +1,12 @@ +use alloc::ffi::CString; +use alloc::rc::Rc; +use alloc::sync::Arc; use core::assert_matches::assert_matches; -use core::ffi::FromBytesUntilNulError; +use core::ffi::{CStr, FromBytesUntilNulError, c_char}; #[allow(deprecated)] use core::hash::SipHasher13 as DefaultHasher; use core::hash::{Hash, Hasher}; -use super::*; - #[test] fn c_to_rust() { let data = b"123\0"; @@ -159,7 +160,7 @@ fn boxed_default() { #[test] fn test_c_str_clone_into() { - let mut c_string = CString::new("lorem").unwrap(); + let mut c_string = c"lorem".to_owned(); let c_ptr = c_string.as_ptr(); let c_str = CStr::from_bytes_with_nul(b"ipsum\0").unwrap(); c_str.clone_into(&mut c_string); diff --git a/alloc/src/collections/binary_heap/tests.rs b/alloctests/tests/collections/binary_heap.rs similarity index 98% rename from alloc/src/collections/binary_heap/tests.rs rename to alloctests/tests/collections/binary_heap.rs index ad0a020a1a961..95f4c3e614f5e 100644 --- a/alloc/src/collections/binary_heap/tests.rs +++ b/alloctests/tests/collections/binary_heap.rs @@ -1,7 +1,9 @@ +use alloc::boxed::Box; +use alloc::collections::binary_heap::*; +use std::iter::TrustedLen; +use std::mem; use std::panic::{AssertUnwindSafe, catch_unwind}; -use super::*; -use crate::boxed::Box; use crate::testing::crash_test::{CrashTestDummy, Panic}; #[test] @@ -500,9 +502,7 @@ fn test_retain_catch_unwind() { // even if the order might not be correct. // // Destructors must be called exactly once per element. -// FIXME: re-enable emscripten once it can unwind again #[test] -#[cfg(not(target_os = "emscripten"))] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn panic_safe() { use std::cmp; @@ -531,7 +531,7 @@ fn panic_safe() { self.0.partial_cmp(&other.0) } } - let mut rng = crate::test_helpers::test_rng(); + let mut rng = crate::test_rng(); const DATASZ: usize = 32; // Miri is too slow let ntest = if cfg!(miri) { 1 } else { 10 }; diff --git a/alloctests/tests/collections/mod.rs b/alloctests/tests/collections/mod.rs new file mode 100644 index 0000000000000..e73f3aaef8c83 --- /dev/null +++ b/alloctests/tests/collections/mod.rs @@ -0,0 +1 @@ +mod binary_heap; diff --git a/alloc/tests/const_fns.rs b/alloctests/tests/const_fns.rs similarity index 100% rename from alloc/tests/const_fns.rs rename to alloctests/tests/const_fns.rs diff --git a/alloc/tests/cow_str.rs b/alloctests/tests/cow_str.rs similarity index 100% rename from alloc/tests/cow_str.rs rename to alloctests/tests/cow_str.rs diff --git a/alloc/tests/fmt.rs b/alloctests/tests/fmt.rs similarity index 100% rename from alloc/tests/fmt.rs rename to alloctests/tests/fmt.rs diff --git a/alloc/tests/heap.rs b/alloctests/tests/heap.rs similarity index 100% rename from alloc/tests/heap.rs rename to alloctests/tests/heap.rs diff --git a/alloc/tests/lib.rs b/alloctests/tests/lib.rs similarity index 67% rename from alloc/tests/lib.rs rename to alloctests/tests/lib.rs index 699a8e6776e6d..46c11ea150bf8 100644 --- a/alloc/tests/lib.rs +++ b/alloctests/tests/lib.rs @@ -3,12 +3,12 @@ #![feature(iter_array_chunks)] #![feature(assert_matches)] #![feature(btree_extract_if)] +#![feature(char_max_len)] #![feature(cow_is_borrowed)] -#![feature(const_heap)] -#![feature(const_try)] #![feature(core_intrinsics)] -#![feature(extract_if)] +#![feature(downcast_unchecked)] #![feature(exact_size_is_empty)] +#![feature(hashmap_internals)] #![feature(linked_list_cursors)] #![feature(map_try_insert)] #![feature(pattern)] @@ -28,40 +28,49 @@ #![feature(string_remove_matches)] #![feature(const_btree_len)] #![feature(const_trait_impl)] -#![feature(const_str_from_utf8)] #![feature(panic_update_hook)] #![feature(pointer_is_aligned_to)] +#![feature(test)] #![feature(thin_box)] -#![cfg_attr(bootstrap, feature(strict_provenance))] -#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] #![feature(drain_keep_rest)] #![feature(local_waker)] -#![feature(vec_pop_if)] +#![feature(str_as_str)] +#![feature(strict_provenance_lints)] +#![feature(vec_deque_pop_if)] #![feature(unique_rc_arc)] #![feature(macro_metavar_expr_concat)] #![allow(internal_features)] #![deny(fuzzy_provenance_casts)] #![deny(unsafe_op_in_unsafe_fn)] +extern crate alloc; +extern crate test; + use std::hash::{DefaultHasher, Hash, Hasher}; +mod alloc_test; mod arc; mod autotraits; mod borrow; mod boxed; mod btree_set_hash; mod c_str; +mod c_str2; +mod collections; mod const_fns; mod cow_str; mod fmt; mod heap; mod linked_list; +mod misc_tests; mod rc; mod slice; mod sort; mod str; mod string; +mod sync; mod task; +mod testing; mod thin_box; mod vec; mod vec_deque; @@ -72,9 +81,18 @@ fn hash(t: &T) -> u64 { s.finish() } -// FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten. -// See https://github.com/kripken/emscripten-fastcomp/issues/169 -#[cfg(not(target_os = "emscripten"))] +/// Copied from `std::test_helpers::test_rng`, since these tests rely on the +/// seed not being the same for every RNG invocation too. +fn test_rng() -> rand_xorshift::XorShiftRng { + use std::hash::{BuildHasher, Hash, Hasher}; + let mut hasher = std::hash::RandomState::new().build_hasher(); + std::panic::Location::caller().hash(&mut hasher); + let hc64 = hasher.finish(); + let seed_vec = hc64.to_le_bytes().into_iter().chain(0u8..8).collect::>(); + let seed: [u8; 16] = seed_vec.as_slice().try_into().unwrap(); + rand::SeedableRng::from_seed(seed) +} + #[test] fn test_boxed_hasher() { let ordinary_hash = hash(&5u32); diff --git a/alloc/tests/linked_list.rs b/alloctests/tests/linked_list.rs similarity index 100% rename from alloc/tests/linked_list.rs rename to alloctests/tests/linked_list.rs diff --git a/alloc/src/tests.rs b/alloctests/tests/misc_tests.rs similarity index 100% rename from alloc/src/tests.rs rename to alloctests/tests/misc_tests.rs diff --git a/alloc/src/rc/tests.rs b/alloctests/tests/rc.rs similarity index 66% rename from alloc/src/rc/tests.rs rename to alloctests/tests/rc.rs index 333e1bde31c1e..bb68eb4ac9e3d 100644 --- a/alloc/src/rc/tests.rs +++ b/alloctests/tests/rc.rs @@ -1,7 +1,263 @@ -use std::cell::RefCell; -use std::clone::Clone; +use std::any::Any; +use std::cell::{Cell, RefCell}; +use std::iter::TrustedLen; +use std::mem; +use std::rc::{Rc, UniqueRc, Weak}; -use super::*; +#[test] +fn uninhabited() { + enum Void {} + let mut a = Weak::::new(); + a = a.clone(); + assert!(a.upgrade().is_none()); + + let mut a: Weak = a; // Unsizing + a = a.clone(); + assert!(a.upgrade().is_none()); +} + +#[test] +fn slice() { + let a: Rc<[u32; 3]> = Rc::new([3, 2, 1]); + let a: Rc<[u32]> = a; // Unsizing + let b: Rc<[u32]> = Rc::from(&[3, 2, 1][..]); // Conversion + assert_eq!(a, b); + + // Exercise is_dangling() with a DST + let mut a = Rc::downgrade(&a); + a = a.clone(); + assert!(a.upgrade().is_some()); +} + +#[test] +fn trait_object() { + let a: Rc = Rc::new(4); + let a: Rc = a; // Unsizing + + // Exercise is_dangling() with a DST + let mut a = Rc::downgrade(&a); + a = a.clone(); + assert!(a.upgrade().is_some()); + + let mut b = Weak::::new(); + b = b.clone(); + assert!(b.upgrade().is_none()); + let mut b: Weak = b; // Unsizing + b = b.clone(); + assert!(b.upgrade().is_none()); +} + +#[test] +fn float_nan_ne() { + let x = Rc::new(f32::NAN); + assert!(x != x); + assert!(!(x == x)); +} + +#[test] +fn partial_eq() { + struct TestPEq(RefCell); + impl PartialEq for TestPEq { + fn eq(&self, other: &TestPEq) -> bool { + *self.0.borrow_mut() += 1; + *other.0.borrow_mut() += 1; + true + } + } + let x = Rc::new(TestPEq(RefCell::new(0))); + assert!(x == x); + assert!(!(x != x)); + assert_eq!(*x.0.borrow(), 4); +} + +#[test] +fn eq() { + #[derive(Eq)] + struct TestEq(RefCell); + impl PartialEq for TestEq { + fn eq(&self, other: &TestEq) -> bool { + *self.0.borrow_mut() += 1; + *other.0.borrow_mut() += 1; + true + } + } + let x = Rc::new(TestEq(RefCell::new(0))); + assert!(x == x); + assert!(!(x != x)); + assert_eq!(*x.0.borrow(), 0); +} + +const SHARED_ITER_MAX: u16 = 100; + +fn assert_trusted_len(_: &I) {} + +#[test] +fn shared_from_iter_normal() { + // Exercise the base implementation for non-`TrustedLen` iterators. + { + // `Filter` is never `TrustedLen` since we don't + // know statically how many elements will be kept: + let iter = (0..SHARED_ITER_MAX).filter(|x| x % 2 == 0).map(Box::new); + + // Collecting into a `Vec` or `Rc<[T]>` should make no difference: + let vec = iter.clone().collect::>(); + let rc = iter.collect::>(); + assert_eq!(&*vec, &*rc); + + // Clone a bit and let these get dropped. + { + let _rc_2 = rc.clone(); + let _rc_3 = rc.clone(); + let _rc_4 = Rc::downgrade(&_rc_3); + } + } // Drop what hasn't been here. +} + +#[test] +fn shared_from_iter_trustedlen_normal() { + // Exercise the `TrustedLen` implementation under normal circumstances + // where `size_hint()` matches `(_, Some(exact_len))`. + { + let iter = (0..SHARED_ITER_MAX).map(Box::new); + assert_trusted_len(&iter); + + // Collecting into a `Vec` or `Rc<[T]>` should make no difference: + let vec = iter.clone().collect::>(); + let rc = iter.collect::>(); + assert_eq!(&*vec, &*rc); + assert_eq!(size_of::>() * SHARED_ITER_MAX as usize, size_of_val(&*rc)); + + // Clone a bit and let these get dropped. + { + let _rc_2 = rc.clone(); + let _rc_3 = rc.clone(); + let _rc_4 = Rc::downgrade(&_rc_3); + } + } // Drop what hasn't been here. + + // Try a ZST to make sure it is handled well. + { + let iter = (0..SHARED_ITER_MAX).map(drop); + let vec = iter.clone().collect::>(); + let rc = iter.collect::>(); + assert_eq!(&*vec, &*rc); + assert_eq!(0, size_of_val(&*rc)); + { + let _rc_2 = rc.clone(); + let _rc_3 = rc.clone(); + let _rc_4 = Rc::downgrade(&_rc_3); + } + } +} + +#[test] +#[should_panic = "I've almost got 99 problems."] +fn shared_from_iter_trustedlen_panic() { + // Exercise the `TrustedLen` implementation when `size_hint()` matches + // `(_, Some(exact_len))` but where `.next()` drops before the last iteration. + let iter = (0..SHARED_ITER_MAX).map(|val| match val { + 98 => panic!("I've almost got 99 problems."), + _ => Box::new(val), + }); + assert_trusted_len(&iter); + let _ = iter.collect::>(); + + panic!("I am unreachable."); +} + +#[test] +fn shared_from_iter_trustedlen_no_fuse() { + // Exercise the `TrustedLen` implementation when `size_hint()` matches + // `(_, Some(exact_len))` but where the iterator does not behave in a fused manner. + struct Iter(std::vec::IntoIter>>); + + unsafe impl TrustedLen for Iter {} + + impl Iterator for Iter { + fn size_hint(&self) -> (usize, Option) { + (2, Some(2)) + } + + type Item = Box; + + fn next(&mut self) -> Option { + self.0.next().flatten() + } + } + + let vec = vec![Some(Box::new(42)), Some(Box::new(24)), None, Some(Box::new(12))]; + let iter = Iter(vec.into_iter()); + assert_trusted_len(&iter); + assert_eq!(&[Box::new(42), Box::new(24)], &*iter.collect::>()); +} + +#[test] +fn weak_may_dangle() { + fn hmm<'a>(val: &'a mut Weak<&'a str>) -> Weak<&'a str> { + val.clone() + } + + // Without #[may_dangle] we get: + let mut val = Weak::new(); + hmm(&mut val); + // ~~~~~~~~ borrowed value does not live long enough + // + // `val` dropped here while still borrowed + // borrow might be used here, when `val` is dropped and runs the `Drop` code for type `std::rc::Weak` +} + +/// Test that a panic from a destructor does not leak the allocation. +#[test] +#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] +fn panic_no_leak() { + use std::alloc::{AllocError, Allocator, Global, Layout}; + use std::panic::{AssertUnwindSafe, catch_unwind}; + use std::ptr::NonNull; + + struct AllocCount(Cell); + unsafe impl Allocator for AllocCount { + fn allocate(&self, layout: Layout) -> Result, AllocError> { + self.0.set(self.0.get() + 1); + Global.allocate(layout) + } + unsafe fn deallocate(&self, ptr: NonNull, layout: Layout) { + self.0.set(self.0.get() - 1); + unsafe { Global.deallocate(ptr, layout) } + } + } + + struct PanicOnDrop; + impl Drop for PanicOnDrop { + fn drop(&mut self) { + panic!("PanicOnDrop"); + } + } + + let alloc = AllocCount(Cell::new(0)); + let rc = Rc::new_in(PanicOnDrop, &alloc); + assert_eq!(alloc.0.get(), 1); + + let panic_message = catch_unwind(AssertUnwindSafe(|| drop(rc))).unwrap_err(); + assert_eq!(*panic_message.downcast_ref::<&'static str>().unwrap(), "PanicOnDrop"); + assert_eq!(alloc.0.get(), 0); +} + +#[allow(unused)] +mod pin_coerce_unsized { + use alloc::rc::{Rc, UniqueRc}; + use core::pin::Pin; + + pub trait MyTrait {} + impl MyTrait for String {} + + // Pin coercion should work for Rc + pub fn pin_rc(arg: Pin>) -> Pin> { + arg + } + pub fn pin_unique_rc(arg: Pin>) -> Pin> { + arg + } +} #[test] fn test_clone() { @@ -61,16 +317,20 @@ fn weak_self_cyclic() { #[test] fn is_unique() { + fn is_unique(this: &Rc) -> bool { + Rc::weak_count(this) == 0 && Rc::strong_count(this) == 1 + } + let x = Rc::new(3); - assert!(Rc::is_unique(&x)); + assert!(is_unique(&x)); let y = x.clone(); - assert!(!Rc::is_unique(&x)); + assert!(!is_unique(&x)); drop(y); - assert!(Rc::is_unique(&x)); + assert!(is_unique(&x)); let w = Rc::downgrade(&x); - assert!(!Rc::is_unique(&x)); + assert!(!is_unique(&x)); drop(w); - assert!(Rc::is_unique(&x)); + assert!(is_unique(&x)); } #[test] @@ -349,9 +609,9 @@ fn test_unsized() { #[test] fn test_maybe_thin_unsized() { // If/when custom thin DSTs exist, this test should be updated to use one - use std::ffi::{CStr, CString}; + use std::ffi::CStr; - let x: Rc = Rc::from(CString::new("swordfish").unwrap().into_boxed_c_str()); + let x: Rc = Rc::from(c"swordfish"); assert_eq!(format!("{x:?}"), "\"swordfish\""); let y: Weak = Rc::downgrade(&x); drop(x); diff --git a/alloc/tests/slice.rs b/alloctests/tests/slice.rs similarity index 99% rename from alloc/tests/slice.rs rename to alloctests/tests/slice.rs index 9625e3d2b5e08..2516563187f2d 100644 --- a/alloc/tests/slice.rs +++ b/alloctests/tests/slice.rs @@ -1,7 +1,7 @@ use std::cmp::Ordering::{Equal, Greater, Less}; use std::convert::identity; use std::rc::Rc; -use std::{fmt, mem, panic}; +use std::{fmt, panic}; fn square(n: usize) -> usize { n * n @@ -73,7 +73,7 @@ fn test_len_divzero() { let v0: &[Z] = &[]; let v1: &[Z] = &[[]]; let v2: &[Z] = &[[], []]; - assert_eq!(mem::size_of::(), 0); + assert_eq!(size_of::(), 0); assert_eq!(v0.len(), 0); assert_eq!(v1.len(), 1); assert_eq!(v2.len(), 2); @@ -1414,7 +1414,6 @@ fn test_box_slice_clone() { #[test] #[allow(unused_must_use)] // here, we care about the side effects of `.clone()` -#[cfg_attr(target_os = "emscripten", ignore)] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn test_box_slice_clone_panics() { use std::sync::Arc; diff --git a/alloc/tests/sort/ffi_types.rs b/alloctests/tests/sort/ffi_types.rs similarity index 100% rename from alloc/tests/sort/ffi_types.rs rename to alloctests/tests/sort/ffi_types.rs diff --git a/alloc/tests/sort/known_good_stable_sort.rs b/alloctests/tests/sort/known_good_stable_sort.rs similarity index 98% rename from alloc/tests/sort/known_good_stable_sort.rs rename to alloctests/tests/sort/known_good_stable_sort.rs index f8615435fc2a7..2df891462538d 100644 --- a/alloc/tests/sort/known_good_stable_sort.rs +++ b/alloctests/tests/sort/known_good_stable_sort.rs @@ -5,7 +5,7 @@ // Based on https://github.com/voultapher/tiny-sort-rs. use alloc::alloc::{Layout, alloc, dealloc}; -use std::{mem, ptr}; +use std::ptr; /// Sort `v` preserving initial order of equal elements. /// @@ -26,7 +26,7 @@ pub fn sort(v: &mut [T]) { #[inline(always)] fn stable_sort bool>(v: &mut [T], mut is_less: F) { - if mem::size_of::() == 0 { + if size_of::() == 0 { return; } @@ -166,7 +166,7 @@ struct BufGuard { impl BufGuard { // SAFETY: The caller has to ensure that len is not 0 and that T is not a ZST. unsafe fn new(len: usize) -> Self { - debug_assert!(len > 0 && mem::size_of::() > 0); + debug_assert!(len > 0 && size_of::() > 0); // SAFETY: See function safety description. let layout = unsafe { unwrap_unchecked(Layout::array::(len).ok()) }; diff --git a/alloc/tests/sort/mod.rs b/alloctests/tests/sort/mod.rs similarity index 100% rename from alloc/tests/sort/mod.rs rename to alloctests/tests/sort/mod.rs diff --git a/alloc/tests/sort/patterns.rs b/alloctests/tests/sort/patterns.rs similarity index 96% rename from alloc/tests/sort/patterns.rs rename to alloctests/tests/sort/patterns.rs index e5d31d868b251..0f1ec664d3d4f 100644 --- a/alloc/tests/sort/patterns.rs +++ b/alloctests/tests/sort/patterns.rs @@ -1,8 +1,8 @@ use std::env; -use std::hash::Hash; use std::str::FromStr; use std::sync::OnceLock; +use rand::distr::Uniform; use rand::prelude::*; use rand_xorshift::XorShiftRng; @@ -23,14 +23,14 @@ pub fn random(len: usize) -> Vec { pub fn random_uniform(len: usize, range: R) -> Vec where - R: Into> + Hash, + Uniform: TryFrom, { // :.:.:.:: let mut rng: XorShiftRng = rand::SeedableRng::seed_from_u64(get_or_init_rand_seed()); // Abstracting over ranges in Rust :( - let dist: rand::distributions::Uniform = range.into(); + let dist = Uniform::try_from(range).unwrap(); (0..len).map(|_| dist.sample(&mut rng)).collect() } @@ -207,5 +207,5 @@ fn rand_root_seed() -> u64 { fn random_vec(len: usize) -> Vec { let mut rng: XorShiftRng = rand::SeedableRng::seed_from_u64(get_or_init_rand_seed()); - (0..len).map(|_| rng.gen::()).collect() + (0..len).map(|_| rng.random::()).collect() } diff --git a/alloc/tests/sort/tests.rs b/alloctests/tests/sort/tests.rs similarity index 99% rename from alloc/tests/sort/tests.rs rename to alloctests/tests/sort/tests.rs index 14e6013f965d8..d321f8df51898 100644 --- a/alloc/tests/sort/tests.rs +++ b/alloctests/tests/sort/tests.rs @@ -11,7 +11,14 @@ use crate::sort::{Sort, known_good_stable_sort, patterns}; #[cfg(miri)] const TEST_LENGTHS: &[usize] = &[2, 3, 4, 7, 10, 15, 20, 24, 33, 50, 100, 171, 300]; -#[cfg(not(miri))] +// node.js gives out of memory error to use with length 1_100_000 +#[cfg(all(not(miri), target_os = "emscripten"))] +const TEST_LENGTHS: &[usize] = &[ + 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 20, 24, 30, 32, 33, 35, 50, 100, 200, 500, 1_000, + 2_048, 5_000, 10_000, 100_000, +]; + +#[cfg(all(not(miri), not(target_os = "emscripten")))] const TEST_LENGTHS: &[usize] = &[ 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 20, 24, 30, 32, 33, 35, 50, 100, 200, 500, 1_000, 2_048, 5_000, 10_000, 100_000, 1_100_000, @@ -33,7 +40,7 @@ fn check_is_sorted(v: &mut [T]) { known_good_stable_sort::sort(known_good_sorted_vec.as_mut_slice()); if is_small_test { - eprintln!("Orginal: {:?}", v_orig); + eprintln!("Original: {:?}", v_orig); eprintln!("Expected: {:?}", known_good_sorted_vec); eprintln!("Got: {:?}", v); } else { diff --git a/alloc/tests/sort/zipf.rs b/alloctests/tests/sort/zipf.rs similarity index 98% rename from alloc/tests/sort/zipf.rs rename to alloctests/tests/sort/zipf.rs index cc774ee5c43bf..3dad2db521f4b 100644 --- a/alloc/tests/sort/zipf.rs +++ b/alloctests/tests/sort/zipf.rs @@ -80,7 +80,7 @@ impl ZipfDistribution { loop { use std::cmp; - let u: f64 = hnum + rng.gen::() * (self.h_integral_x1 - hnum); + let u: f64 = hnum + rng.random::() * (self.h_integral_x1 - hnum); // u is uniformly distributed in (h_integral_x1, h_integral_num_elements] let x: f64 = ZipfDistribution::h_integral_inv(u, self.exponent); @@ -145,7 +145,7 @@ impl ZipfDistribution { } } -impl rand::distributions::Distribution for ZipfDistribution { +impl rand::distr::Distribution for ZipfDistribution { fn sample(&self, rng: &mut R) -> usize { self.next(rng) } diff --git a/alloc/tests/str.rs b/alloctests/tests/str.rs similarity index 96% rename from alloc/tests/str.rs rename to alloctests/tests/str.rs index 6f930ab08535c..906fa2d425e77 100644 --- a/alloc/tests/str.rs +++ b/alloctests/tests/str.rs @@ -2,6 +2,7 @@ use std::assert_matches::assert_matches; use std::borrow::Cow; +use std::char::MAX_LEN_UTF8; use std::cmp::Ordering::{Equal, Greater, Less}; use std::str::{from_utf8, from_utf8_unchecked}; @@ -1231,7 +1232,7 @@ fn test_to_uppercase_rev_iterator() { #[test] #[cfg_attr(miri, ignore)] // Miri is too slow fn test_chars_decoding() { - let mut bytes = [0; 4]; + let mut bytes = [0; MAX_LEN_UTF8]; for c in (0..0x110000).filter_map(std::char::from_u32) { let s = c.encode_utf8(&mut bytes); if Some(c) != s.chars().next() { @@ -1243,7 +1244,7 @@ fn test_chars_decoding() { #[test] #[cfg_attr(miri, ignore)] // Miri is too slow fn test_chars_rev_decoding() { - let mut bytes = [0; 4]; + let mut bytes = [0; MAX_LEN_UTF8]; for c in (0..0x110000).filter_map(std::char::from_u32) { let s = c.encode_utf8(&mut bytes); if Some(c) != s.chars().rev().next() { @@ -1524,18 +1525,14 @@ fn test_lines() { t("bare\r", &["bare\r"]); t("bare\rcr", &["bare\rcr"]); t("Text\n\r", &["Text", "\r"]); - t("\nMäry häd ä little lämb\n\r\nLittle lämb\n", &[ - "", - "Märy häd ä little lämb", - "", - "Little lämb", - ]); - t("\r\nMäry häd ä little lämb\n\nLittle lämb", &[ - "", - "Märy häd ä little lämb", - "", - "Little lämb", - ]); + t( + "\nMäry häd ä little lämb\n\r\nLittle lämb\n", + &["", "Märy häd ä little lämb", "", "Little lämb"], + ); + t( + "\r\nMäry häd ä little lämb\n\nLittle lämb", + &["", "Märy häd ä little lämb", "", "Little lämb"], + ); } #[test] @@ -1978,73 +1975,88 @@ mod pattern { assert_eq!(v, right); } - make_test!(str_searcher_ascii_haystack, "bb", "abbcbbd", [ - Reject(0, 1), - Match(1, 3), - Reject(3, 4), - Match(4, 6), - Reject(6, 7), - ]); - make_test!(str_searcher_ascii_haystack_seq, "bb", "abbcbbbbd", [ - Reject(0, 1), - Match(1, 3), - Reject(3, 4), - Match(4, 6), - Match(6, 8), - Reject(8, 9), - ]); - make_test!(str_searcher_empty_needle_ascii_haystack, "", "abbcbbd", [ - Match(0, 0), - Reject(0, 1), - Match(1, 1), - Reject(1, 2), - Match(2, 2), - Reject(2, 3), - Match(3, 3), - Reject(3, 4), - Match(4, 4), - Reject(4, 5), - Match(5, 5), - Reject(5, 6), - Match(6, 6), - Reject(6, 7), - Match(7, 7), - ]); - make_test!(str_searcher_multibyte_haystack, " ", "├──", [ - Reject(0, 3), - Reject(3, 6), - Reject(6, 9), - ]); - make_test!(str_searcher_empty_needle_multibyte_haystack, "", "├──", [ - Match(0, 0), - Reject(0, 3), - Match(3, 3), - Reject(3, 6), - Match(6, 6), - Reject(6, 9), - Match(9, 9), - ]); + make_test!( + str_searcher_ascii_haystack, + "bb", + "abbcbbd", + [Reject(0, 1), Match(1, 3), Reject(3, 4), Match(4, 6), Reject(6, 7),] + ); + make_test!( + str_searcher_ascii_haystack_seq, + "bb", + "abbcbbbbd", + [Reject(0, 1), Match(1, 3), Reject(3, 4), Match(4, 6), Match(6, 8), Reject(8, 9),] + ); + make_test!( + str_searcher_empty_needle_ascii_haystack, + "", + "abbcbbd", + [ + Match(0, 0), + Reject(0, 1), + Match(1, 1), + Reject(1, 2), + Match(2, 2), + Reject(2, 3), + Match(3, 3), + Reject(3, 4), + Match(4, 4), + Reject(4, 5), + Match(5, 5), + Reject(5, 6), + Match(6, 6), + Reject(6, 7), + Match(7, 7), + ] + ); + make_test!( + str_searcher_multibyte_haystack, + " ", + "├──", + [Reject(0, 3), Reject(3, 6), Reject(6, 9),] + ); + make_test!( + str_searcher_empty_needle_multibyte_haystack, + "", + "├──", + [ + Match(0, 0), + Reject(0, 3), + Match(3, 3), + Reject(3, 6), + Match(6, 6), + Reject(6, 9), + Match(9, 9), + ] + ); make_test!(str_searcher_empty_needle_empty_haystack, "", "", [Match(0, 0),]); make_test!(str_searcher_nonempty_needle_empty_haystack, "├", "", []); - make_test!(char_searcher_ascii_haystack, 'b', "abbcbbd", [ - Reject(0, 1), - Match(1, 2), - Match(2, 3), - Reject(3, 4), - Match(4, 5), - Match(5, 6), - Reject(6, 7), - ]); - make_test!(char_searcher_multibyte_haystack, ' ', "├──", [ - Reject(0, 3), - Reject(3, 6), - Reject(6, 9), - ]); - make_test!(char_searcher_short_haystack, '\u{1F4A9}', "* \t", [ - Reject(0, 1), - Reject(1, 2), - Reject(2, 3), - ]); + make_test!( + char_searcher_ascii_haystack, + 'b', + "abbcbbd", + [ + Reject(0, 1), + Match(1, 2), + Match(2, 3), + Reject(3, 4), + Match(4, 5), + Match(5, 6), + Reject(6, 7), + ] + ); + make_test!( + char_searcher_multibyte_haystack, + ' ', + "├──", + [Reject(0, 3), Reject(3, 6), Reject(6, 9),] + ); + make_test!( + char_searcher_short_haystack, + '\u{1F4A9}', + "* \t", + [Reject(0, 1), Reject(1, 2), Reject(2, 3),] + ); // See #85462 #[test] @@ -2297,21 +2309,21 @@ fn utf8_chars() { assert_eq!(schs.len(), 4); assert_eq!(schs.iter().cloned().collect::(), s); - assert!((from_utf8(s.as_bytes()).is_ok())); + assert!(from_utf8(s.as_bytes()).is_ok()); // invalid prefix - assert!((!from_utf8(&[0x80]).is_ok())); + assert!(!from_utf8(&[0x80]).is_ok()); // invalid 2 byte prefix - assert!((!from_utf8(&[0xc0]).is_ok())); - assert!((!from_utf8(&[0xc0, 0x10]).is_ok())); + assert!(!from_utf8(&[0xc0]).is_ok()); + assert!(!from_utf8(&[0xc0, 0x10]).is_ok()); // invalid 3 byte prefix - assert!((!from_utf8(&[0xe0]).is_ok())); - assert!((!from_utf8(&[0xe0, 0x10]).is_ok())); - assert!((!from_utf8(&[0xe0, 0xff, 0x10]).is_ok())); + assert!(!from_utf8(&[0xe0]).is_ok()); + assert!(!from_utf8(&[0xe0, 0x10]).is_ok()); + assert!(!from_utf8(&[0xe0, 0xff, 0x10]).is_ok()); // invalid 4 byte prefix - assert!((!from_utf8(&[0xf0]).is_ok())); - assert!((!from_utf8(&[0xf0, 0x10]).is_ok())); - assert!((!from_utf8(&[0xf0, 0xff, 0x10]).is_ok())); - assert!((!from_utf8(&[0xf0, 0xff, 0xff, 0x10]).is_ok())); + assert!(!from_utf8(&[0xf0]).is_ok()); + assert!(!from_utf8(&[0xf0, 0x10]).is_ok()); + assert!(!from_utf8(&[0xf0, 0xff, 0x10]).is_ok()); + assert!(!from_utf8(&[0xf0, 0xff, 0xff, 0x10]).is_ok()); } #[test] diff --git a/alloc/tests/string.rs b/alloctests/tests/string.rs similarity index 96% rename from alloc/tests/string.rs rename to alloctests/tests/string.rs index 1c8bff1564db2..d996c55f94660 100644 --- a/alloc/tests/string.rs +++ b/alloctests/tests/string.rs @@ -154,19 +154,28 @@ fn test_fromutf8error_into_lossy() { #[test] fn test_from_utf16() { let pairs = [ - (String::from("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n"), vec![ - 0xd800, 0xdf45, 0xd800, 0xdf3f, 0xd800, 0xdf3b, 0xd800, 0xdf46, 0xd800, 0xdf39, 0xd800, - 0xdf3b, 0xd800, 0xdf30, 0x000a, - ]), - (String::from("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n"), vec![ - 0xd801, 0xdc12, 0xd801, 0xdc49, 0xd801, 0xdc2e, 0xd801, 0xdc40, 0xd801, 0xdc32, 0xd801, - 0xdc4b, 0x0020, 0xd801, 0xdc0f, 0xd801, 0xdc32, 0xd801, 0xdc4d, 0x000a, - ]), - (String::from("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n"), vec![ - 0xd800, 0xdf00, 0xd800, 0xdf16, 0xd800, 0xdf0b, 0xd800, 0xdf04, 0xd800, 0xdf11, 0xd800, - 0xdf09, 0x00b7, 0xd800, 0xdf0c, 0xd800, 0xdf04, 0xd800, 0xdf15, 0xd800, 0xdf04, 0xd800, - 0xdf0b, 0xd800, 0xdf09, 0xd800, 0xdf11, 0x000a, - ]), + ( + String::from("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n"), + vec![ + 0xd800, 0xdf45, 0xd800, 0xdf3f, 0xd800, 0xdf3b, 0xd800, 0xdf46, 0xd800, 0xdf39, + 0xd800, 0xdf3b, 0xd800, 0xdf30, 0x000a, + ], + ), + ( + String::from("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n"), + vec![ + 0xd801, 0xdc12, 0xd801, 0xdc49, 0xd801, 0xdc2e, 0xd801, 0xdc40, 0xd801, 0xdc32, + 0xd801, 0xdc4b, 0x0020, 0xd801, 0xdc0f, 0xd801, 0xdc32, 0xd801, 0xdc4d, 0x000a, + ], + ), + ( + String::from("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n"), + vec![ + 0xd800, 0xdf00, 0xd800, 0xdf16, 0xd800, 0xdf0b, 0xd800, 0xdf04, 0xd800, 0xdf11, + 0xd800, 0xdf09, 0x00b7, 0xd800, 0xdf0c, 0xd800, 0xdf04, 0xd800, 0xdf15, 0xd800, + 0xdf04, 0xd800, 0xdf0b, 0xd800, 0xdf09, 0xd800, 0xdf11, 0x000a, + ], + ), ( String::from("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n"), vec![ diff --git a/alloc/src/sync/tests.rs b/alloctests/tests/sync.rs similarity index 98% rename from alloc/src/sync/tests.rs rename to alloctests/tests/sync.rs index 3f66c88992344..6d3ab1b1d11e1 100644 --- a/alloc/src/sync/tests.rs +++ b/alloctests/tests/sync.rs @@ -1,14 +1,16 @@ +use alloc::sync::*; +use std::alloc::{AllocError, Allocator, Layout}; +use std::any::Any; use std::clone::Clone; use std::mem::MaybeUninit; use std::option::Option::None; +use std::ptr::NonNull; use std::sync::Mutex; -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering::SeqCst; +use std::sync::atomic::Ordering::*; +use std::sync::atomic::{self, AtomicUsize}; use std::sync::mpsc::channel; use std::thread; -use super::*; - struct Canary(*mut AtomicUsize); impl Drop for Canary { @@ -126,6 +128,7 @@ fn try_unwrap() { } #[test] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn into_inner() { for _ in 0..100 // ^ Increase chances of hitting potential race conditions @@ -412,9 +415,9 @@ fn test_unsized() { #[test] fn test_maybe_thin_unsized() { // If/when custom thin DSTs exist, this test should be updated to use one - use std::ffi::{CStr, CString}; + use std::ffi::CStr; - let x: Arc = Arc::from(CString::new("swordfish").unwrap().into_boxed_c_str()); + let x: Arc = Arc::from(c"swordfish"); assert_eq!(format!("{x:?}"), "\"swordfish\""); let y: Weak = Arc::downgrade(&x); drop(x); diff --git a/alloc/tests/task.rs b/alloctests/tests/task.rs similarity index 100% rename from alloc/tests/task.rs rename to alloctests/tests/task.rs diff --git a/alloctests/tests/testing/crash_test.rs b/alloctests/tests/testing/crash_test.rs new file mode 100644 index 0000000000000..502fe6c10c6fd --- /dev/null +++ b/alloctests/tests/testing/crash_test.rs @@ -0,0 +1,80 @@ +use std::cmp::Ordering; +use std::fmt::Debug; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::SeqCst; + +/// A blueprint for crash test dummy instances that monitor drops. +/// Some instances may be configured to panic at some point. +/// +/// Crash test dummies are identified and ordered by an id, so they can be used +/// as keys in a BTreeMap. +#[derive(Debug)] +pub struct CrashTestDummy { + pub id: usize, + dropped: AtomicUsize, +} + +impl CrashTestDummy { + /// Creates a crash test dummy design. The `id` determines order and equality of instances. + pub fn new(id: usize) -> CrashTestDummy { + CrashTestDummy { id, dropped: AtomicUsize::new(0) } + } + + /// Creates an instance of a crash test dummy that records what events it experiences + /// and optionally panics. + pub fn spawn(&self, panic: Panic) -> Instance<'_> { + Instance { origin: self, panic } + } + + /// Returns how many times instances of the dummy have been dropped. + pub fn dropped(&self) -> usize { + self.dropped.load(SeqCst) + } +} + +#[derive(Debug)] +pub struct Instance<'a> { + origin: &'a CrashTestDummy, + panic: Panic, +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum Panic { + Never, + InDrop, +} + +impl Instance<'_> { + pub fn id(&self) -> usize { + self.origin.id + } +} + +impl Drop for Instance<'_> { + fn drop(&mut self) { + self.origin.dropped.fetch_add(1, SeqCst); + if self.panic == Panic::InDrop { + panic!("panic in `drop`"); + } + } +} + +impl PartialOrd for Instance<'_> { + fn partial_cmp(&self, other: &Self) -> Option { + self.id().partial_cmp(&other.id()) + } +} + +impl Ord for Instance<'_> { + fn cmp(&self, other: &Self) -> Ordering { + self.id().cmp(&other.id()) + } +} + +impl PartialEq for Instance<'_> { + fn eq(&self, other: &Self) -> bool { + self.id().eq(&other.id()) + } +} + +impl Eq for Instance<'_> {} diff --git a/alloctests/tests/testing/mod.rs b/alloctests/tests/testing/mod.rs new file mode 100644 index 0000000000000..0a3dd191dc891 --- /dev/null +++ b/alloctests/tests/testing/mod.rs @@ -0,0 +1 @@ +pub mod crash_test; diff --git a/alloc/tests/thin_box.rs b/alloctests/tests/thin_box.rs similarity index 99% rename from alloc/tests/thin_box.rs rename to alloctests/tests/thin_box.rs index e008b0cc35718..4c46b61412796 100644 --- a/alloc/tests/thin_box.rs +++ b/alloctests/tests/thin_box.rs @@ -1,5 +1,4 @@ use core::fmt::Debug; -use core::mem::size_of; use std::boxed::ThinBox; #[test] @@ -52,7 +51,7 @@ fn verify_aligned(ptr: *const T) { ptr.is_aligned() && !ptr.is_null(), "misaligned ThinBox data; valid pointers to `{ty}` should be aligned to {align}: {ptr:p}", ty = core::any::type_name::(), - align = core::mem::align_of::(), + align = align_of::(), ); } diff --git a/alloc/tests/vec.rs b/alloctests/tests/vec.rs similarity index 96% rename from alloc/tests/vec.rs rename to alloctests/tests/vec.rs index 0f27fdff3e182..f430d979fa848 100644 --- a/alloc/tests/vec.rs +++ b/alloctests/tests/vec.rs @@ -11,14 +11,14 @@ use std::borrow::Cow; use std::cell::Cell; use std::collections::TryReserveErrorKind::*; use std::fmt::Debug; +use std::hint; use std::iter::InPlaceIterable; -use std::mem::{size_of, swap}; +use std::mem::swap; use std::ops::Bound::*; use std::panic::{AssertUnwindSafe, catch_unwind}; use std::rc::Rc; use std::sync::atomic::{AtomicU32, Ordering}; use std::vec::{Drain, IntoIter}; -use std::{hint, mem}; struct DropCounter<'a> { count: &'a mut u32, @@ -1134,7 +1134,7 @@ fn test_into_iter_zst() { impl Drop for AlignedZstWithDrop { fn drop(&mut self) { let addr = self as *mut _ as usize; - assert!(hint::black_box(addr) % mem::align_of::() == 0); + assert!(hint::black_box(addr) % align_of::() == 0); } } @@ -1204,22 +1204,16 @@ fn test_from_iter_specialization_with_iterator_adapters() { #[test] fn test_in_place_specialization_step_up_down() { fn assert_in_place_trait(_: &T) {} - let src = vec![[0u8; 4]; 256]; - let srcptr = src.as_ptr(); - let src_cap = src.capacity(); - let iter = src.into_iter().flatten(); - assert_in_place_trait(&iter); - let sink = iter.collect::>(); - let sinkptr = sink.as_ptr(); - assert_eq!(srcptr as *const u8, sinkptr); - assert_eq!(src_cap * 4, sink.capacity()); - let iter = sink.into_iter().array_chunks::<4>(); + let src = vec![0u8; 1024]; + let srcptr = src.as_ptr(); + let src_bytes = src.capacity(); + let iter = src.into_iter().array_chunks::<4>(); assert_in_place_trait(&iter); let sink = iter.collect::>(); let sinkptr = sink.as_ptr(); - assert_eq!(srcptr, sinkptr); - assert_eq!(src_cap, sink.capacity()); + assert_eq!(srcptr.addr(), sinkptr.addr()); + assert_eq!(src_bytes, sink.capacity() * 4); let mut src: Vec = Vec::with_capacity(17); let src_bytes = src.capacity(); @@ -1236,13 +1230,6 @@ fn test_in_place_specialization_step_up_down() { let sink: Vec<[u8; 2]> = iter.collect(); assert_eq!(sink.len(), 8); assert!(sink.capacity() <= 25); - - let src = vec![[0u8; 4]; 256]; - let srcptr = src.as_ptr(); - let iter = src.into_iter().flat_map(|a| a.into_iter().map(|b| b.wrapping_add(1))); - assert_in_place_trait(&iter); - let sink = iter.collect::>(); - assert_eq!(srcptr as *const u8, sink.as_ptr()); } #[test] @@ -1350,6 +1337,20 @@ fn test_collect_after_iterator_clone() { assert_eq!(v, [1, 1, 1, 1, 1]); assert!(v.len() <= v.capacity()); } + +// regression test for #135103, similar to the one above Flatten/FlatMap had an unsound InPlaceIterable +// implementation. +#[test] +fn test_flatten_clone() { + const S: String = String::new(); + + let v = vec![[S, "Hello World!".into()], [S, S]]; + let mut i = v.into_iter().flatten(); + let _ = i.next(); + let result: Vec = i.clone().collect(); + assert_eq!(result, ["Hello World!", "", ""]); +} + #[test] fn test_cow_from() { let borrowed: &[_] = &["borrowed", "(slice)"]; @@ -1414,7 +1415,7 @@ fn extract_if_empty() { let mut vec: Vec = vec![]; { - let mut iter = vec.extract_if(|_| true); + let mut iter = vec.extract_if(.., |_| true); assert_eq!(iter.size_hint(), (0, Some(0))); assert_eq!(iter.next(), None); assert_eq!(iter.size_hint(), (0, Some(0))); @@ -1431,7 +1432,7 @@ fn extract_if_zst() { let initial_len = vec.len(); let mut count = 0; { - let mut iter = vec.extract_if(|_| true); + let mut iter = vec.extract_if(.., |_| true); assert_eq!(iter.size_hint(), (0, Some(initial_len))); while let Some(_) = iter.next() { count += 1; @@ -1454,7 +1455,7 @@ fn extract_if_false() { let initial_len = vec.len(); let mut count = 0; { - let mut iter = vec.extract_if(|_| false); + let mut iter = vec.extract_if(.., |_| false); assert_eq!(iter.size_hint(), (0, Some(initial_len))); for _ in iter.by_ref() { count += 1; @@ -1476,7 +1477,7 @@ fn extract_if_true() { let initial_len = vec.len(); let mut count = 0; { - let mut iter = vec.extract_if(|_| true); + let mut iter = vec.extract_if(.., |_| true); assert_eq!(iter.size_hint(), (0, Some(initial_len))); while let Some(_) = iter.next() { count += 1; @@ -1492,6 +1493,31 @@ fn extract_if_true() { assert_eq!(vec, vec![]); } +#[test] +fn extract_if_ranges() { + let mut vec = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + + let mut count = 0; + let it = vec.extract_if(1..=3, |_| { + count += 1; + true + }); + assert_eq!(it.collect::>(), vec![1, 2, 3]); + assert_eq!(vec, vec![0, 4, 5, 6, 7, 8, 9, 10]); + assert_eq!(count, 3); + + let it = vec.extract_if(1..=3, |_| false); + assert_eq!(it.collect::>(), vec![]); + assert_eq!(vec, vec![0, 4, 5, 6, 7, 8, 9, 10]); +} + +#[test] +#[should_panic] +fn extract_if_out_of_bounds() { + let mut vec = vec![0, 1]; + let _ = vec.extract_if(5.., |_| true).for_each(drop); +} + #[test] fn extract_if_complex() { { @@ -1501,7 +1527,7 @@ fn extract_if_complex() { 39, ]; - let removed = vec.extract_if(|x| *x % 2 == 0).collect::>(); + let removed = vec.extract_if(.., |x| *x % 2 == 0).collect::>(); assert_eq!(removed.len(), 10); assert_eq!(removed, vec![2, 4, 6, 18, 20, 22, 24, 26, 34, 36]); @@ -1515,7 +1541,7 @@ fn extract_if_complex() { 2, 4, 6, 7, 9, 11, 13, 15, 17, 18, 20, 22, 24, 26, 27, 29, 31, 33, 34, 35, 36, 37, 39, ]; - let removed = vec.extract_if(|x| *x % 2 == 0).collect::>(); + let removed = vec.extract_if(.., |x| *x % 2 == 0).collect::>(); assert_eq!(removed.len(), 10); assert_eq!(removed, vec![2, 4, 6, 18, 20, 22, 24, 26, 34, 36]); @@ -1528,7 +1554,7 @@ fn extract_if_complex() { let mut vec = vec![2, 4, 6, 7, 9, 11, 13, 15, 17, 18, 20, 22, 24, 26, 27, 29, 31, 33, 34, 35, 36]; - let removed = vec.extract_if(|x| *x % 2 == 0).collect::>(); + let removed = vec.extract_if(.., |x| *x % 2 == 0).collect::>(); assert_eq!(removed.len(), 10); assert_eq!(removed, vec![2, 4, 6, 18, 20, 22, 24, 26, 34, 36]); @@ -1540,7 +1566,7 @@ fn extract_if_complex() { // [xxxxxxxxxx+++++++++++] let mut vec = vec![2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]; - let removed = vec.extract_if(|x| *x % 2 == 0).collect::>(); + let removed = vec.extract_if(.., |x| *x % 2 == 0).collect::>(); assert_eq!(removed.len(), 10); assert_eq!(removed, vec![2, 4, 6, 8, 10, 12, 14, 16, 18, 20]); @@ -1552,7 +1578,7 @@ fn extract_if_complex() { // [+++++++++++xxxxxxxxxx] let mut vec = vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]; - let removed = vec.extract_if(|x| *x % 2 == 0).collect::>(); + let removed = vec.extract_if(.., |x| *x % 2 == 0).collect::>(); assert_eq!(removed.len(), 10); assert_eq!(removed, vec![2, 4, 6, 8, 10, 12, 14, 16, 18, 20]); @@ -1561,9 +1587,7 @@ fn extract_if_complex() { } } -// FIXME: re-enable emscripten once it can unwind again #[test] -#[cfg(not(target_os = "emscripten"))] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn extract_if_consumed_panic() { use std::rc::Rc; @@ -1600,7 +1624,7 @@ fn extract_if_consumed_panic() { } c.index < 6 }; - let drain = data.extract_if(filter); + let drain = data.extract_if(.., filter); // NOTE: The ExtractIf is explicitly consumed drain.for_each(drop); @@ -1614,9 +1638,7 @@ fn extract_if_consumed_panic() { } } -// FIXME: Re-enable emscripten once it can catch panics #[test] -#[cfg(not(target_os = "emscripten"))] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn extract_if_unconsumed_panic() { use std::rc::Rc; @@ -1653,7 +1675,7 @@ fn extract_if_unconsumed_panic() { } c.index < 6 }; - let _drain = data.extract_if(filter); + let _drain = data.extract_if(.., filter); // NOTE: The ExtractIf is dropped without being consumed }); @@ -1669,7 +1691,7 @@ fn extract_if_unconsumed_panic() { #[test] fn extract_if_unconsumed() { let mut vec = vec![1, 2, 3, 4]; - let drain = vec.extract_if(|&mut x| x % 2 != 0); + let drain = vec.extract_if(.., |&mut x| x % 2 != 0); drop(drain); assert_eq!(vec, [1, 2, 3, 4]); } @@ -2716,3 +2738,13 @@ fn max_swap_remove() { let mut v = vec![0]; v.swap_remove(usize::MAX); } + +// Regression test for #135338 +#[test] +fn vec_null_ptr_roundtrip() { + let ptr = std::ptr::from_ref(&42); + let zero = ptr.with_addr(0); + let roundtripped = vec![zero; 1].pop().unwrap(); + let new = roundtripped.with_addr(ptr.addr()); + unsafe { new.read() }; +} diff --git a/alloc/tests/vec_deque.rs b/alloctests/tests/vec_deque.rs similarity index 98% rename from alloc/tests/vec_deque.rs rename to alloctests/tests/vec_deque.rs index 4b8d3c735f72b..1b03c29e5bda1 100644 --- a/alloc/tests/vec_deque.rs +++ b/alloctests/tests/vec_deque.rs @@ -80,6 +80,45 @@ fn test_parameterized(a: T, b: T, c: T, d: T) { assert_eq!(deq[3].clone(), d.clone()); } +#[test] +fn test_pop_if() { + let mut deq: VecDeque<_> = vec![0, 1, 2, 3, 4].into(); + let pred = |x: &mut i32| *x % 2 == 0; + + assert_eq!(deq.pop_front_if(pred), Some(0)); + assert_eq!(deq, [1, 2, 3, 4]); + + assert_eq!(deq.pop_front_if(pred), None); + assert_eq!(deq, [1, 2, 3, 4]); + + assert_eq!(deq.pop_back_if(pred), Some(4)); + assert_eq!(deq, [1, 2, 3]); + + assert_eq!(deq.pop_back_if(pred), None); + assert_eq!(deq, [1, 2, 3]); +} + +#[test] +fn test_pop_if_empty() { + let mut deq = VecDeque::::new(); + assert_eq!(deq.pop_front_if(|_| true), None); + assert_eq!(deq.pop_back_if(|_| true), None); + assert!(deq.is_empty()); +} + +#[test] +fn test_pop_if_mutates() { + let mut v: VecDeque<_> = vec![-1, 1].into(); + let pred = |x: &mut i32| { + *x *= 2; + false + }; + assert_eq!(v.pop_front_if(pred), None); + assert_eq!(v, [-2, 1]); + assert_eq!(v.pop_back_if(pred), None); + assert_eq!(v, [-2, 2]); +} + #[test] fn test_push_front_grow() { let mut deq = VecDeque::new(); diff --git a/alloc/tests/vec_deque_alloc_error.rs b/alloctests/tests/vec_deque_alloc_error.rs similarity index 100% rename from alloc/tests/vec_deque_alloc_error.rs rename to alloctests/tests/vec_deque_alloc_error.rs diff --git a/backtrace b/backtrace index 230570f2dac80..9d2c34e7e63af 160000 --- a/backtrace +++ b/backtrace @@ -1 +1 @@ -Subproject commit 230570f2dac80a601f5c0b30da00cc9480bd35eb +Subproject commit 9d2c34e7e63afe1e71c333b247065e3b7ba4d883 diff --git a/core/Cargo.toml b/core/Cargo.toml index 94f343d06705e..edde8153aa1d2 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -15,19 +15,6 @@ edition = "2021" test = false bench = false -[[test]] -name = "coretests" -path = "tests/lib.rs" - -[[bench]] -name = "corebenches" -path = "benches/lib.rs" -test = true - -[dev-dependencies] -rand = { version = "0.8.5", default-features = false } -rand_xorshift = { version = "0.3.0", default-features = false } - [features] # Make panics and failed asserts immediately abort without formatting any message panic_immediate_abort = [] @@ -36,6 +23,8 @@ optimize_for_size = [] # Make `RefCell` store additional debugging information, which is printed out when # a borrow error occurs debug_refcell = [] +# Make `TypeId` store a reference to the name of the type, so that it can print that name. +debug_typeid = [] [lints.rust.unexpected_cfgs] level = "warn" @@ -43,8 +32,8 @@ check-cfg = [ 'cfg(bootstrap)', 'cfg(no_fp_fmt_parse)', 'cfg(stdarch_intel_sde)', - # #[cfg(bootstrap)] rtems - 'cfg(target_os, values("rtems"))', + # #[cfg(bootstrap)] + 'cfg(target_feature, values("vector-enhancements-1"))', # core use #[path] imports to portable-simd `core_simd` crate # and to stdarch `core_arch` crate which messes-up with Cargo list # of declared features, we therefor expect any feature cfg diff --git a/core/src/alloc/global.rs b/core/src/alloc/global.rs index 8f48af24557d8..5bf6f143b4f82 100644 --- a/core/src/alloc/global.rs +++ b/core/src/alloc/global.rs @@ -70,7 +70,7 @@ use crate::{cmp, ptr}; /// { /// return null_mut(); /// }; -/// self.arena.get().cast::().add(allocated) +/// unsafe { self.arena.get().cast::().add(allocated) } /// } /// unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {} /// } diff --git a/core/src/alloc/layout.rs b/core/src/alloc/layout.rs index f412ca1716338..1595a3af883d1 100644 --- a/core/src/alloc/layout.rs +++ b/core/src/alloc/layout.rs @@ -17,7 +17,7 @@ use crate::{assert_unsafe_precondition, fmt, mem}; // * https://github.com/rust-lang/rust/pull/72189 // * https://github.com/rust-lang/rust/pull/79827 const fn size_align() -> (usize, usize) { - (mem::size_of::(), mem::align_of::()) + (size_of::(), align_of::()) } /// Layout of a block of memory. @@ -157,7 +157,6 @@ impl Layout { #[must_use = "this returns the minimum alignment, \ without modifying the layout"] #[inline] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(ptr_alignment_type))] pub const fn align(&self) -> usize { self.align.as_usize() } @@ -179,11 +178,11 @@ impl Layout { /// allocate backing structure for `T` (which could be a trait /// or other unsized type like a slice). #[stable(feature = "alloc_layout", since = "1.28.0")] - #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")] + #[rustc_const_stable(feature = "const_alloc_layout", since = "1.85.0")] #[must_use] #[inline] pub const fn for_value(t: &T) -> Self { - let (size, align) = (mem::size_of_val(t), mem::align_of_val(t)); + let (size, align) = (size_of_val(t), align_of_val(t)); // SAFETY: see rationale in `new` for why this is using the unsafe variant unsafe { Layout::from_size_align_unchecked(size, align) } } @@ -216,7 +215,6 @@ impl Layout { /// [trait object]: ../../book/ch17-02-trait-objects.html /// [extern type]: ../../unstable-book/language-features/extern-types.html #[unstable(feature = "layout_for_ptr", issue = "69835")] - #[rustc_const_unstable(feature = "layout_for_ptr", issue = "69835")] #[must_use] pub const unsafe fn for_value_raw(t: *const T) -> Self { // SAFETY: we pass along the prerequisites of these functions to the caller @@ -235,8 +233,7 @@ impl Layout { #[must_use] #[inline] pub const fn dangling(&self) -> NonNull { - // SAFETY: align is guaranteed to be non-zero - unsafe { NonNull::new_unchecked(crate::ptr::without_provenance_mut::(self.align())) } + NonNull::without_provenance(self.align.as_nonzero()) } /// Creates a layout describing the record that can hold a value @@ -254,8 +251,7 @@ impl Layout { /// Returns an error if the combination of `self.size()` and the given /// `align` violates the conditions listed in [`Layout::from_size_align`]. #[stable(feature = "alloc_layout_manipulation", since = "1.44.0")] - #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")] - #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] + #[rustc_const_stable(feature = "const_alloc_layout", since = "1.85.0")] #[inline] pub const fn align_to(&self, align: usize) -> Result { if let Some(align) = Alignment::new(align) { @@ -330,8 +326,7 @@ impl Layout { /// This is equivalent to adding the result of `padding_needed_for` /// to the layout's current size. #[stable(feature = "alloc_layout_manipulation", since = "1.44.0")] - #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")] - #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] + #[rustc_const_stable(feature = "const_alloc_layout", since = "1.85.0")] #[must_use = "this returns a new `Layout`, \ without modifying the original"] #[inline] @@ -430,8 +425,7 @@ impl Layout { /// # assert_eq!(repr_c(&[u64, u32, u16, u32]), Ok((s, vec![0, 8, 12, 16]))); /// ``` #[stable(feature = "alloc_layout_manipulation", since = "1.44.0")] - #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")] - #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] + #[rustc_const_stable(feature = "const_alloc_layout", since = "1.85.0")] #[inline] pub const fn extend(&self, next: Self) -> Result<(Self, usize), LayoutError> { let new_align = Alignment::max(self.align, next.align); @@ -494,8 +488,7 @@ impl Layout { /// On arithmetic overflow or when the total size would exceed /// `isize::MAX`, returns `LayoutError`. #[stable(feature = "alloc_layout_manipulation", since = "1.44.0")] - #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")] - #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] + #[rustc_const_stable(feature = "const_alloc_layout", since = "1.85.0")] #[inline] pub const fn array(n: usize) -> Result { // Reduce the amount of code we need to monomorphize per `T`. diff --git a/core/src/alloc/mod.rs b/core/src/alloc/mod.rs index aa841db045ce7..9805cee1c331e 100644 --- a/core/src/alloc/mod.rs +++ b/core/src/alloc/mod.rs @@ -49,26 +49,26 @@ impl fmt::Display for AllocError { /// An implementation of `Allocator` can allocate, grow, shrink, and deallocate arbitrary blocks of /// data described via [`Layout`][]. /// -/// `Allocator` is designed to be implemented on ZSTs, references, or smart pointers because having -/// an allocator like `MyAlloc([u8; N])` cannot be moved, without updating the pointers to the +/// `Allocator` is designed to be implemented on ZSTs, references, or smart pointers. +/// An allocator for `MyAlloc([u8; N])` cannot be moved, without updating the pointers to the /// allocated memory. /// -/// Unlike [`GlobalAlloc`][], zero-sized allocations are allowed in `Allocator`. If an underlying -/// allocator does not support this (like jemalloc) or return a null pointer (such as -/// `libc::malloc`), this must be caught by the implementation. +/// In contrast to [`GlobalAlloc`][], `Allocator` allows zero-sized allocations. If an underlying +/// allocator does not support this (like jemalloc) or responds by returning a null pointer +/// (such as `libc::malloc`), this must be caught by the implementation. /// /// ### Currently allocated memory /// -/// Some of the methods require that a memory block be *currently allocated* via an allocator. This -/// means that: +/// Some of the methods require that a memory block is *currently allocated* by an allocator. +/// This means that: +/// * the starting address for that memory block was previously +/// returned by [`allocate`], [`grow`], or [`shrink`], and +/// * the memory block has not subsequently been deallocated. /// -/// * the starting address for that memory block was previously returned by [`allocate`], [`grow`], or -/// [`shrink`], and -/// -/// * the memory block has not been subsequently deallocated, where blocks are either deallocated -/// directly by being passed to [`deallocate`] or were changed by being passed to [`grow`] or -/// [`shrink`] that returns `Ok`. If `grow` or `shrink` have returned `Err`, the passed pointer -/// remains valid. +/// A memory block is deallocated by a call to [`deallocate`], +/// or by a call to [`grow`] or [`shrink`] that returns `Ok`. +/// A call to `grow` or `shrink` that returns `Err`, +/// does not deallocate the memory block passed to it. /// /// [`allocate`]: Allocator::allocate /// [`grow`]: Allocator::grow @@ -77,32 +77,28 @@ impl fmt::Display for AllocError { /// /// ### Memory fitting /// -/// Some of the methods require that a layout *fit* a memory block. What it means for a layout to -/// "fit" a memory block means (or equivalently, for a memory block to "fit" a layout) is that the +/// Some of the methods require that a `layout` *fit* a memory block or vice versa. This means that the /// following conditions must hold: -/// -/// * The block must be allocated with the same alignment as [`layout.align()`], and -/// -/// * The provided [`layout.size()`] must fall in the range `min ..= max`, where: -/// - `min` is the size of the layout most recently used to allocate the block, and -/// - `max` is the latest actual size returned from [`allocate`], [`grow`], or [`shrink`]. +/// * the memory block must be *currently allocated* with alignment of [`layout.align()`], and +/// * [`layout.size()`] must fall in the range `min ..= max`, where: +/// - `min` is the size of the layout used to allocate the block, and +/// - `max` is the actual size returned from [`allocate`], [`grow`], or [`shrink`]. /// /// [`layout.align()`]: Layout::align /// [`layout.size()`]: Layout::size /// /// # Safety /// -/// * Memory blocks returned from an allocator that are [*currently allocated*] must point to -/// valid memory and retain their validity while they are [*currently allocated*] and the shorter -/// of: -/// - the borrow-checker lifetime of the allocator type itself. -/// - as long as at least one of the instance and all of its clones has not been dropped. +/// Memory blocks that are [*currently allocated*] by an allocator, +/// must point to valid memory, and retain their validity while until either: +/// - the memory block is deallocated, or +/// - the allocator is dropped. /// -/// * copying, cloning, or moving the allocator must not invalidate memory blocks returned from this -/// allocator. A copied or cloned allocator must behave like the same allocator, and +/// Copying, cloning, or moving the allocator must not invalidate memory blocks returned from it. +/// A copied or cloned allocator must behave like the original allocator. /// -/// * any pointer to a memory block which is [*currently allocated*] may be passed to any other -/// method of the allocator. +/// A memory block which is [*currently allocated*] may be passed to +/// any method of the allocator that accepts such an argument. /// /// [*currently allocated*]: #currently-allocated-memory #[unstable(feature = "allocator_api", issue = "32838")] diff --git a/core/src/any.rs b/core/src/any.rs index 58107b1e7d074..9ed2c8e9f3ad1 100644 --- a/core/src/any.rs +++ b/core/src/any.rs @@ -423,7 +423,8 @@ impl dyn Any + Send { /// /// # Safety /// - /// Same as the method on the type `dyn Any`. + /// The contained value must be of type `T`. Calling this method + /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] pub unsafe fn downcast_ref_unchecked(&self) -> &T { @@ -451,7 +452,8 @@ impl dyn Any + Send { /// /// # Safety /// - /// Same as the method on the type `dyn Any`. + /// The contained value must be of type `T`. Calling this method + /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] pub unsafe fn downcast_mut_unchecked(&mut self) -> &mut T { @@ -552,6 +554,10 @@ impl dyn Any + Send + Sync { /// assert_eq!(*x.downcast_ref_unchecked::(), 1); /// } /// ``` + /// # Safety + /// + /// The contained value must be of type `T`. Calling this method + /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] pub unsafe fn downcast_ref_unchecked(&self) -> &T { @@ -576,6 +582,10 @@ impl dyn Any + Send + Sync { /// /// assert_eq!(*x.downcast_ref::().unwrap(), 2); /// ``` + /// # Safety + /// + /// The contained value must be of type `T`. Calling this method + /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] pub unsafe fn downcast_mut_unchecked(&mut self) -> &mut T { @@ -600,12 +610,109 @@ impl dyn Any + Send + Sync { /// While `TypeId` implements `Hash`, `PartialOrd`, and `Ord`, it is worth /// noting that the hashes and ordering will vary between Rust releases. Beware /// of relying on them inside of your code! +/// +/// # Danger of Improper Variance +/// +/// You might think that subtyping is impossible between two static types, +/// but this is false; there exists a static type with a static subtype. +/// To wit, `fn(&str)`, which is short for `for<'any> fn(&'any str)`, and +/// `fn(&'static str)`, are two distinct, static types, and yet, +/// `fn(&str)` is a subtype of `fn(&'static str)`, since any value of type +/// `fn(&str)` can be used where a value of type `fn(&'static str)` is needed. +/// +/// This means that abstractions around `TypeId`, despite its +/// `'static` bound on arguments, still need to worry about unnecessary +/// and improper variance: it is advisable to strive for invariance +/// first. The usability impact will be negligible, while the reduction +/// in the risk of unsoundness will be most welcome. +/// +/// ## Examples +/// +/// Suppose `SubType` is a subtype of `SuperType`, that is, +/// a value of type `SubType` can be used wherever +/// a value of type `SuperType` is expected. +/// Suppose also that `CoVar` is a generic type, which is covariant over `T` +/// (like many other types, including `PhantomData` and `Vec`). +/// +/// Then, by covariance, `CoVar` is a subtype of `CoVar`, +/// that is, a value of type `CoVar` can be used wherever +/// a value of type `CoVar` is expected. +/// +/// Then if `CoVar` relies on `TypeId::of::()` to uphold any invariants, +/// those invariants may be broken because a value of type `CoVar` can be created +/// without going through any of its methods, like so: +/// ``` +/// type SubType = fn(&()); +/// type SuperType = fn(&'static ()); +/// type CoVar = Vec; // imagine something more complicated +/// +/// let sub: CoVar = CoVar::new(); +/// // we have a `CoVar` instance without +/// // *ever* having called `CoVar::::new()`! +/// let fake_super: CoVar = sub; +/// ``` +/// +/// The following is an example program that tries to use `TypeId::of` to +/// implement a generic type `Unique` that guarantees unique instances for each `Unique`, +/// that is, and for each type `T` there can be at most one value of type `Unique` at any time. +/// +/// ``` +/// mod unique { +/// use std::any::TypeId; +/// use std::collections::BTreeSet; +/// use std::marker::PhantomData; +/// use std::sync::Mutex; +/// +/// static ID_SET: Mutex> = Mutex::new(BTreeSet::new()); +/// +/// // TypeId has only covariant uses, which makes Unique covariant over TypeAsId 🚨 +/// #[derive(Debug, PartialEq)] +/// pub struct Unique( +/// // private field prevents creation without `new` outside this module +/// PhantomData, +/// ); +/// +/// impl Unique { +/// pub fn new() -> Option { +/// let mut set = ID_SET.lock().unwrap(); +/// (set.insert(TypeId::of::())).then(|| Self(PhantomData)) +/// } +/// } +/// +/// impl Drop for Unique { +/// fn drop(&mut self) { +/// let mut set = ID_SET.lock().unwrap(); +/// (!set.remove(&TypeId::of::())).then(|| panic!("duplicity detected")); +/// } +/// } +/// } +/// +/// use unique::Unique; +/// +/// // `OtherRing` is a subtype of `TheOneRing`. Both are 'static, and thus have a TypeId. +/// type TheOneRing = fn(&'static ()); +/// type OtherRing = fn(&()); +/// +/// fn main() { +/// let the_one_ring: Unique = Unique::new().unwrap(); +/// assert_eq!(Unique::::new(), None); +/// +/// let other_ring: Unique = Unique::new().unwrap(); +/// // Use that `Unique` is a subtype of `Unique` 🚨 +/// let fake_one_ring: Unique = other_ring; +/// assert_eq!(fake_one_ring, the_one_ring); +/// +/// std::mem::forget(fake_one_ring); +/// } +/// ``` #[derive(Clone, Copy, Eq, PartialOrd, Ord)] #[stable(feature = "rust1", since = "1.0.0")] pub struct TypeId { // We avoid using `u128` because that imposes higher alignment requirements on many platforms. // See issue #115620 for more information. t: (u64, u64), + #[cfg(feature = "debug_typeid")] + name: &'static str, } #[stable(feature = "rust1", since = "1.0.0")] @@ -617,8 +724,7 @@ impl PartialEq for TypeId { } impl TypeId { - /// Returns the `TypeId` of the type this generic function has been - /// instantiated with. + /// Returns the `TypeId` of the generic type parameter. /// /// # Examples /// @@ -637,10 +743,14 @@ impl TypeId { #[rustc_const_unstable(feature = "const_type_id", issue = "77125")] pub const fn of() -> TypeId { let t: u128 = intrinsics::type_id::(); - let t1 = (t >> 64) as u64; let t2 = t as u64; - TypeId { t: (t1, t2) } + + TypeId { + t: (t1, t2), + #[cfg(feature = "debug_typeid")] + name: type_name::(), + } } fn as_u128(self) -> u128 { @@ -671,7 +781,15 @@ impl hash::Hash for TypeId { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for TypeId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - write!(f, "TypeId({:#034x})", self.as_u128()) + #[cfg(feature = "debug_typeid")] + { + write!(f, "TypeId({:#034x} = {})", self.as_u128(), self.name)?; + } + #[cfg(not(feature = "debug_typeid"))] + { + write!(f, "TypeId({:#034x})", self.as_u128())?; + } + Ok(()) } } diff --git a/core/src/arch.rs b/core/src/arch.rs index 57f456c98b3c6..81d828a971c80 100644 --- a/core/src/arch.rs +++ b/core/src/arch.rs @@ -1,6 +1,14 @@ #![doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")] -#[allow(unused_imports)] +#[allow( + // some targets don't have anything to reexport, which + // makes the `pub use` unused and unreachable, allow + // both lints as to not have `#[cfg]`s + // + // cf. https://github.com/rust-lang/rust/pull/116033#issuecomment-1760085575 + unused_imports, + unreachable_pub +)] #[stable(feature = "simd_arch", since = "1.27.0")] pub use crate::core_arch::arch::*; @@ -42,3 +50,29 @@ pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) { /* compiler built-in */ } + +/// Compiles to a target-specific software breakpoint instruction or equivalent. +/// +/// This will typically abort the program. It may result in a core dump, and/or the system logging +/// debug information. Additional target-specific capabilities may be possible depending on +/// debuggers or other tooling; in particular, a debugger may be able to resume execution. +/// +/// If possible, this will produce an instruction sequence that allows a debugger to resume *after* +/// the breakpoint, rather than resuming *at* the breakpoint; however, the exact behavior is +/// target-specific and debugger-specific, and not guaranteed. +/// +/// If the target platform does not have any kind of debug breakpoint instruction, this may compile +/// to a trapping instruction (e.g. an undefined instruction) instead, or to some other form of +/// target-specific abort that may or may not support convenient resumption. +/// +/// The precise behavior and the precise instruction generated are not guaranteed, except that in +/// normal execution with no debug tooling involved this will not continue executing. +/// +/// - On x86 targets, this produces an `int3` instruction. +/// - On aarch64 targets, this produces a `brk #0xf000` instruction. +// When stabilizing this, update the comment on `core::intrinsics::breakpoint`. +#[unstable(feature = "breakpoint", issue = "133724")] +#[inline(always)] +pub fn breakpoint() { + core::intrinsics::breakpoint(); +} diff --git a/core/src/array/iter.rs b/core/src/array/iter.rs index 9ce0eb61e0814..1edade41597f7 100644 --- a/core/src/array/iter.rs +++ b/core/src/array/iter.rs @@ -214,7 +214,7 @@ impl IntoIter { // SAFETY: We know that all elements within `alive` are properly initialized. unsafe { let slice = self.data.get_unchecked(self.alive.clone()); - MaybeUninit::slice_assume_init_ref(slice) + slice.assume_init_ref() } } @@ -224,7 +224,7 @@ impl IntoIter { // SAFETY: We know that all elements within `alive` are properly initialized. unsafe { let slice = self.data.get_unchecked_mut(self.alive.clone()); - MaybeUninit::slice_assume_init_mut(slice) + slice.assume_init_mut() } } } @@ -285,7 +285,7 @@ impl Iterator for IntoIter { // SAFETY: These elements are currently initialized, so it's fine to drop them. unsafe { let slice = self.data.get_unchecked_mut(range_to_drop); - ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(slice)); + slice.assume_init_drop(); } NonZero::new(remaining).map_or(Ok(()), Err) @@ -340,7 +340,7 @@ impl DoubleEndedIterator for IntoIter { // SAFETY: These elements are currently initialized, so it's fine to drop them. unsafe { let slice = self.data.get_unchecked_mut(range_to_drop); - ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(slice)); + slice.assume_init_drop(); } NonZero::new(remaining).map_or(Ok(()), Err) diff --git a/core/src/array/mod.rs b/core/src/array/mod.rs index 67fbda34bb935..28329bb090845 100644 --- a/core/src/array/mod.rs +++ b/core/src/array/mod.rs @@ -156,7 +156,6 @@ pub const fn from_mut(s: &mut T) -> &mut [T; 1] { /// The error type returned when a conversion from a slice to an array fails. #[stable(feature = "try_from", since = "1.34.0")] -#[rustc_allowed_through_unstable_modules] #[derive(Debug, Copy, Clone)] pub struct TryFromSliceError(()); @@ -214,8 +213,8 @@ impl BorrowMut<[T]> for [T; N] { } } -/// Tries to create an array `[T; N]` by copying from a slice `&[T]`. Succeeds if -/// `slice.len() == N`. +/// Tries to create an array `[T; N]` by copying from a slice `&[T]`. +/// Succeeds if `slice.len() == N`. /// /// ``` /// let bytes: [u8; 3] = [1, 0, 2]; @@ -282,13 +281,7 @@ impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] { #[inline] fn try_from(slice: &'a [T]) -> Result<&'a [T; N], TryFromSliceError> { - if slice.len() == N { - let ptr = slice.as_ptr() as *const [T; N]; - // SAFETY: ok because we just checked that the length fits - unsafe { Ok(&*ptr) } - } else { - Err(TryFromSliceError(())) - } + slice.as_array().ok_or(TryFromSliceError(())) } } @@ -310,13 +303,7 @@ impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N] { #[inline] fn try_from(slice: &'a mut [T]) -> Result<&'a mut [T; N], TryFromSliceError> { - if slice.len() == N { - let ptr = slice.as_mut_ptr() as *mut [T; N]; - // SAFETY: ok because we just checked that the length fits - unsafe { Ok(&mut *ptr) } - } else { - Err(TryFromSliceError(())) - } + slice.as_mut_array().ok_or(TryFromSliceError(())) } } @@ -905,7 +892,7 @@ impl Guard<'_, T> { /// /// No more than N elements must be initialized. #[inline] - pub unsafe fn push_unchecked(&mut self, item: T) { + pub(crate) unsafe fn push_unchecked(&mut self, item: T) { // SAFETY: If `initialized` was correct before and the caller does not // invoke this method more than N times then writes will be in-bounds // and slots will not be initialized more than once. @@ -923,9 +910,7 @@ impl Drop for Guard<'_, T> { // SAFETY: this slice will contain only initialized objects. unsafe { - crate::ptr::drop_in_place(MaybeUninit::slice_assume_init_mut( - self.array_mut.get_unchecked_mut(..self.initialized), - )); + self.array_mut.get_unchecked_mut(..self.initialized).assume_init_drop(); } } } diff --git a/core/src/bool.rs b/core/src/bool.rs index 58a870d2e0725..3c589ca5dfa7e 100644 --- a/core/src/bool.rs +++ b/core/src/bool.rs @@ -54,10 +54,59 @@ impl bool { /// // `then`. /// assert_eq!(a, 1); /// ``` + #[doc(alias = "then_with")] #[stable(feature = "lazy_bool_to_option", since = "1.50.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "bool_then")] #[inline] pub fn then T>(self, f: F) -> Option { if self { Some(f()) } else { None } } + + /// Returns either `true_val` or `false_val` depending on the value of + /// `self`, with a hint to the compiler that `self` is unlikely + /// to be correctly predicted by a CPU’s branch predictor. + /// + /// This method is functionally equivalent to + /// ```ignore (this is just for illustrative purposes) + /// fn select_unpredictable(b: bool, true_val: T, false_val: T) -> T { + /// if b { true_val } else { false_val } + /// } + /// ``` + /// but might generate different assembly. In particular, on platforms with + /// a conditional move or select instruction (like `cmov` on x86 or `csel` + /// on ARM) the optimizer might use these instructions to avoid branches, + /// which can benefit performance if the branch predictor is struggling + /// with predicting `condition`, such as in an implementation of binary + /// search. + /// + /// Note however that this lowering is not guaranteed (on any platform) and + /// should not be relied upon when trying to write constant-time code. Also + /// be aware that this lowering might *decrease* performance if `condition` + /// is well-predictable. It is advisable to perform benchmarks to tell if + /// this function is useful. + /// + /// # Examples + /// + /// Distribute values evenly between two buckets: + /// ``` + /// #![feature(select_unpredictable)] + /// + /// use std::hash::BuildHasher; + /// + /// fn append(hasher: &H, v: i32, bucket_one: &mut Vec, bucket_two: &mut Vec) { + /// let hash = hasher.hash_one(&v); + /// let bucket = (hash % 2 == 0).select_unpredictable(bucket_one, bucket_two); + /// bucket.push(v); + /// } + /// # let hasher = std::collections::hash_map::RandomState::new(); + /// # let mut bucket_one = Vec::new(); + /// # let mut bucket_two = Vec::new(); + /// # append(&hasher, 42, &mut bucket_one, &mut bucket_two); + /// # assert_eq!(bucket_one.len() + bucket_two.len(), 1); + /// ``` + #[inline(always)] + #[unstable(feature = "select_unpredictable", issue = "133962")] + pub fn select_unpredictable(self, true_val: T, false_val: T) -> T { + crate::intrinsics::select_unpredictable(self, true_val, false_val) + } } diff --git a/core/src/bstr.rs b/core/src/bstr.rs new file mode 100644 index 0000000000000..ae84fd8adb61c --- /dev/null +++ b/core/src/bstr.rs @@ -0,0 +1,583 @@ +//! The `ByteStr` type and trait implementations. + +use crate::borrow::{Borrow, BorrowMut}; +use crate::cmp::Ordering; +use crate::ops::{ + Deref, DerefMut, DerefPure, Index, IndexMut, Range, RangeFrom, RangeFull, RangeInclusive, + RangeTo, RangeToInclusive, +}; +use crate::{fmt, hash}; + +/// A wrapper for `&[u8]` representing a human-readable string that's conventionally, but not +/// always, UTF-8. +/// +/// Unlike `&str`, this type permits non-UTF-8 contents, making it suitable for user input, +/// non-native filenames (as `Path` only supports native filenames), and other applications that +/// need to round-trip whatever data the user provides. +/// +/// For an owned, growable byte string buffer, use +/// [`ByteString`](../../std/bstr/struct.ByteString.html). +/// +/// `ByteStr` implements `Deref` to `[u8]`, so all methods available on `[u8]` are available on +/// `ByteStr`. +/// +/// # Representation +/// +/// A `&ByteStr` has the same representation as a `&str`. That is, a `&ByteStr` is a wide pointer +/// which includes a pointer to some bytes and a length. +/// +/// # Trait implementations +/// +/// The `ByteStr` type has a number of trait implementations, and in particular, defines equality +/// and comparisons between `&ByteStr`, `&str`, and `&[u8]`, for convenience. +/// +/// The `Debug` implementation for `ByteStr` shows its bytes as a normal string, with invalid UTF-8 +/// presented as hex escape sequences. +/// +/// The `Display` implementation behaves as if the `ByteStr` were first lossily converted to a +/// `str`, with invalid UTF-8 presented as the Unicode replacement character: � +/// +#[unstable(feature = "bstr", issue = "134915")] +#[repr(transparent)] +#[doc(alias = "BStr")] +pub struct ByteStr(pub [u8]); + +impl ByteStr { + /// Creates a `ByteStr` slice from anything that can be converted to a byte slice. + /// + /// This is a zero-cost conversion. + /// + /// # Example + /// + /// You can create a `ByteStr` from a byte array, a byte slice or a string slice: + /// + /// ``` + /// # #![feature(bstr)] + /// # use std::bstr::ByteStr; + /// let a = ByteStr::new(b"abc"); + /// let b = ByteStr::new(&b"abc"[..]); + /// let c = ByteStr::new("abc"); + /// + /// assert_eq!(a, b); + /// assert_eq!(a, c); + /// ``` + #[inline] + #[unstable(feature = "bstr", issue = "134915")] + pub fn new>(bytes: &B) -> &Self { + ByteStr::from_bytes(bytes.as_ref()) + } + + #[doc(hidden)] + #[unstable(feature = "bstr_internals", issue = "none")] + #[inline] + pub fn from_bytes(slice: &[u8]) -> &Self { + // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`, so we can turn a reference to + // the wrapped type into a reference to the wrapper type. + unsafe { &*(slice as *const [u8] as *const Self) } + } + + #[doc(hidden)] + #[unstable(feature = "bstr_internals", issue = "none")] + #[inline] + pub fn from_bytes_mut(slice: &mut [u8]) -> &mut Self { + // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`, so we can turn a reference to + // the wrapped type into a reference to the wrapper type. + unsafe { &mut *(slice as *mut [u8] as *mut Self) } + } + + #[doc(hidden)] + #[unstable(feature = "bstr_internals", issue = "none")] + #[inline] + pub fn as_bytes(&self) -> &[u8] { + &self.0 + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Deref for ByteStr { + type Target = [u8]; + + #[inline] + fn deref(&self) -> &[u8] { + &self.0 + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl DerefMut for ByteStr { + #[inline] + fn deref_mut(&mut self) -> &mut [u8] { + &mut self.0 + } +} + +#[unstable(feature = "deref_pure_trait", issue = "87121")] +unsafe impl DerefPure for ByteStr {} + +#[unstable(feature = "bstr", issue = "134915")] +impl fmt::Debug for ByteStr { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "\"")?; + for chunk in self.utf8_chunks() { + for c in chunk.valid().chars() { + match c { + '\0' => write!(f, "\\0")?, + '\x01'..='\x7f' => write!(f, "{}", (c as u8).escape_ascii())?, + _ => write!(f, "{}", c.escape_debug())?, + } + } + write!(f, "{}", chunk.invalid().escape_ascii())?; + } + write!(f, "\"")?; + Ok(()) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl fmt::Display for ByteStr { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fn fmt_nopad(this: &ByteStr, f: &mut fmt::Formatter<'_>) -> fmt::Result { + for chunk in this.utf8_chunks() { + f.write_str(chunk.valid())?; + if !chunk.invalid().is_empty() { + f.write_str("\u{FFFD}")?; + } + } + Ok(()) + } + + let Some(align) = f.align() else { + return fmt_nopad(self, f); + }; + let nchars: usize = self + .utf8_chunks() + .map(|chunk| { + chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 } + }) + .sum(); + let padding = f.width().unwrap_or(0).saturating_sub(nchars); + let fill = f.fill(); + let (lpad, rpad) = match align { + fmt::Alignment::Left => (0, padding), + fmt::Alignment::Right => (padding, 0), + fmt::Alignment::Center => { + let half = padding / 2; + (half, half + padding % 2) + } + }; + for _ in 0..lpad { + write!(f, "{fill}")?; + } + fmt_nopad(self, f)?; + for _ in 0..rpad { + write!(f, "{fill}")?; + } + + Ok(()) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl AsRef<[u8]> for ByteStr { + #[inline] + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl AsRef for ByteStr { + #[inline] + fn as_ref(&self) -> &ByteStr { + self + } +} + +// `impl AsRef for [u8]` omitted to avoid widespread inference failures + +#[unstable(feature = "bstr", issue = "134915")] +impl AsRef for str { + #[inline] + fn as_ref(&self) -> &ByteStr { + ByteStr::new(self) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl AsMut<[u8]> for ByteStr { + #[inline] + fn as_mut(&mut self) -> &mut [u8] { + &mut self.0 + } +} + +// `impl AsMut for [u8]` omitted to avoid widespread inference failures + +// `impl Borrow for [u8]` omitted to avoid widespread inference failures + +// `impl Borrow for str` omitted to avoid widespread inference failures + +#[unstable(feature = "bstr", issue = "134915")] +impl Borrow<[u8]> for ByteStr { + #[inline] + fn borrow(&self) -> &[u8] { + &self.0 + } +} + +// `impl BorrowMut for [u8]` omitted to avoid widespread inference failures + +#[unstable(feature = "bstr", issue = "134915")] +impl BorrowMut<[u8]> for ByteStr { + #[inline] + fn borrow_mut(&mut self) -> &mut [u8] { + &mut self.0 + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> Default for &'a ByteStr { + fn default() -> Self { + ByteStr::from_bytes(b"") + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> Default for &'a mut ByteStr { + fn default() -> Self { + ByteStr::from_bytes_mut(&mut []) + } +} + +// Omitted due to inference failures +// +// #[unstable(feature = "bstr", issue = "134915")] +// impl<'a, const N: usize> From<&'a [u8; N]> for &'a ByteStr { +// #[inline] +// fn from(s: &'a [u8; N]) -> Self { +// ByteStr::from_bytes(s) +// } +// } +// +// #[unstable(feature = "bstr", issue = "134915")] +// impl<'a> From<&'a [u8]> for &'a ByteStr { +// #[inline] +// fn from(s: &'a [u8]) -> Self { +// ByteStr::from_bytes(s) +// } +// } + +// Omitted due to slice-from-array-issue-113238: +// +// #[unstable(feature = "bstr", issue = "134915")] +// impl<'a> From<&'a ByteStr> for &'a [u8] { +// #[inline] +// fn from(s: &'a ByteStr) -> Self { +// &s.0 +// } +// } +// +// #[unstable(feature = "bstr", issue = "134915")] +// impl<'a> From<&'a mut ByteStr> for &'a mut [u8] { +// #[inline] +// fn from(s: &'a mut ByteStr) -> Self { +// &mut s.0 +// } +// } + +// Omitted due to inference failures +// +// #[unstable(feature = "bstr", issue = "134915")] +// impl<'a> From<&'a str> for &'a ByteStr { +// #[inline] +// fn from(s: &'a str) -> Self { +// ByteStr::from_bytes(s.as_bytes()) +// } +// } + +#[unstable(feature = "bstr", issue = "134915")] +impl hash::Hash for ByteStr { + #[inline] + fn hash(&self, state: &mut H) { + self.0.hash(state); + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index for ByteStr { + type Output = u8; + + #[inline] + fn index(&self, idx: usize) -> &u8 { + &self.0[idx] + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index for ByteStr { + type Output = ByteStr; + + #[inline] + fn index(&self, _: RangeFull) -> &ByteStr { + self + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index> for ByteStr { + type Output = ByteStr; + + #[inline] + fn index(&self, r: Range) -> &ByteStr { + ByteStr::from_bytes(&self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index> for ByteStr { + type Output = ByteStr; + + #[inline] + fn index(&self, r: RangeInclusive) -> &ByteStr { + ByteStr::from_bytes(&self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index> for ByteStr { + type Output = ByteStr; + + #[inline] + fn index(&self, r: RangeFrom) -> &ByteStr { + ByteStr::from_bytes(&self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index> for ByteStr { + type Output = ByteStr; + + #[inline] + fn index(&self, r: RangeTo) -> &ByteStr { + ByteStr::from_bytes(&self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Index> for ByteStr { + type Output = ByteStr; + + #[inline] + fn index(&self, r: RangeToInclusive) -> &ByteStr { + ByteStr::from_bytes(&self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut for ByteStr { + #[inline] + fn index_mut(&mut self, idx: usize) -> &mut u8 { + &mut self.0[idx] + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut for ByteStr { + #[inline] + fn index_mut(&mut self, _: RangeFull) -> &mut ByteStr { + self + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut> for ByteStr { + #[inline] + fn index_mut(&mut self, r: Range) -> &mut ByteStr { + ByteStr::from_bytes_mut(&mut self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut> for ByteStr { + #[inline] + fn index_mut(&mut self, r: RangeInclusive) -> &mut ByteStr { + ByteStr::from_bytes_mut(&mut self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut> for ByteStr { + #[inline] + fn index_mut(&mut self, r: RangeFrom) -> &mut ByteStr { + ByteStr::from_bytes_mut(&mut self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut> for ByteStr { + #[inline] + fn index_mut(&mut self, r: RangeTo) -> &mut ByteStr { + ByteStr::from_bytes_mut(&mut self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl IndexMut> for ByteStr { + #[inline] + fn index_mut(&mut self, r: RangeToInclusive) -> &mut ByteStr { + ByteStr::from_bytes_mut(&mut self.0[r]) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl Eq for ByteStr {} + +#[unstable(feature = "bstr", issue = "134915")] +impl PartialEq for ByteStr { + #[inline] + fn eq(&self, other: &ByteStr) -> bool { + &self.0 == &other.0 + } +} + +#[doc(hidden)] +#[macro_export] +#[unstable(feature = "bstr_internals", issue = "none")] +macro_rules! impl_partial_eq { + ($lhs:ty, $rhs:ty) => { + #[allow(unused_lifetimes)] + impl<'a> PartialEq<$rhs> for $lhs { + #[inline] + fn eq(&self, other: &$rhs) -> bool { + let other: &[u8] = other.as_ref(); + PartialEq::eq(self.as_bytes(), other) + } + } + + #[allow(unused_lifetimes)] + impl<'a> PartialEq<$lhs> for $rhs { + #[inline] + fn eq(&self, other: &$lhs) -> bool { + let this: &[u8] = self.as_ref(); + PartialEq::eq(this, other.as_bytes()) + } + } + }; +} + +#[doc(hidden)] +#[unstable(feature = "bstr_internals", issue = "none")] +pub use impl_partial_eq; + +#[doc(hidden)] +#[macro_export] +#[unstable(feature = "bstr_internals", issue = "none")] +macro_rules! impl_partial_eq_ord { + ($lhs:ty, $rhs:ty) => { + $crate::bstr::impl_partial_eq!($lhs, $rhs); + + #[allow(unused_lifetimes)] + #[unstable(feature = "bstr", issue = "134915")] + impl<'a> PartialOrd<$rhs> for $lhs { + #[inline] + fn partial_cmp(&self, other: &$rhs) -> Option { + let other: &[u8] = other.as_ref(); + PartialOrd::partial_cmp(self.as_bytes(), other) + } + } + + #[allow(unused_lifetimes)] + #[unstable(feature = "bstr", issue = "134915")] + impl<'a> PartialOrd<$lhs> for $rhs { + #[inline] + fn partial_cmp(&self, other: &$lhs) -> Option { + let this: &[u8] = self.as_ref(); + PartialOrd::partial_cmp(this, other.as_bytes()) + } + } + }; +} + +#[doc(hidden)] +#[unstable(feature = "bstr_internals", issue = "none")] +pub use impl_partial_eq_ord; + +#[doc(hidden)] +#[macro_export] +#[unstable(feature = "bstr_internals", issue = "none")] +macro_rules! impl_partial_eq_n { + ($lhs:ty, $rhs:ty) => { + #[allow(unused_lifetimes)] + #[unstable(feature = "bstr", issue = "134915")] + impl PartialEq<$rhs> for $lhs { + #[inline] + fn eq(&self, other: &$rhs) -> bool { + let other: &[u8] = other.as_ref(); + PartialEq::eq(self.as_bytes(), other) + } + } + + #[allow(unused_lifetimes)] + #[unstable(feature = "bstr", issue = "134915")] + impl PartialEq<$lhs> for $rhs { + #[inline] + fn eq(&self, other: &$lhs) -> bool { + let this: &[u8] = self.as_ref(); + PartialEq::eq(this, other.as_bytes()) + } + } + }; +} + +#[doc(hidden)] +#[unstable(feature = "bstr_internals", issue = "none")] +pub use impl_partial_eq_n; + +// PartialOrd with `[u8]` omitted to avoid inference failures +impl_partial_eq!(ByteStr, [u8]); +// PartialOrd with `&[u8]` omitted to avoid inference failures +impl_partial_eq!(ByteStr, &[u8]); +// PartialOrd with `str` omitted to avoid inference failures +impl_partial_eq!(ByteStr, str); +// PartialOrd with `&str` omitted to avoid inference failures +impl_partial_eq!(ByteStr, &str); +// PartialOrd with `[u8; N]` omitted to avoid inference failures +impl_partial_eq_n!(ByteStr, [u8; N]); +// PartialOrd with `[u8; N]` omitted to avoid inference failures +impl_partial_eq_n!(ByteStr, &[u8; N]); + +#[unstable(feature = "bstr", issue = "134915")] +impl Ord for ByteStr { + #[inline] + fn cmp(&self, other: &ByteStr) -> Ordering { + Ord::cmp(&self.0, &other.0) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl PartialOrd for ByteStr { + #[inline] + fn partial_cmp(&self, other: &ByteStr) -> Option { + PartialOrd::partial_cmp(&self.0, &other.0) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> TryFrom<&'a ByteStr> for &'a str { + type Error = crate::str::Utf8Error; + + #[inline] + fn try_from(s: &'a ByteStr) -> Result { + crate::str::from_utf8(&s.0) + } +} + +#[unstable(feature = "bstr", issue = "134915")] +impl<'a> TryFrom<&'a mut ByteStr> for &'a mut str { + type Error = crate::str::Utf8Error; + + #[inline] + fn try_from(s: &'a mut ByteStr) -> Result { + crate::str::from_utf8_mut(&mut s.0) + } +} diff --git a/core/src/cell.rs b/core/src/cell.rs index bfd2a71f97b2c..cbf00106c5173 100644 --- a/core/src/cell.rs +++ b/core/src/cell.rs @@ -22,8 +22,8 @@ //! (mutable via `&T`), in contrast with typical Rust types that exhibit 'inherited mutability' //! (mutable only via `&mut T`). //! -//! Cell types come in three flavors: `Cell`, `RefCell`, and `OnceCell`. Each provides -//! a different way of providing safe interior mutability. +//! Cell types come in four flavors: `Cell`, `RefCell`, `OnceCell`, and `LazyCell`. +//! Each provides a different way of providing safe interior mutability. //! //! ## `Cell` //! @@ -252,7 +252,7 @@ use crate::cmp::Ordering; use crate::fmt::{self, Debug, Display}; -use crate::marker::{PhantomData, Unsize}; +use crate::marker::{PhantomData, PointerLike, Unsize}; use crate::mem; use crate::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn}; use crate::pin::PinCoerceUnsized; @@ -587,7 +587,7 @@ impl Cell { #[inline] #[stable(feature = "cell_as_ptr", since = "1.12.0")] #[rustc_const_stable(feature = "const_cell_as_ptr", since = "1.32.0")] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[rustc_never_returns_null_ptr] pub const fn as_ptr(&self) -> *mut T { self.value.get() @@ -677,6 +677,9 @@ impl, U> CoerceUnsized> for Cell {} #[unstable(feature = "dispatch_from_dyn", issue = "none")] impl, U> DispatchFromDyn> for Cell {} +#[unstable(feature = "pointer_like_trait", issue = "none")] +impl PointerLike for Cell {} + impl Cell<[T]> { /// Returns a `&[Cell]` from a `&Cell<[T]>` /// @@ -713,7 +716,6 @@ impl Cell<[T; N]> { /// let array_cell: &[Cell; 3] = cell_array.as_array_of_cells(); /// ``` #[unstable(feature = "as_array_of_cells", issue = "88248")] - #[rustc_const_unstable(feature = "as_array_of_cells", issue = "88248")] pub const fn as_array_of_cells(&self) -> &[Cell; N] { // SAFETY: `Cell` has the same memory layout as `T`. unsafe { &*(self as *const Cell<[T; N]> as *const [Cell; N]) } @@ -1150,7 +1152,7 @@ impl RefCell { /// ``` #[inline] #[stable(feature = "cell_as_ptr", since = "1.12.0")] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[rustc_never_returns_null_ptr] pub fn as_ptr(&self) -> *mut T { self.value.get() @@ -1588,10 +1590,10 @@ impl<'b, T: ?Sized> Ref<'b, T> { { let (a, b) = f(&*orig); let borrow = orig.borrow.clone(); - (Ref { value: NonNull::from(a), borrow }, Ref { - value: NonNull::from(b), - borrow: orig.borrow, - }) + ( + Ref { value: NonNull::from(a), borrow }, + Ref { value: NonNull::from(b), borrow: orig.borrow }, + ) } /// Converts into a reference to the underlying data. @@ -1756,11 +1758,10 @@ impl<'b, T: ?Sized> RefMut<'b, T> { { let borrow = orig.borrow.clone(); let (a, b) = f(&mut *orig); - (RefMut { value: NonNull::from(a), borrow, marker: PhantomData }, RefMut { - value: NonNull::from(b), - borrow: orig.borrow, - marker: PhantomData, - }) + ( + RefMut { value: NonNull::from(a), borrow, marker: PhantomData }, + RefMut { value: NonNull::from(b), borrow: orig.borrow, marker: PhantomData }, + ) } /// Converts into a mutable reference to the underlying data. @@ -2116,6 +2117,35 @@ impl UnsafeCell { pub const fn into_inner(self) -> T { self.value } + + /// Replace the value in this `UnsafeCell` and return the old value. + /// + /// # Safety + /// + /// The caller must take care to avoid aliasing and data races. + /// + /// - It is Undefined Behavior to allow calls to race with + /// any other access to the wrapped value. + /// - It is Undefined Behavior to call this while any other + /// reference(s) to the wrapped value are alive. + /// + /// # Examples + /// + /// ``` + /// #![feature(unsafe_cell_access)] + /// use std::cell::UnsafeCell; + /// + /// let uc = UnsafeCell::new(5); + /// + /// let old = unsafe { uc.replace(10) }; + /// assert_eq!(old, 5); + /// ``` + #[inline] + #[unstable(feature = "unsafe_cell_access", issue = "136327")] + pub const unsafe fn replace(&self, value: T) -> T { + // SAFETY: pointer comes from `&self` so naturally satisfies invariants. + unsafe { ptr::replace(self.get(), value) } + } } impl UnsafeCell { @@ -2133,9 +2163,8 @@ impl UnsafeCell { /// assert_eq!(*uc.get_mut(), 41); /// ``` #[inline(always)] - #[stable(feature = "unsafe_cell_from_mut", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "unsafe_cell_from_mut", since = "CURRENT_RUSTC_VERSION")] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))] + #[stable(feature = "unsafe_cell_from_mut", since = "1.84.0")] + #[rustc_const_stable(feature = "unsafe_cell_from_mut", since = "1.84.0")] pub const fn from_mut(value: &mut T) -> &mut UnsafeCell { // SAFETY: `UnsafeCell` has the same memory layout as `T` due to #[repr(transparent)]. unsafe { &mut *(value as *mut T as *mut UnsafeCell) } @@ -2160,7 +2189,7 @@ impl UnsafeCell { #[inline(always)] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_unsafecell_get", since = "1.32.0")] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[rustc_never_returns_null_ptr] pub const fn get(&self) -> *mut T { // We can just cast the pointer from `UnsafeCell` to `T` because of @@ -2229,6 +2258,61 @@ impl UnsafeCell { // no guarantee for user code that this will work in future versions of the compiler! this as *const T as *mut T } + + /// Get a shared reference to the value within the `UnsafeCell`. + /// + /// # Safety + /// + /// - It is Undefined Behavior to call this while any mutable + /// reference to the wrapped value is alive. + /// - Mutating the wrapped value while the returned + /// reference is alive is Undefined Behavior. + /// + /// # Examples + /// + /// ``` + /// #![feature(unsafe_cell_access)] + /// use std::cell::UnsafeCell; + /// + /// let uc = UnsafeCell::new(5); + /// + /// let val = unsafe { uc.as_ref_unchecked() }; + /// assert_eq!(val, &5); + /// ``` + #[inline] + #[unstable(feature = "unsafe_cell_access", issue = "136327")] + pub const unsafe fn as_ref_unchecked(&self) -> &T { + // SAFETY: pointer comes from `&self` so naturally satisfies ptr-to-ref invariants. + unsafe { self.get().as_ref_unchecked() } + } + + /// Get an exclusive reference to the value within the `UnsafeCell`. + /// + /// # Safety + /// + /// - It is Undefined Behavior to call this while any other + /// reference(s) to the wrapped value are alive. + /// - Mutating the wrapped value through other means while the + /// returned reference is alive is Undefined Behavior. + /// + /// # Examples + /// + /// ``` + /// #![feature(unsafe_cell_access)] + /// use std::cell::UnsafeCell; + /// + /// let uc = UnsafeCell::new(5); + /// + /// unsafe { *uc.as_mut_unchecked() += 1; } + /// assert_eq!(uc.into_inner(), 6); + /// ``` + #[inline] + #[unstable(feature = "unsafe_cell_access", issue = "136327")] + #[allow(clippy::mut_from_ref)] + pub const unsafe fn as_mut_unchecked(&self) -> &mut T { + // SAFETY: pointer comes from `&self` so naturally satisfies ptr-to-ref invariants. + unsafe { self.get().as_mut_unchecked() } + } } #[stable(feature = "unsafe_cell_default", since = "1.10.0")] @@ -2260,6 +2344,9 @@ impl, U> CoerceUnsized> for UnsafeCell {} #[unstable(feature = "dispatch_from_dyn", issue = "none")] impl, U> DispatchFromDyn> for UnsafeCell {} +#[unstable(feature = "pointer_like_trait", issue = "none")] +impl PointerLike for UnsafeCell {} + /// [`UnsafeCell`], but [`Sync`]. /// /// This is just an `UnsafeCell`, except it implements `Sync` @@ -2308,7 +2395,7 @@ impl SyncUnsafeCell { /// when casting to `&mut T`, and ensure that there are no mutations /// or mutable aliases going on when casting to `&T` #[inline] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[rustc_never_returns_null_ptr] pub const fn get(&self) -> *mut T { self.value.get() @@ -2366,6 +2453,9 @@ impl, U> CoerceUnsized> for SyncUnsafeCell //#[unstable(feature = "sync_unsafe_cell", issue = "95439")] impl, U> DispatchFromDyn> for SyncUnsafeCell {} +#[unstable(feature = "pointer_like_trait", issue = "none")] +impl PointerLike for SyncUnsafeCell {} + #[allow(unused)] fn assert_coerce_unsized( a: UnsafeCell<&i32>, diff --git a/core/src/cell/lazy.rs b/core/src/cell/lazy.rs index 5ac33516684d7..84cbbc71f40ae 100644 --- a/core/src/cell/lazy.rs +++ b/core/src/cell/lazy.rs @@ -219,7 +219,7 @@ impl T> LazyCell { } impl LazyCell { - /// Returns a reference to the value if initialized, or `None` if not. + /// Returns a mutable reference to the value if initialized, or `None` if not. /// /// # Examples /// @@ -245,7 +245,7 @@ impl LazyCell { } } - /// Returns a mutable reference to the value if initialized, or `None` if not. + /// Returns a reference to the value if initialized, or `None` if not. /// /// # Examples /// diff --git a/core/src/cell/once.rs b/core/src/cell/once.rs index c14afe0f4761c..c6c96571d33c9 100644 --- a/core/src/cell/once.rs +++ b/core/src/cell/once.rs @@ -8,6 +8,9 @@ use crate::{fmt, mem}; /// only immutable references can be obtained unless one has a mutable reference to the cell /// itself. In the same vein, the cell can only be re-initialized with such a mutable reference. /// +/// A `OnceCell` can be thought of as a safe abstraction over uninitialized data that becomes +/// initialized once written. +/// /// For a thread-safe version of this struct, see [`std::sync::OnceLock`]. /// /// [`RefCell`]: crate::cell::RefCell @@ -35,7 +38,7 @@ pub struct OnceCell { } impl OnceCell { - /// Creates a new empty cell. + /// Creates a new uninitialized cell. #[inline] #[must_use] #[stable(feature = "once_cell", since = "1.70.0")] @@ -46,7 +49,7 @@ impl OnceCell { /// Gets the reference to the underlying value. /// - /// Returns `None` if the cell is empty. + /// Returns `None` if the cell is uninitialized. #[inline] #[stable(feature = "once_cell", since = "1.70.0")] pub fn get(&self) -> Option<&T> { @@ -56,19 +59,19 @@ impl OnceCell { /// Gets the mutable reference to the underlying value. /// - /// Returns `None` if the cell is empty. + /// Returns `None` if the cell is uninitialized. #[inline] #[stable(feature = "once_cell", since = "1.70.0")] pub fn get_mut(&mut self) -> Option<&mut T> { self.inner.get_mut().as_mut() } - /// Sets the contents of the cell to `value`. + /// Initializes the contents of the cell to `value`. /// /// # Errors /// - /// This method returns `Ok(())` if the cell was empty and `Err(value)` if - /// it was full. + /// This method returns `Ok(())` if the cell was uninitialized + /// and `Err(value)` if it was already initialized. /// /// # Examples /// @@ -92,13 +95,13 @@ impl OnceCell { } } - /// Sets the contents of the cell to `value` if the cell was empty, then - /// returns a reference to it. + /// Initializes the contents of the cell to `value` if the cell was + /// uninitialized, then returns a reference to it. /// /// # Errors /// - /// This method returns `Ok(&value)` if the cell was empty and - /// `Err(¤t_value, value)` if it was full. + /// This method returns `Ok(&value)` if the cell was uninitialized + /// and `Err((¤t_value, value))` if it was already initialized. /// /// # Examples /// @@ -130,12 +133,12 @@ impl OnceCell { Ok(slot.insert(value)) } - /// Gets the contents of the cell, initializing it with `f` - /// if the cell was empty. + /// Gets the contents of the cell, initializing it to `f()` + /// if the cell was uninitialized. /// /// # Panics /// - /// If `f` panics, the panic is propagated to the caller, and the cell + /// If `f()` panics, the panic is propagated to the caller, and the cell /// remains uninitialized. /// /// It is an error to reentrantly initialize the cell from `f`. Doing @@ -164,11 +167,11 @@ impl OnceCell { } /// Gets the mutable reference of the contents of the cell, - /// initializing it with `f` if the cell was empty. + /// initializing it to `f()` if the cell was uninitialized. /// /// # Panics /// - /// If `f` panics, the panic is propagated to the caller, and the cell + /// If `f()` panics, the panic is propagated to the caller, and the cell /// remains uninitialized. /// /// # Examples @@ -199,13 +202,13 @@ impl OnceCell { } } - /// Gets the contents of the cell, initializing it with `f` if - /// the cell was empty. If the cell was empty and `f` failed, an - /// error is returned. + /// Gets the contents of the cell, initializing it to `f()` if + /// the cell was uninitialized. If the cell was uninitialized + /// and `f()` failed, an error is returned. /// /// # Panics /// - /// If `f` panics, the panic is propagated to the caller, and the cell + /// If `f()` panics, the panic is propagated to the caller, and the cell /// remains uninitialized. /// /// It is an error to reentrantly initialize the cell from `f`. Doing @@ -239,12 +242,12 @@ impl OnceCell { } /// Gets the mutable reference of the contents of the cell, initializing - /// it with `f` if the cell was empty. If the cell was empty and `f` failed, - /// an error is returned. + /// it to `f()` if the cell was uninitialized. If the cell was uninitialized + /// and `f()` failed, an error is returned. /// /// # Panics /// - /// If `f` panics, the panic is propagated to the caller, and the cell + /// If `f()` panics, the panic is propagated to the caller, and the cell /// remains uninitialized. /// /// # Examples @@ -256,13 +259,15 @@ impl OnceCell { /// /// let mut cell: OnceCell = OnceCell::new(); /// - /// // Failed initializers do not change the value + /// // Failed attempts to initialize the cell do not change its contents /// assert!(cell.get_mut_or_try_init(|| "not a number!".parse()).is_err()); /// assert!(cell.get().is_none()); /// /// let value = cell.get_mut_or_try_init(|| "1234".parse()); /// assert_eq!(value, Ok(&mut 1234)); - /// *value.unwrap() += 2; + /// + /// let Ok(value) = value else { return; }; + /// *value += 2; /// assert_eq!(cell.get(), Some(&1236)) /// ``` #[unstable(feature = "once_cell_get_mut", issue = "121641")] @@ -293,7 +298,7 @@ impl OnceCell { /// Consumes the cell, returning the wrapped value. /// - /// Returns `None` if the cell was empty. + /// Returns `None` if the cell was uninitialized. /// /// # Examples /// @@ -304,8 +309,8 @@ impl OnceCell { /// assert_eq!(cell.into_inner(), None); /// /// let cell = OnceCell::new(); - /// cell.set("hello".to_string()).unwrap(); - /// assert_eq!(cell.into_inner(), Some("hello".to_string())); + /// let _ = cell.set("hello".to_owned()); + /// assert_eq!(cell.into_inner(), Some("hello".to_owned())); /// ``` #[inline] #[stable(feature = "once_cell", since = "1.70.0")] @@ -319,7 +324,7 @@ impl OnceCell { /// Takes the value out of this `OnceCell`, moving it back to an uninitialized state. /// - /// Has no effect and returns `None` if the `OnceCell` hasn't been initialized. + /// Has no effect and returns `None` if the `OnceCell` is uninitialized. /// /// Safety is guaranteed by requiring a mutable reference. /// @@ -332,8 +337,8 @@ impl OnceCell { /// assert_eq!(cell.take(), None); /// /// let mut cell = OnceCell::new(); - /// cell.set("hello".to_string()).unwrap(); - /// assert_eq!(cell.take(), Some("hello".to_string())); + /// let _ = cell.set("hello".to_owned()); + /// assert_eq!(cell.take(), Some("hello".to_owned())); /// assert_eq!(cell.get(), None); /// ``` #[inline] diff --git a/core/src/char/convert.rs b/core/src/char/convert.rs index 73ab4f1e52ade..ac808038f8900 100644 --- a/core/src/char/convert.rs +++ b/core/src/char/convert.rs @@ -40,11 +40,9 @@ impl From for u32 { /// # Examples /// /// ``` - /// use std::mem; - /// /// let c = 'c'; /// let u = u32::from(c); - /// assert!(4 == mem::size_of_val(&u)) + /// assert!(4 == size_of_val(&u)) /// ``` #[inline] fn from(c: char) -> Self { @@ -59,11 +57,9 @@ impl From for u64 { /// # Examples /// /// ``` - /// use std::mem; - /// /// let c = '👤'; /// let u = u64::from(c); - /// assert!(8 == mem::size_of_val(&u)) + /// assert!(8 == size_of_val(&u)) /// ``` #[inline] fn from(c: char) -> Self { @@ -80,11 +76,9 @@ impl From for u128 { /// # Examples /// /// ``` - /// use std::mem; - /// /// let c = '⚙'; /// let u = u128::from(c); - /// assert!(16 == mem::size_of_val(&u)) + /// assert!(16 == size_of_val(&u)) /// ``` #[inline] fn from(c: char) -> Self { @@ -167,11 +161,9 @@ impl From for char { /// # Examples /// /// ``` - /// use std::mem; - /// /// let u = 32 as u8; /// let c = char::from(u); - /// assert!(4 == mem::size_of_val(&c)) + /// assert!(4 == size_of_val(&c)) /// ``` #[inline] fn from(i: u8) -> Self { diff --git a/core/src/char/methods.rs b/core/src/char/methods.rs index 974e7baccf7bc..bb71af339b818 100644 --- a/core/src/char/methods.rs +++ b/core/src/char/methods.rs @@ -71,6 +71,16 @@ impl char { #[stable(feature = "assoc_char_consts", since = "1.52.0")] pub const MAX: char = '\u{10FFFF}'; + /// The maximum number of bytes required to [encode](char::encode_utf8) a `char` to + /// UTF-8 encoding. + #[unstable(feature = "char_max_len", issue = "121714")] + pub const MAX_LEN_UTF8: usize = 4; + + /// The maximum number of two-byte units required to [encode](char::encode_utf16) a `char` + /// to UTF-16 encoding. + #[unstable(feature = "char_max_len", issue = "121714")] + pub const MAX_LEN_UTF16: usize = 2; + /// `U+FFFD REPLACEMENT CHARACTER` (�) is used in Unicode to represent a /// decoding error. /// @@ -92,7 +102,7 @@ impl char { #[stable(feature = "assoc_char_consts", since = "1.52.0")] pub const UNICODE_VERSION: (u8, u8, u8) = crate::unicode::UNICODE_VERSION; - /// Creates an iterator over the UTF-16 encoded code points in `iter`, + /// Creates an iterator over the native endian UTF-16 encoded code points in `iter`, /// returning unpaired surrogates as `Err`s. /// /// # Examples @@ -327,7 +337,7 @@ impl char { /// '1'.is_digit(1); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_char_classify", issue = "132241")] + #[rustc_const_stable(feature = "const_char_classify", since = "CURRENT_RUSTC_VERSION")] #[inline] pub const fn is_digit(self, radix: u32) -> bool { self.to_digit(radix).is_some() @@ -394,17 +404,21 @@ impl char { ); // check radix to remove letter handling code when radix is a known constant let value = if self > '9' && radix > 10 { - // convert ASCII letters to lowercase - let lower = self as u32 | 0x20; - // convert an ASCII letter to the corresponding value, - // non-letters convert to values > 36 - lower.wrapping_sub('a' as u32) as u64 + 10 + // mask to convert ASCII letters to uppercase + const TO_UPPERCASE_MASK: u32 = !0b0010_0000; + // Converts an ASCII letter to its corresponding integer value: + // A-Z => 10-35, a-z => 10-35. Other characters produce values >= 36. + // + // Add Overflow Safety: + // By applying the mask after the subtraction, the first addendum is + // constrained such that it never exceeds u32::MAX - 0x20. + ((self as u32).wrapping_sub('A' as u32) & TO_UPPERCASE_MASK) + 10 } else { // convert digit to value, non-digits wrap to values > 36 - (self as u32).wrapping_sub('0' as u32) as u64 + (self as u32).wrapping_sub('0' as u32) }; // FIXME(const-hack): once then_some is const fn, use it here - if value < radix as u64 { Some(value as u32) } else { None } + if value < radix { Some(value) } else { None } } /// Returns an iterator that yields the hexadecimal Unicode escape of a @@ -700,7 +714,7 @@ impl char { unsafe { from_utf8_unchecked_mut(encode_utf8_raw(self as u32, dst)) } } - /// Encodes this character as UTF-16 into the provided `u16` buffer, + /// Encodes this character as native endian UTF-16 into the provided `u16` buffer, /// and then returns the subslice of the buffer that contains the encoded character. /// /// # Panics @@ -729,7 +743,7 @@ impl char { /// '𝕊'.encode_utf16(&mut b); /// ``` #[stable(feature = "unicode_encode_char", since = "1.15.0")] - #[rustc_const_stable(feature = "const_char_encode_utf16", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_char_encode_utf16", since = "1.84.0")] #[inline] pub const fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16] { encode_utf16_raw(self as u32, dst) @@ -872,7 +886,7 @@ impl char { /// ``` #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_char_classify", issue = "132241")] + #[rustc_const_stable(feature = "const_char_classify", since = "CURRENT_RUSTC_VERSION")] #[inline] pub const fn is_whitespace(self) -> bool { match self { @@ -1164,6 +1178,7 @@ impl char { #[must_use] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] #[rustc_const_stable(feature = "const_char_is_ascii", since = "1.32.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "char_is_ascii")] #[inline] pub const fn is_ascii(&self) -> bool { *self as u32 <= 0x7F @@ -1299,7 +1314,7 @@ impl char { /// /// [`to_ascii_uppercase()`]: #method.to_ascii_uppercase #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] - #[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_make_ascii", since = "1.84.0")] #[inline] pub const fn make_ascii_uppercase(&mut self) { *self = self.to_ascii_uppercase(); @@ -1325,7 +1340,7 @@ impl char { /// /// [`to_ascii_lowercase()`]: #method.to_ascii_lowercase #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] - #[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_make_ascii", since = "1.84.0")] #[inline] pub const fn make_ascii_lowercase(&mut self) { *self = self.to_ascii_lowercase(); @@ -1787,7 +1802,6 @@ const fn len_utf16(code: u32) -> usize { /// Panics if the buffer is not large enough. /// A buffer of length four is large enough to encode any `char`. #[unstable(feature = "char_internals", reason = "exposed only for libstd", issue = "none")] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_char_encode_utf8", since = "1.83.0"))] #[doc(hidden)] #[inline] pub const fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> &mut [u8] { @@ -1825,7 +1839,7 @@ pub const fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> &mut [u8] { unsafe { slice::from_raw_parts_mut(dst.as_mut_ptr(), len) } } -/// Encodes a raw `u32` value as UTF-16 into the provided `u16` buffer, +/// Encodes a raw `u32` value as native endian UTF-16 into the provided `u16` buffer, /// and then returns the subslice of the buffer that contains the encoded character. /// /// Unlike `char::encode_utf16`, this method also handles codepoints in the surrogate range. @@ -1836,10 +1850,6 @@ pub const fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> &mut [u8] { /// Panics if the buffer is not large enough. /// A buffer of length 2 is large enough to encode any `char`. #[unstable(feature = "char_internals", reason = "exposed only for libstd", issue = "none")] -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_char_encode_utf16", since = "CURRENT_RUSTC_VERSION") -)] #[doc(hidden)] #[inline] pub const fn encode_utf16_raw(mut code: u32, dst: &mut [u16]) -> &mut [u16] { diff --git a/core/src/char/mod.rs b/core/src/char/mod.rs index 59fd7250e8f8e..088c709f1a2af 100644 --- a/core/src/char/mod.rs +++ b/core/src/char/mod.rs @@ -95,6 +95,16 @@ const MAX_THREE_B: u32 = 0x10000; #[stable(feature = "rust1", since = "1.0.0")] pub const MAX: char = char::MAX; +/// The maximum number of bytes required to [encode](char::encode_utf8) a `char` to +/// UTF-8 encoding. +#[unstable(feature = "char_max_len", issue = "121714")] +pub const MAX_LEN_UTF8: usize = char::MAX_LEN_UTF8; + +/// The maximum number of two-byte units required to [encode](char::encode_utf16) a `char` +/// to UTF-16 encoding. +#[unstable(feature = "char_max_len", issue = "121714")] +pub const MAX_LEN_UTF16: usize = char::MAX_LEN_UTF16; + /// `U+FFFD REPLACEMENT CHARACTER` (�) is used in Unicode to represent a /// decoding error. Use [`char::REPLACEMENT_CHARACTER`] instead. #[stable(feature = "decode_utf16", since = "1.9.0")] diff --git a/core/src/clone.rs b/core/src/clone.rs index ec1aed53eaf72..c777dd995a656 100644 --- a/core/src/clone.rs +++ b/core/src/clone.rs @@ -184,6 +184,59 @@ pub macro Clone($item:item) { /* compiler built-in */ } +/// Trait for objects whose [`Clone`] impl is lightweight (e.g. reference-counted) +/// +/// Cloning an object implementing this trait should in general: +/// - be O(1) (constant) time regardless of the amount of data managed by the object, +/// - not require a memory allocation, +/// - not require copying more than roughly 64 bytes (a typical cache line size), +/// - not block the current thread, +/// - not have any semantic side effects (e.g. allocating a file descriptor), and +/// - not have overhead larger than a couple of atomic operations. +/// +/// The `UseCloned` trait does not provide a method; instead, it indicates that +/// `Clone::clone` is lightweight, and allows the use of the `.use` syntax. +/// +/// ## .use postfix syntax +/// +/// Values can be `.use`d by adding `.use` postfix to the value you want to use. +/// +/// ```ignore (this won't work until we land use) +/// fn foo(f: Foo) { +/// // if `Foo` implements `Copy` f would be copied into x. +/// // if `Foo` implements `UseCloned` f would be cloned into x. +/// // otherwise f would be moved into x. +/// let x = f.use; +/// // ... +/// } +/// ``` +/// +/// ## use closures +/// +/// Use closures allow captured values to be automatically used. +/// This is similar to have a closure that you would call `.use` over each captured value. +#[unstable(feature = "ergonomic_clones", issue = "132290")] +#[cfg_attr(not(bootstrap), lang = "use_cloned")] +pub trait UseCloned: Clone { + // Empty. +} + +macro_rules! impl_use_cloned { + ($($t:ty)*) => { + $( + #[unstable(feature = "ergonomic_clones", issue = "132290")] + impl UseCloned for $t {} + )* + } +} + +impl_use_cloned! { + usize u8 u16 u32 u64 u128 + isize i8 i16 i32 i64 i128 + f16 f32 f64 f128 + bool char +} + // FIXME(aburka): these structs are used solely by #[derive] to // assert that every component of a type implements Clone or Copy. // @@ -244,8 +297,8 @@ pub unsafe trait CloneToUninit { /// /// Behavior is undefined if any of the following conditions are violated: /// - /// * `dst` must be [valid] for writes for `std::mem::size_of_val(self)` bytes. - /// * `dst` must be properly aligned to `std::mem::align_of_val(self)`. + /// * `dst` must be [valid] for writes for `size_of_val(self)` bytes. + /// * `dst` must be properly aligned to `align_of_val(self)`. /// /// [valid]: crate::ptr#safety /// [pointer metadata]: crate::ptr::metadata() @@ -311,6 +364,16 @@ unsafe impl CloneToUninit for crate::ffi::CStr { } } +#[unstable(feature = "bstr", issue = "134915")] +unsafe impl CloneToUninit for crate::bstr::ByteStr { + #[inline] + #[cfg_attr(debug_assertions, track_caller)] + unsafe fn clone_to_uninit(&self, dst: *mut u8) { + // SAFETY: ByteStr is a `#[repr(transparent)]` wrapper around `[u8]` + unsafe { self.as_bytes().clone_to_uninit(dst) } + } +} + /// Implementations of `Clone` for primitive types. /// /// Implementations that cannot be described in Rust diff --git a/core/src/cmp.rs b/core/src/cmp.rs index 5a3b9365cd220..b29251b4b436c 100644 --- a/core/src/cmp.rs +++ b/core/src/cmp.rs @@ -397,6 +397,12 @@ pub enum Ordering { } impl Ordering { + #[inline] + const fn as_raw(self) -> i8 { + // FIXME(const-hack): just use `PartialOrd` against `Equal` once that's const + crate::intrinsics::discriminant_value(&self) + } + /// Returns `true` if the ordering is the `Equal` variant. /// /// # Examples @@ -413,7 +419,11 @@ impl Ordering { #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_eq(self) -> bool { - matches!(self, Equal) + // All the `is_*` methods are implemented as comparisons against zero + // to follow how clang's libcxx implements their equivalents in + // + + self.as_raw() == 0 } /// Returns `true` if the ordering is not the `Equal` variant. @@ -432,7 +442,7 @@ impl Ordering { #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_ne(self) -> bool { - !matches!(self, Equal) + self.as_raw() != 0 } /// Returns `true` if the ordering is the `Less` variant. @@ -451,7 +461,7 @@ impl Ordering { #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_lt(self) -> bool { - matches!(self, Less) + self.as_raw() < 0 } /// Returns `true` if the ordering is the `Greater` variant. @@ -470,7 +480,7 @@ impl Ordering { #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_gt(self) -> bool { - matches!(self, Greater) + self.as_raw() > 0 } /// Returns `true` if the ordering is either the `Less` or `Equal` variant. @@ -489,7 +499,7 @@ impl Ordering { #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_le(self) -> bool { - !matches!(self, Greater) + self.as_raw() <= 0 } /// Returns `true` if the ordering is either the `Greater` or `Equal` variant. @@ -508,7 +518,7 @@ impl Ordering { #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_ge(self) -> bool { - !matches!(self, Less) + self.as_raw() >= 0 } /// Reverses the `Ordering`. @@ -796,7 +806,7 @@ impl Clone for Reverse { /// } /// /// impl Ord for Character { -/// fn cmp(&self, other: &Self) -> std::cmp::Ordering { +/// fn cmp(&self, other: &Self) -> Ordering { /// self.experience /// .cmp(&other.experience) /// .then(self.health.cmp(&other.health)) @@ -973,6 +983,24 @@ pub trait Ord: Eq + PartialOrd { /// assert_eq!(1.max(2), 2); /// assert_eq!(2.max(2), 2); /// ``` + /// ``` + /// use std::cmp::Ordering; + /// + /// #[derive(Eq)] + /// struct Equal(&'static str); + /// + /// impl PartialEq for Equal { + /// fn eq(&self, other: &Self) -> bool { true } + /// } + /// impl PartialOrd for Equal { + /// fn partial_cmp(&self, other: &Self) -> Option { Some(Ordering::Equal) } + /// } + /// impl Ord for Equal { + /// fn cmp(&self, other: &Self) -> Ordering { Ordering::Equal } + /// } + /// + /// assert_eq!(Equal("self").max(Equal("other")).0, "other"); + /// ``` #[stable(feature = "ord_max_min", since = "1.21.0")] #[inline] #[must_use] @@ -981,7 +1009,7 @@ pub trait Ord: Eq + PartialOrd { where Self: Sized, { - max_by(self, other, Ord::cmp) + if other < self { self } else { other } } /// Compares and returns the minimum of two values. @@ -994,6 +1022,24 @@ pub trait Ord: Eq + PartialOrd { /// assert_eq!(1.min(2), 1); /// assert_eq!(2.min(2), 2); /// ``` + /// ``` + /// use std::cmp::Ordering; + /// + /// #[derive(Eq)] + /// struct Equal(&'static str); + /// + /// impl PartialEq for Equal { + /// fn eq(&self, other: &Self) -> bool { true } + /// } + /// impl PartialOrd for Equal { + /// fn partial_cmp(&self, other: &Self) -> Option { Some(Ordering::Equal) } + /// } + /// impl Ord for Equal { + /// fn cmp(&self, other: &Self) -> Ordering { Ordering::Equal } + /// } + /// + /// assert_eq!(Equal("self").min(Equal("other")).0, "self"); + /// ``` #[stable(feature = "ord_max_min", since = "1.21.0")] #[inline] #[must_use] @@ -1002,7 +1048,7 @@ pub trait Ord: Eq + PartialOrd { where Self: Sized, { - min_by(self, other, Ord::cmp) + if other < self { other } else { self } } /// Restrict a value to a certain interval. @@ -1333,7 +1379,7 @@ pub trait PartialOrd: PartialEq { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_lt"] fn lt(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Less)) + self.partial_cmp(other).is_some_and(Ordering::is_lt) } /// Tests less than or equal to (for `self` and `other`) and is used by the @@ -1351,7 +1397,7 @@ pub trait PartialOrd: PartialEq { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_le"] fn le(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Less | Equal)) + self.partial_cmp(other).is_some_and(Ordering::is_le) } /// Tests greater than (for `self` and `other`) and is used by the `>` @@ -1369,7 +1415,7 @@ pub trait PartialOrd: PartialEq { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_gt"] fn gt(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Greater)) + self.partial_cmp(other).is_some_and(Ordering::is_gt) } /// Tests greater than or equal to (for `self` and `other`) and is used by @@ -1387,7 +1433,7 @@ pub trait PartialOrd: PartialEq { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_ge"] fn ge(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Greater | Equal)) + self.partial_cmp(other).is_some_and(Ordering::is_ge) } } @@ -1414,6 +1460,24 @@ pub macro PartialOrd($item:item) { /// assert_eq!(cmp::min(1, 2), 1); /// assert_eq!(cmp::min(2, 2), 2); /// ``` +/// ``` +/// use std::cmp::{self, Ordering}; +/// +/// #[derive(Eq)] +/// struct Equal(&'static str); +/// +/// impl PartialEq for Equal { +/// fn eq(&self, other: &Self) -> bool { true } +/// } +/// impl PartialOrd for Equal { +/// fn partial_cmp(&self, other: &Self) -> Option { Some(Ordering::Equal) } +/// } +/// impl Ord for Equal { +/// fn cmp(&self, other: &Self) -> Ordering { Ordering::Equal } +/// } +/// +/// assert_eq!(cmp::min(Equal("v1"), Equal("v2")).0, "v1"); +/// ``` #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] @@ -1431,20 +1495,22 @@ pub fn min(v1: T, v2: T) -> T { /// ``` /// use std::cmp; /// -/// let result = cmp::min_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs())); -/// assert_eq!(result, 1); +/// let abs_cmp = |x: &i32, y: &i32| x.abs().cmp(&y.abs()); /// -/// let result = cmp::min_by(-2, 3, |x: &i32, y: &i32| x.abs().cmp(&y.abs())); -/// assert_eq!(result, -2); +/// let result = cmp::min_by(2, -1, abs_cmp); +/// assert_eq!(result, -1); +/// +/// let result = cmp::min_by(2, -3, abs_cmp); +/// assert_eq!(result, 2); +/// +/// let result = cmp::min_by(1, -1, abs_cmp); +/// assert_eq!(result, 1); /// ``` #[inline] #[must_use] #[stable(feature = "cmp_min_max_by", since = "1.53.0")] pub fn min_by Ordering>(v1: T, v2: T, compare: F) -> T { - match compare(&v1, &v2) { - Ordering::Less | Ordering::Equal => v1, - Ordering::Greater => v2, - } + if compare(&v2, &v1).is_lt() { v2 } else { v1 } } /// Returns the element that gives the minimum value from the specified function. @@ -1456,17 +1522,20 @@ pub fn min_by Ordering>(v1: T, v2: T, compare: F) -> T { /// ``` /// use std::cmp; /// -/// let result = cmp::min_by_key(-2, 1, |x: &i32| x.abs()); -/// assert_eq!(result, 1); +/// let result = cmp::min_by_key(2, -1, |x: &i32| x.abs()); +/// assert_eq!(result, -1); /// -/// let result = cmp::min_by_key(-2, 2, |x: &i32| x.abs()); -/// assert_eq!(result, -2); +/// let result = cmp::min_by_key(2, -3, |x: &i32| x.abs()); +/// assert_eq!(result, 2); +/// +/// let result = cmp::min_by_key(1, -1, |x: &i32| x.abs()); +/// assert_eq!(result, 1); /// ``` #[inline] #[must_use] #[stable(feature = "cmp_min_max_by", since = "1.53.0")] pub fn min_by_key K, K: Ord>(v1: T, v2: T, mut f: F) -> T { - min_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2))) + if f(&v2) < f(&v1) { v2 } else { v1 } } /// Compares and returns the maximum of two values. @@ -1483,6 +1552,24 @@ pub fn min_by_key K, K: Ord>(v1: T, v2: T, mut f: F) -> T { /// assert_eq!(cmp::max(1, 2), 2); /// assert_eq!(cmp::max(2, 2), 2); /// ``` +/// ``` +/// use std::cmp::{self, Ordering}; +/// +/// #[derive(Eq)] +/// struct Equal(&'static str); +/// +/// impl PartialEq for Equal { +/// fn eq(&self, other: &Self) -> bool { true } +/// } +/// impl PartialOrd for Equal { +/// fn partial_cmp(&self, other: &Self) -> Option { Some(Ordering::Equal) } +/// } +/// impl Ord for Equal { +/// fn cmp(&self, other: &Self) -> Ordering { Ordering::Equal } +/// } +/// +/// assert_eq!(cmp::max(Equal("v1"), Equal("v2")).0, "v2"); +/// ``` #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] @@ -1500,20 +1587,22 @@ pub fn max(v1: T, v2: T) -> T { /// ``` /// use std::cmp; /// -/// let result = cmp::max_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs())); +/// let abs_cmp = |x: &i32, y: &i32| x.abs().cmp(&y.abs()); +/// +/// let result = cmp::max_by(3, -2, abs_cmp) ; +/// assert_eq!(result, 3); +/// +/// let result = cmp::max_by(1, -2, abs_cmp); /// assert_eq!(result, -2); /// -/// let result = cmp::max_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())) ; -/// assert_eq!(result, 2); +/// let result = cmp::max_by(1, -1, abs_cmp); +/// assert_eq!(result, -1); /// ``` #[inline] #[must_use] #[stable(feature = "cmp_min_max_by", since = "1.53.0")] pub fn max_by Ordering>(v1: T, v2: T, compare: F) -> T { - match compare(&v1, &v2) { - Ordering::Less | Ordering::Equal => v2, - Ordering::Greater => v1, - } + if compare(&v2, &v1).is_lt() { v1 } else { v2 } } /// Returns the element that gives the maximum value from the specified function. @@ -1525,17 +1614,20 @@ pub fn max_by Ordering>(v1: T, v2: T, compare: F) -> T { /// ``` /// use std::cmp; /// -/// let result = cmp::max_by_key(-2, 1, |x: &i32| x.abs()); +/// let result = cmp::max_by_key(3, -2, |x: &i32| x.abs()); +/// assert_eq!(result, 3); +/// +/// let result = cmp::max_by_key(1, -2, |x: &i32| x.abs()); /// assert_eq!(result, -2); /// -/// let result = cmp::max_by_key(-2, 2, |x: &i32| x.abs()); -/// assert_eq!(result, 2); +/// let result = cmp::max_by_key(1, -1, |x: &i32| x.abs()); +/// assert_eq!(result, -1); /// ``` #[inline] #[must_use] #[stable(feature = "cmp_min_max_by", since = "1.53.0")] pub fn max_by_key K, K: Ord>(v1: T, v2: T, mut f: F) -> T { - max_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2))) + if f(&v2) < f(&v1) { v1 } else { v2 } } /// Compares and sorts two values, returning minimum and maximum. @@ -1549,13 +1641,32 @@ pub fn max_by_key K, K: Ord>(v1: T, v2: T, mut f: F) -> T { /// use std::cmp; /// /// assert_eq!(cmp::minmax(1, 2), [1, 2]); -/// assert_eq!(cmp::minmax(2, 2), [2, 2]); +/// assert_eq!(cmp::minmax(2, 1), [1, 2]); /// /// // You can destructure the result using array patterns /// let [min, max] = cmp::minmax(42, 17); /// assert_eq!(min, 17); /// assert_eq!(max, 42); /// ``` +/// ``` +/// #![feature(cmp_minmax)] +/// use std::cmp::{self, Ordering}; +/// +/// #[derive(Eq)] +/// struct Equal(&'static str); +/// +/// impl PartialEq for Equal { +/// fn eq(&self, other: &Self) -> bool { true } +/// } +/// impl PartialOrd for Equal { +/// fn partial_cmp(&self, other: &Self) -> Option { Some(Ordering::Equal) } +/// } +/// impl Ord for Equal { +/// fn cmp(&self, other: &Self) -> Ordering { Ordering::Equal } +/// } +/// +/// assert_eq!(cmp::minmax(Equal("v1"), Equal("v2")).map(|v| v.0), ["v1", "v2"]); +/// ``` #[inline] #[must_use] #[unstable(feature = "cmp_minmax", issue = "115939")] @@ -1563,7 +1674,7 @@ pub fn minmax(v1: T, v2: T) -> [T; 2] where T: Ord, { - if v1 <= v2 { [v1, v2] } else { [v2, v1] } + if v2 < v1 { [v2, v1] } else { [v1, v2] } } /// Returns minimum and maximum values with respect to the specified comparison function. @@ -1576,11 +1687,14 @@ where /// #![feature(cmp_minmax)] /// use std::cmp; /// -/// assert_eq!(cmp::minmax_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), [1, -2]); -/// assert_eq!(cmp::minmax_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), [-2, 2]); +/// let abs_cmp = |x: &i32, y: &i32| x.abs().cmp(&y.abs()); +/// +/// assert_eq!(cmp::minmax_by(-2, 1, abs_cmp), [1, -2]); +/// assert_eq!(cmp::minmax_by(-1, 2, abs_cmp), [-1, 2]); +/// assert_eq!(cmp::minmax_by(-2, 2, abs_cmp), [-2, 2]); /// /// // You can destructure the result using array patterns -/// let [min, max] = cmp::minmax_by(-42, 17, |x: &i32, y: &i32| x.abs().cmp(&y.abs())); +/// let [min, max] = cmp::minmax_by(-42, 17, abs_cmp); /// assert_eq!(min, 17); /// assert_eq!(max, -42); /// ``` @@ -1591,7 +1705,7 @@ pub fn minmax_by(v1: T, v2: T, compare: F) -> [T; 2] where F: FnOnce(&T, &T) -> Ordering, { - if compare(&v1, &v2).is_le() { [v1, v2] } else { [v2, v1] } + if compare(&v2, &v1).is_lt() { [v2, v1] } else { [v1, v2] } } /// Returns minimum and maximum values with respect to the specified key function. @@ -1620,7 +1734,7 @@ where F: FnMut(&T) -> K, K: Ord, { - minmax_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2))) + if f(&v2) < f(&v1) { [v2, v1] } else { [v1, v2] } } // Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types diff --git a/core/src/contracts.rs b/core/src/contracts.rs new file mode 100644 index 0000000000000..8b79a3a7eba86 --- /dev/null +++ b/core/src/contracts.rs @@ -0,0 +1,20 @@ +//! Unstable module containing the unstable contracts lang items and attribute macros. + +pub use crate::macros::builtin::{contracts_ensures as ensures, contracts_requires as requires}; + +/// Emitted by rustc as a desugaring of `#[ensures(PRED)] fn foo() -> R { ... [return R;] ... }` +/// into: `fn foo() { let _check = build_check_ensures(|ret| PRED) ... [return _check(R);] ... }` +/// (including the implicit return of the tail expression, if any). +#[unstable(feature = "contracts_internals", issue = "128044" /* compiler-team#759 */)] +#[lang = "contract_build_check_ensures"] +#[track_caller] +pub fn build_check_ensures(cond: C) -> impl (Fn(Ret) -> Ret) + Copy +where + C: for<'a> Fn(&'a Ret) -> bool + Copy + 'static, +{ + #[track_caller] + move |ret| { + crate::intrinsics::contract_check_ensures(&ret, cond); + ret + } +} diff --git a/core/src/convert/mod.rs b/core/src/convert/mod.rs index 432e55e8c9a4c..43fd54f881dae 100644 --- a/core/src/convert/mod.rs +++ b/core/src/convert/mod.rs @@ -443,6 +443,7 @@ pub trait AsMut { /// [`Vec`]: ../../std/vec/struct.Vec.html #[rustc_diagnostic_item = "Into"] #[stable(feature = "rust1", since = "1.0.0")] +#[doc(search_unbox)] pub trait Into: Sized { /// Converts this type into the (usually inferred) input type. #[must_use] @@ -577,6 +578,7 @@ pub trait Into: Sized { all(_Self = "&str", T = "alloc::string::String"), note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix", ))] +#[doc(search_unbox)] pub trait From: Sized { /// Converts to this type from the input type. #[rustc_diagnostic_item = "from_fn"] @@ -776,7 +778,6 @@ impl From for T { /// /// [#64715]: https://github.com/rust-lang/rust/issues/64715 #[stable(feature = "convert_infallible", since = "1.34.0")] -#[allow(unused_attributes)] // FIXME(#58633): do a principled fix instead. #[rustc_reservation_impl = "permitting this impl would forbid us from adding \ `impl From for T` later; see rust-lang/rust#64715 for details"] impl From for T { diff --git a/core/src/error.rs b/core/src/error.rs index 95a39cc3aed38..94847685ec965 100644 --- a/core/src/error.rs +++ b/core/src/error.rs @@ -2,7 +2,7 @@ #![stable(feature = "error_in_core", since = "1.81.0")] use crate::any::TypeId; -use crate::fmt::{Debug, Display, Formatter, Result}; +use crate::fmt::{self, Debug, Display, Formatter}; /// `Error` is a trait representing the basic expectations for error values, /// i.e., values of type `E` in [`Result`]. @@ -22,6 +22,30 @@ use crate::fmt::{Debug, Display, Formatter, Result}; /// accessing that error via [`Error::source()`]. This makes it possible for the /// high-level module to provide its own errors while also revealing some of the /// implementation for debugging. +/// +/// # Example +/// +/// Implementing the `Error` trait only requires that `Debug` and `Display` are implemented too. +/// +/// ``` +/// use std::error::Error; +/// use std::fmt; +/// use std::path::PathBuf; +/// +/// #[derive(Debug)] +/// struct ReadConfigError { +/// path: PathBuf +/// } +/// +/// impl fmt::Display for ReadConfigError { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { +/// let path = self.path.display(); +/// write!(f, "unable to read configuration at {path}") +/// } +/// } +/// +/// impl Error for ReadConfigError {} +/// ``` #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "Error")] #[rustc_has_incoherent_inherent_impls] @@ -857,7 +881,7 @@ impl<'a> Request<'a> { #[unstable(feature = "error_generic_member_access", issue = "99301")] impl<'a> Debug for Request<'a> { - fn fmt(&self, f: &mut Formatter<'_>) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { f.debug_struct("Request").finish_non_exhaustive() } } @@ -1075,5 +1099,5 @@ impl Error for crate::time::TryFromFloatSecsError {} #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] impl Error for crate::ffi::FromBytesUntilNulError {} -#[unstable(feature = "get_many_mut", issue = "104642")] -impl Error for crate::slice::GetManyMutError {} +#[stable(feature = "get_many_mut", since = "1.86.0")] +impl Error for crate::slice::GetDisjointMutError {} diff --git a/core/src/escape.rs b/core/src/escape.rs index 0685f525dca83..0c3329f676eeb 100644 --- a/core/src/escape.rs +++ b/core/src/escape.rs @@ -163,28 +163,28 @@ pub(crate) struct EscapeIterInner { } impl EscapeIterInner { - pub const fn backslash(c: ascii::Char) -> Self { + pub(crate) const fn backslash(c: ascii::Char) -> Self { let (data, range) = backslash(c); Self { data, alive: range } } - pub const fn ascii(c: u8) -> Self { + pub(crate) const fn ascii(c: u8) -> Self { let (data, range) = escape_ascii(c); Self { data, alive: range } } - pub const fn unicode(c: char) -> Self { + pub(crate) const fn unicode(c: char) -> Self { let (data, range) = escape_unicode(c); Self { data, alive: range } } #[inline] - pub const fn empty() -> Self { + pub(crate) const fn empty() -> Self { Self { data: [ascii::Char::Null; N], alive: 0..0 } } #[inline] - pub fn as_ascii(&self) -> &[ascii::Char] { + pub(crate) fn as_ascii(&self) -> &[ascii::Char] { // SAFETY: `self.alive` is guaranteed to be a valid range for indexing `self.data`. unsafe { self.data.get_unchecked(usize::from(self.alive.start)..usize::from(self.alive.end)) @@ -192,34 +192,34 @@ impl EscapeIterInner { } #[inline] - pub fn as_str(&self) -> &str { + pub(crate) fn as_str(&self) -> &str { self.as_ascii().as_str() } #[inline] - pub fn len(&self) -> usize { + pub(crate) fn len(&self) -> usize { usize::from(self.alive.end - self.alive.start) } - pub fn next(&mut self) -> Option { + pub(crate) fn next(&mut self) -> Option { let i = self.alive.next()?; // SAFETY: `i` is guaranteed to be a valid index for `self.data`. unsafe { Some(self.data.get_unchecked(usize::from(i)).to_u8()) } } - pub fn next_back(&mut self) -> Option { + pub(crate) fn next_back(&mut self) -> Option { let i = self.alive.next_back()?; // SAFETY: `i` is guaranteed to be a valid index for `self.data`. unsafe { Some(self.data.get_unchecked(usize::from(i)).to_u8()) } } - pub fn advance_by(&mut self, n: usize) -> Result<(), NonZero> { + pub(crate) fn advance_by(&mut self, n: usize) -> Result<(), NonZero> { self.alive.advance_by(n) } - pub fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero> { + pub(crate) fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero> { self.alive.advance_back_by(n) } } diff --git a/core/src/ffi/c_str.rs b/core/src/ffi/c_str.rs index 9e32f74227cf9..080c0cef53304 100644 --- a/core/src/ffi/c_str.rs +++ b/core/src/ffi/c_str.rs @@ -55,18 +55,15 @@ use crate::{fmt, ops, slice, str}; /// Passing a Rust-originating C string: /// /// ``` -/// use std::ffi::{CString, CStr}; +/// use std::ffi::CStr; /// use std::os::raw::c_char; /// /// fn work(data: &CStr) { -/// # /* Extern functions are awkward in doc comments - fake it instead -/// extern "C" { fn work_with(data: *const c_char); } -/// # */ unsafe extern "C" fn work_with(s: *const c_char) {} -/// +/// unsafe extern "C" fn work_with(s: *const c_char) {} /// unsafe { work_with(data.as_ptr()) } /// } /// -/// let s = CString::new("data data data data").expect("CString::new failed"); +/// let s = c"Hello world!"; /// work(&s); /// ``` /// @@ -124,39 +121,25 @@ pub struct CStr { /// /// let _: FromBytesWithNulError = CStr::from_bytes_with_nul(b"f\0oo").unwrap_err(); /// ``` -#[derive(Clone, PartialEq, Eq, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, Debug)] #[stable(feature = "core_c_str", since = "1.64.0")] -pub struct FromBytesWithNulError { - kind: FromBytesWithNulErrorKind, -} - -#[derive(Clone, PartialEq, Eq, Debug)] -enum FromBytesWithNulErrorKind { - InteriorNul(usize), +pub enum FromBytesWithNulError { + /// Data provided contains an interior nul byte at byte `position`. + InteriorNul { + /// The position of the interior nul byte. + position: usize, + }, + /// Data provided is not nul terminated. NotNulTerminated, } -// FIXME: const stability attributes should not be required here, I think -impl FromBytesWithNulError { - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_cstr_methods", since = "1.72.0"))] - const fn interior_nul(pos: usize) -> FromBytesWithNulError { - FromBytesWithNulError { kind: FromBytesWithNulErrorKind::InteriorNul(pos) } - } - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_cstr_methods", since = "1.72.0"))] - const fn not_nul_terminated() -> FromBytesWithNulError { - FromBytesWithNulError { kind: FromBytesWithNulErrorKind::NotNulTerminated } - } -} - #[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")] impl Error for FromBytesWithNulError { #[allow(deprecated)] fn description(&self) -> &str { - match self.kind { - FromBytesWithNulErrorKind::InteriorNul(..) => { - "data provided contains an interior nul byte" - } - FromBytesWithNulErrorKind::NotNulTerminated => "data provided is not nul terminated", + match self { + Self::InteriorNul { .. } => "data provided contains an interior nul byte", + Self::NotNulTerminated => "data provided is not nul terminated", } } } @@ -201,8 +184,8 @@ impl fmt::Display for FromBytesWithNulError { #[allow(deprecated, deprecated_in_future)] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.description())?; - if let FromBytesWithNulErrorKind::InteriorNul(pos) = self.kind { - write!(f, " at byte pos {pos}")?; + if let Self::InteriorNul { position } = self { + write!(f, " at byte pos {position}")?; } Ok(()) } @@ -351,25 +334,25 @@ impl CStr { /// use std::ffi::CStr; /// /// let cstr = CStr::from_bytes_with_nul(b"hello\0"); - /// assert!(cstr.is_ok()); + /// assert_eq!(cstr, Ok(c"hello")); /// ``` /// /// Creating a `CStr` without a trailing nul terminator is an error: /// /// ``` - /// use std::ffi::CStr; + /// use std::ffi::{CStr, FromBytesWithNulError}; /// /// let cstr = CStr::from_bytes_with_nul(b"hello"); - /// assert!(cstr.is_err()); + /// assert_eq!(cstr, Err(FromBytesWithNulError::NotNulTerminated)); /// ``` /// /// Creating a `CStr` with an interior nul byte is an error: /// /// ``` - /// use std::ffi::CStr; + /// use std::ffi::{CStr, FromBytesWithNulError}; /// /// let cstr = CStr::from_bytes_with_nul(b"he\0llo\0"); - /// assert!(cstr.is_err()); + /// assert_eq!(cstr, Err(FromBytesWithNulError::InteriorNul { position: 2 })); /// ``` #[stable(feature = "cstr_from_bytes", since = "1.10.0")] #[rustc_const_stable(feature = "const_cstr_methods", since = "1.72.0")] @@ -381,8 +364,8 @@ impl CStr { // of the byte slice. Ok(unsafe { Self::from_bytes_with_nul_unchecked(bytes) }) } - Some(nul_pos) => Err(FromBytesWithNulError::interior_nul(nul_pos)), - None => Err(FromBytesWithNulError::not_nul_terminated()), + Some(position) => Err(FromBytesWithNulError::InteriorNul { position }), + None => Err(FromBytesWithNulError::NotNulTerminated), } } @@ -398,13 +381,12 @@ impl CStr { /// # Examples /// /// ``` - /// use std::ffi::{CStr, CString}; + /// use std::ffi::CStr; /// - /// unsafe { - /// let cstring = CString::new("hello").expect("CString::new failed"); - /// let cstr = CStr::from_bytes_with_nul_unchecked(cstring.to_bytes_with_nul()); - /// assert_eq!(cstr, &*cstring); - /// } + /// let bytes = b"Hello world!\0"; + /// + /// let cstr = unsafe { CStr::from_bytes_with_nul_unchecked(bytes) }; + /// assert_eq!(cstr.to_bytes_with_nul(), bytes); /// ``` #[inline] #[must_use] @@ -463,44 +445,48 @@ impl CStr { /// behavior when `ptr` is used inside the `unsafe` block: /// /// ```no_run - /// # #![allow(unused_must_use)] - /// # #![cfg_attr(bootstrap, expect(temporary_cstring_as_ptr))] - /// # #![cfg_attr(not(bootstrap), expect(dangling_pointers_from_temporaries))] - /// use std::ffi::CString; + /// # #![expect(dangling_pointers_from_temporaries)] + /// use std::ffi::{CStr, CString}; /// - /// // Do not do this: - /// let ptr = CString::new("Hello").expect("CString::new failed").as_ptr(); - /// unsafe { - /// // `ptr` is dangling - /// *ptr; - /// } + /// // 💀 The meaning of this entire program is undefined, + /// // 💀 and nothing about its behavior is guaranteed, + /// // 💀 not even that its behavior resembles the code as written, + /// // 💀 just because it contains a single instance of undefined behavior! + /// + /// // 🚨 creates a dangling pointer to a temporary `CString` + /// // 🚨 that is deallocated at the end of the statement + /// let ptr = CString::new("Hi!".to_uppercase()).unwrap().as_ptr(); + /// + /// // without undefined behavior, you would expect that `ptr` equals: + /// dbg!(CStr::from_bytes_with_nul(b"HI!\0").unwrap()); + /// + /// // 🙏 Possibly the program behaved as expected so far, + /// // 🙏 and this just shows `ptr` is now garbage..., but + /// // 💀 this violates `CStr::from_ptr`'s safety contract + /// // 💀 leading to a dereference of a dangling pointer, + /// // 💀 which is immediate undefined behavior. + /// // 💀 *BOOM*, you're dead, you're entire program has no meaning. + /// dbg!(unsafe { CStr::from_ptr(ptr) }); /// ``` /// - /// This happens because the pointer returned by `as_ptr` does not carry any - /// lifetime information and the `CString` is deallocated immediately after - /// the `CString::new("Hello").expect("CString::new failed").as_ptr()` - /// expression is evaluated. + /// This happens because, the pointer returned by `as_ptr` does not carry any + /// lifetime information, and the `CString` is deallocated immediately after + /// the expression that it is part of has been evaluated. /// To fix the problem, bind the `CString` to a local variable: /// - /// ```no_run - /// # #![allow(unused_must_use)] - /// use std::ffi::CString; - /// - /// let hello = CString::new("Hello").expect("CString::new failed"); - /// let ptr = hello.as_ptr(); - /// unsafe { - /// // `ptr` is valid because `hello` is in scope - /// *ptr; - /// } /// ``` + /// use std::ffi::{CStr, CString}; + /// + /// let c_str = CString::new("Hi!".to_uppercase()).unwrap(); + /// let ptr = c_str.as_ptr(); /// - /// This way, the lifetime of the `CString` in `hello` encompasses - /// the lifetime of `ptr` and the `unsafe` block. + /// assert_eq!(unsafe { CStr::from_ptr(ptr) }, c"HI!"); + /// ``` #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_str_as_ptr", since = "1.32.0")] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[rustc_never_returns_null_ptr] pub const fn as_ptr(&self) -> *const c_char { self.inner.as_ptr() @@ -732,7 +718,6 @@ impl AsRef for CStr { /// located within `isize::MAX` from `ptr`. #[inline] #[unstable(feature = "cstr_internals", issue = "none")] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_cstr_from_ptr", since = "1.81.0"))] #[rustc_allow_const_fn_unstable(const_eval_select)] const unsafe fn strlen(ptr: *const c_char) -> usize { const_eval_select!( @@ -747,7 +732,7 @@ const unsafe fn strlen(ptr: *const c_char) -> usize { len } else { - extern "C" { + unsafe extern "C" { /// Provided by libc or compiler_builtins. fn strlen(s: *const c_char) -> usize; } diff --git a/core/src/ffi/mod.rs b/core/src/ffi/mod.rs index dc107c5d22cdd..9bae5fd466a18 100644 --- a/core/src/ffi/mod.rs +++ b/core/src/ffi/mod.rs @@ -12,10 +12,10 @@ #[doc(inline)] #[stable(feature = "core_c_str", since = "1.64.0")] pub use self::c_str::CStr; -#[doc(no_inline)] +#[doc(inline)] #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] pub use self::c_str::FromBytesUntilNulError; -#[doc(no_inline)] +#[doc(inline)] #[stable(feature = "core_c_str", since = "1.64.0")] pub use self::c_str::FromBytesWithNulError; use crate::fmt; @@ -37,146 +37,14 @@ pub use self::va_list::{VaList, VaListImpl}; )] pub mod va_list; -macro_rules! type_alias { - { - $Docfile:tt, $Alias:ident = $Real:ty; - $( $Cfg:tt )* - } => { - #[doc = include_str!($Docfile)] - $( $Cfg )* - #[stable(feature = "core_ffi_c", since = "1.64.0")] - pub type $Alias = $Real; - } -} - -type_alias! { "c_char.md", c_char = c_char_definition::c_char; #[doc(cfg(all()))] } - -type_alias! { "c_schar.md", c_schar = i8; } -type_alias! { "c_uchar.md", c_uchar = u8; } -type_alias! { "c_short.md", c_short = i16; } -type_alias! { "c_ushort.md", c_ushort = u16; } - -type_alias! { "c_int.md", c_int = c_int_definition::c_int; #[doc(cfg(all()))] } -type_alias! { "c_uint.md", c_uint = c_int_definition::c_uint; #[doc(cfg(all()))] } - -type_alias! { "c_long.md", c_long = c_long_definition::c_long; #[doc(cfg(all()))] } -type_alias! { "c_ulong.md", c_ulong = c_long_definition::c_ulong; #[doc(cfg(all()))] } - -type_alias! { "c_longlong.md", c_longlong = i64; } -type_alias! { "c_ulonglong.md", c_ulonglong = u64; } - -type_alias! { "c_float.md", c_float = f32; } -type_alias! { "c_double.md", c_double = f64; } - -/// Equivalent to C's `size_t` type, from `stddef.h` (or `cstddef` for C++). -/// -/// This type is currently always [`usize`], however in the future there may be -/// platforms where this is not the case. -#[unstable(feature = "c_size_t", issue = "88345")] -pub type c_size_t = usize; - -/// Equivalent to C's `ptrdiff_t` type, from `stddef.h` (or `cstddef` for C++). -/// -/// This type is currently always [`isize`], however in the future there may be -/// platforms where this is not the case. -#[unstable(feature = "c_size_t", issue = "88345")] -pub type c_ptrdiff_t = isize; - -/// Equivalent to C's `ssize_t` (on POSIX) or `SSIZE_T` (on Windows) type. -/// -/// This type is currently always [`isize`], however in the future there may be -/// platforms where this is not the case. +mod primitives; +#[stable(feature = "core_ffi_c", since = "1.64.0")] +pub use self::primitives::{ + c_char, c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, + c_ulong, c_ulonglong, c_ushort, +}; #[unstable(feature = "c_size_t", issue = "88345")] -pub type c_ssize_t = isize; - -mod c_char_definition { - cfg_if! { - // These are the targets on which c_char is unsigned. - if #[cfg(any( - all( - target_os = "linux", - any( - target_arch = "aarch64", - target_arch = "arm", - target_arch = "hexagon", - target_arch = "powerpc", - target_arch = "powerpc64", - target_arch = "s390x", - target_arch = "riscv64", - target_arch = "riscv32", - target_arch = "csky" - ) - ), - all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")), - all(target_os = "l4re", target_arch = "x86_64"), - all( - any(target_os = "freebsd", target_os = "openbsd", target_os = "rtems"), - any( - target_arch = "aarch64", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "powerpc64", - target_arch = "riscv64" - ) - ), - all( - target_os = "netbsd", - any( - target_arch = "aarch64", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "riscv64" - ) - ), - all( - target_os = "vxworks", - any( - target_arch = "aarch64", - target_arch = "arm", - target_arch = "powerpc64", - target_arch = "powerpc" - ) - ), - all( - target_os = "fuchsia", - any(target_arch = "aarch64", target_arch = "riscv64") - ), - all(target_os = "nto", target_arch = "aarch64"), - target_os = "horizon", - target_os = "aix", - ))] { - pub type c_char = u8; - } else { - // On every other target, c_char is signed. - pub type c_char = i8; - } - } -} - -mod c_int_definition { - cfg_if! { - if #[cfg(any(target_arch = "avr", target_arch = "msp430"))] { - pub type c_int = i16; - pub type c_uint = u16; - } else { - pub type c_int = i32; - pub type c_uint = u32; - } - } -} - -mod c_long_definition { - cfg_if! { - if #[cfg(all(target_pointer_width = "64", not(windows)))] { - pub type c_long = i64; - pub type c_ulong = u64; - } else { - // The minimal size of `long` in the C standard is 32 bits - pub type c_long = i32; - pub type c_ulong = u32; - } - } -} +pub use self::primitives::{c_ptrdiff_t, c_size_t, c_ssize_t}; // N.B., for LLVM to recognize the void pointer type and by extension // functions like malloc(), we need to have it represented as i8* in @@ -222,4 +90,4 @@ impl fmt::Debug for c_void { cfg(not(target_feature = "crt-static")) )] #[link(name = "/defaultlib:libcmt", modifiers = "+verbatim", cfg(target_feature = "crt-static"))] -extern "C" {} +unsafe extern "C" {} diff --git a/core/src/ffi/primitives.rs b/core/src/ffi/primitives.rs new file mode 100644 index 0000000000000..0a70eb4da5522 --- /dev/null +++ b/core/src/ffi/primitives.rs @@ -0,0 +1,181 @@ +//! Defines primitive types that match C's type definitions for FFI compatibility. +//! +//! This module is intentionally standalone to facilitate parsing when retrieving +//! core C types. + +macro_rules! type_alias { + { + $Docfile:tt, $Alias:ident = $Real:ty; + $( $Cfg:tt )* + } => { + #[doc = include_str!($Docfile)] + $( $Cfg )* + #[stable(feature = "core_ffi_c", since = "1.64.0")] + pub type $Alias = $Real; + } +} + +type_alias! { "c_char.md", c_char = c_char_definition::c_char; #[doc(cfg(all()))] } + +type_alias! { "c_schar.md", c_schar = i8; } +type_alias! { "c_uchar.md", c_uchar = u8; } +type_alias! { "c_short.md", c_short = i16; } +type_alias! { "c_ushort.md", c_ushort = u16; } + +type_alias! { "c_int.md", c_int = c_int_definition::c_int; #[doc(cfg(all()))] } +type_alias! { "c_uint.md", c_uint = c_int_definition::c_uint; #[doc(cfg(all()))] } + +type_alias! { "c_long.md", c_long = c_long_definition::c_long; #[doc(cfg(all()))] } +type_alias! { "c_ulong.md", c_ulong = c_long_definition::c_ulong; #[doc(cfg(all()))] } + +type_alias! { "c_longlong.md", c_longlong = i64; } +type_alias! { "c_ulonglong.md", c_ulonglong = u64; } + +type_alias! { "c_float.md", c_float = f32; } +type_alias! { "c_double.md", c_double = f64; } + +mod c_char_definition { + cfg_if! { + // These are the targets on which c_char is unsigned. Usually the + // signedness is the same for all target_os values on a given architecture + // but there are some exceptions (see isSignedCharDefault() in clang). + // aarch64: + // Section 10 "Arm C and C++ language mappings" in Procedure Call Standard for the Arm® + // 64-bit Architecture (AArch64) says C/C++ char is unsigned byte. + // https://github.com/ARM-software/abi-aa/blob/2024Q3/aapcs64/aapcs64.rst#arm-c-and-c-language-mappings + // arm: + // Section 8 "Arm C and C++ Language Mappings" in Procedure Call Standard for the Arm® + // Architecture says C/C++ char is unsigned byte. + // https://github.com/ARM-software/abi-aa/blob/2024Q3/aapcs32/aapcs32.rst#arm-c-and-c-language-mappings + // csky: + // Section 2.1.2 "Primary Data Type" in C-SKY V2 CPU Applications Binary Interface + // Standards Manual says ANSI C char is unsigned byte. + // https://github.com/c-sky/csky-doc/blob/9f7121f7d40970ba5cc0f15716da033db2bb9d07/C-SKY_V2_CPU_Applications_Binary_Interface_Standards_Manual.pdf + // Note: this doesn't seem to match Clang's default (https://github.com/rust-lang/rust/issues/129945). + // hexagon: + // Section 3.1 "Basic data type" in Qualcomm Hexagon™ Application + // Binary Interface User Guide says "By default, the `char` data type is unsigned." + // https://docs.qualcomm.com/bundle/publicresource/80-N2040-23_REV_K_Qualcomm_Hexagon_Application_Binary_Interface_User_Guide.pdf + // msp430: + // Section 2.1 "Basic Types" in MSP430 Embedded Application Binary + // Interface says "The char type is unsigned by default". + // https://www.ti.com/lit/an/slaa534a/slaa534a.pdf + // powerpc/powerpc64: + // - PPC32 SysV: "Table 3-1 Scalar Types" in System V Application Binary Interface PowerPC + // Processor Supplement says ANSI C char is unsigned byte + // https://refspecs.linuxfoundation.org/elf/elfspec_ppc.pdf + // - PPC64 ELFv1: Section 3.1.4 "Fundamental Types" in 64-bit PowerPC ELF Application + // Binary Interface Supplement 1.9 says ANSI C is unsigned byte + // https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUND-TYPE + // - PPC64 ELFv2: Section 2.1.2.2 "Fundamental Types" in 64-Bit ELF V2 ABI Specification + // says char is unsigned byte + // https://openpowerfoundation.org/specifications/64bitelfabi/ + // - AIX: XL C for AIX Language Reference says "By default, char behaves like an unsigned char." + // https://www.ibm.com/docs/en/xl-c-aix/13.1.3?topic=specifiers-character-types + // riscv32/riscv64: + // C/C++ type representations section in RISC-V Calling Conventions + // page in RISC-V ELF psABI Document says "char is unsigned." + // https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/draft-20240829-13bfa9f54634cb60d86b9b333e109f077805b4b3/riscv-cc.adoc#cc-type-representations + // s390x: + // - ELF: "Table 1.1.: Scalar types" in ELF Application Binary Interface s390x Supplement + // Version 1.6.1 categorize ISO C char in unsigned integer + // https://github.com/IBM/s390x-abi/releases/tag/v1.6.1 + // - z/OS: XL C/C++ Language Reference says: "By default, char behaves like an unsigned char." + // https://www.ibm.com/docs/en/zos/3.1.0?topic=specifiers-character-types + // xtensa: + // Section 2.17.1 "Data Types and Alignment" of Xtensa LX Microprocessor Overview handbook + // says "`char` type is unsigned by default". + // https://loboris.eu/ESP32/Xtensa_lx%20Overview%20handbook.pdf + // + // On the following operating systems, c_char is signed by default, regardless of architecture. + // Darwin (macOS, iOS, etc.): + // Apple targets' c_char is signed by default even on arm + // https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Handle-data-types-and-data-alignment-properly + // Windows: + // Windows MSVC C++ Language Reference says "Microsoft-specific: Variables of type char + // are promoted to int as if from type signed char by default, unless the /J compilation + // option is used." + // https://learn.microsoft.com/en-us/cpp/cpp/fundamental-types-cpp?view=msvc-170#character-types + // Vita: + // Chars are signed by default on the Vita, and VITASDK follows that convention. + // https://github.com/vitasdk/buildscripts/blob/09c533b771591ecde88864b6acad28ffb688dbd4/patches/gcc/0001-gcc-10.patch#L33-L34 + // + // L4Re: + // The kernel builds with -funsigned-char on all targets (but userspace follows the + // architecture defaults). As we only have a target for userspace apps so there are no + // special cases for L4Re below. + // https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240 + if #[cfg(all( + not(windows), + not(target_vendor = "apple"), + not(target_os = "vita"), + any( + target_arch = "aarch64", + target_arch = "arm", + target_arch = "csky", + target_arch = "hexagon", + target_arch = "msp430", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "riscv32", + target_arch = "riscv64", + target_arch = "s390x", + target_arch = "xtensa", + ) + ))] { + pub(super) type c_char = u8; + } else { + // On every other target, c_char is signed. + pub(super) type c_char = i8; + } + } +} + +mod c_long_definition { + cfg_if! { + if #[cfg(any( + all(target_pointer_width = "64", not(windows)), + // wasm32 Linux ABI uses 64-bit long + all(target_arch = "wasm32", target_os = "linux")))] { + pub(super) type c_long = i64; + pub(super) type c_ulong = u64; + } else { + // The minimal size of `long` in the C standard is 32 bits + pub(super) type c_long = i32; + pub(super) type c_ulong = u32; + } + } +} + +/// Equivalent to C's `size_t` type, from `stddef.h` (or `cstddef` for C++). +/// +/// This type is currently always [`usize`], however in the future there may be +/// platforms where this is not the case. +#[unstable(feature = "c_size_t", issue = "88345")] +pub type c_size_t = usize; + +/// Equivalent to C's `ptrdiff_t` type, from `stddef.h` (or `cstddef` for C++). +/// +/// This type is currently always [`isize`], however in the future there may be +/// platforms where this is not the case. +#[unstable(feature = "c_size_t", issue = "88345")] +pub type c_ptrdiff_t = isize; + +/// Equivalent to C's `ssize_t` (on POSIX) or `SSIZE_T` (on Windows) type. +/// +/// This type is currently always [`isize`], however in the future there may be +/// platforms where this is not the case. +#[unstable(feature = "c_size_t", issue = "88345")] +pub type c_ssize_t = isize; + +mod c_int_definition { + cfg_if! { + if #[cfg(any(target_arch = "avr", target_arch = "msp430"))] { + pub(super) type c_int = i16; + pub(super) type c_uint = u16; + } else { + pub(super) type c_int = i32; + pub(super) type c_uint = u32; + } + } +} diff --git a/core/src/ffi/va_list.rs b/core/src/ffi/va_list.rs index 3a224e4d8fe5f..1ad8038cbf6eb 100644 --- a/core/src/ffi/va_list.rs +++ b/core/src/ffi/va_list.rs @@ -15,6 +15,7 @@ use crate::ops::{Deref, DerefMut}; not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "s390x"), + not(target_arch = "xtensa"), not(target_arch = "x86_64") ), all(target_arch = "aarch64", target_vendor = "apple"), @@ -37,6 +38,7 @@ pub struct VaListImpl<'f> { not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "s390x"), + not(target_arch = "xtensa"), not(target_arch = "x86_64") ), all(target_arch = "aarch64", target_vendor = "apple"), @@ -113,6 +115,18 @@ pub struct VaListImpl<'f> { _marker: PhantomData<&'f mut &'f c_void>, } +/// Xtensa ABI implementation of a `va_list`. +#[cfg(target_arch = "xtensa")] +#[repr(C)] +#[derive(Debug)] +#[lang = "va_list"] +pub struct VaListImpl<'f> { + stk: *mut i32, + reg: *mut i32, + ndx: i32, + _marker: PhantomData<&'f mut &'f c_void>, +} + /// A wrapper for a `va_list` #[repr(transparent)] #[derive(Debug)] @@ -124,6 +138,7 @@ pub struct VaList<'a, 'f: 'a> { not(target_arch = "s390x"), not(target_arch = "x86_64") ), + target_arch = "xtensa", all(target_arch = "aarch64", target_vendor = "apple"), target_family = "wasm", target_os = "uefi", @@ -138,6 +153,7 @@ pub struct VaList<'a, 'f: 'a> { target_arch = "s390x", target_arch = "x86_64" ), + not(target_arch = "xtensa"), any(not(target_arch = "aarch64"), not(target_vendor = "apple")), not(target_family = "wasm"), not(target_os = "uefi"), @@ -155,6 +171,7 @@ pub struct VaList<'a, 'f: 'a> { not(target_arch = "s390x"), not(target_arch = "x86_64") ), + target_arch = "xtensa", all(target_arch = "aarch64", target_vendor = "apple"), target_family = "wasm", target_os = "uefi", @@ -173,8 +190,10 @@ impl<'f> VaListImpl<'f> { target_arch = "aarch64", target_arch = "powerpc", target_arch = "s390x", + target_arch = "xtensa", target_arch = "x86_64" ), + not(target_arch = "xtensa"), any(not(target_arch = "aarch64"), not(target_vendor = "apple")), not(target_family = "wasm"), not(target_os = "uefi"), @@ -283,18 +302,19 @@ impl<'f> Drop for VaListImpl<'f> { } } -extern "rust-intrinsic" { - /// Destroy the arglist `ap` after initialization with `va_start` or - /// `va_copy`. - #[rustc_nounwind] - fn va_end(ap: &mut VaListImpl<'_>); +/// Destroy the arglist `ap` after initialization with `va_start` or +/// `va_copy`. +#[rustc_intrinsic] +#[rustc_nounwind] +unsafe fn va_end(ap: &mut VaListImpl<'_>); - /// Copies the current location of arglist `src` to the arglist `dst`. - #[rustc_nounwind] - fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>); +/// Copies the current location of arglist `src` to the arglist `dst`. +#[rustc_intrinsic] +#[rustc_nounwind] +unsafe fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>); - /// Loads an argument of type `T` from the `va_list` `ap` and increment the - /// argument `ap` points to. - #[rustc_nounwind] - fn va_arg(ap: &mut VaListImpl<'_>) -> T; -} +/// Loads an argument of type `T` from the `va_list` `ap` and increment the +/// argument `ap` points to. +#[rustc_intrinsic] +#[rustc_nounwind] +unsafe fn va_arg(ap: &mut VaListImpl<'_>) -> T; diff --git a/core/src/fmt/builders.rs b/core/src/fmt/builders.rs index 1862be0e86c5d..665b05b12ec07 100644 --- a/core/src/fmt/builders.rs +++ b/core/src/fmt/builders.rs @@ -1228,6 +1228,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { /// assert_eq!(format!("{:?}", wrapped), "'a'"); /// ``` #[unstable(feature = "debug_closure_helpers", issue = "117729")] +#[must_use = "returns a type implementing Debug and Display, which do not have any effects unless they are used"] pub fn from_fn) -> fmt::Result>(f: F) -> FromFn { FromFn(f) } diff --git a/core/src/fmt/float.rs b/core/src/fmt/float.rs index 04230b1610aae..4a43c12be9aaa 100644 --- a/core/src/fmt/float.rs +++ b/core/src/fmt/float.rs @@ -29,7 +29,7 @@ fn float_to_decimal_common_exact( fmt: &mut Formatter<'_>, num: &T, sign: flt2dec::Sign, - precision: usize, + precision: u16, ) -> Result where T: flt2dec::DecodableFloat, @@ -40,7 +40,7 @@ where flt2dec::strategy::grisu::format_exact, *num, sign, - precision, + precision.into(), &mut buf, &mut parts, ); @@ -55,7 +55,7 @@ fn float_to_decimal_common_shortest( fmt: &mut Formatter<'_>, num: &T, sign: flt2dec::Sign, - precision: usize, + precision: u16, ) -> Result where T: flt2dec::DecodableFloat, @@ -68,7 +68,7 @@ where flt2dec::strategy::grisu::format_shortest, *num, sign, - precision, + precision.into(), &mut buf, &mut parts, ); @@ -86,7 +86,7 @@ where true => flt2dec::Sign::MinusPlus, }; - if let Some(precision) = fmt.precision { + if let Some(precision) = fmt.options.precision { float_to_decimal_common_exact(fmt, num, sign, precision) } else { let min_precision = 0; @@ -101,7 +101,7 @@ fn float_to_exponential_common_exact( fmt: &mut Formatter<'_>, num: &T, sign: flt2dec::Sign, - precision: usize, + precision: u16, upper: bool, ) -> Result where @@ -113,7 +113,7 @@ where flt2dec::strategy::grisu::format_exact, *num, sign, - precision, + precision.into(), upper, &mut buf, &mut parts, @@ -162,7 +162,7 @@ where true => flt2dec::Sign::MinusPlus, }; - if let Some(precision) = fmt.precision { + if let Some(precision) = fmt.options.precision { // 1 integral digit + `precision` fractional digits = `precision + 1` total digits float_to_exponential_common_exact(fmt, num, sign, precision + 1, upper) } else { @@ -180,7 +180,7 @@ where true => flt2dec::Sign::MinusPlus, }; - if let Some(precision) = fmt.precision { + if let Some(precision) = fmt.options.precision { // this behavior of {:.PREC?} predates exponential formatting for {:?} float_to_decimal_common_exact(fmt, num, sign, precision) } else { diff --git a/core/src/fmt/mod.rs b/core/src/fmt/mod.rs index 2b1692a195e50..e0dc632df7051 100644 --- a/core/src/fmt/mod.rs +++ b/core/src/fmt/mod.rs @@ -3,7 +3,7 @@ #![stable(feature = "rust1", since = "1.0.0")] use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell}; -use crate::char::EscapeDebugExtArgs; +use crate::char::{EscapeDebugExtArgs, MAX_LEN_UTF8}; use crate::marker::PhantomData; use crate::num::fmt as numfmt; use crate::ops::Deref; @@ -33,6 +33,19 @@ pub enum Alignment { Center, } +#[doc(hidden)] +#[unstable(feature = "fmt_internals", reason = "internal to standard library", issue = "none")] +impl From for Option { + fn from(value: rt::Alignment) -> Self { + match value { + rt::Alignment::Left => Some(Alignment::Left), + rt::Alignment::Right => Some(Alignment::Right), + rt::Alignment::Center => Some(Alignment::Center), + rt::Alignment::Unknown => None, + } + } +} + #[stable(feature = "debug_builders", since = "1.2.0")] pub use self::builders::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; #[unstable(feature = "debug_closure_helpers", issue = "117729")] @@ -139,8 +152,9 @@ pub trait Write { /// } /// /// let mut buf = String::new(); - /// writer(&mut buf, "hola").unwrap(); + /// writer(&mut buf, "hola")?; /// assert_eq!(&buf, "hola"); + /// # std::fmt::Result::Ok(()) /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn write_str(&mut self, s: &str) -> Result; @@ -166,13 +180,14 @@ pub trait Write { /// } /// /// let mut buf = String::new(); - /// writer(&mut buf, 'a').unwrap(); - /// writer(&mut buf, 'b').unwrap(); + /// writer(&mut buf, 'a')?; + /// writer(&mut buf, 'b')?; /// assert_eq!(&buf, "ab"); + /// # std::fmt::Result::Ok(()) /// ``` #[stable(feature = "fmt_write_char", since = "1.1.0")] fn write_char(&mut self, c: char) -> Result { - self.write_str(c.encode_utf8(&mut [0; 4])) + self.write_str(c.encode_utf8(&mut [0; MAX_LEN_UTF8])) } /// Glue for usage of the [`write!`] macro with implementors of this trait. @@ -195,8 +210,9 @@ pub trait Write { /// } /// /// let mut buf = String::new(); - /// writer(&mut buf, "world").unwrap(); + /// writer(&mut buf, "world")?; /// assert_eq!(&buf, "world"); + /// # std::fmt::Result::Ok(()) /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn write_fmt(&mut self, args: Arguments<'_>) -> Result { @@ -247,6 +263,260 @@ impl Write for &mut W { } } +/// The signedness of a [`Formatter`] (or of a [`FormattingOptions`]). +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[unstable(feature = "formatting_options", issue = "118117")] +pub enum Sign { + /// Represents the `+` flag. + Plus, + /// Represents the `-` flag. + Minus, +} + +/// Specifies whether the [`Debug`] trait should use lower-/upper-case +/// hexadecimal or normal integers. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[unstable(feature = "formatting_options", issue = "118117")] +pub enum DebugAsHex { + /// Use lower-case hexadecimal integers for the `Debug` trait (like [the `x?` type](../../std/fmt/index.html#formatting-traits)). + Lower, + /// Use upper-case hexadecimal integers for the `Debug` trait (like [the `X?` type](../../std/fmt/index.html#formatting-traits)). + Upper, +} + +/// Options for formatting. +/// +/// `FormattingOptions` is a [`Formatter`] without an attached [`Write`] trait. +/// It is mainly used to construct `Formatter` instances. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[unstable(feature = "formatting_options", issue = "118117")] +pub struct FormattingOptions { + flags: u32, + fill: char, + align: Option, + width: Option, + precision: Option, +} + +impl FormattingOptions { + /// Construct a new `FormatterBuilder` with the supplied `Write` trait + /// object for output that is equivalent to the `{}` formatting + /// specifier: + /// + /// - no flags, + /// - filled with spaces, + /// - no alignment, + /// - no width, + /// - no precision, and + /// - no [`DebugAsHex`] output mode. + #[unstable(feature = "formatting_options", issue = "118117")] + pub const fn new() -> Self { + Self { flags: 0, fill: ' ', align: None, width: None, precision: None } + } + + /// Sets or removes the sign (the `+` or the `-` flag). + /// + /// - `+`: This is intended for numeric types and indicates that the sign + /// should always be printed. By default only the negative sign of signed + /// values is printed, and the sign of positive or unsigned values is + /// omitted. This flag indicates that the correct sign (+ or -) should + /// always be printed. + /// - `-`: Currently not used + #[unstable(feature = "formatting_options", issue = "118117")] + pub fn sign(&mut self, sign: Option) -> &mut Self { + self.flags = + self.flags & !(1 << rt::Flag::SignMinus as u32 | 1 << rt::Flag::SignPlus as u32); + match sign { + None => {} + Some(Sign::Plus) => self.flags |= 1 << rt::Flag::SignPlus as u32, + Some(Sign::Minus) => self.flags |= 1 << rt::Flag::SignMinus as u32, + } + self + } + /// Sets or unsets the `0` flag. + /// + /// This is used to indicate for integer formats that the padding to width should both be done with a 0 character as well as be sign-aware + #[unstable(feature = "formatting_options", issue = "118117")] + pub fn sign_aware_zero_pad(&mut self, sign_aware_zero_pad: bool) -> &mut Self { + if sign_aware_zero_pad { + self.flags |= 1 << rt::Flag::SignAwareZeroPad as u32 + } else { + self.flags &= !(1 << rt::Flag::SignAwareZeroPad as u32) + } + self + } + /// Sets or unsets the `#` flag. + /// + /// This flag indicates that the "alternate" form of printing should be + /// used. The alternate forms are: + /// - [`Debug`] : pretty-print the [`Debug`] formatting (adds linebreaks and indentation) + /// - [`LowerHex`] as well as [`UpperHex`] - precedes the argument with a `0x` + /// - [`Octal`] - precedes the argument with a `0b` + /// - [`Binary`] - precedes the argument with a `0o` + #[unstable(feature = "formatting_options", issue = "118117")] + pub fn alternate(&mut self, alternate: bool) -> &mut Self { + if alternate { + self.flags |= 1 << rt::Flag::Alternate as u32 + } else { + self.flags &= !(1 << rt::Flag::Alternate as u32) + } + self + } + /// Sets the fill character. + /// + /// The optional fill character and alignment is provided normally in + /// conjunction with the width parameter. This indicates that if the value + /// being formatted is smaller than width some extra characters will be + /// printed around it. + #[unstable(feature = "formatting_options", issue = "118117")] + pub fn fill(&mut self, fill: char) -> &mut Self { + self.fill = fill; + self + } + /// Sets or removes the alignment. + /// + /// The alignment specifies how the value being formatted should be + /// positioned if it is smaller than the width of the formatter. + #[unstable(feature = "formatting_options", issue = "118117")] + pub fn align(&mut self, align: Option) -> &mut Self { + self.align = align; + self + } + /// Sets or removes the width. + /// + /// This is a parameter for the “minimum width” that the format should take + /// up. If the value’s string does not fill up this many characters, then + /// the padding specified by [`FormattingOptions::fill`]/[`FormattingOptions::align`] + /// will be used to take up the required space. + #[unstable(feature = "formatting_options", issue = "118117")] + pub fn width(&mut self, width: Option) -> &mut Self { + self.width = width; + self + } + /// Sets or removes the precision. + /// + /// - For non-numeric types, this can be considered a “maximum width”. If + /// the resulting string is longer than this width, then it is truncated + /// down to this many characters and that truncated value is emitted with + /// proper fill, alignment and width if those parameters are set. + /// - For integral types, this is ignored. + /// - For floating-point types, this indicates how many digits after the + /// decimal point should be printed. + #[unstable(feature = "formatting_options", issue = "118117")] + pub fn precision(&mut self, precision: Option) -> &mut Self { + self.precision = precision; + self + } + /// Specifies whether the [`Debug`] trait should use lower-/upper-case + /// hexadecimal or normal integers + #[unstable(feature = "formatting_options", issue = "118117")] + pub fn debug_as_hex(&mut self, debug_as_hex: Option) -> &mut Self { + self.flags = self.flags + & !(1 << rt::Flag::DebugUpperHex as u32 | 1 << rt::Flag::DebugLowerHex as u32); + match debug_as_hex { + None => {} + Some(DebugAsHex::Upper) => self.flags |= 1 << rt::Flag::DebugUpperHex as u32, + Some(DebugAsHex::Lower) => self.flags |= 1 << rt::Flag::DebugLowerHex as u32, + } + self + } + + /// Returns the current sign (the `+` or the `-` flag). + #[unstable(feature = "formatting_options", issue = "118117")] + pub const fn get_sign(&self) -> Option { + const SIGN_PLUS_BITFIELD: u32 = 1 << rt::Flag::SignPlus as u32; + const SIGN_MINUS_BITFIELD: u32 = 1 << rt::Flag::SignMinus as u32; + match self.flags & ((1 << rt::Flag::SignPlus as u32) | (1 << rt::Flag::SignMinus as u32)) { + SIGN_PLUS_BITFIELD => Some(Sign::Plus), + SIGN_MINUS_BITFIELD => Some(Sign::Minus), + 0 => None, + _ => panic!("Invalid sign bits set in flags"), + } + } + /// Returns the current `0` flag. + #[unstable(feature = "formatting_options", issue = "118117")] + pub const fn get_sign_aware_zero_pad(&self) -> bool { + self.flags & (1 << rt::Flag::SignAwareZeroPad as u32) != 0 + } + /// Returns the current `#` flag. + #[unstable(feature = "formatting_options", issue = "118117")] + pub const fn get_alternate(&self) -> bool { + self.flags & (1 << rt::Flag::Alternate as u32) != 0 + } + /// Returns the current fill character. + #[unstable(feature = "formatting_options", issue = "118117")] + pub const fn get_fill(&self) -> char { + self.fill + } + /// Returns the current alignment. + #[unstable(feature = "formatting_options", issue = "118117")] + pub const fn get_align(&self) -> Option { + self.align + } + /// Returns the current width. + #[unstable(feature = "formatting_options", issue = "118117")] + pub const fn get_width(&self) -> Option { + self.width + } + /// Returns the current precision. + #[unstable(feature = "formatting_options", issue = "118117")] + pub const fn get_precision(&self) -> Option { + self.precision + } + /// Returns the current precision. + #[unstable(feature = "formatting_options", issue = "118117")] + pub const fn get_debug_as_hex(&self) -> Option { + const DEBUG_UPPER_BITFIELD: u32 = 1 << rt::Flag::DebugUpperHex as u32; + const DEBUG_LOWER_BITFIELD: u32 = 1 << rt::Flag::DebugLowerHex as u32; + match self.flags + & ((1 << rt::Flag::DebugUpperHex as u32) | (1 << rt::Flag::DebugLowerHex as u32)) + { + DEBUG_UPPER_BITFIELD => Some(DebugAsHex::Upper), + DEBUG_LOWER_BITFIELD => Some(DebugAsHex::Lower), + 0 => None, + _ => panic!("Invalid hex debug bits set in flags"), + } + } + + /// Creates a [`Formatter`] that writes its output to the given [`Write`] trait. + /// + /// You may alternatively use [`Formatter::new()`]. + #[unstable(feature = "formatting_options", issue = "118117")] + pub fn create_formatter<'a>(self, write: &'a mut (dyn Write + 'a)) -> Formatter<'a> { + Formatter { options: self, buf: write } + } + + #[doc(hidden)] + #[unstable( + feature = "fmt_internals", + reason = "internal routines only exposed for testing", + issue = "none" + )] + /// Flags for formatting + pub fn flags(&mut self, flags: u32) { + self.flags = flags + } + #[doc(hidden)] + #[unstable( + feature = "fmt_internals", + reason = "internal routines only exposed for testing", + issue = "none" + )] + /// Flags for formatting + pub fn get_flags(&self) -> u32 { + self.flags + } +} + +#[unstable(feature = "formatting_options", issue = "118117")] +impl Default for FormattingOptions { + /// Same as [`FormattingOptions::new()`]. + fn default() -> Self { + // The `#[derive(Default)]` implementation would set `fill` to `\0` instead of space. + Self::new() + } +} + /// Configuration for formatting. /// /// A `Formatter` represents various options related to formatting. Users do not @@ -260,34 +530,28 @@ impl Write for &mut W { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "Formatter"] pub struct Formatter<'a> { - flags: u32, - fill: char, - align: rt::Alignment, - width: Option, - precision: Option, + options: FormattingOptions, buf: &'a mut (dyn Write + 'a), } impl<'a> Formatter<'a> { - /// Creates a new formatter with default settings. + /// Creates a new formatter with given [`FormattingOptions`]. /// - /// This can be used as a micro-optimization in cases where a full `Arguments` - /// structure (as created by `format_args!`) is not necessary; `Arguments` - /// is a little more expensive to use in simple formatting scenarios. + /// If `write` is a reference to a formatter, it is recommended to use + /// [`Formatter::with_options`] instead as this can borrow the underlying + /// `write`, thereby bypassing one layer of indirection. /// - /// Currently not intended for use outside of the standard library. - #[unstable(feature = "fmt_internals", reason = "internal to standard library", issue = "none")] - #[doc(hidden)] - pub fn new(buf: &'a mut (dyn Write + 'a)) -> Formatter<'a> { - Formatter { - flags: 0, - fill: ' ', - align: rt::Alignment::Unknown, - width: None, - precision: None, - buf, - } + /// You may alternatively use [`FormattingOptions::create_formatter()`]. + #[unstable(feature = "formatting_options", issue = "118117")] + pub fn new(write: &'a mut (dyn Write + 'a), options: FormattingOptions) -> Self { + Formatter { options, buf: write } + } + + /// Creates a new formatter based on this one with given [`FormattingOptions`]. + #[unstable(feature = "formatting_options", issue = "118117")] + pub fn with_options<'b>(&'b mut self, options: FormattingOptions) -> Formatter<'b> { + Formatter { options, buf: self.buf } } } @@ -333,10 +597,6 @@ pub struct Arguments<'a> { #[unstable(feature = "fmt_internals", issue = "none")] impl<'a> Arguments<'a> { #[inline] - #[cfg_attr( - bootstrap, - rustc_const_unstable(feature = "const_fmt_arguments_new", issue = "none") - )] pub const fn new_const(pieces: &'a [&'static str; N]) -> Self { const { assert!(N <= 1) }; Arguments { pieces, fmt: None, args: &[] } @@ -345,7 +605,7 @@ impl<'a> Arguments<'a> { /// When using the format_args!() macro, this function is used to generate the /// Arguments structure. #[inline] - pub fn new_v1( + pub const fn new_v1( pieces: &'a [&'static str; P], args: &'a [rt::Argument<'a>; A], ) -> Arguments<'a> { @@ -361,7 +621,7 @@ impl<'a> Arguments<'a> { /// 2. Every `rt::Placeholder::position` value within `fmt` must be a valid index of `args`. /// 3. Every `rt::Count::Param` within `fmt` must contain a valid index of `args`. #[inline] - pub fn new_v1_formatted( + pub const fn new_v1_formatted( pieces: &'a [&'static str], args: &'a [rt::Argument<'a>], fmt: &'a [rt::Placeholder], @@ -438,7 +698,7 @@ impl<'a> Arguments<'a> { /// assert_eq!(format_args!("{:?}", std::env::current_dir()).as_str(), None); /// ``` #[stable(feature = "fmt_as_str", since = "1.52.0")] - #[rustc_const_stable(feature = "const_arguments_as_str", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_arguments_as_str", since = "1.84.0")] #[must_use] #[inline] pub const fn as_str(&self) -> Option<&'static str> { @@ -1169,7 +1429,7 @@ pub trait UpperExp { /// [`write!`]: crate::write! #[stable(feature = "rust1", since = "1.0.0")] pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result { - let mut formatter = Formatter::new(output); + let mut formatter = Formatter::new(output, FormattingOptions::new()); let mut idx = 0; match args.fmt { @@ -1218,14 +1478,14 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result { } unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::Placeholder, args: &[rt::Argument<'_>]) -> Result { - fmt.fill = arg.fill; - fmt.align = arg.align; - fmt.flags = arg.flags; + fmt.options.fill = arg.fill; + fmt.options.align = arg.align.into(); + fmt.options.flags = arg.flags; // SAFETY: arg and args come from the same Arguments, // which guarantees the indexes are always within bounds. unsafe { - fmt.width = getcount(args, &arg.width); - fmt.precision = getcount(args, &arg.precision); + fmt.options.width = getcount(args, &arg.width); + fmt.options.precision = getcount(args, &arg.precision); } // Extract the correct argument @@ -1239,15 +1499,18 @@ unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::Placeholder, args: &[rt::Argume unsafe { value.fmt(fmt) } } -unsafe fn getcount(args: &[rt::Argument<'_>], cnt: &rt::Count) -> Option { +unsafe fn getcount(args: &[rt::Argument<'_>], cnt: &rt::Count) -> Option { match *cnt { + #[cfg(bootstrap)] + rt::Count::Is(n) => Some(n as u16), + #[cfg(not(bootstrap))] rt::Count::Is(n) => Some(n), rt::Count::Implied => None, rt::Count::Param(i) => { debug_assert!(i < args.len()); // SAFETY: cnt and args come from the same Arguments, // which guarantees this index is always within bounds. - unsafe { args.get_unchecked(i).as_usize() } + unsafe { args.get_unchecked(i).as_u16() } } } } @@ -1256,11 +1519,11 @@ unsafe fn getcount(args: &[rt::Argument<'_>], cnt: &rt::Count) -> Option #[must_use = "don't forget to write the post padding"] pub(crate) struct PostPadding { fill: char, - padding: usize, + padding: u16, } impl PostPadding { - fn new(fill: char, padding: usize) -> PostPadding { + fn new(fill: char, padding: u16) -> PostPadding { PostPadding { fill, padding } } @@ -1284,11 +1547,7 @@ impl<'a> Formatter<'a> { buf: wrap(self.buf), // And preserve these - flags: self.flags, - fill: self.fill, - align: self.align, - width: self.width, - precision: self.precision, + options: self.options, } } @@ -1369,7 +1628,7 @@ impl<'a> Formatter<'a> { } // The `width` field is more of a `min-width` parameter at this point. - match self.width { + match self.options.width { // If there's no minimum length requirements then we can just // write the bytes. None => { @@ -1378,26 +1637,27 @@ impl<'a> Formatter<'a> { } // Check if we're over the minimum width, if so then we can also // just write the bytes. - Some(min) if width >= min => { + Some(min) if width >= usize::from(min) => { write_prefix(self, sign, prefix)?; self.buf.write_str(buf) } // The sign and prefix goes before the padding if the fill character // is zero Some(min) if self.sign_aware_zero_pad() => { - let old_fill = crate::mem::replace(&mut self.fill, '0'); - let old_align = crate::mem::replace(&mut self.align, rt::Alignment::Right); + let old_fill = crate::mem::replace(&mut self.options.fill, '0'); + let old_align = + crate::mem::replace(&mut self.options.align, Some(Alignment::Right)); write_prefix(self, sign, prefix)?; - let post_padding = self.padding(min - width, Alignment::Right)?; + let post_padding = self.padding(min - width as u16, Alignment::Right)?; self.buf.write_str(buf)?; post_padding.write(self)?; - self.fill = old_fill; - self.align = old_align; + self.options.fill = old_fill; + self.options.align = old_align; Ok(()) } // Otherwise, the sign and prefix goes after the padding Some(min) => { - let post_padding = self.padding(min - width, Alignment::Right)?; + let post_padding = self.padding(min - width as u16, Alignment::Right)?; write_prefix(self, sign, prefix)?; self.buf.write_str(buf)?; post_padding.write(self) @@ -1436,49 +1696,41 @@ impl<'a> Formatter<'a> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn pad(&mut self, s: &str) -> Result { - // Make sure there's a fast path up front - if self.width.is_none() && self.precision.is_none() { + // Make sure there's a fast path up front. + if self.options.width.is_none() && self.options.precision.is_none() { return self.buf.write_str(s); } - // The `precision` field can be interpreted as a `max-width` for the + + // The `precision` field can be interpreted as a maximum width for the // string being formatted. - let s = if let Some(max) = self.precision { - // If our string is longer that the precision, then we must have - // truncation. However other flags like `fill`, `width` and `align` - // must act as always. - if let Some((i, _)) = s.char_indices().nth(max) { - // LLVM here can't prove that `..i` won't panic `&s[..i]`, but - // we know that it can't panic. Use `get` + `unwrap_or` to avoid - // `unsafe` and otherwise don't emit any panic-related code - // here. - s.get(..i).unwrap_or(s) - } else { - &s - } + let (s, char_count) = if let Some(max_char_count) = self.options.precision { + let mut iter = s.char_indices(); + let remaining = match iter.advance_by(usize::from(max_char_count)) { + Ok(()) => 0, + Err(remaining) => remaining.get(), + }; + // SAFETY: The offset of `.char_indices()` is guaranteed to be + // in-bounds and between character boundaries. + let truncated = unsafe { s.get_unchecked(..iter.offset()) }; + (truncated, usize::from(max_char_count) - remaining) } else { - &s + // Use the optimized char counting algorithm for the full string. + (s, s.chars().count()) }; - // The `width` field is more of a `min-width` parameter at this point. - match self.width { - // If we're under the maximum length, and there's no minimum length - // requirements, then we can just emit the string - None => self.buf.write_str(s), - Some(width) => { - let chars_count = s.chars().count(); - // If we're under the maximum width, check if we're over the minimum - // width, if so it's as easy as just emitting the string. - if chars_count >= width { - self.buf.write_str(s) - } - // If we're under both the maximum and the minimum width, then fill - // up the minimum width with the specified string + some alignment. - else { - let align = Alignment::Left; - let post_padding = self.padding(width - chars_count, align)?; - self.buf.write_str(s)?; - post_padding.write(self) - } - } + + // The `width` field is more of a minimum width parameter at this point. + if let Some(width) = self.options.width + && char_count < usize::from(width) + { + // If we're under the minimum width, then fill up the minimum width + // with the specified string + some alignment. + let post_padding = self.padding(width - char_count as u16, Alignment::Left)?; + self.buf.write_str(s)?; + post_padding.write(self) + } else { + // If we're over the minimum width or there is no minimum width, we + // can just emit the string. + self.buf.write_str(s) } } @@ -1488,15 +1740,10 @@ impl<'a> Formatter<'a> { /// thing that is being padded. pub(crate) fn padding( &mut self, - padding: usize, + padding: u16, default: Alignment, ) -> result::Result { - let align = match self.align { - rt::Alignment::Unknown => default, - rt::Alignment::Left => Alignment::Left, - rt::Alignment::Right => Alignment::Right, - rt::Alignment::Center => Alignment::Center, - }; + let align = self.align().unwrap_or(default); let (pre_pad, post_pad) = match align { Alignment::Left => (0, padding), @@ -1505,10 +1752,10 @@ impl<'a> Formatter<'a> { }; for _ in 0..pre_pad { - self.buf.write_char(self.fill)?; + self.buf.write_char(self.options.fill)?; } - Ok(PostPadding::new(self.fill, post_pad)) + Ok(PostPadding::new(self.options.fill, post_pad)) } /// Takes the formatted parts and applies the padding. @@ -1520,12 +1767,12 @@ impl<'a> Formatter<'a> { /// /// Any `numfmt::Part::Copy` parts in `formatted` must contain valid UTF-8. unsafe fn pad_formatted_parts(&mut self, formatted: &numfmt::Formatted<'_>) -> Result { - if let Some(mut width) = self.width { + if let Some(mut width) = self.options.width { // for the sign-aware zero padding, we render the sign first and // behave as if we had no sign from the beginning. let mut formatted = formatted.clone(); - let old_fill = self.fill; - let old_align = self.align; + let old_fill = self.options.fill; + let old_align = self.options.align; if self.sign_aware_zero_pad() { // a sign always goes first let sign = formatted.sign; @@ -1533,27 +1780,27 @@ impl<'a> Formatter<'a> { // remove the sign from the formatted parts formatted.sign = ""; - width = width.saturating_sub(sign.len()); - self.fill = '0'; - self.align = rt::Alignment::Right; + width = width.saturating_sub(sign.len() as u16); + self.options.fill = '0'; + self.options.align = Some(Alignment::Right); } // remaining parts go through the ordinary padding process. let len = formatted.len(); - let ret = if width <= len { + let ret = if usize::from(width) <= len { // no padding // SAFETY: Per the precondition. unsafe { self.write_formatted_parts(&formatted) } } else { - let post_padding = self.padding(width - len, Alignment::Right)?; + let post_padding = self.padding(width - len as u16, Alignment::Right)?; // SAFETY: Per the precondition. unsafe { self.write_formatted_parts(&formatted)?; } post_padding.write(self) }; - self.fill = old_fill; - self.align = old_align; + self.options.fill = old_fill; + self.options.align = old_align; ret } else { // this is the common case and we take a shortcut @@ -1679,7 +1926,7 @@ impl<'a> Formatter<'a> { or `sign_aware_zero_pad` methods instead" )] pub fn flags(&self) -> u32 { - self.flags + self.options.flags } /// Returns the character used as 'fill' whenever there is alignment. @@ -1712,7 +1959,7 @@ impl<'a> Formatter<'a> { #[must_use] #[stable(feature = "fmt_flags", since = "1.5.0")] pub fn fill(&self) -> char { - self.fill + self.options.fill } /// Returns a flag indicating what form of alignment was requested. @@ -1747,12 +1994,7 @@ impl<'a> Formatter<'a> { #[must_use] #[stable(feature = "fmt_flags_align", since = "1.28.0")] pub fn align(&self) -> Option { - match self.align { - rt::Alignment::Left => Some(Alignment::Left), - rt::Alignment::Right => Some(Alignment::Right), - rt::Alignment::Center => Some(Alignment::Center), - rt::Alignment::Unknown => None, - } + self.options.align } /// Returns the optionally specified integer width that the output should be. @@ -1782,7 +2024,7 @@ impl<'a> Formatter<'a> { #[must_use] #[stable(feature = "fmt_flags", since = "1.5.0")] pub fn width(&self) -> Option { - self.width + self.options.width.map(|x| x as usize) } /// Returns the optionally specified precision for numeric types. @@ -1813,7 +2055,7 @@ impl<'a> Formatter<'a> { #[must_use] #[stable(feature = "fmt_flags", since = "1.5.0")] pub fn precision(&self) -> Option { - self.precision + self.options.precision.map(|x| x as usize) } /// Determines if the `+` flag was specified. @@ -1845,7 +2087,7 @@ impl<'a> Formatter<'a> { #[must_use] #[stable(feature = "fmt_flags", since = "1.5.0")] pub fn sign_plus(&self) -> bool { - self.flags & (1 << rt::Flag::SignPlus as u32) != 0 + self.options.flags & (1 << rt::Flag::SignPlus as u32) != 0 } /// Determines if the `-` flag was specified. @@ -1874,7 +2116,7 @@ impl<'a> Formatter<'a> { #[must_use] #[stable(feature = "fmt_flags", since = "1.5.0")] pub fn sign_minus(&self) -> bool { - self.flags & (1 << rt::Flag::SignMinus as u32) != 0 + self.options.flags & (1 << rt::Flag::SignMinus as u32) != 0 } /// Determines if the `#` flag was specified. @@ -1902,7 +2144,7 @@ impl<'a> Formatter<'a> { #[must_use] #[stable(feature = "fmt_flags", since = "1.5.0")] pub fn alternate(&self) -> bool { - self.flags & (1 << rt::Flag::Alternate as u32) != 0 + self.options.flags & (1 << rt::Flag::Alternate as u32) != 0 } /// Determines if the `0` flag was specified. @@ -1928,17 +2170,17 @@ impl<'a> Formatter<'a> { #[must_use] #[stable(feature = "fmt_flags", since = "1.5.0")] pub fn sign_aware_zero_pad(&self) -> bool { - self.flags & (1 << rt::Flag::SignAwareZeroPad as u32) != 0 + self.options.flags & (1 << rt::Flag::SignAwareZeroPad as u32) != 0 } // FIXME: Decide what public API we want for these two flags. // https://github.com/rust-lang/rust/issues/48584 fn debug_lower_hex(&self) -> bool { - self.flags & (1 << rt::Flag::DebugLowerHex as u32) != 0 + self.options.flags & (1 << rt::Flag::DebugLowerHex as u32) != 0 } fn debug_upper_hex(&self) -> bool { - self.flags & (1 << rt::Flag::DebugUpperHex as u32) != 0 + self.options.flags & (1 << rt::Flag::DebugUpperHex as u32) != 0 } /// Creates a [`DebugStruct`] builder designed to assist with creation of @@ -2354,6 +2596,18 @@ impl<'a> Formatter<'a> { pub fn debug_map<'b>(&'b mut self) -> DebugMap<'b, 'a> { builders::debug_map_new(self) } + + /// Returns the sign of this formatter (`+` or `-`). + #[unstable(feature = "formatting_options", issue = "118117")] + pub const fn sign(&self) -> Option { + self.options.get_sign() + } + + /// Returns the formatting options this formatter corresponds to. + #[unstable(feature = "formatting_options", issue = "118117")] + pub const fn options(&self) -> FormattingOptions { + self.options + } } #[stable(since = "1.2.0", feature = "formatter_write")] @@ -2506,10 +2760,10 @@ impl Debug for char { #[stable(feature = "rust1", since = "1.0.0")] impl Display for char { fn fmt(&self, f: &mut Formatter<'_>) -> Result { - if f.width.is_none() && f.precision.is_none() { + if f.options.width.is_none() && f.options.precision.is_none() { f.write_char(*self) } else { - f.pad(self.encode_utf8(&mut [0; 4])) + f.pad(self.encode_utf8(&mut [0; MAX_LEN_UTF8])) } } } @@ -2530,26 +2784,26 @@ impl Pointer for *const T { /// /// [problematic]: https://github.com/rust-lang/rust/issues/95489 pub(crate) fn pointer_fmt_inner(ptr_addr: usize, f: &mut Formatter<'_>) -> Result { - let old_width = f.width; - let old_flags = f.flags; + let old_width = f.options.width; + let old_flags = f.options.flags; // The alternate flag is already treated by LowerHex as being special- // it denotes whether to prefix with 0x. We use it to work out whether // or not to zero extend, and then unconditionally set it to get the // prefix. if f.alternate() { - f.flags |= 1 << (rt::Flag::SignAwareZeroPad as u32); + f.options.flags |= 1 << (rt::Flag::SignAwareZeroPad as u32); - if f.width.is_none() { - f.width = Some((usize::BITS / 4) as usize + 2); + if f.options.width.is_none() { + f.options.width = Some((usize::BITS / 4) as u16 + 2); } } - f.flags |= 1 << (rt::Flag::Alternate as u32); + f.options.flags |= 1 << (rt::Flag::Alternate as u32); let ret = LowerHex::fmt(&ptr_addr, f); - f.width = old_width; - f.flags = old_flags; + f.options.width = old_width; + f.options.flags = old_flags; ret } diff --git a/core/src/fmt/num.rs b/core/src/fmt/num.rs index 683e45b35f70a..4467b37bd4510 100644 --- a/core/src/fmt/num.rs +++ b/core/src/fmt/num.rs @@ -192,7 +192,8 @@ macro_rules! impl_Debug { } // 2 digit decimal look up table -static DEC_DIGITS_LUT: &[u8; 200] = b"0001020304050607080910111213141516171819\ +static DEC_DIGITS_LUT: &[u8; 200] = b"\ + 0001020304050607080910111213141516171819\ 2021222324252627282930313233343536373839\ 4041424344454647484950515253545556575859\ 6061626364656667686970717273747576777879\ @@ -232,83 +233,89 @@ macro_rules! impl_Display { #[cfg(not(feature = "optimize_for_size"))] impl $unsigned { - fn _fmt(mut self, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result { - const SIZE: usize = $unsigned::MAX.ilog(10) as usize + 1; - let mut buf = [MaybeUninit::::uninit(); SIZE]; - let mut curr = SIZE; - let buf_ptr = MaybeUninit::slice_as_mut_ptr(&mut buf); - let lut_ptr = DEC_DIGITS_LUT.as_ptr(); - - // SAFETY: Since `d1` and `d2` are always less than or equal to `198`, we - // can copy from `lut_ptr[d1..d1 + 1]` and `lut_ptr[d2..d2 + 1]`. To show - // that it's OK to copy into `buf_ptr`, notice that at the beginning - // `curr == buf.len() == 39 > log(n)` since `n < 2^128 < 10^39`, and at - // each step this is kept the same as `n` is divided. Since `n` is always - // non-negative, this means that `curr > 0` so `buf_ptr[curr..curr + 1]` - // is safe to access. - unsafe { - // need at least 16 bits for the 4-characters-at-a-time to work. - #[allow(overflowing_literals)] - #[allow(unused_comparisons)] - // This block will be removed for smaller types at compile time and in the worst - // case, it will prevent to have the `10000` literal to overflow for `i8` and `u8`. - if core::mem::size_of::<$unsigned>() >= 2 { - // eagerly decode 4 characters at a time - while self >= 10000 { - let rem = (self % 10000) as usize; - self /= 10000; - - let d1 = (rem / 100) << 1; - let d2 = (rem % 100) << 1; - curr -= 4; - - // We are allowed to copy to `buf_ptr[curr..curr + 3]` here since - // otherwise `curr < 0`. But then `n` was originally at least `10000^10` - // which is `10^40 > 2^128 > n`. - ptr::copy_nonoverlapping(lut_ptr.add(d1 as usize), buf_ptr.add(curr), 2); - ptr::copy_nonoverlapping(lut_ptr.add(d2 as usize), buf_ptr.add(curr + 2), 2); - } - } - - // if we reach here numbers are <= 9999, so at most 4 chars long - let mut n = self as usize; // possibly reduce 64bit math + fn _fmt(self, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result { + const MAX_DEC_N: usize = $unsigned::MAX.ilog(10) as usize + 1; + // Buffer decimals for $unsigned with right alignment. + let mut buf = [MaybeUninit::::uninit(); MAX_DEC_N]; + // Count the number of bytes in buf that are not initialized. + let mut offset = buf.len(); + // Consume the least-significant decimals from a working copy. + let mut remain = self; + + // Format per four digits from the lookup table. + // Four digits need a 16-bit $unsigned or wider. + while size_of::() > 1 && remain > 999.try_into().expect("branch is not hit for types that cannot fit 999 (u8)") { + // SAFETY: All of the decimals fit in buf due to MAX_DEC_N + // and the while condition ensures at least 4 more decimals. + unsafe { core::hint::assert_unchecked(offset >= 4) } + // SAFETY: The offset counts down from its initial buf.len() + // without underflow due to the previous precondition. + unsafe { core::hint::assert_unchecked(offset <= buf.len()) } + offset -= 4; + + // pull two pairs + let scale: Self = 1_00_00.try_into().expect("branch is not hit for types that cannot fit 1E4 (u8)"); + let quad = remain % scale; + remain /= scale; + let pair1 = (quad / 100) as usize; + let pair2 = (quad % 100) as usize; + buf[offset + 0].write(DEC_DIGITS_LUT[pair1 * 2 + 0]); + buf[offset + 1].write(DEC_DIGITS_LUT[pair1 * 2 + 1]); + buf[offset + 2].write(DEC_DIGITS_LUT[pair2 * 2 + 0]); + buf[offset + 3].write(DEC_DIGITS_LUT[pair2 * 2 + 1]); + } - // decode 2 more chars, if > 2 chars - if n >= 100 { - let d1 = (n % 100) << 1; - n /= 100; - curr -= 2; - ptr::copy_nonoverlapping(lut_ptr.add(d1), buf_ptr.add(curr), 2); - } + // Format per two digits from the lookup table. + if remain > 9 { + // SAFETY: All of the decimals fit in buf due to MAX_DEC_N + // and the while condition ensures at least 2 more decimals. + unsafe { core::hint::assert_unchecked(offset >= 2) } + // SAFETY: The offset counts down from its initial buf.len() + // without underflow due to the previous precondition. + unsafe { core::hint::assert_unchecked(offset <= buf.len()) } + offset -= 2; + + let pair = (remain % 100) as usize; + remain /= 100; + buf[offset + 0].write(DEC_DIGITS_LUT[pair * 2 + 0]); + buf[offset + 1].write(DEC_DIGITS_LUT[pair * 2 + 1]); + } - // if we reach here numbers are <= 100, so at most 2 chars long - // The biggest it can be is 99, and 99 << 1 == 198, so a `u8` is enough. - // decode last 1 or 2 chars - if n < 10 { - curr -= 1; - *buf_ptr.add(curr) = (n as u8) + b'0'; - } else { - let d1 = n << 1; - curr -= 2; - ptr::copy_nonoverlapping(lut_ptr.add(d1), buf_ptr.add(curr), 2); - } + // Format the last remaining digit, if any. + if remain != 0 || self == 0 { + // SAFETY: All of the decimals fit in buf due to MAX_DEC_N + // and the if condition ensures (at least) 1 more decimals. + unsafe { core::hint::assert_unchecked(offset >= 1) } + // SAFETY: The offset counts down from its initial buf.len() + // without underflow due to the previous precondition. + unsafe { core::hint::assert_unchecked(offset <= buf.len()) } + offset -= 1; + + // Either the compiler sees that remain < 10, or it prevents + // a boundary check up next. + let last = (remain & 15) as usize; + buf[offset].write(DEC_DIGITS_LUT[last * 2 + 1]); + // not used: remain = 0; } - // SAFETY: `curr` > 0 (since we made `buf` large enough), and all the chars are valid - // UTF-8 since `DEC_DIGITS_LUT` is - let buf_slice = unsafe { - str::from_utf8_unchecked( - slice::from_raw_parts(buf_ptr.add(curr), buf.len() - curr)) + // SAFETY: All buf content since offset is set. + let written = unsafe { buf.get_unchecked(offset..) }; + // SAFETY: Writes use ASCII from the lookup table exclusively. + let as_str = unsafe { + str::from_utf8_unchecked(slice::from_raw_parts( + MaybeUninit::slice_as_ptr(written), + written.len(), + )) }; - f.pad_integral(is_nonnegative, "", buf_slice) + f.pad_integral(is_nonnegative, "", as_str) } })* #[cfg(feature = "optimize_for_size")] fn $gen_name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result { - const SIZE: usize = $u::MAX.ilog(10) as usize + 1; - let mut buf = [MaybeUninit::::uninit(); SIZE]; - let mut curr = buf.len(); + const MAX_DEC_N: usize = $u::MAX.ilog(10) as usize + 1; + let mut buf = [MaybeUninit::::uninit(); MAX_DEC_N]; + let mut curr = MAX_DEC_N; let buf_ptr = MaybeUninit::slice_as_mut_ptr(&mut buf); // SAFETY: To show that it's OK to copy into `buf_ptr`, notice that at the beginning @@ -726,28 +733,9 @@ fn udiv_1e19(n: u128) -> (u128, u64) { let quot = if n < 1 << 83 { ((n >> 19) as u64 / (DIV >> 19)) as u128 } else { - u128_mulhi(n, FACTOR) >> 62 + n.widening_mul(FACTOR).1 >> 62 }; let rem = (n - quot * DIV as u128) as u64; (quot, rem) } - -/// Multiply unsigned 128 bit integers, return upper 128 bits of the result -#[inline] -fn u128_mulhi(x: u128, y: u128) -> u128 { - let x_lo = x as u64; - let x_hi = (x >> 64) as u64; - let y_lo = y as u64; - let y_hi = (y >> 64) as u64; - - // handle possibility of overflow - let carry = (x_lo as u128 * y_lo as u128) >> 64; - let m = x_lo as u128 * y_hi as u128 + carry; - let high1 = m >> 64; - - let m_lo = m as u64; - let high2 = (x_hi as u128 * y_lo as u128 + m_lo as u128) >> 64; - - x_hi as u128 * y_hi as u128 + high1 + high2 -} diff --git a/core/src/fmt/rt.rs b/core/src/fmt/rt.rs index af6f0da88de67..080fc6ddfc9b8 100644 --- a/core/src/fmt/rt.rs +++ b/core/src/fmt/rt.rs @@ -19,7 +19,7 @@ pub struct Placeholder { } impl Placeholder { - #[inline(always)] + #[inline] pub const fn new( position: usize, fill: char, @@ -47,7 +47,11 @@ pub enum Alignment { #[derive(Copy, Clone)] pub enum Count { /// Specified with a literal number, stores the value + #[cfg(bootstrap)] Is(usize), + /// Specified with a literal number, stores the value + #[cfg(not(bootstrap))] + Is(u16), /// Specified using `$` and `*` syntaxes, stores the index into `args` Param(usize), /// Not specified @@ -74,7 +78,7 @@ enum ArgumentType<'a> { formatter: unsafe fn(NonNull<()>, &mut Formatter<'_>) -> Result, _lifetime: PhantomData<&'a ()>, }, - Count(usize), + Count(u16), } /// This struct represents a generic "argument" which is taken by format_args!(). @@ -95,13 +99,13 @@ pub struct Argument<'a> { #[rustc_diagnostic_item = "ArgumentMethods"] impl Argument<'_> { - #[inline(always)] - fn new<'a, T>(x: &'a T, f: fn(&T, &mut Formatter<'_>) -> Result) -> Argument<'a> { + #[inline] + const fn new<'a, T>(x: &'a T, f: fn(&T, &mut Formatter<'_>) -> Result) -> Argument<'a> { Argument { // INVARIANT: this creates an `ArgumentType<'a>` from a `&'a T` and // a `fn(&T, ...)`, so the invariant is maintained. ty: ArgumentType::Placeholder { - value: NonNull::from(x).cast(), + value: NonNull::from_ref(x).cast(), // SAFETY: function pointers always have the same layout. formatter: unsafe { mem::transmute(f) }, _lifetime: PhantomData, @@ -109,49 +113,53 @@ impl Argument<'_> { } } - #[inline(always)] + #[inline] pub fn new_display(x: &T) -> Argument<'_> { Self::new(x, Display::fmt) } - #[inline(always)] + #[inline] pub fn new_debug(x: &T) -> Argument<'_> { Self::new(x, Debug::fmt) } - #[inline(always)] + #[inline] pub fn new_debug_noop(x: &T) -> Argument<'_> { Self::new(x, |_, _| Ok(())) } - #[inline(always)] + #[inline] pub fn new_octal(x: &T) -> Argument<'_> { Self::new(x, Octal::fmt) } - #[inline(always)] + #[inline] pub fn new_lower_hex(x: &T) -> Argument<'_> { Self::new(x, LowerHex::fmt) } - #[inline(always)] + #[inline] pub fn new_upper_hex(x: &T) -> Argument<'_> { Self::new(x, UpperHex::fmt) } - #[inline(always)] + #[inline] pub fn new_pointer(x: &T) -> Argument<'_> { Self::new(x, Pointer::fmt) } - #[inline(always)] + #[inline] pub fn new_binary(x: &T) -> Argument<'_> { Self::new(x, Binary::fmt) } - #[inline(always)] + #[inline] pub fn new_lower_exp(x: &T) -> Argument<'_> { Self::new(x, LowerExp::fmt) } - #[inline(always)] + #[inline] pub fn new_upper_exp(x: &T) -> Argument<'_> { Self::new(x, UpperExp::fmt) } - #[inline(always)] - pub fn from_usize(x: &usize) -> Argument<'_> { - Argument { ty: ArgumentType::Count(*x) } + #[inline] + #[track_caller] + pub const fn from_usize(x: &usize) -> Argument<'_> { + if *x > u16::MAX as usize { + panic!("Formatting argument out of range"); + } + Argument { ty: ArgumentType::Count(*x as u16) } } /// Format this placeholder argument. @@ -164,7 +172,7 @@ impl Argument<'_> { // it here is an explicit CFI violation. #[allow(inline_no_sanitize)] #[no_sanitize(cfi, kcfi)] - #[inline(always)] + #[inline] pub(super) unsafe fn fmt(&self, f: &mut Formatter<'_>) -> Result { match self.ty { // SAFETY: @@ -180,8 +188,8 @@ impl Argument<'_> { } } - #[inline(always)] - pub(super) fn as_usize(&self) -> Option { + #[inline] + pub(super) const fn as_u16(&self) -> Option { match self.ty { ArgumentType::Count(count) => Some(count), ArgumentType::Placeholder { .. } => None, @@ -198,8 +206,8 @@ impl Argument<'_> { /// let f = format_args!("{}", "a"); /// println!("{f}"); /// ``` - #[inline(always)] - pub fn none() -> [Self; 0] { + #[inline] + pub const fn none() -> [Self; 0] { [] } } @@ -215,8 +223,8 @@ pub struct UnsafeArg { impl UnsafeArg { /// See documentation where `UnsafeArg` is required to know when it is safe to /// create and use `UnsafeArg`. - #[inline(always)] - pub unsafe fn new() -> Self { + #[inline] + pub const unsafe fn new() -> Self { Self { _private: () } } } diff --git a/core/src/future/async_drop.rs b/core/src/future/async_drop.rs index 7de5fe67cd096..f1778a4d782af 100644 --- a/core/src/future/async_drop.rs +++ b/core/src/future/async_drop.rs @@ -133,7 +133,8 @@ pub trait AsyncDrop { } #[lang = "async_destruct"] -#[rustc_deny_explicit_impl(implement_via_object = false)] +#[rustc_deny_explicit_impl] +#[rustc_do_not_implement_via_object] trait AsyncDestruct { type AsyncDestructor: Future; } diff --git a/core/src/future/future.rs b/core/src/future/future.rs index 234914c20fc31..cfbd88bbe7998 100644 --- a/core/src/future/future.rs +++ b/core/src/future/future.rs @@ -25,7 +25,7 @@ use crate::task::{Context, Poll}; /// [`async`]: ../../std/keyword.async.html /// [`Waker`]: crate::task::Waker #[doc(notable_trait)] -#[cfg_attr(not(bootstrap), doc(search_unbox))] +#[doc(search_unbox)] #[must_use = "futures do nothing unless you `.await` or poll them"] #[stable(feature = "futures_api", since = "1.36.0")] #[lang = "future_trait"] diff --git a/core/src/future/mod.rs b/core/src/future/mod.rs index e5a368796ec93..65c0171c88d5b 100644 --- a/core/src/future/mod.rs +++ b/core/src/future/mod.rs @@ -46,19 +46,19 @@ pub use self::join::join; /// It also simplifies the HIR lowering of `.await`. #[lang = "ResumeTy"] #[doc(hidden)] -#[unstable(feature = "gen_future", issue = "50547")] +#[unstable(feature = "gen_future", issue = "none")] #[derive(Debug, Copy, Clone)] pub struct ResumeTy(NonNull>); -#[unstable(feature = "gen_future", issue = "50547")] +#[unstable(feature = "gen_future", issue = "none")] unsafe impl Send for ResumeTy {} -#[unstable(feature = "gen_future", issue = "50547")] +#[unstable(feature = "gen_future", issue = "none")] unsafe impl Sync for ResumeTy {} #[lang = "get_context"] #[doc(hidden)] -#[unstable(feature = "gen_future", issue = "50547")] +#[unstable(feature = "gen_future", issue = "none")] #[must_use] #[inline] pub unsafe fn get_context<'a, 'b>(cx: ResumeTy) -> &'a mut Context<'b> { diff --git a/core/src/hash/mod.rs b/core/src/hash/mod.rs index 061690e88ddf8..f7b874b26bb74 100644 --- a/core/src/hash/mod.rs +++ b/core/src/hash/mod.rs @@ -752,11 +752,8 @@ pub struct BuildHasherDefault(marker::PhantomData H>); impl BuildHasherDefault { /// Creates a new BuildHasherDefault for Hasher `H`. - #[unstable( - feature = "build_hasher_default_const_new", - issue = "123197", - reason = "recently added" - )] + #[stable(feature = "build_hasher_default_const_new", since = "1.85.0")] + #[rustc_const_stable(feature = "build_hasher_default_const_new", since = "1.85.0")] pub const fn new() -> Self { BuildHasherDefault(marker::PhantomData) } @@ -804,7 +801,7 @@ impl Eq for BuildHasherDefault {} mod impls { use super::*; - use crate::{mem, slice}; + use crate::slice; macro_rules! impl_write { ($(($ty:ident, $meth:ident),)*) => {$( @@ -817,7 +814,7 @@ mod impls { #[inline] fn hash_slice(data: &[$ty], state: &mut H) { - let newlen = mem::size_of_val(data); + let newlen = size_of_val(data); let ptr = data.as_ptr() as *const u8; // SAFETY: `ptr` is valid and aligned, as this macro is only used // for numeric primitives which have no padding. The new slice only diff --git a/core/src/hash/sip.rs b/core/src/hash/sip.rs index 6ea3241c59354..780e522c48ebf 100644 --- a/core/src/hash/sip.rs +++ b/core/src/hash/sip.rs @@ -3,7 +3,7 @@ #![allow(deprecated)] // the types in this module are deprecated use crate::marker::PhantomData; -use crate::{cmp, mem, ptr}; +use crate::{cmp, ptr}; /// An implementation of SipHash 1-3. /// @@ -99,12 +99,12 @@ macro_rules! compress { /// `$i..$i+size_of::<$int_ty>()`, so that must be in-bounds. macro_rules! load_int_le { ($buf:expr, $i:expr, $int_ty:ident) => {{ - debug_assert!($i + mem::size_of::<$int_ty>() <= $buf.len()); + debug_assert!($i + size_of::<$int_ty>() <= $buf.len()); let mut data = 0 as $int_ty; ptr::copy_nonoverlapping( $buf.as_ptr().add($i), &mut data as *mut _ as *mut u8, - mem::size_of::<$int_ty>(), + size_of::<$int_ty>(), ); data.to_le() }}; diff --git a/core/src/hint.rs b/core/src/hint.rs index 78df51f2bc47d..5ce282b05de73 100644 --- a/core/src/hint.rs +++ b/core/src/hint.rs @@ -52,7 +52,7 @@ use crate::{intrinsics, ub_checks}; /// // Safety: `divisor` can't be zero because of `prepare_inputs`, /// // but the compiler does not know about this. We *promise* /// // that we always call `prepare_inputs`. -/// std::hint::unreachable_unchecked() +/// unsafe { std::hint::unreachable_unchecked() } /// } /// // The compiler would normally introduce a check here that prevents /// // a division by zero. However, if `divisor` was zero, the branch @@ -310,6 +310,8 @@ pub fn spin_loop() { /// behavior in the calling code. This property makes `black_box` useful for writing code in which /// certain optimizations are not desired, such as benchmarks. /// +///

+/// /// [`std::convert::identity`]: crate::convert::identity /// /// # When is this useful? @@ -357,7 +361,7 @@ pub fn spin_loop() { /// ``` /// use std::hint::black_box; /// -/// // Same `contains` function +/// // Same `contains` function. /// fn contains(haystack: &[&str], needle: &str) -> bool { /// haystack.iter().any(|x| x == &needle) /// } @@ -366,8 +370,13 @@ pub fn spin_loop() { /// let haystack = vec!["abc", "def", "ghi", "jkl", "mno"]; /// let needle = "ghi"; /// for _ in 0..10 { -/// // Adjust our benchmark loop contents -/// black_box(contains(black_box(&haystack), black_box(needle))); +/// // Force the compiler to run `contains`, even though it is a pure function whose +/// // results are unused. +/// black_box(contains( +/// // Prevent the compiler from making assumptions about the input. +/// black_box(&haystack), +/// black_box(needle), +/// )); /// } /// } /// ``` @@ -382,9 +391,88 @@ pub fn spin_loop() { /// /// This makes our benchmark much more realistic to how the function would actually be used, where /// arguments are usually not known at compile time and the result is used in some way. +/// +/// # How to use this +/// +/// In practice, `black_box` serves two purposes: +/// +/// 1. It prevents the compiler from making optimizations related to the value returned by `black_box` +/// 2. It forces the value passed to `black_box` to be calculated, even if the return value of `black_box` is unused +/// +/// ``` +/// use std::hint::black_box; +/// +/// let zero = 0; +/// let five = 5; +/// +/// // The compiler will see this and remove the `* five` call, because it knows that multiplying +/// // any integer by 0 will result in 0. +/// let c = zero * five; +/// +/// // Adding `black_box` here disables the compiler's ability to reason about the first operand in the multiplication. +/// // It is forced to assume that it can be any possible number, so it cannot remove the `* five` +/// // operation. +/// let c = black_box(zero) * five; +/// ``` +/// +/// While most cases will not be as clear-cut as the above example, it still illustrates how +/// `black_box` can be used. When benchmarking a function, you usually want to wrap its inputs in +/// `black_box` so the compiler cannot make optimizations that would be unrealistic in real-life +/// use. +/// +/// ``` +/// use std::hint::black_box; +/// +/// // This is a simple function that increments its input by 1. Note that it is pure, meaning it +/// // has no side-effects. This function has no effect if its result is unused. (An example of a +/// // function *with* side-effects is `println!()`.) +/// fn increment(x: u8) -> u8 { +/// x + 1 +/// } +/// +/// // Here, we call `increment` but discard its result. The compiler, seeing this and knowing that +/// // `increment` is pure, will eliminate this function call entirely. This may not be desired, +/// // though, especially if we're trying to track how much time `increment` takes to execute. +/// let _ = increment(black_box(5)); +/// +/// // Here, we force `increment` to be executed. This is because the compiler treats `black_box` +/// // as if it has side-effects, and thus must compute its input. +/// let _ = black_box(increment(black_box(5))); +/// ``` +/// +/// There may be additional situations where you want to wrap the result of a function in +/// `black_box` to force its execution. This is situational though, and may not have any effect +/// (such as when the function returns a zero-sized type such as [`()` unit][unit]). +/// +/// Note that `black_box` has no effect on how its input is treated, only its output. As such, +/// expressions passed to `black_box` may still be optimized: +/// +/// ``` +/// use std::hint::black_box; +/// +/// // The compiler sees this... +/// let y = black_box(5 * 10); +/// +/// // ...as this. As such, it will likely simplify `5 * 10` to just `50`. +/// let _0 = 5 * 10; +/// let y = black_box(_0); +/// ``` +/// +/// In the above example, the `5 * 10` expression is considered distinct from the `black_box` call, +/// and thus is still optimized by the compiler. You can prevent this by moving the multiplication +/// operation outside of `black_box`: +/// +/// ``` +/// use std::hint::black_box; +/// +/// // No assumptions can be made about either operand, so the multiplication is not optimized out. +/// let y = black_box(5) * black_box(10); +/// ``` +/// +/// During constant evaluation, `black_box` is treated as a no-op. #[inline] #[stable(feature = "bench_black_box", since = "1.66.0")] -#[rustc_const_unstable(feature = "const_black_box", issue = "none")] +#[rustc_const_stable(feature = "const_black_box", since = "1.86.0")] pub const fn black_box(dummy: T) -> T { crate::intrinsics::black_box(dummy) } @@ -506,9 +594,143 @@ pub const fn black_box(dummy: T) -> T { /// # } /// ``` #[unstable(feature = "hint_must_use", issue = "94745")] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "hint_must_use", issue = "94745"))] #[must_use] // <-- :) #[inline(always)] pub const fn must_use(value: T) -> T { value } + +/// Hints to the compiler that a branch condition is likely to be true. +/// Returns the value passed to it. +/// +/// It can be used with `if` or boolean `match` expressions. +/// +/// When used outside of a branch condition, it may still influence a nearby branch, but +/// probably will not have any effect. +/// +/// It can also be applied to parts of expressions, such as `likely(a) && unlikely(b)`, or to +/// compound expressions, such as `likely(a && b)`. When applied to compound expressions, it has +/// the following effect: +/// ```text +/// likely(!a) => !unlikely(a) +/// likely(a && b) => likely(a) && likely(b) +/// likely(a || b) => a || likely(b) +/// ``` +/// +/// See also the function [`cold_path()`] which may be more appropriate for idiomatic Rust code. +/// +/// # Examples +/// +/// ``` +/// #![feature(likely_unlikely)] +/// use core::hint::likely; +/// +/// fn foo(x: i32) { +/// if likely(x > 0) { +/// println!("this branch is likely to be taken"); +/// } else { +/// println!("this branch is unlikely to be taken"); +/// } +/// +/// match likely(x > 0) { +/// true => println!("this branch is likely to be taken"), +/// false => println!("this branch is unlikely to be taken"), +/// } +/// +/// // Use outside of a branch condition may still influence a nearby branch +/// let cond = likely(x != 0); +/// if cond { +/// println!("this branch is likely to be taken"); +/// } +/// } +/// ``` +/// +/// +#[unstable(feature = "likely_unlikely", issue = "136873")] +#[inline(always)] +pub const fn likely(b: bool) -> bool { + crate::intrinsics::likely(b) +} + +/// Hints to the compiler that a branch condition is unlikely to be true. +/// Returns the value passed to it. +/// +/// It can be used with `if` or boolean `match` expressions. +/// +/// When used outside of a branch condition, it may still influence a nearby branch, but +/// probably will not have any effect. +/// +/// It can also be applied to parts of expressions, such as `likely(a) && unlikely(b)`, or to +/// compound expressions, such as `unlikely(a && b)`. When applied to compound expressions, it has +/// the following effect: +/// ```text +/// unlikely(!a) => !likely(a) +/// unlikely(a && b) => a && unlikely(b) +/// unlikely(a || b) => unlikely(a) || unlikely(b) +/// ``` +/// +/// See also the function [`cold_path()`] which may be more appropriate for idiomatic Rust code. +/// +/// # Examples +/// +/// ``` +/// #![feature(likely_unlikely)] +/// use core::hint::unlikely; +/// +/// fn foo(x: i32) { +/// if unlikely(x > 0) { +/// println!("this branch is unlikely to be taken"); +/// } else { +/// println!("this branch is likely to be taken"); +/// } +/// +/// match unlikely(x > 0) { +/// true => println!("this branch is unlikely to be taken"), +/// false => println!("this branch is likely to be taken"), +/// } +/// +/// // Use outside of a branch condition may still influence a nearby branch +/// let cond = unlikely(x != 0); +/// if cond { +/// println!("this branch is likely to be taken"); +/// } +/// } +/// ``` +#[unstable(feature = "likely_unlikely", issue = "136873")] +#[inline(always)] +pub const fn unlikely(b: bool) -> bool { + crate::intrinsics::unlikely(b) +} + +/// Hints to the compiler that given path is cold, i.e., unlikely to be taken. The compiler may +/// choose to optimize paths that are not cold at the expense of paths that are cold. +/// +/// # Examples +/// +/// ``` +/// #![feature(cold_path)] +/// use core::hint::cold_path; +/// +/// fn foo(x: &[i32]) { +/// if let Some(first) = x.get(0) { +/// // this is the fast path +/// } else { +/// // this path is unlikely +/// cold_path(); +/// } +/// } +/// +/// fn bar(x: i32) -> i32 { +/// match x { +/// 1 => 10, +/// 2 => 100, +/// 3 => { cold_path(); 1000 }, // this branch is unlikely +/// _ => { cold_path(); 10000 }, // this is also unlikely +/// } +/// } +/// ``` +#[unstable(feature = "cold_path", issue = "136873")] +#[inline(always)] +pub const fn cold_path() { + crate::intrinsics::cold_path() +} diff --git a/core/src/intrinsics/fallback.rs b/core/src/intrinsics/fallback.rs new file mode 100644 index 0000000000000..eec5c4d646d07 --- /dev/null +++ b/core/src/intrinsics/fallback.rs @@ -0,0 +1,150 @@ +#![unstable( + feature = "core_intrinsics_fallbacks", + reason = "The fallbacks will never be stable, as they exist only to be called \ + by the fallback MIR, but they're exported so they can be tested on \ + platforms where the fallback MIR isn't actually used", + issue = "none" +)] +#![allow(missing_docs)] + +#[const_trait] +#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")] +pub trait CarryingMulAdd: Copy + 'static { + type Unsigned: Copy + 'static; + fn carrying_mul_add( + self, + multiplicand: Self, + addend: Self, + carry: Self, + ) -> (Self::Unsigned, Self); +} + +macro_rules! impl_carrying_mul_add_by_widening { + ($($t:ident $u:ident $w:ident,)+) => {$( + #[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")] + impl const CarryingMulAdd for $t { + type Unsigned = $u; + #[inline] + fn carrying_mul_add(self, a: Self, b: Self, c: Self) -> ($u, $t) { + let wide = (self as $w) * (a as $w) + (b as $w) + (c as $w); + (wide as _, (wide >> Self::BITS) as _) + } + } + )+}; +} +impl_carrying_mul_add_by_widening! { + u8 u8 u16, + u16 u16 u32, + u32 u32 u64, + u64 u64 u128, + usize usize UDoubleSize, + i8 u8 i16, + i16 u16 i32, + i32 u32 i64, + i64 u64 i128, + isize usize UDoubleSize, +} + +#[cfg(target_pointer_width = "16")] +type UDoubleSize = u32; +#[cfg(target_pointer_width = "32")] +type UDoubleSize = u64; +#[cfg(target_pointer_width = "64")] +type UDoubleSize = u128; + +#[inline] +const fn wide_mul_u128(a: u128, b: u128) -> (u128, u128) { + #[inline] + const fn to_low_high(x: u128) -> [u128; 2] { + const MASK: u128 = u64::MAX as _; + [x & MASK, x >> 64] + } + #[inline] + const fn from_low_high(x: [u128; 2]) -> u128 { + x[0] | (x[1] << 64) + } + #[inline] + const fn scalar_mul(low_high: [u128; 2], k: u128) -> [u128; 3] { + let [x, c] = to_low_high(k * low_high[0]); + let [y, z] = to_low_high(k * low_high[1] + c); + [x, y, z] + } + let a = to_low_high(a); + let b = to_low_high(b); + let low = scalar_mul(a, b[0]); + let high = scalar_mul(a, b[1]); + let r0 = low[0]; + let [r1, c] = to_low_high(low[1] + high[0]); + let [r2, c] = to_low_high(low[2] + high[1] + c); + let r3 = high[2] + c; + (from_low_high([r0, r1]), from_low_high([r2, r3])) +} + +#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")] +impl const CarryingMulAdd for u128 { + type Unsigned = u128; + #[inline] + fn carrying_mul_add(self, b: u128, c: u128, d: u128) -> (u128, u128) { + let (low, mut high) = wide_mul_u128(self, b); + let (low, carry) = u128::overflowing_add(low, c); + high += carry as u128; + let (low, carry) = u128::overflowing_add(low, d); + high += carry as u128; + (low, high) + } +} + +#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")] +impl const CarryingMulAdd for i128 { + type Unsigned = u128; + #[inline] + fn carrying_mul_add(self, b: i128, c: i128, d: i128) -> (u128, i128) { + let (low, high) = wide_mul_u128(self as u128, b as u128); + let mut high = high as i128; + high = high.wrapping_add(i128::wrapping_mul(self >> 127, b)); + high = high.wrapping_add(i128::wrapping_mul(self, b >> 127)); + let (low, carry) = u128::overflowing_add(low, c as u128); + high = high.wrapping_add((carry as i128) + (c >> 127)); + let (low, carry) = u128::overflowing_add(low, d as u128); + high = high.wrapping_add((carry as i128) + (d >> 127)); + (low, high) + } +} + +#[const_trait] +#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")] +pub trait DisjointBitOr: Copy + 'static { + /// See [`super::disjoint_bitor`]; we just need the trait indirection to handle + /// different types since calling intrinsics with generics doesn't work. + unsafe fn disjoint_bitor(self, other: Self) -> Self; +} +macro_rules! zero { + (bool) => { + false + }; + ($t:ident) => { + 0 + }; +} +macro_rules! impl_disjoint_bitor { + ($($t:ident,)+) => {$( + #[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")] + impl const DisjointBitOr for $t { + #[cfg_attr(miri, track_caller)] + #[inline] + unsafe fn disjoint_bitor(self, other: Self) -> Self { + // Note that the assume here is required for UB detection in Miri! + + // SAFETY: our precondition is that there are no bits in common, + // so this is just telling that to the backend. + unsafe { super::assume((self & other) == zero!($t)) }; + self | other + } + } + )+}; +} +impl_disjoint_bitor! { + bool, + u8, u16, u32, u64, u128, usize, + i8, i16, i32, i64, i128, isize, +} diff --git a/core/src/intrinsics/mir.rs b/core/src/intrinsics/mir.rs index 6539964bc0956..55dcf7cd47e97 100644 --- a/core/src/intrinsics/mir.rs +++ b/core/src/intrinsics/mir.rs @@ -249,6 +249,39 @@ //! `Call(ret_val = function(arg1, arg2, ...), ReturnTo(next_block), UnwindContinue())`. //! - [`TailCall`] does not have a return destination or next block, so its syntax is just //! `TailCall(function(arg1, arg2, ...))`. +//! +//! #### Debuginfo +//! +//! Debuginfo associates source code variable names (of variables that may not exist any more) with +//! MIR expressions that indicate where the value of that variable is stored. The syntax to do so +//! is: +//! ```text +//! debug source_var_name => expression; +//! ``` +//! Both places and constants are supported in the `expression`. +//! +//! ```rust +//! #![allow(internal_features)] +//! #![feature(core_intrinsics, custom_mir)] +//! +//! use core::intrinsics::mir::*; +//! +//! #[custom_mir(dialect = "built")] +//! fn debuginfo(arg: Option<&i32>) { +//! mir!( +//! // Debuginfo for a source variable `plain_local` that just duplicates `arg`. +//! debug plain_local => arg; +//! // Debuginfo for a source variable `projection` that can be computed by dereferencing +//! // a field of `arg`. +//! debug projection => *Field::<&i32>(Variant(arg, 1), 0); +//! // Debuginfo for a source variable `constant` that always holds the value `5`. +//! debug constant => 5_usize; +//! { +//! Return() +//! } +//! ) +//! } +//! ``` #![unstable( feature = "custom_mir", diff --git a/core/src/intrinsics/mod.rs b/core/src/intrinsics/mod.rs index 2f75bfae988f2..ead7b2d29655b 100644 --- a/core/src/intrinsics/mod.rs +++ b/core/src/intrinsics/mod.rs @@ -10,7 +10,7 @@ //! //! In order to make an intrinsic usable at compile-time, it needs to be declared in the "new" //! style, i.e. as a `#[rustc_intrinsic]` function, not inside an `extern` block. Then copy the -//! implementation from to +//! implementation from to //! //! and make the intrinsic declaration a `const fn`. //! @@ -68,6 +68,7 @@ use crate::marker::{DiscriminantKind, Tuple}; use crate::mem::SizedTypeProperties; use crate::{ptr, ub_checks}; +pub mod fallback; pub mod mir; pub mod simd; @@ -77,7 +78,7 @@ pub mod simd; use crate::sync::atomic::{self, AtomicBool, AtomicI32, AtomicIsize, AtomicU32, Ordering}; #[stable(feature = "drop_in_place", since = "1.8.0")] -#[rustc_allowed_through_unstable_modules] +#[rustc_allowed_through_unstable_modules = "import this function via `std::ptr` instead"] #[deprecated(note = "no longer an intrinsic - use `ptr::drop_in_place` directly", since = "1.52.0")] #[inline] pub unsafe fn drop_in_place(to_drop: *mut T) { @@ -95,11 +96,8 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { /// [`Ordering::Relaxed`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_relaxed_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_relaxed_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -107,11 +105,8 @@ pub unsafe fn atomic_cxchg_relaxed_relaxed(_dst: *mut T, _old: T, _src: /// [`Ordering::Relaxed`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_relaxed_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_relaxed_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -119,11 +114,8 @@ pub unsafe fn atomic_cxchg_relaxed_acquire(_dst: *mut T, _old: T, _src: /// [`Ordering::Relaxed`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_relaxed_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_relaxed_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -131,11 +123,8 @@ pub unsafe fn atomic_cxchg_relaxed_seqcst(_dst: *mut T, _old: T, _src: /// [`Ordering::Acquire`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acquire_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acquire_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -143,11 +132,8 @@ pub unsafe fn atomic_cxchg_acquire_relaxed(_dst: *mut T, _old: T, _src: /// [`Ordering::Acquire`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acquire_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acquire_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -155,11 +141,8 @@ pub unsafe fn atomic_cxchg_acquire_acquire(_dst: *mut T, _old: T, _src: /// [`Ordering::Acquire`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acquire_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acquire_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -167,11 +150,8 @@ pub unsafe fn atomic_cxchg_acquire_seqcst(_dst: *mut T, _old: T, _src: /// [`Ordering::Release`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_release_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_release_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -179,11 +159,8 @@ pub unsafe fn atomic_cxchg_release_relaxed(_dst: *mut T, _old: T, _src: /// [`Ordering::Release`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_release_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_release_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -191,11 +168,8 @@ pub unsafe fn atomic_cxchg_release_acquire(_dst: *mut T, _old: T, _src: /// [`Ordering::Release`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_release_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_release_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -203,11 +177,8 @@ pub unsafe fn atomic_cxchg_release_seqcst(_dst: *mut T, _old: T, _src: /// [`Ordering::AcqRel`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acqrel_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acqrel_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -215,11 +186,8 @@ pub unsafe fn atomic_cxchg_acqrel_relaxed(_dst: *mut T, _old: T, _src: /// [`Ordering::AcqRel`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acqrel_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acqrel_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -227,11 +195,8 @@ pub unsafe fn atomic_cxchg_acqrel_acquire(_dst: *mut T, _old: T, _src: /// [`Ordering::AcqRel`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acqrel_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acqrel_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -239,11 +204,8 @@ pub unsafe fn atomic_cxchg_acqrel_seqcst(_dst: *mut T, _old: T, _src: T /// [`Ordering::SeqCst`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_seqcst_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_seqcst_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -251,11 +213,8 @@ pub unsafe fn atomic_cxchg_seqcst_relaxed(_dst: *mut T, _old: T, _src: /// [`Ordering::SeqCst`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_seqcst_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_seqcst_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -263,11 +222,8 @@ pub unsafe fn atomic_cxchg_seqcst_acquire(_dst: *mut T, _old: T, _src: /// [`Ordering::SeqCst`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_seqcst_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_seqcst_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -276,15 +232,12 @@ pub unsafe fn atomic_cxchg_seqcst_seqcst(_dst: *mut T, _old: T, _src: T /// [`Ordering::Relaxed`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_relaxed_relaxed( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -292,15 +245,12 @@ pub unsafe fn atomic_cxchgweak_relaxed_relaxed( /// [`Ordering::Relaxed`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_relaxed_acquire( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -308,15 +258,8 @@ pub unsafe fn atomic_cxchgweak_relaxed_acquire( /// [`Ordering::Relaxed`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_relaxed_seqcst( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_relaxed_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -324,15 +267,12 @@ pub unsafe fn atomic_cxchgweak_relaxed_seqcst( /// [`Ordering::Acquire`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_acquire_relaxed( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -340,15 +280,12 @@ pub unsafe fn atomic_cxchgweak_acquire_relaxed( /// [`Ordering::Acquire`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_acquire_acquire( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -356,15 +293,8 @@ pub unsafe fn atomic_cxchgweak_acquire_acquire( /// [`Ordering::Acquire`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_acquire_seqcst( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_acquire_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -372,15 +302,12 @@ pub unsafe fn atomic_cxchgweak_acquire_seqcst( /// [`Ordering::Release`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_release_relaxed( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -388,15 +315,12 @@ pub unsafe fn atomic_cxchgweak_release_relaxed( /// [`Ordering::Release`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_release_acquire( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -404,15 +328,8 @@ pub unsafe fn atomic_cxchgweak_release_acquire( /// [`Ordering::Release`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_release_seqcst( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_release_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -420,15 +337,8 @@ pub unsafe fn atomic_cxchgweak_release_seqcst( /// [`Ordering::AcqRel`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_acqrel_relaxed( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_acqrel_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -436,15 +346,8 @@ pub unsafe fn atomic_cxchgweak_acqrel_relaxed( /// [`Ordering::AcqRel`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_acqrel_acquire( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_acqrel_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -452,11 +355,8 @@ pub unsafe fn atomic_cxchgweak_acqrel_acquire( /// [`Ordering::AcqRel`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_acqrel_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_acqrel_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -464,15 +364,8 @@ pub unsafe fn atomic_cxchgweak_acqrel_seqcst(_dst: *mut T, _old: T, _sr /// [`Ordering::SeqCst`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_seqcst_relaxed( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_seqcst_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -480,15 +373,8 @@ pub unsafe fn atomic_cxchgweak_seqcst_relaxed( /// [`Ordering::SeqCst`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_seqcst_acquire( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_seqcst_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -496,11 +382,8 @@ pub unsafe fn atomic_cxchgweak_seqcst_acquire( /// [`Ordering::SeqCst`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_seqcst_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_seqcst_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Loads the current value of the pointer. /// @@ -508,42 +391,30 @@ pub unsafe fn atomic_cxchgweak_seqcst_seqcst(_dst: *mut T, _old: T, _sr /// [`atomic`] types via the `load` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::load`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_load_seqcst(_src: *const T) -> T { - unreachable!() -} +pub unsafe fn atomic_load_seqcst(src: *const T) -> T; /// Loads the current value of the pointer. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `load` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::load`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_load_acquire(_src: *const T) -> T { - unreachable!() -} +pub unsafe fn atomic_load_acquire(src: *const T) -> T; /// Loads the current value of the pointer. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `load` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::load`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_load_relaxed(_src: *const T) -> T { - unreachable!() -} +pub unsafe fn atomic_load_relaxed(src: *const T) -> T; /// Do NOT use this intrinsic; "unordered" operations do not exist in our memory model! /// In terms of the Rust Abstract Machine, this operation is equivalent to `src.read()`, /// i.e., it performs a non-atomic read. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_load_unordered(_src: *const T) -> T { - unreachable!() -} +pub unsafe fn atomic_load_unordered(src: *const T) -> T; /// Stores the value at the specified memory location. /// @@ -551,42 +422,30 @@ pub unsafe fn atomic_load_unordered(_src: *const T) -> T { /// [`atomic`] types via the `store` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::store`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_store_seqcst(_dst: *mut T, _val: T) { - unreachable!() -} +pub unsafe fn atomic_store_seqcst(dst: *mut T, val: T); /// Stores the value at the specified memory location. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `store` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::store`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_store_release(_dst: *mut T, _val: T) { - unreachable!() -} +pub unsafe fn atomic_store_release(dst: *mut T, val: T); /// Stores the value at the specified memory location. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `store` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::store`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_store_relaxed(_dst: *mut T, _val: T) { - unreachable!() -} +pub unsafe fn atomic_store_relaxed(dst: *mut T, val: T); /// Do NOT use this intrinsic; "unordered" operations do not exist in our memory model! /// In terms of the Rust Abstract Machine, this operation is equivalent to `dst.write(val)`, /// i.e., it performs a non-atomic write. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_store_unordered(_dst: *mut T, _val: T) { - unreachable!() -} +pub unsafe fn atomic_store_unordered(dst: *mut T, val: T); /// Stores the value at the specified memory location, returning the old value. /// @@ -594,55 +453,40 @@ pub unsafe fn atomic_store_unordered(_dst: *mut T, _val: T) { /// [`atomic`] types via the `swap` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::swap`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xchg_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xchg_seqcst(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::swap`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xchg_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xchg_acquire(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::swap`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xchg_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xchg_release(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::swap`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xchg_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xchg_acqrel(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::swap`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xchg_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xchg_relaxed(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// @@ -650,55 +494,40 @@ pub unsafe fn atomic_xchg_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] types via the `fetch_add` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicIsize::fetch_add`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xadd_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xadd_seqcst(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicIsize::fetch_add`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xadd_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xadd_acquire(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicIsize::fetch_add`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xadd_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xadd_release(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicIsize::fetch_add`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xadd_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xadd_acqrel(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicIsize::fetch_add`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xadd_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xadd_relaxed(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// @@ -706,55 +535,40 @@ pub unsafe fn atomic_xadd_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] types via the `fetch_sub` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xsub_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xsub_seqcst(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xsub_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xsub_acquire(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xsub_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xsub_release(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xsub_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xsub_acqrel(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xsub_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xsub_relaxed(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// @@ -762,55 +576,40 @@ pub unsafe fn atomic_xsub_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] types via the `fetch_and` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_and`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_and_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_and_seqcst(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_and`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_and_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_and_acquire(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_and`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_and_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_and_release(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_and`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_and_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_and_acqrel(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_and`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_and_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_and_relaxed(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// @@ -818,55 +617,40 @@ pub unsafe fn atomic_and_relaxed(_dst: *mut T, _src: T) -> T { /// [`AtomicBool`] type via the `fetch_nand` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_nand`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_nand_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_nand_seqcst(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_nand`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_nand_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_nand_acquire(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_nand`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_nand_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_nand_release(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_nand`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_nand_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_nand_acqrel(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_nand`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_nand_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_nand_relaxed(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// @@ -874,55 +658,40 @@ pub unsafe fn atomic_nand_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] types via the `fetch_or` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_or`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_or_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_or_seqcst(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_or`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_or_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_or_acquire(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_or`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_or_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_or_release(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_or`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_or_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_or_acqrel(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_or`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_or_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_or_relaxed(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// @@ -930,55 +699,40 @@ pub unsafe fn atomic_or_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] types via the `fetch_xor` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_xor`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xor_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xor_seqcst(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_xor`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xor_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xor_acquire(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_xor`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xor_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xor_release(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_xor`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xor_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xor_acqrel(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_xor`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xor_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xor_relaxed(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. /// @@ -986,55 +740,40 @@ pub unsafe fn atomic_xor_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] signed integer types via the `fetch_max` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicI32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_max_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_max_seqcst(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicI32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_max_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_max_acquire(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicI32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_max_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_max_release(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicI32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_max_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_max_acqrel(dst: *mut T, src: T) -> T; /// Maximum with the current value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicI32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_max_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_max_relaxed(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// @@ -1042,55 +781,40 @@ pub unsafe fn atomic_max_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] signed integer types via the `fetch_min` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicI32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_min_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_min_seqcst(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicI32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_min_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_min_acquire(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicI32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_min_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_min_release(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicI32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_min_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_min_acqrel(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicI32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_min_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_min_relaxed(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// @@ -1098,55 +822,40 @@ pub unsafe fn atomic_min_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] unsigned integer types via the `fetch_min` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicU32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umin_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umin_seqcst(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicU32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umin_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umin_acquire(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicU32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umin_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umin_release(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicU32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umin_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umin_acqrel(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicU32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umin_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umin_relaxed(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// @@ -1154,55 +863,40 @@ pub unsafe fn atomic_umin_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] unsigned integer types via the `fetch_max` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicU32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umax_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umax_seqcst(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicU32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umax_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umax_acquire(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicU32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umax_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umax_release(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicU32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umax_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umax_acqrel(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicU32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umax_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umax_relaxed(dst: *mut T, src: T) -> T; /// An atomic fence. /// @@ -1210,44 +904,32 @@ pub unsafe fn atomic_umax_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic::fence`] by passing [`Ordering::SeqCst`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_fence_seqcst() { - unreachable!() -} +pub unsafe fn atomic_fence_seqcst(); /// An atomic fence. /// /// The stabilized version of this intrinsic is available in /// [`atomic::fence`] by passing [`Ordering::Acquire`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_fence_acquire() { - unreachable!() -} +pub unsafe fn atomic_fence_acquire(); /// An atomic fence. /// /// The stabilized version of this intrinsic is available in /// [`atomic::fence`] by passing [`Ordering::Release`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_fence_release() { - unreachable!() -} +pub unsafe fn atomic_fence_release(); /// An atomic fence. /// /// The stabilized version of this intrinsic is available in /// [`atomic::fence`] by passing [`Ordering::AcqRel`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_fence_acqrel() { - unreachable!() -} +pub unsafe fn atomic_fence_acqrel(); /// A compiler-only memory barrier. /// @@ -1260,11 +942,8 @@ pub unsafe fn atomic_fence_acqrel() { /// [`atomic::compiler_fence`] by passing [`Ordering::SeqCst`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_singlethreadfence_seqcst() { - unreachable!() -} +pub unsafe fn atomic_singlethreadfence_seqcst(); /// A compiler-only memory barrier. /// /// Memory accesses will never be reordered across this barrier by the @@ -1276,11 +955,8 @@ pub unsafe fn atomic_singlethreadfence_seqcst() { /// [`atomic::compiler_fence`] by passing [`Ordering::Acquire`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_singlethreadfence_acquire() { - unreachable!() -} +pub unsafe fn atomic_singlethreadfence_acquire(); /// A compiler-only memory barrier. /// /// Memory accesses will never be reordered across this barrier by the @@ -1292,11 +968,8 @@ pub unsafe fn atomic_singlethreadfence_acquire() { /// [`atomic::compiler_fence`] by passing [`Ordering::Release`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_singlethreadfence_release() { - unreachable!() -} +pub unsafe fn atomic_singlethreadfence_release(); /// A compiler-only memory barrier. /// /// Memory accesses will never be reordered across this barrier by the @@ -1308,11 +981,8 @@ pub unsafe fn atomic_singlethreadfence_release() { /// [`atomic::compiler_fence`] by passing [`Ordering::AcqRel`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_singlethreadfence_acqrel() { - unreachable!() -} +pub unsafe fn atomic_singlethreadfence_acqrel(); /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction /// if supported; otherwise, it is a no-op. @@ -1324,11 +994,8 @@ pub unsafe fn atomic_singlethreadfence_acqrel() { /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn prefetch_read_data(_data: *const T, _locality: i32) { - unreachable!() -} +pub unsafe fn prefetch_read_data(data: *const T, locality: i32); /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction /// if supported; otherwise, it is a no-op. /// Prefetches have no effect on the behavior of the program but can change its performance @@ -1339,11 +1006,8 @@ pub unsafe fn prefetch_read_data(_data: *const T, _locality: i32) { /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn prefetch_write_data(_data: *const T, _locality: i32) { - unreachable!() -} +pub unsafe fn prefetch_write_data(data: *const T, locality: i32); /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction /// if supported; otherwise, it is a no-op. /// Prefetches have no effect on the behavior of the program but can change its performance @@ -1354,11 +1018,8 @@ pub unsafe fn prefetch_write_data(_data: *const T, _locality: i32) { /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn prefetch_read_instruction(_data: *const T, _locality: i32) { - unreachable!() -} +pub unsafe fn prefetch_read_instruction(data: *const T, locality: i32); /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction /// if supported; otherwise, it is a no-op. /// Prefetches have no effect on the behavior of the program but can change its performance @@ -1369,21 +1030,15 @@ pub unsafe fn prefetch_read_instruction(_data: *const T, _locality: i32) { /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn prefetch_write_instruction(_data: *const T, _locality: i32) { - unreachable!() -} +pub unsafe fn prefetch_write_instruction(data: *const T, locality: i32); /// Executes a breakpoint trap, for inspection by a debugger. /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn breakpoint() { - unreachable!() -} +pub fn breakpoint(); /// Magic intrinsic that derives its meaning from attributes /// attached to the function. @@ -1396,10 +1051,7 @@ pub unsafe fn breakpoint() { /// This intrinsic should not be used outside of the compiler. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn rustc_peek(_: T) -> T { - unreachable!() -} +pub fn rustc_peek(_: T) -> T; /// Aborts the execution of the process. /// @@ -1418,10 +1070,7 @@ pub fn rustc_peek(_: T) -> T { /// `SIGBUS`. The precise behavior is not guaranteed and not stable. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn abort() -> ! { - unreachable!() -} +pub fn abort() -> !; /// Informs the optimizer that this point in the code is not reachable, /// enabling further optimizations. @@ -1431,17 +1080,10 @@ pub fn abort() -> ! { /// reach code marked with this function. /// /// The stabilized version of this intrinsic is [`core::hint::unreachable_unchecked`]. -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0") -)] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unreachable() -> ! { - unreachable!() -} +pub const unsafe fn unreachable() -> !; /// Informs the optimizer that a condition is always true. /// If the condition is false, the behavior is undefined. @@ -1453,8 +1095,7 @@ pub const unsafe fn unreachable() -> ! { /// own, or if it does not enable any significant optimizations. /// /// The stabilized version of this intrinsic is [`core::hint::assert_unchecked`]. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_assume", since = "1.77.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] @@ -1474,8 +1115,7 @@ pub const unsafe fn assume(b: bool) { /// /// This intrinsic does not have a stable counterpart. #[unstable(feature = "core_intrinsics", issue = "none")] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] -#[cfg(not(bootstrap))] +#[rustc_intrinsic] #[rustc_nounwind] #[miri::intrinsic_fallback_is_spec] #[cold] @@ -1492,19 +1132,10 @@ pub const fn cold_path() {} /// any safety invariants. /// /// This intrinsic does not have a stable counterpart. -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_likely", since = "CURRENT_RUSTC_VERSION") -)] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_nounwind] #[inline(always)] pub const fn likely(b: bool) -> bool { - #[cfg(bootstrap)] - { - b - } - #[cfg(not(bootstrap))] if b { true } else { @@ -1524,19 +1155,10 @@ pub const fn likely(b: bool) -> bool { /// any safety invariants. /// /// This intrinsic does not have a stable counterpart. -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_likely", since = "CURRENT_RUSTC_VERSION") -)] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_nounwind] #[inline(always)] pub const fn unlikely(b: bool) -> bool { - #[cfg(bootstrap)] - { - b - } - #[cfg(not(bootstrap))] if b { cold_path(); true @@ -1556,7 +1178,7 @@ pub const fn unlikely(b: bool) -> bool { /// Therefore, implementations must not require the user to uphold /// any safety invariants. /// -/// This intrinsic does not have a stable counterpart. +/// The public form of this instrinsic is [`bool::select_unpredictable`]. #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] #[rustc_nounwind] @@ -1570,39 +1192,27 @@ pub fn select_unpredictable(b: bool, true_val: T, false_val: T) -> T { /// This will statically either panic, or do nothing. /// /// This intrinsic does not have a stable counterpart. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_assert_type", since = "1.59.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn assert_inhabited() { - unreachable!() -} +pub const fn assert_inhabited(); /// A guard for unsafe functions that cannot ever be executed if `T` does not permit /// zero-initialization: This will statically either panic, or do nothing. /// /// This intrinsic does not have a stable counterpart. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_assert_type2", since = "1.75.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn assert_zero_valid() { - unreachable!() -} +pub const fn assert_zero_valid(); /// A guard for `std::mem::uninitialized`. This will statically either panic, or do nothing. /// /// This intrinsic does not have a stable counterpart. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_assert_type2", since = "1.75.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn assert_mem_uninitialized_valid() { - unreachable!() -} +pub const fn assert_mem_uninitialized_valid(); /// Gets a reference to a static `Location` indicating where it was called. /// @@ -1612,14 +1222,10 @@ pub const fn assert_mem_uninitialized_valid() { /// any safety invariants. /// /// Consider using [`core::panic::Location::caller`] instead. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_caller_location", since = "1.79.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn caller_location() -> &'static crate::panic::Location<'static> { - unreachable!() -} +pub const fn caller_location() -> &'static crate::panic::Location<'static>; /// Moves a value out of scope without running drop glue. /// @@ -1630,14 +1236,10 @@ pub const fn caller_location() -> &'static crate::panic::Location<'static> { /// it does not require an `unsafe` block. /// Therefore, implementations must not require the user to uphold /// any safety invariants. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_intrinsic_forget", since = "1.83.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn forget(_: T) { - unreachable!() -} +pub const fn forget(_: T); /// Reinterprets the bits of a value of one type as another type. /// @@ -1727,12 +1329,12 @@ pub const fn forget(_: T) { /// ``` /// struct R<'a>(&'a i32); /// unsafe fn extend_lifetime<'b>(r: R<'b>) -> R<'static> { -/// std::mem::transmute::, R<'static>>(r) +/// unsafe { std::mem::transmute::, R<'static>>(r) } /// } /// /// unsafe fn shorten_invariant_lifetime<'b, 'c>(r: &'b mut R<'static>) /// -> &'b mut R<'c> { -/// std::mem::transmute::<&'b mut R<'static>, &'b mut R<'c>>(r) +/// unsafe { std::mem::transmute::<&'b mut R<'static>, &'b mut R<'c>>(r) } /// } /// ``` /// @@ -1925,15 +1527,12 @@ pub const fn forget(_: T) { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_allowed_through_unstable_modules] +#[rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"] #[rustc_const_stable(feature = "const_transmute", since = "1.56.0")] #[rustc_diagnostic_item = "transmute"] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn transmute(_src: Src) -> Dst { - unreachable!() -} +pub const unsafe fn transmute(src: Src) -> Dst; /// Like [`transmute`], but even less checked at compile-time: rather than /// giving an error for `size_of::() != size_of::()`, it's @@ -1944,14 +1543,10 @@ pub const unsafe fn transmute(_src: Src) -> Dst { /// /// This is not expected to ever be exposed directly to users, rather it /// may eventually be exposed through some more-constrained API. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_transmute", since = "1.56.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn transmute_unchecked(_src: Src) -> Dst { - unreachable!() -} +pub const unsafe fn transmute_unchecked(src: Src) -> Dst; /// Returns `true` if the actual type given as `T` requires drop /// glue; returns `false` if the actual type provided for `T` @@ -1966,14 +1561,10 @@ pub const unsafe fn transmute_unchecked(_src: Src) -> Dst { /// any safety invariants. /// /// The stabilized version of this intrinsic is [`mem::needs_drop`](crate::mem::needs_drop). -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_needs_drop", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn needs_drop() -> bool { - unreachable!() -} +pub const fn needs_drop() -> bool; /// Calculates the offset from a pointer. /// @@ -1992,14 +1583,10 @@ pub const fn needs_drop() -> bool { /// /// The stabilized version of this intrinsic is [`pointer::offset`]. #[must_use = "returns a new pointer rather than modifying its argument"] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn offset(_dst: Ptr, _offset: Delta) -> Ptr { - unreachable!() -} +pub const unsafe fn offset(dst: Ptr, offset: Delta) -> Ptr; /// Calculates the offset from a pointer, potentially wrapping. /// @@ -2015,14 +1602,10 @@ pub const unsafe fn offset(_dst: Ptr, _offset: Delta) -> Ptr { /// /// The stabilized version of this intrinsic is [`pointer::wrapping_offset`]. #[must_use = "returns a new pointer rather than modifying its argument"] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn arith_offset(_dst: *const T, _offset: isize) -> *const T { - unreachable!() -} +pub const unsafe fn arith_offset(dst: *const T, offset: isize) -> *const T; /// Masks out bits of the pointer according to a mask. /// @@ -2034,684 +1617,738 @@ pub const unsafe fn arith_offset(_dst: *const T, _offset: isize) -> *const T /// Consider using [`pointer::mask`] instead. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn ptr_mask(_ptr: *const T, _mask: usize) -> *const T { - unreachable!() -} - -extern "rust-intrinsic" { - /// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with - /// a size of `count` * `size_of::()` and an alignment of - /// `min_align_of::()` - /// - /// The volatile parameter is set to `true`, so it will not be optimized out - /// unless size is equal to zero. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn volatile_copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: usize); - /// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with - /// a size of `count * size_of::()` and an alignment of - /// `min_align_of::()` - /// - /// The volatile parameter is set to `true`, so it will not be optimized out - /// unless size is equal to zero. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn volatile_copy_memory(dst: *mut T, src: *const T, count: usize); - /// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a - /// size of `count * size_of::()` and an alignment of - /// `min_align_of::()`. - /// - /// The volatile parameter is set to `true`, so it will not be optimized out - /// unless size is equal to zero. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn volatile_set_memory(dst: *mut T, val: u8, count: usize); - - /// Performs a volatile load from the `src` pointer. - /// - /// The stabilized version of this intrinsic is [`core::ptr::read_volatile`]. - #[rustc_nounwind] - pub fn volatile_load(src: *const T) -> T; - /// Performs a volatile store to the `dst` pointer. - /// - /// The stabilized version of this intrinsic is [`core::ptr::write_volatile`]. - #[rustc_nounwind] - pub fn volatile_store(dst: *mut T, val: T); +pub fn ptr_mask(ptr: *const T, mask: usize) -> *const T; - /// Performs a volatile load from the `src` pointer - /// The pointer is not required to be aligned. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - #[rustc_diagnostic_item = "intrinsics_unaligned_volatile_load"] - pub fn unaligned_volatile_load(src: *const T) -> T; - /// Performs a volatile store to the `dst` pointer. - /// The pointer is not required to be aligned. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - #[rustc_diagnostic_item = "intrinsics_unaligned_volatile_store"] - pub fn unaligned_volatile_store(dst: *mut T, val: T); +/// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with +/// a size of `count` * `size_of::()` and an alignment of +/// `min_align_of::()` +/// +/// The volatile parameter is set to `true`, so it will not be optimized out +/// unless size is equal to zero. +/// +/// This intrinsic does not have a stable counterpart. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn volatile_copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: usize); +/// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with +/// a size of `count * size_of::()` and an alignment of +/// `min_align_of::()` +/// +/// The volatile parameter is set to `true`, so it will not be optimized out +/// unless size is equal to zero. +/// +/// This intrinsic does not have a stable counterpart. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn volatile_copy_memory(dst: *mut T, src: *const T, count: usize); +/// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a +/// size of `count * size_of::()` and an alignment of +/// `min_align_of::()`. +/// +/// The volatile parameter is set to `true`, so it will not be optimized out +/// unless size is equal to zero. +/// +/// This intrinsic does not have a stable counterpart. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn volatile_set_memory(dst: *mut T, val: u8, count: usize); - /// Returns the square root of an `f16` - /// - /// The stabilized version of this intrinsic is - /// [`f16::sqrt`](../../std/primitive.f16.html#method.sqrt) - #[rustc_nounwind] - pub fn sqrtf16(x: f16) -> f16; - /// Returns the square root of an `f32` - /// - /// The stabilized version of this intrinsic is - /// [`f32::sqrt`](../../std/primitive.f32.html#method.sqrt) - #[rustc_nounwind] - pub fn sqrtf32(x: f32) -> f32; - /// Returns the square root of an `f64` - /// - /// The stabilized version of this intrinsic is - /// [`f64::sqrt`](../../std/primitive.f64.html#method.sqrt) - #[rustc_nounwind] - pub fn sqrtf64(x: f64) -> f64; - /// Returns the square root of an `f128` - /// - /// The stabilized version of this intrinsic is - /// [`f128::sqrt`](../../std/primitive.f128.html#method.sqrt) - #[rustc_nounwind] - pub fn sqrtf128(x: f128) -> f128; +/// Performs a volatile load from the `src` pointer. +/// +/// The stabilized version of this intrinsic is [`core::ptr::read_volatile`]. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn volatile_load(src: *const T) -> T; +/// Performs a volatile store to the `dst` pointer. +/// +/// The stabilized version of this intrinsic is [`core::ptr::write_volatile`]. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn volatile_store(dst: *mut T, val: T); - /// Raises an `f16` to an integer power. - /// - /// The stabilized version of this intrinsic is - /// [`f16::powi`](../../std/primitive.f16.html#method.powi) - #[rustc_nounwind] - pub fn powif16(a: f16, x: i32) -> f16; - /// Raises an `f32` to an integer power. - /// - /// The stabilized version of this intrinsic is - /// [`f32::powi`](../../std/primitive.f32.html#method.powi) - #[rustc_nounwind] - pub fn powif32(a: f32, x: i32) -> f32; - /// Raises an `f64` to an integer power. - /// - /// The stabilized version of this intrinsic is - /// [`f64::powi`](../../std/primitive.f64.html#method.powi) - #[rustc_nounwind] - pub fn powif64(a: f64, x: i32) -> f64; - /// Raises an `f128` to an integer power. - /// - /// The stabilized version of this intrinsic is - /// [`f128::powi`](../../std/primitive.f128.html#method.powi) - #[rustc_nounwind] - pub fn powif128(a: f128, x: i32) -> f128; +/// Performs a volatile load from the `src` pointer +/// The pointer is not required to be aligned. +/// +/// This intrinsic does not have a stable counterpart. +#[rustc_intrinsic] +#[rustc_nounwind] +#[rustc_diagnostic_item = "intrinsics_unaligned_volatile_load"] +pub unsafe fn unaligned_volatile_load(src: *const T) -> T; +/// Performs a volatile store to the `dst` pointer. +/// The pointer is not required to be aligned. +/// +/// This intrinsic does not have a stable counterpart. +#[rustc_intrinsic] +#[rustc_nounwind] +#[rustc_diagnostic_item = "intrinsics_unaligned_volatile_store"] +pub unsafe fn unaligned_volatile_store(dst: *mut T, val: T); - /// Returns the sine of an `f16`. - /// - /// The stabilized version of this intrinsic is - /// [`f16::sin`](../../std/primitive.f16.html#method.sin) - #[rustc_nounwind] - pub fn sinf16(x: f16) -> f16; - /// Returns the sine of an `f32`. - /// - /// The stabilized version of this intrinsic is - /// [`f32::sin`](../../std/primitive.f32.html#method.sin) - #[rustc_nounwind] - pub fn sinf32(x: f32) -> f32; - /// Returns the sine of an `f64`. - /// - /// The stabilized version of this intrinsic is - /// [`f64::sin`](../../std/primitive.f64.html#method.sin) - #[rustc_nounwind] - pub fn sinf64(x: f64) -> f64; - /// Returns the sine of an `f128`. - /// - /// The stabilized version of this intrinsic is - /// [`f128::sin`](../../std/primitive.f128.html#method.sin) - #[rustc_nounwind] - pub fn sinf128(x: f128) -> f128; +/// Returns the square root of an `f16` +/// +/// The stabilized version of this intrinsic is +/// [`f16::sqrt`](../../std/primitive.f16.html#method.sqrt) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn sqrtf16(x: f16) -> f16; +/// Returns the square root of an `f32` +/// +/// The stabilized version of this intrinsic is +/// [`f32::sqrt`](../../std/primitive.f32.html#method.sqrt) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn sqrtf32(x: f32) -> f32; +/// Returns the square root of an `f64` +/// +/// The stabilized version of this intrinsic is +/// [`f64::sqrt`](../../std/primitive.f64.html#method.sqrt) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn sqrtf64(x: f64) -> f64; +/// Returns the square root of an `f128` +/// +/// The stabilized version of this intrinsic is +/// [`f128::sqrt`](../../std/primitive.f128.html#method.sqrt) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn sqrtf128(x: f128) -> f128; - /// Returns the cosine of an `f16`. - /// - /// The stabilized version of this intrinsic is - /// [`f16::cos`](../../std/primitive.f16.html#method.cos) - #[rustc_nounwind] - pub fn cosf16(x: f16) -> f16; - /// Returns the cosine of an `f32`. - /// - /// The stabilized version of this intrinsic is - /// [`f32::cos`](../../std/primitive.f32.html#method.cos) - #[rustc_nounwind] - pub fn cosf32(x: f32) -> f32; - /// Returns the cosine of an `f64`. - /// - /// The stabilized version of this intrinsic is - /// [`f64::cos`](../../std/primitive.f64.html#method.cos) - #[rustc_nounwind] - pub fn cosf64(x: f64) -> f64; - /// Returns the cosine of an `f128`. - /// - /// The stabilized version of this intrinsic is - /// [`f128::cos`](../../std/primitive.f128.html#method.cos) - #[rustc_nounwind] - pub fn cosf128(x: f128) -> f128; +/// Raises an `f16` to an integer power. +/// +/// The stabilized version of this intrinsic is +/// [`f16::powi`](../../std/primitive.f16.html#method.powi) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn powif16(a: f16, x: i32) -> f16; +/// Raises an `f32` to an integer power. +/// +/// The stabilized version of this intrinsic is +/// [`f32::powi`](../../std/primitive.f32.html#method.powi) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn powif32(a: f32, x: i32) -> f32; +/// Raises an `f64` to an integer power. +/// +/// The stabilized version of this intrinsic is +/// [`f64::powi`](../../std/primitive.f64.html#method.powi) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn powif64(a: f64, x: i32) -> f64; +/// Raises an `f128` to an integer power. +/// +/// The stabilized version of this intrinsic is +/// [`f128::powi`](../../std/primitive.f128.html#method.powi) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn powif128(a: f128, x: i32) -> f128; - /// Raises an `f16` to an `f16` power. - /// - /// The stabilized version of this intrinsic is - /// [`f16::powf`](../../std/primitive.f16.html#method.powf) - #[rustc_nounwind] - pub fn powf16(a: f16, x: f16) -> f16; - /// Raises an `f32` to an `f32` power. - /// - /// The stabilized version of this intrinsic is - /// [`f32::powf`](../../std/primitive.f32.html#method.powf) - #[rustc_nounwind] - pub fn powf32(a: f32, x: f32) -> f32; - /// Raises an `f64` to an `f64` power. - /// - /// The stabilized version of this intrinsic is - /// [`f64::powf`](../../std/primitive.f64.html#method.powf) - #[rustc_nounwind] - pub fn powf64(a: f64, x: f64) -> f64; - /// Raises an `f128` to an `f128` power. - /// - /// The stabilized version of this intrinsic is - /// [`f128::powf`](../../std/primitive.f128.html#method.powf) - #[rustc_nounwind] - pub fn powf128(a: f128, x: f128) -> f128; +/// Returns the sine of an `f16`. +/// +/// The stabilized version of this intrinsic is +/// [`f16::sin`](../../std/primitive.f16.html#method.sin) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn sinf16(x: f16) -> f16; +/// Returns the sine of an `f32`. +/// +/// The stabilized version of this intrinsic is +/// [`f32::sin`](../../std/primitive.f32.html#method.sin) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn sinf32(x: f32) -> f32; +/// Returns the sine of an `f64`. +/// +/// The stabilized version of this intrinsic is +/// [`f64::sin`](../../std/primitive.f64.html#method.sin) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn sinf64(x: f64) -> f64; +/// Returns the sine of an `f128`. +/// +/// The stabilized version of this intrinsic is +/// [`f128::sin`](../../std/primitive.f128.html#method.sin) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn sinf128(x: f128) -> f128; - /// Returns the exponential of an `f16`. - /// - /// The stabilized version of this intrinsic is - /// [`f16::exp`](../../std/primitive.f16.html#method.exp) - #[rustc_nounwind] - pub fn expf16(x: f16) -> f16; - /// Returns the exponential of an `f32`. - /// - /// The stabilized version of this intrinsic is - /// [`f32::exp`](../../std/primitive.f32.html#method.exp) - #[rustc_nounwind] - pub fn expf32(x: f32) -> f32; - /// Returns the exponential of an `f64`. - /// - /// The stabilized version of this intrinsic is - /// [`f64::exp`](../../std/primitive.f64.html#method.exp) - #[rustc_nounwind] - pub fn expf64(x: f64) -> f64; - /// Returns the exponential of an `f128`. - /// - /// The stabilized version of this intrinsic is - /// [`f128::exp`](../../std/primitive.f128.html#method.exp) - #[rustc_nounwind] - pub fn expf128(x: f128) -> f128; +/// Returns the cosine of an `f16`. +/// +/// The stabilized version of this intrinsic is +/// [`f16::cos`](../../std/primitive.f16.html#method.cos) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn cosf16(x: f16) -> f16; +/// Returns the cosine of an `f32`. +/// +/// The stabilized version of this intrinsic is +/// [`f32::cos`](../../std/primitive.f32.html#method.cos) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn cosf32(x: f32) -> f32; +/// Returns the cosine of an `f64`. +/// +/// The stabilized version of this intrinsic is +/// [`f64::cos`](../../std/primitive.f64.html#method.cos) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn cosf64(x: f64) -> f64; +/// Returns the cosine of an `f128`. +/// +/// The stabilized version of this intrinsic is +/// [`f128::cos`](../../std/primitive.f128.html#method.cos) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn cosf128(x: f128) -> f128; - /// Returns 2 raised to the power of an `f16`. - /// - /// The stabilized version of this intrinsic is - /// [`f16::exp2`](../../std/primitive.f16.html#method.exp2) - #[rustc_nounwind] - pub fn exp2f16(x: f16) -> f16; - /// Returns 2 raised to the power of an `f32`. - /// - /// The stabilized version of this intrinsic is - /// [`f32::exp2`](../../std/primitive.f32.html#method.exp2) - #[rustc_nounwind] - pub fn exp2f32(x: f32) -> f32; - /// Returns 2 raised to the power of an `f64`. - /// - /// The stabilized version of this intrinsic is - /// [`f64::exp2`](../../std/primitive.f64.html#method.exp2) - #[rustc_nounwind] - pub fn exp2f64(x: f64) -> f64; - /// Returns 2 raised to the power of an `f128`. - /// - /// The stabilized version of this intrinsic is - /// [`f128::exp2`](../../std/primitive.f128.html#method.exp2) - #[rustc_nounwind] - pub fn exp2f128(x: f128) -> f128; +/// Raises an `f16` to an `f16` power. +/// +/// The stabilized version of this intrinsic is +/// [`f16::powf`](../../std/primitive.f16.html#method.powf) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn powf16(a: f16, x: f16) -> f16; +/// Raises an `f32` to an `f32` power. +/// +/// The stabilized version of this intrinsic is +/// [`f32::powf`](../../std/primitive.f32.html#method.powf) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn powf32(a: f32, x: f32) -> f32; +/// Raises an `f64` to an `f64` power. +/// +/// The stabilized version of this intrinsic is +/// [`f64::powf`](../../std/primitive.f64.html#method.powf) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn powf64(a: f64, x: f64) -> f64; +/// Raises an `f128` to an `f128` power. +/// +/// The stabilized version of this intrinsic is +/// [`f128::powf`](../../std/primitive.f128.html#method.powf) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn powf128(a: f128, x: f128) -> f128; - /// Returns the natural logarithm of an `f16`. - /// - /// The stabilized version of this intrinsic is - /// [`f16::ln`](../../std/primitive.f16.html#method.ln) - #[rustc_nounwind] - pub fn logf16(x: f16) -> f16; - /// Returns the natural logarithm of an `f32`. - /// - /// The stabilized version of this intrinsic is - /// [`f32::ln`](../../std/primitive.f32.html#method.ln) - #[rustc_nounwind] - pub fn logf32(x: f32) -> f32; - /// Returns the natural logarithm of an `f64`. - /// - /// The stabilized version of this intrinsic is - /// [`f64::ln`](../../std/primitive.f64.html#method.ln) - #[rustc_nounwind] - pub fn logf64(x: f64) -> f64; - /// Returns the natural logarithm of an `f128`. - /// - /// The stabilized version of this intrinsic is - /// [`f128::ln`](../../std/primitive.f128.html#method.ln) - #[rustc_nounwind] - pub fn logf128(x: f128) -> f128; +/// Returns the exponential of an `f16`. +/// +/// The stabilized version of this intrinsic is +/// [`f16::exp`](../../std/primitive.f16.html#method.exp) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn expf16(x: f16) -> f16; +/// Returns the exponential of an `f32`. +/// +/// The stabilized version of this intrinsic is +/// [`f32::exp`](../../std/primitive.f32.html#method.exp) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn expf32(x: f32) -> f32; +/// Returns the exponential of an `f64`. +/// +/// The stabilized version of this intrinsic is +/// [`f64::exp`](../../std/primitive.f64.html#method.exp) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn expf64(x: f64) -> f64; +/// Returns the exponential of an `f128`. +/// +/// The stabilized version of this intrinsic is +/// [`f128::exp`](../../std/primitive.f128.html#method.exp) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn expf128(x: f128) -> f128; - /// Returns the base 10 logarithm of an `f16`. - /// - /// The stabilized version of this intrinsic is - /// [`f16::log10`](../../std/primitive.f16.html#method.log10) - #[rustc_nounwind] - pub fn log10f16(x: f16) -> f16; - /// Returns the base 10 logarithm of an `f32`. - /// - /// The stabilized version of this intrinsic is - /// [`f32::log10`](../../std/primitive.f32.html#method.log10) - #[rustc_nounwind] - pub fn log10f32(x: f32) -> f32; - /// Returns the base 10 logarithm of an `f64`. - /// - /// The stabilized version of this intrinsic is - /// [`f64::log10`](../../std/primitive.f64.html#method.log10) - #[rustc_nounwind] - pub fn log10f64(x: f64) -> f64; - /// Returns the base 10 logarithm of an `f128`. - /// - /// The stabilized version of this intrinsic is - /// [`f128::log10`](../../std/primitive.f128.html#method.log10) - #[rustc_nounwind] - pub fn log10f128(x: f128) -> f128; +/// Returns 2 raised to the power of an `f16`. +/// +/// The stabilized version of this intrinsic is +/// [`f16::exp2`](../../std/primitive.f16.html#method.exp2) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn exp2f16(x: f16) -> f16; +/// Returns 2 raised to the power of an `f32`. +/// +/// The stabilized version of this intrinsic is +/// [`f32::exp2`](../../std/primitive.f32.html#method.exp2) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn exp2f32(x: f32) -> f32; +/// Returns 2 raised to the power of an `f64`. +/// +/// The stabilized version of this intrinsic is +/// [`f64::exp2`](../../std/primitive.f64.html#method.exp2) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn exp2f64(x: f64) -> f64; +/// Returns 2 raised to the power of an `f128`. +/// +/// The stabilized version of this intrinsic is +/// [`f128::exp2`](../../std/primitive.f128.html#method.exp2) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn exp2f128(x: f128) -> f128; - /// Returns the base 2 logarithm of an `f16`. - /// - /// The stabilized version of this intrinsic is - /// [`f16::log2`](../../std/primitive.f16.html#method.log2) - #[rustc_nounwind] - pub fn log2f16(x: f16) -> f16; - /// Returns the base 2 logarithm of an `f32`. - /// - /// The stabilized version of this intrinsic is - /// [`f32::log2`](../../std/primitive.f32.html#method.log2) - #[rustc_nounwind] - pub fn log2f32(x: f32) -> f32; - /// Returns the base 2 logarithm of an `f64`. - /// - /// The stabilized version of this intrinsic is - /// [`f64::log2`](../../std/primitive.f64.html#method.log2) - #[rustc_nounwind] - pub fn log2f64(x: f64) -> f64; - /// Returns the base 2 logarithm of an `f128`. - /// - /// The stabilized version of this intrinsic is - /// [`f128::log2`](../../std/primitive.f128.html#method.log2) - #[rustc_nounwind] - pub fn log2f128(x: f128) -> f128; +/// Returns the natural logarithm of an `f16`. +/// +/// The stabilized version of this intrinsic is +/// [`f16::ln`](../../std/primitive.f16.html#method.ln) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn logf16(x: f16) -> f16; +/// Returns the natural logarithm of an `f32`. +/// +/// The stabilized version of this intrinsic is +/// [`f32::ln`](../../std/primitive.f32.html#method.ln) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn logf32(x: f32) -> f32; +/// Returns the natural logarithm of an `f64`. +/// +/// The stabilized version of this intrinsic is +/// [`f64::ln`](../../std/primitive.f64.html#method.ln) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn logf64(x: f64) -> f64; +/// Returns the natural logarithm of an `f128`. +/// +/// The stabilized version of this intrinsic is +/// [`f128::ln`](../../std/primitive.f128.html#method.ln) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn logf128(x: f128) -> f128; - /// Returns `a * b + c` for `f16` values. - /// - /// The stabilized version of this intrinsic is - /// [`f16::mul_add`](../../std/primitive.f16.html#method.mul_add) - #[rustc_nounwind] - pub fn fmaf16(a: f16, b: f16, c: f16) -> f16; - /// Returns `a * b + c` for `f32` values. - /// - /// The stabilized version of this intrinsic is - /// [`f32::mul_add`](../../std/primitive.f32.html#method.mul_add) - #[rustc_nounwind] - pub fn fmaf32(a: f32, b: f32, c: f32) -> f32; - /// Returns `a * b + c` for `f64` values. - /// - /// The stabilized version of this intrinsic is - /// [`f64::mul_add`](../../std/primitive.f64.html#method.mul_add) - #[rustc_nounwind] - pub fn fmaf64(a: f64, b: f64, c: f64) -> f64; - /// Returns `a * b + c` for `f128` values. - /// - /// The stabilized version of this intrinsic is - /// [`f128::mul_add`](../../std/primitive.f128.html#method.mul_add) - #[rustc_nounwind] - pub fn fmaf128(a: f128, b: f128, c: f128) -> f128; - - /// Returns `a * b + c` for `f16` values, non-deterministically executing - /// either a fused multiply-add or two operations with rounding of the - /// intermediate result. - /// - /// The operation is fused if the code generator determines that target - /// instruction set has support for a fused operation, and that the fused - /// operation is more efficient than the equivalent, separate pair of mul - /// and add instructions. It is unspecified whether or not a fused operation - /// is selected, and that may depend on optimization level and context, for - /// example. - #[rustc_nounwind] - pub fn fmuladdf16(a: f16, b: f16, c: f16) -> f16; - /// Returns `a * b + c` for `f32` values, non-deterministically executing - /// either a fused multiply-add or two operations with rounding of the - /// intermediate result. - /// - /// The operation is fused if the code generator determines that target - /// instruction set has support for a fused operation, and that the fused - /// operation is more efficient than the equivalent, separate pair of mul - /// and add instructions. It is unspecified whether or not a fused operation - /// is selected, and that may depend on optimization level and context, for - /// example. - #[rustc_nounwind] - pub fn fmuladdf32(a: f32, b: f32, c: f32) -> f32; - /// Returns `a * b + c` for `f64` values, non-deterministically executing - /// either a fused multiply-add or two operations with rounding of the - /// intermediate result. - /// - /// The operation is fused if the code generator determines that target - /// instruction set has support for a fused operation, and that the fused - /// operation is more efficient than the equivalent, separate pair of mul - /// and add instructions. It is unspecified whether or not a fused operation - /// is selected, and that may depend on optimization level and context, for - /// example. - #[rustc_nounwind] - pub fn fmuladdf64(a: f64, b: f64, c: f64) -> f64; - /// Returns `a * b + c` for `f128` values, non-deterministically executing - /// either a fused multiply-add or two operations with rounding of the - /// intermediate result. - /// - /// The operation is fused if the code generator determines that target - /// instruction set has support for a fused operation, and that the fused - /// operation is more efficient than the equivalent, separate pair of mul - /// and add instructions. It is unspecified whether or not a fused operation - /// is selected, and that may depend on optimization level and context, for - /// example. - #[rustc_nounwind] - pub fn fmuladdf128(a: f128, b: f128, c: f128) -> f128; +/// Returns the base 10 logarithm of an `f16`. +/// +/// The stabilized version of this intrinsic is +/// [`f16::log10`](../../std/primitive.f16.html#method.log10) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn log10f16(x: f16) -> f16; +/// Returns the base 10 logarithm of an `f32`. +/// +/// The stabilized version of this intrinsic is +/// [`f32::log10`](../../std/primitive.f32.html#method.log10) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn log10f32(x: f32) -> f32; +/// Returns the base 10 logarithm of an `f64`. +/// +/// The stabilized version of this intrinsic is +/// [`f64::log10`](../../std/primitive.f64.html#method.log10) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn log10f64(x: f64) -> f64; +/// Returns the base 10 logarithm of an `f128`. +/// +/// The stabilized version of this intrinsic is +/// [`f128::log10`](../../std/primitive.f128.html#method.log10) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn log10f128(x: f128) -> f128; - /// Returns the largest integer less than or equal to an `f16`. - /// - /// The stabilized version of this intrinsic is - /// [`f16::floor`](../../std/primitive.f16.html#method.floor) - #[rustc_nounwind] - pub fn floorf16(x: f16) -> f16; - /// Returns the largest integer less than or equal to an `f32`. - /// - /// The stabilized version of this intrinsic is - /// [`f32::floor`](../../std/primitive.f32.html#method.floor) - #[rustc_nounwind] - pub fn floorf32(x: f32) -> f32; - /// Returns the largest integer less than or equal to an `f64`. - /// - /// The stabilized version of this intrinsic is - /// [`f64::floor`](../../std/primitive.f64.html#method.floor) - #[rustc_nounwind] - pub fn floorf64(x: f64) -> f64; - /// Returns the largest integer less than or equal to an `f128`. - /// - /// The stabilized version of this intrinsic is - /// [`f128::floor`](../../std/primitive.f128.html#method.floor) - #[rustc_nounwind] - pub fn floorf128(x: f128) -> f128; +/// Returns the base 2 logarithm of an `f16`. +/// +/// The stabilized version of this intrinsic is +/// [`f16::log2`](../../std/primitive.f16.html#method.log2) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn log2f16(x: f16) -> f16; +/// Returns the base 2 logarithm of an `f32`. +/// +/// The stabilized version of this intrinsic is +/// [`f32::log2`](../../std/primitive.f32.html#method.log2) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn log2f32(x: f32) -> f32; +/// Returns the base 2 logarithm of an `f64`. +/// +/// The stabilized version of this intrinsic is +/// [`f64::log2`](../../std/primitive.f64.html#method.log2) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn log2f64(x: f64) -> f64; +/// Returns the base 2 logarithm of an `f128`. +/// +/// The stabilized version of this intrinsic is +/// [`f128::log2`](../../std/primitive.f128.html#method.log2) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn log2f128(x: f128) -> f128; - /// Returns the smallest integer greater than or equal to an `f16`. - /// - /// The stabilized version of this intrinsic is - /// [`f16::ceil`](../../std/primitive.f16.html#method.ceil) - #[rustc_nounwind] - pub fn ceilf16(x: f16) -> f16; - /// Returns the smallest integer greater than or equal to an `f32`. - /// - /// The stabilized version of this intrinsic is - /// [`f32::ceil`](../../std/primitive.f32.html#method.ceil) - #[rustc_nounwind] - pub fn ceilf32(x: f32) -> f32; - /// Returns the smallest integer greater than or equal to an `f64`. - /// - /// The stabilized version of this intrinsic is - /// [`f64::ceil`](../../std/primitive.f64.html#method.ceil) - #[rustc_nounwind] - pub fn ceilf64(x: f64) -> f64; - /// Returns the smallest integer greater than or equal to an `f128`. - /// - /// The stabilized version of this intrinsic is - /// [`f128::ceil`](../../std/primitive.f128.html#method.ceil) - #[rustc_nounwind] - pub fn ceilf128(x: f128) -> f128; +/// Returns `a * b + c` for `f16` values. +/// +/// The stabilized version of this intrinsic is +/// [`f16::mul_add`](../../std/primitive.f16.html#method.mul_add) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn fmaf16(a: f16, b: f16, c: f16) -> f16; +/// Returns `a * b + c` for `f32` values. +/// +/// The stabilized version of this intrinsic is +/// [`f32::mul_add`](../../std/primitive.f32.html#method.mul_add) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn fmaf32(a: f32, b: f32, c: f32) -> f32; +/// Returns `a * b + c` for `f64` values. +/// +/// The stabilized version of this intrinsic is +/// [`f64::mul_add`](../../std/primitive.f64.html#method.mul_add) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn fmaf64(a: f64, b: f64, c: f64) -> f64; +/// Returns `a * b + c` for `f128` values. +/// +/// The stabilized version of this intrinsic is +/// [`f128::mul_add`](../../std/primitive.f128.html#method.mul_add) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn fmaf128(a: f128, b: f128, c: f128) -> f128; - /// Returns the integer part of an `f16`. - /// - /// The stabilized version of this intrinsic is - /// [`f16::trunc`](../../std/primitive.f16.html#method.trunc) - #[rustc_nounwind] - pub fn truncf16(x: f16) -> f16; - /// Returns the integer part of an `f32`. - /// - /// The stabilized version of this intrinsic is - /// [`f32::trunc`](../../std/primitive.f32.html#method.trunc) - #[rustc_nounwind] - pub fn truncf32(x: f32) -> f32; - /// Returns the integer part of an `f64`. - /// - /// The stabilized version of this intrinsic is - /// [`f64::trunc`](../../std/primitive.f64.html#method.trunc) - #[rustc_nounwind] - pub fn truncf64(x: f64) -> f64; - /// Returns the integer part of an `f128`. - /// - /// The stabilized version of this intrinsic is - /// [`f128::trunc`](../../std/primitive.f128.html#method.trunc) - #[rustc_nounwind] - pub fn truncf128(x: f128) -> f128; - - /// Returns the nearest integer to an `f16`. Changing the rounding mode is not possible in Rust, - /// so this rounds half-way cases to the number with an even least significant digit. - /// - /// May raise an inexact floating-point exception if the argument is not an integer. - /// However, Rust assumes floating-point exceptions cannot be observed, so these exceptions - /// cannot actually be utilized from Rust code. - /// In other words, this intrinsic is equivalent in behavior to `nearbyintf16` and `roundevenf16`. - /// - /// The stabilized version of this intrinsic is - /// [`f16::round_ties_even`](../../std/primitive.f16.html#method.round_ties_even) - #[rustc_nounwind] - pub fn rintf16(x: f16) -> f16; - /// Returns the nearest integer to an `f32`. Changing the rounding mode is not possible in Rust, - /// so this rounds half-way cases to the number with an even least significant digit. - /// - /// May raise an inexact floating-point exception if the argument is not an integer. - /// However, Rust assumes floating-point exceptions cannot be observed, so these exceptions - /// cannot actually be utilized from Rust code. - /// In other words, this intrinsic is equivalent in behavior to `nearbyintf32` and `roundevenf32`. - /// - /// The stabilized version of this intrinsic is - /// [`f32::round_ties_even`](../../std/primitive.f32.html#method.round_ties_even) - #[rustc_nounwind] - pub fn rintf32(x: f32) -> f32; - /// Returns the nearest integer to an `f64`. Changing the rounding mode is not possible in Rust, - /// so this rounds half-way cases to the number with an even least significant digit. - /// - /// May raise an inexact floating-point exception if the argument is not an integer. - /// However, Rust assumes floating-point exceptions cannot be observed, so these exceptions - /// cannot actually be utilized from Rust code. - /// In other words, this intrinsic is equivalent in behavior to `nearbyintf64` and `roundevenf64`. - /// - /// The stabilized version of this intrinsic is - /// [`f64::round_ties_even`](../../std/primitive.f64.html#method.round_ties_even) - #[rustc_nounwind] - pub fn rintf64(x: f64) -> f64; - /// Returns the nearest integer to an `f128`. Changing the rounding mode is not possible in Rust, - /// so this rounds half-way cases to the number with an even least significant digit. - /// - /// May raise an inexact floating-point exception if the argument is not an integer. - /// However, Rust assumes floating-point exceptions cannot be observed, so these exceptions - /// cannot actually be utilized from Rust code. - /// In other words, this intrinsic is equivalent in behavior to `nearbyintf128` and `roundevenf128`. - /// - /// The stabilized version of this intrinsic is - /// [`f128::round_ties_even`](../../std/primitive.f128.html#method.round_ties_even) - #[rustc_nounwind] - pub fn rintf128(x: f128) -> f128; +/// Returns `a * b + c` for `f16` values, non-deterministically executing +/// either a fused multiply-add or two operations with rounding of the +/// intermediate result. +/// +/// The operation is fused if the code generator determines that target +/// instruction set has support for a fused operation, and that the fused +/// operation is more efficient than the equivalent, separate pair of mul +/// and add instructions. It is unspecified whether or not a fused operation +/// is selected, and that may depend on optimization level and context, for +/// example. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn fmuladdf16(a: f16, b: f16, c: f16) -> f16; +/// Returns `a * b + c` for `f32` values, non-deterministically executing +/// either a fused multiply-add or two operations with rounding of the +/// intermediate result. +/// +/// The operation is fused if the code generator determines that target +/// instruction set has support for a fused operation, and that the fused +/// operation is more efficient than the equivalent, separate pair of mul +/// and add instructions. It is unspecified whether or not a fused operation +/// is selected, and that may depend on optimization level and context, for +/// example. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn fmuladdf32(a: f32, b: f32, c: f32) -> f32; +/// Returns `a * b + c` for `f64` values, non-deterministically executing +/// either a fused multiply-add or two operations with rounding of the +/// intermediate result. +/// +/// The operation is fused if the code generator determines that target +/// instruction set has support for a fused operation, and that the fused +/// operation is more efficient than the equivalent, separate pair of mul +/// and add instructions. It is unspecified whether or not a fused operation +/// is selected, and that may depend on optimization level and context, for +/// example. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn fmuladdf64(a: f64, b: f64, c: f64) -> f64; +/// Returns `a * b + c` for `f128` values, non-deterministically executing +/// either a fused multiply-add or two operations with rounding of the +/// intermediate result. +/// +/// The operation is fused if the code generator determines that target +/// instruction set has support for a fused operation, and that the fused +/// operation is more efficient than the equivalent, separate pair of mul +/// and add instructions. It is unspecified whether or not a fused operation +/// is selected, and that may depend on optimization level and context, for +/// example. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn fmuladdf128(a: f128, b: f128, c: f128) -> f128; - /// Returns the nearest integer to an `f16`. Changing the rounding mode is not possible in Rust, - /// so this rounds half-way cases to the number with an even least significant digit. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn nearbyintf16(x: f16) -> f16; - /// Returns the nearest integer to an `f32`. Changing the rounding mode is not possible in Rust, - /// so this rounds half-way cases to the number with an even least significant digit. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn nearbyintf32(x: f32) -> f32; - /// Returns the nearest integer to an `f64`. Changing the rounding mode is not possible in Rust, - /// so this rounds half-way cases to the number with an even least significant digit. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn nearbyintf64(x: f64) -> f64; - /// Returns the nearest integer to an `f128`. Changing the rounding mode is not possible in Rust, - /// so this rounds half-way cases to the number with an even least significant digit. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn nearbyintf128(x: f128) -> f128; +/// Returns the largest integer less than or equal to an `f16`. +/// +/// The stabilized version of this intrinsic is +/// [`f16::floor`](../../std/primitive.f16.html#method.floor) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn floorf16(x: f16) -> f16; +/// Returns the largest integer less than or equal to an `f32`. +/// +/// The stabilized version of this intrinsic is +/// [`f32::floor`](../../std/primitive.f32.html#method.floor) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn floorf32(x: f32) -> f32; +/// Returns the largest integer less than or equal to an `f64`. +/// +/// The stabilized version of this intrinsic is +/// [`f64::floor`](../../std/primitive.f64.html#method.floor) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn floorf64(x: f64) -> f64; +/// Returns the largest integer less than or equal to an `f128`. +/// +/// The stabilized version of this intrinsic is +/// [`f128::floor`](../../std/primitive.f128.html#method.floor) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn floorf128(x: f128) -> f128; - /// Returns the nearest integer to an `f16`. Rounds half-way cases away from zero. - /// - /// The stabilized version of this intrinsic is - /// [`f16::round`](../../std/primitive.f16.html#method.round) - #[rustc_nounwind] - pub fn roundf16(x: f16) -> f16; - /// Returns the nearest integer to an `f32`. Rounds half-way cases away from zero. - /// - /// The stabilized version of this intrinsic is - /// [`f32::round`](../../std/primitive.f32.html#method.round) - #[rustc_nounwind] - pub fn roundf32(x: f32) -> f32; - /// Returns the nearest integer to an `f64`. Rounds half-way cases away from zero. - /// - /// The stabilized version of this intrinsic is - /// [`f64::round`](../../std/primitive.f64.html#method.round) - #[rustc_nounwind] - pub fn roundf64(x: f64) -> f64; - /// Returns the nearest integer to an `f128`. Rounds half-way cases away from zero. - /// - /// The stabilized version of this intrinsic is - /// [`f128::round`](../../std/primitive.f128.html#method.round) - #[rustc_nounwind] - pub fn roundf128(x: f128) -> f128; +/// Returns the smallest integer greater than or equal to an `f16`. +/// +/// The stabilized version of this intrinsic is +/// [`f16::ceil`](../../std/primitive.f16.html#method.ceil) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn ceilf16(x: f16) -> f16; +/// Returns the smallest integer greater than or equal to an `f32`. +/// +/// The stabilized version of this intrinsic is +/// [`f32::ceil`](../../std/primitive.f32.html#method.ceil) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn ceilf32(x: f32) -> f32; +/// Returns the smallest integer greater than or equal to an `f64`. +/// +/// The stabilized version of this intrinsic is +/// [`f64::ceil`](../../std/primitive.f64.html#method.ceil) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn ceilf64(x: f64) -> f64; +/// Returns the smallest integer greater than or equal to an `f128`. +/// +/// The stabilized version of this intrinsic is +/// [`f128::ceil`](../../std/primitive.f128.html#method.ceil) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn ceilf128(x: f128) -> f128; - /// Returns the nearest integer to an `f16`. Rounds half-way cases to the number - /// with an even least significant digit. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn roundevenf16(x: f16) -> f16; - /// Returns the nearest integer to an `f32`. Rounds half-way cases to the number - /// with an even least significant digit. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn roundevenf32(x: f32) -> f32; - /// Returns the nearest integer to an `f64`. Rounds half-way cases to the number - /// with an even least significant digit. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn roundevenf64(x: f64) -> f64; - /// Returns the nearest integer to an `f128`. Rounds half-way cases to the number - /// with an even least significant digit. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn roundevenf128(x: f128) -> f128; +/// Returns the integer part of an `f16`. +/// +/// The stabilized version of this intrinsic is +/// [`f16::trunc`](../../std/primitive.f16.html#method.trunc) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn truncf16(x: f16) -> f16; +/// Returns the integer part of an `f32`. +/// +/// The stabilized version of this intrinsic is +/// [`f32::trunc`](../../std/primitive.f32.html#method.trunc) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn truncf32(x: f32) -> f32; +/// Returns the integer part of an `f64`. +/// +/// The stabilized version of this intrinsic is +/// [`f64::trunc`](../../std/primitive.f64.html#method.trunc) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn truncf64(x: f64) -> f64; +/// Returns the integer part of an `f128`. +/// +/// The stabilized version of this intrinsic is +/// [`f128::trunc`](../../std/primitive.f128.html#method.trunc) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn truncf128(x: f128) -> f128; - /// Float addition that allows optimizations based on algebraic rules. - /// May assume inputs are finite. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn fadd_fast(a: T, b: T) -> T; +/// Returns the nearest integer to an `f16`. Rounds half-way cases to the number with an even +/// least significant digit. +/// +/// The stabilized version of this intrinsic is +/// [`f16::round_ties_even`](../../std/primitive.f16.html#method.round_ties_even) +#[rustc_intrinsic] +#[rustc_nounwind] +#[cfg(not(bootstrap))] +pub fn round_ties_even_f16(x: f16) -> f16; - /// Float subtraction that allows optimizations based on algebraic rules. - /// May assume inputs are finite. - /// - /// This intrinsic does not have a stable counterpart. +/// To be removed on next bootstrap bump. +#[cfg(bootstrap)] +pub fn round_ties_even_f16(x: f16) -> f16 { + #[rustc_intrinsic] #[rustc_nounwind] - pub fn fsub_fast(a: T, b: T) -> T; + unsafe fn rintf16(x: f16) -> f16; - /// Float multiplication that allows optimizations based on algebraic rules. - /// May assume inputs are finite. - /// - /// This intrinsic does not have a stable counterpart. - #[rustc_nounwind] - pub fn fmul_fast(a: T, b: T) -> T; + // SAFETY: this intrinsic isn't actually unsafe + unsafe { rintf16(x) } +} + +/// Returns the nearest integer to an `f32`. Rounds half-way cases to the number with an even +/// least significant digit. +/// +/// The stabilized version of this intrinsic is +/// [`f32::round_ties_even`](../../std/primitive.f32.html#method.round_ties_even) +#[rustc_intrinsic] +#[rustc_nounwind] +#[cfg(not(bootstrap))] +pub fn round_ties_even_f32(x: f32) -> f32; - /// Float division that allows optimizations based on algebraic rules. - /// May assume inputs are finite. - /// - /// This intrinsic does not have a stable counterpart. +/// To be removed on next bootstrap bump. +#[cfg(bootstrap)] +pub fn round_ties_even_f32(x: f32) -> f32 { + #[rustc_intrinsic] #[rustc_nounwind] - pub fn fdiv_fast(a: T, b: T) -> T; + unsafe fn rintf32(x: f32) -> f32; + + // SAFETY: this intrinsic isn't actually unsafe + unsafe { rintf32(x) } +} - /// Float remainder that allows optimizations based on algebraic rules. - /// May assume inputs are finite. - /// - /// This intrinsic does not have a stable counterpart. +/// Provided for compatibility with stdarch. DO NOT USE. +#[inline(always)] +pub unsafe fn rintf32(x: f32) -> f32 { + round_ties_even_f32(x) +} + +/// Returns the nearest integer to an `f64`. Rounds half-way cases to the number with an even +/// least significant digit. +/// +/// The stabilized version of this intrinsic is +/// [`f64::round_ties_even`](../../std/primitive.f64.html#method.round_ties_even) +#[rustc_intrinsic] +#[rustc_nounwind] +#[cfg(not(bootstrap))] +pub fn round_ties_even_f64(x: f64) -> f64; + +/// To be removed on next bootstrap bump. +#[cfg(bootstrap)] +pub fn round_ties_even_f64(x: f64) -> f64 { + #[rustc_intrinsic] #[rustc_nounwind] - pub fn frem_fast(a: T, b: T) -> T; + unsafe fn rintf64(x: f64) -> f64; + + // SAFETY: this intrinsic isn't actually unsafe + unsafe { rintf64(x) } +} + +/// Provided for compatibility with stdarch. DO NOT USE. +#[inline(always)] +pub unsafe fn rintf64(x: f64) -> f64 { + round_ties_even_f64(x) +} - /// Converts with LLVM’s fptoui/fptosi, which may return undef for values out of range - /// () - /// - /// Stabilized as [`f32::to_int_unchecked`] and [`f64::to_int_unchecked`]. +/// Returns the nearest integer to an `f128`. Rounds half-way cases to the number with an even +/// least significant digit. +/// +/// The stabilized version of this intrinsic is +/// [`f128::round_ties_even`](../../std/primitive.f128.html#method.round_ties_even) +#[rustc_intrinsic] +#[rustc_nounwind] +#[cfg(not(bootstrap))] +pub fn round_ties_even_f128(x: f128) -> f128; + +/// To be removed on next bootstrap bump. +#[cfg(bootstrap)] +pub fn round_ties_even_f128(x: f128) -> f128 { + #[rustc_intrinsic] #[rustc_nounwind] - pub fn float_to_int_unchecked(value: Float) -> Int; + unsafe fn rintf128(x: f128) -> f128; + + // SAFETY: this intrinsic isn't actually unsafe + unsafe { rintf128(x) } } +/// Returns the nearest integer to an `f16`. Rounds half-way cases away from zero. +/// +/// The stabilized version of this intrinsic is +/// [`f16::round`](../../std/primitive.f16.html#method.round) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn roundf16(x: f16) -> f16; +/// Returns the nearest integer to an `f32`. Rounds half-way cases away from zero. +/// +/// The stabilized version of this intrinsic is +/// [`f32::round`](../../std/primitive.f32.html#method.round) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn roundf32(x: f32) -> f32; +/// Returns the nearest integer to an `f64`. Rounds half-way cases away from zero. +/// +/// The stabilized version of this intrinsic is +/// [`f64::round`](../../std/primitive.f64.html#method.round) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn roundf64(x: f64) -> f64; +/// Returns the nearest integer to an `f128`. Rounds half-way cases away from zero. +/// +/// The stabilized version of this intrinsic is +/// [`f128::round`](../../std/primitive.f128.html#method.round) +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn roundf128(x: f128) -> f128; + /// Float addition that allows optimizations based on algebraic rules. +/// May assume inputs are finite. /// /// This intrinsic does not have a stable counterpart. +#[rustc_intrinsic] #[rustc_nounwind] +pub unsafe fn fadd_fast(a: T, b: T) -> T; + +/// Float subtraction that allows optimizations based on algebraic rules. +/// May assume inputs are finite. +/// +/// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn fadd_algebraic(_a: T, _b: T) -> T { - unimplemented!() -} +#[rustc_nounwind] +pub unsafe fn fsub_fast(a: T, b: T) -> T; + +/// Float multiplication that allows optimizations based on algebraic rules. +/// May assume inputs are finite. +/// +/// This intrinsic does not have a stable counterpart. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn fmul_fast(a: T, b: T) -> T; + +/// Float division that allows optimizations based on algebraic rules. +/// May assume inputs are finite. +/// +/// This intrinsic does not have a stable counterpart. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn fdiv_fast(a: T, b: T) -> T; + +/// Float remainder that allows optimizations based on algebraic rules. +/// May assume inputs are finite. +/// +/// This intrinsic does not have a stable counterpart. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn frem_fast(a: T, b: T) -> T; + +/// Converts with LLVM’s fptoui/fptosi, which may return undef for values out of range +/// () +/// +/// Stabilized as [`f32::to_int_unchecked`] and [`f64::to_int_unchecked`]. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn float_to_int_unchecked(value: Float) -> Int; + +/// Float addition that allows optimizations based on algebraic rules. +/// +/// This intrinsic does not have a stable counterpart. +#[rustc_nounwind] +#[rustc_intrinsic] +pub fn fadd_algebraic(a: T, b: T) -> T; /// Float subtraction that allows optimizations based on algebraic rules. /// /// This intrinsic does not have a stable counterpart. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn fsub_algebraic(_a: T, _b: T) -> T { - unimplemented!() -} +pub fn fsub_algebraic(a: T, b: T) -> T; /// Float multiplication that allows optimizations based on algebraic rules. /// /// This intrinsic does not have a stable counterpart. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn fmul_algebraic(_a: T, _b: T) -> T { - unimplemented!() -} +pub fn fmul_algebraic(a: T, b: T) -> T; /// Float division that allows optimizations based on algebraic rules. /// /// This intrinsic does not have a stable counterpart. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn fdiv_algebraic(_a: T, _b: T) -> T { - unimplemented!() -} +pub fn fdiv_algebraic(a: T, b: T) -> T; /// Float remainder that allows optimizations based on algebraic rules. /// /// This intrinsic does not have a stable counterpart. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn frem_algebraic(_a: T, _b: T) -> T { - unimplemented!() -} +pub fn frem_algebraic(a: T, b: T) -> T; /// Returns the number of bits set in an integer type `T` /// @@ -2723,14 +2360,10 @@ pub fn frem_algebraic(_a: T, _b: T) -> T { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `count_ones` method. For example, /// [`u32::count_ones`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ctpop", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn ctpop(_x: T) -> u32 { - unimplemented!() -} +pub const fn ctpop(x: T) -> u32; /// Returns the number of leading unset bits (zeroes) in an integer type `T`. /// @@ -2768,14 +2401,10 @@ pub const fn ctpop(_x: T) -> u32 { /// let num_leading = ctlz(x); /// assert_eq!(num_leading, 16); /// ``` -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ctlz", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn ctlz(_x: T) -> u32 { - unimplemented!() -} +pub const fn ctlz(x: T) -> u32; /// Like `ctlz`, but extra-unsafe as it returns `undef` when /// given an `x` with value `0`. @@ -2794,14 +2423,10 @@ pub const fn ctlz(_x: T) -> u32 { /// let num_leading = unsafe { ctlz_nonzero(x) }; /// assert_eq!(num_leading, 3); /// ``` -#[cfg_attr(bootstrap, rustc_const_stable(feature = "constctlz", since = "1.50.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn ctlz_nonzero(_x: T) -> u32 { - unimplemented!() -} +pub const unsafe fn ctlz_nonzero(x: T) -> u32; /// Returns the number of trailing unset bits (zeroes) in an integer type `T`. /// @@ -2839,14 +2464,10 @@ pub const unsafe fn ctlz_nonzero(_x: T) -> u32 { /// let num_trailing = cttz(x); /// assert_eq!(num_trailing, 16); /// ``` -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_cttz", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn cttz(_x: T) -> u32 { - unimplemented!() -} +pub const fn cttz(x: T) -> u32; /// Like `cttz`, but extra-unsafe as it returns `undef` when /// given an `x` with value `0`. @@ -2865,14 +2486,10 @@ pub const fn cttz(_x: T) -> u32 { /// let num_trailing = unsafe { cttz_nonzero(x) }; /// assert_eq!(num_trailing, 3); /// ``` -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_cttz_nonzero", since = "1.53.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn cttz_nonzero(_x: T) -> u32 { - unimplemented!() -} +pub const unsafe fn cttz_nonzero(x: T) -> u32; /// Reverses the bytes in an integer type `T`. /// @@ -2884,14 +2501,10 @@ pub const unsafe fn cttz_nonzero(_x: T) -> u32 { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `swap_bytes` method. For example, /// [`u32::swap_bytes`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_bswap", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn bswap(_x: T) -> T { - unimplemented!() -} +pub const fn bswap(x: T) -> T; /// Reverses the bits in an integer type `T`. /// @@ -2903,14 +2516,10 @@ pub const fn bswap(_x: T) -> T { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `reverse_bits` method. For example, /// [`u32::reverse_bits`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_bitreverse", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn bitreverse(_x: T) -> T { - unimplemented!() -} +pub const fn bitreverse(x: T) -> T; /// Does a three-way comparison between the two integer arguments. /// @@ -2919,11 +2528,27 @@ pub const fn bitreverse(_x: T) -> T { /// large and difficult to optimize. /// /// The stabilized version of this intrinsic is [`Ord::cmp`]. -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_three_way_compare", issue = "none"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn three_way_compare(_lhs: T, _rhss: T) -> crate::cmp::Ordering { - unimplemented!() +pub const fn three_way_compare(lhs: T, rhss: T) -> crate::cmp::Ordering; + +/// Combine two values which have no bits in common. +/// +/// This allows the backend to implement it as `a + b` *or* `a | b`, +/// depending which is easier to implement on a specific target. +/// +/// # Safety +/// +/// Requires that `(a & b) == 0`, or equivalently that `(a | b) == (a + b)`. +/// +/// Otherwise it's immediate UB. +#[rustc_const_unstable(feature = "disjoint_bitor", issue = "135758")] +#[rustc_nounwind] +#[rustc_intrinsic] +#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces +#[miri::intrinsic_fallback_is_spec] // the fallbacks all `assume` to tell Miri +pub const unsafe fn disjoint_bitor(a: T, b: T) -> T { + // SAFETY: same preconditions as this function. + unsafe { fallback::DisjointBitOr::disjoint_bitor(a, b) } } /// Performs checked integer addition. @@ -2936,14 +2561,10 @@ pub const fn three_way_compare(_lhs: T, _rhss: T) -> crate::cmp::Orderi /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `overflowing_add` method. For example, /// [`u32::overflowing_add`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_overflow", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn add_with_overflow(_x: T, _y: T) -> (T, bool) { - unimplemented!() -} +pub const fn add_with_overflow(x: T, y: T) -> (T, bool); /// Performs checked integer subtraction /// @@ -2955,14 +2576,10 @@ pub const fn add_with_overflow(_x: T, _y: T) -> (T, bool) { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `overflowing_sub` method. For example, /// [`u32::overflowing_sub`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_overflow", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn sub_with_overflow(_x: T, _y: T) -> (T, bool) { - unimplemented!() -} +pub const fn sub_with_overflow(x: T, y: T) -> (T, bool); /// Performs checked integer multiplication /// @@ -2974,26 +2591,46 @@ pub const fn sub_with_overflow(_x: T, _y: T) -> (T, bool) { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `overflowing_mul` method. For example, /// [`u32::overflowing_mul`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_overflow", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn mul_with_overflow(_x: T, _y: T) -> (T, bool) { - unimplemented!() +pub const fn mul_with_overflow(x: T, y: T) -> (T, bool); + +/// Performs full-width multiplication and addition with a carry: +/// `multiplier * multiplicand + addend + carry`. +/// +/// This is possible without any overflow. For `uN`: +/// MAX * MAX + MAX + MAX +/// => (2ⁿ-1) × (2ⁿ-1) + (2ⁿ-1) + (2ⁿ-1) +/// => (2²ⁿ - 2ⁿ⁺¹ + 1) + (2ⁿ⁺¹ - 2) +/// => 2²ⁿ - 1 +/// +/// For `iN`, the upper bound is MIN * MIN + MAX + MAX => 2²ⁿ⁻² + 2ⁿ - 2, +/// and the lower bound is MAX * MIN + MIN + MIN => -2²ⁿ⁻² - 2ⁿ + 2ⁿ⁺¹. +/// +/// This currently supports unsigned integers *only*, no signed ones. +/// The stabilized versions of this intrinsic are available on integers. +#[unstable(feature = "core_intrinsics", issue = "none")] +#[rustc_const_unstable(feature = "const_carrying_mul_add", issue = "85532")] +#[rustc_nounwind] +#[rustc_intrinsic] +#[miri::intrinsic_fallback_is_spec] +pub const fn carrying_mul_add, U>( + multiplier: T, + multiplicand: T, + addend: T, + carry: T, +) -> (U, T) { + multiplier.carrying_mul_add(multiplicand, addend, carry) } /// Performs an exact division, resulting in undefined behavior where /// `x % y != 0` or `y == 0` or `x == T::MIN && y == -1` /// /// This intrinsic does not have a stable counterpart. -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_exact_div", issue = "none"))] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn exact_div(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn exact_div(x: T, y: T) -> T; /// Performs an unchecked division, resulting in undefined behavior /// where `y == 0` or `x == T::MIN && y == -1` @@ -3001,28 +2638,20 @@ pub const unsafe fn exact_div(_x: T, _y: T) -> T { /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_div` method. For example, /// [`u32::checked_div`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_unchecked_div", since = "1.52.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_div(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_div(x: T, y: T) -> T; /// Returns the remainder of an unchecked division, resulting in /// undefined behavior when `y == 0` or `x == T::MIN && y == -1` /// /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_rem` method. For example, /// [`u32::checked_rem`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_unchecked_rem", since = "1.52.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_rem(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_rem(x: T, y: T) -> T; /// Performs an unchecked left shift, resulting in undefined behavior when /// `y < 0` or `y >= N`, where N is the width of T in bits. @@ -3030,70 +2659,50 @@ pub const unsafe fn unchecked_rem(_x: T, _y: T) -> T { /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_shl` method. For example, /// [`u32::checked_shl`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_shl(_x: T, _y: U) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_shl(x: T, y: U) -> T; /// Performs an unchecked right shift, resulting in undefined behavior when /// `y < 0` or `y >= N`, where N is the width of T in bits. /// /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_shr` method. For example, /// [`u32::checked_shr`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_shr(_x: T, _y: U) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_shr(x: T, y: U) -> T; /// Returns the result of an unchecked addition, resulting in /// undefined behavior when `x + y > T::MAX` or `x + y < T::MIN`. /// /// The stable counterpart of this intrinsic is `unchecked_add` on the various /// integer types, such as [`u16::unchecked_add`] and [`i64::unchecked_add`]. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "unchecked_math", since = "1.79.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_add(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_add(x: T, y: T) -> T; /// Returns the result of an unchecked subtraction, resulting in /// undefined behavior when `x - y > T::MAX` or `x - y < T::MIN`. /// /// The stable counterpart of this intrinsic is `unchecked_sub` on the various /// integer types, such as [`u16::unchecked_sub`] and [`i64::unchecked_sub`]. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "unchecked_math", since = "1.79.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_sub(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_sub(x: T, y: T) -> T; /// Returns the result of an unchecked multiplication, resulting in /// undefined behavior when `x * y > T::MAX` or `x * y < T::MIN`. /// /// The stable counterpart of this intrinsic is `unchecked_mul` on the various /// integer types, such as [`u16::unchecked_mul`] and [`i64::unchecked_mul`]. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "unchecked_math", since = "1.79.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_mul(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_mul(x: T, y: T) -> T; /// Performs rotate left. /// @@ -3105,14 +2714,10 @@ pub const unsafe fn unchecked_mul(_x: T, _y: T) -> T { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `rotate_left` method. For example, /// [`u32::rotate_left`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_rotate", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn rotate_left(_x: T, _shift: u32) -> T { - unimplemented!() -} +pub const fn rotate_left(x: T, shift: u32) -> T; /// Performs rotate right. /// @@ -3124,14 +2729,10 @@ pub const fn rotate_left(_x: T, _shift: u32) -> T { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `rotate_right` method. For example, /// [`u32::rotate_right`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_rotate", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn rotate_right(_x: T, _shift: u32) -> T { - unimplemented!() -} +pub const fn rotate_right(x: T, shift: u32) -> T; /// Returns (a + b) mod 2N, where N is the width of T in bits. /// @@ -3143,14 +2744,10 @@ pub const fn rotate_right(_x: T, _shift: u32) -> T { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `wrapping_add` method. For example, /// [`u32::wrapping_add`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn wrapping_add(_a: T, _b: T) -> T { - unimplemented!() -} +pub const fn wrapping_add(a: T, b: T) -> T; /// Returns (a - b) mod 2N, where N is the width of T in bits. /// /// Note that, unlike most intrinsics, this is safe to call; @@ -3161,14 +2758,10 @@ pub const fn wrapping_add(_a: T, _b: T) -> T { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `wrapping_sub` method. For example, /// [`u32::wrapping_sub`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn wrapping_sub(_a: T, _b: T) -> T { - unimplemented!() -} +pub const fn wrapping_sub(a: T, b: T) -> T; /// Returns (a * b) mod 2N, where N is the width of T in bits. /// /// Note that, unlike most intrinsics, this is safe to call; @@ -3179,14 +2772,10 @@ pub const fn wrapping_sub(_a: T, _b: T) -> T { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `wrapping_mul` method. For example, /// [`u32::wrapping_mul`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn wrapping_mul(_a: T, _b: T) -> T { - unimplemented!() -} +pub const fn wrapping_mul(a: T, b: T) -> T; /// Computes `a + b`, saturating at numeric bounds. /// @@ -3198,14 +2787,10 @@ pub const fn wrapping_mul(_a: T, _b: T) -> T { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `saturating_add` method. For example, /// [`u32::saturating_add`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_saturating", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn saturating_add(_a: T, _b: T) -> T { - unimplemented!() -} +pub const fn saturating_add(a: T, b: T) -> T; /// Computes `a - b`, saturating at numeric bounds. /// /// Note that, unlike most intrinsics, this is safe to call; @@ -3216,14 +2801,10 @@ pub const fn saturating_add(_a: T, _b: T) -> T { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `saturating_sub` method. For example, /// [`u32::saturating_sub`] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_saturating", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn saturating_sub(_a: T, _b: T) -> T { - unimplemented!() -} +pub const fn saturating_sub(a: T, b: T) -> T; /// This is an implementation detail of [`crate::ptr::read`] and should /// not be used anywhere else. See its comments for why this exists. @@ -3231,14 +2812,10 @@ pub const fn saturating_sub(_a: T, _b: T) -> T { /// This intrinsic can *only* be called where the pointer is a local without /// projections (`read_via_copy(ptr)`, not `read_via_copy(*ptr)`) so that it /// trivially obeys runtime-MIR rules about derefs in operands. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_read", since = "1.71.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn read_via_copy(_ptr: *const T) -> T { - unimplemented!() -} +pub const unsafe fn read_via_copy(ptr: *const T) -> T; /// This is an implementation detail of [`crate::ptr::write`] and should /// not be used anywhere else. See its comments for why this exists. @@ -3246,14 +2823,10 @@ pub const unsafe fn read_via_copy(_ptr: *const T) -> T { /// This intrinsic can *only* be called where the pointer is a local without /// projections (`write_via_move(ptr, x)`, not `write_via_move(*ptr, x)`) so /// that it trivially obeys runtime-MIR rules about derefs in operands. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_write", since = "1.83.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn write_via_move(_ptr: *mut T, _value: T) { - unimplemented!() -} +pub const unsafe fn write_via_move(ptr: *mut T, value: T); /// Returns the value of the discriminant for the variant in 'v'; /// if `T` has no discriminant, returns `0`. @@ -3264,69 +2837,61 @@ pub const unsafe fn write_via_move(_ptr: *mut T, _value: T) { /// any safety invariants. /// /// The stabilized version of this intrinsic is [`core::mem::discriminant`]. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_discriminant", since = "1.75.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn discriminant_value(_v: &T) -> ::Discriminant { - unimplemented!() -} +pub const fn discriminant_value(v: &T) -> ::Discriminant; -extern "rust-intrinsic" { - /// Rust's "try catch" construct for unwinding. Invokes the function pointer `try_fn` with the - /// data pointer `data`, and calls `catch_fn` if unwinding occurs while `try_fn` runs. - /// - /// `catch_fn` must not unwind. - /// - /// The third argument is a function called if an unwind occurs (both Rust `panic` and foreign - /// unwinds). This function takes the data pointer and a pointer to the target- and - /// runtime-specific exception object that was caught. - /// - /// Note that in the case of a foreign unwinding operation, the exception object data may not be - /// safely usable from Rust, and should not be directly exposed via the standard library. To - /// prevent unsafe access, the library implementation may either abort the process or present an - /// opaque error type to the user. - /// - /// For more information, see the compiler's source, as well as the documentation for the stable - /// version of this intrinsic, `std::panic::catch_unwind`. - #[rustc_nounwind] - pub fn catch_unwind(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32; - - /// Emits a `nontemporal` store, which gives a hint to the CPU that the data should not be held - /// in cache. Except for performance, this is fully equivalent to `ptr.write(val)`. - /// - /// Not all architectures provide such an operation. For instance, x86 does not: while `MOVNT` - /// exists, that operation is *not* equivalent to `ptr.write(val)` (`MOVNT` writes can be reordered - /// in ways that are not allowed for regular writes). - #[rustc_nounwind] - pub fn nontemporal_store(ptr: *mut T, val: T); -} +/// Rust's "try catch" construct for unwinding. Invokes the function pointer `try_fn` with the +/// data pointer `data`, and calls `catch_fn` if unwinding occurs while `try_fn` runs. +/// +/// `catch_fn` must not unwind. +/// +/// The third argument is a function called if an unwind occurs (both Rust `panic` and foreign +/// unwinds). This function takes the data pointer and a pointer to the target- and +/// runtime-specific exception object that was caught. +/// +/// Note that in the case of a foreign unwinding operation, the exception object data may not be +/// safely usable from Rust, and should not be directly exposed via the standard library. To +/// prevent unsafe access, the library implementation may either abort the process or present an +/// opaque error type to the user. +/// +/// For more information, see the compiler's source, as well as the documentation for the stable +/// version of this intrinsic, `std::panic::catch_unwind`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn catch_unwind( + _try_fn: fn(*mut u8), + _data: *mut u8, + _catch_fn: fn(*mut u8, *mut u8), +) -> i32; + +/// Emits a `nontemporal` store, which gives a hint to the CPU that the data should not be held +/// in cache. Except for performance, this is fully equivalent to `ptr.write(val)`. +/// +/// Not all architectures provide such an operation. For instance, x86 does not: while `MOVNT` +/// exists, that operation is *not* equivalent to `ptr.write(val)` (`MOVNT` writes can be reordered +/// in ways that are not allowed for regular writes). +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn nontemporal_store(ptr: *mut T, val: T); /// See documentation of `<*const T>::offset_from` for details. -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_offset_from", since = "1.65.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn ptr_offset_from(_ptr: *const T, _base: *const T) -> isize { - unimplemented!() -} +pub const unsafe fn ptr_offset_from(ptr: *const T, base: *const T) -> isize; /// See documentation of `<*const T>::sub_ptr` for details. -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892"))] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn ptr_offset_from_unsigned(_ptr: *const T, _base: *const T) -> usize { - unimplemented!() -} +#[rustc_intrinsic_const_stable_indirect] +pub const unsafe fn ptr_offset_from_unsigned(ptr: *const T, base: *const T) -> usize; /// See documentation of `<*const T>::guaranteed_eq` for details. /// Returns `2` if the result is unknown. /// Returns `1` if the pointers are guaranteed equal. /// Returns `0` if the pointers are guaranteed inequal. -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020"))] #[rustc_intrinsic] #[rustc_nounwind] #[rustc_do_not_const_check] @@ -3359,13 +2924,9 @@ pub const fn ptr_guaranteed_cmp(ptr: *const T, other: *const T) -> u8 { /// /// (The implementation is allowed to branch on the results of comparisons, /// which is UB if any of their inputs are `undef`.) -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_intrinsic_raw_eq", issue = "none"))] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn raw_eq(_a: &T, _b: &T) -> bool { - unimplemented!() -} +pub const unsafe fn raw_eq(a: &T, b: &T) -> bool; /// Lexicographically compare `[left, left + bytes)` and `[right, right + bytes)` /// as unsigned bytes, returning negative if `left` is less, zero if all the @@ -3381,27 +2942,17 @@ pub const unsafe fn raw_eq(_a: &T, _b: &T) -> bool { /// that differs. That allows optimizations that can read in large chunks. /// /// [valid]: crate::ptr#safety -#[cfg_attr( - bootstrap, - rustc_const_unstable(feature = "const_intrinsic_compare_bytes", issue = "none") -)] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn compare_bytes(_left: *const u8, _right: *const u8, _bytes: usize) -> i32 { - unimplemented!() -} +pub const unsafe fn compare_bytes(left: *const u8, right: *const u8, bytes: usize) -> i32; /// See documentation of [`std::hint::black_box`] for details. /// /// [`std::hint::black_box`]: crate::hint::black_box -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_black_box", issue = "none"))] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn black_box(_dummy: T) -> T { - unimplemented!() -} +#[rustc_intrinsic_const_stable_indirect] +pub const fn black_box(dummy: T) -> T; /// Selects which function to call depending on the context. /// @@ -3457,7 +3008,6 @@ pub const fn black_box(_dummy: T) -> T { /// otherwise, that principle should not be violated. #[rustc_const_unstable(feature = "const_eval_select", issue = "124625")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] pub const fn const_eval_select( _arg: ARG, _called_in_const: F, @@ -3465,10 +3015,7 @@ pub const fn const_eval_select( ) -> RET where G: FnOnce, - F: FnOnce, -{ - unreachable!() -} + F: FnOnce; /// A macro to make it easier to invoke const_eval_select. Use as follows: /// ```rust,ignore (just a macro example) @@ -3490,7 +3037,7 @@ where /// See [`const_eval_select()`] for the rules and requirements around that intrinsic. pub(crate) macro const_eval_select { ( - @capture { $($arg:ident : $ty:ty = $val:expr),* $(,)? } $( -> $ret:ty )? : + @capture$([$($binders:tt)*])? { $($arg:ident : $ty:ty = $val:expr),* $(,)? } $( -> $ret:ty )? : if const $(#[$compiletime_attr:meta])* $compiletime:block else @@ -3498,7 +3045,7 @@ pub(crate) macro const_eval_select { ) => { // Use the `noinline` arm, after adding explicit `inline` attributes $crate::intrinsics::const_eval_select!( - @capture { $($arg : $ty = $val),* } $(-> $ret)? : + @capture$([$($binders)*])? { $($arg : $ty = $val),* } $(-> $ret)? : #[noinline] if const #[inline] // prevent codegen on this function @@ -3512,7 +3059,7 @@ pub(crate) macro const_eval_select { }, // With a leading #[noinline], we don't add inline attributes ( - @capture { $($arg:ident : $ty:ty = $val:expr),* $(,)? } $( -> $ret:ty )? : + @capture$([$($binders:tt)*])? { $($arg:ident : $ty:ty = $val:expr),* $(,)? } $( -> $ret:ty )? : #[noinline] if const $(#[$compiletime_attr:meta])* $compiletime:block @@ -3520,12 +3067,12 @@ pub(crate) macro const_eval_select { $(#[$runtime_attr:meta])* $runtime:block ) => {{ $(#[$runtime_attr])* - fn runtime($($arg: $ty),*) $( -> $ret )? { + fn runtime$(<$($binders)*>)?($($arg: $ty),*) $( -> $ret )? { $runtime } $(#[$compiletime_attr])* - const fn compiletime($($arg: $ty),*) $( -> $ret )? { + const fn compiletime$(<$($binders)*>)?($($arg: $ty),*) $( -> $ret )? { // Don't warn if one of the arguments is unused. $(let _ = $arg;)* @@ -3537,14 +3084,14 @@ pub(crate) macro const_eval_select { // We support leaving away the `val` expressions for *all* arguments // (but not for *some* arguments, that's too tricky). ( - @capture { $($arg:ident : $ty:ty),* $(,)? } $( -> $ret:ty )? : + @capture$([$($binders:tt)*])? { $($arg:ident : $ty:ty),* $(,)? } $( -> $ret:ty )? : if const $(#[$compiletime_attr:meta])* $compiletime:block else $(#[$runtime_attr:meta])* $runtime:block ) => { $crate::intrinsics::const_eval_select!( - @capture { $($arg : $ty = $arg),* } $(-> $ret)? : + @capture$([$($binders)*])? { $($arg : $ty = $arg),* } $(-> $ret)? : if const $(#[$compiletime_attr])* $compiletime else @@ -3627,11 +3174,7 @@ pub(crate) macro const_eval_select { /// # _ = foo(&5_i32); /// # _ = bar(&5_i32); /// ``` -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_is_val_statically_known", since = "CURRENT_RUSTC_VERSION") -)] -#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] +#[rustc_const_stable_indirect] #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] @@ -3652,9 +3195,9 @@ pub const fn is_val_statically_known(_arg: T) -> bool { #[rustc_nounwind] #[inline] #[rustc_intrinsic] -// Const-unstable because `swap_nonoverlapping` is const-unstable. -#[rustc_const_unstable(feature = "const_typed_swap", issue = "none")] -pub const unsafe fn typed_swap(x: *mut T, y: *mut T) { +#[rustc_intrinsic_const_stable_indirect] +#[rustc_allow_const_fn_unstable(const_swap_nonoverlapping)] // this is anyway not called since CTFE implements the intrinsic +pub const unsafe fn typed_swap_nonoverlapping(x: *mut T, y: *mut T) { // SAFETY: The caller provided single non-overlapping items behind // pointers, so swapping them with `count: 1` is fine. unsafe { ptr::swap_nonoverlapping(x, y, 1) }; @@ -3673,8 +3216,7 @@ pub const unsafe fn typed_swap(x: *mut T, y: *mut T) { /// assertions are enabled whenever the *user crate* has UB checks enabled. However, if the /// user has UB checks disabled, the checks will still get optimized out. This intrinsic is /// primarily used by [`ub_checks::assert_unsafe_precondition`]. -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_ub_checks", issue = "none"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] // just for UB checks +#[rustc_intrinsic_const_stable_indirect] // just for UB checks #[inline(always)] #[rustc_intrinsic] pub const fn ub_checks() -> bool { @@ -3718,6 +3260,49 @@ pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) // Runtime NOP } +/// Returns whether we should perform contract-checking at runtime. +/// +/// This is meant to be similar to the ub_checks intrinsic, in terms +/// of not prematurely commiting at compile-time to whether contract +/// checking is turned on, so that we can specify contracts in libstd +/// and let an end user opt into turning them on. +#[rustc_const_unstable(feature = "contracts_internals", issue = "128044" /* compiler-team#759 */)] +#[unstable(feature = "contracts_internals", issue = "128044" /* compiler-team#759 */)] +#[inline(always)] +#[rustc_intrinsic] +pub const fn contract_checks() -> bool { + // FIXME: should this be `false` or `cfg!(contract_checks)`? + + // cfg!(contract_checks) + false +} + +/// Check if the pre-condition `cond` has been met. +/// +/// By default, if `contract_checks` is enabled, this will panic with no unwind if the condition +/// returns false. +#[unstable(feature = "contracts_internals", issue = "128044" /* compiler-team#759 */)] +#[lang = "contract_check_requires"] +#[rustc_intrinsic] +pub fn contract_check_requires bool>(cond: C) { + if contract_checks() && !cond() { + // Emit no unwind panic in case this was a safety requirement. + crate::panicking::panic_nounwind("failed requires check"); + } +} + +/// Check if the post-condition `cond` has been met. +/// +/// By default, if `contract_checks` is enabled, this will panic with no unwind if the condition +/// returns false. +#[unstable(feature = "contracts_internals", issue = "128044" /* compiler-team#759 */)] +#[rustc_intrinsic] +pub fn contract_check_ensures<'a, Ret, C: Fn(&'a Ret) -> bool>(ret: &'a Ret, cond: C) { + if contract_checks() && !cond(ret) { + crate::panicking::panic_nounwind("failed ensures check"); + } +} + /// The intrinsic will return the size stored in that vtable. /// /// # Safety @@ -3726,10 +3311,7 @@ pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub unsafe fn vtable_size(_ptr: *const ()) -> usize { - unreachable!() -} +pub unsafe fn vtable_size(ptr: *const ()) -> usize; /// The intrinsic will return the alignment stored in that vtable. /// @@ -3739,10 +3321,7 @@ pub unsafe fn vtable_size(_ptr: *const ()) -> usize { #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub unsafe fn vtable_align(_ptr: *const ()) -> usize { - unreachable!() -} +pub unsafe fn vtable_align(ptr: *const ()) -> usize; /// The size of a type in bytes. /// @@ -3754,16 +3333,12 @@ pub unsafe fn vtable_align(_ptr: *const ()) -> usize { /// More specifically, this is the offset in bytes between successive /// items of the same type, including alignment padding. /// -/// The stabilized version of this intrinsic is [`core::mem::size_of`]. +/// The stabilized version of this intrinsic is [`size_of`]. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_size_of", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn size_of() -> usize { - unreachable!() -} +pub const fn size_of() -> usize; /// The minimum alignment of a type. /// @@ -3772,16 +3347,12 @@ pub const fn size_of() -> usize { /// Therefore, implementations must not require the user to uphold /// any safety invariants. /// -/// The stabilized version of this intrinsic is [`core::mem::align_of`]. +/// The stabilized version of this intrinsic is [`align_of`]. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_min_align_of", since = "1.40.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn min_align_of() -> usize { - unreachable!() -} +pub const fn min_align_of() -> usize; /// The preferred alignment of a type. /// @@ -3789,12 +3360,8 @@ pub const fn min_align_of() -> usize { /// It's "tracking issue" is [#91971](https://github.com/rust-lang/rust/issues/91971). #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_pref_align_of", issue = "91971"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn pref_align_of() -> usize { - unreachable!() -} +pub const unsafe fn pref_align_of() -> usize; /// Returns the number of variants of the type `T` cast to a `usize`; /// if `T` has no variants, returns `0`. Uninhabited variants will be counted. @@ -3807,44 +3374,34 @@ pub const unsafe fn pref_align_of() -> usize { /// The to-be-stabilized version of this intrinsic is [`crate::mem::variant_count`]. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "variant_count", issue = "73662"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn variant_count() -> usize { - unreachable!() -} +pub const fn variant_count() -> usize; /// The size of the referenced value in bytes. /// -/// The stabilized version of this intrinsic is [`crate::mem::size_of_val`]. +/// The stabilized version of this intrinsic is [`size_of_val`]. /// /// # Safety /// /// See [`crate::mem::size_of_val_raw`] for safety conditions. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_size_of_val", issue = "46571"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn size_of_val(_ptr: *const T) -> usize { - unreachable!() -} +#[rustc_intrinsic_const_stable_indirect] +pub const unsafe fn size_of_val(ptr: *const T) -> usize; /// The required alignment of the referenced value. /// -/// The stabilized version of this intrinsic is [`core::mem::align_of_val`]. +/// The stabilized version of this intrinsic is [`align_of_val`]. /// /// # Safety /// /// See [`crate::mem::align_of_val_raw`] for safety conditions. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_align_of_val", issue = "46571"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn min_align_of_val(_ptr: *const T) -> usize { - unreachable!() -} +#[rustc_intrinsic_const_stable_indirect] +pub const unsafe fn min_align_of_val(ptr: *const T) -> usize; /// Gets a static string slice containing the name of a type. /// @@ -3856,12 +3413,8 @@ pub const unsafe fn min_align_of_val(_ptr: *const T) -> usize { /// The stabilized version of this intrinsic is [`core::any::type_name`]. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_type_name", issue = "63084"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn type_name() -> &'static str { - unreachable!() -} +pub const fn type_name() -> &'static str; /// Gets an identifier which is globally unique to the specified type. This /// function will return the same value for a type regardless of whichever @@ -3875,12 +3428,8 @@ pub const fn type_name() -> &'static str { /// The stabilized version of this intrinsic is [`core::any::TypeId::of`]. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_type_id", issue = "77125"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn type_id() -> u128 { - unreachable!() -} +pub const fn type_id() -> u128; /// Lowers in MIR to `Rvalue::Aggregate` with `AggregateKind::RawPtr`. /// @@ -3889,15 +3438,9 @@ pub const fn type_id() -> u128 { /// change the possible layouts of pointers. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "ptr_metadata_const", since = "1.83.0"))] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] -#[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn aggregate_raw_ptr, D, M>(_data: D, _meta: M) -> P { - // To implement a fallback we'd have to assume the layout of the pointer, - // but the whole point of this intrinsic is that we shouldn't do that. - unreachable!() -} +#[rustc_intrinsic_const_stable_indirect] +#[rustc_intrinsic] +pub const fn aggregate_raw_ptr, D, M>(data: D, meta: M) -> P; #[unstable(feature = "core_intrinsics", issue = "none")] pub trait AggregateRawPtr { @@ -3915,18 +3458,9 @@ impl AggregateRawPtr<*mut T> for *mut P { /// This is used to implement functions like `ptr::metadata`. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[cfg_attr( - bootstrap, - cfg_attr(bootstrap, rustc_const_stable(feature = "ptr_metadata_const", since = "1.83.0")) -)] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn ptr_metadata + ?Sized, M>(_ptr: *const P) -> M { - // To implement a fallback we'd have to assume the layout of the pointer, - // but the whole point of this intrinsic is that we shouldn't do that. - unreachable!() -} +pub const fn ptr_metadata + ?Sized, M>(ptr: *const P) -> M; // Some functions are defined here because they accidentally got made // available in this module on stable. See . @@ -4019,20 +3553,16 @@ pub const fn ptr_metadata + ?Sized, M>(_ptr: *cons /// [`Vec::append`]: ../../std/vec/struct.Vec.html#method.append #[doc(alias = "memcpy")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_allowed_through_unstable_modules] +#[rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces #[rustc_diagnostic_item = "ptr_copy_nonoverlapping"] pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0"))] - #[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] + #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - const unsafe fn copy_nonoverlapping(_src: *const T, _dst: *mut T, _count: usize) { - unreachable!() - } + const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize); ub_checks::assert_unsafe_precondition!( check_language_ub, @@ -4076,13 +3606,11 @@ pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: us /// /// Behavior is undefined if any of the following conditions are violated: /// -/// * `src` must be [valid] for reads of `count * size_of::()` bytes, and must remain valid even -/// when `dst` is written for `count * size_of::()` bytes. (This means if the memory ranges -/// overlap, the two pointers must not be subject to aliasing restrictions relative to each -/// other.) +/// * `src` must be [valid] for reads of `count * size_of::()` bytes. /// /// * `dst` must be [valid] for writes of `count * size_of::()` bytes, and must remain valid even -/// when `src` is read for `count * size_of::()` bytes. +/// when `src` is read for `count * size_of::()` bytes. (This means if the memory ranges +/// overlap, the `dst` pointer must not be invalidated by `src` reads.) /// /// * Both `src` and `dst` must be properly aligned. /// @@ -4116,30 +3644,26 @@ pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: us /// /// // SAFETY: Our precondition ensures the source is aligned and valid, /// // and `Vec::with_capacity` ensures that we have usable space to write them. -/// ptr::copy(ptr, dst.as_mut_ptr(), elts); +/// unsafe { ptr::copy(ptr, dst.as_mut_ptr(), elts); } /// /// // SAFETY: We created it with this much capacity earlier, /// // and the previous `copy` has initialized these elements. -/// dst.set_len(elts); +/// unsafe { dst.set_len(elts); } /// dst /// } /// ``` #[doc(alias = "memmove")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_allowed_through_unstable_modules] +#[rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces #[rustc_diagnostic_item = "ptr_copy"] pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0"))] - #[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] + #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - const unsafe fn copy(_src: *const T, _dst: *mut T, _count: usize) { - unreachable!() - } + const unsafe fn copy(src: *const T, dst: *mut T, count: usize); // SAFETY: the safety contract for `copy` must be upheld by the caller. unsafe { @@ -4210,20 +3734,16 @@ pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { /// ``` #[doc(alias = "memset")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_allowed_through_unstable_modules] +#[rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"] #[rustc_const_stable(feature = "const_ptr_write", since = "1.83.0")] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces #[rustc_diagnostic_item = "ptr_write_bytes"] pub const unsafe fn write_bytes(dst: *mut T, val: u8, count: usize) { - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_write", since = "1.83.0"))] - #[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] + #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - const unsafe fn write_bytes(_dst: *mut T, _val: u8, _count: usize) { - unreachable!() - } + const unsafe fn write_bytes(dst: *mut T, val: u8, count: usize); // SAFETY: the safety contract for `write_bytes` must be upheld by the caller. unsafe { @@ -4250,12 +3770,8 @@ pub const unsafe fn write_bytes(dst: *mut T, val: u8, count: usize) { /// The stabilized version of this intrinsic is /// [`f16::min`] #[rustc_nounwind] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f16", issue = "116909"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn minnumf16(_x: f16, _y: f16) -> f16 { - unimplemented!(); -} +pub const fn minnumf16(x: f16, y: f16) -> f16; /// Returns the minimum of two `f32` values. /// @@ -4267,16 +3783,9 @@ pub const fn minnumf16(_x: f16, _y: f16) -> f16 { /// The stabilized version of this intrinsic is /// [`f32::min`] #[rustc_nounwind] -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION") -)] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn minnumf32(_x: f32, _y: f32) -> f32 { - unimplemented!(); -} +pub const fn minnumf32(x: f32, y: f32) -> f32; /// Returns the minimum of two `f64` values. /// @@ -4288,16 +3797,9 @@ pub const fn minnumf32(_x: f32, _y: f32) -> f32 { /// The stabilized version of this intrinsic is /// [`f64::min`] #[rustc_nounwind] -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION") -)] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn minnumf64(_x: f64, _y: f64) -> f64 { - unimplemented!(); -} +pub const fn minnumf64(x: f64, y: f64) -> f64; /// Returns the minimum of two `f128` values. /// @@ -4309,12 +3811,8 @@ pub const fn minnumf64(_x: f64, _y: f64) -> f64 { /// The stabilized version of this intrinsic is /// [`f128::min`] #[rustc_nounwind] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f128", issue = "116909"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn minnumf128(_x: f128, _y: f128) -> f128 { - unimplemented!(); -} +pub const fn minnumf128(x: f128, y: f128) -> f128; /// Returns the maximum of two `f16` values. /// @@ -4326,12 +3824,8 @@ pub const fn minnumf128(_x: f128, _y: f128) -> f128 { /// The stabilized version of this intrinsic is /// [`f16::max`] #[rustc_nounwind] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f16", issue = "116909"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn maxnumf16(_x: f16, _y: f16) -> f16 { - unimplemented!(); -} +pub const fn maxnumf16(x: f16, y: f16) -> f16; /// Returns the maximum of two `f32` values. /// @@ -4343,16 +3837,9 @@ pub const fn maxnumf16(_x: f16, _y: f16) -> f16 { /// The stabilized version of this intrinsic is /// [`f32::max`] #[rustc_nounwind] -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION") -)] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn maxnumf32(_x: f32, _y: f32) -> f32 { - unimplemented!(); -} +pub const fn maxnumf32(x: f32, y: f32) -> f32; /// Returns the maximum of two `f64` values. /// @@ -4364,16 +3851,9 @@ pub const fn maxnumf32(_x: f32, _y: f32) -> f32 { /// The stabilized version of this intrinsic is /// [`f64::max`] #[rustc_nounwind] -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION") -)] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn maxnumf64(_x: f64, _y: f64) -> f64 { - unimplemented!(); -} +pub const fn maxnumf64(x: f64, y: f64) -> f64; /// Returns the maximum of two `f128` values. /// @@ -4385,129 +3865,81 @@ pub const fn maxnumf64(_x: f64, _y: f64) -> f64 { /// The stabilized version of this intrinsic is /// [`f128::max`] #[rustc_nounwind] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f128", issue = "116909"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn maxnumf128(_x: f128, _y: f128) -> f128 { - unimplemented!(); -} +pub const fn maxnumf128(x: f128, y: f128) -> f128; /// Returns the absolute value of an `f16`. /// /// The stabilized version of this intrinsic is /// [`f16::abs`](../../std/primitive.f16.html#method.abs) #[rustc_nounwind] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f16", issue = "116909"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn fabsf16(_x: f16) -> f16 { - unimplemented!(); -} +pub const unsafe fn fabsf16(x: f16) -> f16; /// Returns the absolute value of an `f32`. /// /// The stabilized version of this intrinsic is /// [`f32::abs`](../../std/primitive.f32.html#method.abs) #[rustc_nounwind] -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION") -)] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn fabsf32(_x: f32) -> f32 { - unimplemented!(); -} +pub const unsafe fn fabsf32(x: f32) -> f32; /// Returns the absolute value of an `f64`. /// /// The stabilized version of this intrinsic is /// [`f64::abs`](../../std/primitive.f64.html#method.abs) #[rustc_nounwind] -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION") -)] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn fabsf64(_x: f64) -> f64 { - unimplemented!(); -} +pub const unsafe fn fabsf64(x: f64) -> f64; /// Returns the absolute value of an `f128`. /// /// The stabilized version of this intrinsic is /// [`f128::abs`](../../std/primitive.f128.html#method.abs) #[rustc_nounwind] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f128", issue = "116909"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn fabsf128(_x: f128) -> f128 { - unimplemented!(); -} +pub const unsafe fn fabsf128(x: f128) -> f128; /// Copies the sign from `y` to `x` for `f16` values. /// /// The stabilized version of this intrinsic is /// [`f16::copysign`](../../std/primitive.f16.html#method.copysign) #[rustc_nounwind] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f16", issue = "116909"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn copysignf16(_x: f16, _y: f16) -> f16 { - unimplemented!(); -} +pub const unsafe fn copysignf16(x: f16, y: f16) -> f16; /// Copies the sign from `y` to `x` for `f32` values. /// /// The stabilized version of this intrinsic is /// [`f32::copysign`](../../std/primitive.f32.html#method.copysign) #[rustc_nounwind] -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION") -)] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn copysignf32(_x: f32, _y: f32) -> f32 { - unimplemented!(); -} +pub const unsafe fn copysignf32(x: f32, y: f32) -> f32; /// Copies the sign from `y` to `x` for `f64` values. /// /// The stabilized version of this intrinsic is /// [`f64::copysign`](../../std/primitive.f64.html#method.copysign) #[rustc_nounwind] -#[cfg_attr( - bootstrap, - rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION") -)] -#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn copysignf64(_x: f64, _y: f64) -> f64 { - unimplemented!(); -} +pub const unsafe fn copysignf64(x: f64, y: f64) -> f64; /// Copies the sign from `y` to `x` for `f128` values. /// /// The stabilized version of this intrinsic is /// [`f128::copysign`](../../std/primitive.f128.html#method.copysign) #[rustc_nounwind] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f128", issue = "116909"))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn copysignf128(_x: f128, _y: f128) -> f128 { - unimplemented!(); -} +pub const unsafe fn copysignf128(x: f128, y: f128) -> f128; /// Inform Miri that a given pointer definitely has a certain alignment. #[cfg(miri)] #[rustc_allow_const_fn_unstable(const_eval_select)] pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize) { - extern "Rust" { + unsafe extern "Rust" { /// Miri-provided extern function to promise that a given pointer is properly aligned for /// "symbolic" alignment checks. Will fail if the pointer is not actually aligned or `align` is /// not a power of two. Has no effect when alignment checks are concrete (which is the default). diff --git a/core/src/intrinsics/simd.rs b/core/src/intrinsics/simd.rs index 5ddca9c4dce88..ae6e1a779ed58 100644 --- a/core/src/intrinsics/simd.rs +++ b/core/src/intrinsics/simd.rs @@ -2,655 +2,733 @@ //! //! In this module, a "vector" is any `repr(simd)` type. -extern "rust-intrinsic" { - /// Inserts an element into a vector, returning the updated vector. - /// - /// `T` must be a vector with element type `U`. - /// - /// # Safety - /// - /// `idx` must be in-bounds of the vector. - #[rustc_nounwind] - pub fn simd_insert(x: T, idx: u32, val: U) -> T; - - /// Extracts an element from a vector. - /// - /// `T` must be a vector with element type `U`. - /// - /// # Safety - /// - /// `idx` must be in-bounds of the vector. - #[rustc_nounwind] - pub fn simd_extract(x: T, idx: u32) -> U; - - /// Adds two simd vectors elementwise. - /// - /// `T` must be a vector of integer or floating point primitive types. - #[rustc_nounwind] - pub fn simd_add(x: T, y: T) -> T; - - /// Subtracts `rhs` from `lhs` elementwise. - /// - /// `T` must be a vector of integer or floating point primitive types. - #[rustc_nounwind] - pub fn simd_sub(lhs: T, rhs: T) -> T; - - /// Multiplies two simd vectors elementwise. - /// - /// `T` must be a vector of integer or floating point primitive types. - #[rustc_nounwind] - pub fn simd_mul(x: T, y: T) -> T; - - /// Divides `lhs` by `rhs` elementwise. - /// - /// `T` must be a vector of integer or floating point primitive types. - /// - /// # Safety - /// For integers, `rhs` must not contain any zero elements. - /// Additionally for signed integers, `::MIN / -1` is undefined behavior. - #[rustc_nounwind] - pub fn simd_div(lhs: T, rhs: T) -> T; - - /// Returns remainder of two vectors elementwise. - /// - /// `T` must be a vector of integer or floating point primitive types. - /// - /// # Safety - /// For integers, `rhs` must not contain any zero elements. - /// Additionally for signed integers, `::MIN / -1` is undefined behavior. - #[rustc_nounwind] - pub fn simd_rem(lhs: T, rhs: T) -> T; - - /// Shifts vector left elementwise, with UB on overflow. - /// - /// Shifts `lhs` left by `rhs`, shifting in sign bits for signed types. - /// - /// `T` must be a vector of integer primitive types. - /// - /// # Safety - /// - /// Each element of `rhs` must be less than `::BITS`. - #[rustc_nounwind] - pub fn simd_shl(lhs: T, rhs: T) -> T; - - /// Shifts vector right elementwise, with UB on overflow. - /// - /// `T` must be a vector of integer primitive types. - /// - /// Shifts `lhs` right by `rhs`, shifting in sign bits for signed types. - /// - /// # Safety - /// - /// Each element of `rhs` must be less than `::BITS`. - #[rustc_nounwind] - pub fn simd_shr(lhs: T, rhs: T) -> T; - - /// "Ands" vectors elementwise. - /// - /// `T` must be a vector of integer primitive types. - #[rustc_nounwind] - pub fn simd_and(x: T, y: T) -> T; - - /// "Ors" vectors elementwise. - /// - /// `T` must be a vector of integer primitive types. - #[rustc_nounwind] - pub fn simd_or(x: T, y: T) -> T; - - /// "Exclusive ors" vectors elementwise. - /// - /// `T` must be a vector of integer primitive types. - #[rustc_nounwind] - pub fn simd_xor(x: T, y: T) -> T; - - /// Numerically casts a vector, elementwise. - /// - /// `T` and `U` must be vectors of integer or floating point primitive types, and must have the - /// same length. - /// - /// When casting floats to integers, the result is truncated. Out-of-bounds result lead to UB. - /// When casting integers to floats, the result is rounded. - /// Otherwise, truncates or extends the value, maintaining the sign for signed integers. - /// - /// # Safety - /// Casting from integer types is always safe. - /// Casting between two float types is also always safe. - /// - /// Casting floats to integers truncates, following the same rules as `to_int_unchecked`. - /// Specifically, each element must: - /// * Not be `NaN` - /// * Not be infinite - /// * Be representable in the return type, after truncating off its fractional part - #[rustc_nounwind] - pub fn simd_cast(x: T) -> U; - - /// Numerically casts a vector, elementwise. - /// - /// `T` and `U` be a vectors of integer or floating point primitive types, and must have the - /// same length. - /// - /// Like `simd_cast`, but saturates float-to-integer conversions (NaN becomes 0). - /// This matches regular `as` and is always safe. - /// - /// When casting floats to integers, the result is truncated. - /// When casting integers to floats, the result is rounded. - /// Otherwise, truncates or extends the value, maintaining the sign for signed integers. - #[rustc_nounwind] - pub fn simd_as(x: T) -> U; - - /// Negates a vector elementwise. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// Rust panics for `-::Min` due to overflow, but it is not UB with this intrinsic. - #[rustc_nounwind] - pub fn simd_neg(x: T) -> T; - - /// Returns absolute value of a vector, elementwise. - /// - /// `T` must be a vector of floating-point primitive types. - #[rustc_nounwind] - pub fn simd_fabs(x: T) -> T; - - /// Returns the minimum of two vectors, elementwise. - /// - /// `T` must be a vector of floating-point primitive types. - /// - /// Follows IEEE-754 `minNum` semantics. - #[rustc_nounwind] - pub fn simd_fmin(x: T, y: T) -> T; - - /// Returns the maximum of two vectors, elementwise. - /// - /// `T` must be a vector of floating-point primitive types. - /// - /// Follows IEEE-754 `maxNum` semantics. - #[rustc_nounwind] - pub fn simd_fmax(x: T, y: T) -> T; - - /// Tests elementwise equality of two vectors. - /// - /// `T` must be a vector of floating-point primitive types. - /// - /// `U` must be a vector of integers with the same number of elements and element size as `T`. - /// - /// Returns `0` for false and `!0` for true. - #[rustc_nounwind] - pub fn simd_eq(x: T, y: T) -> U; - - /// Tests elementwise inequality equality of two vectors. - /// - /// `T` must be a vector of floating-point primitive types. - /// - /// `U` must be a vector of integers with the same number of elements and element size as `T`. - /// - /// Returns `0` for false and `!0` for true. - #[rustc_nounwind] - pub fn simd_ne(x: T, y: T) -> U; - - /// Tests if `x` is less than `y`, elementwise. - /// - /// `T` must be a vector of floating-point primitive types. - /// - /// `U` must be a vector of integers with the same number of elements and element size as `T`. - /// - /// Returns `0` for false and `!0` for true. - #[rustc_nounwind] - pub fn simd_lt(x: T, y: T) -> U; - - /// Tests if `x` is less than or equal to `y`, elementwise. - /// - /// `T` must be a vector of floating-point primitive types. - /// - /// `U` must be a vector of integers with the same number of elements and element size as `T`. - /// - /// Returns `0` for false and `!0` for true. - #[rustc_nounwind] - pub fn simd_le(x: T, y: T) -> U; - - /// Tests if `x` is greater than `y`, elementwise. - /// - /// `T` must be a vector of floating-point primitive types. - /// - /// `U` must be a vector of integers with the same number of elements and element size as `T`. - /// - /// Returns `0` for false and `!0` for true. - #[rustc_nounwind] - pub fn simd_gt(x: T, y: T) -> U; - - /// Tests if `x` is greater than or equal to `y`, elementwise. - /// - /// `T` must be a vector of floating-point primitive types. - /// - /// `U` must be a vector of integers with the same number of elements and element size as `T`. - /// - /// Returns `0` for false and `!0` for true. - #[rustc_nounwind] - pub fn simd_ge(x: T, y: T) -> U; - - /// Shuffles two vectors by const indices. - /// - /// `T` must be a vector. - /// - /// `U` must be a **const** vector of `u32`s. This means it must either refer to a named - /// const or be given as an inline const expression (`const { ... }`). - /// - /// `V` must be a vector with the same element type as `T` and the same length as `U`. - /// - /// Returns a new vector such that element `i` is selected from `xy[idx[i]]`, where `xy` - /// is the concatenation of `x` and `y`. It is a compile-time error if `idx[i]` is out-of-bounds - /// of `xy`. - #[rustc_nounwind] - pub fn simd_shuffle(x: T, y: T, idx: U) -> V; - - /// Reads a vector of pointers. - /// - /// `T` must be a vector. - /// - /// `U` must be a vector of pointers to the element type of `T`, with the same length as `T`. - /// - /// `V` must be a vector of integers with the same length as `T` (but any element size). - /// - /// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, read the pointer. - /// Otherwise if the corresponding value in `mask` is `0`, return the corresponding value from - /// `val`. - /// - /// # Safety - /// Unmasked values in `T` must be readable as if by `::read` (e.g. aligned to the element - /// type). - /// - /// `mask` must only contain `0` or `!0` values. - #[rustc_nounwind] - pub fn simd_gather(val: T, ptr: U, mask: V) -> T; - - /// Writes to a vector of pointers. - /// - /// `T` must be a vector. - /// - /// `U` must be a vector of pointers to the element type of `T`, with the same length as `T`. - /// - /// `V` must be a vector of integers with the same length as `T` (but any element size). - /// - /// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, write the - /// corresponding value in `val` to the pointer. - /// Otherwise if the corresponding value in `mask` is `0`, do nothing. - /// - /// The stores happen in left-to-right order. - /// (This is relevant in case two of the stores overlap.) - /// - /// # Safety - /// Unmasked values in `T` must be writeable as if by `::write` (e.g. aligned to the element - /// type). - /// - /// `mask` must only contain `0` or `!0` values. - #[rustc_nounwind] - pub fn simd_scatter(val: T, ptr: U, mask: V); - - /// Reads a vector of pointers. - /// - /// `T` must be a vector. - /// - /// `U` must be a pointer to the element type of `T` - /// - /// `V` must be a vector of integers with the same length as `T` (but any element size). - /// - /// For each element, if the corresponding value in `mask` is `!0`, read the corresponding - /// pointer offset from `ptr`. - /// The first element is loaded from `ptr`, the second from `ptr.wrapping_offset(1)` and so on. - /// Otherwise if the corresponding value in `mask` is `0`, return the corresponding value from - /// `val`. - /// - /// # Safety - /// Unmasked values in `T` must be readable as if by `::read` (e.g. aligned to the element - /// type). - /// - /// `mask` must only contain `0` or `!0` values. - #[rustc_nounwind] - pub fn simd_masked_load(mask: V, ptr: U, val: T) -> T; - - /// Writes to a vector of pointers. - /// - /// `T` must be a vector. - /// - /// `U` must be a pointer to the element type of `T` - /// - /// `V` must be a vector of integers with the same length as `T` (but any element size). - /// - /// For each element, if the corresponding value in `mask` is `!0`, write the corresponding - /// value in `val` to the pointer offset from `ptr`. - /// The first element is written to `ptr`, the second to `ptr.wrapping_offset(1)` and so on. - /// Otherwise if the corresponding value in `mask` is `0`, do nothing. - /// - /// # Safety - /// Unmasked values in `T` must be writeable as if by `::write` (e.g. aligned to the element - /// type). - /// - /// `mask` must only contain `0` or `!0` values. - #[rustc_nounwind] - pub fn simd_masked_store(mask: V, ptr: U, val: T); - - /// Adds two simd vectors elementwise, with saturation. - /// - /// `T` must be a vector of integer primitive types. - #[rustc_nounwind] - pub fn simd_saturating_add(x: T, y: T) -> T; - - /// Subtracts two simd vectors elementwise, with saturation. - /// - /// `T` must be a vector of integer primitive types. - /// - /// Subtract `rhs` from `lhs`. - #[rustc_nounwind] - pub fn simd_saturating_sub(lhs: T, rhs: T) -> T; - - /// Adds elements within a vector from left to right. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// `U` must be the element type of `T`. - /// - /// Starting with the value `y`, add the elements of `x` and accumulate. - #[rustc_nounwind] - pub fn simd_reduce_add_ordered(x: T, y: U) -> U; - - /// Adds elements within a vector in arbitrary order. May also be re-associated with - /// unordered additions on the inputs/outputs. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// `U` must be the element type of `T`. - #[rustc_nounwind] - pub fn simd_reduce_add_unordered(x: T) -> U; - - /// Multiplies elements within a vector from left to right. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// `U` must be the element type of `T`. - /// - /// Starting with the value `y`, multiply the elements of `x` and accumulate. - #[rustc_nounwind] - pub fn simd_reduce_mul_ordered(x: T, y: U) -> U; - - /// Multiplies elements within a vector in arbitrary order. May also be re-associated with - /// unordered additions on the inputs/outputs. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// `U` must be the element type of `T`. - #[rustc_nounwind] - pub fn simd_reduce_mul_unordered(x: T) -> U; - - /// Checks if all mask values are true. - /// - /// `T` must be a vector of integer primitive types. - /// - /// # Safety - /// `x` must contain only `0` or `!0`. - #[rustc_nounwind] - pub fn simd_reduce_all(x: T) -> bool; - - /// Checks if any mask value is true. - /// - /// `T` must be a vector of integer primitive types. - /// - /// # Safety - /// `x` must contain only `0` or `!0`. - #[rustc_nounwind] - pub fn simd_reduce_any(x: T) -> bool; - - /// Returns the maximum element of a vector. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// `U` must be the element type of `T`. - /// - /// For floating-point values, uses IEEE-754 `maxNum`. - #[rustc_nounwind] - pub fn simd_reduce_max(x: T) -> U; - - /// Returns the minimum element of a vector. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// `U` must be the element type of `T`. - /// - /// For floating-point values, uses IEEE-754 `minNum`. - #[rustc_nounwind] - pub fn simd_reduce_min(x: T) -> U; - - /// Logical "ands" all elements together. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// `U` must be the element type of `T`. - #[rustc_nounwind] - pub fn simd_reduce_and(x: T) -> U; - - /// Logical "ors" all elements together. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// `U` must be the element type of `T`. - #[rustc_nounwind] - pub fn simd_reduce_or(x: T) -> U; - - /// Logical "exclusive ors" all elements together. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// `U` must be the element type of `T`. - #[rustc_nounwind] - pub fn simd_reduce_xor(x: T) -> U; - - /// Truncates an integer vector to a bitmask. - /// - /// `T` must be an integer vector. - /// - /// `U` must be either the smallest unsigned integer with at least as many bits as the length - /// of `T`, or the smallest array of `u8` with at least as many bits as the length of `T`. - /// - /// Each element is truncated to a single bit and packed into the result. - /// - /// No matter whether the output is an array or an unsigned integer, it is treated as a single - /// contiguous list of bits. The bitmask is always packed on the least-significant side of the - /// output, and padded with 0s in the most-significant bits. The order of the bits depends on - /// endianness: - /// - /// * On little endian, the least significant bit corresponds to the first vector element. - /// * On big endian, the least significant bit corresponds to the last vector element. - /// - /// For example, `[!0, 0, !0, !0]` packs to - /// - `0b1101u8` or `[0b1101]` on little endian, and - /// - `0b1011u8` or `[0b1011]` on big endian. - /// - /// To consider a larger example, - /// `[!0, 0, 0, 0, 0, 0, 0, 0, !0, !0, 0, 0, 0, 0, !0, 0]` packs to - /// - `0b0100001100000001u16` or `[0b00000001, 0b01000011]` on little endian, and - /// - `0b1000000011000010u16` or `[0b10000000, 0b11000010]` on big endian. - /// - /// And finally, a non-power-of-2 example with multiple bytes: - /// `[!0, !0, 0, !0, 0, 0, !0, 0, !0, 0]` packs to - /// - `0b0101001011u16` or `[0b01001011, 0b01]` on little endian, and - /// - `0b1101001010u16` or `[0b11, 0b01001010]` on big endian. - /// - /// # Safety - /// `x` must contain only `0` and `!0`. - #[rustc_nounwind] - pub fn simd_bitmask(x: T) -> U; - - /// Selects elements from a mask. - /// - /// `M` must be an integer vector. - /// - /// `T` must be a vector with the same number of elements as `M`. - /// - /// For each element, if the corresponding value in `mask` is `!0`, select the element from - /// `if_true`. If the corresponding value in `mask` is `0`, select the element from - /// `if_false`. - /// - /// # Safety - /// `mask` must only contain `0` and `!0`. - #[rustc_nounwind] - pub fn simd_select(mask: M, if_true: T, if_false: T) -> T; - - /// Selects elements from a bitmask. - /// - /// `M` must be an unsigned integer or array of `u8`, matching `simd_bitmask`. - /// - /// `T` must be a vector. - /// - /// For each element, if the bit in `mask` is `1`, select the element from - /// `if_true`. If the corresponding bit in `mask` is `0`, select the element from - /// `if_false`. - /// - /// The bitmask bit order matches `simd_bitmask`. - /// - /// # Safety - /// Padding bits must be all zero. - #[rustc_nounwind] - pub fn simd_select_bitmask(m: M, yes: T, no: T) -> T; - - /// Calculates the offset from a pointer vector elementwise, potentially - /// wrapping. - /// - /// `T` must be a vector of pointers. - /// - /// `U` must be a vector of `isize` or `usize` with the same number of elements as `T`. - /// - /// Operates as if by `::wrapping_offset`. - #[rustc_nounwind] - pub fn simd_arith_offset(ptr: T, offset: U) -> T; - - /// Casts a vector of pointers. - /// - /// `T` and `U` must be vectors of pointers with the same number of elements. - #[rustc_nounwind] - pub fn simd_cast_ptr(ptr: T) -> U; - - /// Exposes a vector of pointers as a vector of addresses. - /// - /// `T` must be a vector of pointers. - /// - /// `U` must be a vector of `usize` with the same length as `T`. - #[rustc_nounwind] - pub fn simd_expose_provenance(ptr: T) -> U; - - /// Creates a vector of pointers from a vector of addresses. - /// - /// `T` must be a vector of `usize`. - /// - /// `U` must be a vector of pointers, with the same length as `T`. - #[rustc_nounwind] - pub fn simd_with_exposed_provenance(addr: T) -> U; - - /// Swaps bytes of each element. - /// - /// `T` must be a vector of integers. - #[rustc_nounwind] - pub fn simd_bswap(x: T) -> T; - - /// Reverses bits of each element. - /// - /// `T` must be a vector of integers. - #[rustc_nounwind] - pub fn simd_bitreverse(x: T) -> T; - - /// Counts the leading zeros of each element. - /// - /// `T` must be a vector of integers. - #[rustc_nounwind] - pub fn simd_ctlz(x: T) -> T; - - /// Counts the number of ones in each element. - /// - /// `T` must be a vector of integers. - #[rustc_nounwind] - pub fn simd_ctpop(x: T) -> T; - - /// Counts the trailing zeros of each element. - /// - /// `T` must be a vector of integers. - #[rustc_nounwind] - pub fn simd_cttz(x: T) -> T; - - /// Rounds up each element to the next highest integer-valued float. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_ceil(x: T) -> T; - - /// Rounds down each element to the next lowest integer-valued float. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_floor(x: T) -> T; - - /// Rounds each element to the closest integer-valued float. - /// Ties are resolved by rounding away from 0. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_round(x: T) -> T; - - /// Returns the integer part of each element as an integer-valued float. - /// In other words, non-integer values are truncated towards zero. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_trunc(x: T) -> T; - - /// Takes the square root of each element. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_fsqrt(x: T) -> T; - - /// Computes `(x*y) + z` for each element, but without any intermediate rounding. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_fma(x: T, y: T, z: T) -> T; - - // Computes the sine of each element. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_fsin(a: T) -> T; - - // Computes the cosine of each element. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_fcos(a: T) -> T; - - // Computes the exponential function of each element. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_fexp(a: T) -> T; - - // Computes 2 raised to the power of each element. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_fexp2(a: T) -> T; - - // Computes the base 10 logarithm of each element. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_flog10(a: T) -> T; - - // Computes the base 2 logarithm of each element. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_flog2(a: T) -> T; - - // Computes the natural logarithm of each element. - /// - /// `T` must be a vector of floats. - #[rustc_nounwind] - pub fn simd_flog(a: T) -> T; -} +/// Inserts an element into a vector, returning the updated vector. +/// +/// `T` must be a vector with element type `U`. +/// +/// # Safety +/// +/// `idx` must be in-bounds of the vector. +#[rustc_intrinsic] +#[rustc_nounwind] +pub const unsafe fn simd_insert(x: T, idx: u32, val: U) -> T; + +/// Extracts an element from a vector. +/// +/// `T` must be a vector with element type `U`. +/// +/// # Safety +/// +/// `idx` must be in-bounds of the vector. +#[rustc_intrinsic] +#[rustc_nounwind] +pub const unsafe fn simd_extract(x: T, idx: u32) -> U; + +/// Adds two simd vectors elementwise. +/// +/// `T` must be a vector of integers or floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_add(x: T, y: T) -> T; + +/// Subtracts `rhs` from `lhs` elementwise. +/// +/// `T` must be a vector of integers or floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_sub(lhs: T, rhs: T) -> T; + +/// Multiplies two simd vectors elementwise. +/// +/// `T` must be a vector of integers or floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_mul(x: T, y: T) -> T; + +/// Divides `lhs` by `rhs` elementwise. +/// +/// `T` must be a vector of integers or floats. +/// +/// # Safety +/// For integers, `rhs` must not contain any zero elements. +/// Additionally for signed integers, `::MIN / -1` is undefined behavior. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_div(lhs: T, rhs: T) -> T; + +/// Returns remainder of two vectors elementwise. +/// +/// `T` must be a vector of integers or floats. +/// +/// # Safety +/// For integers, `rhs` must not contain any zero elements. +/// Additionally for signed integers, `::MIN / -1` is undefined behavior. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_rem(lhs: T, rhs: T) -> T; + +/// Shifts vector left elementwise, with UB on overflow. +/// +/// Shifts `lhs` left by `rhs`, shifting in sign bits for signed types. +/// +/// `T` must be a vector of integers. +/// +/// # Safety +/// +/// Each element of `rhs` must be less than `::BITS`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_shl(lhs: T, rhs: T) -> T; + +/// Shifts vector right elementwise, with UB on overflow. +/// +/// `T` must be a vector of integers. +/// +/// Shifts `lhs` right by `rhs`, shifting in sign bits for signed types. +/// +/// # Safety +/// +/// Each element of `rhs` must be less than `::BITS`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_shr(lhs: T, rhs: T) -> T; + +/// "Ands" vectors elementwise. +/// +/// `T` must be a vector of integers. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_and(x: T, y: T) -> T; + +/// "Ors" vectors elementwise. +/// +/// `T` must be a vector of integers. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_or(x: T, y: T) -> T; + +/// "Exclusive ors" vectors elementwise. +/// +/// `T` must be a vector of integers. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_xor(x: T, y: T) -> T; + +/// Numerically casts a vector, elementwise. +/// +/// `T` and `U` must be vectors of integers or floats, and must have the same length. +/// +/// When casting floats to integers, the result is truncated. Out-of-bounds result lead to UB. +/// When casting integers to floats, the result is rounded. +/// Otherwise, truncates or extends the value, maintaining the sign for signed integers. +/// +/// # Safety +/// Casting from integer types is always safe. +/// Casting between two float types is also always safe. +/// +/// Casting floats to integers truncates, following the same rules as `to_int_unchecked`. +/// Specifically, each element must: +/// * Not be `NaN` +/// * Not be infinite +/// * Be representable in the return type, after truncating off its fractional part +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_cast(x: T) -> U; + +/// Numerically casts a vector, elementwise. +/// +/// `T` and `U` be a vectors of integers or floats, and must have the same length. +/// +/// Like `simd_cast`, but saturates float-to-integer conversions (NaN becomes 0). +/// This matches regular `as` and is always safe. +/// +/// When casting floats to integers, the result is truncated. +/// When casting integers to floats, the result is rounded. +/// Otherwise, truncates or extends the value, maintaining the sign for signed integers. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_as(x: T) -> U; + +/// Negates a vector elementwise. +/// +/// `T` must be a vector of integers or floats. +/// +/// Rust panics for `-::Min` due to overflow, but it is not UB with this intrinsic. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_neg(x: T) -> T; + +/// Returns absolute value of a vector, elementwise. +/// +/// `T` must be a vector of floating-point primitive types. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_fabs(x: T) -> T; + +/// Returns the minimum of two vectors, elementwise. +/// +/// `T` must be a vector of floating-point primitive types. +/// +/// Follows IEEE-754 `minNum` semantics. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_fmin(x: T, y: T) -> T; + +/// Returns the maximum of two vectors, elementwise. +/// +/// `T` must be a vector of floating-point primitive types. +/// +/// Follows IEEE-754 `maxNum` semantics. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_fmax(x: T, y: T) -> T; + +/// Tests elementwise equality of two vectors. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be a vector of integers with the same number of elements and element size as `T`. +/// +/// Returns `0` for false and `!0` for true. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_eq(x: T, y: T) -> U; + +/// Tests elementwise inequality equality of two vectors. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be a vector of integers with the same number of elements and element size as `T`. +/// +/// Returns `0` for false and `!0` for true. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_ne(x: T, y: T) -> U; + +/// Tests if `x` is less than `y`, elementwise. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be a vector of integers with the same number of elements and element size as `T`. +/// +/// Returns `0` for false and `!0` for true. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_lt(x: T, y: T) -> U; + +/// Tests if `x` is less than or equal to `y`, elementwise. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be a vector of integers with the same number of elements and element size as `T`. +/// +/// Returns `0` for false and `!0` for true. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_le(x: T, y: T) -> U; + +/// Tests if `x` is greater than `y`, elementwise. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be a vector of integers with the same number of elements and element size as `T`. +/// +/// Returns `0` for false and `!0` for true. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_gt(x: T, y: T) -> U; + +/// Tests if `x` is greater than or equal to `y`, elementwise. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be a vector of integers with the same number of elements and element size as `T`. +/// +/// Returns `0` for false and `!0` for true. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_ge(x: T, y: T) -> U; + +/// Shuffles two vectors by const indices. +/// +/// `T` must be a vector. +/// +/// `U` must be a **const** vector of `u32`s. This means it must either refer to a named +/// const or be given as an inline const expression (`const { ... }`). +/// +/// `V` must be a vector with the same element type as `T` and the same length as `U`. +/// +/// Returns a new vector such that element `i` is selected from `xy[idx[i]]`, where `xy` +/// is the concatenation of `x` and `y`. It is a compile-time error if `idx[i]` is out-of-bounds +/// of `xy`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_shuffle(x: T, y: T, idx: U) -> V; + +/// Reads a vector of pointers. +/// +/// `T` must be a vector. +/// +/// `U` must be a vector of pointers to the element type of `T`, with the same length as `T`. +/// +/// `V` must be a vector of signed integers with the same length as `T` (but any element size). +/// +/// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, read the pointer. +/// Otherwise if the corresponding value in `mask` is `0`, return the corresponding value from +/// `val`. +/// +/// # Safety +/// Unmasked values in `T` must be readable as if by `::read` (e.g. aligned to the element +/// type). +/// +/// `mask` must only contain `0` or `!0` values. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_gather(val: T, ptr: U, mask: V) -> T; + +/// Writes to a vector of pointers. +/// +/// `T` must be a vector. +/// +/// `U` must be a vector of pointers to the element type of `T`, with the same length as `T`. +/// +/// `V` must be a vector of signed integers with the same length as `T` (but any element size). +/// +/// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, write the +/// corresponding value in `val` to the pointer. +/// Otherwise if the corresponding value in `mask` is `0`, do nothing. +/// +/// The stores happen in left-to-right order. +/// (This is relevant in case two of the stores overlap.) +/// +/// # Safety +/// Unmasked values in `T` must be writeable as if by `::write` (e.g. aligned to the element +/// type). +/// +/// `mask` must only contain `0` or `!0` values. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_scatter(val: T, ptr: U, mask: V); + +/// Reads a vector of pointers. +/// +/// `T` must be a vector. +/// +/// `U` must be a pointer to the element type of `T` +/// +/// `V` must be a vector of signed integers with the same length as `T` (but any element size). +/// +/// For each element, if the corresponding value in `mask` is `!0`, read the corresponding +/// pointer offset from `ptr`. +/// The first element is loaded from `ptr`, the second from `ptr.wrapping_offset(1)` and so on. +/// Otherwise if the corresponding value in `mask` is `0`, return the corresponding value from +/// `val`. +/// +/// # Safety +/// Unmasked values in `T` must be readable as if by `::read` (e.g. aligned to the element +/// type). +/// +/// `mask` must only contain `0` or `!0` values. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_masked_load(mask: V, ptr: U, val: T) -> T; + +/// Writes to a vector of pointers. +/// +/// `T` must be a vector. +/// +/// `U` must be a pointer to the element type of `T` +/// +/// `V` must be a vector of signed integers with the same length as `T` (but any element size). +/// +/// For each element, if the corresponding value in `mask` is `!0`, write the corresponding +/// value in `val` to the pointer offset from `ptr`. +/// The first element is written to `ptr`, the second to `ptr.wrapping_offset(1)` and so on. +/// Otherwise if the corresponding value in `mask` is `0`, do nothing. +/// +/// # Safety +/// Unmasked values in `T` must be writeable as if by `::write` (e.g. aligned to the element +/// type). +/// +/// `mask` must only contain `0` or `!0` values. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_masked_store(mask: V, ptr: U, val: T); + +/// Adds two simd vectors elementwise, with saturation. +/// +/// `T` must be a vector of integer primitive types. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_saturating_add(x: T, y: T) -> T; + +/// Subtracts two simd vectors elementwise, with saturation. +/// +/// `T` must be a vector of integer primitive types. +/// +/// Subtract `rhs` from `lhs`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_saturating_sub(lhs: T, rhs: T) -> T; + +/// Adds elements within a vector from left to right. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be the element type of `T`. +/// +/// Starting with the value `y`, add the elements of `x` and accumulate. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_reduce_add_ordered(x: T, y: U) -> U; + +/// Adds elements within a vector in arbitrary order. May also be re-associated with +/// unordered additions on the inputs/outputs. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be the element type of `T`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_reduce_add_unordered(x: T) -> U; + +/// Multiplies elements within a vector from left to right. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be the element type of `T`. +/// +/// Starting with the value `y`, multiply the elements of `x` and accumulate. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_reduce_mul_ordered(x: T, y: U) -> U; + +/// Multiplies elements within a vector in arbitrary order. May also be re-associated with +/// unordered additions on the inputs/outputs. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be the element type of `T`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_reduce_mul_unordered(x: T) -> U; + +/// Checks if all mask values are true. +/// +/// `T` must be a vector of integer primitive types. +/// +/// # Safety +/// `x` must contain only `0` or `!0`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_reduce_all(x: T) -> bool; + +/// Checks if any mask value is true. +/// +/// `T` must be a vector of integer primitive types. +/// +/// # Safety +/// `x` must contain only `0` or `!0`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_reduce_any(x: T) -> bool; + +/// Returns the maximum element of a vector. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be the element type of `T`. +/// +/// For floating-point values, uses IEEE-754 `maxNum`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_reduce_max(x: T) -> U; + +/// Returns the minimum element of a vector. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be the element type of `T`. +/// +/// For floating-point values, uses IEEE-754 `minNum`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_reduce_min(x: T) -> U; + +/// Logical "ands" all elements together. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be the element type of `T`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_reduce_and(x: T) -> U; + +/// Logical "ors" all elements together. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be the element type of `T`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_reduce_or(x: T) -> U; + +/// Logical "exclusive ors" all elements together. +/// +/// `T` must be a vector of integers or floats. +/// +/// `U` must be the element type of `T`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_reduce_xor(x: T) -> U; + +/// Truncates an integer vector to a bitmask. +/// +/// `T` must be an integer vector. +/// +/// `U` must be either the smallest unsigned integer with at least as many bits as the length +/// of `T`, or the smallest array of `u8` with at least as many bits as the length of `T`. +/// +/// Each element is truncated to a single bit and packed into the result. +/// +/// No matter whether the output is an array or an unsigned integer, it is treated as a single +/// contiguous list of bits. The bitmask is always packed on the least-significant side of the +/// output, and padded with 0s in the most-significant bits. The order of the bits depends on +/// endianness: +/// +/// * On little endian, the least significant bit corresponds to the first vector element. +/// * On big endian, the least significant bit corresponds to the last vector element. +/// +/// For example, `[!0, 0, !0, !0]` packs to +/// - `0b1101u8` or `[0b1101]` on little endian, and +/// - `0b1011u8` or `[0b1011]` on big endian. +/// +/// To consider a larger example, +/// `[!0, 0, 0, 0, 0, 0, 0, 0, !0, !0, 0, 0, 0, 0, !0, 0]` packs to +/// - `0b0100001100000001u16` or `[0b00000001, 0b01000011]` on little endian, and +/// - `0b1000000011000010u16` or `[0b10000000, 0b11000010]` on big endian. +/// +/// And finally, a non-power-of-2 example with multiple bytes: +/// `[!0, !0, 0, !0, 0, 0, !0, 0, !0, 0]` packs to +/// - `0b0101001011u16` or `[0b01001011, 0b01]` on little endian, and +/// - `0b1101001010u16` or `[0b11, 0b01001010]` on big endian. +/// +/// # Safety +/// `x` must contain only `0` and `!0`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_bitmask(x: T) -> U; + +/// Selects elements from a mask. +/// +/// `T` must be a vector. +/// +/// `M` must be a signed integer vector with the same length as `T` (but any element size). +/// +/// For each element, if the corresponding value in `mask` is `!0`, select the element from +/// `if_true`. If the corresponding value in `mask` is `0`, select the element from +/// `if_false`. +/// +/// # Safety +/// `mask` must only contain `0` and `!0`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_select(mask: M, if_true: T, if_false: T) -> T; + +/// Selects elements from a bitmask. +/// +/// `M` must be an unsigned integer or array of `u8`, matching `simd_bitmask`. +/// +/// `T` must be a vector. +/// +/// For each element, if the bit in `mask` is `1`, select the element from +/// `if_true`. If the corresponding bit in `mask` is `0`, select the element from +/// `if_false`. +/// +/// The bitmask bit order matches `simd_bitmask`. +/// +/// # Safety +/// Padding bits must be all zero. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_select_bitmask(m: M, yes: T, no: T) -> T; + +/// Calculates the offset from a pointer vector elementwise, potentially +/// wrapping. +/// +/// `T` must be a vector of pointers. +/// +/// `U` must be a vector of `isize` or `usize` with the same number of elements as `T`. +/// +/// Operates as if by `::wrapping_offset`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_arith_offset(ptr: T, offset: U) -> T; + +/// Casts a vector of pointers. +/// +/// `T` and `U` must be vectors of pointers with the same number of elements. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_cast_ptr(ptr: T) -> U; + +/// Exposes a vector of pointers as a vector of addresses. +/// +/// `T` must be a vector of pointers. +/// +/// `U` must be a vector of `usize` with the same length as `T`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_expose_provenance(ptr: T) -> U; + +/// Creates a vector of pointers from a vector of addresses. +/// +/// `T` must be a vector of `usize`. +/// +/// `U` must be a vector of pointers, with the same length as `T`. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_with_exposed_provenance(addr: T) -> U; + +/// Swaps bytes of each element. +/// +/// `T` must be a vector of integers. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_bswap(x: T) -> T; + +/// Reverses bits of each element. +/// +/// `T` must be a vector of integers. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_bitreverse(x: T) -> T; + +/// Counts the leading zeros of each element. +/// +/// `T` must be a vector of integers. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_ctlz(x: T) -> T; + +/// Counts the number of ones in each element. +/// +/// `T` must be a vector of integers. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_ctpop(x: T) -> T; + +/// Counts the trailing zeros of each element. +/// +/// `T` must be a vector of integers. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_cttz(x: T) -> T; + +/// Rounds up each element to the next highest integer-valued float. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_ceil(x: T) -> T; + +/// Rounds down each element to the next lowest integer-valued float. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_floor(x: T) -> T; + +/// Rounds each element to the closest integer-valued float. +/// Ties are resolved by rounding away from 0. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_round(x: T) -> T; + +/// Returns the integer part of each element as an integer-valued float. +/// In other words, non-integer values are truncated towards zero. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_trunc(x: T) -> T; + +/// Takes the square root of each element. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_fsqrt(x: T) -> T; + +/// Computes `(x*y) + z` for each element, but without any intermediate rounding. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_fma(x: T, y: T, z: T) -> T; + +/// Computes `(x*y) + z` for each element, non-deterministically executing either +/// a fused multiply-add or two operations with rounding of the intermediate result. +/// +/// The operation is fused if the code generator determines that target instruction +/// set has support for a fused operation, and that the fused operation is more efficient +/// than the equivalent, separate pair of mul and add instructions. It is unspecified +/// whether or not a fused operation is selected, and that may depend on optimization +/// level and context, for example. It may even be the case that some SIMD lanes get fused +/// and others do not. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_relaxed_fma(x: T, y: T, z: T) -> T; + +// Computes the sine of each element. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_fsin(a: T) -> T; + +// Computes the cosine of each element. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_fcos(a: T) -> T; + +// Computes the exponential function of each element. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_fexp(a: T) -> T; + +// Computes 2 raised to the power of each element. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_fexp2(a: T) -> T; + +// Computes the base 10 logarithm of each element. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_flog10(a: T) -> T; + +// Computes the base 2 logarithm of each element. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_flog2(a: T) -> T; + +// Computes the natural logarithm of each element. +/// +/// `T` must be a vector of floats. +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn simd_flog(a: T) -> T; diff --git a/core/src/io/borrowed_buf.rs b/core/src/io/borrowed_buf.rs index 4227e503ba7ba..f86abf7f1e91c 100644 --- a/core/src/io/borrowed_buf.rs +++ b/core/src/io/borrowed_buf.rs @@ -94,7 +94,7 @@ impl<'data> BorrowedBuf<'data> { // SAFETY: We only slice the filled part of the buffer, which is always valid unsafe { let buf = self.buf.get_unchecked(..self.filled); - MaybeUninit::slice_assume_init_ref(buf) + buf.assume_init_ref() } } @@ -104,7 +104,7 @@ impl<'data> BorrowedBuf<'data> { // SAFETY: We only slice the filled part of the buffer, which is always valid unsafe { let buf = self.buf.get_unchecked_mut(..self.filled); - MaybeUninit::slice_assume_init_mut(buf) + buf.assume_init_mut() } } @@ -114,7 +114,7 @@ impl<'data> BorrowedBuf<'data> { // SAFETY: We only slice the filled part of the buffer, which is always valid unsafe { let buf = self.buf.get_unchecked(..self.filled); - MaybeUninit::slice_assume_init_ref(buf) + buf.assume_init_ref() } } @@ -124,7 +124,7 @@ impl<'data> BorrowedBuf<'data> { // SAFETY: We only slice the filled part of the buffer, which is always valid unsafe { let buf = self.buf.get_unchecked_mut(..self.filled); - MaybeUninit::slice_assume_init_mut(buf) + buf.assume_init_mut() } } @@ -233,7 +233,7 @@ impl<'a> BorrowedCursor<'a> { // SAFETY: We only slice the initialized part of the buffer, which is always valid unsafe { let buf = self.buf.buf.get_unchecked(self.buf.filled..self.buf.init); - MaybeUninit::slice_assume_init_ref(buf) + buf.assume_init_ref() } } @@ -243,7 +243,7 @@ impl<'a> BorrowedCursor<'a> { // SAFETY: We only slice the initialized part of the buffer, which is always valid unsafe { let buf = self.buf.buf.get_unchecked_mut(self.buf.filled..self.buf.init); - MaybeUninit::slice_assume_init_mut(buf) + buf.assume_init_mut() } } @@ -344,7 +344,7 @@ impl<'a> BorrowedCursor<'a> { // SAFETY: we do not de-initialize any of the elements of the slice unsafe { - MaybeUninit::copy_from_slice(&mut self.as_mut()[..buf.len()], buf); + self.as_mut()[..buf.len()].write_copy_of_slice(buf); } // SAFETY: We just added the entire contents of buf to the filled section. diff --git a/core/src/iter/adapters/filter_map.rs b/core/src/iter/adapters/filter_map.rs index cc64ceb13f766..24ec6b1741ce1 100644 --- a/core/src/iter/adapters/filter_map.rs +++ b/core/src/iter/adapters/filter_map.rs @@ -81,9 +81,7 @@ where if const { crate::mem::needs_drop::() } { // SAFETY: self.initialized is always <= N, which also is the length of the array. unsafe { - core::ptr::drop_in_place(MaybeUninit::slice_assume_init_mut( - self.array.get_unchecked_mut(..self.initialized), - )); + self.array.get_unchecked_mut(..self.initialized).assume_init_drop(); } } } diff --git a/core/src/iter/adapters/flatten.rs b/core/src/iter/adapters/flatten.rs index 0023b46031f12..9b9353b800a98 100644 --- a/core/src/iter/adapters/flatten.rs +++ b/core/src/iter/adapters/flatten.rs @@ -1,7 +1,7 @@ use crate::iter::adapters::SourceIter; use crate::iter::{ - Cloned, Copied, Empty, Filter, FilterMap, Fuse, FusedIterator, InPlaceIterable, Map, Once, - OnceWith, TrustedFused, TrustedLen, + Cloned, Copied, Empty, Filter, FilterMap, Fuse, FusedIterator, Map, Once, OnceWith, + TrustedFused, TrustedLen, }; use crate::num::NonZero; use crate::ops::{ControlFlow, Try}; @@ -157,21 +157,6 @@ where { } -#[unstable(issue = "none", feature = "inplace_iteration")] -unsafe impl InPlaceIterable for FlatMap -where - I: InPlaceIterable, - U: BoundedSize + IntoIterator, -{ - const EXPAND_BY: Option> = const { - match (I::EXPAND_BY, U::UPPER_BOUND) { - (Some(m), Some(n)) => m.checked_mul(n), - _ => None, - } - }; - const MERGE_BY: Option> = I::MERGE_BY; -} - #[unstable(issue = "none", feature = "inplace_iteration")] unsafe impl SourceIter for FlatMap where @@ -386,21 +371,6 @@ where { } -#[unstable(issue = "none", feature = "inplace_iteration")] -unsafe impl InPlaceIterable for Flatten -where - I: InPlaceIterable + Iterator, - ::Item: IntoIterator + BoundedSize, -{ - const EXPAND_BY: Option> = const { - match (I::EXPAND_BY, I::Item::UPPER_BOUND) { - (Some(m), Some(n)) => m.checked_mul(n), - _ => None, - } - }; - const MERGE_BY: Option> = I::MERGE_BY; -} - #[unstable(issue = "none", feature = "inplace_iteration")] unsafe impl SourceIter for Flatten where diff --git a/core/src/iter/adapters/map_windows.rs b/core/src/iter/adapters/map_windows.rs index cb13023c85c41..a9c07fee2a91e 100644 --- a/core/src/iter/adapters/map_windows.rs +++ b/core/src/iter/adapters/map_windows.rs @@ -1,5 +1,5 @@ use crate::iter::FusedIterator; -use crate::mem::{self, MaybeUninit}; +use crate::mem::MaybeUninit; use crate::{fmt, ptr}; /// An iterator over the mapped windows of another iterator. @@ -50,7 +50,7 @@ impl MapWindows { assert!(N != 0, "array in `Iterator::map_windows` must contain more than 0 elements"); // Only ZST arrays' length can be so large. - if mem::size_of::() == 0 { + if size_of::() == 0 { assert!( N.checked_mul(2).is_some(), "array size of `Iterator::map_windows` is too large" diff --git a/core/src/iter/adapters/zip.rs b/core/src/iter/adapters/zip.rs index 0c38811590877..8090c98e7edb7 100644 --- a/core/src/iter/adapters/zip.rs +++ b/core/src/iter/adapters/zip.rs @@ -556,13 +556,13 @@ impl Option`. +/// Creates an iterator with the provided closure +/// `F: FnMut() -> Option` as its [`next`](Iterator::next) method. +/// +/// The iterator will yield the `T`s returned from the closure. /// /// This allows creating a custom iterator with any behavior /// without using the more verbose syntax of creating a dedicated type diff --git a/core/src/iter/sources/once.rs b/core/src/iter/sources/once.rs index 21be4377da1ca..c4a9860bdd76c 100644 --- a/core/src/iter/sources/once.rs +++ b/core/src/iter/sources/once.rs @@ -34,7 +34,7 @@ use crate::iter::{FusedIterator, TrustedLen}; /// use std::fs; /// use std::path::PathBuf; /// -/// let dirs = fs::read_dir(".foo").unwrap(); +/// let dirs = fs::read_dir(".foo")?; /// /// // we need to convert from an iterator of DirEntry-s to an iterator of /// // PathBufs, so we use map @@ -50,6 +50,7 @@ use crate::iter::{FusedIterator, TrustedLen}; /// for f in files { /// println!("{f:?}"); /// } +/// # std::io::Result::Ok(()) /// ``` #[stable(feature = "iter_once", since = "1.2.0")] pub fn once(value: T) -> Once { diff --git a/core/src/iter/sources/once_with.rs b/core/src/iter/sources/once_with.rs index 8b31ab2ff90c0..c9698b4fd431b 100644 --- a/core/src/iter/sources/once_with.rs +++ b/core/src/iter/sources/once_with.rs @@ -58,8 +58,8 @@ use crate::iter::{FusedIterator, TrustedLen}; /// ``` #[inline] #[stable(feature = "iter_once_with", since = "1.43.0")] -pub fn once_with A>(gen: F) -> OnceWith { - OnceWith { gen: Some(gen) } +pub fn once_with A>(make: F) -> OnceWith { + OnceWith { make: Some(make) } } /// An iterator that yields a single element of type `A` by @@ -70,13 +70,13 @@ pub fn once_with A>(gen: F) -> OnceWith { #[derive(Clone)] #[stable(feature = "iter_once_with", since = "1.43.0")] pub struct OnceWith { - gen: Option, + make: Option, } #[stable(feature = "iter_once_with_debug", since = "1.68.0")] impl fmt::Debug for OnceWith { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - if self.gen.is_some() { + if self.make.is_some() { f.write_str("OnceWith(Some(_))") } else { f.write_str("OnceWith(None)") @@ -90,13 +90,13 @@ impl A> Iterator for OnceWith { #[inline] fn next(&mut self) -> Option { - let f = self.gen.take()?; + let f = self.make.take()?; Some(f()) } #[inline] fn size_hint(&self) -> (usize, Option) { - self.gen.iter().size_hint() + self.make.iter().size_hint() } } @@ -110,7 +110,7 @@ impl A> DoubleEndedIterator for OnceWith { #[stable(feature = "iter_once_with", since = "1.43.0")] impl A> ExactSizeIterator for OnceWith { fn len(&self) -> usize { - self.gen.iter().len() + self.make.iter().len() } } diff --git a/core/src/iter/sources/successors.rs b/core/src/iter/sources/successors.rs index 36bc4035039e6..5466131903f85 100644 --- a/core/src/iter/sources/successors.rs +++ b/core/src/iter/sources/successors.rs @@ -1,10 +1,16 @@ use crate::fmt; use crate::iter::FusedIterator; -/// Creates a new iterator where each successive item is computed based on the preceding one. +/// Creates an iterator which, starting from an initial item, +/// computes each successive item from the preceding one. /// -/// The iterator starts with the given first item (if any) -/// and calls the given `FnMut(&T) -> Option` closure to compute each item’s successor. +/// This iterator stores an optional item (`Option`) and a successor closure (`impl FnMut(&T) -> Option`). +/// Its `next` method returns the stored optional item and +/// if it is `Some(val)` calls the stored closure on `&val` to compute and store its successor. +/// The iterator will apply the closure successively to the stored option's value until the option is `None`. +/// This also means that once the stored option is `None` it will remain `None`, +/// as the closure will not be called again, so the created iterator is a [`FusedIterator`]. +/// The iterator's items will be the initial item and all of its successors as calculated by the successor closure. /// /// ``` /// use std::iter::successors; @@ -23,7 +29,8 @@ where Successors { next: first, succ } } -/// A new iterator where each successive item is computed based on the preceding one. +/// An iterator which, starting from an initial item, +/// computes each successive item from the preceding one. /// /// This `struct` is created by the [`iter::successors()`] function. /// See its documentation for more. diff --git a/core/src/iter/traits/collect.rs b/core/src/iter/traits/collect.rs index 2cf2ea58fd4ee..97bb21c8a36e8 100644 --- a/core/src/iter/traits/collect.rs +++ b/core/src/iter/traits/collect.rs @@ -152,39 +152,6 @@ pub trait FromIterator: Sized { fn from_iter>(iter: T) -> Self; } -/// This implementation turns an iterator of tuples into a tuple of types which implement -/// [`Default`] and [`Extend`]. -/// -/// This is similar to [`Iterator::unzip`], but is also composable with other [`FromIterator`] -/// implementations: -/// -/// ```rust -/// # fn main() -> Result<(), core::num::ParseIntError> { -/// let string = "1,2,123,4"; -/// -/// let (numbers, lengths): (Vec<_>, Vec<_>) = string -/// .split(',') -/// .map(|s| s.parse().map(|n: u32| (n, s.len()))) -/// .collect::>()?; -/// -/// assert_eq!(numbers, [1, 2, 123, 4]); -/// assert_eq!(lengths, [1, 1, 3, 1]); -/// # Ok(()) } -/// ``` -#[stable(feature = "from_iterator_for_tuple", since = "1.79.0")] -impl FromIterator<(AE, BE)> for (A, B) -where - A: Default + Extend, - B: Default + Extend, -{ - fn from_iter>(iter: I) -> Self { - let mut res = <(A, B)>::default(); - res.extend(iter); - - res - } -} - /// Conversion into an [`Iterator`]. /// /// By implementing `IntoIterator` for a type, you define how it will be @@ -492,131 +459,234 @@ impl Extend<()> for () { fn extend_one(&mut self, _item: ()) {} } -#[stable(feature = "extend_for_tuple", since = "1.56.0")] -impl Extend<(A, B)> for (ExtendA, ExtendB) -where - ExtendA: Extend, - ExtendB: Extend, -{ - /// Allows to `extend` a tuple of collections that also implement `Extend`. - /// - /// See also: [`Iterator::unzip`] - /// - /// # Examples - /// ``` - /// let mut tuple = (vec![0], vec![1]); - /// tuple.extend([(2, 3), (4, 5), (6, 7)]); - /// assert_eq!(tuple.0, [0, 2, 4, 6]); - /// assert_eq!(tuple.1, [1, 3, 5, 7]); - /// - /// // also allows for arbitrarily nested tuples as elements - /// let mut nested_tuple = (vec![1], (vec![2], vec![3])); - /// nested_tuple.extend([(4, (5, 6)), (7, (8, 9))]); - /// - /// let (a, (b, c)) = nested_tuple; - /// assert_eq!(a, [1, 4, 7]); - /// assert_eq!(b, [2, 5, 8]); - /// assert_eq!(c, [3, 6, 9]); - /// ``` - fn extend>(&mut self, into_iter: T) { - let (a, b) = self; - let iter = into_iter.into_iter(); - SpecTupleExtend::extend(iter, a, b); - } +macro_rules! spec_tuple_impl { + ( + ( + $ty_name:ident, $var_name:ident, $extend_ty_name: ident, + $trait_name:ident, $default_fn_name:ident, $cnt:tt + ), + ) => { + spec_tuple_impl!( + $trait_name, + $default_fn_name, + #[doc(fake_variadic)] + #[doc = "This trait is implemented for tuples up to twelve items long. The `impl`s for \ + 1- and 3- through 12-ary tuples were stabilized after 2-tuples, in \ + 1.85.0."] + => ($ty_name, $var_name, $extend_ty_name, $cnt), + ); + }; + ( + ( + $ty_name:ident, $var_name:ident, $extend_ty_name: ident, + $trait_name:ident, $default_fn_name:ident, $cnt:tt + ), + $( + ( + $ty_names:ident, $var_names:ident, $extend_ty_names:ident, + $trait_names:ident, $default_fn_names:ident, $cnts:tt + ), + )* + ) => { + spec_tuple_impl!( + $( + ( + $ty_names, $var_names, $extend_ty_names, + $trait_names, $default_fn_names, $cnts + ), + )* + ); + spec_tuple_impl!( + $trait_name, + $default_fn_name, + #[doc(hidden)] + => ( + $ty_name, $var_name, $extend_ty_name, $cnt + ), + $( + ( + $ty_names, $var_names, $extend_ty_names, $cnts + ), + )* + ); + }; + ( + $trait_name:ident, $default_fn_name:ident, #[$meta:meta] + $(#[$doctext:meta])? => $( + ( + $ty_names:ident, $var_names:ident, $extend_ty_names:ident, $cnts:tt + ), + )* + ) => { + #[$meta] + $(#[$doctext])? + #[stable(feature = "extend_for_tuple", since = "1.56.0")] + impl<$($ty_names,)* $($extend_ty_names,)*> Extend<($($ty_names,)*)> for ($($extend_ty_names,)*) + where + $($extend_ty_names: Extend<$ty_names>,)* + { + /// Allows to `extend` a tuple of collections that also implement `Extend`. + /// + /// See also: [`Iterator::unzip`] + /// + /// # Examples + /// ``` + /// // Example given for a 2-tuple, but 1- through 12-tuples are supported + /// let mut tuple = (vec![0], vec![1]); + /// tuple.extend([(2, 3), (4, 5), (6, 7)]); + /// assert_eq!(tuple.0, [0, 2, 4, 6]); + /// assert_eq!(tuple.1, [1, 3, 5, 7]); + /// + /// // also allows for arbitrarily nested tuples as elements + /// let mut nested_tuple = (vec![1], (vec![2], vec![3])); + /// nested_tuple.extend([(4, (5, 6)), (7, (8, 9))]); + /// + /// let (a, (b, c)) = nested_tuple; + /// assert_eq!(a, [1, 4, 7]); + /// assert_eq!(b, [2, 5, 8]); + /// assert_eq!(c, [3, 6, 9]); + /// ``` + fn extend>(&mut self, into_iter: T) { + let ($($var_names,)*) = self; + let iter = into_iter.into_iter(); + $trait_name::extend(iter, $($var_names,)*); + } - fn extend_one(&mut self, item: (A, B)) { - self.0.extend_one(item.0); - self.1.extend_one(item.1); - } + fn extend_one(&mut self, item: ($($ty_names,)*)) { + $(self.$cnts.extend_one(item.$cnts);)* + } - fn extend_reserve(&mut self, additional: usize) { - self.0.extend_reserve(additional); - self.1.extend_reserve(additional); - } + fn extend_reserve(&mut self, additional: usize) { + $(self.$cnts.extend_reserve(additional);)* + } - unsafe fn extend_one_unchecked(&mut self, item: (A, B)) { - // SAFETY: Those are our safety preconditions, and we correctly forward `extend_reserve`. - unsafe { - self.0.extend_one_unchecked(item.0); - self.1.extend_one_unchecked(item.1); + unsafe fn extend_one_unchecked(&mut self, item: ($($ty_names,)*)) { + // SAFETY: Those are our safety preconditions, and we correctly forward `extend_reserve`. + unsafe { + $(self.$cnts.extend_one_unchecked(item.$cnts);)* + } + } } - } -} -fn default_extend_tuple( - iter: impl Iterator, - a: &mut ExtendA, - b: &mut ExtendB, -) where - ExtendA: Extend, - ExtendB: Extend, -{ - fn extend<'a, A, B>( - a: &'a mut impl Extend, - b: &'a mut impl Extend, - ) -> impl FnMut((), (A, B)) + 'a { - move |(), (t, u)| { - a.extend_one(t); - b.extend_one(u); + trait $trait_name<$($ty_names),*> { + fn extend(self, $($var_names: &mut $ty_names,)*); } - } - let (lower_bound, _) = iter.size_hint(); - if lower_bound > 0 { - a.extend_reserve(lower_bound); - b.extend_reserve(lower_bound); - } - - iter.fold((), extend(a, b)); -} + fn $default_fn_name<$($ty_names,)* $($extend_ty_names,)*>( + iter: impl Iterator, + $($var_names: &mut $extend_ty_names,)* + ) where + $($extend_ty_names: Extend<$ty_names>,)* + { + fn extend<'a, $($ty_names,)*>( + $($var_names: &'a mut impl Extend<$ty_names>,)* + ) -> impl FnMut((), ($($ty_names,)*)) + 'a { + #[allow(non_snake_case)] + move |(), ($($extend_ty_names,)*)| { + $($var_names.extend_one($extend_ty_names);)* + } + } -trait SpecTupleExtend { - fn extend(self, a: &mut A, b: &mut B); -} + let (lower_bound, _) = iter.size_hint(); + if lower_bound > 0 { + $($var_names.extend_reserve(lower_bound);)* + } -impl SpecTupleExtend for Iter -where - ExtendA: Extend, - ExtendB: Extend, - Iter: Iterator, -{ - default fn extend(self, a: &mut ExtendA, b: &mut ExtendB) { - default_extend_tuple(self, a, b); - } -} + iter.fold((), extend($($var_names,)*)); + } -impl SpecTupleExtend for Iter -where - ExtendA: Extend, - ExtendB: Extend, - Iter: TrustedLen, -{ - fn extend(self, a: &mut ExtendA, b: &mut ExtendB) { - fn extend<'a, A, B>( - a: &'a mut impl Extend, - b: &'a mut impl Extend, - ) -> impl FnMut((), (A, B)) + 'a { - // SAFETY: We reserve enough space for the `size_hint`, and the iterator is `TrustedLen` - // so its `size_hint` is exact. - move |(), (t, u)| unsafe { - a.extend_one_unchecked(t); - b.extend_one_unchecked(u); + impl<$($ty_names,)* $($extend_ty_names,)* Iter> $trait_name<$($extend_ty_names),*> for Iter + where + $($extend_ty_names: Extend<$ty_names>,)* + Iter: Iterator, + { + default fn extend(self, $($var_names: &mut $extend_ty_names),*) { + $default_fn_name(self, $($var_names),*); } } - let (lower_bound, upper_bound) = self.size_hint(); + impl<$($ty_names,)* $($extend_ty_names,)* Iter> $trait_name<$($extend_ty_names),*> for Iter + where + $($extend_ty_names: Extend<$ty_names>,)* + Iter: TrustedLen, + { + fn extend(self, $($var_names: &mut $extend_ty_names,)*) { + fn extend<'a, $($ty_names,)*>( + $($var_names: &'a mut impl Extend<$ty_names>,)* + ) -> impl FnMut((), ($($ty_names,)*)) + 'a { + #[allow(non_snake_case)] + // SAFETY: We reserve enough space for the `size_hint`, and the iterator is + // `TrustedLen` so its `size_hint` is exact. + move |(), ($($extend_ty_names,)*)| unsafe { + $($var_names.extend_one_unchecked($extend_ty_names);)* + } + } + + let (lower_bound, upper_bound) = self.size_hint(); + + if upper_bound.is_none() { + // We cannot reserve more than `usize::MAX` items, and this is likely to go out of memory anyway. + $default_fn_name(self, $($var_names,)*); + return; + } + + if lower_bound > 0 { + $($var_names.extend_reserve(lower_bound);)* + } - if upper_bound.is_none() { - // We cannot reserve more than `usize::MAX` items, and this is likely to go out of memory anyway. - default_extend_tuple(self, a, b); - return; + self.fold((), extend($($var_names,)*)); + } } - if lower_bound > 0 { - a.extend_reserve(lower_bound); - b.extend_reserve(lower_bound); + /// This implementation turns an iterator of tuples into a tuple of types which implement + /// [`Default`] and [`Extend`]. + /// + /// This is similar to [`Iterator::unzip`], but is also composable with other [`FromIterator`] + /// implementations: + /// + /// ```rust + /// # fn main() -> Result<(), core::num::ParseIntError> { + /// let string = "1,2,123,4"; + /// + /// // Example given for a 2-tuple, but 1- through 12-tuples are supported + /// let (numbers, lengths): (Vec<_>, Vec<_>) = string + /// .split(',') + /// .map(|s| s.parse().map(|n: u32| (n, s.len()))) + /// .collect::>()?; + /// + /// assert_eq!(numbers, [1, 2, 123, 4]); + /// assert_eq!(lengths, [1, 1, 3, 1]); + /// # Ok(()) } + /// ``` + #[$meta] + $(#[$doctext])? + #[stable(feature = "from_iterator_for_tuple", since = "1.79.0")] + impl<$($ty_names,)* $($extend_ty_names,)*> FromIterator<($($extend_ty_names,)*)> for ($($ty_names,)*) + where + $($ty_names: Default + Extend<$extend_ty_names>,)* + { + fn from_iter>(iter: Iter) -> Self { + let mut res = <($($ty_names,)*)>::default(); + res.extend(iter); + + res + } } - self.fold((), extend(a, b)); - } + }; } + +spec_tuple_impl!( + (L, l, EL, TraitL, default_extend_tuple_l, 11), + (K, k, EK, TraitK, default_extend_tuple_k, 10), + (J, j, EJ, TraitJ, default_extend_tuple_j, 9), + (I, i, EI, TraitI, default_extend_tuple_i, 8), + (H, h, EH, TraitH, default_extend_tuple_h, 7), + (G, g, EG, TraitG, default_extend_tuple_g, 6), + (F, f, EF, TraitF, default_extend_tuple_f, 5), + (E, e, EE, TraitE, default_extend_tuple_e, 4), + (D, d, ED, TraitD, default_extend_tuple_d, 3), + (C, c, EC, TraitC, default_extend_tuple_c, 2), + (B, b, EB, TraitB, default_extend_tuple_b, 1), + (A, a, EA, TraitA, default_extend_tuple_a, 0), +); diff --git a/core/src/iter/traits/iterator.rs b/core/src/iter/traits/iterator.rs index ffaf1bc56e942..10ae43ac3fcd5 100644 --- a/core/src/iter/traits/iterator.rs +++ b/core/src/iter/traits/iterator.rs @@ -1553,7 +1553,7 @@ pub trait Iterator { /// /// # Panics /// - /// Panics if `N` is 0. This check will most probably get changed to a + /// Panics if `N` is zero. This check will most probably get changed to a /// compile time error before this method gets stabilized. /// /// ```should_panic @@ -1825,10 +1825,19 @@ pub trait Iterator { Inspect::new(self, f) } - /// Borrows an iterator, rather than consuming it. + /// Creates a "by reference" adapter for this instance of `Iterator`. /// - /// This is useful to allow applying iterator adapters while still - /// retaining ownership of the original iterator. + /// Consuming method calls (direct or indirect calls to `next`) + /// on the "by reference" adapter will consume the original iterator, + /// but ownership-taking methods (those with a `self` parameter) + /// only take ownership of the "by reference" iterator. + /// + /// This is useful for applying ownership-taking methods + /// (such as `take` in the example below) + /// without giving up ownership of the original iterator, + /// so you can use the original iterator afterwards. + /// + /// Uses [impl Iterator for &mut I { type Item = I::Item; ...}](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#impl-Iterator-for-%26mut+I). /// /// # Examples /// @@ -2564,7 +2573,7 @@ pub trait Iterator { /// # Example /// /// ``` - /// let reduced: i32 = (1..10).reduce(|acc, e| acc + e).unwrap(); + /// let reduced: i32 = (1..10).reduce(|acc, e| acc + e).unwrap_or(0); /// assert_eq!(reduced, 45); /// /// // Which is equivalent to doing it with `fold`: @@ -3051,6 +3060,7 @@ pub trait Iterator { /// /// // we can still use `iter`, as there are more elements. /// assert_eq!(iter.next(), Some(&-1)); + /// assert_eq!(iter.next_back(), Some(&3)); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -3087,7 +3097,7 @@ pub trait Iterator { /// [2.4, f32::NAN, 1.3] /// .into_iter() /// .reduce(f32::max) - /// .unwrap(), + /// .unwrap_or(0.), /// 2.4 /// ); /// ``` @@ -3123,7 +3133,7 @@ pub trait Iterator { /// [2.4, f32::NAN, 1.3] /// .into_iter() /// .reduce(f32::min) - /// .unwrap(), + /// .unwrap_or(0.), /// 1.3 /// ); /// ``` @@ -3454,7 +3464,7 @@ pub trait Iterator { /// /// # Panics /// - /// Panics if `N` is 0. + /// Panics if `N` is zero. /// /// # Examples /// @@ -3492,7 +3502,8 @@ pub trait Iterator { /// /// Takes each element, adds them together, and returns the result. /// - /// An empty iterator returns the zero value of the type. + /// An empty iterator returns the *additive identity* ("zero") of the type, + /// which is `0` for integers and `-0.0` for floats. /// /// `sum()` can be used to sum any type implementing [`Sum`][`core::iter::Sum`], /// including [`Option`][`Option::sum`] and [`Result`][`Result::sum`]. @@ -3510,6 +3521,10 @@ pub trait Iterator { /// let sum: i32 = a.iter().sum(); /// /// assert_eq!(sum, 6); + /// + /// let b: Vec = vec![]; + /// let sum: f32 = b.iter().sum(); + /// assert_eq!(sum, -0.0_f32); /// ``` #[stable(feature = "iter_arith", since = "1.11.0")] fn sum(self) -> S @@ -4018,6 +4033,9 @@ where } } +/// Implements `Iterator` for mutable references to iterators, such as those produced by [`Iterator::by_ref`]. +/// +/// This implementation passes all method calls on to the original iterator. #[stable(feature = "rust1", since = "1.0.0")] impl Iterator for &mut I { type Item = I::Item; diff --git a/core/src/lib.rs b/core/src/lib.rs index a178d10125477..987fa93d59877 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -44,7 +44,7 @@ //! called. The `lang` attribute is called `eh_personality`. // Since core defines many fundamental lang items, all tests live in a -// separate crate, libcoretest (library/core/tests), to avoid bizarre issues. +// separate crate, coretests (library/coretests), to avoid bizarre issues. // // Here we explicitly #[cfg]-out this whole crate when testing. If we don't do // this, both the generated test artifact and the linked libtest (which @@ -101,38 +101,24 @@ #![warn(multiple_supertrait_upcastable)] #![allow(internal_features)] #![deny(ffi_unwind_calls)] +#![warn(unreachable_pub)] // Do not check link redundancy on bootstraping phase #![allow(rustdoc::redundant_explicit_links)] #![warn(rustdoc::unescaped_backticks)] // // Library features: // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(const_exact_div))] -#![cfg_attr(bootstrap, feature(const_fmt_arguments_new))] -#![cfg_attr(bootstrap, feature(const_ub_checks))] #![feature(array_ptr_get)] #![feature(asm_experimental_arch)] -#![feature(const_align_of_val)] -#![feature(const_align_of_val_raw)] -#![feature(const_alloc_layout)] -#![feature(const_black_box)] -#![feature(const_eq_ignore_ascii_case)] +#![feature(bigint_helper_methods)] +#![feature(bstr)] +#![feature(bstr_internals)] +#![feature(closure_track_caller)] +#![feature(const_carrying_mul_add)] #![feature(const_eval_select)] -#![feature(const_heap)] -#![feature(const_nonnull_new)] -#![feature(const_ptr_sub_ptr)] -#![feature(const_raw_ptr_comparison)] -#![feature(const_size_of_val)] -#![feature(const_size_of_val_raw)] -#![feature(const_sockaddr_setters)] -#![feature(const_swap)] -#![feature(const_try)] -#![feature(const_type_id)] -#![feature(const_type_name)] -#![feature(const_typed_swap)] #![feature(core_intrinsics)] #![feature(coverage_attribute)] -#![feature(do_not_recommend)] +#![feature(disjoint_bitor)] #![feature(internal_impls_macro)] #![feature(ip)] #![feature(is_ascii_octdigit)] @@ -144,6 +130,7 @@ #![feature(ptr_alignment_type)] #![feature(ptr_metadata)] #![feature(set_ptr_value)] +#![feature(slice_as_array)] #![feature(slice_as_chunks)] #![feature(slice_ptr_get)] #![feature(str_internals)] @@ -158,8 +145,6 @@ // // Language features: // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(strict_provenance))] -#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] #![feature(abi_unadjusted)] #![feature(adt_const_params)] #![feature(allow_internal_unsafe)] @@ -169,10 +154,7 @@ #![feature(cfg_target_has_atomic)] #![feature(cfg_target_has_atomic_equal_alignment)] #![feature(cfg_ub_checks)] -#![feature(const_for)] -#![feature(const_is_char_boundary)] #![feature(const_precise_live_drops)] -#![feature(const_str_split_at)] #![feature(const_trait_impl)] #![feature(decl_macro)] #![feature(deprecated_suggestion)] @@ -209,7 +191,7 @@ #![feature(simd_ffi)] #![feature(staged_api)] #![feature(stmt_expr_attributes)] -#![feature(target_feature_11)] +#![feature(strict_provenance_lints)] #![feature(trait_alias)] #![feature(transparent_unions)] #![feature(try_blocks)] @@ -220,14 +202,17 @@ // // Target features: // tidy-alphabetical-start +#![feature(aarch64_unstable_target_feature)] #![feature(arm_target_feature)] #![feature(avx512_target_feature)] #![feature(hexagon_target_feature)] +#![feature(keylocker_x86)] #![feature(loongarch_target_feature)] #![feature(mips_target_feature)] #![feature(powerpc_target_feature)] #![feature(riscv_target_feature)] #![feature(rtm_target_feature)] +#![feature(s390x_target_feature)] #![feature(sha512_sm_x86)] #![feature(sse4a_target_feature)] #![feature(tbm_target_feature)] @@ -258,7 +243,6 @@ pub mod assert_matches { } // We don't export this through #[macro_export] for now, to avoid breakage. -#[cfg(not(bootstrap))] #[unstable(feature = "autodiff", issue = "124509")] /// Unstable module containing the unstable `autodiff` macro. pub mod autodiff { @@ -266,6 +250,9 @@ pub mod autodiff { pub use crate::macros::builtin::autodiff; } +#[unstable(feature = "contracts", issue = "128044")] +pub mod contracts; + #[unstable(feature = "cfg_match", issue = "115585")] pub use crate::macros::cfg_match; @@ -358,6 +345,8 @@ pub mod ascii; pub mod asserting; #[unstable(feature = "async_iterator", issue = "79024")] pub mod async_iter; +#[unstable(feature = "bstr", issue = "134915")] +pub mod bstr; pub mod cell; pub mod char; pub mod ffi; @@ -368,7 +357,7 @@ pub mod net; pub mod option; pub mod panic; pub mod panicking; -#[unstable(feature = "core_pattern_types", issue = "123646")] +#[unstable(feature = "pattern_type_macro", issue = "123646")] pub mod pat; pub mod pin; #[unstable(feature = "random", issue = "130703")] @@ -377,6 +366,8 @@ pub mod random; pub mod range; pub mod result; pub mod sync; +#[unstable(feature = "unsafe_binders", issue = "130516")] +pub mod unsafe_binder; pub mod fmt; pub mod hash; @@ -417,7 +408,8 @@ pub mod primitive; unused_imports, unsafe_op_in_unsafe_fn, ambiguous_glob_reexports, - deprecated_in_future + deprecated_in_future, + unreachable_pub )] #[allow(rustdoc::bare_urls)] mod core_arch; diff --git a/core/src/macros/mod.rs b/core/src/macros/mod.rs index 771c2d31b60e0..a527a2ea5aada 100644 --- a/core/src/macros/mod.rs +++ b/core/src/macros/mod.rs @@ -213,10 +213,10 @@ pub macro assert_matches { /// #![feature(cfg_match)] /// /// cfg_match! { -/// cfg(unix) => { +/// unix => { /// fn foo() { /* unix specific functionality */ } /// } -/// cfg(target_pointer_width = "32") => { +/// target_pointer_width = "32" => { /// fn foo() { /* non-unix, 32-bit functionality */ } /// } /// _ => { @@ -224,64 +224,37 @@ pub macro assert_matches { /// } /// } /// ``` +/// +/// If desired, it is possible to return expressions through the use of surrounding braces: +/// +/// ``` +/// #![feature(cfg_match)] +/// +/// let _some_string = cfg_match! {{ +/// unix => { "With great power comes great electricity bills" } +/// _ => { "Behind every successful diet is an unwatched pizza" } +/// }}; +/// ``` #[unstable(feature = "cfg_match", issue = "115585")] #[rustc_diagnostic_item = "cfg_match"] pub macro cfg_match { - // with a final wildcard - ( - $(cfg($initial_meta:meta) => { $($initial_tokens:tt)* })+ - _ => { $($extra_tokens:tt)* } - ) => { - cfg_match! { - @__items (); - $((($initial_meta) ($($initial_tokens)*)),)+ - (() ($($extra_tokens)*)), - } + ({ $($tt:tt)* }) => {{ + cfg_match! { $($tt)* } + }}, + (_ => { $($output:tt)* }) => { + $($output)* }, - - // without a final wildcard ( - $(cfg($extra_meta:meta) => { $($extra_tokens:tt)* })* + $cfg:meta => $output:tt + $($( $rest:tt )+)? ) => { - cfg_match! { - @__items (); - $((($extra_meta) ($($extra_tokens)*)),)* - } + #[cfg($cfg)] + cfg_match! { _ => $output } + $( + #[cfg(not($cfg))] + cfg_match! { $($rest)+ } + )? }, - - // Internal and recursive macro to emit all the items - // - // Collects all the previous cfgs in a list at the beginning, so they can be - // negated. After the semicolon is all the remaining items. - (@__items ($($_:meta,)*);) => {}, - ( - @__items ($($no:meta,)*); - (($($yes:meta)?) ($($tokens:tt)*)), - $($rest:tt,)* - ) => { - // Emit all items within one block, applying an appropriate #[cfg]. The - // #[cfg] will require all `$yes` matchers specified and must also negate - // all previous matchers. - #[cfg(all( - $($yes,)? - not(any($($no),*)) - ))] - cfg_match! { @__identity $($tokens)* } - - // Recurse to emit all other items in `$rest`, and when we do so add all - // our `$yes` matchers to the list of `$no` matchers as future emissions - // will have to negate everything we just matched as well. - cfg_match! { - @__items ($($no,)* $($yes,)?); - $($rest,)* - } - }, - - // Internal macro to make __apply work out right for different match types, - // because of how macros match/expand stuff. - (@__identity $($tokens:tt)*) => { - $($tokens)* - } } /// Asserts that a boolean expression is `true` at runtime. @@ -1549,12 +1522,11 @@ pub(crate) mod builtin { /// NAME is a string that represents a valid function name. /// MODE is any of Forward, Reverse, ForwardFirst, ReverseFirst. /// INPUT_ACTIVITIES consists of one valid activity for each input parameter. - /// OUTPUT_ACTIVITY must not be set if we implicitely return nothing (or explicitely return + /// OUTPUT_ACTIVITY must not be set if we implicitly return nothing (or explicitly return /// `-> ()`). Otherwise it must be set to one of the allowed activities. #[unstable(feature = "autodiff", issue = "124509")] #[allow_internal_unstable(rustc_attrs)] #[rustc_builtin_macro] - #[cfg(not(bootstrap))] pub macro autodiff($item:item) { /* compiler built-in */ } @@ -1715,6 +1687,30 @@ pub(crate) mod builtin { /* compiler built-in */ } + /// Attribute macro applied to a function to give it a post-condition. + /// + /// The attribute carries an argument token-tree which is + /// eventually parsed as a unary closure expression that is + /// invoked on a reference to the return value. + #[unstable(feature = "contracts", issue = "128044")] + #[allow_internal_unstable(contracts_internals)] + #[rustc_builtin_macro] + pub macro contracts_ensures($item:item) { + /* compiler built-in */ + } + + /// Attribute macro applied to a function to give it a precondition. + /// + /// The attribute carries an argument token-tree which is + /// eventually parsed as an boolean expression with access to the + /// function's formal parameters + #[unstable(feature = "contracts", issue = "128044")] + #[allow_internal_unstable(contracts_internals)] + #[rustc_builtin_macro] + pub macro contracts_requires($item:item) { + /* compiler built-in */ + } + /// Attribute macro applied to a function to register it as a handler for allocation failure. /// /// See also [`std::alloc::handle_alloc_error`](../../../std/alloc/fn.handle_alloc_error.html). @@ -1747,6 +1743,21 @@ pub(crate) mod builtin { /* compiler built-in */ } + /// Provide a list of type aliases and other opaque-type-containing type definitions. + /// This list will be used in the body of the item it is applied to to define opaque + /// types' hidden types. + /// Can only be applied to things that have bodies. + #[unstable( + feature = "type_alias_impl_trait", + issue = "63063", + reason = "`type_alias_impl_trait` has open design concerns" + )] + #[rustc_builtin_macro] + #[cfg(not(bootstrap))] + pub macro define_opaque($($tt:tt)*) { + /* compiler built-in */ + } + /// Unstable placeholder for type ascription. #[allow_internal_unstable(builtin_syntax)] #[unstable( @@ -1769,32 +1780,4 @@ pub(crate) mod builtin { pub macro deref($pat:pat) { builtin # deref($pat) } - - /// Derive macro for `rustc-serialize`. Should not be used in new code. - #[rustc_builtin_macro] - #[unstable( - feature = "rustc_encodable_decodable", - issue = "none", - soft, - reason = "derive macro for `rustc-serialize`; should not be used in new code" - )] - #[deprecated(since = "1.52.0", note = "rustc-serialize is deprecated and no longer supported")] - #[doc(hidden)] // While technically stable, using it is unstable, and deprecated. Hide it. - pub macro RustcDecodable($item:item) { - /* compiler built-in */ - } - - /// Derive macro for `rustc-serialize`. Should not be used in new code. - #[rustc_builtin_macro] - #[unstable( - feature = "rustc_encodable_decodable", - issue = "none", - soft, - reason = "derive macro for `rustc-serialize`; should not be used in new code" - )] - #[deprecated(since = "1.52.0", note = "rustc-serialize is deprecated and no longer supported")] - #[doc(hidden)] // While technically stable, using it is unstable, and deprecated. Hide it. - pub macro RustcEncodable($item:item) { - /* compiler built-in */ - } } diff --git a/core/src/marker.rs b/core/src/marker.rs index acbad07746bb9..e234f105b0b76 100644 --- a/core/src/marker.rs +++ b/core/src/marker.rs @@ -6,6 +6,13 @@ #![stable(feature = "rust1", since = "1.0.0")] +mod variance; + +#[unstable(feature = "phantom_variance_markers", issue = "135806")] +pub use self::variance::{ + PhantomContravariant, PhantomContravariantLifetime, PhantomCovariant, PhantomCovariantLifetime, + PhantomInvariant, PhantomInvariantLifetime, Variance, variance, +}; use crate::cell::UnsafeCell; use crate::cmp; use crate::fmt::Debug; @@ -141,7 +148,8 @@ unsafe impl Send for &T {} )] #[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable #[rustc_specialization_trait] -#[rustc_deny_explicit_impl(implement_via_object = false)] +#[rustc_deny_explicit_impl] +#[rustc_do_not_implement_via_object] #[rustc_coinductive] pub trait Sized { // Empty. @@ -181,31 +189,27 @@ pub trait Sized { /// [^1]: Formerly known as *object safe*. #[unstable(feature = "unsize", issue = "18598")] #[lang = "unsize"] -#[rustc_deny_explicit_impl(implement_via_object = false)] +#[rustc_deny_explicit_impl] +#[rustc_do_not_implement_via_object] pub trait Unsize { // Empty. } /// Required trait for constants used in pattern matches. /// -/// Any type that derives `PartialEq` automatically implements this trait, -/// *regardless* of whether its type-parameters implement `PartialEq`. -/// -/// If a `const` item contains some type that does not implement this trait, -/// then that type either (1.) does not implement `PartialEq` (which means the -/// constant will not provide that comparison method, which code generation -/// assumes is available), or (2.) it implements *its own* version of -/// `PartialEq` (which we assume does not conform to a structural-equality -/// comparison). -/// -/// In either of the two scenarios above, we reject usage of such a constant in -/// a pattern match. +/// Constants are only allowed as patterns if (a) their type implements +/// `PartialEq`, and (b) interpreting the value of the constant as a pattern +/// is equialent to calling `PartialEq`. This ensures that constants used as +/// patterns cannot expose implementation details in an unexpected way or +/// cause semver hazards. /// -/// See also the [structural match RFC][RFC1445], and [issue 63438] which -/// motivated migrating from an attribute-based design to this trait. +/// This trait ensures point (b). +/// Any type that derives `PartialEq` automatically implements this trait. /// -/// [RFC1445]: https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md -/// [issue 63438]: https://github.com/rust-lang/rust/issues/63438 +/// Implementing this trait (which is unstable) is a way for type authors to explicitly allow +/// comparing const values of this type; that operation will recursively compare all fields +/// (including private fields), even if that behavior differs from `PartialEq`. This can make it +/// semver-breaking to add further private fields to a type. #[unstable(feature = "structural_match", issue = "31434")] #[diagnostic::on_unimplemented(message = "the type `{Self}` does not `#[derive(PartialEq)]`")] #[lang = "structural_peq"] @@ -401,7 +405,7 @@ marker_impls! { /// /// [`Vec`]: ../../std/vec/struct.Vec.html /// [`String`]: ../../std/string/struct.String.html -/// [`size_of::`]: crate::mem::size_of +/// [`size_of::`]: size_of /// [impls]: #implementors #[stable(feature = "rust1", since = "1.0.0")] #[lang = "copy"] @@ -449,6 +453,23 @@ impl Copy for ! {} #[stable(feature = "rust1", since = "1.0.0")] impl Copy for &T {} +/// Marker trait for the types that are allowed in union fields and unsafe +/// binder types. +/// +/// Implemented for: +/// * `&T`, `&mut T` for all `T`, +/// * `ManuallyDrop` for all `T`, +/// * tuples and arrays whose elements implement `BikeshedGuaranteedNoDrop`, +/// * or otherwise, all types that are `Copy`. +/// +/// Notably, this doesn't include all trivially-destructible types for semver +/// reasons. +/// +/// Bikeshed name for now. +#[unstable(feature = "bikeshed_guaranteed_no_drop", issue = "none")] +#[lang = "bikeshed_guaranteed_no_drop"] +pub trait BikeshedGuaranteedNoDrop {} + /// Types for which it is safe to share references between threads. /// /// This trait is automatically implemented when the compiler determines @@ -710,7 +731,6 @@ impl !Sync for *mut T {} /// # } /// # fn convert_params(_: ParamType) -> usize { 42 } /// use std::marker::PhantomData; -/// use std::mem; /// /// struct ExternalResource { /// resource_handle: *mut (), @@ -719,7 +739,7 @@ impl !Sync for *mut T {} /// /// impl ExternalResource { /// fn new() -> Self { -/// let size_of_res = mem::size_of::(); +/// let size_of_res = size_of::(); /// Self { /// resource_handle: foreign_lib::new(size_of_res), /// resource_type: PhantomData, @@ -815,7 +835,8 @@ impl StructuralPartialEq for PhantomData {} reason = "this trait is unlikely to ever be stabilized, use `mem::discriminant` instead" )] #[lang = "discriminant_kind"] -#[rustc_deny_explicit_impl(implement_via_object = false)] +#[rustc_deny_explicit_impl] +#[rustc_do_not_implement_via_object] pub trait DiscriminantKind { /// The type of the discriminant, which must satisfy the trait /// bounds required by `mem::Discriminant`. @@ -954,9 +975,12 @@ marker_impls! { /// This should be used for `~const` bounds, /// as non-const bounds will always hold for every type. #[unstable(feature = "const_destruct", issue = "133214")] +#[rustc_const_unstable(feature = "const_destruct", issue = "133214")] #[lang = "destruct"] #[rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg)] -#[rustc_deny_explicit_impl(implement_via_object = false)] +#[rustc_deny_explicit_impl] +#[rustc_do_not_implement_via_object] +#[const_trait] pub trait Destruct {} /// A marker for tuple types. @@ -966,25 +990,33 @@ pub trait Destruct {} #[unstable(feature = "tuple_trait", issue = "none")] #[lang = "tuple_trait"] #[diagnostic::on_unimplemented(message = "`{Self}` is not a tuple")] -#[rustc_deny_explicit_impl(implement_via_object = false)] +#[rustc_deny_explicit_impl] +#[rustc_do_not_implement_via_object] pub trait Tuple {} /// A marker for pointer-like types. /// -/// All types that have the same size and alignment as a `usize` or -/// `*const ()` automatically implement this trait. +/// This trait can only be implemented for types that are certain to have +/// the same size and alignment as a [`usize`] or [`*const ()`](pointer). +/// To ensure this, there are special requirements on implementations +/// of `PointerLike` (other than the already-provided implementations +/// for built-in types): +/// +/// * The type must have `#[repr(transparent)]`. +/// * The type’s sole non-zero-sized field must itself implement `PointerLike`. #[unstable(feature = "pointer_like_trait", issue = "none")] #[lang = "pointer_like"] #[diagnostic::on_unimplemented( message = "`{Self}` needs to have the same ABI as a pointer", label = "`{Self}` needs to be a pointer-like type" )] +#[rustc_do_not_implement_via_object] pub trait PointerLike {} -#[cfg(not(bootstrap))] marker_impls! { #[unstable(feature = "pointer_like_trait", issue = "none")] PointerLike for + isize, usize, {T} &T, {T} &mut T, @@ -1061,24 +1093,229 @@ marker_impls! { } /// A common trait implemented by all function pointers. +// +// Note that while the trait is internal and unstable it is nevertheless +// exposed as a public bound of the stable `core::ptr::fn_addr_eq` function. #[unstable( feature = "fn_ptr_trait", issue = "none", reason = "internal trait for implementing various traits for all function pointers" )] #[lang = "fn_ptr_trait"] -#[rustc_deny_explicit_impl(implement_via_object = false)] +#[rustc_deny_explicit_impl] +#[rustc_do_not_implement_via_object] pub trait FnPtr: Copy + Clone { /// Returns the address of the function pointer. #[lang = "fn_ptr_addr"] fn addr(self) -> *const (); } -/// Derive macro generating impls of traits related to smart pointers. +/// Derive macro that makes a smart pointer usable with trait objects. +/// +/// # What this macro does +/// +/// This macro is intended to be used with user-defined pointer types, and makes it possible to +/// perform coercions on the pointee of the user-defined pointer. There are two aspects to this: +/// +/// ## Unsizing coercions of the pointee +/// +/// By using the macro, the following example will compile: +/// ``` +/// #![feature(derive_coerce_pointee)] +/// use std::marker::CoercePointee; +/// use std::ops::Deref; +/// +/// #[derive(CoercePointee)] +/// #[repr(transparent)] +/// struct MySmartPointer(Box); +/// +/// impl Deref for MySmartPointer { +/// type Target = T; +/// fn deref(&self) -> &T { +/// &self.0 +/// } +/// } +/// +/// trait MyTrait {} +/// +/// impl MyTrait for i32 {} +/// +/// fn main() { +/// let ptr: MySmartPointer = MySmartPointer(Box::new(4)); +/// +/// // This coercion would be an error without the derive. +/// let ptr: MySmartPointer = ptr; +/// } +/// ``` +/// Without the `#[derive(CoercePointee)]` macro, this example would fail with the following error: +/// ```text +/// error[E0308]: mismatched types +/// --> src/main.rs:11:44 +/// | +/// 11 | let ptr: MySmartPointer = ptr; +/// | --------------------------- ^^^ expected `MySmartPointer`, found `MySmartPointer` +/// | | +/// | expected due to this +/// | +/// = note: expected struct `MySmartPointer` +/// found struct `MySmartPointer` +/// = help: `i32` implements `MyTrait` so you could box the found value and coerce it to the trait object `Box`, you will have to change the expected type as well +/// ``` +/// +/// ## Dyn compatibility +/// +/// This macro allows you to dispatch on the user-defined pointer type. That is, traits using the +/// type as a receiver are dyn-compatible. For example, this compiles: +/// +/// ``` +/// #![feature(arbitrary_self_types, derive_coerce_pointee)] +/// use std::marker::CoercePointee; +/// use std::ops::Deref; +/// +/// #[derive(CoercePointee)] +/// #[repr(transparent)] +/// struct MySmartPointer(Box); +/// +/// impl Deref for MySmartPointer { +/// type Target = T; +/// fn deref(&self) -> &T { +/// &self.0 +/// } +/// } +/// +/// // You can always define this trait. (as long as you have #![feature(arbitrary_self_types)]) +/// trait MyTrait { +/// fn func(self: MySmartPointer); +/// } +/// +/// // But using `dyn MyTrait` requires #[derive(CoercePointee)]. +/// fn call_func(value: MySmartPointer) { +/// value.func(); +/// } +/// ``` +/// If you remove the `#[derive(CoercePointee)]` annotation from the struct, then the above example +/// will fail with this error message: +/// ```text +/// error[E0038]: the trait `MyTrait` is not dyn compatible +/// --> src/lib.rs:21:36 +/// | +/// 17 | fn func(self: MySmartPointer); +/// | -------------------- help: consider changing method `func`'s `self` parameter to be `&self`: `&Self` +/// ... +/// 21 | fn call_func(value: MySmartPointer) { +/// | ^^^^^^^^^^^ `MyTrait` is not dyn compatible +/// | +/// note: for a trait to be dyn compatible it needs to allow building a vtable +/// for more information, visit +/// --> src/lib.rs:17:19 +/// | +/// 16 | trait MyTrait { +/// | ------- this trait is not dyn compatible... +/// 17 | fn func(self: MySmartPointer); +/// | ^^^^^^^^^^^^^^^^^^^^ ...because method `func`'s `self` parameter cannot be dispatched on +/// ``` +/// +/// # Requirements for using the macro +/// +/// This macro can only be used if: +/// * The type is a `#[repr(transparent)]` struct. +/// * The type of its non-zero-sized field must either be a standard library pointer type +/// (reference, raw pointer, `NonNull`, `Box`, `Rc`, `Arc`, etc.) or another user-defined type +/// also using the `#[derive(CoercePointee)]` macro. +/// * Zero-sized fields must not mention any generic parameters unless the zero-sized field has +/// type [`PhantomData`]. +/// +/// ## Multiple type parameters +/// +/// If the type has multiple type parameters, then you must explicitly specify which one should be +/// used for dynamic dispatch. For example: +/// ``` +/// # #![feature(derive_coerce_pointee)] +/// # use std::marker::{CoercePointee, PhantomData}; +/// #[derive(CoercePointee)] +/// #[repr(transparent)] +/// struct MySmartPointer<#[pointee] T: ?Sized, U> { +/// ptr: Box, +/// _phantom: PhantomData, +/// } +/// ``` +/// Specifying `#[pointee]` when the struct has only one type parameter is allowed, but not required. +/// +/// # Examples +/// +/// A custom implementation of the `Rc` type: +/// ``` +/// #![feature(derive_coerce_pointee)] +/// use std::marker::CoercePointee; +/// use std::ops::Deref; +/// use std::ptr::NonNull; +/// +/// #[derive(CoercePointee)] +/// #[repr(transparent)] +/// pub struct Rc { +/// inner: NonNull>, +/// } +/// +/// struct RcInner { +/// refcount: usize, +/// value: T, +/// } +/// +/// impl Deref for Rc { +/// type Target = T; +/// fn deref(&self) -> &T { +/// let ptr = self.inner.as_ptr(); +/// unsafe { &(*ptr).value } +/// } +/// } +/// +/// impl Rc { +/// pub fn new(value: T) -> Self { +/// let inner = Box::new(RcInner { +/// refcount: 1, +/// value, +/// }); +/// Self { +/// inner: NonNull::from(Box::leak(inner)), +/// } +/// } +/// } +/// +/// impl Clone for Rc { +/// fn clone(&self) -> Self { +/// // A real implementation would handle overflow here. +/// unsafe { (*self.inner.as_ptr()).refcount += 1 }; +/// Self { inner: self.inner } +/// } +/// } +/// +/// impl Drop for Rc { +/// fn drop(&mut self) { +/// let ptr = self.inner.as_ptr(); +/// unsafe { (*ptr).refcount -= 1 }; +/// if unsafe { (*ptr).refcount } == 0 { +/// drop(unsafe { Box::from_raw(ptr) }); +/// } +/// } +/// } +/// ``` #[rustc_builtin_macro(CoercePointee, attributes(pointee))] -#[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize)] +#[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize, coerce_pointee_validated)] +#[cfg_attr(not(test), rustc_diagnostic_item = "CoercePointee")] #[unstable(feature = "derive_coerce_pointee", issue = "123430")] -#[cfg(not(bootstrap))] pub macro CoercePointee($item:item) { /* compiler built-in */ } + +/// A trait that is implemented for ADTs with `derive(CoercePointee)` so that +/// the compiler can enforce the derive impls are valid post-expansion, since +/// the derive has stricter requirements than if the impls were written by hand. +/// +/// This trait is not intended to be implemented by users or used other than +/// validation, so it should never be stabilized. +#[lang = "coerce_pointee_validated"] +#[unstable(feature = "coerce_pointee_validated", issue = "none")] +#[doc(hidden)] +pub trait CoercePointeeValidated { + /* compiler built-in */ +} diff --git a/core/src/marker/variance.rs b/core/src/marker/variance.rs new file mode 100644 index 0000000000000..235f8a3bb79f2 --- /dev/null +++ b/core/src/marker/variance.rs @@ -0,0 +1,272 @@ +#![unstable(feature = "phantom_variance_markers", issue = "135806")] + +use super::PhantomData; +use crate::any::type_name; +use crate::cmp::Ordering; +use crate::fmt; +use crate::hash::{Hash, Hasher}; + +macro_rules! first_token { + ($first:tt $($rest:tt)*) => { + $first + }; +} + +macro_rules! phantom_type { + ($( + $(#[$attr:meta])* + pub struct $name:ident <$t:ident> ($($inner:tt)*); + )*) => {$( + $(#[$attr])* + pub struct $name<$t>($($inner)*) where T: ?Sized; + + impl $name + where T: ?Sized + { + /// Constructs a new instance of the variance marker. + pub const fn new() -> Self { + Self(PhantomData) + } + } + + impl self::sealed::Sealed for $name where T: ?Sized { + const VALUE: Self = Self::new(); + } + impl Variance for $name where T: ?Sized {} + + impl Default for $name + where T: ?Sized + { + fn default() -> Self { + Self(PhantomData) + } + } + + impl fmt::Debug for $name + where T: ?Sized + { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}<{}>", stringify!($name), type_name::()) + } + } + + impl Clone for $name + where T: ?Sized + { + fn clone(&self) -> Self { + *self + } + } + + impl Copy for $name where T: ?Sized {} + + impl PartialEq for $name + where T: ?Sized + { + fn eq(&self, _: &Self) -> bool { + true + } + } + + impl Eq for $name where T: ?Sized {} + + impl PartialOrd for $name + where T: ?Sized + { + fn partial_cmp(&self, _: &Self) -> Option { + Some(Ordering::Equal) + } + } + + impl Ord for $name + where T: ?Sized + { + fn cmp(&self, _: &Self) -> Ordering { + Ordering::Equal + } + } + + impl Hash for $name + where T: ?Sized + { + fn hash(&self, _: &mut H) {} + } + )*}; +} + +macro_rules! phantom_lifetime { + ($( + $(#[$attr:meta])* + pub struct $name:ident <$lt:lifetime> ($($inner:tt)*); + )*) => {$( + $(#[$attr])* + #[derive(Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct $name<$lt>($($inner)*); + + impl $name<'_> { + /// Constructs a new instance of the variance marker. + pub const fn new() -> Self { + Self(first_token!($($inner)*)(PhantomData)) + } + } + + impl self::sealed::Sealed for $name<'_> { + const VALUE: Self = Self::new(); + } + impl Variance for $name<'_> {} + + impl fmt::Debug for $name<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", stringify!($name)) + } + } + )*}; +} + +phantom_lifetime! { + /// Zero-sized type used to mark a lifetime as covariant. + /// + /// Covariant lifetimes must live at least as long as declared. See [the reference][1] for more + /// information. + /// + /// [1]: https://doc.rust-lang.org/stable/reference/subtyping.html#variance + /// + /// ## Layout + /// + /// For all `'a`, the following are guaranteed: + /// * `size_of::>() == 0` + /// * `align_of::>() == 1` + #[rustc_pub_transparent] + #[repr(transparent)] + pub struct PhantomCovariantLifetime<'a>(PhantomCovariant<&'a ()>); + /// Zero-sized type used to mark a lifetime as contravariant. + /// + /// Contravariant lifetimes must live at most as long as declared. See [the reference][1] for + /// more information. + /// + /// [1]: https://doc.rust-lang.org/stable/reference/subtyping.html#variance + /// + /// ## Layout + /// + /// For all `'a`, the following are guaranteed: + /// * `size_of::>() == 0` + /// * `align_of::>() == 1` + #[rustc_pub_transparent] + #[repr(transparent)] + pub struct PhantomContravariantLifetime<'a>(PhantomContravariant<&'a ()>); + /// Zero-sized type used to mark a lifetime as invariant. + /// + /// Invariant lifetimes must be live for the exact length declared, neither shorter nor longer. + /// See [the reference][1] for more information. + /// + /// [1]: https://doc.rust-lang.org/stable/reference/subtyping.html#variance + /// + /// ## Layout + /// + /// For all `'a`, the following are guaranteed: + /// * `size_of::>() == 0` + /// * `align_of::>() == 1` + #[rustc_pub_transparent] + #[repr(transparent)] + pub struct PhantomInvariantLifetime<'a>(PhantomInvariant<&'a ()>); +} + +phantom_type! { + /// Zero-sized type used to mark a type parameter as covariant. + /// + /// Types used as part of the return value from a function are covariant. If the type is _also_ + /// passed as a parameter then it is [invariant][PhantomInvariant]. See [the reference][1] for + /// more information. + /// + /// [1]: https://doc.rust-lang.org/stable/reference/subtyping.html#variance + /// + /// ## Layout + /// + /// For all `T`, the following are guaranteed: + /// * `size_of::>() == 0` + /// * `align_of::>() == 1` + #[rustc_pub_transparent] + #[repr(transparent)] + pub struct PhantomCovariant(PhantomData T>); + /// Zero-sized type used to mark a type parameter as contravariant. + /// + /// Types passed as arguments to a function are contravariant. If the type is _also_ part of the + /// return value from a function then it is [invariant][PhantomInvariant]. See [the + /// reference][1] for more information. + /// + /// [1]: https://doc.rust-lang.org/stable/reference/subtyping.html#variance + /// + /// ## Layout + /// + /// For all `T`, the following are guaranteed: + /// * `size_of::>() == 0` + /// * `align_of::>() == 1` + #[rustc_pub_transparent] + #[repr(transparent)] + pub struct PhantomContravariant(PhantomData); + /// Zero-sized type used to mark a type parameter as invariant. + /// + /// Types that are both passed as an argument _and_ used as part of the return value from a + /// function are invariant. See [the reference][1] for more information. + /// + /// [1]: https://doc.rust-lang.org/stable/reference/subtyping.html#variance + /// + /// ## Layout + /// + /// For all `T`, the following are guaranteed: + /// * `size_of::>() == 0` + /// * `align_of::>() == 1` + #[rustc_pub_transparent] + #[repr(transparent)] + pub struct PhantomInvariant(PhantomData T>); +} + +mod sealed { + pub trait Sealed { + const VALUE: Self; + } +} + +/// A marker trait for phantom variance types. +pub trait Variance: sealed::Sealed + Default {} + +/// Construct a variance marker; equivalent to [`Default::default`]. +/// +/// This type can be any of the following. You generally should not need to explicitly name the +/// type, however. +/// +/// - [`PhantomCovariant`] +/// - [`PhantomContravariant`] +/// - [`PhantomInvariant`] +/// - [`PhantomCovariantLifetime`] +/// - [`PhantomContravariantLifetime`] +/// - [`PhantomInvariantLifetime`] +/// +/// # Example +/// +/// ```rust +/// #![feature(phantom_variance_markers)] +/// +/// use core::marker::{PhantomCovariant, variance}; +/// +/// struct BoundFn +/// where +/// F: Fn(P) -> R, +/// { +/// function: F, +/// parameter: P, +/// return_value: PhantomCovariant, +/// } +/// +/// let bound_fn = BoundFn { +/// function: core::convert::identity, +/// parameter: 5u8, +/// return_value: variance(), +/// }; +/// ``` +pub const fn variance() -> T +where + T: Variance, +{ + T::VALUE +} diff --git a/core/src/mem/maybe_uninit.rs b/core/src/mem/maybe_uninit.rs index 58315cb74f0a1..ce84f105e5c50 100644 --- a/core/src/mem/maybe_uninit.rs +++ b/core/src/mem/maybe_uninit.rs @@ -1,5 +1,5 @@ use crate::any::type_name; -use crate::mem::{self, ManuallyDrop}; +use crate::mem::ManuallyDrop; use crate::{fmt, intrinsics, ptr, slice}; /// A wrapper type to construct uninitialized instances of `T`. @@ -98,7 +98,7 @@ use crate::{fmt, intrinsics, ptr, slice}; /// /// unsafe fn make_vec(out: *mut Vec) { /// // `write` does not drop the old contents, which is important. -/// out.write(vec![1, 2, 3]); +/// unsafe { out.write(vec![1, 2, 3]); } /// } /// /// let mut v = MaybeUninit::uninit(); @@ -203,7 +203,7 @@ use crate::{fmt, intrinsics, ptr, slice}; /// `MaybeUninit` is guaranteed to have the same size, alignment, and ABI as `T`: /// /// ```rust -/// use std::mem::{MaybeUninit, size_of, align_of}; +/// use std::mem::MaybeUninit; /// assert_eq!(size_of::>(), size_of::()); /// assert_eq!(align_of::>(), align_of::()); /// ``` @@ -215,7 +215,7 @@ use crate::{fmt, intrinsics, ptr, slice}; /// optimizations, potentially resulting in a larger size: /// /// ```rust -/// # use std::mem::{MaybeUninit, size_of}; +/// # use std::mem::MaybeUninit; /// assert_eq!(size_of::>(), 1); /// assert_eq!(size_of::>>(), 2); /// ``` @@ -232,6 +232,26 @@ use crate::{fmt, intrinsics, ptr, slice}; /// remain `#[repr(transparent)]`. That said, `MaybeUninit` will *always* guarantee that it has /// the same size, alignment, and ABI as `T`; it's just that the way `MaybeUninit` implements that /// guarantee may evolve. +/// +/// Note that even though `T` and `MaybeUninit` are ABI compatible it is still unsound to +/// transmute `&mut T` to `&mut MaybeUninit` and expose that to safe code because it would allow +/// safe code to access uninitialized memory: +/// +/// ```rust,no_run +/// use core::mem::MaybeUninit; +/// +/// fn unsound_transmute(val: &mut T) -> &mut MaybeUninit { +/// unsafe { core::mem::transmute(val) } +/// } +/// +/// fn main() { +/// let mut code = 0; +/// let code = &mut code; +/// let code2 = unsound_transmute(code); +/// *code2 = MaybeUninit::uninit(); +/// std::process::exit(*code); // UB! Accessing uninitialized memory. +/// } +/// ``` #[stable(feature = "maybe_uninit", since = "1.36.0")] // Lang item so we can wrap other types in it. This is useful for coroutines. #[lang = "maybe_uninit"] @@ -255,7 +275,10 @@ impl Clone for MaybeUninit { #[stable(feature = "maybe_uninit_debug", since = "1.41.0")] impl fmt::Debug for MaybeUninit { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad(type_name::()) + // NB: there is no `.pad_fmt` so we can't use a simpler `format_args!("MaybeUninit<{..}>"). + let full_name = type_name::(); + let prefix_len = full_name.find("MaybeUninit").unwrap(); + f.pad(&full_name[prefix_len..]) } } @@ -308,42 +331,6 @@ impl MaybeUninit { MaybeUninit { uninit: () } } - /// Creates a new array of `MaybeUninit` items, in an uninitialized state. - /// - /// Note: in a future Rust version this method may become unnecessary - /// when Rust allows - /// [inline const expressions](https://github.com/rust-lang/rust/issues/76001). - /// The example below could then use `let mut buf = [const { MaybeUninit::::uninit() }; 32];`. - /// - /// # Examples - /// - /// ```no_run - /// #![feature(maybe_uninit_uninit_array, maybe_uninit_slice)] - /// - /// use std::mem::MaybeUninit; - /// - /// extern "C" { - /// fn read_into_buffer(ptr: *mut u8, max_len: usize) -> usize; - /// } - /// - /// /// Returns a (possibly smaller) slice of data that was actually read - /// fn read(buf: &mut [MaybeUninit]) -> &[u8] { - /// unsafe { - /// let len = read_into_buffer(buf.as_mut_ptr() as *mut u8, buf.len()); - /// MaybeUninit::slice_assume_init_ref(&buf[..len]) - /// } - /// } - /// - /// let mut buf: [MaybeUninit; 32] = MaybeUninit::uninit_array(); - /// let data = read(&mut buf); - /// ``` - #[unstable(feature = "maybe_uninit_uninit_array", issue = "96097")] - #[must_use] - #[inline(always)] - pub const fn uninit_array() -> [Self; N] { - [const { MaybeUninit::uninit() }; N] - } - /// Creates a new `MaybeUninit` in an uninitialized state, with the memory being /// filled with `0` bytes. It depends on `T` whether that already makes for /// proper initialization. For example, `MaybeUninit::zeroed()` is initialized, @@ -481,9 +468,9 @@ impl MaybeUninit { /// } /// } /// ``` - #[stable(feature = "maybe_uninit_write", since = "1.55.0")] - #[rustc_const_unstable(feature = "const_maybe_uninit_write", issue = "63567")] #[inline(always)] + #[stable(feature = "maybe_uninit_write", since = "1.55.0")] + #[rustc_const_stable(feature = "const_maybe_uninit_write", since = "1.85.0")] pub const fn write(&mut self, val: T) -> &mut T { *self = MaybeUninit::new(val); // SAFETY: We just initialized this value. @@ -525,7 +512,7 @@ impl MaybeUninit { /// until they are, it is advisable to avoid them.) #[stable(feature = "maybe_uninit", since = "1.36.0")] #[rustc_const_stable(feature = "const_maybe_uninit_as_ptr", since = "1.59.0")] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[inline(always)] pub const fn as_ptr(&self) -> *const T { // `MaybeUninit` and `ManuallyDrop` are both `repr(transparent)` so we can cast the pointer. @@ -567,7 +554,7 @@ impl MaybeUninit { /// until they are, it is advisable to avoid them.) #[stable(feature = "maybe_uninit", since = "1.36.0")] #[rustc_const_stable(feature = "const_maybe_uninit_as_mut_ptr", since = "1.83.0")] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[inline(always)] pub const fn as_mut_ptr(&mut self) -> *mut T { // `MaybeUninit` and `ManuallyDrop` are both `repr(transparent)` so we can cast the pointer. @@ -716,7 +703,7 @@ impl MaybeUninit { /// /// On top of that, all additional invariants of the type `T` must be /// satisfied, as the `Drop` implementation of `T` (or its members) may - /// rely on this. For example, setting a [`Vec`] to an invalid but + /// rely on this. For example, setting a `Vec` to an invalid but /// non-null address makes it initialized (under the current implementation; /// this does not constitute a stable guarantee), because the only /// requirement the compiler knows about it is that the data pointer must be @@ -724,7 +711,6 @@ impl MaybeUninit { /// behavior. /// /// [`assume_init`]: MaybeUninit::assume_init - /// [`Vec`]: ../../std/vec/struct.Vec.html #[stable(feature = "maybe_uninit_extra", since = "1.60.0")] pub unsafe fn assume_init_drop(&mut self) { // SAFETY: the caller must guarantee that `self` is initialized and @@ -822,7 +808,7 @@ impl MaybeUninit { /// # #![allow(unexpected_cfgs)] /// use std::mem::MaybeUninit; /// - /// # unsafe extern "C" fn initialize_buffer(buf: *mut [u8; 1024]) { *buf = [0; 1024] } + /// # unsafe extern "C" fn initialize_buffer(buf: *mut [u8; 1024]) { unsafe { *buf = [0; 1024] } } /// # #[cfg(FALSE)] /// extern "C" { /// /// Initializes *all* the bytes of the input buffer. @@ -907,10 +893,7 @@ impl MaybeUninit { /// }; /// ``` #[stable(feature = "maybe_uninit_ref", since = "1.55.0")] - #[rustc_const_stable( - feature = "const_maybe_uninit_assume_init", - since = "CURRENT_RUSTC_VERSION" - )] + #[rustc_const_stable(feature = "const_maybe_uninit_assume_init", since = "1.84.0")] #[inline(always)] pub const unsafe fn assume_init_mut(&mut self) -> &mut T { // SAFETY: the caller must guarantee that `self` is initialized. @@ -961,44 +944,85 @@ impl MaybeUninit { } } - /// Assuming all the elements are initialized, get a slice to them. + /// Returns the contents of this `MaybeUninit` as a slice of potentially uninitialized bytes. /// - /// # Safety + /// Note that even if the contents of a `MaybeUninit` have been initialized, the value may still + /// contain padding bytes which are left uninitialized. /// - /// It is up to the caller to guarantee that the `MaybeUninit` elements - /// really are in an initialized state. - /// Calling this when the content is not yet fully initialized causes undefined behavior. + /// # Examples /// - /// See [`assume_init_ref`] for more details and examples. + /// ``` + /// #![feature(maybe_uninit_as_bytes, maybe_uninit_slice)] + /// use std::mem::MaybeUninit; /// - /// [`assume_init_ref`]: MaybeUninit::assume_init_ref - #[unstable(feature = "maybe_uninit_slice", issue = "63569")] - #[inline(always)] - pub const unsafe fn slice_assume_init_ref(slice: &[Self]) -> &[T] { - // SAFETY: casting `slice` to a `*const [T]` is safe since the caller guarantees that - // `slice` is initialized, and `MaybeUninit` is guaranteed to have the same layout as `T`. - // The pointer obtained is valid since it refers to memory owned by `slice` which is a - // reference and thus guaranteed to be valid for reads. - unsafe { &*(slice as *const [Self] as *const [T]) } + /// let val = 0x12345678_i32; + /// let uninit = MaybeUninit::new(val); + /// let uninit_bytes = uninit.as_bytes(); + /// let bytes = unsafe { uninit_bytes.assume_init_ref() }; + /// assert_eq!(bytes, val.to_ne_bytes()); + /// ``` + #[unstable(feature = "maybe_uninit_as_bytes", issue = "93092")] + pub const fn as_bytes(&self) -> &[MaybeUninit] { + // SAFETY: MaybeUninit is always valid, even for padding bytes + unsafe { + slice::from_raw_parts(self.as_ptr().cast::>(), super::size_of::()) + } } - /// Assuming all the elements are initialized, get a mutable slice to them. + /// Returns the contents of this `MaybeUninit` as a mutable slice of potentially uninitialized + /// bytes. /// - /// # Safety + /// Note that even if the contents of a `MaybeUninit` have been initialized, the value may still + /// contain padding bytes which are left uninitialized. /// - /// It is up to the caller to guarantee that the `MaybeUninit` elements - /// really are in an initialized state. - /// Calling this when the content is not yet fully initialized causes undefined behavior. + /// # Examples /// - /// See [`assume_init_mut`] for more details and examples. + /// ``` + /// #![feature(maybe_uninit_as_bytes)] + /// use std::mem::MaybeUninit; /// - /// [`assume_init_mut`]: MaybeUninit::assume_init_mut + /// let val = 0x12345678_i32; + /// let mut uninit = MaybeUninit::new(val); + /// let uninit_bytes = uninit.as_bytes_mut(); + /// if cfg!(target_endian = "little") { + /// uninit_bytes[0].write(0xcd); + /// } else { + /// uninit_bytes[3].write(0xcd); + /// } + /// let val2 = unsafe { uninit.assume_init() }; + /// assert_eq!(val2, 0x123456cd); + /// ``` + #[unstable(feature = "maybe_uninit_as_bytes", issue = "93092")] + pub const fn as_bytes_mut(&mut self) -> &mut [MaybeUninit] { + // SAFETY: MaybeUninit is always valid, even for padding bytes + unsafe { + slice::from_raw_parts_mut( + self.as_mut_ptr().cast::>(), + super::size_of::(), + ) + } + } + + /// Deprecated version of [`slice::assume_init_ref`]. #[unstable(feature = "maybe_uninit_slice", issue = "63569")] - #[inline(always)] + #[deprecated( + note = "replaced by inherent assume_init_ref method; will eventually be removed", + since = "1.83.0" + )] + pub const unsafe fn slice_assume_init_ref(slice: &[Self]) -> &[T] { + // SAFETY: Same for both methods. + unsafe { slice.assume_init_ref() } + } + + /// Deprecated version of [`slice::assume_init_mut`]. + #[unstable(feature = "maybe_uninit_slice", issue = "63569")] + #[deprecated( + note = "replaced by inherent assume_init_mut method; will eventually be removed", + since = "1.83.0" + )] pub const unsafe fn slice_assume_init_mut(slice: &mut [Self]) -> &mut [T] { - // SAFETY: similar to safety notes for `slice_get_ref`, but we have a - // mutable reference which is also guaranteed to be valid for writes. - unsafe { &mut *(slice as *mut [Self] as *mut [T]) } + // SAFETY: Same for both methods. + unsafe { slice.assume_init_mut() } } /// Gets a pointer to the first element of the array. @@ -1015,142 +1039,34 @@ impl MaybeUninit { this.as_mut_ptr() as *mut T } - /// Copies the elements from `src` to `this`, returning a mutable reference to the now initialized contents of `this`. - /// - /// If `T` does not implement `Copy`, use [`clone_from_slice`] - /// - /// This is similar to [`slice::copy_from_slice`]. - /// - /// # Panics - /// - /// This function will panic if the two slices have different lengths. - /// - /// # Examples - /// - /// ``` - /// #![feature(maybe_uninit_write_slice)] - /// use std::mem::MaybeUninit; - /// - /// let mut dst = [MaybeUninit::uninit(); 32]; - /// let src = [0; 32]; - /// - /// let init = MaybeUninit::copy_from_slice(&mut dst, &src); - /// - /// assert_eq!(init, src); - /// ``` - /// - /// ``` - /// #![feature(maybe_uninit_write_slice)] - /// use std::mem::MaybeUninit; - /// - /// let mut vec = Vec::with_capacity(32); - /// let src = [0; 16]; - /// - /// MaybeUninit::copy_from_slice(&mut vec.spare_capacity_mut()[..src.len()], &src); - /// - /// // SAFETY: we have just copied all the elements of len into the spare capacity - /// // the first src.len() elements of the vec are valid now. - /// unsafe { - /// vec.set_len(src.len()); - /// } - /// - /// assert_eq!(vec, src); - /// ``` - /// - /// [`clone_from_slice`]: MaybeUninit::clone_from_slice + /// Deprecated version of [`slice::write_copy_of_slice`]. #[unstable(feature = "maybe_uninit_write_slice", issue = "79995")] + #[deprecated( + note = "replaced by inherent write_copy_of_slice method; will eventually be removed", + since = "1.83.0" + )] pub fn copy_from_slice<'a>(this: &'a mut [MaybeUninit], src: &[T]) -> &'a mut [T] where T: Copy, { - // SAFETY: &[T] and &[MaybeUninit] have the same layout - let uninit_src: &[MaybeUninit] = unsafe { super::transmute(src) }; - - this.copy_from_slice(uninit_src); - - // SAFETY: Valid elements have just been copied into `this` so it is initialized - unsafe { MaybeUninit::slice_assume_init_mut(this) } + this.write_copy_of_slice(src) } - /// Clones the elements from `src` to `this`, returning a mutable reference to the now initialized contents of `this`. - /// Any already initialized elements will not be dropped. - /// - /// If `T` implements `Copy`, use [`copy_from_slice`] - /// - /// This is similar to [`slice::clone_from_slice`] but does not drop existing elements. - /// - /// # Panics - /// - /// This function will panic if the two slices have different lengths, or if the implementation of `Clone` panics. - /// - /// If there is a panic, the already cloned elements will be dropped. - /// - /// # Examples - /// - /// ``` - /// #![feature(maybe_uninit_write_slice)] - /// use std::mem::MaybeUninit; - /// - /// let mut dst = [MaybeUninit::uninit(), MaybeUninit::uninit(), MaybeUninit::uninit(), MaybeUninit::uninit(), MaybeUninit::uninit()]; - /// let src = ["wibbly".to_string(), "wobbly".to_string(), "timey".to_string(), "wimey".to_string(), "stuff".to_string()]; - /// - /// let init = MaybeUninit::clone_from_slice(&mut dst, &src); - /// - /// assert_eq!(init, src); - /// # // Prevent leaks for Miri - /// # unsafe { std::ptr::drop_in_place(init); } - /// ``` - /// - /// ``` - /// #![feature(maybe_uninit_write_slice)] - /// use std::mem::MaybeUninit; - /// - /// let mut vec = Vec::with_capacity(32); - /// let src = ["rust", "is", "a", "pretty", "cool", "language"]; - /// - /// MaybeUninit::clone_from_slice(&mut vec.spare_capacity_mut()[..src.len()], &src); - /// - /// // SAFETY: we have just cloned all the elements of len into the spare capacity - /// // the first src.len() elements of the vec are valid now. - /// unsafe { - /// vec.set_len(src.len()); - /// } - /// - /// assert_eq!(vec, src); - /// ``` - /// - /// [`copy_from_slice`]: MaybeUninit::copy_from_slice + /// Deprecated version of [`slice::write_clone_of_slice`]. #[unstable(feature = "maybe_uninit_write_slice", issue = "79995")] + #[deprecated( + note = "replaced by inherent write_clone_of_slice method; will eventually be removed", + since = "1.83.0" + )] pub fn clone_from_slice<'a>(this: &'a mut [MaybeUninit], src: &[T]) -> &'a mut [T] where T: Clone, { - // unlike copy_from_slice this does not call clone_from_slice on the slice - // this is because `MaybeUninit` does not implement Clone. - - assert_eq!(this.len(), src.len(), "destination and source slices have different lengths"); - // NOTE: We need to explicitly slice them to the same length - // for bounds checking to be elided, and the optimizer will - // generate memcpy for simple cases (for example T = u8). - let len = this.len(); - let src = &src[..len]; - - // guard is needed b/c panic might happen during a clone - let mut guard = Guard { slice: this, initialized: 0 }; - - for i in 0..len { - guard.slice[i].write(src[i].clone()); - guard.initialized += 1; - } - - super::forget(guard); - - // SAFETY: Valid elements have just been written into `this` so it is initialized - unsafe { MaybeUninit::slice_assume_init_mut(this) } + this.write_clone_of_slice(src) } - /// Fills `this` with elements by cloning `value`, returning a mutable reference to the now - /// initialized contents of `this`. + /// Fills a slice with elements by cloning `value`, returning a mutable reference to the now + /// initialized contents of the slice. /// Any previously initialized elements will not be dropped. /// /// This is similar to [`slice::fill`]. @@ -1164,27 +1080,26 @@ impl MaybeUninit { /// /// # Examples /// - /// Fill an uninit vec with 1. /// ``` /// #![feature(maybe_uninit_fill)] /// use std::mem::MaybeUninit; /// - /// let mut buf = vec![MaybeUninit::uninit(); 10]; - /// let initialized = MaybeUninit::fill(buf.as_mut_slice(), 1); + /// let mut buf = [const { MaybeUninit::uninit() }; 10]; + /// let initialized = MaybeUninit::fill(&mut buf, 1); /// assert_eq!(initialized, &mut [1; 10]); /// ``` #[doc(alias = "memset")] #[unstable(feature = "maybe_uninit_fill", issue = "117428")] - pub fn fill<'a>(this: &'a mut [MaybeUninit], value: T) -> &'a mut [T] + pub fn fill(this: &mut [MaybeUninit], value: T) -> &mut [T] where T: Clone, { SpecFill::spec_fill(this, value); // SAFETY: Valid elements have just been filled into `this` so it is initialized - unsafe { MaybeUninit::slice_assume_init_mut(this) } + unsafe { this.assume_init_mut() } } - /// Fills `this` with elements returned by calling a closure repeatedly. + /// Fills a slice with elements returned by calling a closure repeatedly. /// /// This method uses a closure to create new values. If you'd rather `Clone` a given value, use /// [`MaybeUninit::fill`]. If you want to use the `Default` trait to generate values, you can @@ -1199,17 +1114,16 @@ impl MaybeUninit { /// /// # Examples /// - /// Fill an uninit vec with the default value. /// ``` /// #![feature(maybe_uninit_fill)] /// use std::mem::MaybeUninit; /// - /// let mut buf = vec![MaybeUninit::::uninit(); 10]; - /// let initialized = MaybeUninit::fill_with(buf.as_mut_slice(), Default::default); + /// let mut buf = [const { MaybeUninit::::uninit() }; 10]; + /// let initialized = MaybeUninit::fill_with(&mut buf, Default::default); /// assert_eq!(initialized, &mut [0; 10]); /// ``` #[unstable(feature = "maybe_uninit_fill", issue = "117428")] - pub fn fill_with<'a, F>(this: &'a mut [MaybeUninit], mut f: F) -> &'a mut [T] + pub fn fill_with(this: &mut [MaybeUninit], mut f: F) -> &mut [T] where F: FnMut() -> T, { @@ -1223,13 +1137,13 @@ impl MaybeUninit { super::forget(guard); // SAFETY: Valid elements have just been written into `this` so it is initialized - unsafe { MaybeUninit::slice_assume_init_mut(this) } + unsafe { this.assume_init_mut() } } - /// Fills `this` with elements yielded by an iterator until either all elements have been + /// Fills a slice with elements yielded by an iterator until either all elements have been /// initialized or the iterator is empty. /// - /// Returns two slices. The first slice contains the initialized portion of the original slice. + /// Returns two slices. The first slice contains the initialized portion of the original slice. /// The second slice is the still-uninitialized remainder of the original slice. /// /// # Panics @@ -1241,37 +1155,51 @@ impl MaybeUninit { /// /// # Examples /// - /// Fill an uninit vec with a cycling iterator. + /// Completely filling the slice: + /// /// ``` /// #![feature(maybe_uninit_fill)] /// use std::mem::MaybeUninit; /// - /// let mut buf = vec![MaybeUninit::uninit(); 5]; + /// let mut buf = [const { MaybeUninit::uninit() }; 5]; /// /// let iter = [1, 2, 3].into_iter().cycle(); /// let (initialized, remainder) = MaybeUninit::fill_from(&mut buf, iter); /// /// assert_eq!(initialized, &mut [1, 2, 3, 1, 2]); - /// assert_eq!(0, remainder.len()); + /// assert_eq!(remainder.len(), 0); /// ``` /// - /// Fill an uninit vec, but not completely. + /// Partially filling the slice: + /// /// ``` /// #![feature(maybe_uninit_fill)] /// use std::mem::MaybeUninit; /// - /// let mut buf = vec![MaybeUninit::uninit(); 5]; + /// let mut buf = [const { MaybeUninit::uninit() }; 5]; /// let iter = [1, 2]; /// let (initialized, remainder) = MaybeUninit::fill_from(&mut buf, iter); /// /// assert_eq!(initialized, &mut [1, 2]); /// assert_eq!(remainder.len(), 3); /// ``` + /// + /// Checking an iterator after filling a slice: + /// + /// ``` + /// #![feature(maybe_uninit_fill)] + /// use std::mem::MaybeUninit; + /// + /// let mut buf = [const { MaybeUninit::uninit() }; 3]; + /// let mut iter = [1, 2, 3, 4, 5].into_iter(); + /// let (initialized, remainder) = MaybeUninit::fill_from(&mut buf, iter.by_ref()); + /// + /// assert_eq!(initialized, &mut [1, 2, 3]); + /// assert_eq!(remainder.len(), 0); + /// assert_eq!(iter.as_slice(), &[4, 5]); + /// ``` #[unstable(feature = "maybe_uninit_fill", issue = "117428")] - pub fn fill_from<'a, I>( - this: &'a mut [MaybeUninit], - it: I, - ) -> (&'a mut [T], &'a mut [MaybeUninit]) + pub fn fill_from(this: &mut [MaybeUninit], it: I) -> (&mut [T], &mut [MaybeUninit]) where I: IntoIterator, { @@ -1291,70 +1219,168 @@ impl MaybeUninit { // SAFETY: Valid elements have just been written into `init`, so that portion // of `this` is initialized. - (unsafe { MaybeUninit::slice_assume_init_mut(initted) }, remainder) + (unsafe { initted.assume_init_mut() }, remainder) } - /// Returns the contents of this `MaybeUninit` as a slice of potentially uninitialized bytes. + /// Deprecated version of [`slice::as_bytes`]. + #[unstable(feature = "maybe_uninit_as_bytes", issue = "93092")] + #[deprecated( + note = "replaced by inherent as_bytes method; will eventually be removed", + since = "1.83.0" + )] + pub fn slice_as_bytes(this: &[MaybeUninit]) -> &[MaybeUninit] { + this.as_bytes() + } + + /// Deprecated version of [`slice::as_bytes_mut`]. + #[unstable(feature = "maybe_uninit_as_bytes", issue = "93092")] + #[deprecated( + note = "replaced by inherent as_bytes_mut method; will eventually be removed", + since = "1.83.0" + )] + pub fn slice_as_bytes_mut(this: &mut [MaybeUninit]) -> &mut [MaybeUninit] { + this.as_bytes_mut() + } +} + +impl [MaybeUninit] { + /// Copies the elements from `src` to `self`, + /// returning a mutable reference to the now initialized contents of `self`. /// - /// Note that even if the contents of a `MaybeUninit` have been initialized, the value may still - /// contain padding bytes which are left uninitialized. + /// If `T` does not implement `Copy`, use [`write_clone_of_slice`] instead. + /// + /// This is similar to [`slice::copy_from_slice`]. + /// + /// # Panics + /// + /// This function will panic if the two slices have different lengths. /// /// # Examples /// /// ``` - /// #![feature(maybe_uninit_as_bytes, maybe_uninit_slice)] + /// #![feature(maybe_uninit_write_slice)] /// use std::mem::MaybeUninit; /// - /// let val = 0x12345678_i32; - /// let uninit = MaybeUninit::new(val); - /// let uninit_bytes = uninit.as_bytes(); - /// let bytes = unsafe { MaybeUninit::slice_assume_init_ref(uninit_bytes) }; - /// assert_eq!(bytes, val.to_ne_bytes()); + /// let mut dst = [MaybeUninit::uninit(); 32]; + /// let src = [0; 32]; + /// + /// let init = dst.write_copy_of_slice(&src); + /// + /// assert_eq!(init, src); /// ``` - #[unstable(feature = "maybe_uninit_as_bytes", issue = "93092")] - pub fn as_bytes(&self) -> &[MaybeUninit] { - // SAFETY: MaybeUninit is always valid, even for padding bytes - unsafe { - slice::from_raw_parts(self.as_ptr() as *const MaybeUninit, mem::size_of::()) - } + /// + /// ``` + /// #![feature(maybe_uninit_write_slice)] + /// + /// let mut vec = Vec::with_capacity(32); + /// let src = [0; 16]; + /// + /// vec.spare_capacity_mut()[..src.len()].write_copy_of_slice(&src); + /// + /// // SAFETY: we have just copied all the elements of len into the spare capacity + /// // the first src.len() elements of the vec are valid now. + /// unsafe { + /// vec.set_len(src.len()); + /// } + /// + /// assert_eq!(vec, src); + /// ``` + /// + /// [`write_clone_of_slice`]: slice::write_clone_of_slice + #[unstable(feature = "maybe_uninit_write_slice", issue = "79995")] + pub const fn write_copy_of_slice(&mut self, src: &[T]) -> &mut [T] + where + T: Copy, + { + // SAFETY: &[T] and &[MaybeUninit] have the same layout + let uninit_src: &[MaybeUninit] = unsafe { super::transmute(src) }; + + self.copy_from_slice(uninit_src); + + // SAFETY: Valid elements have just been copied into `self` so it is initialized + unsafe { self.assume_init_mut() } } - /// Returns the contents of this `MaybeUninit` as a mutable slice of potentially uninitialized - /// bytes. + /// Clones the elements from `src` to `self`, + /// returning a mutable reference to the now initialized contents of `self`. + /// Any already initialized elements will not be dropped. /// - /// Note that even if the contents of a `MaybeUninit` have been initialized, the value may still - /// contain padding bytes which are left uninitialized. + /// If `T` implements `Copy`, use [`write_copy_of_slice`] instead. + /// + /// This is similar to [`slice::clone_from_slice`] but does not drop existing elements. + /// + /// # Panics + /// + /// This function will panic if the two slices have different lengths, or if the implementation of `Clone` panics. + /// + /// If there is a panic, the already cloned elements will be dropped. /// /// # Examples /// /// ``` - /// #![feature(maybe_uninit_as_bytes)] + /// #![feature(maybe_uninit_write_slice)] /// use std::mem::MaybeUninit; /// - /// let val = 0x12345678_i32; - /// let mut uninit = MaybeUninit::new(val); - /// let uninit_bytes = uninit.as_bytes_mut(); - /// if cfg!(target_endian = "little") { - /// uninit_bytes[0].write(0xcd); - /// } else { - /// uninit_bytes[3].write(0xcd); + /// let mut dst = [const { MaybeUninit::uninit() }; 5]; + /// let src = ["wibbly", "wobbly", "timey", "wimey", "stuff"].map(|s| s.to_string()); + /// + /// let init = dst.write_clone_of_slice(&src); + /// + /// assert_eq!(init, src); + /// + /// # // Prevent leaks for Miri + /// # unsafe { std::ptr::drop_in_place(init); } + /// ``` + /// + /// ``` + /// #![feature(maybe_uninit_write_slice)] + /// + /// let mut vec = Vec::with_capacity(32); + /// let src = ["rust", "is", "a", "pretty", "cool", "language"].map(|s| s.to_string()); + /// + /// vec.spare_capacity_mut()[..src.len()].write_clone_of_slice(&src); + /// + /// // SAFETY: we have just cloned all the elements of len into the spare capacity + /// // the first src.len() elements of the vec are valid now. + /// unsafe { + /// vec.set_len(src.len()); /// } - /// let val2 = unsafe { uninit.assume_init() }; - /// assert_eq!(val2, 0x123456cd); + /// + /// assert_eq!(vec, src); /// ``` - #[unstable(feature = "maybe_uninit_as_bytes", issue = "93092")] - pub fn as_bytes_mut(&mut self) -> &mut [MaybeUninit] { - // SAFETY: MaybeUninit is always valid, even for padding bytes - unsafe { - slice::from_raw_parts_mut( - self.as_mut_ptr() as *mut MaybeUninit, - mem::size_of::(), - ) + /// + /// [`write_copy_of_slice`]: slice::write_copy_of_slice + #[unstable(feature = "maybe_uninit_write_slice", issue = "79995")] + pub fn write_clone_of_slice(&mut self, src: &[T]) -> &mut [T] + where + T: Clone, + { + // unlike copy_from_slice this does not call clone_from_slice on the slice + // this is because `MaybeUninit` does not implement Clone. + + assert_eq!(self.len(), src.len(), "destination and source slices have different lengths"); + + // NOTE: We need to explicitly slice them to the same length + // for bounds checking to be elided, and the optimizer will + // generate memcpy for simple cases (for example T = u8). + let len = self.len(); + let src = &src[..len]; + + // guard is needed b/c panic might happen during a clone + let mut guard = Guard { slice: self, initialized: 0 }; + + for i in 0..len { + guard.slice[i].write(src[i].clone()); + guard.initialized += 1; } + + super::forget(guard); + + // SAFETY: Valid elements have just been written into `self` so it is initialized + unsafe { self.assume_init_mut() } } - /// Returns the contents of this slice of `MaybeUninit` as a slice of potentially uninitialized - /// bytes. + /// Returns the contents of this `MaybeUninit` as a slice of potentially uninitialized bytes. /// /// Note that even if the contents of a `MaybeUninit` have been initialized, the value may still /// contain padding bytes which are left uninitialized. @@ -1366,21 +1392,22 @@ impl MaybeUninit { /// use std::mem::MaybeUninit; /// /// let uninit = [MaybeUninit::new(0x1234u16), MaybeUninit::new(0x5678u16)]; - /// let uninit_bytes = MaybeUninit::slice_as_bytes(&uninit); - /// let bytes = unsafe { MaybeUninit::slice_assume_init_ref(&uninit_bytes) }; + /// let uninit_bytes = uninit.as_bytes(); + /// let bytes = unsafe { uninit_bytes.assume_init_ref() }; /// let val1 = u16::from_ne_bytes(bytes[0..2].try_into().unwrap()); /// let val2 = u16::from_ne_bytes(bytes[2..4].try_into().unwrap()); /// assert_eq!(&[val1, val2], &[0x1234u16, 0x5678u16]); /// ``` #[unstable(feature = "maybe_uninit_as_bytes", issue = "93092")] - pub fn slice_as_bytes(this: &[MaybeUninit]) -> &[MaybeUninit] { - let bytes = mem::size_of_val(this); + pub const fn as_bytes(&self) -> &[MaybeUninit] { // SAFETY: MaybeUninit is always valid, even for padding bytes - unsafe { slice::from_raw_parts(this.as_ptr() as *const MaybeUninit, bytes) } + unsafe { + slice::from_raw_parts(self.as_ptr().cast::>(), super::size_of_val(self)) + } } - /// Returns the contents of this mutable slice of `MaybeUninit` as a mutable slice of - /// potentially uninitialized bytes. + /// Returns the contents of this `MaybeUninit` slice as a mutable slice of potentially + /// uninitialized bytes. /// /// Note that even if the contents of a `MaybeUninit` have been initialized, the value may still /// contain padding bytes which are left uninitialized. @@ -1393,8 +1420,8 @@ impl MaybeUninit { /// /// let mut uninit = [MaybeUninit::::uninit(), MaybeUninit::::uninit()]; /// let uninit_bytes = MaybeUninit::slice_as_bytes_mut(&mut uninit); - /// MaybeUninit::copy_from_slice(uninit_bytes, &[0x12, 0x34, 0x56, 0x78]); - /// let vals = unsafe { MaybeUninit::slice_assume_init_ref(&uninit) }; + /// uninit_bytes.write_copy_of_slice(&[0x12, 0x34, 0x56, 0x78]); + /// let vals = unsafe { uninit.assume_init_ref() }; /// if cfg!(target_endian = "little") { /// assert_eq!(vals, &[0x3412u16, 0x7856u16]); /// } else { @@ -1402,10 +1429,74 @@ impl MaybeUninit { /// } /// ``` #[unstable(feature = "maybe_uninit_as_bytes", issue = "93092")] - pub fn slice_as_bytes_mut(this: &mut [MaybeUninit]) -> &mut [MaybeUninit] { - let bytes = mem::size_of_val(this); + pub const fn as_bytes_mut(&mut self) -> &mut [MaybeUninit] { // SAFETY: MaybeUninit is always valid, even for padding bytes - unsafe { slice::from_raw_parts_mut(this.as_mut_ptr() as *mut MaybeUninit, bytes) } + unsafe { + slice::from_raw_parts_mut( + self.as_mut_ptr() as *mut MaybeUninit, + super::size_of_val(self), + ) + } + } + + /// Drops the contained values in place. + /// + /// # Safety + /// + /// It is up to the caller to guarantee that every `MaybeUninit` in the slice + /// really is in an initialized state. Calling this when the content is not yet + /// fully initialized causes undefined behavior. + /// + /// On top of that, all additional invariants of the type `T` must be + /// satisfied, as the `Drop` implementation of `T` (or its members) may + /// rely on this. For example, setting a `Vec` to an invalid but + /// non-null address makes it initialized (under the current implementation; + /// this does not constitute a stable guarantee), because the only + /// requirement the compiler knows about it is that the data pointer must be + /// non-null. Dropping such a `Vec` however will cause undefined + /// behaviour. + #[unstable(feature = "maybe_uninit_slice", issue = "63569")] + #[inline(always)] + pub unsafe fn assume_init_drop(&mut self) { + if !self.is_empty() { + // SAFETY: the caller must guarantee that every element of `self` + // is initialized and satisfies all invariants of `T`. + // Dropping the value in place is safe if that is the case. + unsafe { ptr::drop_in_place(self as *mut [MaybeUninit] as *mut [T]) } + } + } + + /// Gets a shared reference to the contained value. + /// + /// # Safety + /// + /// Calling this when the content is not yet fully initialized causes undefined + /// behavior: it is up to the caller to guarantee that every `MaybeUninit` in + /// the slice really is in an initialized state. + #[unstable(feature = "maybe_uninit_slice", issue = "63569")] + #[inline(always)] + pub const unsafe fn assume_init_ref(&self) -> &[T] { + // SAFETY: casting `slice` to a `*const [T]` is safe since the caller guarantees that + // `slice` is initialized, and `MaybeUninit` is guaranteed to have the same layout as `T`. + // The pointer obtained is valid since it refers to memory owned by `slice` which is a + // reference and thus guaranteed to be valid for reads. + unsafe { &*(self as *const Self as *const [T]) } + } + + /// Gets a mutable (unique) reference to the contained value. + /// + /// # Safety + /// + /// Calling this when the content is not yet fully initialized causes undefined + /// behavior: it is up to the caller to guarantee that every `MaybeUninit` in the + /// slice really is in an initialized state. For instance, `.assume_init_mut()` cannot + /// be used to initialize a `MaybeUninit` slice. + #[unstable(feature = "maybe_uninit_slice", issue = "63569")] + #[inline(always)] + pub const unsafe fn assume_init_mut(&mut self) -> &mut [T] { + // SAFETY: similar to safety notes for `slice_get_ref`, but we have a + // mutable reference which is also guaranteed to be valid for writes. + unsafe { &mut *(self as *mut Self as *mut [T]) } } } @@ -1458,7 +1549,7 @@ impl<'a, T> Drop for Guard<'a, T> { let initialized_part = &mut self.slice[..self.initialized]; // SAFETY: this raw sub-slice will contain only initialized objects. unsafe { - crate::ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(initialized_part)); + initialized_part.assume_init_drop(); } } } diff --git a/core/src/mem/mod.rs b/core/src/mem/mod.rs index 4cf52042a57f6..caab7a6ddb52f 100644 --- a/core/src/mem/mod.rs +++ b/core/src/mem/mod.rs @@ -226,31 +226,27 @@ pub fn forget_unsized(t: T) { /// # Examples /// /// ``` -/// use std::mem; -/// /// // Some primitives -/// assert_eq!(4, mem::size_of::()); -/// assert_eq!(8, mem::size_of::()); -/// assert_eq!(0, mem::size_of::<()>()); +/// assert_eq!(4, size_of::()); +/// assert_eq!(8, size_of::()); +/// assert_eq!(0, size_of::<()>()); /// /// // Some arrays -/// assert_eq!(8, mem::size_of::<[i32; 2]>()); -/// assert_eq!(12, mem::size_of::<[i32; 3]>()); -/// assert_eq!(0, mem::size_of::<[i32; 0]>()); +/// assert_eq!(8, size_of::<[i32; 2]>()); +/// assert_eq!(12, size_of::<[i32; 3]>()); +/// assert_eq!(0, size_of::<[i32; 0]>()); /// /// /// // Pointer size equality -/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::<*const i32>()); -/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::>()); -/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::>()); -/// assert_eq!(mem::size_of::>(), mem::size_of::>>()); +/// assert_eq!(size_of::<&i32>(), size_of::<*const i32>()); +/// assert_eq!(size_of::<&i32>(), size_of::>()); +/// assert_eq!(size_of::<&i32>(), size_of::>()); +/// assert_eq!(size_of::>(), size_of::>>()); /// ``` /// /// Using `#[repr(C)]`. /// /// ``` -/// use std::mem; -/// /// #[repr(C)] /// struct FieldStruct { /// first: u8, @@ -265,13 +261,13 @@ pub fn forget_unsized(t: T) { /// // The size of the third field is 1, so add 1 to the size. Size is 5. /// // Finally, the alignment of the struct is 2 (because the largest alignment amongst its /// // fields is 2), so add 1 to the size for padding. Size is 6. -/// assert_eq!(6, mem::size_of::()); +/// assert_eq!(6, size_of::()); /// /// #[repr(C)] /// struct TupleStruct(u8, u16, u8); /// /// // Tuple structs follow the same rules. -/// assert_eq!(6, mem::size_of::()); +/// assert_eq!(6, size_of::()); /// /// // Note that reordering the fields can lower the size. We can remove both padding bytes /// // by putting `third` before `second`. @@ -282,7 +278,7 @@ pub fn forget_unsized(t: T) { /// second: u16 /// } /// -/// assert_eq!(4, mem::size_of::()); +/// assert_eq!(4, size_of::()); /// /// // Union size is the size of the largest field. /// #[repr(C)] @@ -291,7 +287,7 @@ pub fn forget_unsized(t: T) { /// larger: u16 /// } /// -/// assert_eq!(2, mem::size_of::()); +/// assert_eq!(2, size_of::()); /// ``` /// /// [alignment]: align_of @@ -320,20 +316,18 @@ pub const fn size_of() -> usize { /// # Examples /// /// ``` -/// use std::mem; -/// -/// assert_eq!(4, mem::size_of_val(&5i32)); +/// assert_eq!(4, size_of_val(&5i32)); /// /// let x: [u8; 13] = [0; 13]; /// let y: &[u8] = &x; -/// assert_eq!(13, mem::size_of_val(y)); +/// assert_eq!(13, size_of_val(y)); /// ``` /// /// [`size_of::()`]: size_of #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_size_of_val", issue = "46571")] +#[rustc_const_stable(feature = "const_size_of_val", since = "1.85.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "mem_size_of_val")] pub const fn size_of_val(val: &T) -> usize { // SAFETY: `val` is a reference, so it's a valid raw pointer @@ -381,7 +375,7 @@ pub const fn size_of_val(val: &T) -> usize { /// #![feature(layout_for_ptr)] /// use std::mem; /// -/// assert_eq!(4, mem::size_of_val(&5i32)); +/// assert_eq!(4, size_of_val(&5i32)); /// /// let x: [u8; 13] = [0; 13]; /// let y: &[u8] = &x; @@ -390,7 +384,6 @@ pub const fn size_of_val(val: &T) -> usize { #[inline] #[must_use] #[unstable(feature = "layout_for_ptr", issue = "69835")] -#[rustc_const_unstable(feature = "const_size_of_val_raw", issue = "46571")] pub const unsafe fn size_of_val_raw(val: *const T) -> usize { // SAFETY: the caller must provide a valid raw pointer unsafe { intrinsics::size_of_val(val) } @@ -455,9 +448,7 @@ pub fn min_align_of_val(val: &T) -> usize { /// # Examples /// /// ``` -/// use std::mem; -/// -/// assert_eq!(4, mem::align_of::()); +/// assert_eq!(4, align_of::()); /// ``` #[inline(always)] #[must_use] @@ -478,14 +469,12 @@ pub const fn align_of() -> usize { /// # Examples /// /// ``` -/// use std::mem; -/// -/// assert_eq!(4, mem::align_of_val(&5i32)); +/// assert_eq!(4, align_of_val(&5i32)); /// ``` #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_align_of_val", issue = "46571")] +#[rustc_const_stable(feature = "const_align_of_val", since = "1.85.0")] #[allow(deprecated)] pub const fn align_of_val(val: &T) -> usize { // SAFETY: val is a reference, so it's a valid raw pointer @@ -534,7 +523,6 @@ pub const fn align_of_val(val: &T) -> usize { #[inline] #[must_use] #[unstable(feature = "layout_for_ptr", issue = "69835")] -#[rustc_const_unstable(feature = "const_align_of_val_raw", issue = "46571")] pub const unsafe fn align_of_val_raw(val: *const T) -> usize { // SAFETY: the caller must provide a valid raw pointer unsafe { intrinsics::min_align_of_val(val) } @@ -727,12 +715,12 @@ pub unsafe fn uninitialized() -> T { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_swap", issue = "83163")] +#[rustc_const_stable(feature = "const_swap", since = "1.85.0")] #[rustc_diagnostic_item = "mem_swap"] pub const fn swap(x: &mut T, y: &mut T) { // SAFETY: `&mut` guarantees these are typed readable and writable // as well as non-overlapping. - unsafe { intrinsics::typed_swap(x, y) } + unsafe { intrinsics::typed_swap_nonoverlapping(x, y) } } /// Replaces `dest` with the default value of `T`, returning the previous `dest` value. @@ -1243,6 +1231,17 @@ pub trait SizedTypeProperties: Sized { #[doc(hidden)] #[unstable(feature = "sized_type_properties", issue = "none")] const LAYOUT: Layout = Layout::new::(); + + /// The largest safe length for a `[Self]`. + /// + /// Anything larger than this would make `size_of_val` overflow `isize::MAX`, + /// which is never allowed for a single object. + #[doc(hidden)] + #[unstable(feature = "sized_type_properties", issue = "none")] + const MAX_SLICE_LEN: usize = match size_of::() { + 0 => usize::MAX, + n => (isize::MAX as usize) / n, + }; } #[doc(hidden)] #[unstable(feature = "sized_type_properties", issue = "none")] diff --git a/core/src/mem/transmutability.rs b/core/src/mem/transmutability.rs index 7fa3c33439170..782b826448a32 100644 --- a/core/src/mem/transmutability.rs +++ b/core/src/mem/transmutability.rs @@ -32,7 +32,7 @@ use crate::marker::{ConstParamTy_, UnsizedConstParamTy}; /// src: ManuallyDrop::new(src), /// }; /// -/// let dst = transmute.dst; +/// let dst = unsafe { transmute.dst }; /// /// ManuallyDrop::into_inner(dst) /// } @@ -84,7 +84,8 @@ use crate::marker::{ConstParamTy_, UnsizedConstParamTy}; /// `usize` is stable, but not portable. #[unstable(feature = "transmutability", issue = "99571")] #[lang = "transmute_trait"] -#[rustc_deny_explicit_impl(implement_via_object = false)] +#[rustc_deny_explicit_impl] +#[rustc_do_not_implement_via_object] #[rustc_coinductive] pub unsafe trait TransmuteFrom where @@ -152,7 +153,7 @@ pub struct Assume { /// /// ```compile_fail,E0277 /// #![feature(transmutability)] - /// use core::mem::{align_of, TransmuteFrom}; + /// use core::mem::TransmuteFrom; /// /// assert_eq!(align_of::<[u8; 2]>(), 1); /// assert_eq!(align_of::(), 2); @@ -171,7 +172,7 @@ pub struct Assume { /// /// ```rust /// #![feature(pointer_is_aligned_to, transmutability)] - /// use core::mem::{align_of, Assume, TransmuteFrom}; + /// use core::mem::{Assume, TransmuteFrom}; /// /// let src: &[u8; 2] = &[0xFF, 0xFF]; /// @@ -336,7 +337,7 @@ impl Assume { /// transmutability, /// )] /// #![allow(incomplete_features)] - /// use core::mem::{align_of, Assume, TransmuteFrom}; + /// use core::mem::{Assume, TransmuteFrom}; /// /// /// Attempts to transmute `src` to `&Dst`. /// /// diff --git a/core/src/net/display_buffer.rs b/core/src/net/display_buffer.rs index bab84a97308b3..625ad5401f5c0 100644 --- a/core/src/net/display_buffer.rs +++ b/core/src/net/display_buffer.rs @@ -2,23 +2,23 @@ use crate::mem::MaybeUninit; use crate::{fmt, str}; /// Used for slow path in `Display` implementations when alignment is required. -pub struct DisplayBuffer { +pub(super) struct DisplayBuffer { buf: [MaybeUninit; SIZE], len: usize, } impl DisplayBuffer { #[inline] - pub const fn new() -> Self { + pub(super) const fn new() -> Self { Self { buf: [MaybeUninit::uninit(); SIZE], len: 0 } } #[inline] - pub fn as_str(&self) -> &str { + pub(super) fn as_str(&self) -> &str { // SAFETY: `buf` is only written to by the `fmt::Write::write_str` implementation // which writes a valid UTF-8 string to `buf` and correctly sets `len`. unsafe { - let s = MaybeUninit::slice_assume_init_ref(&self.buf[..self.len]); + let s = self.buf[..self.len].assume_init_ref(); str::from_utf8_unchecked(s) } } @@ -29,7 +29,7 @@ impl fmt::Write for DisplayBuffer { let bytes = s.as_bytes(); if let Some(buf) = self.buf.get_mut(self.len..(self.len + bytes.len())) { - MaybeUninit::copy_from_slice(buf, bytes); + buf.write_copy_of_slice(bytes); self.len += bytes.len(); Ok(()) } else { diff --git a/core/src/net/ip_addr.rs b/core/src/net/ip_addr.rs index 6746f0b2b316b..8e4417ec461b8 100644 --- a/core/src/net/ip_addr.rs +++ b/core/src/net/ip_addr.rs @@ -451,6 +451,28 @@ impl IpAddr { IpAddr::V6(v6) => v6.to_canonical(), } } + + /// Returns the eight-bit integers this address consists of as a slice. + /// + /// # Examples + /// + /// ``` + /// #![feature(ip_as_octets)] + /// + /// use std::net::{Ipv4Addr, Ipv6Addr, IpAddr}; + /// + /// assert_eq!(IpAddr::V4(Ipv4Addr::LOCALHOST).as_octets(), &[127, 0, 0, 1]); + /// assert_eq!(IpAddr::V6(Ipv6Addr::LOCALHOST).as_octets(), + /// &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) + /// ``` + #[unstable(feature = "ip_as_octets", issue = "137259")] + #[inline] + pub const fn as_octets(&self) -> &[u8] { + match self { + IpAddr::V4(ip) => ip.as_octets().as_slice(), + IpAddr::V6(ip) => ip.as_octets().as_slice(), + } + } } impl Ipv4Addr { @@ -527,7 +549,7 @@ impl Ipv4Addr { /// ``` /// use std::net::Ipv4Addr; /// - /// let addr = Ipv4Addr::from(0x12345678); + /// let addr = Ipv4Addr::from_bits(0x12345678); /// assert_eq!(Ipv4Addr::new(0x12, 0x34, 0x56, 0x78), addr); /// ``` #[rustc_const_stable(feature = "ip_bits", since = "1.80.0")] @@ -616,6 +638,25 @@ impl Ipv4Addr { Ipv4Addr { octets } } + /// Returns the four eight-bit integers that make up this address + /// as a slice. + /// + /// # Examples + /// + /// ``` + /// #![feature(ip_as_octets)] + /// + /// use std::net::Ipv4Addr; + /// + /// let addr = Ipv4Addr::new(127, 0, 0, 1); + /// assert_eq!(addr.as_octets(), &[127, 0, 0, 1]); + /// ``` + #[unstable(feature = "ip_as_octets", issue = "137259")] + #[inline] + pub const fn as_octets(&self) -> &[u8; 4] { + &self.octets + } + /// Returns [`true`] for the special 'unspecified' address (`0.0.0.0`). /// /// This property is defined in _UNIX Network Programming, Second Edition_, @@ -1294,7 +1335,7 @@ impl Ipv6Addr { /// 0x1020, 0x3040, 0x5060, 0x7080, /// 0x90A0, 0xB0C0, 0xD0E0, 0xF00D, /// ); - /// assert_eq!(0x102030405060708090A0B0C0D0E0F00D_u128, u128::from(addr)); + /// assert_eq!(0x102030405060708090A0B0C0D0E0F00D_u128, addr.to_bits()); /// ``` /// /// ``` @@ -1330,7 +1371,7 @@ impl Ipv6Addr { /// ``` /// use std::net::Ipv6Addr; /// - /// let addr = Ipv6Addr::from(0x102030405060708090A0B0C0D0E0F00D_u128); + /// let addr = Ipv6Addr::from_bits(0x102030405060708090A0B0C0D0E0F00D_u128); /// assert_eq!( /// Ipv6Addr::new( /// 0x1020, 0x3040, 0x5060, 0x7080, @@ -1539,8 +1580,9 @@ impl Ipv6Addr { /// // Addresses reserved for benchmarking (`2001:2::/48`) /// assert_eq!(Ipv6Addr::new(0x2001, 2, 0, 0, 0, 0, 0, 1,).is_global(), false); /// - /// // Addresses reserved for documentation (`2001:db8::/32`) + /// // Addresses reserved for documentation (`2001:db8::/32` and `3fff::/20`) /// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1).is_global(), false); + /// assert_eq!(Ipv6Addr::new(0x3fff, 0, 0, 0, 0, 0, 0, 0).is_global(), false); /// /// // Unique local addresses (`fc00::/7`) /// assert_eq!(Ipv6Addr::new(0xfc02, 0, 0, 0, 0, 0, 0, 1).is_global(), false); @@ -1601,8 +1643,8 @@ impl Ipv6Addr { /// ``` #[must_use] #[inline] - #[stable(feature = "ipv6_is_unique_local", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "ipv6_is_unique_local", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "ipv6_is_unique_local", since = "1.84.0")] + #[rustc_const_stable(feature = "ipv6_is_unique_local", since = "1.84.0")] pub const fn is_unique_local(&self) -> bool { (self.segments()[0] & 0xfe00) == 0xfc00 } @@ -1679,18 +1721,19 @@ impl Ipv6Addr { /// ``` #[must_use] #[inline] - #[stable(feature = "ipv6_is_unique_local", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "ipv6_is_unique_local", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "ipv6_is_unique_local", since = "1.84.0")] + #[rustc_const_stable(feature = "ipv6_is_unique_local", since = "1.84.0")] pub const fn is_unicast_link_local(&self) -> bool { (self.segments()[0] & 0xffc0) == 0xfe80 } /// Returns [`true`] if this is an address reserved for documentation - /// (`2001:db8::/32`). + /// (`2001:db8::/32` and `3fff::/20`). /// - /// This property is defined in [IETF RFC 3849]. + /// This property is defined by [IETF RFC 3849] and [IETF RFC 9637]. /// /// [IETF RFC 3849]: https://tools.ietf.org/html/rfc3849 + /// [IETF RFC 9637]: https://tools.ietf.org/html/rfc9637 /// /// # Examples /// @@ -1701,12 +1744,13 @@ impl Ipv6Addr { /// /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_documentation(), false); /// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_documentation(), true); + /// assert_eq!(Ipv6Addr::new(0x3fff, 0, 0, 0, 0, 0, 0, 0).is_documentation(), true); /// ``` #[unstable(feature = "ip", issue = "27709")] #[must_use] #[inline] pub const fn is_documentation(&self) -> bool { - (self.segments()[0] == 0x2001) && (self.segments()[1] == 0xdb8) + matches!(self.segments(), [0x2001, 0xdb8, ..] | [0x3fff, 0..=0x0fff, ..]) } /// Returns [`true`] if this is an address reserved for benchmarking (`2001:2::/48`). @@ -1998,6 +2042,25 @@ impl Ipv6Addr { pub const fn from_octets(octets: [u8; 16]) -> Ipv6Addr { Ipv6Addr { octets } } + + /// Returns the sixteen eight-bit integers the IPv6 address consists of + /// as a slice. + /// + /// # Examples + /// + /// ``` + /// #![feature(ip_as_octets)] + /// + /// use std::net::Ipv6Addr; + /// + /// assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).as_octets(), + /// &[255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + /// ``` + #[unstable(feature = "ip_as_octets", issue = "137259")] + #[inline] + pub const fn as_octets(&self) -> &[u8; 16] { + &self.octets + } } /// Writes an Ipv6Addr, conforming to the canonical style described by diff --git a/core/src/net/socket_addr.rs b/core/src/net/socket_addr.rs index 9204797e6e157..57f47e66e81e7 100644 --- a/core/src/net/socket_addr.rs +++ b/core/src/net/socket_addr.rs @@ -200,7 +200,7 @@ impl SocketAddr { /// ``` #[inline] #[stable(feature = "sockaddr_setters", since = "1.9.0")] - #[rustc_const_unstable(feature = "const_sockaddr_setters", issue = "131714")] + #[rustc_const_stable(feature = "const_sockaddr_setters", since = "CURRENT_RUSTC_VERSION")] pub const fn set_ip(&mut self, new_ip: IpAddr) { // `match (*self, new_ip)` would have us mutate a copy of self only to throw it away. match (self, new_ip) { @@ -244,7 +244,7 @@ impl SocketAddr { /// ``` #[inline] #[stable(feature = "sockaddr_setters", since = "1.9.0")] - #[rustc_const_unstable(feature = "const_sockaddr_setters", issue = "131714")] + #[rustc_const_stable(feature = "const_sockaddr_setters", since = "CURRENT_RUSTC_VERSION")] pub const fn set_port(&mut self, new_port: u16) { match *self { SocketAddr::V4(ref mut a) => a.set_port(new_port), @@ -350,7 +350,7 @@ impl SocketAddrV4 { /// ``` #[inline] #[stable(feature = "sockaddr_setters", since = "1.9.0")] - #[rustc_const_unstable(feature = "const_sockaddr_setters", issue = "131714")] + #[rustc_const_stable(feature = "const_sockaddr_setters", since = "CURRENT_RUSTC_VERSION")] pub const fn set_ip(&mut self, new_ip: Ipv4Addr) { self.ip = new_ip; } @@ -386,7 +386,7 @@ impl SocketAddrV4 { /// ``` #[inline] #[stable(feature = "sockaddr_setters", since = "1.9.0")] - #[rustc_const_unstable(feature = "const_sockaddr_setters", issue = "131714")] + #[rustc_const_stable(feature = "const_sockaddr_setters", since = "CURRENT_RUSTC_VERSION")] pub const fn set_port(&mut self, new_port: u16) { self.port = new_port; } @@ -448,7 +448,7 @@ impl SocketAddrV6 { /// ``` #[inline] #[stable(feature = "sockaddr_setters", since = "1.9.0")] - #[rustc_const_unstable(feature = "const_sockaddr_setters", issue = "131714")] + #[rustc_const_stable(feature = "const_sockaddr_setters", since = "CURRENT_RUSTC_VERSION")] pub const fn set_ip(&mut self, new_ip: Ipv6Addr) { self.ip = new_ip; } @@ -484,7 +484,7 @@ impl SocketAddrV6 { /// ``` #[inline] #[stable(feature = "sockaddr_setters", since = "1.9.0")] - #[rustc_const_unstable(feature = "const_sockaddr_setters", issue = "131714")] + #[rustc_const_stable(feature = "const_sockaddr_setters", since = "CURRENT_RUSTC_VERSION")] pub const fn set_port(&mut self, new_port: u16) { self.port = new_port; } @@ -532,7 +532,7 @@ impl SocketAddrV6 { /// ``` #[inline] #[stable(feature = "sockaddr_setters", since = "1.9.0")] - #[rustc_const_unstable(feature = "const_sockaddr_setters", issue = "131714")] + #[rustc_const_stable(feature = "const_sockaddr_setters", since = "CURRENT_RUSTC_VERSION")] pub const fn set_flowinfo(&mut self, new_flowinfo: u32) { self.flowinfo = new_flowinfo; } @@ -575,7 +575,7 @@ impl SocketAddrV6 { /// ``` #[inline] #[stable(feature = "sockaddr_setters", since = "1.9.0")] - #[rustc_const_unstable(feature = "const_sockaddr_setters", issue = "131714")] + #[rustc_const_stable(feature = "const_sockaddr_setters", since = "CURRENT_RUSTC_VERSION")] pub const fn set_scope_id(&mut self, new_scope_id: u32) { self.scope_id = new_scope_id; } diff --git a/core/src/num/bignum.rs b/core/src/num/bignum.rs index 2a47c89e2aee2..e33f58197bba5 100644 --- a/core/src/num/bignum.rs +++ b/core/src/num/bignum.rs @@ -253,12 +253,11 @@ macro_rules! define_bignum { /// Multiplies itself by `5^e` and returns its own mutable reference. pub fn mul_pow5(&mut self, mut e: usize) -> &mut $name { - use crate::mem; use crate::num::bignum::SMALL_POW5; // There are exactly n trailing zeros on 2^n, and the only relevant digit sizes // are consecutive powers of two, so this is well suited index for the table. - let table_index = mem::size_of::<$ty>().trailing_zeros() as usize; + let table_index = size_of::<$ty>().trailing_zeros() as usize; let (small_power, small_e) = SMALL_POW5[table_index]; let small_power = small_power as $ty; @@ -405,6 +404,8 @@ macro_rules! define_bignum { } } + impl crate::clone::UseCloned for $name {} + impl crate::fmt::Debug for $name { fn fmt(&self, f: &mut crate::fmt::Formatter<'_>) -> crate::fmt::Result { let sz = if self.size < 1 { 1 } else { self.size }; diff --git a/core/src/num/dec2flt/common.rs b/core/src/num/dec2flt/common.rs index 4dadf406ae8c7..a140a311c452f 100644 --- a/core/src/num/dec2flt/common.rs +++ b/core/src/num/dec2flt/common.rs @@ -8,12 +8,12 @@ pub(crate) trait ByteSlice { /// Writes a 64-bit integer as 8 bytes in little-endian order. fn write_u64(&mut self, value: u64); - /// Calculate the offset of a slice from another. + /// Calculate the difference in length between two slices. fn offset_from(&self, other: &Self) -> isize; /// Iteratively parse and consume digits from bytes. - /// Returns the same bytes with consumed digits being - /// elided. + /// + /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits. fn parse_digits(&self, func: impl FnMut(u8)) -> &Self; } @@ -39,11 +39,11 @@ impl ByteSlice for [u8] { fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self { let mut s = self; - while let Some((c, s_next)) = s.split_first() { + while let Some((c, rest)) = s.split_first() { let c = c.wrapping_sub(b'0'); if c < 10 { func(c); - s = s_next; + s = rest; } else { break; } @@ -53,7 +53,9 @@ impl ByteSlice for [u8] { } } -/// Determine if 8 bytes are all decimal digits. +/// Determine if all characters in an 8-byte byte string (represented as a `u64`) are all decimal +/// digits. +/// /// This does not care about the order in which the bytes were loaded. pub(crate) fn is_8digits(v: u64) -> bool { let a = v.wrapping_add(0x4646_4646_4646_4646); @@ -61,19 +63,20 @@ pub(crate) fn is_8digits(v: u64) -> bool { (a | b) & 0x8080_8080_8080_8080 == 0 } -/// A custom 64-bit floating point type, representing `f * 2^e`. -/// e is biased, so it be directly shifted into the exponent bits. +/// A custom 64-bit floating point type, representing `m * 2^p`. +/// p is biased, so it be directly shifted into the exponent bits. #[derive(Debug, Copy, Clone, PartialEq, Eq, Default)] pub struct BiasedFp { /// The significant digits. - pub f: u64, + pub m: u64, /// The biased, binary exponent. - pub e: i32, + pub p_biased: i32, } impl BiasedFp { + /// Represent `0 ^ p` #[inline] - pub const fn zero_pow2(e: i32) -> Self { - Self { f: 0, e } + pub const fn zero_pow2(p_biased: i32) -> Self { + Self { m: 0, p_biased } } } diff --git a/core/src/num/dec2flt/decimal.rs b/core/src/num/dec2flt/decimal.rs index be9c0eccd5eb8..db7176c124318 100644 --- a/core/src/num/dec2flt/decimal.rs +++ b/core/src/num/dec2flt/decimal.rs @@ -1,358 +1,87 @@ -//! Arbitrary-precision decimal class for fallback algorithms. -//! -//! This is only used if the fast-path (native floats) and -//! the Eisel-Lemire algorithm are unable to unambiguously -//! determine the float. -//! -//! The technique used is "Simple Decimal Conversion", developed -//! by Nigel Tao and Ken Thompson. A detailed description of the -//! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion", -//! available online: . - -use crate::num::dec2flt::common::{ByteSlice, is_8digits}; - -#[derive(Clone)] +//! Representation of a float as the significant digits and exponent. + +use crate::num::dec2flt::float::RawFloat; +use crate::num::dec2flt::fpu::set_precision; + +const INT_POW10: [u64; 16] = [ + 1, + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000, + 10000000000, + 100000000000, + 1000000000000, + 10000000000000, + 100000000000000, + 1000000000000000, +]; + +/// A floating point number with up to 64 bits of mantissa and an `i64` exponent. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct Decimal { - /// The number of significant digits in the decimal. - pub num_digits: usize, - /// The offset of the decimal point in the significant digits. - pub decimal_point: i32, - /// If the number of significant digits stored in the decimal is truncated. - pub truncated: bool, - /// Buffer of the raw digits, in the range [0, 9]. - pub digits: [u8; Self::MAX_DIGITS], + pub exponent: i64, + pub mantissa: u64, + pub negative: bool, + pub many_digits: bool, } -impl Default for Decimal { - fn default() -> Self { - Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] } +impl Decimal { + /// Detect if the float can be accurately reconstructed from native floats. + #[inline] + fn can_use_fast_path(&self) -> bool { + F::MIN_EXPONENT_FAST_PATH <= self.exponent + && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH + && self.mantissa <= F::MAX_MANTISSA_FAST_PATH + && !self.many_digits } -} -impl Decimal { - /// The maximum number of digits required to unambiguously round a float. - /// - /// For a double-precision IEEE 754 float, this required 767 digits, - /// so we store the max digits + 1. - /// - /// We can exactly represent a float in radix `b` from radix 2 if - /// `b` is divisible by 2. This function calculates the exact number of - /// digits required to exactly represent that float. - /// - /// According to the "Handbook of Floating Point Arithmetic", - /// for IEEE754, with emin being the min exponent, p2 being the - /// precision, and b being the radix, the number of digits follows as: + /// Try turning the decimal into an exact float representation, using machine-sized integers + /// and floats. /// - /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋` + /// This is extracted into a separate function so that it can be attempted before constructing + /// a Decimal. This only works if both the mantissa and the exponent + /// can be exactly represented as a machine float, since IEE-754 guarantees + /// no rounding will occur. /// - /// For f32, this follows as: - /// emin = -126 - /// p2 = 24 - /// - /// For f64, this follows as: - /// emin = -1022 - /// p2 = 53 - /// - /// In Python: - /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))` - pub const MAX_DIGITS: usize = 768; - /// The max digits that can be exactly represented in a 64-bit integer. - pub const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19; - pub const DECIMAL_POINT_RANGE: i32 = 2047; - - /// Append a digit to the buffer. - pub fn try_add_digit(&mut self, digit: u8) { - if self.num_digits < Self::MAX_DIGITS { - self.digits[self.num_digits] = digit; - } - self.num_digits += 1; - } - - /// Trim trailing zeros from the buffer. - pub fn trim(&mut self) { - // All of the following calls to `Decimal::trim` can't panic because: - // - // 1. `parse_decimal` sets `num_digits` to a max of `Decimal::MAX_DIGITS`. - // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`. - // 3. `left_shift` `num_digits` to a max of `Decimal::MAX_DIGITS`. - // - // Trim is only called in `right_shift` and `left_shift`. - debug_assert!(self.num_digits <= Self::MAX_DIGITS); - while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 { - self.num_digits -= 1; - } - } - - pub fn round(&self) -> u64 { - if self.num_digits == 0 || self.decimal_point < 0 { - return 0; - } else if self.decimal_point > 18 { - return 0xFFFF_FFFF_FFFF_FFFF_u64; - } - let dp = self.decimal_point as usize; - let mut n = 0_u64; - for i in 0..dp { - n *= 10; - if i < self.num_digits { - n += self.digits[i] as u64; - } - } - let mut round_up = false; - if dp < self.num_digits { - round_up = self.digits[dp] >= 5; - if self.digits[dp] == 5 && dp + 1 == self.num_digits { - round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0)) - } - } - if round_up { - n += 1; - } - n - } - - /// Computes decimal * 2^shift. - pub fn left_shift(&mut self, shift: usize) { - if self.num_digits == 0 { - return; - } - let num_new_digits = number_of_digits_decimal_left_shift(self, shift); - let mut read_index = self.num_digits; - let mut write_index = self.num_digits + num_new_digits; - let mut n = 0_u64; - while read_index != 0 { - read_index -= 1; - write_index -= 1; - n += (self.digits[read_index] as u64) << shift; - let quotient = n / 10; - let remainder = n - (10 * quotient); - if write_index < Self::MAX_DIGITS { - self.digits[write_index] = remainder as u8; - } else if remainder > 0 { - self.truncated = true; - } - n = quotient; - } - while n > 0 { - write_index -= 1; - let quotient = n / 10; - let remainder = n - (10 * quotient); - if write_index < Self::MAX_DIGITS { - self.digits[write_index] = remainder as u8; - } else if remainder > 0 { - self.truncated = true; - } - n = quotient; - } - self.num_digits += num_new_digits; - if self.num_digits > Self::MAX_DIGITS { - self.num_digits = Self::MAX_DIGITS; - } - self.decimal_point += num_new_digits as i32; - self.trim(); - } - - /// Computes decimal * 2^-shift. - pub fn right_shift(&mut self, shift: usize) { - let mut read_index = 0; - let mut write_index = 0; - let mut n = 0_u64; - while (n >> shift) == 0 { - if read_index < self.num_digits { - n = (10 * n) + self.digits[read_index] as u64; - read_index += 1; - } else if n == 0 { - return; + /// There is an exception: disguised fast-path cases, where we can shift + /// powers-of-10 from the exponent to the significant digits. + pub fn try_fast_path(&self) -> Option { + // Here we need to work around . + // The fast path crucially depends on arithmetic being rounded to the correct number of bits + // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision + // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit. + // The `set_precision` function takes care of setting the precision on architectures which + // require setting it by changing the global state (like the control word of the x87 FPU). + let _cw = set_precision::(); + + if !self.can_use_fast_path::() { + return None; + } + + let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH { + // normal fast path + let value = F::from_u64(self.mantissa); + if self.exponent < 0 { + value / F::pow10_fast_path((-self.exponent) as _) } else { - while (n >> shift) == 0 { - n *= 10; - read_index += 1; - } - break; - } - } - self.decimal_point -= read_index as i32 - 1; - if self.decimal_point < -Self::DECIMAL_POINT_RANGE { - // `self = Self::Default()`, but without the overhead of clearing `digits`. - self.num_digits = 0; - self.decimal_point = 0; - self.truncated = false; - return; - } - let mask = (1_u64 << shift) - 1; - while read_index < self.num_digits { - let new_digit = (n >> shift) as u8; - n = (10 * (n & mask)) + self.digits[read_index] as u64; - read_index += 1; - self.digits[write_index] = new_digit; - write_index += 1; - } - while n > 0 { - let new_digit = (n >> shift) as u8; - n = 10 * (n & mask); - if write_index < Self::MAX_DIGITS { - self.digits[write_index] = new_digit; - write_index += 1; - } else if new_digit > 0 { - self.truncated = true; - } - } - self.num_digits = write_index; - self.trim(); - } -} - -/// Parse a big integer representation of the float as a decimal. -pub fn parse_decimal(mut s: &[u8]) -> Decimal { - let mut d = Decimal::default(); - let start = s; - - while let Some((&b'0', s_next)) = s.split_first() { - s = s_next; - } - - s = s.parse_digits(|digit| d.try_add_digit(digit)); - - if let Some((b'.', s_next)) = s.split_first() { - s = s_next; - let first = s; - // Skip leading zeros. - if d.num_digits == 0 { - while let Some((&b'0', s_next)) = s.split_first() { - s = s_next; - } - } - while s.len() >= 8 && d.num_digits + 8 < Decimal::MAX_DIGITS { - let v = s.read_u64(); - if !is_8digits(v) { - break; + value * F::pow10_fast_path(self.exponent as _) } - d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030); - d.num_digits += 8; - s = &s[8..]; - } - s = s.parse_digits(|digit| d.try_add_digit(digit)); - d.decimal_point = s.len() as i32 - first.len() as i32; - } - if d.num_digits != 0 { - // Ignore the trailing zeros if there are any - let mut n_trailing_zeros = 0; - for &c in start[..(start.len() - s.len())].iter().rev() { - if c == b'0' { - n_trailing_zeros += 1; - } else if c != b'.' { - break; - } - } - d.decimal_point += n_trailing_zeros as i32; - d.num_digits -= n_trailing_zeros; - d.decimal_point += d.num_digits as i32; - if d.num_digits > Decimal::MAX_DIGITS { - d.truncated = true; - d.num_digits = Decimal::MAX_DIGITS; - } - } - if let Some((&ch, s_next)) = s.split_first() { - if ch == b'e' || ch == b'E' { - s = s_next; - let mut neg_exp = false; - if let Some((&ch, s_next)) = s.split_first() { - neg_exp = ch == b'-'; - if ch == b'-' || ch == b'+' { - s = s_next; - } + } else { + // disguised fast path + let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH; + let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?; + if mantissa > F::MAX_MANTISSA_FAST_PATH { + return None; } - let mut exp_num = 0_i32; - - s.parse_digits(|digit| { - if exp_num < 0x10000 { - exp_num = 10 * exp_num + digit as i32; - } - }); + F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _) + }; - d.decimal_point += if neg_exp { -exp_num } else { exp_num }; - } - } - for i in d.num_digits..Decimal::MAX_DIGITS_WITHOUT_OVERFLOW { - d.digits[i] = 0; - } - d -} - -fn number_of_digits_decimal_left_shift(d: &Decimal, mut shift: usize) -> usize { - #[rustfmt::skip] - const TABLE: [u16; 65] = [ - 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024, - 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C, - 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169, - 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B, - 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02, - 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C, - ]; - #[rustfmt::skip] - const TABLE_POW5: [u8; 0x051C] = [ - 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1, - 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5, - 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2, - 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6, - 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1, - 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9, - 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6, - 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1, - 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2, - 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6, - 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5, - 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2, - 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5, - 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4, - 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6, - 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0, - 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3, - 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8, - 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4, - 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5, - 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5, - 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7, - 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8, - 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0, - 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0, - 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1, - 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2, - 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8, - 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0, - 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3, - 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2, - 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4, - 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1, - 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8, - 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5, - 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1, - 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8, - 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0, - 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2, - 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1, - 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2, - 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3, - 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2, - 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5, - ]; - - shift &= 63; - let x_a = TABLE[shift]; - let x_b = TABLE[shift + 1]; - let num_new_digits = (x_a >> 11) as _; - let pow5_a = (0x7FF & x_a) as usize; - let pow5_b = (0x7FF & x_b) as usize; - let pow5 = &TABLE_POW5[pow5_a..]; - for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) { - if i >= d.num_digits { - return num_new_digits - 1; - } else if d.digits[i] == p5 { - continue; - } else if d.digits[i] < p5 { - return num_new_digits - 1; - } else { - return num_new_digits; - } + if self.negative { Some(-value) } else { Some(value) } } - num_new_digits } diff --git a/core/src/num/dec2flt/decimal_seq.rs b/core/src/num/dec2flt/decimal_seq.rs new file mode 100644 index 0000000000000..de22280c001c9 --- /dev/null +++ b/core/src/num/dec2flt/decimal_seq.rs @@ -0,0 +1,379 @@ +//! Arbitrary-precision decimal type used by fallback algorithms. +//! +//! This is only used if the fast-path (native floats) and +//! the Eisel-Lemire algorithm are unable to unambiguously +//! determine the float. +//! +//! The technique used is "Simple Decimal Conversion", developed +//! by Nigel Tao and Ken Thompson. A detailed description of the +//! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion", +//! available online: . + +use crate::num::dec2flt::common::{ByteSlice, is_8digits}; + +/// A decimal floating-point number, represented as a sequence of decimal digits. +#[derive(Clone, Debug, PartialEq)] +pub struct DecimalSeq { + /// The number of significant digits in the decimal. + pub num_digits: usize, + /// The offset of the decimal point in the significant digits. + pub decimal_point: i32, + /// If the number of significant digits stored in the decimal is truncated. + pub truncated: bool, + /// Buffer of the raw digits, in the range [0, 9]. + pub digits: [u8; Self::MAX_DIGITS], +} + +impl Default for DecimalSeq { + fn default() -> Self { + Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] } + } +} + +impl DecimalSeq { + /// The maximum number of digits required to unambiguously round up to a 64-bit float. + /// + /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1. + /// + /// We can exactly represent a float in radix `b` from radix 2 if + /// `b` is divisible by 2. This function calculates the exact number of + /// digits required to exactly represent that float. + /// + /// According to the "Handbook of Floating Point Arithmetic", + /// for IEEE754, with `emin` being the min exponent, `p2` being the + /// precision, and `b` being the radix, the number of digits follows as: + /// + /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋` + /// + /// For f32, this follows as: + /// emin = -126 + /// p2 = 24 + /// + /// For f64, this follows as: + /// emin = -1022 + /// p2 = 53 + /// + /// In Python: + /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))` + pub const MAX_DIGITS: usize = 768; + + /// The max decimal digits that can be exactly represented in a 64-bit integer. + pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19; + pub(super) const DECIMAL_POINT_RANGE: i32 = 2047; + + /// Append a digit to the buffer if it fits. + // FIXME(tgross35): it may be better for this to return an option + // FIXME(tgross35): incrementing the digit counter even if we don't push anything + // seems incorrect. + pub(super) fn try_add_digit(&mut self, digit: u8) { + if self.num_digits < Self::MAX_DIGITS { + self.digits[self.num_digits] = digit; + } + self.num_digits += 1; + } + + /// Trim trailing zeros from the buffer. + // FIXME(tgross35): this could be `.rev().position()` if perf is okay + pub fn trim(&mut self) { + // All of the following calls to `DecimalSeq::trim` can't panic because: + // + // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`. + // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`. + // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`. + // + // Trim is only called in `right_shift` and `left_shift`. + debug_assert!(self.num_digits <= Self::MAX_DIGITS); + while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 { + self.num_digits -= 1; + } + } + + pub(super) fn round(&self) -> u64 { + if self.num_digits == 0 || self.decimal_point < 0 { + return 0; + } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 { + return 0xFFFF_FFFF_FFFF_FFFF_u64; + } + + let dp = self.decimal_point as usize; + let mut n = 0_u64; + + for i in 0..dp { + n *= 10; + if i < self.num_digits { + n += self.digits[i] as u64; + } + } + + let mut round_up = false; + + if dp < self.num_digits { + round_up = self.digits[dp] >= 5; + if self.digits[dp] == 5 && dp + 1 == self.num_digits { + round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0)) + } + } + + if round_up { + n += 1; + } + n + } + + /// Computes decimal * 2^shift. + pub(super) fn left_shift(&mut self, shift: usize) { + if self.num_digits == 0 { + return; + } + let num_new_digits = number_of_digits_decimal_left_shift(self, shift); + let mut read_index = self.num_digits; + let mut write_index = self.num_digits + num_new_digits; + let mut n = 0_u64; + + while read_index != 0 { + read_index -= 1; + write_index -= 1; + n += (self.digits[read_index] as u64) << shift; + let quotient = n / 10; + let remainder = n - (10 * quotient); + if write_index < Self::MAX_DIGITS { + self.digits[write_index] = remainder as u8; + } else if remainder > 0 { + self.truncated = true; + } + n = quotient; + } + + while n > 0 { + write_index -= 1; + let quotient = n / 10; + let remainder = n - (10 * quotient); + if write_index < Self::MAX_DIGITS { + self.digits[write_index] = remainder as u8; + } else if remainder > 0 { + self.truncated = true; + } + n = quotient; + } + + self.num_digits += num_new_digits; + + if self.num_digits > Self::MAX_DIGITS { + self.num_digits = Self::MAX_DIGITS; + } + + self.decimal_point += num_new_digits as i32; + self.trim(); + } + + /// Computes decimal * 2^-shift. + pub(super) fn right_shift(&mut self, shift: usize) { + let mut read_index = 0; + let mut write_index = 0; + let mut n = 0_u64; + while (n >> shift) == 0 { + if read_index < self.num_digits { + n = (10 * n) + self.digits[read_index] as u64; + read_index += 1; + } else if n == 0 { + return; + } else { + while (n >> shift) == 0 { + n *= 10; + read_index += 1; + } + break; + } + } + self.decimal_point -= read_index as i32 - 1; + if self.decimal_point < -Self::DECIMAL_POINT_RANGE { + // `self = Self::Default()`, but without the overhead of clearing `digits`. + self.num_digits = 0; + self.decimal_point = 0; + self.truncated = false; + return; + } + let mask = (1_u64 << shift) - 1; + while read_index < self.num_digits { + let new_digit = (n >> shift) as u8; + n = (10 * (n & mask)) + self.digits[read_index] as u64; + read_index += 1; + self.digits[write_index] = new_digit; + write_index += 1; + } + while n > 0 { + let new_digit = (n >> shift) as u8; + n = 10 * (n & mask); + if write_index < Self::MAX_DIGITS { + self.digits[write_index] = new_digit; + write_index += 1; + } else if new_digit > 0 { + self.truncated = true; + } + } + self.num_digits = write_index; + self.trim(); + } +} + +/// Parse a big integer representation of the float as a decimal. +pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq { + let mut d = DecimalSeq::default(); + let start = s; + + while let Some((&b'0', s_next)) = s.split_first() { + s = s_next; + } + + s = s.parse_digits(|digit| d.try_add_digit(digit)); + + if let Some((b'.', s_next)) = s.split_first() { + s = s_next; + let first = s; + // Skip leading zeros. + if d.num_digits == 0 { + while let Some((&b'0', s_next)) = s.split_first() { + s = s_next; + } + } + while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS { + let v = s.read_u64(); + if !is_8digits(v) { + break; + } + d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030); + d.num_digits += 8; + s = &s[8..]; + } + s = s.parse_digits(|digit| d.try_add_digit(digit)); + d.decimal_point = s.len() as i32 - first.len() as i32; + } + + if d.num_digits != 0 { + // Ignore the trailing zeros if there are any + let mut n_trailing_zeros = 0; + for &c in start[..(start.len() - s.len())].iter().rev() { + if c == b'0' { + n_trailing_zeros += 1; + } else if c != b'.' { + break; + } + } + d.decimal_point += n_trailing_zeros as i32; + d.num_digits -= n_trailing_zeros; + d.decimal_point += d.num_digits as i32; + if d.num_digits > DecimalSeq::MAX_DIGITS { + d.truncated = true; + d.num_digits = DecimalSeq::MAX_DIGITS; + } + } + + if let Some((&ch, s_next)) = s.split_first() { + if ch == b'e' || ch == b'E' { + s = s_next; + let mut neg_exp = false; + if let Some((&ch, s_next)) = s.split_first() { + neg_exp = ch == b'-'; + if ch == b'-' || ch == b'+' { + s = s_next; + } + } + let mut exp_num = 0_i32; + + s.parse_digits(|digit| { + if exp_num < 0x10000 { + exp_num = 10 * exp_num + digit as i32; + } + }); + + d.decimal_point += if neg_exp { -exp_num } else { exp_num }; + } + } + + for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW { + d.digits[i] = 0; + } + + d +} + +fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize { + #[rustfmt::skip] + const TABLE: [u16; 65] = [ + 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024, + 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C, + 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169, + 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B, + 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02, + 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C, + ]; + #[rustfmt::skip] + const TABLE_POW5: [u8; 0x051C] = [ + 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1, + 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5, + 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2, + 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6, + 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1, + 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9, + 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6, + 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1, + 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2, + 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6, + 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5, + 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2, + 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5, + 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4, + 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6, + 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0, + 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3, + 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8, + 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4, + 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5, + 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5, + 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7, + 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8, + 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0, + 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0, + 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1, + 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2, + 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8, + 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0, + 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3, + 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2, + 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4, + 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1, + 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8, + 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5, + 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1, + 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8, + 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0, + 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2, + 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1, + 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2, + 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3, + 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2, + 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5, + ]; + + shift &= 63; + let x_a = TABLE[shift]; + let x_b = TABLE[shift + 1]; + let num_new_digits = (x_a >> 11) as _; + let pow5_a = (0x7FF & x_a) as usize; + let pow5_b = (0x7FF & x_b) as usize; + let pow5 = &TABLE_POW5[pow5_a..]; + + for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) { + if i >= d.num_digits { + return num_new_digits - 1; + } else if d.digits[i] == p5 { + continue; + } else if d.digits[i] < p5 { + return num_new_digits - 1; + } else { + return num_new_digits; + } + } + + num_new_digits +} diff --git a/core/src/num/dec2flt/float.rs b/core/src/num/dec2flt/float.rs index da57aa9a546af..b8a28a6756917 100644 --- a/core/src/num/dec2flt/float.rs +++ b/core/src/num/dec2flt/float.rs @@ -1,14 +1,57 @@ //! Helper trait for generic float types. +use core::f64; + use crate::fmt::{Debug, LowerExp}; use crate::num::FpCategory; -use crate::ops::{Add, Div, Mul, Neg}; +use crate::ops::{self, Add, Div, Mul, Neg}; + +/// Lossy `as` casting between two types. +pub trait CastInto: Copy { + fn cast(self) -> T; +} + +/// Collection of traits that allow us to be generic over integer size. +pub trait Integer: + Sized + + Clone + + Copy + + Debug + + ops::Shr + + ops::Shl + + ops::BitAnd + + ops::BitOr + + PartialEq + + CastInto +{ + const ZERO: Self; + const ONE: Self; +} + +macro_rules! int { + ($($ty:ty),+) => { + $( + impl CastInto for $ty { + fn cast(self) -> i16 { + self as i16 + } + } + + impl Integer for $ty { + const ZERO: Self = 0; + const ONE: Self = 1; + } + )+ + } +} + +int!(u32, u64); -/// A helper trait to avoid duplicating basically all the conversion code for `f32` and `f64`. +/// A helper trait to avoid duplicating basically all the conversion code for IEEE floats. /// /// See the parent module's doc comment for why this is necessary. /// -/// Should **never ever** be implemented for other types or be used outside the dec2flt module. +/// Should **never ever** be implemented for other types or be used outside the `dec2flt` module. #[doc(hidden)] pub trait RawFloat: Sized @@ -24,62 +67,107 @@ pub trait RawFloat: + Copy + Debug { + /// The unsigned integer with the same size as the float + type Int: Integer + Into; + + /* general constants */ + const INFINITY: Self; const NEG_INFINITY: Self; const NAN: Self; const NEG_NAN: Self; - /// The number of bits in the significand, *excluding* the hidden bit. - const MANTISSA_EXPLICIT_BITS: usize; - - // Round-to-even only happens for negative values of q - // when q ≥ −4 in the 64-bit case and when q ≥ −17 in - // the 32-bitcase. - // - // When q ≥ 0,we have that 5^q ≤ 2m+1. In the 64-bit case,we - // have 5^q ≤ 2m+1 ≤ 2^54 or q ≤ 23. In the 32-bit case,we have - // 5^q ≤ 2m+1 ≤ 2^25 or q ≤ 10. - // - // When q < 0, we have w ≥ (2m+1)×5^−q. We must have that w < 2^64 - // so (2m+1)×5^−q < 2^64. We have that 2m+1 > 2^53 (64-bit case) - // or 2m+1 > 2^24 (32-bit case). Hence,we must have 2^53×5^−q < 2^64 - // (64-bit) and 2^24×5^−q < 2^64 (32-bit). Hence we have 5^−q < 2^11 - // or q ≥ −4 (64-bit case) and 5^−q < 2^40 or q ≥ −17 (32-bitcase). - // - // Thus we have that we only need to round ties to even when - // we have that q ∈ [−4,23](in the 64-bit case) or q∈[−17,10] - // (in the 32-bit case). In both cases,the power of five(5^|q|) - // fits in a 64-bit word. - const MIN_EXPONENT_ROUND_TO_EVEN: i32; - const MAX_EXPONENT_ROUND_TO_EVEN: i32; + /// Bit width of the float + const BITS: u32; - // Minimum exponent that for a fast path case, or `-⌊(MANTISSA_EXPLICIT_BITS+1)/log2(5)⌋` - const MIN_EXPONENT_FAST_PATH: i64; + /// The number of bits in the significand, *including* the hidden bit. + const SIG_TOTAL_BITS: u32; - // Maximum exponent that for a fast path case, or `⌊(MANTISSA_EXPLICIT_BITS+1)/log2(5)⌋` - const MAX_EXPONENT_FAST_PATH: i64; + const EXP_MASK: Self::Int; + const SIG_MASK: Self::Int; - // Maximum exponent that can be represented for a disguised-fast path case. - // This is `MAX_EXPONENT_FAST_PATH + ⌊(MANTISSA_EXPLICIT_BITS+1)/log2(10)⌋` - const MAX_EXPONENT_DISGUISED_FAST_PATH: i64; - - // Minimum exponent value `-(1 << (EXP_BITS - 1)) + 1`. - const MINIMUM_EXPONENT: i32; + /// The number of bits in the significand, *excluding* the hidden bit. + const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1; + + /// Number of bits in the exponent. + const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1; + + /// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite + /// representation. + /// + /// This shifted fully right, use `EXP_MASK` for the shifted value. + const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1; + + /// Signed version of `EXP_SAT` since we convert a lot. + const INFINITE_POWER: i32 = Self::EXP_SAT as i32; + + /// The exponent bias value. This is also the maximum value of the exponent. + const EXP_BIAS: u32 = Self::EXP_SAT >> 1; + + /// Minimum exponent value of normal values. + const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1); + + /// Round-to-even only happens for negative values of q + /// when q ≥ −4 in the 64-bit case and when q ≥ −17 in + /// the 32-bitcase. + /// + /// When q ≥ 0,we have that 5^q ≤ 2m+1. In the 64-bit case,we + /// have 5^q ≤ 2m+1 ≤ 2^54 or q ≤ 23. In the 32-bit case,we have + /// 5^q ≤ 2m+1 ≤ 2^25 or q ≤ 10. + /// + /// When q < 0, we have w ≥ (2m+1)×5^−q. We must have that w < 2^64 + /// so (2m+1)×5^−q < 2^64. We have that 2m+1 > 2^53 (64-bit case) + /// or 2m+1 > 2^24 (32-bit case). Hence,we must have 2^53×5^−q < 2^64 + /// (64-bit) and 2^24×5^−q < 2^64 (32-bit). Hence we have 5^−q < 2^11 + /// or q ≥ −4 (64-bit case) and 5^−q < 2^40 or q ≥ −17 (32-bitcase). + /// + /// Thus we have that we only need to round ties to even when + /// we have that q ∈ [−4,23](in the 64-bit case) or q∈[−17,10] + /// (in the 32-bit case). In both cases,the power of five(5^|q|) + /// fits in a 64-bit word. + const MIN_EXPONENT_ROUND_TO_EVEN: i32; + const MAX_EXPONENT_ROUND_TO_EVEN: i32; - // Largest exponent value `(1 << EXP_BITS) - 1`. - const INFINITE_POWER: i32; + /* limits related to Fast pathing */ + + /// Largest decimal exponent for a non-infinite value. + /// + /// This is the max exponent in binary converted to the max exponent in decimal. Allows fast + /// pathing anything larger than `10^LARGEST_POWER_OF_TEN`, which will round to infinity. + const LARGEST_POWER_OF_TEN: i32 = { + let largest_pow2 = Self::EXP_BIAS + 1; + pow2_to_pow10(largest_pow2 as i64) as i32 + }; + + /// Smallest decimal exponent for a non-zero value. This allows for fast pathing anything + /// smaller than `10^SMALLEST_POWER_OF_TEN`, which will round to zero. + /// + /// The smallest power of ten is represented by `⌊log10(2^-n / (2^64 - 1))⌋`, where `n` is + /// the smallest power of two. The `2^64 - 1)` denomenator comes from the number of values + /// that are representable by the intermediate storage format. I don't actually know _why_ + /// the storage format is relevant here. + /// + /// The values may be calculated using the formula. Unfortunately we cannot calculate them at + /// compile time since intermediates exceed the range of an `f64`. + const SMALLEST_POWER_OF_TEN: i32; - // Index (in bits) of the sign. - const SIGN_INDEX: usize; + /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋` + // assuming FLT_EVAL_METHOD = 0 + const MAX_EXPONENT_FAST_PATH: i64 = { + let log2_5 = f64::consts::LOG2_10 - 1.0; + (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64 + }; - // Smallest decimal exponent for a non-zero value. - const SMALLEST_POWER_OF_TEN: i32; + /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋` + const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH; - // Largest decimal exponent for a non-infinite value. - const LARGEST_POWER_OF_TEN: i32; + /// Maximum exponent that can be represented for a disguised-fast path case. + /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋` + const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = + Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64; - // Maximum mantissa for the fast-path (`1 << 53` for f64). - const MAX_MANTISSA_FAST_PATH: u64 = 2_u64 << Self::MANTISSA_EXPLICIT_BITS; + /// Maximum mantissa for the fast-path (`1 << 53` for f64). + const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS; /// Converts integer into float through an as cast. /// This is only called in the fast-path algorithm, and therefore @@ -96,27 +184,51 @@ pub trait RawFloat: /// Returns the category that this number falls into. fn classify(self) -> FpCategory; + /// Transmute to the integer representation + fn to_bits(self) -> Self::Int; + /// Returns the mantissa, exponent and sign as integers. - fn integer_decode(self) -> (u64, i16, i8); + /// + /// That is, this returns `(m, p, s)` such that `s * m * 2^p` represents the original float. + /// For 0, the exponent will be `-(EXP_BIAS + SIG_BITS`, which is the + /// minimum subnormal power. + fn integer_decode(self) -> (u64, i16, i8) { + let bits = self.to_bits(); + let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 }; + let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast(); + let mantissa = if exponent == 0 { + (bits & Self::SIG_MASK) << 1 + } else { + (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS) + }; + // Exponent bias + mantissa shift + exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16; + (mantissa.into(), exponent, sign) + } +} + +/// Solve for `b` in `10^b = 2^a` +const fn pow2_to_pow10(a: i64) -> i64 { + let res = (a as f64) / f64::consts::LOG2_10; + res as i64 } impl RawFloat for f32 { + type Int = u32; + const INFINITY: Self = f32::INFINITY; const NEG_INFINITY: Self = f32::NEG_INFINITY; const NAN: Self = f32::NAN; const NEG_NAN: Self = -f32::NAN; - const MANTISSA_EXPLICIT_BITS: usize = 23; + const BITS: u32 = 32; + const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS; + const EXP_MASK: Self::Int = Self::EXP_MASK; + const SIG_MASK: Self::Int = Self::MAN_MASK; + const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -17; const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 10; - const MIN_EXPONENT_FAST_PATH: i64 = -10; // assuming FLT_EVAL_METHOD = 0 - const MAX_EXPONENT_FAST_PATH: i64 = 10; - const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17; - const MINIMUM_EXPONENT: i32 = -127; - const INFINITE_POWER: i32 = 0xFF; - const SIGN_INDEX: usize = 31; const SMALLEST_POWER_OF_TEN: i32 = -65; - const LARGEST_POWER_OF_TEN: i32 = 38; #[inline] fn from_u64(v: u64) -> Self { @@ -136,16 +248,8 @@ impl RawFloat for f32 { TABLE[exponent & 15] } - /// Returns the mantissa, exponent and sign as integers. - fn integer_decode(self) -> (u64, i16, i8) { - let bits = self.to_bits(); - let sign: i8 = if bits >> 31 == 0 { 1 } else { -1 }; - let mut exponent: i16 = ((bits >> 23) & 0xff) as i16; - let mantissa = - if exponent == 0 { (bits & 0x7fffff) << 1 } else { (bits & 0x7fffff) | 0x800000 }; - // Exponent bias + mantissa shift - exponent -= 127 + 23; - (mantissa as u64, exponent, sign) + fn to_bits(self) -> Self::Int { + self.to_bits() } fn classify(self) -> FpCategory { @@ -154,22 +258,21 @@ impl RawFloat for f32 { } impl RawFloat for f64 { - const INFINITY: Self = f64::INFINITY; - const NEG_INFINITY: Self = f64::NEG_INFINITY; - const NAN: Self = f64::NAN; - const NEG_NAN: Self = -f64::NAN; + type Int = u64; + + const INFINITY: Self = Self::INFINITY; + const NEG_INFINITY: Self = Self::NEG_INFINITY; + const NAN: Self = Self::NAN; + const NEG_NAN: Self = -Self::NAN; + + const BITS: u32 = 64; + const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS; + const EXP_MASK: Self::Int = Self::EXP_MASK; + const SIG_MASK: Self::Int = Self::MAN_MASK; - const MANTISSA_EXPLICIT_BITS: usize = 52; const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4; const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23; - const MIN_EXPONENT_FAST_PATH: i64 = -22; // assuming FLT_EVAL_METHOD = 0 - const MAX_EXPONENT_FAST_PATH: i64 = 22; - const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37; - const MINIMUM_EXPONENT: i32 = -1023; - const INFINITE_POWER: i32 = 0x7FF; - const SIGN_INDEX: usize = 63; const SMALLEST_POWER_OF_TEN: i32 = -342; - const LARGEST_POWER_OF_TEN: i32 = 308; #[inline] fn from_u64(v: u64) -> Self { @@ -190,19 +293,8 @@ impl RawFloat for f64 { TABLE[exponent & 31] } - /// Returns the mantissa, exponent and sign as integers. - fn integer_decode(self) -> (u64, i16, i8) { - let bits = self.to_bits(); - let sign: i8 = if bits >> 63 == 0 { 1 } else { -1 }; - let mut exponent: i16 = ((bits >> 52) & 0x7ff) as i16; - let mantissa = if exponent == 0 { - (bits & 0xfffffffffffff) << 1 - } else { - (bits & 0xfffffffffffff) | 0x10000000000000 - }; - // Exponent bias + mantissa shift - exponent -= 1023 + 52; - (mantissa, exponent, sign) + fn to_bits(self) -> Self::Int { + self.to_bits() } fn classify(self) -> FpCategory { diff --git a/core/src/num/dec2flt/fpu.rs b/core/src/num/dec2flt/fpu.rs index 8d62684f8d383..8aad087ec1bc4 100644 --- a/core/src/num/dec2flt/fpu.rs +++ b/core/src/num/dec2flt/fpu.rs @@ -1,7 +1,7 @@ //! Platform-specific, assembly instructions to avoid //! intermediate rounding on architectures with FPUs. -pub use fpu_precision::set_precision; +pub(super) use fpu_precision::set_precision; // On x86, the x87 FPU is used for float operations if the SSE/SSE2 extensions are not available. // The x87 FPU operates with 80 bits of precision by default, which means that operations will @@ -22,7 +22,6 @@ pub use fpu_precision::set_precision; #[cfg(all(target_arch = "x86", not(target_feature = "sse2")))] mod fpu_precision { use core::arch::asm; - use core::mem::size_of; /// A structure used to preserve the original value of the FPU control word, so that it can be /// restored when the structure is dropped. @@ -42,7 +41,7 @@ mod fpu_precision { /// - 0b10, double precision i.e., 64-bits /// - 0b11, double extended precision i.e., 80-bits (default state) /// The 0b01 value is reserved and should not be used. - pub struct FPUControlWord(u16); + pub(crate) struct FPUControlWord(u16); fn set_cw(cw: u16) { // SAFETY: the `fldcw` instruction has been audited to be able to work correctly with @@ -57,7 +56,7 @@ mod fpu_precision { } /// Sets the precision field of the FPU to `T` and returns a `FPUControlWord`. - pub fn set_precision() -> FPUControlWord { + pub(crate) fn set_precision() -> FPUControlWord { let mut cw = 0_u16; // Compute the value for the Precision Control field that is appropriate for `T`. @@ -97,5 +96,5 @@ mod fpu_precision { // precision of the computation is determined on a per-operation basis. #[cfg(any(not(target_arch = "x86"), target_feature = "sse2"))] mod fpu_precision { - pub fn set_precision() {} + pub(crate) fn set_precision() {} } diff --git a/core/src/num/dec2flt/lemire.rs b/core/src/num/dec2flt/lemire.rs index 01642e1b1112a..f84929a03c172 100644 --- a/core/src/num/dec2flt/lemire.rs +++ b/core/src/num/dec2flt/lemire.rs @@ -38,7 +38,7 @@ pub fn compute_float(q: i64, mut w: u64) -> BiasedFp { // Normalize our significant digits, so the most-significant bit is set. let lz = w.leading_zeros(); w <<= lz; - let (lo, hi) = compute_product_approx(q, w, F::MANTISSA_EXPLICIT_BITS + 3); + let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3); if lo == 0xFFFF_FFFF_FFFF_FFFF { // If we have failed to approximate w x 5^-q with our 128-bit value. // Since the addition of 1 could lead to an overflow which could then @@ -61,8 +61,8 @@ pub fn compute_float(q: i64, mut w: u64) -> BiasedFp { } } let upperbit = (hi >> 63) as i32; - let mut mantissa = hi >> (upperbit + 64 - F::MANTISSA_EXPLICIT_BITS as i32 - 3); - let mut power2 = power(q as i32) + upperbit - lz as i32 - F::MINIMUM_EXPONENT; + let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3); + let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1; if power2 <= 0 { if -power2 + 1 >= 64 { // Have more than 64 bits below the minimum exponent, must be 0. @@ -72,8 +72,8 @@ pub fn compute_float(q: i64, mut w: u64) -> BiasedFp { mantissa >>= -power2 + 1; mantissa += mantissa & 1; mantissa >>= 1; - power2 = (mantissa >= (1_u64 << F::MANTISSA_EXPLICIT_BITS)) as i32; - return BiasedFp { f: mantissa, e: power2 }; + power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32; + return BiasedFp { m: mantissa, p_biased: power2 }; } // Need to handle rounding ties. Normally, we need to round up, // but if we fall right in between and we have an even basis, we @@ -89,8 +89,8 @@ pub fn compute_float(q: i64, mut w: u64) -> BiasedFp { if lo <= 1 && q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64 && q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64 - && mantissa & 3 == 1 - && (mantissa << (upperbit + 64 - F::MANTISSA_EXPLICIT_BITS as i32 - 3)) == hi + && mantissa & 0b11 == 0b01 + && (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi { // Zero the lowest bit, so we don't round up. mantissa &= !1_u64; @@ -98,20 +98,20 @@ pub fn compute_float(q: i64, mut w: u64) -> BiasedFp { // Round-to-even, then shift the significant digits into place. mantissa += mantissa & 1; mantissa >>= 1; - if mantissa >= (2_u64 << F::MANTISSA_EXPLICIT_BITS) { + if mantissa >= (2_u64 << F::SIG_BITS) { // Rounding up overflowed, so the carry bit is set. Set the // mantissa to 1 (only the implicit, hidden bit is set) and // increase the exponent. - mantissa = 1_u64 << F::MANTISSA_EXPLICIT_BITS; + mantissa = 1_u64 << F::SIG_BITS; power2 += 1; } // Zero out the hidden bit. - mantissa &= !(1_u64 << F::MANTISSA_EXPLICIT_BITS); + mantissa &= !(1_u64 << F::SIG_BITS); if power2 >= F::INFINITE_POWER { // Exponent is above largest normal value, must be infinite. return fp_inf; } - BiasedFp { f: mantissa, e: power2 } + BiasedFp { m: mantissa, p_biased: power2 } } /// Calculate a base 2 exponent from a decimal exponent. diff --git a/core/src/num/dec2flt/mod.rs b/core/src/num/dec2flt/mod.rs index 6dca740684537..d1a0e1db31314 100644 --- a/core/src/num/dec2flt/mod.rs +++ b/core/src/num/dec2flt/mod.rs @@ -3,8 +3,8 @@ //! # Problem statement //! //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`), -//! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as zero -//! when missing. +//! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a +//! default value (1 or 0) when missing. //! //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal //! string. It is well-known that many decimal strings do not have terminating representations in @@ -67,6 +67,18 @@ //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer". //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately //! turned into {positive,negative} {zero,infinity}. +//! +//! # Notation +//! +//! This module uses the same notation as the Lemire paper: +//! +//! - `m`: binary mantissa; always nonnegative +//! - `p`: binary exponent; a signed integer +//! - `w`: decimal significand; always nonnegative +//! - `q`: decimal exponent; a signed integer +//! +//! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal +//! equivalent. #![doc(hidden)] #![unstable( @@ -85,14 +97,14 @@ use crate::fmt; use crate::str::FromStr; mod common; -mod decimal; +pub mod decimal; +pub mod decimal_seq; mod fpu; mod slow; mod table; // float is used in flt2dec, and all are used in unit tests. pub mod float; pub mod lemire; -pub mod number; pub mod parse; macro_rules! from_str_float_impl { @@ -220,10 +232,10 @@ pub fn pfe_invalid() -> ParseFloatError { } /// Converts a `BiasedFp` to the closest machine float type. -fn biased_fp_to_float(x: BiasedFp) -> T { - let mut word = x.f; - word |= (x.e as u64) << T::MANTISSA_EXPLICIT_BITS; - T::from_u64_bits(word) +fn biased_fp_to_float(x: BiasedFp) -> F { + let mut word = x.m; + word |= (x.p_biased as u64) << F::SIG_BITS; + F::from_u64_bits(word) } /// Converts a decimal string into a floating point number. @@ -260,12 +272,15 @@ pub fn dec2flt(s: &str) -> Result { // redundantly using the Eisel-Lemire algorithm if it was unable to // correctly round on the first pass. let mut fp = compute_float::(num.exponent, num.mantissa); - if num.many_digits && fp.e >= 0 && fp != compute_float::(num.exponent, num.mantissa + 1) { - fp.e = -1; + if num.many_digits + && fp.p_biased >= 0 + && fp != compute_float::(num.exponent, num.mantissa + 1) + { + fp.p_biased = -1; } // Unable to correctly round the float using the Eisel-Lemire algorithm. // Fallback to a slower, but always correct algorithm. - if fp.e < 0 { + if fp.p_biased < 0 { fp = parse_long_mantissa::(s); } diff --git a/core/src/num/dec2flt/number.rs b/core/src/num/dec2flt/number.rs deleted file mode 100644 index 2538991564ae4..0000000000000 --- a/core/src/num/dec2flt/number.rs +++ /dev/null @@ -1,88 +0,0 @@ -//! Representation of a float as the significant digits and exponent. - -use crate::num::dec2flt::float::RawFloat; -use crate::num::dec2flt::fpu::set_precision; - -#[rustfmt::skip] -const INT_POW10: [u64; 16] = [ - 1, - 10, - 100, - 1000, - 10000, - 100000, - 1000000, - 10000000, - 100000000, - 1000000000, - 10000000000, - 100000000000, - 1000000000000, - 10000000000000, - 100000000000000, - 1000000000000000, -]; - -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] -pub struct Number { - pub exponent: i64, - pub mantissa: u64, - pub negative: bool, - pub many_digits: bool, -} - -impl Number { - /// Detect if the float can be accurately reconstructed from native floats. - #[inline] - fn is_fast_path(&self) -> bool { - F::MIN_EXPONENT_FAST_PATH <= self.exponent - && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH - && self.mantissa <= F::MAX_MANTISSA_FAST_PATH - && !self.many_digits - } - - /// The fast path algorithm using machine-sized integers and floats. - /// - /// This is extracted into a separate function so that it can be attempted before constructing - /// a Decimal. This only works if both the mantissa and the exponent - /// can be exactly represented as a machine float, since IEE-754 guarantees - /// no rounding will occur. - /// - /// There is an exception: disguised fast-path cases, where we can shift - /// powers-of-10 from the exponent to the significant digits. - pub fn try_fast_path(&self) -> Option { - // Here we need to work around . - // The fast path crucially depends on arithmetic being rounded to the correct number of bits - // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision - // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit. - // The `set_precision` function takes care of setting the precision on architectures which - // require setting it by changing the global state (like the control word of the x87 FPU). - let _cw = set_precision::(); - - if self.is_fast_path::() { - let mut value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH { - // normal fast path - let value = F::from_u64(self.mantissa); - if self.exponent < 0 { - value / F::pow10_fast_path((-self.exponent) as _) - } else { - value * F::pow10_fast_path(self.exponent as _) - } - } else { - // disguised fast path - let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH; - let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?; - if mantissa > F::MAX_MANTISSA_FAST_PATH { - return None; - } - F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _) - }; - if self.negative { - value = -value; - } - Some(value) - } else { - None - } - } -} diff --git a/core/src/num/dec2flt/parse.rs b/core/src/num/dec2flt/parse.rs index 06ee8e95fbc47..e38fedc58bec0 100644 --- a/core/src/num/dec2flt/parse.rs +++ b/core/src/num/dec2flt/parse.rs @@ -1,8 +1,8 @@ //! Functions to parse floating-point numbers. use crate::num::dec2flt::common::{ByteSlice, is_8digits}; +use crate::num::dec2flt::decimal::Decimal; use crate::num::dec2flt::float::RawFloat; -use crate::num::dec2flt::number::Number; const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000; @@ -100,7 +100,7 @@ fn parse_scientific(s_ref: &mut &[u8]) -> Option { /// /// This creates a representation of the float as the /// significant digits and the decimal exponent. -fn parse_partial_number(mut s: &[u8]) -> Option<(Number, usize)> { +fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> { debug_assert!(!s.is_empty()); // parse initial digits before dot @@ -146,7 +146,7 @@ fn parse_partial_number(mut s: &[u8]) -> Option<(Number, usize)> { // handle uncommon case with many digits if n_digits <= 19 { - return Some((Number { exponent, mantissa, negative: false, many_digits: false }, len)); + return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len)); } n_digits -= 19; @@ -179,13 +179,13 @@ fn parse_partial_number(mut s: &[u8]) -> Option<(Number, usize)> { exponent += exp_number; } - Some((Number { exponent, mantissa, negative: false, many_digits }, len)) + Some((Decimal { exponent, mantissa, negative: false, many_digits }, len)) } /// Try to parse a non-special floating point number, /// as well as two slices with integer and fractional parts /// and the parsed exponent. -pub fn parse_number(s: &[u8]) -> Option { +pub fn parse_number(s: &[u8]) -> Option { if let Some((float, rest)) = parse_partial_number(s) { if rest == s.len() { return Some(float); diff --git a/core/src/num/dec2flt/slow.rs b/core/src/num/dec2flt/slow.rs index 85d4b13284b7d..3baed42652393 100644 --- a/core/src/num/dec2flt/slow.rs +++ b/core/src/num/dec2flt/slow.rs @@ -1,7 +1,7 @@ //! Slow, fallback algorithm for cases the Eisel-Lemire algorithm cannot round. use crate::num::dec2flt::common::BiasedFp; -use crate::num::dec2flt::decimal::{Decimal, parse_decimal}; +use crate::num::dec2flt::decimal_seq::{DecimalSeq, parse_decimal_seq}; use crate::num::dec2flt::float::RawFloat; /// Parse the significant digits and biased, binary exponent of a float. @@ -36,7 +36,7 @@ pub(crate) fn parse_long_mantissa(s: &[u8]) -> BiasedFp { let fp_zero = BiasedFp::zero_pow2(0); let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER); - let mut d = parse_decimal(s); + let mut d = parse_decimal_seq(s); // Short-circuit if the value can only be a literal 0 or infinity. if d.num_digits == 0 || d.decimal_point < -324 { @@ -50,7 +50,7 @@ pub(crate) fn parse_long_mantissa(s: &[u8]) -> BiasedFp { let n = d.decimal_point as usize; let shift = get_shift(n); d.right_shift(shift); - if d.decimal_point < -Decimal::DECIMAL_POINT_RANGE { + if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE { return fp_zero; } exp2 += shift as i32; @@ -67,43 +67,43 @@ pub(crate) fn parse_long_mantissa(s: &[u8]) -> BiasedFp { get_shift((-d.decimal_point) as _) }; d.left_shift(shift); - if d.decimal_point > Decimal::DECIMAL_POINT_RANGE { + if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE { return fp_inf; } exp2 -= shift as i32; } // We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2]. exp2 -= 1; - while (F::MINIMUM_EXPONENT + 1) > exp2 { - let mut n = ((F::MINIMUM_EXPONENT + 1) - exp2) as usize; + while F::EXP_MIN > exp2 { + let mut n = (F::EXP_MIN - exp2) as usize; if n > MAX_SHIFT { n = MAX_SHIFT; } d.right_shift(n); exp2 += n as i32; } - if (exp2 - F::MINIMUM_EXPONENT) >= F::INFINITE_POWER { + if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER { return fp_inf; } // Shift the decimal to the hidden bit, and then round the value // to get the high mantissa+1 bits. - d.left_shift(F::MANTISSA_EXPLICIT_BITS + 1); + d.left_shift(F::SIG_BITS as usize + 1); let mut mantissa = d.round(); - if mantissa >= (1_u64 << (F::MANTISSA_EXPLICIT_BITS + 1)) { + if mantissa >= (1_u64 << (F::SIG_BITS + 1)) { // Rounding up overflowed to the carry bit, need to // shift back to the hidden bit. d.right_shift(1); exp2 += 1; mantissa = d.round(); - if (exp2 - F::MINIMUM_EXPONENT) >= F::INFINITE_POWER { + if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER { return fp_inf; } } - let mut power2 = exp2 - F::MINIMUM_EXPONENT; - if mantissa < (1_u64 << F::MANTISSA_EXPLICIT_BITS) { + let mut power2 = exp2 - F::EXP_MIN + 1; + if mantissa < (1_u64 << F::SIG_BITS) { power2 -= 1; } // Zero out all the bits above the explicit mantissa bits. - mantissa &= (1_u64 << F::MANTISSA_EXPLICIT_BITS) - 1; - BiasedFp { f: mantissa, e: power2 } + mantissa &= (1_u64 << F::SIG_BITS) - 1; + BiasedFp { m: mantissa, p_biased: power2 } } diff --git a/core/src/num/dec2flt/table.rs b/core/src/num/dec2flt/table.rs index 4856074a62bd0..942c2eacfd276 100644 --- a/core/src/num/dec2flt/table.rs +++ b/core/src/num/dec2flt/table.rs @@ -6,16 +6,17 @@ //! //! DO NOT MODIFY: Generated by `src/etc/dec2flt_table.py` -pub const SMALLEST_POWER_OF_FIVE: i32 = -342; -pub const LARGEST_POWER_OF_FIVE: i32 = 308; -pub const N_POWERS_OF_FIVE: usize = (LARGEST_POWER_OF_FIVE - SMALLEST_POWER_OF_FIVE + 1) as usize; +pub(super) const SMALLEST_POWER_OF_FIVE: i32 = -342; +pub(super) const LARGEST_POWER_OF_FIVE: i32 = 308; +pub(super) const N_POWERS_OF_FIVE: usize = + (LARGEST_POWER_OF_FIVE - SMALLEST_POWER_OF_FIVE + 1) as usize; // Use static to avoid long compile times: Rust compiler errors // can have the entire table compiled multiple times, and then // emit code multiple times, even if it's stripped out in // the final binary. #[rustfmt::skip] -pub static POWER_OF_FIVE_128: [(u64, u64); N_POWERS_OF_FIVE] = [ +pub(super) static POWER_OF_FIVE_128: [(u64, u64); N_POWERS_OF_FIVE] = [ (0xeef453d6923bd65a, 0x113faa2906a13b3f), // 5^-342 (0x9558b4661b6565f8, 0x4ac7ca59a424c507), // 5^-341 (0xbaaee17fa23ebf76, 0x5d79bcf00d2df649), // 5^-340 diff --git a/core/src/num/f128.rs b/core/src/num/f128.rs index abeccb7eea248..5e45974b3d422 100644 --- a/core/src/num/f128.rs +++ b/core/src/num/f128.rs @@ -504,7 +504,6 @@ impl f128 { /// /// ```rust /// #![feature(f128)] - /// #![feature(float_next_up_down)] /// # // FIXME(f16_f128): remove when `eqtf2` is available /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { /// @@ -516,13 +515,15 @@ impl f128 { /// # } /// ``` /// + /// This operation corresponds to IEEE-754 `nextUp`. + /// /// [`NEG_INFINITY`]: Self::NEG_INFINITY /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX #[inline] + #[doc(alias = "nextUp")] #[unstable(feature = "f128", issue = "116909")] - // #[unstable(feature = "float_next_up_down", issue = "91399")] pub const fn next_up(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here @@ -558,7 +559,6 @@ impl f128 { /// /// ```rust /// #![feature(f128)] - /// #![feature(float_next_up_down)] /// # // FIXME(f16_f128): remove when `eqtf2` is available /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { /// @@ -570,13 +570,15 @@ impl f128 { /// # } /// ``` /// + /// This operation corresponds to IEEE-754 `nextDown`. + /// /// [`NEG_INFINITY`]: Self::NEG_INFINITY /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX #[inline] + #[doc(alias = "nextDown")] #[unstable(feature = "f128", issue = "116909")] - // #[unstable(feature = "float_next_up_down", issue = "91399")] pub const fn next_down(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here @@ -668,7 +670,8 @@ impl f128 { /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs; /// this function handles all NaNs the same way and avoids maxNum's problems with associativity. - /// This also matches the behavior of libm’s fmax. + /// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal + /// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically. /// /// ``` /// #![feature(f128)] @@ -694,7 +697,8 @@ impl f128 { /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs; /// this function handles all NaNs the same way and avoids minNum's problems with associativity. - /// This also matches the behavior of libm’s fmin. + /// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal + /// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically. /// /// ``` /// #![feature(f128)] @@ -807,7 +811,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// #![feature(num_midpoint)] /// # // Using aarch64 because `reliable_f128_math` is needed /// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { /// @@ -817,8 +820,8 @@ impl f128 { /// ``` #[inline] #[unstable(feature = "f128", issue = "116909")] - // #[unstable(feature = "num_midpoint", issue = "110840")] - pub fn midpoint(self, other: f128) -> f128 { + #[rustc_const_unstable(feature = "f128", issue = "116909")] + pub const fn midpoint(self, other: f128) -> f128 { const LO: f128 = f128::MIN_POSITIVE * 2.; const HI: f128 = f128::MAX / 2.; diff --git a/core/src/num/f16.rs b/core/src/num/f16.rs index 0d3e92695707c..e3176cd168852 100644 --- a/core/src/num/f16.rs +++ b/core/src/num/f16.rs @@ -497,7 +497,6 @@ impl f16 { /// /// ```rust /// #![feature(f16)] - /// #![feature(float_next_up_down)] /// # // FIXME(f16_f128): ABI issues on MSVC /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { /// @@ -509,13 +508,15 @@ impl f16 { /// # } /// ``` /// + /// This operation corresponds to IEEE-754 `nextUp`. + /// /// [`NEG_INFINITY`]: Self::NEG_INFINITY /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX #[inline] + #[doc(alias = "nextUp")] #[unstable(feature = "f16", issue = "116909")] - // #[unstable(feature = "float_next_up_down", issue = "91399")] pub const fn next_up(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here @@ -551,7 +552,6 @@ impl f16 { /// /// ```rust /// #![feature(f16)] - /// #![feature(float_next_up_down)] /// # // FIXME(f16_f128): ABI issues on MSVC /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { /// @@ -563,13 +563,15 @@ impl f16 { /// # } /// ``` /// + /// This operation corresponds to IEEE-754 `nextDown`. + /// /// [`NEG_INFINITY`]: Self::NEG_INFINITY /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX #[inline] + #[doc(alias = "nextDown")] #[unstable(feature = "f16", issue = "116909")] - // #[unstable(feature = "float_next_up_down", issue = "91399")] pub const fn next_down(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here @@ -660,7 +662,8 @@ impl f16 { /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs; /// this function handles all NaNs the same way and avoids maxNum's problems with associativity. - /// This also matches the behavior of libm’s fmax. + /// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal + /// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically. /// /// ``` /// #![feature(f16)] @@ -685,7 +688,8 @@ impl f16 { /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs; /// this function handles all NaNs the same way and avoids minNum's problems with associativity. - /// This also matches the behavior of libm’s fmin. + /// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal + /// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically. /// /// ``` /// #![feature(f16)] @@ -795,7 +799,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// #![feature(num_midpoint)] /// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885 /// /// assert_eq!(1f16.midpoint(4.0), 2.5); @@ -804,8 +807,8 @@ impl f16 { /// ``` #[inline] #[unstable(feature = "f16", issue = "116909")] - // #[unstable(feature = "num_midpoint", issue = "110840")] - pub fn midpoint(self, other: f16) -> f16 { + #[rustc_const_unstable(feature = "f16", issue = "116909")] + pub const fn midpoint(self, other: f16) -> f16 { const LO: f16 = f16::MIN_POSITIVE * 2.; const HI: f16 = f16::MAX / 2.; diff --git a/core/src/num/f32.rs b/core/src/num/f32.rs index 47dfce7530fb7..de1557ccc9028 100644 --- a/core/src/num/f32.rs +++ b/core/src/num/f32.rs @@ -493,13 +493,13 @@ impl f32 { pub const NEG_INFINITY: f32 = -1.0_f32 / 0.0_f32; /// Sign bit - const SIGN_MASK: u32 = 0x8000_0000; + pub(crate) const SIGN_MASK: u32 = 0x8000_0000; /// Exponent mask - const EXP_MASK: u32 = 0x7f80_0000; + pub(crate) const EXP_MASK: u32 = 0x7f80_0000; /// Mantissa mask - const MAN_MASK: u32 = 0x007f_ffff; + pub(crate) const MAN_MASK: u32 = 0x007f_ffff; /// Minimum representable positive value (min subnormal) const TINY_BITS: u32 = 0x1; @@ -726,7 +726,6 @@ impl f32 { /// is finite `x == x.next_up().next_down()` also holds. /// /// ```rust - /// #![feature(float_next_up_down)] /// // f32::EPSILON is the difference between 1.0 and the next number up. /// assert_eq!(1.0f32.next_up(), 1.0 + f32::EPSILON); /// // But not for most numbers. @@ -734,12 +733,16 @@ impl f32 { /// assert_eq!(16777216f32.next_up(), 16777218.0); /// ``` /// + /// This operation corresponds to IEEE-754 `nextUp`. + /// /// [`NEG_INFINITY`]: Self::NEG_INFINITY /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX #[inline] - #[unstable(feature = "float_next_up_down", issue = "91399")] + #[doc(alias = "nextUp")] + #[stable(feature = "float_next_up_down", since = "1.86.0")] + #[rustc_const_stable(feature = "float_next_up_down", since = "1.86.0")] pub const fn next_up(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here @@ -774,7 +777,6 @@ impl f32 { /// is finite `x == x.next_down().next_up()` also holds. /// /// ```rust - /// #![feature(float_next_up_down)] /// let x = 1.0f32; /// // Clamp value into range [0, 1). /// let clamped = x.clamp(0.0, 1.0f32.next_down()); @@ -782,12 +784,16 @@ impl f32 { /// assert_eq!(clamped.next_up(), 1.0); /// ``` /// + /// This operation corresponds to IEEE-754 `nextDown`. + /// /// [`NEG_INFINITY`]: Self::NEG_INFINITY /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX #[inline] - #[unstable(feature = "float_next_up_down", issue = "91399")] + #[doc(alias = "nextDown")] + #[stable(feature = "float_next_up_down", since = "1.86.0")] + #[rustc_const_stable(feature = "float_next_up_down", since = "1.86.0")] pub const fn next_down(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here @@ -818,7 +824,7 @@ impl f32 { /// ``` #[must_use = "this returns the result of the operation, without modifying the original"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn recip(self) -> f32 { 1.0 / self @@ -836,7 +842,7 @@ impl f32 { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[stable(feature = "f32_deg_rad_conversions", since = "1.7.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn to_degrees(self) -> f32 { // Use a constant for better precision. @@ -856,7 +862,7 @@ impl f32 { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[stable(feature = "f32_deg_rad_conversions", since = "1.7.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn to_radians(self) -> f32 { const RADS_PER_DEG: f32 = consts::PI / 180.0; @@ -868,7 +874,8 @@ impl f32 { /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs; /// this function handles all NaNs the same way and avoids maxNum's problems with associativity. - /// This also matches the behavior of libm’s fmax. + /// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal + /// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically. /// /// ``` /// let x = 1.0f32; @@ -878,7 +885,7 @@ impl f32 { /// ``` #[must_use = "this returns the result of the comparison, without modifying either input"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn max(self, other: f32) -> f32 { intrinsics::maxnumf32(self, other) @@ -889,7 +896,8 @@ impl f32 { /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs; /// this function handles all NaNs the same way and avoids minNum's problems with associativity. - /// This also matches the behavior of libm’s fmin. + /// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal + /// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically. /// /// ``` /// let x = 1.0f32; @@ -899,7 +907,7 @@ impl f32 { /// ``` #[must_use = "this returns the result of the comparison, without modifying either input"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn min(self, other: f32) -> f32 { intrinsics::minnumf32(self, other) @@ -984,27 +992,27 @@ impl f32 { /// # Examples /// /// ``` - /// #![feature(num_midpoint)] /// assert_eq!(1f32.midpoint(4.0), 2.5); /// assert_eq!((-5.5f32).midpoint(8.0), 1.25); /// ``` #[inline] - #[unstable(feature = "num_midpoint", issue = "110840")] - pub fn midpoint(self, other: f32) -> f32 { + #[stable(feature = "num_midpoint", since = "1.85.0")] + #[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")] + pub const fn midpoint(self, other: f32) -> f32 { cfg_if! { + // Allow faster implementation that have known good 64-bit float + // implementations. Falling back to the branchy code on targets that don't + // have 64-bit hardware floats or buggy implementations. + // https://github.com/rust-lang/rust/pull/121062#issuecomment-2123408114 if #[cfg(any( target_arch = "x86_64", target_arch = "aarch64", - all(any(target_arch="riscv32", target_arch= "riscv64"), target_feature="d"), - all(target_arch = "arm", target_feature="vfp2"), + all(any(target_arch = "riscv32", target_arch = "riscv64"), target_feature = "d"), + all(target_arch = "arm", target_feature = "vfp2"), target_arch = "wasm32", target_arch = "wasm64", ))] { - // whitelist the faster implementation to targets that have known good 64-bit float - // implementations. Falling back to the branchy code on targets that don't have - // 64-bit hardware floats or buggy implementations. - // see: https://github.com/rust-lang/rust/pull/121062#issuecomment-2123408114 - ((f64::from(self) + f64::from(other)) / 2.0) as f32 + ((self as f64 + other as f64) / 2.0) as f32 } else { const LO: f32 = f32::MIN_POSITIVE * 2.; const HI: f32 = f32::MAX / 2.; @@ -1396,7 +1404,7 @@ impl f32 { /// ``` #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "clamp", since = "1.50.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn clamp(mut self, min: f32, max: f32) -> f32 { const_assert!( @@ -1433,7 +1441,7 @@ impl f32 { /// ``` #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn abs(self) -> f32 { // SAFETY: this is actually a safe intrinsic @@ -1458,7 +1466,7 @@ impl f32 { /// ``` #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn signum(self) -> f32 { if self.is_nan() { Self::NAN } else { 1.0_f32.copysign(self) } @@ -1493,7 +1501,7 @@ impl f32 { #[must_use = "method returns a new number and does not mutate the original value"] #[inline] #[stable(feature = "copysign", since = "1.35.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] pub const fn copysign(self, sign: f32) -> f32 { // SAFETY: this is actually a safe intrinsic unsafe { intrinsics::copysignf32(self, sign) } diff --git a/core/src/num/f64.rs b/core/src/num/f64.rs index c89023c1ae490..65b5f3b9af093 100644 --- a/core/src/num/f64.rs +++ b/core/src/num/f64.rs @@ -492,13 +492,13 @@ impl f64 { pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64; /// Sign bit - const SIGN_MASK: u64 = 0x8000_0000_0000_0000; + pub(crate) const SIGN_MASK: u64 = 0x8000_0000_0000_0000; /// Exponent mask - const EXP_MASK: u64 = 0x7ff0_0000_0000_0000; + pub(crate) const EXP_MASK: u64 = 0x7ff0_0000_0000_0000; /// Mantissa mask - const MAN_MASK: u64 = 0x000f_ffff_ffff_ffff; + pub(crate) const MAN_MASK: u64 = 0x000f_ffff_ffff_ffff; /// Minimum representable positive value (min subnormal) const TINY_BITS: u64 = 0x1; @@ -743,7 +743,6 @@ impl f64 { /// is finite `x == x.next_up().next_down()` also holds. /// /// ```rust - /// #![feature(float_next_up_down)] /// // f64::EPSILON is the difference between 1.0 and the next number up. /// assert_eq!(1.0f64.next_up(), 1.0 + f64::EPSILON); /// // But not for most numbers. @@ -751,12 +750,16 @@ impl f64 { /// assert_eq!(9007199254740992f64.next_up(), 9007199254740994.0); /// ``` /// + /// This operation corresponds to IEEE-754 `nextUp`. + /// /// [`NEG_INFINITY`]: Self::NEG_INFINITY /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX #[inline] - #[unstable(feature = "float_next_up_down", issue = "91399")] + #[doc(alias = "nextUp")] + #[stable(feature = "float_next_up_down", since = "1.86.0")] + #[rustc_const_stable(feature = "float_next_up_down", since = "1.86.0")] pub const fn next_up(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here @@ -791,7 +794,6 @@ impl f64 { /// is finite `x == x.next_down().next_up()` also holds. /// /// ```rust - /// #![feature(float_next_up_down)] /// let x = 1.0f64; /// // Clamp value into range [0, 1). /// let clamped = x.clamp(0.0, 1.0f64.next_down()); @@ -799,12 +801,16 @@ impl f64 { /// assert_eq!(clamped.next_up(), 1.0); /// ``` /// + /// This operation corresponds to IEEE-754 `nextDown`. + /// /// [`NEG_INFINITY`]: Self::NEG_INFINITY /// [`INFINITY`]: Self::INFINITY /// [`MIN`]: Self::MIN /// [`MAX`]: Self::MAX #[inline] - #[unstable(feature = "float_next_up_down", issue = "91399")] + #[doc(alias = "nextDown")] + #[stable(feature = "float_next_up_down", since = "1.86.0")] + #[rustc_const_stable(feature = "float_next_up_down", since = "1.86.0")] pub const fn next_down(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here @@ -835,7 +841,7 @@ impl f64 { /// ``` #[must_use = "this returns the result of the operation, without modifying the original"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn recip(self) -> f64 { 1.0 / self @@ -853,7 +859,7 @@ impl f64 { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn to_degrees(self) -> f64 { // The division here is correctly rounded with respect to the true @@ -874,7 +880,7 @@ impl f64 { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn to_radians(self) -> f64 { const RADS_PER_DEG: f64 = consts::PI / 180.0; @@ -886,7 +892,8 @@ impl f64 { /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs; /// this function handles all NaNs the same way and avoids maxNum's problems with associativity. - /// This also matches the behavior of libm’s fmax. + /// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal + /// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically. /// /// ``` /// let x = 1.0_f64; @@ -896,7 +903,7 @@ impl f64 { /// ``` #[must_use = "this returns the result of the comparison, without modifying either input"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn max(self, other: f64) -> f64 { intrinsics::maxnumf64(self, other) @@ -907,7 +914,8 @@ impl f64 { /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs; /// this function handles all NaNs the same way and avoids minNum's problems with associativity. - /// This also matches the behavior of libm’s fmin. + /// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal + /// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically. /// /// ``` /// let x = 1.0_f64; @@ -917,7 +925,7 @@ impl f64 { /// ``` #[must_use = "this returns the result of the comparison, without modifying either input"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn min(self, other: f64) -> f64 { intrinsics::minnumf64(self, other) @@ -1002,13 +1010,13 @@ impl f64 { /// # Examples /// /// ``` - /// #![feature(num_midpoint)] /// assert_eq!(1f64.midpoint(4.0), 2.5); /// assert_eq!((-5.5f64).midpoint(8.0), 1.25); /// ``` #[inline] - #[unstable(feature = "num_midpoint", issue = "110840")] - pub fn midpoint(self, other: f64) -> f64 { + #[stable(feature = "num_midpoint", since = "1.85.0")] + #[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")] + pub const fn midpoint(self, other: f64) -> f64 { const LO: f64 = f64::MIN_POSITIVE * 2.; const HI: f64 = f64::MAX / 2.; @@ -1396,7 +1404,7 @@ impl f64 { /// ``` #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "clamp", since = "1.50.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn clamp(mut self, min: f64, max: f64) -> f64 { const_assert!( @@ -1433,7 +1441,7 @@ impl f64 { /// ``` #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn abs(self) -> f64 { // SAFETY: this is actually a safe intrinsic @@ -1458,7 +1466,7 @@ impl f64 { /// ``` #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn signum(self) -> f64 { if self.is_nan() { Self::NAN } else { 1.0_f64.copysign(self) } @@ -1492,7 +1500,7 @@ impl f64 { /// ``` #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "copysign", since = "1.35.0")] - #[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn copysign(self, sign: f64) -> f64 { // SAFETY: this is actually a safe intrinsic diff --git a/core/src/num/flt2dec/mod.rs b/core/src/num/flt2dec/mod.rs index d6413fadc3381..7601e3e2c58a2 100644 --- a/core/src/num/flt2dec/mod.rs +++ b/core/src/num/flt2dec/mod.rs @@ -210,10 +210,10 @@ fn digits_to_dec_str<'a>( if frac_digits > buf.len() && frac_digits - buf.len() > minus_exp { parts[3] = MaybeUninit::new(Part::Zero((frac_digits - buf.len()) - minus_exp)); // SAFETY: we just initialized the elements `..4`. - unsafe { MaybeUninit::slice_assume_init_ref(&parts[..4]) } + unsafe { parts[..4].assume_init_ref() } } else { // SAFETY: we just initialized the elements `..3`. - unsafe { MaybeUninit::slice_assume_init_ref(&parts[..3]) } + unsafe { parts[..3].assume_init_ref() } } } else { let exp = exp as usize; @@ -225,10 +225,10 @@ fn digits_to_dec_str<'a>( if frac_digits > buf.len() - exp { parts[3] = MaybeUninit::new(Part::Zero(frac_digits - (buf.len() - exp))); // SAFETY: we just initialized the elements `..4`. - unsafe { MaybeUninit::slice_assume_init_ref(&parts[..4]) } + unsafe { parts[..4].assume_init_ref() } } else { // SAFETY: we just initialized the elements `..3`. - unsafe { MaybeUninit::slice_assume_init_ref(&parts[..3]) } + unsafe { parts[..3].assume_init_ref() } } } else { // the decimal point is after rendered digits: [1234][____0000] or [1234][__][.][__]. @@ -238,10 +238,10 @@ fn digits_to_dec_str<'a>( parts[2] = MaybeUninit::new(Part::Copy(b".")); parts[3] = MaybeUninit::new(Part::Zero(frac_digits)); // SAFETY: we just initialized the elements `..4`. - unsafe { MaybeUninit::slice_assume_init_ref(&parts[..4]) } + unsafe { parts[..4].assume_init_ref() } } else { // SAFETY: we just initialized the elements `..2`. - unsafe { MaybeUninit::slice_assume_init_ref(&parts[..2]) } + unsafe { parts[..2].assume_init_ref() } } } } @@ -292,7 +292,7 @@ fn digits_to_exp_str<'a>( parts[n + 1] = MaybeUninit::new(Part::Num(exp as u16)); } // SAFETY: we just initialized the elements `..n + 2`. - unsafe { MaybeUninit::slice_assume_init_ref(&parts[..n + 2]) } + unsafe { parts[..n + 2].assume_init_ref() } } /// Sign formatting options. @@ -366,12 +366,12 @@ where FullDecoded::Nan => { parts[0] = MaybeUninit::new(Part::Copy(b"NaN")); // SAFETY: we just initialized the elements `..1`. - Formatted { sign, parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) } } + Formatted { sign, parts: unsafe { parts[..1].assume_init_ref() } } } FullDecoded::Infinite => { parts[0] = MaybeUninit::new(Part::Copy(b"inf")); // SAFETY: we just initialized the elements `..1`. - Formatted { sign, parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) } } + Formatted { sign, parts: unsafe { parts[..1].assume_init_ref() } } } FullDecoded::Zero => { if frac_digits > 0 { @@ -381,14 +381,14 @@ where Formatted { sign, // SAFETY: we just initialized the elements `..2`. - parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..2]) }, + parts: unsafe { parts[..2].assume_init_ref() }, } } else { parts[0] = MaybeUninit::new(Part::Copy(b"0")); Formatted { sign, // SAFETY: we just initialized the elements `..1`. - parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) }, + parts: unsafe { parts[..1].assume_init_ref() }, } } } @@ -442,12 +442,12 @@ where FullDecoded::Nan => { parts[0] = MaybeUninit::new(Part::Copy(b"NaN")); // SAFETY: we just initialized the elements `..1`. - Formatted { sign, parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) } } + Formatted { sign, parts: unsafe { parts[..1].assume_init_ref() } } } FullDecoded::Infinite => { parts[0] = MaybeUninit::new(Part::Copy(b"inf")); // SAFETY: we just initialized the elements `..1`. - Formatted { sign, parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) } } + Formatted { sign, parts: unsafe { parts[..1].assume_init_ref() } } } FullDecoded::Zero => { parts[0] = if dec_bounds.0 <= 0 && 0 < dec_bounds.1 { @@ -456,7 +456,7 @@ where MaybeUninit::new(Part::Copy(if upper { b"0E0" } else { b"0e0" })) }; // SAFETY: we just initialized the elements `..1`. - Formatted { sign, parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) } } + Formatted { sign, parts: unsafe { parts[..1].assume_init_ref() } } } FullDecoded::Finite(ref decoded) => { let (buf, exp) = format_shortest(decoded, buf); @@ -533,12 +533,12 @@ where FullDecoded::Nan => { parts[0] = MaybeUninit::new(Part::Copy(b"NaN")); // SAFETY: we just initialized the elements `..1`. - Formatted { sign, parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) } } + Formatted { sign, parts: unsafe { parts[..1].assume_init_ref() } } } FullDecoded::Infinite => { parts[0] = MaybeUninit::new(Part::Copy(b"inf")); // SAFETY: we just initialized the elements `..1`. - Formatted { sign, parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) } } + Formatted { sign, parts: unsafe { parts[..1].assume_init_ref() } } } FullDecoded::Zero => { if ndigits > 1 { @@ -549,14 +549,14 @@ where Formatted { sign, // SAFETY: we just initialized the elements `..3`. - parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..3]) }, + parts: unsafe { parts[..3].assume_init_ref() }, } } else { parts[0] = MaybeUninit::new(Part::Copy(if upper { b"0E0" } else { b"0e0" })); Formatted { sign, // SAFETY: we just initialized the elements `..1`. - parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) }, + parts: unsafe { parts[..1].assume_init_ref() }, } } } @@ -607,12 +607,12 @@ where FullDecoded::Nan => { parts[0] = MaybeUninit::new(Part::Copy(b"NaN")); // SAFETY: we just initialized the elements `..1`. - Formatted { sign, parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) } } + Formatted { sign, parts: unsafe { parts[..1].assume_init_ref() } } } FullDecoded::Infinite => { parts[0] = MaybeUninit::new(Part::Copy(b"inf")); // SAFETY: we just initialized the elements `..1`. - Formatted { sign, parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) } } + Formatted { sign, parts: unsafe { parts[..1].assume_init_ref() } } } FullDecoded::Zero => { if frac_digits > 0 { @@ -622,14 +622,14 @@ where Formatted { sign, // SAFETY: we just initialized the elements `..2`. - parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..2]) }, + parts: unsafe { parts[..2].assume_init_ref() }, } } else { parts[0] = MaybeUninit::new(Part::Copy(b"0")); Formatted { sign, // SAFETY: we just initialized the elements `..1`. - parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) }, + parts: unsafe { parts[..1].assume_init_ref() }, } } } @@ -654,14 +654,14 @@ where Formatted { sign, // SAFETY: we just initialized the elements `..2`. - parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..2]) }, + parts: unsafe { parts[..2].assume_init_ref() }, } } else { parts[0] = MaybeUninit::new(Part::Copy(b"0")); Formatted { sign, // SAFETY: we just initialized the elements `..1`. - parts: unsafe { MaybeUninit::slice_assume_init_ref(&parts[..1]) }, + parts: unsafe { parts[..1].assume_init_ref() }, } } } else { diff --git a/core/src/num/flt2dec/strategy/dragon.rs b/core/src/num/flt2dec/strategy/dragon.rs index e801f07b3bc0e..dd73e4b4846d5 100644 --- a/core/src/num/flt2dec/strategy/dragon.rs +++ b/core/src/num/flt2dec/strategy/dragon.rs @@ -247,7 +247,7 @@ pub fn format_shortest<'a>( // it seems that this condition is very hard to satisfy (possibly impossible), // but we are just being safe and consistent here. // SAFETY: we initialized that memory above. - if let Some(c) = round_up(unsafe { MaybeUninit::slice_assume_init_mut(&mut buf[..i]) }) { + if let Some(c) = round_up(unsafe { buf[..i].assume_init_mut() }) { buf[i] = MaybeUninit::new(c); i += 1; k += 1; @@ -255,7 +255,7 @@ pub fn format_shortest<'a>( } // SAFETY: we initialized that memory above. - (unsafe { MaybeUninit::slice_assume_init_ref(&buf[..i]) }, k) + (unsafe { buf[..i].assume_init_ref() }, k) } /// The exact and fixed mode implementation for Dragon. @@ -333,7 +333,7 @@ pub fn format_exact<'a>( *c = MaybeUninit::new(b'0'); } // SAFETY: we initialized that memory above. - return (unsafe { MaybeUninit::slice_assume_init_ref(&buf[..len]) }, k); + return (unsafe { buf[..len].assume_init_ref() }, k); } let mut d = 0; @@ -372,7 +372,7 @@ pub fn format_exact<'a>( // if rounding up changes the length, the exponent should also change. // but we've been requested a fixed number of digits, so do not alter the buffer... // SAFETY: we initialized that memory above. - if let Some(c) = round_up(unsafe { MaybeUninit::slice_assume_init_mut(&mut buf[..len]) }) { + if let Some(c) = round_up(unsafe { buf[..len].assume_init_mut() }) { // ...unless we've been requested the fixed precision instead. // we also need to check that, if the original buffer was empty, // the additional digit can only be added when `k == limit` (edge case). @@ -385,5 +385,5 @@ pub fn format_exact<'a>( } // SAFETY: we initialized that memory above. - (unsafe { MaybeUninit::slice_assume_init_ref(&buf[..len]) }, k) + (unsafe { buf[..len].assume_init_ref() }, k) } diff --git a/core/src/num/flt2dec/strategy/grisu.rs b/core/src/num/flt2dec/strategy/grisu.rs index bdf544a4133bb..2816de4c63339 100644 --- a/core/src/num/flt2dec/strategy/grisu.rs +++ b/core/src/num/flt2dec/strategy/grisu.rs @@ -275,7 +275,7 @@ pub fn format_shortest_opt<'a>( let ten_kappa = (ten_kappa as u64) << e; // scale 10^kappa back to the shared exponent return round_and_weed( // SAFETY: we initialized that memory above. - unsafe { MaybeUninit::slice_assume_init_mut(&mut buf[..i]) }, + unsafe { buf[..i].assume_init_mut() }, exp, plus1rem, delta1, @@ -324,7 +324,7 @@ pub fn format_shortest_opt<'a>( let ten_kappa = 1 << e; // implicit divisor return round_and_weed( // SAFETY: we initialized that memory above. - unsafe { MaybeUninit::slice_assume_init_mut(&mut buf[..i]) }, + unsafe { buf[..i].assume_init_mut() }, exp, r, threshold, @@ -713,7 +713,7 @@ pub fn format_exact_opt<'a>( // `10^kappa` did not overflow after all, the second check is fine. if ten_kappa - remainder > remainder && ten_kappa - 2 * remainder >= 2 * ulp { // SAFETY: our caller initialized that memory. - return Some((unsafe { MaybeUninit::slice_assume_init_ref(&buf[..len]) }, exp)); + return Some((unsafe { buf[..len].assume_init_ref() }, exp)); } // :<------- remainder ------>| : @@ -736,7 +736,7 @@ pub fn format_exact_opt<'a>( if remainder > ulp && ten_kappa - (remainder - ulp) <= remainder - ulp { if let Some(c) = // SAFETY: our caller must have initialized that memory. - round_up(unsafe { MaybeUninit::slice_assume_init_mut(&mut buf[..len]) }) + round_up(unsafe { buf[..len].assume_init_mut() }) { // only add an additional digit when we've been requested the fixed precision. // we also need to check that, if the original buffer was empty, @@ -748,7 +748,7 @@ pub fn format_exact_opt<'a>( } } // SAFETY: we and our caller initialized that memory. - return Some((unsafe { MaybeUninit::slice_assume_init_ref(&buf[..len]) }, exp)); + return Some((unsafe { buf[..len].assume_init_ref() }, exp)); } // otherwise we are doomed (i.e., some values between `v - 1 ulp` and `v + 1 ulp` are diff --git a/core/src/num/int_log10.rs b/core/src/num/int_log10.rs index 0ce31b40a3845..28a3f5d880ad7 100644 --- a/core/src/num/int_log10.rs +++ b/core/src/num/int_log10.rs @@ -3,7 +3,7 @@ // 0 < val <= u8::MAX #[inline] -pub const fn u8(val: u8) -> u32 { +pub(super) const fn u8(val: u8) -> u32 { let val = val as u32; // For better performance, avoid branches by assembling the solution @@ -45,13 +45,13 @@ const fn less_than_5(val: u32) -> u32 { // 0 < val <= u16::MAX #[inline] -pub const fn u16(val: u16) -> u32 { +pub(super) const fn u16(val: u16) -> u32 { less_than_5(val as u32) } // 0 < val <= u32::MAX #[inline] -pub const fn u32(mut val: u32) -> u32 { +pub(super) const fn u32(mut val: u32) -> u32 { let mut log = 0; if val >= 100_000 { val /= 100_000; @@ -62,7 +62,7 @@ pub const fn u32(mut val: u32) -> u32 { // 0 < val <= u64::MAX #[inline] -pub const fn u64(mut val: u64) -> u32 { +pub(super) const fn u64(mut val: u64) -> u32 { let mut log = 0; if val >= 10_000_000_000 { val /= 10_000_000_000; @@ -77,7 +77,7 @@ pub const fn u64(mut val: u64) -> u32 { // 0 < val <= u128::MAX #[inline] -pub const fn u128(mut val: u128) -> u32 { +pub(super) const fn u128(mut val: u128) -> u32 { let mut log = 0; if val >= 100_000_000_000_000_000_000_000_000_000_000 { val /= 100_000_000_000_000_000_000_000_000_000_000; @@ -93,49 +93,49 @@ pub const fn u128(mut val: u128) -> u32 { #[cfg(target_pointer_width = "16")] #[inline] -pub const fn usize(val: usize) -> u32 { +pub(super) const fn usize(val: usize) -> u32 { u16(val as _) } #[cfg(target_pointer_width = "32")] #[inline] -pub const fn usize(val: usize) -> u32 { +pub(super) const fn usize(val: usize) -> u32 { u32(val as _) } #[cfg(target_pointer_width = "64")] #[inline] -pub const fn usize(val: usize) -> u32 { +pub(super) const fn usize(val: usize) -> u32 { u64(val as _) } // 0 < val <= i8::MAX #[inline] -pub const fn i8(val: i8) -> u32 { +pub(super) const fn i8(val: i8) -> u32 { u8(val as u8) } // 0 < val <= i16::MAX #[inline] -pub const fn i16(val: i16) -> u32 { +pub(super) const fn i16(val: i16) -> u32 { u16(val as u16) } // 0 < val <= i32::MAX #[inline] -pub const fn i32(val: i32) -> u32 { +pub(super) const fn i32(val: i32) -> u32 { u32(val as u32) } // 0 < val <= i64::MAX #[inline] -pub const fn i64(val: i64) -> u32 { +pub(super) const fn i64(val: i64) -> u32 { u64(val as u64) } // 0 < val <= i128::MAX #[inline] -pub const fn i128(val: i128) -> u32 { +pub(super) const fn i128(val: i128) -> u32 { u128(val as u128) } @@ -143,6 +143,6 @@ pub const fn i128(val: i128) -> u32 { /// on every single primitive type. #[cold] #[track_caller] -pub const fn panic_for_nonpositive_argument() -> ! { +pub(super) const fn panic_for_nonpositive_argument() -> ! { panic!("argument of integer logarithm must be positive") } diff --git a/core/src/num/int_macros.rs b/core/src/num/int_macros.rs index 64dcb4c91e628..a72ca4bcb059b 100644 --- a/core/src/num/int_macros.rs +++ b/core/src/num/int_macros.rs @@ -183,6 +183,52 @@ macro_rules! int_impl { (self as $UnsignedT).trailing_ones() } + /// Returns `self` with only the most significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_most_significant_one(), 0b_01000000); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_most_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_most_significant_one(self) -> Self { + self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros())) + } + + /// Returns `self` with only the least significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_least_significant_one(), 0b_00000100); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_least_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_least_significant_one(self) -> Self { + self & self.wrapping_neg() + } + /// Returns the bit pattern of `self` reinterpreted as an unsigned integer of the same size. /// /// This produces the same result as an `as` cast, but ensures that the bit-width remains @@ -193,13 +239,13 @@ macro_rules! int_impl { /// Basic usage: /// /// ``` - /// #![feature(integer_sign_cast)] /// #[doc = concat!("let n = -1", stringify!($SelfT), ";")] /// #[doc = concat!("assert_eq!(n.cast_unsigned(), ", stringify!($UnsignedT), "::MAX);")] /// ``` - #[unstable(feature = "integer_sign_cast", issue = "125882")] + #[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] @@ -1152,7 +1198,6 @@ macro_rules! int_impl { )] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "unchecked_neg", issue = "85122"))] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn unchecked_neg(self) -> Self { @@ -1217,7 +1262,6 @@ macro_rules! int_impl { /// ``` #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1282,7 +1326,6 @@ macro_rules! int_impl { )] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "unchecked_shifts", issue = "85122"))] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn unchecked_shl(self, rhs: u32) -> Self { @@ -1309,11 +1352,11 @@ macro_rules! int_impl { /// /// Basic usage: /// ``` - /// #![feature(unbounded_shifts)] #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(4), 0x10);")] #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(129), 0);")] /// ``` - #[unstable(feature = "unbounded_shifts", issue = "129375")] + #[stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1340,7 +1383,6 @@ macro_rules! int_impl { /// ``` #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1405,7 +1447,6 @@ macro_rules! int_impl { )] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "unchecked_shifts", issue = "85122"))] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn unchecked_shr(self, rhs: u32) -> Self { @@ -1433,12 +1474,12 @@ macro_rules! int_impl { /// /// Basic usage: /// ``` - /// #![feature(unbounded_shifts)] #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(4), 0x1);")] #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(129), 0);")] #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.unbounded_shr(129), -1);")] /// ``` - #[unstable(feature = "unbounded_shifts", issue = "129375")] + #[stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1613,8 +1654,8 @@ macro_rules! int_impl { /// ``` #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_isqrt(), Some(3));")] /// ``` - #[stable(feature = "isqrt", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "isqrt", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "isqrt", since = "1.84.0")] + #[rustc_const_stable(feature = "isqrt", since = "1.84.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1828,7 +1869,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -1986,7 +2027,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2014,7 +2055,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2042,7 +2083,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2069,7 +2110,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2134,7 +2175,6 @@ macro_rules! int_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))] pub const fn wrapping_shl(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds @@ -2164,7 +2204,6 @@ macro_rules! int_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))] pub const fn wrapping_shr(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds @@ -2519,6 +2558,114 @@ macro_rules! int_impl { (a as Self, b) } + /// Calculates the complete product `self * rhs` without the possibility to overflow. + /// + /// This returns the low-order (wrapping) bits and the high-order (overflow) bits + /// of the result as two separate values, in that order. + /// + /// If you also need to add a carry to the wide result, then you want + /// [`Self::carrying_mul`] instead. + /// + /// # Examples + /// + /// Basic usage: + /// + /// Please note that this example is shared between integer types. + /// Which explains why `i32` is used here. + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// assert_eq!(5i32.widening_mul(-2), (4294967286, -1)); + /// assert_eq!(1_000_000_000i32.widening_mul(-10), (2884901888, -3)); + /// ``` + #[unstable(feature = "bigint_helper_methods", issue = "85532")] + #[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn widening_mul(self, rhs: Self) -> ($UnsignedT, Self) { + Self::carrying_mul_add(self, rhs, 0, 0) + } + + /// Calculates the "full multiplication" `self * rhs + carry` + /// without the possibility to overflow. + /// + /// This returns the low-order (wrapping) bits and the high-order (overflow) bits + /// of the result as two separate values, in that order. + /// + /// Performs "long multiplication" which takes in an extra amount to add, and may return an + /// additional amount of overflow. This allows for chaining together multiple + /// multiplications to create "big integers" which represent larger values. + /// + /// If you don't need the `carry`, then you can use [`Self::widening_mul`] instead. + /// + /// # Examples + /// + /// Basic usage: + /// + /// Please note that this example is shared between integer types. + /// Which explains why `i32` is used here. + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// assert_eq!(5i32.carrying_mul(-2, 0), (4294967286, -1)); + /// assert_eq!(5i32.carrying_mul(-2, 10), (0, 0)); + /// assert_eq!(1_000_000_000i32.carrying_mul(-10, 0), (2884901888, -3)); + /// assert_eq!(1_000_000_000i32.carrying_mul(-10, 10), (2884901898, -3)); + #[doc = concat!("assert_eq!(", + stringify!($SelfT), "::MAX.carrying_mul(", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX), ", + "(", stringify!($SelfT), "::MAX.unsigned_abs() + 1, ", stringify!($SelfT), "::MAX / 2));" + )] + /// ``` + #[unstable(feature = "bigint_helper_methods", issue = "85532")] + #[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn carrying_mul(self, rhs: Self, carry: Self) -> ($UnsignedT, Self) { + Self::carrying_mul_add(self, rhs, carry, 0) + } + + /// Calculates the "full multiplication" `self * rhs + carry1 + carry2` + /// without the possibility to overflow. + /// + /// This returns the low-order (wrapping) bits and the high-order (overflow) bits + /// of the result as two separate values, in that order. + /// + /// Performs "long multiplication" which takes in an extra amount to add, and may return an + /// additional amount of overflow. This allows for chaining together multiple + /// multiplications to create "big integers" which represent larger values. + /// + /// If you don't need either `carry`, then you can use [`Self::widening_mul`] instead, + /// and if you only need one `carry`, then you can use [`Self::carrying_mul`] instead. + /// + /// # Examples + /// + /// Basic usage: + /// + /// Please note that this example is shared between integer types. + /// Which explains why `i32` is used here. + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// assert_eq!(5i32.carrying_mul_add(-2, 0, 0), (4294967286, -1)); + /// assert_eq!(5i32.carrying_mul_add(-2, 10, 10), (10, 0)); + /// assert_eq!(1_000_000_000i32.carrying_mul_add(-10, 0, 0), (2884901888, -3)); + /// assert_eq!(1_000_000_000i32.carrying_mul_add(-10, 10, 10), (2884901908, -3)); + #[doc = concat!("assert_eq!(", + stringify!($SelfT), "::MAX.carrying_mul_add(", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX), ", + "(", stringify!($UnsignedT), "::MAX, ", stringify!($SelfT), "::MAX / 2));" + )] + /// ``` + #[unstable(feature = "bigint_helper_methods", issue = "85532")] + #[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn carrying_mul_add(self, rhs: Self, carry: Self, add: Self) -> ($UnsignedT, Self) { + intrinsics::carrying_mul_add(self, rhs, carry, add) + } + /// Calculates the divisor when `self` is divided by `rhs`. /// /// Returns a tuple of the divisor along with a boolean indicating whether an arithmetic overflow would @@ -2526,7 +2673,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2557,7 +2704,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2588,7 +2735,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2619,7 +2766,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2860,8 +3007,8 @@ macro_rules! int_impl { /// ``` #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".isqrt(), 3);")] /// ``` - #[stable(feature = "isqrt", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "isqrt", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "isqrt", since = "1.84.0")] + #[rustc_const_stable(feature = "isqrt", since = "1.84.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -2887,7 +3034,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0 or if `self` is `Self::MIN` + /// This function will panic if `rhs` is zero or if `self` is `Self::MIN` /// and `rhs` is -1. This behavior is not affected by the `overflow-checks` flag. /// /// # Examples @@ -2926,7 +3073,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0 or if `self` is `Self::MIN` and + /// This function will panic if `rhs` is zero or if `self` is `Self::MIN` and /// `rhs` is -1. This behavior is not affected by the `overflow-checks` flag. /// /// # Examples @@ -2975,7 +3122,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0 or if `self` is `Self::MIN` + /// This function will panic if `rhs` is zero or if `self` is `Self::MIN` /// and `rhs` is -1. This behavior is not affected by the `overflow-checks` flag. /// /// # Examples @@ -3019,7 +3166,7 @@ macro_rules! int_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0 or if `self` is `Self::MIN` + /// This function will panic if `rhs` is zero or if `self` is `Self::MIN` /// and `rhs` is -1. This behavior is not affected by the `overflow-checks` flag. /// /// # Examples @@ -3480,7 +3627,7 @@ macro_rules! int_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - pub const fn to_be_bytes(self) -> [u8; mem::size_of::()] { + pub const fn to_be_bytes(self) -> [u8; size_of::()] { self.to_be().to_ne_bytes() } @@ -3500,7 +3647,7 @@ macro_rules! int_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - pub const fn to_le_bytes(self) -> [u8; mem::size_of::()] { + pub const fn to_le_bytes(self) -> [u8; size_of::()] { self.to_le().to_ne_bytes() } @@ -3536,7 +3683,7 @@ macro_rules! int_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - pub const fn to_ne_bytes(self) -> [u8; mem::size_of::()] { + pub const fn to_ne_bytes(self) -> [u8; size_of::()] { // SAFETY: integers are plain old datatypes so we can always transmute them to // arrays of bytes unsafe { mem::transmute(self) } @@ -3558,7 +3705,7 @@ macro_rules! int_impl { /// /// ``` #[doc = concat!("fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")] - #[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")] + #[doc = concat!(" let (int_bytes, rest) = input.split_at(size_of::<", stringify!($SelfT), ">());")] /// *input = rest; #[doc = concat!(" ", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap())")] /// } @@ -3567,7 +3714,7 @@ macro_rules! int_impl { #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[must_use] #[inline] - pub const fn from_be_bytes(bytes: [u8; mem::size_of::()]) -> Self { + pub const fn from_be_bytes(bytes: [u8; size_of::()]) -> Self { Self::from_be(Self::from_ne_bytes(bytes)) } @@ -3587,7 +3734,7 @@ macro_rules! int_impl { /// /// ``` #[doc = concat!("fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")] - #[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")] + #[doc = concat!(" let (int_bytes, rest) = input.split_at(size_of::<", stringify!($SelfT), ">());")] /// *input = rest; #[doc = concat!(" ", stringify!($SelfT), "::from_le_bytes(int_bytes.try_into().unwrap())")] /// } @@ -3596,7 +3743,7 @@ macro_rules! int_impl { #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[must_use] #[inline] - pub const fn from_le_bytes(bytes: [u8; mem::size_of::()]) -> Self { + pub const fn from_le_bytes(bytes: [u8; size_of::()]) -> Self { Self::from_le(Self::from_ne_bytes(bytes)) } @@ -3627,7 +3774,7 @@ macro_rules! int_impl { /// /// ``` #[doc = concat!("fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")] - #[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")] + #[doc = concat!(" let (int_bytes, rest) = input.split_at(size_of::<", stringify!($SelfT), ">());")] /// *input = rest; #[doc = concat!(" ", stringify!($SelfT), "::from_ne_bytes(int_bytes.try_into().unwrap())")] /// } @@ -3638,7 +3785,7 @@ macro_rules! int_impl { // SAFETY: const sound because integers are plain old datatypes so we can always // transmute to them #[inline] - pub const fn from_ne_bytes(bytes: [u8; mem::size_of::()]) -> Self { + pub const fn from_ne_bytes(bytes: [u8; size_of::()]) -> Self { // SAFETY: integers are plain old datatypes so we can always transmute to them unsafe { mem::transmute(bytes) } } diff --git a/core/src/num/int_sqrt.rs b/core/src/num/int_sqrt.rs index 601e81f69930f..c7a322c08c139 100644 --- a/core/src/num/int_sqrt.rs +++ b/core/src/num/int_sqrt.rs @@ -37,7 +37,7 @@ const U8_ISQRT_WITH_REMAINDER: [(u8, u8); 256] = { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] -pub const fn u8(n: u8) -> u8 { +pub(super) const fn u8(n: u8) -> u8 { U8_ISQRT_WITH_REMAINDER[n as usize].0 } @@ -58,7 +58,7 @@ macro_rules! signed_fn { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - pub const unsafe fn $SignedT(n: $SignedT) -> $SignedT { + pub(super) const unsafe fn $SignedT(n: $SignedT) -> $SignedT { debug_assert!(n >= 0, "Negative input inside `isqrt`."); $UnsignedT(n as $UnsignedT) as $SignedT } @@ -83,7 +83,7 @@ macro_rules! unsigned_fn { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - pub const fn $UnsignedT(mut n: $UnsignedT) -> $UnsignedT { + pub(super) const fn $UnsignedT(mut n: $UnsignedT) -> $UnsignedT { if n <= <$HalfBitsT>::MAX as $UnsignedT { $HalfBitsT(n as $HalfBitsT) as $UnsignedT } else { @@ -311,6 +311,6 @@ unsigned_fn!(u128, u64, u128_stages); /// on every single primitive type. #[cold] #[track_caller] -pub const fn panic_for_negative_argument() -> ! { +pub(super) const fn panic_for_negative_argument() -> ! { panic!("argument of integer square root cannot be negative") } diff --git a/core/src/num/mod.rs b/core/src/num/mod.rs index 9d9897b9cf05e..151e128cd78a9 100644 --- a/core/src/num/mod.rs +++ b/core/src/num/mod.rs @@ -51,6 +51,10 @@ mod overflow_panic; mod saturating; mod wrapping; +/// 100% perma-unstable +#[doc(hidden)] +pub mod niche_types; + #[stable(feature = "rust1", since = "1.0.0")] #[cfg(not(no_fp_fmt_parse))] pub use dec2flt::ParseFloatError; @@ -77,6 +81,31 @@ pub use saturating::Saturating; #[stable(feature = "rust1", since = "1.0.0")] pub use wrapping::Wrapping; +macro_rules! u8_xe_bytes_doc { + () => { + " + +**Note**: This function is meaningless on `u8`. Byte order does not exist as a +concept for byte-sized integers. This function is only provided in symmetry +with larger integer types. + +" + }; +} + +macro_rules! i8_xe_bytes_doc { + () => { + " + +**Note**: This function is meaningless on `i8`. Byte order does not exist as a +concept for byte-sized integers. This function is only provided in symmetry +with larger integer types. You can cast from and to `u8` using `as i8` and `as +u8`. + +" + }; +} + macro_rules! usize_isize_to_xe_bytes_doc { () => { " @@ -103,18 +132,18 @@ macro_rules! midpoint_impl { ($SelfT:ty, unsigned) => { /// Calculates the middle point of `self` and `rhs`. /// - /// `midpoint(a, b)` is `(a + b) >> 1` as if it were performed in a - /// sufficiently-large signed integral type. This implies that the result is - /// always rounded towards negative infinity and that no overflow will ever occur. + /// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a + /// sufficiently-large unsigned integral type. This implies that the result is + /// always rounded towards zero and that no overflow will ever occur. /// /// # Examples /// /// ``` - /// #![feature(num_midpoint)] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(4), 2);")] #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".midpoint(4), 2);")] /// ``` - #[unstable(feature = "num_midpoint", issue = "110840")] + #[stable(feature = "num_midpoint", since = "1.85.0")] + #[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -134,14 +163,14 @@ macro_rules! midpoint_impl { /// # Examples /// /// ``` - /// #![feature(num_midpoint)] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(4), 2);")] #[doc = concat!("assert_eq!((-1", stringify!($SelfT), ").midpoint(2), 0);")] #[doc = concat!("assert_eq!((-7", stringify!($SelfT), ").midpoint(0), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(-7), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(7), 3);")] /// ``` - #[unstable(feature = "num_midpoint", issue = "110840")] + #[stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -157,18 +186,18 @@ macro_rules! midpoint_impl { ($SelfT:ty, $WideT:ty, unsigned) => { /// Calculates the middle point of `self` and `rhs`. /// - /// `midpoint(a, b)` is `(a + b) >> 1` as if it were performed in a - /// sufficiently-large signed integral type. This implies that the result is - /// always rounded towards negative infinity and that no overflow will ever occur. + /// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a + /// sufficiently-large unsigned integral type. This implies that the result is + /// always rounded towards zero and that no overflow will ever occur. /// /// # Examples /// /// ``` - /// #![feature(num_midpoint)] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(4), 2);")] #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".midpoint(4), 2);")] /// ``` - #[unstable(feature = "num_midpoint", issue = "110840")] + #[stable(feature = "num_midpoint", since = "1.85.0")] + #[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -186,14 +215,14 @@ macro_rules! midpoint_impl { /// # Examples /// /// ``` - /// #![feature(num_midpoint)] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(4), 2);")] #[doc = concat!("assert_eq!((-1", stringify!($SelfT), ").midpoint(2), 0);")] #[doc = concat!("assert_eq!((-7", stringify!($SelfT), ").midpoint(0), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(-7), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(7), 3);")] /// ``` - #[unstable(feature = "num_midpoint", issue = "110840")] + #[stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -203,134 +232,6 @@ macro_rules! midpoint_impl { }; } -macro_rules! widening_impl { - ($SelfT:ty, $WideT:ty, $BITS:literal, unsigned) => { - /// Calculates the complete product `self * rhs` without the possibility to overflow. - /// - /// This returns the low-order (wrapping) bits and the high-order (overflow) bits - /// of the result as two separate values, in that order. - /// - /// If you also need to add a carry to the wide result, then you want - /// [`Self::carrying_mul`] instead. - /// - /// # Examples - /// - /// Basic usage: - /// - /// Please note that this example is shared between integer types. - /// Which explains why `u32` is used here. - /// - /// ``` - /// #![feature(bigint_helper_methods)] - /// assert_eq!(5u32.widening_mul(2), (10, 0)); - /// assert_eq!(1_000_000_000u32.widening_mul(10), (1410065408, 2)); - /// ``` - #[unstable(feature = "bigint_helper_methods", issue = "85532")] - #[must_use = "this returns the result of the operation, \ - without modifying the original"] - #[inline] - pub const fn widening_mul(self, rhs: Self) -> (Self, Self) { - // note: longer-term this should be done via an intrinsic, - // but for now we can deal without an impl for u128/i128 - // SAFETY: overflow will be contained within the wider types - let wide = unsafe { (self as $WideT).unchecked_mul(rhs as $WideT) }; - (wide as $SelfT, (wide >> $BITS) as $SelfT) - } - - /// Calculates the "full multiplication" `self * rhs + carry` - /// without the possibility to overflow. - /// - /// This returns the low-order (wrapping) bits and the high-order (overflow) bits - /// of the result as two separate values, in that order. - /// - /// Performs "long multiplication" which takes in an extra amount to add, and may return an - /// additional amount of overflow. This allows for chaining together multiple - /// multiplications to create "big integers" which represent larger values. - /// - /// If you don't need the `carry`, then you can use [`Self::widening_mul`] instead. - /// - /// # Examples - /// - /// Basic usage: - /// - /// Please note that this example is shared between integer types. - /// Which explains why `u32` is used here. - /// - /// ``` - /// #![feature(bigint_helper_methods)] - /// assert_eq!(5u32.carrying_mul(2, 0), (10, 0)); - /// assert_eq!(5u32.carrying_mul(2, 10), (20, 0)); - /// assert_eq!(1_000_000_000u32.carrying_mul(10, 0), (1410065408, 2)); - /// assert_eq!(1_000_000_000u32.carrying_mul(10, 10), (1410065418, 2)); - #[doc = concat!("assert_eq!(", - stringify!($SelfT), "::MAX.carrying_mul(", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX), ", - "(0, ", stringify!($SelfT), "::MAX));" - )] - /// ``` - /// - /// This is the core operation needed for scalar multiplication when - /// implementing it for wider-than-native types. - /// - /// ``` - /// #![feature(bigint_helper_methods)] - /// fn scalar_mul_eq(little_endian_digits: &mut Vec, multiplicand: u16) { - /// let mut carry = 0; - /// for d in little_endian_digits.iter_mut() { - /// (*d, carry) = d.carrying_mul(multiplicand, carry); - /// } - /// if carry != 0 { - /// little_endian_digits.push(carry); - /// } - /// } - /// - /// let mut v = vec![10, 20]; - /// scalar_mul_eq(&mut v, 3); - /// assert_eq!(v, [30, 60]); - /// - /// assert_eq!(0x87654321_u64 * 0xFEED, 0x86D3D159E38D); - /// let mut v = vec![0x4321, 0x8765]; - /// scalar_mul_eq(&mut v, 0xFEED); - /// assert_eq!(v, [0xE38D, 0xD159, 0x86D3]); - /// ``` - /// - /// If `carry` is zero, this is similar to [`overflowing_mul`](Self::overflowing_mul), - /// except that it gives the value of the overflow instead of just whether one happened: - /// - /// ``` - /// #![feature(bigint_helper_methods)] - /// let r = u8::carrying_mul(7, 13, 0); - /// assert_eq!((r.0, r.1 != 0), u8::overflowing_mul(7, 13)); - /// let r = u8::carrying_mul(13, 42, 0); - /// assert_eq!((r.0, r.1 != 0), u8::overflowing_mul(13, 42)); - /// ``` - /// - /// The value of the first field in the returned tuple matches what you'd get - /// by combining the [`wrapping_mul`](Self::wrapping_mul) and - /// [`wrapping_add`](Self::wrapping_add) methods: - /// - /// ``` - /// #![feature(bigint_helper_methods)] - /// assert_eq!( - /// 789_u16.carrying_mul(456, 123).0, - /// 789_u16.wrapping_mul(456).wrapping_add(123), - /// ); - /// ``` - #[unstable(feature = "bigint_helper_methods", issue = "85532")] - #[must_use = "this returns the result of the operation, \ - without modifying the original"] - #[inline] - pub const fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self) { - // note: longer-term this should be done via an intrinsic, - // but for now we can deal without an impl for u128/i128 - // SAFETY: overflow will be contained within the wider types - let wide = unsafe { - (self as $WideT).unchecked_mul(rhs as $WideT).unchecked_add(carry as $WideT) - }; - (wide as $SelfT, (wide >> $BITS) as $SelfT) - } - }; -} - impl i8 { int_impl! { Self = i8, @@ -348,8 +249,8 @@ impl i8 { reversed = "0x48", le_bytes = "[0x12]", be_bytes = "[0x12]", - to_xe_bytes_doc = "", - from_xe_bytes_doc = "", + to_xe_bytes_doc = i8_xe_bytes_doc!(), + from_xe_bytes_doc = i8_xe_bytes_doc!(), bound_condition = "", } midpoint_impl! { i8, i16, signed } @@ -547,11 +448,10 @@ impl u8 { reversed = "0x48", le_bytes = "[0x12]", be_bytes = "[0x12]", - to_xe_bytes_doc = "", - from_xe_bytes_doc = "", + to_xe_bytes_doc = u8_xe_bytes_doc!(), + from_xe_bytes_doc = u8_xe_bytes_doc!(), bound_condition = "", } - widening_impl! { u8, u16, 8, unsigned } midpoint_impl! { u8, u16, unsigned } /// Checks if the value is within the ASCII range. @@ -677,7 +577,7 @@ impl u8 { /// /// [`to_ascii_uppercase`]: Self::to_ascii_uppercase #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] - #[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_make_ascii", since = "1.84.0")] #[inline] pub const fn make_ascii_uppercase(&mut self) { *self = self.to_ascii_uppercase(); @@ -703,7 +603,7 @@ impl u8 { /// /// [`to_ascii_lowercase`]: Self::to_ascii_lowercase #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] - #[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_make_ascii", since = "1.84.0")] #[inline] pub const fn make_ascii_lowercase(&mut self) { *self = self.to_ascii_lowercase(); @@ -1167,7 +1067,6 @@ impl u16 { from_xe_bytes_doc = "", bound_condition = "", } - widening_impl! { u16, u32, 16, unsigned } midpoint_impl! { u16, u32, unsigned } /// Checks if the value is a Unicode surrogate code point, which are disallowed values for [`char`]. @@ -1215,7 +1114,6 @@ impl u32 { from_xe_bytes_doc = "", bound_condition = "", } - widening_impl! { u32, u64, 32, unsigned } midpoint_impl! { u32, u64, unsigned } } @@ -1239,7 +1137,6 @@ impl u64 { from_xe_bytes_doc = "", bound_condition = "", } - widening_impl! { u64, u128, 64, unsigned } midpoint_impl! { u64, u128, unsigned } } @@ -1289,7 +1186,6 @@ impl usize { from_xe_bytes_doc = usize_isize_from_xe_bytes_doc!(), bound_condition = " on 16-bit targets", } - widening_impl! { usize, u32, 16, unsigned } midpoint_impl! { usize, u32, unsigned } } @@ -1314,7 +1210,6 @@ impl usize { from_xe_bytes_doc = usize_isize_from_xe_bytes_doc!(), bound_condition = " on 32-bit targets", } - widening_impl! { usize, u64, 32, unsigned } midpoint_impl! { usize, u64, unsigned } } @@ -1339,7 +1234,6 @@ impl usize { from_xe_bytes_doc = usize_isize_from_xe_bytes_doc!(), bound_condition = " on 64-bit targets", } - widening_impl! { usize, u128, 64, unsigned } midpoint_impl! { usize, u128, unsigned } } @@ -1347,7 +1241,7 @@ impl usize { /// Returns an `usize` where every byte is equal to `x`. #[inline] pub(crate) const fn repeat_u8(x: u8) -> usize { - usize::from_ne_bytes([x; mem::size_of::()]) + usize::from_ne_bytes([x; size_of::()]) } /// Returns an `usize` where every byte pair is equal to `x`. @@ -1355,7 +1249,7 @@ impl usize { pub(crate) const fn repeat_u16(x: u16) -> usize { let mut r = 0usize; let mut i = 0; - while i < mem::size_of::() { + while i < size_of::() { // Use `wrapping_shl` to make it work on targets with 16-bit `usize` r = r.wrapping_shl(16) | (x as usize); i += 2; @@ -1428,20 +1322,6 @@ pub enum FpCategory { Normal, } -macro_rules! from_str_radix_int_impl { - ($($t:ty)*) => {$( - #[stable(feature = "rust1", since = "1.0.0")] - impl FromStr for $t { - type Err = ParseIntError; - #[inline] - fn from_str(src: &str) -> Result { - <$t>::from_str_radix(src, 10) - } - } - )*} -} -from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 } - /// Determines if a string of text of that length of that radix could be guaranteed to be /// stored in the given type T. /// Note that if the radix is known to the compiler, it is just the check of digits.len that @@ -1449,27 +1329,66 @@ from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 } #[doc(hidden)] #[inline(always)] #[unstable(issue = "none", feature = "std_internals")] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_from_str", since = "1.82.0"))] pub const fn can_not_overflow(radix: u32, is_signed_ty: bool, digits: &[u8]) -> bool { - radix <= 16 && digits.len() <= mem::size_of::() * 2 - is_signed_ty as usize + radix <= 16 && digits.len() <= size_of::() * 2 - is_signed_ty as usize } #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] -const fn from_str_radix_panic(radix: u32) -> ! { +const fn from_ascii_radix_panic(radix: u32) -> ! { const_panic!( - "from_str_radix_int: must lie in the range `[2, 36]`", - "from_str_radix_int: must lie in the range `[2, 36]` - found {radix}", + "from_ascii_radix: radix must lie in the range `[2, 36]`", + "from_ascii_radix: radix must lie in the range `[2, 36]` - found {radix}", radix: u32 = radix, ) } -macro_rules! from_str_radix { +macro_rules! from_str_int_impl { ($signedness:ident $($int_ty:ty)+) => {$( + #[stable(feature = "rust1", since = "1.0.0")] + impl FromStr for $int_ty { + type Err = ParseIntError; + + /// Parses an integer from a string slice with decimal digits. + /// + /// The characters are expected to be an optional + #[doc = sign_dependent_expr!{ + $signedness ? + if signed { + " `+` or `-` " + } + if unsigned { + " `+` " + } + }] + /// sign followed by only digits. Leading and trailing non-digit characters (including + /// whitespace) represent an error. Underscores (which are accepted in Rust literals) + /// also represent an error. + /// + /// # Examples + /// + /// Basic usage: + /// ``` + /// use std::str::FromStr; + /// + #[doc = concat!("assert_eq!(", stringify!($int_ty), "::from_str(\"+10\"), Ok(10));")] + /// ``` + /// Trailing space returns error: + /// ``` + /// # use std::str::FromStr; + /// # + #[doc = concat!("assert!(", stringify!($int_ty), "::from_str(\"1 \").is_err());")] + /// ``` + #[inline] + fn from_str(src: &str) -> Result<$int_ty, ParseIntError> { + <$int_ty>::from_str_radix(src, 10) + } + } + impl $int_ty { - /// Converts a string slice in a given base to an integer. + /// Parses an integer from a string slice with digits in a given base. /// /// The string is expected to be an optional #[doc = sign_dependent_expr!{ @@ -1482,7 +1401,7 @@ macro_rules! from_str_radix { } }] /// sign followed by only digits. Leading and trailing non-digit characters (including - /// whitespace) represent an error. Underscores (which are accepted in rust literals) + /// whitespace) represent an error. Underscores (which are accepted in Rust literals) /// also represent an error. /// /// Digits are a subset of these characters, depending on `radix`: @@ -1508,11 +1427,92 @@ macro_rules! from_str_radix { #[rustc_const_stable(feature = "const_int_from_str", since = "1.82.0")] #[inline] pub const fn from_str_radix(src: &str, radix: u32) -> Result<$int_ty, ParseIntError> { + <$int_ty>::from_ascii_radix(src.as_bytes(), radix) + } + + /// Parses an integer from an ASCII-byte slice with decimal digits. + /// + /// The characters are expected to be an optional + #[doc = sign_dependent_expr!{ + $signedness ? + if signed { + " `+` or `-` " + } + if unsigned { + " `+` " + } + }] + /// sign followed by only digits. Leading and trailing non-digit characters (including + /// whitespace) represent an error. Underscores (which are accepted in Rust literals) + /// also represent an error. + /// + /// # Examples + /// + /// Basic usage: + /// ``` + /// #![feature(int_from_ascii)] + /// + #[doc = concat!("assert_eq!(", stringify!($int_ty), "::from_ascii(b\"+10\"), Ok(10));")] + /// ``` + /// Trailing space returns error: + /// ``` + /// # #![feature(int_from_ascii)] + /// # + #[doc = concat!("assert!(", stringify!($int_ty), "::from_ascii(b\"1 \").is_err());")] + /// ``` + #[unstable(feature = "int_from_ascii", issue = "134821")] + #[inline] + pub const fn from_ascii(src: &[u8]) -> Result<$int_ty, ParseIntError> { + <$int_ty>::from_ascii_radix(src, 10) + } + + /// Parses an integer from an ASCII-byte slice with digits in a given base. + /// + /// The characters are expected to be an optional + #[doc = sign_dependent_expr!{ + $signedness ? + if signed { + " `+` or `-` " + } + if unsigned { + " `+` " + } + }] + /// sign followed by only digits. Leading and trailing non-digit characters (including + /// whitespace) represent an error. Underscores (which are accepted in Rust literals) + /// also represent an error. + /// + /// Digits are a subset of these characters, depending on `radix`: + /// * `0-9` + /// * `a-z` + /// * `A-Z` + /// + /// # Panics + /// + /// This function panics if `radix` is not in the range from 2 to 36. + /// + /// # Examples + /// + /// Basic usage: + /// ``` + /// #![feature(int_from_ascii)] + /// + #[doc = concat!("assert_eq!(", stringify!($int_ty), "::from_ascii_radix(b\"A\", 16), Ok(10));")] + /// ``` + /// Trailing space returns error: + /// ``` + /// # #![feature(int_from_ascii)] + /// # + #[doc = concat!("assert!(", stringify!($int_ty), "::from_ascii_radix(b\"1 \", 10).is_err());")] + /// ``` + #[unstable(feature = "int_from_ascii", issue = "134821")] + #[inline] + pub const fn from_ascii_radix(src: &[u8], radix: u32) -> Result<$int_ty, ParseIntError> { use self::IntErrorKind::*; use self::ParseIntError as PIE; if 2 > radix || radix > 36 { - from_str_radix_panic(radix); + from_ascii_radix_panic(radix); } if src.is_empty() { @@ -1522,12 +1522,6 @@ macro_rules! from_str_radix { #[allow(unused_comparisons)] let is_signed_ty = 0 > <$int_ty>::MIN; - // all valid digits are ascii, so we will just iterate over the utf8 bytes - // and cast them to chars. .to_digit() will safely return None for anything - // other than a valid ascii digit for the given radix, including the first-byte - // of multi-byte sequences - let src = src.as_bytes(); - let (is_positive, mut digits) = match src { [b'+' | b'-'] => { return Err(PIE { kind: InvalidDigit }); @@ -1603,67 +1597,8 @@ macro_rules! from_str_radix { Ok(result) } } - )+} -} - -from_str_radix! { unsigned u8 u16 u32 u64 u128 } -from_str_radix! { signed i8 i16 i32 i64 i128 } - -// Re-use the relevant implementation of from_str_radix for isize and usize to avoid outputting two -// identical functions. -macro_rules! from_str_radix_size_impl { - ($($signedness:ident $t:ident $size:ty),*) => {$( - impl $size { - /// Converts a string slice in a given base to an integer. - /// - /// The string is expected to be an optional - #[doc = sign_dependent_expr!{ - $signedness ? - if signed { - " `+` or `-` " - } - if unsigned { - " `+` " - } - }] - /// sign followed by only digits. Leading and trailing non-digit characters (including - /// whitespace) represent an error. Underscores (which are accepted in rust literals) - /// also represent an error. - /// - /// Digits are a subset of these characters, depending on `radix`: - /// * `0-9` - /// * `a-z` - /// * `A-Z` - /// - /// # Panics - /// - /// This function panics if `radix` is not in the range from 2 to 36. - /// - /// # Examples - /// - /// Basic usage: - /// ``` - #[doc = concat!("assert_eq!(", stringify!($size), "::from_str_radix(\"A\", 16), Ok(10));")] - /// ``` - /// Trailing space returns error: - /// ``` - #[doc = concat!("assert!(", stringify!($size), "::from_str_radix(\"1 \", 10).is_err());")] - /// ``` - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_int_from_str", since = "1.82.0")] - #[inline] - pub const fn from_str_radix(src: &str, radix: u32) -> Result<$size, ParseIntError> { - match <$t>::from_str_radix(src, radix) { - Ok(x) => Ok(x as $size), - Err(e) => Err(e), - } - } - })*} + )*} } -#[cfg(target_pointer_width = "16")] -from_str_radix_size_impl! { signed i16 isize, unsigned u16 usize } -#[cfg(target_pointer_width = "32")] -from_str_radix_size_impl! { signed i32 isize, unsigned u32 usize } -#[cfg(target_pointer_width = "64")] -from_str_radix_size_impl! { signed i64 isize, unsigned u64 usize } +from_str_int_impl! { signed isize i8 i16 i32 i64 i128 } +from_str_int_impl! { unsigned usize u8 u16 u32 u64 u128 } diff --git a/core/src/num/niche_types.rs b/core/src/num/niche_types.rs new file mode 100644 index 0000000000000..47ff4254e533b --- /dev/null +++ b/core/src/num/niche_types.rs @@ -0,0 +1,178 @@ +#![unstable( + feature = "temporary_niche_types", + issue = "none", + reason = "for core, alloc, and std internals until pattern types are further along" +)] + +use crate::cmp::Ordering; +use crate::fmt; +use crate::hash::{Hash, Hasher}; +use crate::marker::StructuralPartialEq; + +macro_rules! define_valid_range_type { + ($( + $(#[$m:meta])* + $vis:vis struct $name:ident($int:ident as $uint:ident in $low:literal..=$high:literal); + )+) => {$( + #[derive(Clone, Copy, Eq)] + #[repr(transparent)] + #[rustc_layout_scalar_valid_range_start($low)] + #[rustc_layout_scalar_valid_range_end($high)] + $(#[$m])* + $vis struct $name($int); + + const _: () = { + // With the `valid_range` attributes, it's always specified as unsigned + assert!(<$uint>::MIN == 0); + let ulow: $uint = $low; + let uhigh: $uint = $high; + assert!(ulow <= uhigh); + + assert!(size_of::<$int>() == size_of::<$uint>()); + }; + + impl $name { + #[inline] + pub const fn new(val: $int) -> Option { + if (val as $uint) >= ($low as $uint) && (val as $uint) <= ($high as $uint) { + // SAFETY: just checked the inclusive range + Some(unsafe { $name(val) }) + } else { + None + } + } + + /// Constructs an instance of this type from the underlying integer + /// primitive without checking whether its zero. + /// + /// # Safety + /// Immediate language UB if `val == 0`, as it violates the validity + /// invariant of this type. + #[inline] + pub const unsafe fn new_unchecked(val: $int) -> Self { + // SAFETY: Caller promised that `val` is non-zero. + unsafe { $name(val) } + } + + #[inline] + pub const fn as_inner(self) -> $int { + // SAFETY: This is a transparent wrapper, so unwrapping it is sound + // (Not using `.0` due to MCP#807.) + unsafe { crate::mem::transmute(self) } + } + } + + // This is required to allow matching a constant. We don't get it from a derive + // because the derived `PartialEq` would do a field projection, which is banned + // by . + impl StructuralPartialEq for $name {} + + impl PartialEq for $name { + #[inline] + fn eq(&self, other: &Self) -> bool { + self.as_inner() == other.as_inner() + } + } + + impl Ord for $name { + #[inline] + fn cmp(&self, other: &Self) -> Ordering { + Ord::cmp(&self.as_inner(), &other.as_inner()) + } + } + + impl PartialOrd for $name { + #[inline] + fn partial_cmp(&self, other: &Self) -> Option { + Some(Ord::cmp(self, other)) + } + } + + impl Hash for $name { + // Required method + fn hash(&self, state: &mut H) { + Hash::hash(&self.as_inner(), state); + } + } + + impl fmt::Debug for $name { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + <$int as fmt::Debug>::fmt(&self.as_inner(), f) + } + } + )+}; +} + +define_valid_range_type! { + pub struct Nanoseconds(u32 as u32 in 0..=999_999_999); +} + +impl Nanoseconds { + // SAFETY: 0 is within the valid range + pub const ZERO: Self = unsafe { Nanoseconds::new_unchecked(0) }; +} + +impl Default for Nanoseconds { + #[inline] + fn default() -> Self { + Self::ZERO + } +} + +define_valid_range_type! { + pub struct NonZeroU8Inner(u8 as u8 in 1..=0xff); + pub struct NonZeroU16Inner(u16 as u16 in 1..=0xff_ff); + pub struct NonZeroU32Inner(u32 as u32 in 1..=0xffff_ffff); + pub struct NonZeroU64Inner(u64 as u64 in 1..=0xffffffff_ffffffff); + pub struct NonZeroU128Inner(u128 as u128 in 1..=0xffffffffffffffff_ffffffffffffffff); + + pub struct NonZeroI8Inner(i8 as u8 in 1..=0xff); + pub struct NonZeroI16Inner(i16 as u16 in 1..=0xff_ff); + pub struct NonZeroI32Inner(i32 as u32 in 1..=0xffff_ffff); + pub struct NonZeroI64Inner(i64 as u64 in 1..=0xffffffff_ffffffff); + pub struct NonZeroI128Inner(i128 as u128 in 1..=0xffffffffffffffff_ffffffffffffffff); +} + +#[cfg(target_pointer_width = "16")] +define_valid_range_type! { + pub struct UsizeNoHighBit(usize as usize in 0..=0x7fff); + pub struct NonZeroUsizeInner(usize as usize in 1..=0xffff); + pub struct NonZeroIsizeInner(isize as usize in 1..=0xffff); +} +#[cfg(target_pointer_width = "32")] +define_valid_range_type! { + pub struct UsizeNoHighBit(usize as usize in 0..=0x7fff_ffff); + pub struct NonZeroUsizeInner(usize as usize in 1..=0xffff_ffff); + pub struct NonZeroIsizeInner(isize as usize in 1..=0xffff_ffff); +} +#[cfg(target_pointer_width = "64")] +define_valid_range_type! { + pub struct UsizeNoHighBit(usize as usize in 0..=0x7fff_ffff_ffff_ffff); + pub struct NonZeroUsizeInner(usize as usize in 1..=0xffff_ffff_ffff_ffff); + pub struct NonZeroIsizeInner(isize as usize in 1..=0xffff_ffff_ffff_ffff); +} + +define_valid_range_type! { + pub struct U32NotAllOnes(u32 as u32 in 0..=0xffff_fffe); + pub struct I32NotAllOnes(i32 as u32 in 0..=0xffff_fffe); + + pub struct U64NotAllOnes(u64 as u64 in 0..=0xffff_ffff_ffff_fffe); + pub struct I64NotAllOnes(i64 as u64 in 0..=0xffff_ffff_ffff_fffe); +} + +pub trait NotAllOnesHelper { + type Type; +} +pub type NotAllOnes = ::Type; +impl NotAllOnesHelper for u32 { + type Type = U32NotAllOnes; +} +impl NotAllOnesHelper for i32 { + type Type = I32NotAllOnes; +} +impl NotAllOnesHelper for u64 { + type Type = U64NotAllOnes; +} +impl NotAllOnesHelper for i64 { + type Type = I64NotAllOnes; +} diff --git a/core/src/num/nonzero.rs b/core/src/num/nonzero.rs index b883a0c2ec7f9..7585ec140e31e 100644 --- a/core/src/num/nonzero.rs +++ b/core/src/num/nonzero.rs @@ -1,6 +1,7 @@ //! Definitions of integer that is known not to equal zero. use super::{IntErrorKind, ParseIntError}; +use crate::clone::UseCloned; use crate::cmp::Ordering; use crate::hash::{Hash, Hasher}; use crate::marker::{Freeze, StructuralPartialEq}; @@ -43,19 +44,6 @@ macro_rules! impl_zeroable_primitive { issue = "none" )] pub trait Sealed {} - - $( - #[derive(Debug, Clone, Copy, PartialEq)] - #[repr(transparent)] - #[rustc_layout_scalar_valid_range_start(1)] - #[rustc_nonnull_optimization_guaranteed] - #[unstable( - feature = "nonzero_internals", - reason = "implementation detail which may disappear or be replaced at any time", - issue = "none" - )] - pub struct $NonZeroInner($primitive); - )+ } $( @@ -72,7 +60,7 @@ macro_rules! impl_zeroable_primitive { issue = "none" )] unsafe impl ZeroablePrimitive for $primitive { - type NonZeroInner = private::$NonZeroInner; + type NonZeroInner = super::niche_types::$NonZeroInner; } )+ }; @@ -99,10 +87,29 @@ impl_zeroable_primitive!( /// For example, `Option>` is the same size as `u32`: /// /// ``` -/// use core::{mem::size_of, num::NonZero}; +/// use core::{num::NonZero}; /// /// assert_eq!(size_of::>>(), size_of::()); /// ``` +/// +/// # Layout +/// +/// `NonZero` is guaranteed to have the same layout and bit validity as `T` +/// with the exception that the all-zero bit pattern is invalid. +/// `Option>` is guaranteed to be compatible with `T`, including in +/// FFI. +/// +/// Thanks to the [null pointer optimization], `NonZero` and +/// `Option>` are guaranteed to have the same size and alignment: +/// +/// ``` +/// use std::num::NonZero; +/// +/// assert_eq!(size_of::>(), size_of::>>()); +/// assert_eq!(align_of::>(), align_of::>>()); +/// ``` +/// +/// [null pointer optimization]: crate::option#representation #[stable(feature = "generic_nonzero", since = "1.79.0")] #[repr(transparent)] #[rustc_nonnull_optimization_guaranteed] @@ -139,9 +146,9 @@ impl_nonzero_fmt! { LowerHex #[stable(feature = "nonzero", since = "1.28.0")] UpperHex - #[stable(feature = "nonzero_fmt_exp", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "nonzero_fmt_exp", since = "1.84.0")] LowerExp - #[stable(feature = "nonzero_fmt_exp", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "nonzero_fmt_exp", since = "1.84.0")] UpperExp } @@ -172,10 +179,13 @@ where { #[inline] fn clone(&self) -> Self { - Self(self.0) + *self } } +#[unstable(feature = "ergonomic_clones", issue = "132290")] +impl UseCloned for NonZero where T: ZeroablePrimitive {} + #[stable(feature = "nonzero", since = "1.28.0")] impl Copy for NonZero where T: ZeroablePrimitive {} @@ -440,15 +450,21 @@ where #[rustc_const_stable(feature = "const_nonzero_get", since = "1.34.0")] #[inline] pub const fn get(self) -> T { - // FIXME: This can be changed to simply `self.0` once LLVM supports `!range` metadata - // for function arguments: https://github.com/llvm/llvm-project/issues/76628 - // // Rustc can set range metadata only if it loads `self` from // memory somewhere. If the value of `self` was from by-value argument // of some not-inlined function, LLVM don't have range metadata // to understand that the value cannot be zero. // - // For now, using the transmute `assume`s the range at runtime. + // Using the transmute `assume`s the range at runtime. + // + // Even once LLVM supports `!range` metadata for function arguments + // (see ), this can't + // be `.0` because MCP#807 bans field-projecting into `scalar_valid_range` + // types, and it arguably wouldn't want to be anyway because if this is + // MIR-inlined, there's no opportunity to put that argument metadata anywhere. + // + // The good answer here will eventually be pattern types, which will hopefully + // allow it to go back to `.0`, maybe with a cast of some sort. // // SAFETY: `ZeroablePrimitive` guarantees that the size and bit validity // of `.0` is such that this transmute is sound. @@ -461,6 +477,7 @@ macro_rules! nonzero_integer { #[$stability:meta] Self = $Ty:ident, Primitive = $signedness:ident $Int:ident, + SignedPrimitive = $Sint:ty, UnsignedPrimitive = $Uint:ty, // Used in doc comments. @@ -486,7 +503,6 @@ macro_rules! nonzero_integer { #[doc = concat!("For example, `Option<", stringify!($Ty), ">` is the same size as `", stringify!($Int), "`:")] /// /// ```rust - /// use std::mem::size_of; #[doc = concat!("assert_eq!(size_of::>(), size_of::<", stringify!($Int), ">());")] /// ``` /// @@ -502,7 +518,6 @@ macro_rules! nonzero_integer { /// are guaranteed to have the same size and alignment: /// /// ``` - /// # use std::mem::{size_of, align_of}; #[doc = concat!("use std::num::", stringify!($Ty), ";")] /// #[doc = concat!("assert_eq!(size_of::<", stringify!($Ty), ">(), size_of::>());")] @@ -591,6 +606,70 @@ macro_rules! nonzero_integer { } } + /// Returns `self` with only the most significant bit set. + /// + /// # Example + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + /// # use core::num::NonZero; + /// # fn main() { test().unwrap(); } + /// # fn test() -> Option<()> { + #[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")] + #[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_01000000)?;")] + /// + /// assert_eq!(a.isolate_most_significant_one(), b); + /// # Some(()) + /// # } + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_most_significant_one(self) -> Self { + let n = self.get() & (((1 as $Int) << (<$Int>::BITS - 1)).wrapping_shr(self.leading_zeros())); + + // SAFETY: + // `self` is non-zero, so masking to preserve only the most + // significant set bit will result in a non-zero `n`. + unsafe { NonZero::new_unchecked(n) } + } + + /// Returns `self` with only the least significant bit set. + /// + /// # Example + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + /// # use core::num::NonZero; + /// # fn main() { test().unwrap(); } + /// # fn test() -> Option<()> { + #[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")] + #[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_00000100)?;")] + /// + /// assert_eq!(a.isolate_least_significant_one(), b); + /// # Some(()) + /// # } + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_least_significant_one(self) -> Self { + let n = self.get(); + let n = n & n.wrapping_neg(); + + // SAFETY: `self` is non-zero, so `self` with only its least + // significant set bit will remain non-zero. + unsafe { NonZero::new_unchecked(n) } + } + /// Returns the number of ones in the binary representation of `self`. /// /// # Examples @@ -598,8 +677,6 @@ macro_rules! nonzero_integer { /// Basic usage: /// /// ``` - /// #![feature(non_zero_count_ones)] - /// /// # use std::num::NonZero; /// # /// # fn main() { test().unwrap(); } @@ -613,8 +690,8 @@ macro_rules! nonzero_integer { /// # } /// ``` /// - #[unstable(feature = "non_zero_count_ones", issue = "120287")] - #[rustc_const_unstable(feature = "non_zero_count_ones", issue = "120287")] + #[stable(feature = "non_zero_count_ones", since = "1.86.0")] + #[rustc_const_stable(feature = "non_zero_count_ones", since = "1.86.0")] #[doc(alias = "popcount")] #[doc(alias = "popcnt")] #[must_use = "this returns the result of the operation, \ @@ -893,6 +970,7 @@ macro_rules! nonzero_integer { nonzero_integer_signedness_dependent_methods! { Primitive = $signedness $Int, + SignedPrimitive = $Sint, UnsignedPrimitive = $Uint, } @@ -1116,6 +1194,7 @@ macro_rules! nonzero_integer { ( Self = $Ty:ident, Primitive = unsigned $Int:ident, + SignedPrimitive = $Sint:ident, rot = $rot:literal, rot_op = $rot_op:literal, rot_result = $rot_result:literal, @@ -1128,6 +1207,7 @@ macro_rules! nonzero_integer { #[stable(feature = "nonzero", since = "1.28.0")] Self = $Ty, Primitive = unsigned $Int, + SignedPrimitive = $Sint, UnsignedPrimitive = $Int, rot = $rot, rot_op = $rot_op, @@ -1142,7 +1222,7 @@ macro_rules! nonzero_integer { ( Self = $Ty:ident, Primitive = signed $Int:ident, - UnsignedPrimitive = $UInt:ident, + UnsignedPrimitive = $Uint:ident, rot = $rot:literal, rot_op = $rot_op:literal, rot_result = $rot_result:literal, @@ -1154,7 +1234,8 @@ macro_rules! nonzero_integer { #[stable(feature = "signed_nonzero", since = "1.34.0")] Self = $Ty, Primitive = signed $Int, - UnsignedPrimitive = $UInt, + SignedPrimitive = $Int, + UnsignedPrimitive = $Uint, rot = $rot, rot_op = $rot_op, rot_result = $rot_result, @@ -1173,8 +1254,12 @@ macro_rules! nonzero_integer_signedness_dependent_impls { impl Div> for $Int { type Output = $Int; + /// Same as `self / other.get()`, but because `other` is a `NonZero<_>`, + /// there's never a runtime check for division-by-zero. + /// /// This operation rounds towards zero, truncating any fractional /// part of the exact result, and cannot panic. + #[doc(alias = "unchecked_div")] #[inline] fn div(self, other: NonZero<$Int>) -> $Int { // SAFETY: Division by zero is checked because `other` is non-zero, @@ -1185,6 +1270,9 @@ macro_rules! nonzero_integer_signedness_dependent_impls { #[stable(feature = "nonzero_div_assign", since = "1.79.0")] impl DivAssign> for $Int { + /// Same as `self /= other.get()`, but because `other` is a `NonZero<_>`, + /// there's never a runtime check for division-by-zero. + /// /// This operation rounds towards zero, truncating any fractional /// part of the exact result, and cannot panic. #[inline] @@ -1267,6 +1355,7 @@ macro_rules! nonzero_integer_signedness_dependent_methods { // Associated items for unsigned nonzero types only. ( Primitive = unsigned $Int:ident, + SignedPrimitive = $Sint:ty, UnsignedPrimitive = $Uint:ty, ) => { /// The smallest value that can be represented by this non-zero @@ -1509,8 +1598,6 @@ macro_rules! nonzero_integer_signedness_dependent_methods { /// # Examples /// /// ``` - /// #![feature(num_midpoint)] - /// /// # use std::num::NonZero; /// # /// # fn main() { test().unwrap(); } @@ -1524,7 +1611,8 @@ macro_rules! nonzero_integer_signedness_dependent_methods { /// # Some(()) /// # } /// ``` - #[unstable(feature = "num_midpoint", issue = "110840")] + #[stable(feature = "num_midpoint", since = "1.85.0")] + #[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1587,8 +1675,8 @@ macro_rules! nonzero_integer_signedness_dependent_methods { /// # Some(()) /// # } /// ``` - #[stable(feature = "isqrt", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "isqrt", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "isqrt", since = "1.84.0")] + #[rustc_const_stable(feature = "isqrt", since = "1.84.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1602,11 +1690,35 @@ macro_rules! nonzero_integer_signedness_dependent_methods { // results will be sqrt(1), which is 1, so a result can't be zero. unsafe { Self::new_unchecked(result) } } + + /// Returns the bit pattern of `self` reinterpreted as a signed integer of the same size. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// # use std::num::NonZero; + /// + #[doc = concat!("let n = NonZero::<", stringify!($Int), ">::MAX;")] + /// + #[doc = concat!("assert_eq!(n.cast_signed(), NonZero::new(-1", stringify!($Sint), ").unwrap());")] + /// ``` + #[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn cast_signed(self) -> NonZero<$Sint> { + // SAFETY: `self.get()` can't be zero + unsafe { NonZero::new_unchecked(self.get().cast_signed()) } + } }; // Associated items for signed nonzero types only. ( Primitive = signed $Int:ident, + SignedPrimitive = $Sint:ty, UnsignedPrimitive = $Uint:ty, ) => { /// The smallest value that can be represented by this non-zero @@ -2017,12 +2129,37 @@ macro_rules! nonzero_integer_signedness_dependent_methods { // SAFETY: negation of nonzero cannot yield zero values. unsafe { Self::new_unchecked(result) } } + + /// Returns the bit pattern of `self` reinterpreted as an unsigned integer of the same size. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// # use std::num::NonZero; + /// + #[doc = concat!("let n = NonZero::new(-1", stringify!($Int), ").unwrap();")] + /// + #[doc = concat!("assert_eq!(n.cast_unsigned(), NonZero::<", stringify!($Uint), ">::MAX);")] + /// ``` + #[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn cast_unsigned(self) -> NonZero<$Uint> { + // SAFETY: `self.get()` can't be zero + unsafe { NonZero::new_unchecked(self.get().cast_unsigned()) } + } + }; } nonzero_integer! { Self = NonZeroU8, Primitive = unsigned u8, + SignedPrimitive = i8, rot = 2, rot_op = "0x82", rot_result = "0xa", @@ -2034,6 +2171,7 @@ nonzero_integer! { nonzero_integer! { Self = NonZeroU16, Primitive = unsigned u16, + SignedPrimitive = i16, rot = 4, rot_op = "0xa003", rot_result = "0x3a", @@ -2045,6 +2183,7 @@ nonzero_integer! { nonzero_integer! { Self = NonZeroU32, Primitive = unsigned u32, + SignedPrimitive = i32, rot = 8, rot_op = "0x10000b3", rot_result = "0xb301", @@ -2056,6 +2195,7 @@ nonzero_integer! { nonzero_integer! { Self = NonZeroU64, Primitive = unsigned u64, + SignedPrimitive = i64, rot = 12, rot_op = "0xaa00000000006e1", rot_result = "0x6e10aa", @@ -2067,6 +2207,7 @@ nonzero_integer! { nonzero_integer! { Self = NonZeroU128, Primitive = unsigned u128, + SignedPrimitive = i128, rot = 16, rot_op = "0x13f40000000000000000000000004f76", rot_result = "0x4f7613f4", @@ -2079,6 +2220,7 @@ nonzero_integer! { nonzero_integer! { Self = NonZeroUsize, Primitive = unsigned usize, + SignedPrimitive = isize, rot = 4, rot_op = "0xa003", rot_result = "0x3a", @@ -2091,6 +2233,7 @@ nonzero_integer! { nonzero_integer! { Self = NonZeroUsize, Primitive = unsigned usize, + SignedPrimitive = isize, rot = 8, rot_op = "0x10000b3", rot_result = "0xb301", @@ -2103,6 +2246,7 @@ nonzero_integer! { nonzero_integer! { Self = NonZeroUsize, Primitive = unsigned usize, + SignedPrimitive = isize, rot = 12, rot_op = "0xaa00000000006e1", rot_result = "0x6e10aa", diff --git a/core/src/num/overflow_panic.rs b/core/src/num/overflow_panic.rs index 203037ffb43ea..e30573dd3f392 100644 --- a/core/src/num/overflow_panic.rs +++ b/core/src/num/overflow_panic.rs @@ -4,48 +4,48 @@ #[cold] #[track_caller] -pub const fn add() -> ! { +pub(super) const fn add() -> ! { panic!("attempt to add with overflow") } #[cold] #[track_caller] -pub const fn sub() -> ! { +pub(super) const fn sub() -> ! { panic!("attempt to subtract with overflow") } #[cold] #[track_caller] -pub const fn mul() -> ! { +pub(super) const fn mul() -> ! { panic!("attempt to multiply with overflow") } #[cold] #[track_caller] -pub const fn div() -> ! { +pub(super) const fn div() -> ! { panic!("attempt to divide with overflow") } #[cold] #[track_caller] -pub const fn rem() -> ! { +pub(super) const fn rem() -> ! { panic!("attempt to calculate the remainder with overflow") } #[cold] #[track_caller] -pub const fn neg() -> ! { +pub(super) const fn neg() -> ! { panic!("attempt to negate with overflow") } #[cold] #[track_caller] -pub const fn shr() -> ! { +pub(super) const fn shr() -> ! { panic!("attempt to shift right with overflow") } #[cold] #[track_caller] -pub const fn shl() -> ! { +pub(super) const fn shl() -> ! { panic!("attempt to shift left with overflow") } diff --git a/core/src/num/uint_macros.rs b/core/src/num/uint_macros.rs index 0383c13fa082d..586892758398b 100644 --- a/core/src/num/uint_macros.rs +++ b/core/src/num/uint_macros.rs @@ -4,7 +4,7 @@ macro_rules! uint_impl { ActualT = $ActualT:ident, SignedT = $SignedT:ident, - // There are all for use *only* in doc comments. + // These are all for use *only* in doc comments. // As such, they're all passed as literals -- passing them as a string // literal is fine if they need to be multiple code tokens. // In non-comments, use the associated constants rather than these. @@ -213,6 +213,52 @@ macro_rules! uint_impl { (!self).trailing_zeros() } + /// Returns `self` with only the most significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_most_significant_one(), 0b_01000000); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_most_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_most_significant_one(self) -> Self { + self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros())) + } + + /// Returns `self` with only the least significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_least_significant_one(), 0b_00000100); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_least_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_least_significant_one(self) -> Self { + self & self.wrapping_neg() + } + /// Returns the bit pattern of `self` reinterpreted as a signed integer of the same size. /// /// This produces the same result as an `as` cast, but ensures that the bit-width remains @@ -223,13 +269,12 @@ macro_rules! uint_impl { /// Basic usage: /// /// ``` - /// #![feature(integer_sign_cast)] - /// #[doc = concat!("let n = ", stringify!($SelfT), "::MAX;")] /// #[doc = concat!("assert_eq!(n.cast_signed(), -1", stringify!($SignedT), ");")] /// ``` - #[unstable(feature = "integer_sign_cast", issue = "125882")] + #[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] @@ -1187,6 +1232,50 @@ macro_rules! uint_impl { self % rhs } + /// Same value as `self | other`, but UB if any bit position is set in both inputs. + /// + /// This is a situational micro-optimization for places where you'd rather + /// use addition on some platforms and bitwise or on other platforms, based + /// on exactly which instructions combine better with whatever else you're + /// doing. Note that there's no reason to bother using this for places + /// where it's clear from the operations involved that they can't overlap. + /// For example, if you're combining `u16`s into a `u32` with + /// `((a as u32) << 16) | (b as u32)`, that's fine, as the backend will + /// know those sides of the `|` are disjoint without needing help. + /// + /// # Examples + /// + /// ``` + /// #![feature(disjoint_bitor)] + /// + /// // SAFETY: `1` and `4` have no bits in common. + /// unsafe { + #[doc = concat!(" assert_eq!(1_", stringify!($SelfT), ".unchecked_disjoint_bitor(4), 5);")] + /// } + /// ``` + /// + /// # Safety + /// + /// Requires that `(self & other) == 0`, otherwise it's immediate UB. + /// + /// Equivalently, requires that `(self | other) == (self + other)`. + #[unstable(feature = "disjoint_bitor", issue = "135758")] + #[rustc_const_unstable(feature = "disjoint_bitor", issue = "135758")] + #[inline] + pub const unsafe fn unchecked_disjoint_bitor(self, other: Self) -> Self { + assert_unsafe_precondition!( + check_language_ub, + concat!(stringify!($SelfT), "::unchecked_disjoint_bitor cannot have overlapping bits"), + ( + lhs: $SelfT = self, + rhs: $SelfT = other, + ) => (lhs & rhs) == 0, + ); + + // SAFETY: Same precondition + unsafe { intrinsics::disjoint_bitor(self, other) } + } + /// Returns the logarithm of the number with respect to an arbitrary base, /// rounded down. /// @@ -1434,7 +1523,6 @@ macro_rules! uint_impl { /// ``` #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1499,7 +1587,6 @@ macro_rules! uint_impl { )] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "unchecked_shifts", issue = "85122"))] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn unchecked_shl(self, rhs: u32) -> Self { @@ -1526,11 +1613,11 @@ macro_rules! uint_impl { /// /// Basic usage: /// ``` - /// #![feature(unbounded_shifts)] #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(4), 0x10);")] #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(129), 0);")] /// ``` - #[unstable(feature = "unbounded_shifts", issue = "129375")] + #[stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1557,7 +1644,6 @@ macro_rules! uint_impl { /// ``` #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1622,7 +1708,6 @@ macro_rules! uint_impl { )] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "unchecked_shifts", issue = "85122"))] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn unchecked_shr(self, rhs: u32) -> Self { @@ -1649,11 +1734,11 @@ macro_rules! uint_impl { /// /// Basic usage: /// ``` - /// #![feature(unbounded_shifts)] #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(4), 0x1);")] #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(129), 0);")] /// ``` - #[unstable(feature = "unbounded_shifts", issue = "129375")] + #[stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1877,7 +1962,7 @@ macro_rules! uint_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2034,7 +2119,7 @@ macro_rules! uint_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2063,7 +2148,7 @@ macro_rules! uint_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2091,7 +2176,7 @@ macro_rules! uint_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2121,7 +2206,7 @@ macro_rules! uint_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2193,7 +2278,6 @@ macro_rules! uint_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))] pub const fn wrapping_shl(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds @@ -2226,7 +2310,6 @@ macro_rules! uint_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))] pub const fn wrapping_shr(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds @@ -2352,15 +2435,22 @@ macro_rules! uint_impl { /// assert_eq!((sum1, sum0), (9, 6)); /// ``` #[unstable(feature = "bigint_helper_methods", issue = "85532")] + #[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] pub const fn carrying_add(self, rhs: Self, carry: bool) -> (Self, bool) { // note: longer-term this should be done via an intrinsic, but this has been shown // to generate optimal code for now, and LLVM doesn't have an equivalent intrinsic - let (a, b) = self.overflowing_add(rhs); - let (c, d) = a.overflowing_add(carry as $SelfT); - (c, b || d) + let (a, c1) = self.overflowing_add(rhs); + let (b, c2) = a.overflowing_add(carry as $SelfT); + // Ideally LLVM would know this is disjoint without us telling them, + // but it doesn't + // SAFETY: Only one of `c1` and `c2` can be set. + // For c1 to be set we need to have overflowed, but if we did then + // `a` is at most `MAX-1`, which means that `c2` cannot possibly + // overflow because it's adding at most `1` (since it came from `bool`) + (b, unsafe { intrinsics::disjoint_bitor(c1, c2) }) } /// Calculates `self` + `rhs` with a signed `rhs`. @@ -2443,15 +2533,20 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!((diff1, diff0), (3, ", stringify!($SelfT), "::MAX));")] /// ``` #[unstable(feature = "bigint_helper_methods", issue = "85532")] + #[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] pub const fn borrowing_sub(self, rhs: Self, borrow: bool) -> (Self, bool) { // note: longer-term this should be done via an intrinsic, but this has been shown // to generate optimal code for now, and LLVM doesn't have an equivalent intrinsic - let (a, b) = self.overflowing_sub(rhs); - let (c, d) = a.overflowing_sub(borrow as $SelfT); - (c, b || d) + let (a, c1) = self.overflowing_sub(rhs); + let (b, c2) = a.overflowing_sub(borrow as $SelfT); + // SAFETY: Only one of `c1` and `c2` can be set. + // For c1 to be set we need to have underflowed, but if we did then + // `a` is nonzero, which means that `c2` cannot possibly + // underflow because it's subtracting at most `1` (since it came from `bool`) + (b, unsafe { intrinsics::disjoint_bitor(c1, c2) }) } /// Calculates `self` - `rhs` with a signed `rhs` @@ -2496,7 +2591,7 @@ macro_rules! uint_impl { without modifying the original"] #[inline] pub const fn abs_diff(self, other: Self) -> Self { - if mem::size_of::() == 1 { + if size_of::() == 1 { // Trick LLVM into generating the psadbw instruction when SSE2 // is available and this function is autovectorized for u8's. (self as i32).wrapping_sub(other as i32).abs() as Self @@ -2536,6 +2631,191 @@ macro_rules! uint_impl { (a as Self, b) } + /// Calculates the complete product `self * rhs` without the possibility to overflow. + /// + /// This returns the low-order (wrapping) bits and the high-order (overflow) bits + /// of the result as two separate values, in that order. + /// + /// If you also need to add a carry to the wide result, then you want + /// [`Self::carrying_mul`] instead. + /// + /// # Examples + /// + /// Basic usage: + /// + /// Please note that this example is shared between integer types. + /// Which explains why `u32` is used here. + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// assert_eq!(5u32.widening_mul(2), (10, 0)); + /// assert_eq!(1_000_000_000u32.widening_mul(10), (1410065408, 2)); + /// ``` + #[unstable(feature = "bigint_helper_methods", issue = "85532")] + #[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn widening_mul(self, rhs: Self) -> (Self, Self) { + Self::carrying_mul_add(self, rhs, 0, 0) + } + + /// Calculates the "full multiplication" `self * rhs + carry` + /// without the possibility to overflow. + /// + /// This returns the low-order (wrapping) bits and the high-order (overflow) bits + /// of the result as two separate values, in that order. + /// + /// Performs "long multiplication" which takes in an extra amount to add, and may return an + /// additional amount of overflow. This allows for chaining together multiple + /// multiplications to create "big integers" which represent larger values. + /// + /// If you don't need the `carry`, then you can use [`Self::widening_mul`] instead. + /// + /// # Examples + /// + /// Basic usage: + /// + /// Please note that this example is shared between integer types. + /// Which explains why `u32` is used here. + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// assert_eq!(5u32.carrying_mul(2, 0), (10, 0)); + /// assert_eq!(5u32.carrying_mul(2, 10), (20, 0)); + /// assert_eq!(1_000_000_000u32.carrying_mul(10, 0), (1410065408, 2)); + /// assert_eq!(1_000_000_000u32.carrying_mul(10, 10), (1410065418, 2)); + #[doc = concat!("assert_eq!(", + stringify!($SelfT), "::MAX.carrying_mul(", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX), ", + "(0, ", stringify!($SelfT), "::MAX));" + )] + /// ``` + /// + /// This is the core operation needed for scalar multiplication when + /// implementing it for wider-than-native types. + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// fn scalar_mul_eq(little_endian_digits: &mut Vec, multiplicand: u16) { + /// let mut carry = 0; + /// for d in little_endian_digits.iter_mut() { + /// (*d, carry) = d.carrying_mul(multiplicand, carry); + /// } + /// if carry != 0 { + /// little_endian_digits.push(carry); + /// } + /// } + /// + /// let mut v = vec![10, 20]; + /// scalar_mul_eq(&mut v, 3); + /// assert_eq!(v, [30, 60]); + /// + /// assert_eq!(0x87654321_u64 * 0xFEED, 0x86D3D159E38D); + /// let mut v = vec![0x4321, 0x8765]; + /// scalar_mul_eq(&mut v, 0xFEED); + /// assert_eq!(v, [0xE38D, 0xD159, 0x86D3]); + /// ``` + /// + /// If `carry` is zero, this is similar to [`overflowing_mul`](Self::overflowing_mul), + /// except that it gives the value of the overflow instead of just whether one happened: + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// let r = u8::carrying_mul(7, 13, 0); + /// assert_eq!((r.0, r.1 != 0), u8::overflowing_mul(7, 13)); + /// let r = u8::carrying_mul(13, 42, 0); + /// assert_eq!((r.0, r.1 != 0), u8::overflowing_mul(13, 42)); + /// ``` + /// + /// The value of the first field in the returned tuple matches what you'd get + /// by combining the [`wrapping_mul`](Self::wrapping_mul) and + /// [`wrapping_add`](Self::wrapping_add) methods: + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// assert_eq!( + /// 789_u16.carrying_mul(456, 123).0, + /// 789_u16.wrapping_mul(456).wrapping_add(123), + /// ); + /// ``` + #[unstable(feature = "bigint_helper_methods", issue = "85532")] + #[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self) { + Self::carrying_mul_add(self, rhs, carry, 0) + } + + /// Calculates the "full multiplication" `self * rhs + carry1 + carry2` + /// without the possibility to overflow. + /// + /// This returns the low-order (wrapping) bits and the high-order (overflow) bits + /// of the result as two separate values, in that order. + /// + /// Performs "long multiplication" which takes in an extra amount to add, and may return an + /// additional amount of overflow. This allows for chaining together multiple + /// multiplications to create "big integers" which represent larger values. + /// + /// If you don't need either `carry`, then you can use [`Self::widening_mul`] instead, + /// and if you only need one `carry`, then you can use [`Self::carrying_mul`] instead. + /// + /// # Examples + /// + /// Basic usage: + /// + /// Please note that this example is shared between integer types, + /// which explains why `u32` is used here. + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// assert_eq!(5u32.carrying_mul_add(2, 0, 0), (10, 0)); + /// assert_eq!(5u32.carrying_mul_add(2, 10, 10), (30, 0)); + /// assert_eq!(1_000_000_000u32.carrying_mul_add(10, 0, 0), (1410065408, 2)); + /// assert_eq!(1_000_000_000u32.carrying_mul_add(10, 10, 10), (1410065428, 2)); + #[doc = concat!("assert_eq!(", + stringify!($SelfT), "::MAX.carrying_mul_add(", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX), ", + "(", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX));" + )] + /// ``` + /// + /// This is the core per-digit operation for "grade school" O(n²) multiplication. + /// + /// Please note that this example is shared between integer types, + /// using `u8` for simplicity of the demonstration. + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// + /// fn quadratic_mul(a: [u8; N], b: [u8; N]) -> [u8; N] { + /// let mut out = [0; N]; + /// for j in 0..N { + /// let mut carry = 0; + /// for i in 0..(N - j) { + /// (out[j + i], carry) = u8::carrying_mul_add(a[i], b[j], out[j + i], carry); + /// } + /// } + /// out + /// } + /// + /// // -1 * -1 == 1 + /// assert_eq!(quadratic_mul([0xFF; 3], [0xFF; 3]), [1, 0, 0]); + /// + /// assert_eq!(u32::wrapping_mul(0x9e3779b9, 0x7f4a7c15), 0xCFFC982D); + /// assert_eq!( + /// quadratic_mul(u32::to_le_bytes(0x9e3779b9), u32::to_le_bytes(0x7f4a7c15)), + /// u32::to_le_bytes(0xCFFC982D) + /// ); + /// ``` + #[unstable(feature = "bigint_helper_methods", issue = "85532")] + #[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn carrying_mul_add(self, rhs: Self, carry: Self, add: Self) -> (Self, Self) { + intrinsics::carrying_mul_add(self, rhs, carry, add) + } + /// Calculates the divisor when `self` is divided by `rhs`. /// /// Returns a tuple of the divisor along with a boolean indicating @@ -2545,7 +2825,7 @@ macro_rules! uint_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2576,7 +2856,7 @@ macro_rules! uint_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2604,7 +2884,7 @@ macro_rules! uint_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2635,7 +2915,7 @@ macro_rules! uint_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2838,8 +3118,8 @@ macro_rules! uint_impl { /// ``` #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".isqrt(), 3);")] /// ``` - #[stable(feature = "isqrt", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "isqrt", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "isqrt", since = "1.84.0")] + #[rustc_const_stable(feature = "isqrt", since = "1.84.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -2872,7 +3152,7 @@ macro_rules! uint_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -2900,7 +3180,7 @@ macro_rules! uint_impl { /// /// # Panics /// - /// This function will panic if `rhs` is 0. + /// This function will panic if `rhs` is zero. /// /// # Examples /// @@ -3045,14 +3325,14 @@ macro_rules! uint_impl { /// Basic usage: /// /// ``` - /// #![feature(unsigned_is_multiple_of)] #[doc = concat!("assert!(6_", stringify!($SelfT), ".is_multiple_of(2));")] #[doc = concat!("assert!(!5_", stringify!($SelfT), ".is_multiple_of(2));")] /// #[doc = concat!("assert!(0_", stringify!($SelfT), ".is_multiple_of(0));")] #[doc = concat!("assert!(!6_", stringify!($SelfT), ".is_multiple_of(0));")] /// ``` - #[unstable(feature = "unsigned_is_multiple_of", issue = "128101")] + #[stable(feature = "unsigned_is_multiple_of", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "unsigned_is_multiple_of", since = "CURRENT_RUSTC_VERSION")] #[must_use] #[inline] #[rustc_inherit_overflow_checks] @@ -3091,7 +3371,6 @@ macro_rules! uint_impl { // overflow cases it instead ends up returning the maximum value // of the type, and can return 0 for 0. #[inline] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_pow", since = "1.50.0"))] const fn one_less_than_next_power_of_two(self) -> Self { if self <= 1 { return 0; } @@ -3169,7 +3448,6 @@ macro_rules! uint_impl { #[inline] #[unstable(feature = "wrapping_next_power_of_two", issue = "32463", reason = "needs decision on wrapping behavior")] - #[rustc_const_unstable(feature = "wrapping_next_power_of_two", issue = "32463")] #[must_use = "this returns the result of the operation, \ without modifying the original"] pub const fn wrapping_next_power_of_two(self) -> Self { @@ -3192,7 +3470,7 @@ macro_rules! uint_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - pub const fn to_be_bytes(self) -> [u8; mem::size_of::()] { + pub const fn to_be_bytes(self) -> [u8; size_of::()] { self.to_be().to_ne_bytes() } @@ -3212,7 +3490,7 @@ macro_rules! uint_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - pub const fn to_le_bytes(self) -> [u8; mem::size_of::()] { + pub const fn to_le_bytes(self) -> [u8; size_of::()] { self.to_le().to_ne_bytes() } @@ -3248,7 +3526,7 @@ macro_rules! uint_impl { // SAFETY: const sound because integers are plain old datatypes so we can always // transmute them to arrays of bytes #[inline] - pub const fn to_ne_bytes(self) -> [u8; mem::size_of::()] { + pub const fn to_ne_bytes(self) -> [u8; size_of::()] { // SAFETY: integers are plain old datatypes so we can always transmute them to // arrays of bytes unsafe { mem::transmute(self) } @@ -3270,7 +3548,7 @@ macro_rules! uint_impl { /// /// ``` #[doc = concat!("fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")] - #[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")] + #[doc = concat!(" let (int_bytes, rest) = input.split_at(size_of::<", stringify!($SelfT), ">());")] /// *input = rest; #[doc = concat!(" ", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap())")] /// } @@ -3279,7 +3557,7 @@ macro_rules! uint_impl { #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[must_use] #[inline] - pub const fn from_be_bytes(bytes: [u8; mem::size_of::()]) -> Self { + pub const fn from_be_bytes(bytes: [u8; size_of::()]) -> Self { Self::from_be(Self::from_ne_bytes(bytes)) } @@ -3299,7 +3577,7 @@ macro_rules! uint_impl { /// /// ``` #[doc = concat!("fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")] - #[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")] + #[doc = concat!(" let (int_bytes, rest) = input.split_at(size_of::<", stringify!($SelfT), ">());")] /// *input = rest; #[doc = concat!(" ", stringify!($SelfT), "::from_le_bytes(int_bytes.try_into().unwrap())")] /// } @@ -3308,7 +3586,7 @@ macro_rules! uint_impl { #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[must_use] #[inline] - pub const fn from_le_bytes(bytes: [u8; mem::size_of::()]) -> Self { + pub const fn from_le_bytes(bytes: [u8; size_of::()]) -> Self { Self::from_le(Self::from_ne_bytes(bytes)) } @@ -3339,7 +3617,7 @@ macro_rules! uint_impl { /// /// ``` #[doc = concat!("fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")] - #[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")] + #[doc = concat!(" let (int_bytes, rest) = input.split_at(size_of::<", stringify!($SelfT), ">());")] /// *input = rest; #[doc = concat!(" ", stringify!($SelfT), "::from_ne_bytes(int_bytes.try_into().unwrap())")] /// } @@ -3350,7 +3628,7 @@ macro_rules! uint_impl { // SAFETY: const sound because integers are plain old datatypes so we can always // transmute to them #[inline] - pub const fn from_ne_bytes(bytes: [u8; mem::size_of::()]) -> Self { + pub const fn from_ne_bytes(bytes: [u8; size_of::()]) -> Self { // SAFETY: integers are plain old datatypes so we can always transmute to them unsafe { mem::transmute(bytes) } } diff --git a/core/src/num/wrapping.rs b/core/src/num/wrapping.rs index 1156b389e2867..55fa91d0b9f49 100644 --- a/core/src/num/wrapping.rs +++ b/core/src/num/wrapping.rs @@ -1058,33 +1058,33 @@ mod shift_max { #[cfg(target_pointer_width = "16")] mod platform { - pub const usize: u32 = super::u16; - pub const isize: u32 = super::i16; + pub(crate) const usize: u32 = super::u16; + pub(crate) const isize: u32 = super::i16; } #[cfg(target_pointer_width = "32")] mod platform { - pub const usize: u32 = super::u32; - pub const isize: u32 = super::i32; + pub(crate) const usize: u32 = super::u32; + pub(crate) const isize: u32 = super::i32; } #[cfg(target_pointer_width = "64")] mod platform { - pub const usize: u32 = super::u64; - pub const isize: u32 = super::i64; + pub(crate) const usize: u32 = super::u64; + pub(crate) const isize: u32 = super::i64; } - pub const i8: u32 = (1 << 3) - 1; - pub const i16: u32 = (1 << 4) - 1; - pub const i32: u32 = (1 << 5) - 1; - pub const i64: u32 = (1 << 6) - 1; - pub const i128: u32 = (1 << 7) - 1; - pub use self::platform::isize; - - pub const u8: u32 = i8; - pub const u16: u32 = i16; - pub const u32: u32 = i32; - pub const u64: u32 = i64; - pub const u128: u32 = i128; - pub use self::platform::usize; + pub(super) const i8: u32 = (1 << 3) - 1; + pub(super) const i16: u32 = (1 << 4) - 1; + pub(super) const i32: u32 = (1 << 5) - 1; + pub(super) const i64: u32 = (1 << 6) - 1; + pub(super) const i128: u32 = (1 << 7) - 1; + pub(super) use self::platform::isize; + + pub(super) const u8: u32 = i8; + pub(super) const u16: u32 = i16; + pub(super) const u32: u32 = i32; + pub(super) const u64: u32 = i64; + pub(super) const u128: u32 = i128; + pub(super) use self::platform::usize; } diff --git a/core/src/ops/arith.rs b/core/src/ops/arith.rs index 565bccf589826..54d79beca95ab 100644 --- a/core/src/ops/arith.rs +++ b/core/src/ops/arith.rs @@ -65,6 +65,7 @@ /// ``` #[lang = "add"] #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature = "const_ops", issue = "90080")] #[rustc_on_unimplemented( on(all(_Self = "{integer}", Rhs = "{float}"), message = "cannot add a float to an integer",), on(all(_Self = "{float}", Rhs = "{integer}"), message = "cannot add an integer to a float",), @@ -73,7 +74,7 @@ append_const_msg )] #[doc(alias = "+")] -#[cfg_attr(not(bootstrap), const_trait)] +#[const_trait] pub trait Add { /// The resulting type after applying the `+` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -95,18 +96,7 @@ pub trait Add { macro_rules! add_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] - #[cfg(bootstrap)] - impl Add for $t { - type Output = $t; - - #[inline] - #[track_caller] - #[rustc_inherit_overflow_checks] - fn add(self, other: $t) -> $t { self + other } - } - - #[stable(feature = "rust1", since = "1.0.0")] - #[cfg(not(bootstrap))] + #[rustc_const_unstable(feature = "const_ops", issue = "90080")] impl const Add for $t { type Output = $t; diff --git a/core/src/ops/async_function.rs b/core/src/ops/async_function.rs index 4b230b15a1e6f..6be42ca7d32fe 100644 --- a/core/src/ops/async_function.rs +++ b/core/src/ops/async_function.rs @@ -4,9 +4,8 @@ use crate::marker::Tuple; /// An async-aware version of the [`Fn`](crate::ops::Fn) trait. /// /// All `async fn` and functions returning futures implement this trait. -#[unstable(feature = "async_closure", issue = "62290")] +#[stable(feature = "async_closure", since = "1.85.0")] #[rustc_paren_sugar] -#[fundamental] #[must_use = "async closures are lazy and do nothing unless called"] #[lang = "async_fn"] pub trait AsyncFn: AsyncFnMut { @@ -18,9 +17,8 @@ pub trait AsyncFn: AsyncFnMut { /// An async-aware version of the [`FnMut`](crate::ops::FnMut) trait. /// /// All `async fn` and functions returning futures implement this trait. -#[unstable(feature = "async_closure", issue = "62290")] +#[stable(feature = "async_closure", since = "1.85.0")] #[rustc_paren_sugar] -#[fundamental] #[must_use = "async closures are lazy and do nothing unless called"] #[lang = "async_fn_mut"] pub trait AsyncFnMut: AsyncFnOnce { @@ -39,9 +37,8 @@ pub trait AsyncFnMut: AsyncFnOnce { /// An async-aware version of the [`FnOnce`](crate::ops::FnOnce) trait. /// /// All `async fn` and functions returning futures implement this trait. -#[unstable(feature = "async_closure", issue = "62290")] +#[stable(feature = "async_closure", since = "1.85.0")] #[rustc_paren_sugar] -#[fundamental] #[must_use = "async closures are lazy and do nothing unless called"] #[lang = "async_fn_once"] pub trait AsyncFnOnce { @@ -64,7 +61,7 @@ mod impls { use super::{AsyncFn, AsyncFnMut, AsyncFnOnce}; use crate::marker::Tuple; - #[unstable(feature = "async_fn_traits", issue = "none")] + #[stable(feature = "async_closure", since = "1.85.0")] impl AsyncFn for &F where F: AsyncFn, @@ -74,7 +71,7 @@ mod impls { } } - #[unstable(feature = "async_fn_traits", issue = "none")] + #[stable(feature = "async_closure", since = "1.85.0")] impl AsyncFnMut for &F where F: AsyncFn, @@ -89,7 +86,7 @@ mod impls { } } - #[unstable(feature = "async_fn_traits", issue = "none")] + #[stable(feature = "async_closure", since = "1.85.0")] impl<'a, A: Tuple, F: ?Sized> AsyncFnOnce for &'a F where F: AsyncFn, @@ -102,7 +99,7 @@ mod impls { } } - #[unstable(feature = "async_fn_traits", issue = "none")] + #[stable(feature = "async_closure", since = "1.85.0")] impl AsyncFnMut for &mut F where F: AsyncFnMut, @@ -117,7 +114,7 @@ mod impls { } } - #[unstable(feature = "async_fn_traits", issue = "none")] + #[stable(feature = "async_closure", since = "1.85.0")] impl<'a, A: Tuple, F: ?Sized> AsyncFnOnce for &'a mut F where F: AsyncFnMut, diff --git a/core/src/ops/bit.rs b/core/src/ops/bit.rs index 6984100e498e8..deb54c8ba348e 100644 --- a/core/src/ops/bit.rs +++ b/core/src/ops/bit.rs @@ -493,7 +493,7 @@ macro_rules! shl_impl_all { )*) } -shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } +shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } /// The right shift operator `>>`. Note that because this trait is implemented /// for all integer types with multiple right-hand-side types, Rust's type diff --git a/core/src/ops/control_flow.rs b/core/src/ops/control_flow.rs index 55deabbee8fb5..8993e14fcd379 100644 --- a/core/src/ops/control_flow.rs +++ b/core/src/ops/control_flow.rs @@ -79,6 +79,7 @@ use crate::{convert, ops}; /// [`Break`]: ControlFlow::Break /// [`Continue`]: ControlFlow::Continue #[stable(feature = "control_flow_enum_type", since = "1.55.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "ControlFlow")] // ControlFlow should not implement PartialOrd or Ord, per RFC 3058: // https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#traits-for-controlflow #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -140,8 +141,8 @@ impl ControlFlow { /// ``` /// use std::ops::ControlFlow; /// - /// assert!(ControlFlow::::Break(3).is_break()); - /// assert!(!ControlFlow::::Continue(3).is_break()); + /// assert!(ControlFlow::<&str, i32>::Break("Stop right there!").is_break()); + /// assert!(!ControlFlow::<&str, i32>::Continue(3).is_break()); /// ``` #[inline] #[stable(feature = "control_flow_enum_is", since = "1.59.0")] @@ -156,8 +157,8 @@ impl ControlFlow { /// ``` /// use std::ops::ControlFlow; /// - /// assert!(!ControlFlow::::Break(3).is_continue()); - /// assert!(ControlFlow::::Continue(3).is_continue()); + /// assert!(!ControlFlow::<&str, i32>::Break("Stop right there!").is_continue()); + /// assert!(ControlFlow::<&str, i32>::Continue(3).is_continue()); /// ``` #[inline] #[stable(feature = "control_flow_enum_is", since = "1.59.0")] @@ -173,8 +174,8 @@ impl ControlFlow { /// ``` /// use std::ops::ControlFlow; /// - /// assert_eq!(ControlFlow::::Break(3).break_value(), Some(3)); - /// assert_eq!(ControlFlow::::Continue(3).break_value(), None); + /// assert_eq!(ControlFlow::<&str, i32>::Break("Stop right there!").break_value(), Some("Stop right there!")); + /// assert_eq!(ControlFlow::<&str, i32>::Continue(3).break_value(), None); /// ``` #[inline] #[stable(feature = "control_flow_enum", since = "1.83.0")] @@ -204,8 +205,8 @@ impl ControlFlow { /// ``` /// use std::ops::ControlFlow; /// - /// assert_eq!(ControlFlow::::Break(3).continue_value(), None); - /// assert_eq!(ControlFlow::::Continue(3).continue_value(), Some(3)); + /// assert_eq!(ControlFlow::<&str, i32>::Break("Stop right there!").continue_value(), None); + /// assert_eq!(ControlFlow::<&str, i32>::Continue(3).continue_value(), Some(3)); /// ``` #[inline] #[stable(feature = "control_flow_enum", since = "1.83.0")] @@ -228,6 +229,27 @@ impl ControlFlow { } } +impl ControlFlow { + /// Extracts the value `T` that is wrapped by `ControlFlow`. + /// + /// # Examples + /// + /// ``` + /// #![feature(control_flow_into_value)] + /// use std::ops::ControlFlow; + /// + /// assert_eq!(ControlFlow::::Break(1024).into_value(), 1024); + /// assert_eq!(ControlFlow::::Continue(512).into_value(), 512); + /// ``` + #[unstable(feature = "control_flow_into_value", issue = "137461")] + #[rustc_allow_const_fn_unstable(const_precise_live_drops)] + pub const fn into_value(self) -> T { + match self { + ControlFlow::Continue(x) | ControlFlow::Break(x) => x, + } + } +} + /// These are used only as part of implementing the iterator adapters. /// They have mediocre names and non-obvious semantics, so aren't /// currently on a path to potential stabilization. diff --git a/core/src/ops/deref.rs b/core/src/ops/deref.rs index e9bb40d0fdd17..e74f5443ac2d8 100644 --- a/core/src/ops/deref.rs +++ b/core/src/ops/deref.rs @@ -133,7 +133,8 @@ #[doc(alias = "&*")] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "Deref"] -#[cfg_attr(not(bootstrap), const_trait)] +#[const_trait] +#[rustc_const_unstable(feature = "const_deref", issue = "88955")] pub trait Deref { /// The resulting type after dereferencing. #[stable(feature = "rust1", since = "1.0.0")] @@ -148,19 +149,8 @@ pub trait Deref { fn deref(&self) -> &Self::Target; } -#[cfg(bootstrap)] -#[stable(feature = "rust1", since = "1.0.0")] -impl Deref for &T { - type Target = T; - - #[rustc_diagnostic_item = "noop_method_deref"] - fn deref(&self) -> &T { - *self - } -} - -#[cfg(not(bootstrap))] #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature = "const_deref", issue = "88955")] impl const Deref for &T { type Target = T; @@ -173,18 +163,8 @@ impl const Deref for &T { #[stable(feature = "rust1", since = "1.0.0")] impl !DerefMut for &T {} -#[cfg(bootstrap)] -#[stable(feature = "rust1", since = "1.0.0")] -impl Deref for &mut T { - type Target = T; - - fn deref(&self) -> &T { - *self - } -} - -#[cfg(not(bootstrap))] #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature = "const_deref", issue = "88955")] impl const Deref for &mut T { type Target = T; @@ -282,11 +262,11 @@ impl const Deref for &mut T { /// *x = 'b'; /// assert_eq!('b', x.value); /// ``` -#[cfg(not(bootstrap))] #[lang = "deref_mut"] #[doc(alias = "*")] #[stable(feature = "rust1", since = "1.0.0")] #[const_trait] +#[rustc_const_unstable(feature = "const_deref", issue = "88955")] pub trait DerefMut: ~const Deref { /// Mutably dereferences the value. #[stable(feature = "rust1", since = "1.0.0")] @@ -294,28 +274,8 @@ pub trait DerefMut: ~const Deref { fn deref_mut(&mut self) -> &mut Self::Target; } -/// Bootstrap -#[lang = "deref_mut"] -#[doc(alias = "*")] -#[stable(feature = "rust1", since = "1.0.0")] -#[cfg(bootstrap)] -pub trait DerefMut: Deref { - /// Mutably dereferences the value. - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_diagnostic_item = "deref_mut_method"] - fn deref_mut(&mut self) -> &mut Self::Target; -} - -#[cfg(bootstrap)] -#[stable(feature = "rust1", since = "1.0.0")] -impl DerefMut for &mut T { - fn deref_mut(&mut self) -> &mut T { - *self - } -} - -#[cfg(not(bootstrap))] #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature = "const_deref", issue = "88955")] impl const DerefMut for &mut T { fn deref_mut(&mut self) -> &mut T { *self @@ -405,18 +365,15 @@ unsafe impl DerefPure for &mut T {} /// } /// ``` #[lang = "receiver"] -#[cfg(not(bootstrap))] #[unstable(feature = "arbitrary_self_types", issue = "44874")] pub trait Receiver { /// The target type on which the method may be called. - #[cfg(not(bootstrap))] #[rustc_diagnostic_item = "receiver_target"] #[lang = "receiver_target"] #[unstable(feature = "arbitrary_self_types", issue = "44874")] type Target: ?Sized; } -#[cfg(not(bootstrap))] #[unstable(feature = "arbitrary_self_types", issue = "44874")] impl Receiver for P where @@ -433,8 +390,7 @@ where /// facility based around the current "arbitrary self types" unstable feature. /// That new facility will use the replacement trait above called `Receiver` /// which is why this is now named `LegacyReceiver`. -#[cfg_attr(bootstrap, lang = "receiver")] -#[cfg_attr(not(bootstrap), lang = "legacy_receiver")] +#[lang = "legacy_receiver"] #[unstable(feature = "legacy_receiver_trait", issue = "none")] #[doc(hidden)] pub trait LegacyReceiver { diff --git a/core/src/ops/drop.rs b/core/src/ops/drop.rs index a6f63ad68d695..e024b7fb4d301 100644 --- a/core/src/ops/drop.rs +++ b/core/src/ops/drop.rs @@ -203,7 +203,8 @@ /// [nomicon]: ../../nomicon/phantom-data.html#an-exception-the-special-case-of-the-standard-library-and-its-unstable-may_dangle #[lang = "drop"] #[stable(feature = "rust1", since = "1.0.0")] -// FIXME(const_trait_impl) #[const_trait] +#[const_trait] +#[rustc_const_unstable(feature = "const_destruct", issue = "133214")] pub trait Drop { /// Executes the destructor for this type. /// diff --git a/core/src/ops/index_range.rs b/core/src/ops/index_range.rs index dce3514a1595b..b82184b15b2f5 100644 --- a/core/src/ops/index_range.rs +++ b/core/src/ops/index_range.rs @@ -18,7 +18,7 @@ impl IndexRange { /// # Safety /// - `start <= end` #[inline] - pub const unsafe fn new_unchecked(start: usize, end: usize) -> Self { + pub(crate) const unsafe fn new_unchecked(start: usize, end: usize) -> Self { ub_checks::assert_unsafe_precondition!( check_library_ub, "IndexRange::new_unchecked requires `start <= end`", @@ -28,22 +28,22 @@ impl IndexRange { } #[inline] - pub const fn zero_to(end: usize) -> Self { + pub(crate) const fn zero_to(end: usize) -> Self { IndexRange { start: 0, end } } #[inline] - pub const fn start(&self) -> usize { + pub(crate) const fn start(&self) -> usize { self.start } #[inline] - pub const fn end(&self) -> usize { + pub(crate) const fn end(&self) -> usize { self.end } #[inline] - pub const fn len(&self) -> usize { + pub(crate) const fn len(&self) -> usize { // SAFETY: By invariant, this cannot wrap // Using the intrinsic because a UB check here impedes LLVM optimization. (#131563) unsafe { crate::intrinsics::unchecked_sub(self.end, self.start) } @@ -79,7 +79,7 @@ impl IndexRange { /// /// This is designed to help implement `Iterator::advance_by`. #[inline] - pub fn take_prefix(&mut self, n: usize) -> Self { + pub(crate) fn take_prefix(&mut self, n: usize) -> Self { let mid = if n <= self.len() { // SAFETY: We just checked that this will be between start and end, // and thus the addition cannot overflow. @@ -99,7 +99,7 @@ impl IndexRange { /// /// This is designed to help implement `Iterator::advance_back_by`. #[inline] - pub fn take_suffix(&mut self, n: usize) -> Self { + pub(crate) fn take_suffix(&mut self, n: usize) -> Self { let mid = if n <= self.len() { // SAFETY: We just checked that this will be between start and end, // and thus the subtraction cannot overflow. diff --git a/core/src/ops/mod.rs b/core/src/ops/mod.rs index cea1f84f3fd60..627a875d9f724 100644 --- a/core/src/ops/mod.rs +++ b/core/src/ops/mod.rs @@ -171,7 +171,6 @@ pub use self::deref::DerefPure; #[unstable(feature = "legacy_receiver_trait", issue = "none")] pub use self::deref::LegacyReceiver; #[unstable(feature = "arbitrary_self_types", issue = "44874")] -#[cfg(not(bootstrap))] pub use self::deref::Receiver; #[stable(feature = "rust1", since = "1.0.0")] pub use self::deref::{Deref, DerefMut}; @@ -183,10 +182,12 @@ pub use self::function::{Fn, FnMut, FnOnce}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::index::{Index, IndexMut}; pub(crate) use self::index_range::IndexRange; -#[unstable(feature = "one_sided_range", issue = "69780")] -pub use self::range::OneSidedRange; +#[unstable(feature = "range_into_bounds", issue = "136903")] +pub use self::range::IntoBounds; #[stable(feature = "inclusive_range", since = "1.26.0")] pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive}; +#[unstable(feature = "one_sided_range", issue = "69780")] +pub use self::range::{OneSidedRange, OneSidedRangeBound}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::range::{Range, RangeFrom, RangeFull, RangeTo}; #[unstable(feature = "try_trait_v2_residual", issue = "91285")] diff --git a/core/src/ops/range.rs b/core/src/ops/range.rs index 727a22e454d3d..1935268cda891 100644 --- a/core/src/ops/range.rs +++ b/core/src/ops/range.rs @@ -771,13 +771,11 @@ pub trait RangeBounds { /// # Examples /// /// ``` - /// # fn main() { /// use std::ops::Bound::*; /// use std::ops::RangeBounds; /// /// assert_eq!((..10).start_bound(), Unbounded); /// assert_eq!((3..10).start_bound(), Included(&3)); - /// # } /// ``` #[stable(feature = "collections_range", since = "1.28.0")] fn start_bound(&self) -> Bound<&T>; @@ -789,13 +787,11 @@ pub trait RangeBounds { /// # Examples /// /// ``` - /// # fn main() { /// use std::ops::Bound::*; /// use std::ops::RangeBounds; /// /// assert_eq!((3..).end_bound(), Unbounded); /// assert_eq!((3..10).end_bound(), Excluded(&10)); - /// # } /// ``` #[stable(feature = "collections_range", since = "1.28.0")] fn end_bound(&self) -> Bound<&T>; @@ -829,6 +825,164 @@ pub trait RangeBounds { Unbounded => true, }) } + + /// Returns `true` if the range contains no items. + /// One-sided ranges (`RangeFrom`, etc) always return `false`. + /// + /// # Examples + /// + /// ``` + /// #![feature(range_bounds_is_empty)] + /// use std::ops::RangeBounds; + /// + /// assert!(!(3..).is_empty()); + /// assert!(!(..2).is_empty()); + /// assert!(!RangeBounds::is_empty(&(3..5))); + /// assert!( RangeBounds::is_empty(&(3..3))); + /// assert!( RangeBounds::is_empty(&(3..2))); + /// ``` + /// + /// The range is empty if either side is incomparable: + /// + /// ``` + /// #![feature(range_bounds_is_empty)] + /// use std::ops::RangeBounds; + /// + /// assert!(!RangeBounds::is_empty(&(3.0..5.0))); + /// assert!( RangeBounds::is_empty(&(3.0..f32::NAN))); + /// assert!( RangeBounds::is_empty(&(f32::NAN..5.0))); + /// ``` + /// + /// But never empty is either side is unbounded: + /// + /// ``` + /// #![feature(range_bounds_is_empty)] + /// use std::ops::RangeBounds; + /// + /// assert!(!(..0).is_empty()); + /// assert!(!(i32::MAX..).is_empty()); + /// assert!(!RangeBounds::::is_empty(&(..))); + /// ``` + /// + /// `(Excluded(a), Excluded(b))` is only empty if `a >= b`: + /// + /// ``` + /// #![feature(range_bounds_is_empty)] + /// use std::ops::Bound::*; + /// use std::ops::RangeBounds; + /// + /// assert!(!(Excluded(1), Excluded(3)).is_empty()); + /// assert!(!(Excluded(1), Excluded(2)).is_empty()); + /// assert!( (Excluded(1), Excluded(1)).is_empty()); + /// assert!( (Excluded(2), Excluded(1)).is_empty()); + /// assert!( (Excluded(3), Excluded(1)).is_empty()); + /// ``` + #[unstable(feature = "range_bounds_is_empty", issue = "137300")] + fn is_empty(&self) -> bool + where + T: PartialOrd, + { + !match (self.start_bound(), self.end_bound()) { + (Unbounded, _) | (_, Unbounded) => true, + (Included(start), Excluded(end)) + | (Excluded(start), Included(end)) + | (Excluded(start), Excluded(end)) => start < end, + (Included(start), Included(end)) => start <= end, + } + } +} + +/// Used to convert a range into start and end bounds, consuming the +/// range by value. +/// +/// `IntoBounds` is implemented by Rust’s built-in range types, produced +/// by range syntax like `..`, `a..`, `..b`, `..=c`, `d..e`, or `f..=g`. +#[unstable(feature = "range_into_bounds", issue = "136903")] +pub trait IntoBounds: RangeBounds { + /// Convert this range into the start and end bounds. + /// Returns `(start_bound, end_bound)`. + /// + /// # Examples + /// + /// ``` + /// #![feature(range_into_bounds)] + /// use std::ops::Bound::*; + /// use std::ops::IntoBounds; + /// + /// assert_eq!((0..5).into_bounds(), (Included(0), Excluded(5))); + /// assert_eq!((..=7).into_bounds(), (Unbounded, Included(7))); + /// ``` + fn into_bounds(self) -> (Bound, Bound); + + /// Compute the intersection of `self` and `other`. + /// + /// # Examples + /// + /// ``` + /// #![feature(range_into_bounds)] + /// use std::ops::Bound::*; + /// use std::ops::IntoBounds; + /// + /// assert_eq!((3..).intersect(..5), (Included(3), Excluded(5))); + /// assert_eq!((-12..387).intersect(0..256), (Included(0), Excluded(256))); + /// assert_eq!((1..5).intersect(..), (Included(1), Excluded(5))); + /// assert_eq!((1..=9).intersect(0..10), (Included(1), Included(9))); + /// assert_eq!((7..=13).intersect(8..13), (Included(8), Excluded(13))); + /// ``` + /// + /// Combine with `is_empty` to determine if two ranges overlap. + /// + /// ``` + /// #![feature(range_into_bounds)] + /// #![feature(range_bounds_is_empty)] + /// use std::ops::{RangeBounds, IntoBounds}; + /// + /// assert!(!(3..).intersect(..5).is_empty()); + /// assert!(!(-12..387).intersect(0..256).is_empty()); + /// assert!((1..5).intersect(6..).is_empty()); + /// ``` + fn intersect(self, other: R) -> (Bound, Bound) + where + Self: Sized, + T: Ord, + R: Sized + IntoBounds, + { + let (self_start, self_end) = IntoBounds::into_bounds(self); + let (other_start, other_end) = IntoBounds::into_bounds(other); + + let start = match (self_start, other_start) { + (Included(a), Included(b)) => Included(Ord::max(a, b)), + (Excluded(a), Excluded(b)) => Excluded(Ord::max(a, b)), + (Unbounded, Unbounded) => Unbounded, + + (x, Unbounded) | (Unbounded, x) => x, + + (Included(i), Excluded(e)) | (Excluded(e), Included(i)) => { + if i > e { + Included(i) + } else { + Excluded(e) + } + } + }; + let end = match (self_end, other_end) { + (Included(a), Included(b)) => Included(Ord::min(a, b)), + (Excluded(a), Excluded(b)) => Excluded(Ord::min(a, b)), + (Unbounded, Unbounded) => Unbounded, + + (x, Unbounded) | (Unbounded, x) => x, + + (Included(i), Excluded(e)) | (Excluded(e), Included(i)) => { + if i < e { + Included(i) + } else { + Excluded(e) + } + } + }; + + (start, end) + } } use self::Bound::{Excluded, Included, Unbounded}; @@ -843,6 +997,13 @@ impl RangeBounds for RangeFull { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for RangeFull { + fn into_bounds(self) -> (Bound, Bound) { + (Unbounded, Unbounded) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for RangeFrom { fn start_bound(&self) -> Bound<&T> { @@ -853,6 +1014,13 @@ impl RangeBounds for RangeFrom { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for RangeFrom { + fn into_bounds(self) -> (Bound, Bound) { + (Included(self.start), Unbounded) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for RangeTo { fn start_bound(&self) -> Bound<&T> { @@ -863,6 +1031,13 @@ impl RangeBounds for RangeTo { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for RangeTo { + fn into_bounds(self) -> (Bound, Bound) { + (Unbounded, Excluded(self.end)) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for Range { fn start_bound(&self) -> Bound<&T> { @@ -873,6 +1048,13 @@ impl RangeBounds for Range { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for Range { + fn into_bounds(self) -> (Bound, Bound) { + (Included(self.start), Excluded(self.end)) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for RangeInclusive { fn start_bound(&self) -> Bound<&T> { @@ -889,6 +1071,22 @@ impl RangeBounds for RangeInclusive { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for RangeInclusive { + fn into_bounds(self) -> (Bound, Bound) { + ( + Included(self.start), + if self.exhausted { + // When the iterator is exhausted, we usually have start == end, + // but we want the range to appear empty, containing nothing. + Excluded(self.end) + } else { + Included(self.end) + }, + ) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for RangeToInclusive { fn start_bound(&self) -> Bound<&T> { @@ -899,6 +1097,13 @@ impl RangeBounds for RangeToInclusive { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for RangeToInclusive { + fn into_bounds(self) -> (Bound, Bound) { + (Unbounded, Included(self.end)) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for (Bound, Bound) { fn start_bound(&self) -> Bound<&T> { @@ -918,6 +1123,13 @@ impl RangeBounds for (Bound, Bound) { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for (Bound, Bound) { + fn into_bounds(self) -> (Bound, Bound) { + self + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl<'a, T: ?Sized + 'a> RangeBounds for (Bound<&'a T>, Bound<&'a T>) { fn start_bound(&self) -> Bound<&T> { @@ -979,6 +1191,19 @@ impl RangeBounds for RangeToInclusive<&T> { } } +/// An internal helper for `split_off` functions indicating +/// which end a `OneSidedRange` is bounded on. +#[unstable(feature = "one_sided_range", issue = "69780")] +#[allow(missing_debug_implementations)] +pub enum OneSidedRangeBound { + /// The range is bounded inclusively from below and is unbounded above. + StartInclusive, + /// The range is bounded exclusively from above and is unbounded below. + End, + /// The range is bounded inclusively from above and is unbounded below. + EndInclusive, +} + /// `OneSidedRange` is implemented for built-in range types that are unbounded /// on one side. For example, `a..`, `..b` and `..=c` implement `OneSidedRange`, /// but `..`, `d..e`, and `f..=g` do not. @@ -986,13 +1211,38 @@ impl RangeBounds for RangeToInclusive<&T> { /// Types that implement `OneSidedRange` must return `Bound::Unbounded` /// from one of `RangeBounds::start_bound` or `RangeBounds::end_bound`. #[unstable(feature = "one_sided_range", issue = "69780")] -pub trait OneSidedRange: RangeBounds {} +pub trait OneSidedRange: RangeBounds { + /// An internal-only helper function for `split_off` and + /// `split_off_mut` that returns the bound of the one-sided range. + fn bound(self) -> (OneSidedRangeBound, T); +} #[unstable(feature = "one_sided_range", issue = "69780")] -impl OneSidedRange for RangeTo where Self: RangeBounds {} +impl OneSidedRange for RangeTo +where + Self: RangeBounds, +{ + fn bound(self) -> (OneSidedRangeBound, T) { + (OneSidedRangeBound::End, self.end) + } +} #[unstable(feature = "one_sided_range", issue = "69780")] -impl OneSidedRange for RangeFrom where Self: RangeBounds {} +impl OneSidedRange for RangeFrom +where + Self: RangeBounds, +{ + fn bound(self) -> (OneSidedRangeBound, T) { + (OneSidedRangeBound::StartInclusive, self.start) + } +} #[unstable(feature = "one_sided_range", issue = "69780")] -impl OneSidedRange for RangeToInclusive where Self: RangeBounds {} +impl OneSidedRange for RangeToInclusive +where + Self: RangeBounds, +{ + fn bound(self) -> (OneSidedRangeBound, T) { + (OneSidedRangeBound::EndInclusive, self.end) + } +} diff --git a/core/src/ops/try_trait.rs b/core/src/ops/try_trait.rs index cd444c86ed06e..3ba2957526f9c 100644 --- a/core/src/ops/try_trait.rs +++ b/core/src/ops/try_trait.rs @@ -338,6 +338,7 @@ pub trait FromResidual::Residual> { #[inline] #[track_caller] // because `Result::from_residual` has it #[lang = "from_yeet"] +#[allow(unreachable_pub)] // not-exposed but still used via lang-item pub fn from_yeet(yeeted: Y) -> T where T: FromResidual>, @@ -383,12 +384,14 @@ impl NeverShortCircuit { /// This is useful for implementing infallible functions in terms of the `try_` ones, /// without accidentally capturing extra generic parameters in a closure. #[inline] - pub fn wrap_mut_1(mut f: impl FnMut(A) -> T) -> impl FnMut(A) -> NeverShortCircuit { + pub(crate) fn wrap_mut_1( + mut f: impl FnMut(A) -> T, + ) -> impl FnMut(A) -> NeverShortCircuit { move |a| NeverShortCircuit(f(a)) } #[inline] - pub fn wrap_mut_2(mut f: impl FnMut(A, B) -> T) -> impl FnMut(A, B) -> Self { + pub(crate) fn wrap_mut_2(mut f: impl FnMut(A, B) -> T) -> impl FnMut(A, B) -> Self { move |a, b| NeverShortCircuit(f(a, b)) } } diff --git a/core/src/option.rs b/core/src/option.rs index 29d1956af9559..f668c6f067246 100644 --- a/core/src/option.rs +++ b/core/src/option.rs @@ -563,7 +563,7 @@ use crate::pin::Pin; use crate::{cmp, convert, hint, mem, slice}; /// The `Option` type. See [the module level documentation](self) for more. -#[cfg_attr(not(bootstrap), doc(search_unbox))] +#[doc(search_unbox)] #[derive(Copy, Eq, Debug, Hash)] #[rustc_diagnostic_item = "Option"] #[lang = "Option"] @@ -738,7 +738,7 @@ impl Option { #[inline] #[must_use] #[stable(feature = "pin", since = "1.33.0")] - #[rustc_const_stable(feature = "const_option_ext", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_option_ext", since = "1.84.0")] pub const fn as_pin_ref(self: Pin<&Self>) -> Option> { // FIXME(const-hack): use `map` once that is possible match Pin::get_ref(self).as_ref() { @@ -755,7 +755,7 @@ impl Option { #[inline] #[must_use] #[stable(feature = "pin", since = "1.33.0")] - #[rustc_const_stable(feature = "const_option_ext", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_option_ext", since = "1.84.0")] pub const fn as_pin_mut(self: Pin<&mut Self>) -> Option> { // SAFETY: `get_unchecked_mut` is never used to move the `Option` inside `self`. // `x` is guaranteed to be pinned because it comes from `self` which is pinned. @@ -802,7 +802,7 @@ impl Option { #[inline] #[must_use] #[stable(feature = "option_as_slice", since = "1.75.0")] - #[rustc_const_stable(feature = "const_option_ext", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_option_ext", since = "1.84.0")] pub const fn as_slice(&self) -> &[T] { // SAFETY: When the `Option` is `Some`, we're using the actual pointer // to the payload, with a length of 1, so this is equivalent to @@ -857,7 +857,7 @@ impl Option { #[inline] #[must_use] #[stable(feature = "option_as_slice", since = "1.75.0")] - #[rustc_const_stable(feature = "const_option_ext", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_option_ext", since = "1.84.0")] pub const fn as_mut_slice(&mut self) -> &mut [T] { // SAFETY: When the `Option` is `Some`, we're using the actual pointer // to the payload, with a length of 1, so this is equivalent to @@ -937,10 +937,16 @@ impl Option { /// Returns the contained [`Some`] value, consuming the `self` value. /// /// Because this function may panic, its use is generally discouraged. + /// Panics are meant for unrecoverable errors, and + /// [may abort the entire program][panic-abort]. + /// /// Instead, prefer to use pattern matching and handle the [`None`] /// case explicitly, or call [`unwrap_or`], [`unwrap_or_else`], or - /// [`unwrap_or_default`]. + /// [`unwrap_or_default`]. In functions returning `Option`, you can use + /// [the `?` (try) operator][try-option]. /// + /// [panic-abort]: https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html + /// [try-option]: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html#where-the--operator-can-be-used /// [`unwrap_or`]: Option::unwrap_or /// [`unwrap_or_else`]: Option::unwrap_or_else /// [`unwrap_or_default`]: Option::unwrap_or_default @@ -2044,6 +2050,9 @@ where } } +#[unstable(feature = "ergonomic_clones", issue = "132290")] +impl crate::clone::UseCloned for Option where T: crate::clone::UseCloned {} + #[stable(feature = "rust1", since = "1.0.0")] impl Default for Option { /// Returns [`None`][Option::None]. diff --git a/core/src/panic.rs b/core/src/panic.rs index 179aadf0c286c..5fa340a6147f6 100644 --- a/core/src/panic.rs +++ b/core/src/panic.rs @@ -208,14 +208,13 @@ pub macro const_panic { #[rustc_allow_const_fn_unstable(const_eval_select)] #[inline(always)] // inline the wrapper #[track_caller] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_panic", since = "CURRENT_RUSTC_VERSION"))] const fn do_panic($($arg: $ty),*) -> ! { $crate::intrinsics::const_eval_select!( @capture { $($arg: $ty = $arg),* } -> !: #[noinline] if const #[track_caller] #[inline] { // Inline this, to prevent codegen $crate::panic!($const_msg) - } else #[track_caller] #[cfg_attr(bootstrap, inline)] { // Do not inline this, it makes perf worse + } else #[track_caller] { // Do not inline this, it makes perf worse $crate::panic!($runtime_msg) } ) diff --git a/core/src/panic/panic_info.rs b/core/src/panic/panic_info.rs index 230a9918dbf3e..9d53567a26fd9 100644 --- a/core/src/panic/panic_info.rs +++ b/core/src/panic/panic_info.rs @@ -165,7 +165,7 @@ impl<'a> PanicMessage<'a> { /// /// See [`fmt::Arguments::as_str`] for details. #[stable(feature = "panic_info_message", since = "1.81.0")] - #[rustc_const_stable(feature = "const_arguments_as_str", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_arguments_as_str", since = "1.84.0")] #[must_use] #[inline] pub const fn as_str(&self) -> Option<&'static str> { diff --git a/core/src/panicking.rs b/core/src/panicking.rs index f603eb2971f6d..33ad59916e391 100644 --- a/core/src/panicking.rs +++ b/core/src/panicking.rs @@ -51,8 +51,7 @@ const _: () = assert!(cfg!(panic = "abort"), "panic_immediate_abort requires -C #[track_caller] #[lang = "panic_fmt"] // needed for const-evaluated panics #[rustc_do_not_const_check] // hooked by const-eval -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "panic_internals", issue = "none"))] -#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] // must follow stable const rules since it is exposed to stable +#[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! { if cfg!(feature = "panic_immediate_abort") { super::intrinsics::abort() @@ -60,7 +59,7 @@ pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! { // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call // that gets resolved to the `#[panic_handler]` function. - extern "Rust" { + unsafe extern "Rust" { #[lang = "panic_impl"] fn panic_impl(pi: &PanicInfo<'_>) -> !; } @@ -86,8 +85,7 @@ pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! { // and unwinds anyway, we will hit the "unwinding out of nounwind function" guard, // which causes a "panic in a function that cannot unwind". #[rustc_nounwind] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "panic_internals", issue = "none"))] -#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] // must follow stable const rules since it is exposed to stable +#[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable #[rustc_allow_const_fn_unstable(const_eval_select)] pub const fn panic_nounwind_fmt(fmt: fmt::Arguments<'_>, force_no_backtrace: bool) -> ! { const_eval_select!( @@ -102,7 +100,7 @@ pub const fn panic_nounwind_fmt(fmt: fmt::Arguments<'_>, force_no_backtrace: boo // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call // that gets resolved to the `#[panic_handler]` function. - extern "Rust" { + unsafe extern "Rust" { #[lang = "panic_impl"] fn panic_impl(pi: &PanicInfo<'_>) -> !; } @@ -130,8 +128,7 @@ pub const fn panic_nounwind_fmt(fmt: fmt::Arguments<'_>, force_no_backtrace: boo #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[track_caller] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "panic_internals", issue = "none"))] -#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] // must follow stable const rules since it is exposed to stable +#[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable #[lang = "panic"] // used by lints and miri for panics pub const fn panic(expr: &'static str) -> ! { // Use Arguments::new_const instead of format_args!("{expr}") to potentially @@ -169,8 +166,7 @@ macro_rules! panic_const { #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[track_caller] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "panic_internals", issue = "none"))] - #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] // must follow stable const rules since it is exposed to stable + #[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable #[lang = stringify!($lang)] pub const fn $lang() -> ! { // Use Arguments::new_const instead of format_args!("{expr}") to potentially @@ -217,8 +213,7 @@ panic_const! { #[cfg_attr(feature = "panic_immediate_abort", inline)] #[lang = "panic_nounwind"] // needed by codegen for non-unwinding panics #[rustc_nounwind] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "panic_internals", issue = "none"))] -#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] // must follow stable const rules since it is exposed to stable +#[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable pub const fn panic_nounwind(expr: &'static str) -> ! { panic_nounwind_fmt(fmt::Arguments::new_const(&[expr]), /* force_no_backtrace */ false); } @@ -234,8 +229,7 @@ pub fn panic_nounwind_nobacktrace(expr: &'static str) -> ! { #[track_caller] #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)] #[cfg_attr(feature = "panic_immediate_abort", inline)] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "panic_internals", issue = "none"))] -#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] // must follow stable const rules since it is exposed to stable +#[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable pub const fn panic_explicit() -> ! { panic_display(&"explicit panic"); } @@ -252,8 +246,7 @@ pub fn unreachable_display(x: &T) -> ! { #[inline] #[track_caller] #[rustc_diagnostic_item = "panic_str_2015"] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "panic_internals", issue = "none"))] -#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] // must follow stable const rules since it is exposed to stable +#[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable pub const fn panic_str_2015(expr: &str) -> ! { panic_display(&expr); } @@ -263,8 +256,7 @@ pub const fn panic_str_2015(expr: &str) -> ! { #[rustc_do_not_const_check] // hooked by const-eval // enforce a &&str argument in const-check and hook this by const-eval #[rustc_const_panic_str] -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "panic_internals", issue = "none"))] -#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] // must follow stable const rules since it is exposed to stable +#[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable pub const fn panic_display(x: &T) -> ! { panic_fmt(format_args!("{}", *x)); } @@ -299,6 +291,22 @@ fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! { ) } +#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold, optimize(size))] +#[cfg_attr(feature = "panic_immediate_abort", inline)] +#[track_caller] +#[lang = "panic_null_pointer_dereference"] // needed by codegen for panic on null pointer deref +#[rustc_nounwind] // `CheckNull` MIR pass requires this function to never unwind +fn panic_null_pointer_dereference() -> ! { + if cfg!(feature = "panic_immediate_abort") { + super::intrinsics::abort() + } + + panic_nounwind_fmt( + format_args!("null pointer dereference occurred"), + /* force_no_backtrace */ false, + ) +} + /// Panics because we cannot unwind out of a function. /// /// This is a separate function to avoid the codesize impact of each crate containing the string to @@ -333,8 +341,7 @@ fn panic_in_cleanup() -> ! { /// This function is used instead of panic_fmt in const eval. #[lang = "const_panic_fmt"] // needed by const-eval machine to replace calls to `panic_fmt` lang item -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "panic_internals", issue = "none"))] -#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] // must follow stable const rules since it is exposed to stable +#[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable pub const fn const_panic_fmt(fmt: fmt::Arguments<'_>) -> ! { if let Some(msg) = fmt.as_str() { // The panic_display function is hooked by const eval. diff --git a/core/src/pat.rs b/core/src/pat.rs index 1f89d960be67b..f8826096df3e1 100644 --- a/core/src/pat.rs +++ b/core/src/pat.rs @@ -6,9 +6,71 @@ /// ``` #[macro_export] #[rustc_builtin_macro(pattern_type)] -#[unstable(feature = "core_pattern_type", issue = "123646")] +#[unstable(feature = "pattern_type_macro", issue = "123646")] macro_rules! pattern_type { ($($arg:tt)*) => { /* compiler built-in */ }; } + +/// A trait implemented for integer types and `char`. +/// Useful in the future for generic pattern types, but +/// used right now to simplify ast lowering of pattern type ranges. +#[unstable(feature = "pattern_type_range_trait", issue = "123646")] +#[rustc_const_unstable(feature = "pattern_type_range_trait", issue = "123646")] +#[const_trait] +#[diagnostic::on_unimplemented( + message = "`{Self}` is not a valid base type for range patterns", + label = "only integer types and `char` are supported" +)] +pub trait RangePattern { + /// Trait version of the inherent `MIN` assoc const. + #[cfg_attr(not(bootstrap), lang = "RangeMin")] + const MIN: Self; + + /// Trait version of the inherent `MIN` assoc const. + #[cfg_attr(not(bootstrap), lang = "RangeMax")] + const MAX: Self; + + /// A compile-time helper to subtract 1 for exclusive ranges. + #[cfg_attr(not(bootstrap), lang = "RangeSub")] + #[track_caller] + fn sub_one(self) -> Self; +} + +macro_rules! impl_range_pat { + ($($ty:ty,)*) => { + $( + #[rustc_const_unstable(feature = "pattern_type_range_trait", issue = "123646")] + impl const RangePattern for $ty { + const MIN: $ty = <$ty>::MIN; + const MAX: $ty = <$ty>::MAX; + fn sub_one(self) -> Self { + match self.checked_sub(1) { + Some(val) => val, + None => panic!("exclusive range end at minimum value of type") + } + } + } + )* + } +} + +impl_range_pat! { + i8, i16, i32, i64, i128, isize, + u8, u16, u32, u64, u128, usize, +} + +#[rustc_const_unstable(feature = "pattern_type_range_trait", issue = "123646")] +impl const RangePattern for char { + const MIN: Self = char::MIN; + + const MAX: Self = char::MAX; + + fn sub_one(self) -> Self { + match char::from_u32(self as u32 - 1) { + None => panic!("exclusive range to start of valid chars"), + Some(val) => val, + } + } +} diff --git a/core/src/pin.rs b/core/src/pin.rs index c14c49a0d92f9..7fcd19f67ee2d 100644 --- a/core/src/pin.rs +++ b/core/src/pin.rs @@ -156,8 +156,8 @@ //! //! In order to implement the second option, we must in some way enforce its key invariant, //! *i.e.* prevent the value from being *moved* or otherwise invalidated (you may notice this -//! sounds an awful lot like the definition of *pinning* a value). There a few ways one might be -//! able to enforce this invariant in Rust: +//! sounds an awful lot like the definition of *pinning* a value). There are a few ways one might +//! be able to enforce this invariant in Rust: //! //! 1. Offer a wholly `unsafe` API to interact with the object, thus requiring every caller to //! uphold the invariant themselves @@ -331,7 +331,7 @@ //! //! Note that this invariant is enforced by simply making it impossible to call code that would //! perform a move on the pinned value. This is the case since the only way to access that pinned -//! value is through the pinning [Pin]<[&mut] T>>, which in turn restricts our access. +//! value is through the pinning [Pin]<[&mut] T>, which in turn restricts our access. //! //! ## [`Unpin`] //! @@ -373,13 +373,13 @@ //! exactly what we did with our `AddrTracker` example above. Without doing this, you *must not* //! rely on pinning-related guarantees to apply to your type! //! -//! If need to truly pin a value of a foreign or built-in type that implements [`Unpin`], you'll -//! need to create your own wrapper type around the [`Unpin`] type you want to pin and then -//! opts-out of [`Unpin`] using [`PhantomPinned`]. +//! If you really need to pin a value of a foreign or built-in type that implements [`Unpin`], +//! you'll need to create your own wrapper type around the [`Unpin`] type you want to pin and then +//! opt-out of [`Unpin`] using [`PhantomPinned`]. //! //! Exposing access to the inner field which you want to remain pinned must then be carefully //! considered as well! Remember, exposing a method that gives access to a -//! [Pin]<[&mut] InnerT>> where InnerT: [Unpin] would allow safe code to +//! [Pin]<[&mut] InnerT> where InnerT: [Unpin] would allow safe code to //! trivially move the inner value out of that pinning pointer, which is precisely what you're //! seeking to prevent! Exposing a field of a pinned value through a pinning pointer is called //! "projecting" a pin, and the more general case of deciding in which cases a pin should be able @@ -595,7 +595,7 @@ //! [drop-impl]: self#implementing-drop-for-types-with-address-sensitive-states //! //! The [`drop`] function takes [`&mut self`], but this is called *even if that `self` has been -//! pinned*! Implementing [`Drop`] for a type with address-sensitive states, because if `self` was +//! pinned*! Implementing [`Drop`] for a type with address-sensitive states requires some care, because if `self` was //! indeed in an address-sensitive state before [`drop`] was called, it is as if the compiler //! automatically called [`Pin::get_unchecked_mut`]. //! @@ -1186,7 +1186,7 @@ impl> Pin { /// let mut pinned: Pin<&mut u8> = Pin::new(&mut val); /// ``` #[inline(always)] - #[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_pin", since = "1.84.0")] #[stable(feature = "pin", since = "1.33.0")] pub const fn new(pointer: Ptr) -> Pin { // SAFETY: the value pointed to is `Unpin`, and so has no requirements @@ -1215,7 +1215,7 @@ impl> Pin { /// ``` #[inline(always)] #[rustc_allow_const_fn_unstable(const_precise_live_drops)] - #[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_pin", since = "1.84.0")] #[stable(feature = "pin_into_inner", since = "1.39.0")] pub const fn into_inner(pin: Pin) -> Ptr { pin.__pointer @@ -1240,8 +1240,8 @@ impl Pin { /// points to is pinned, that is a violation of the API contract and may lead to undefined /// behavior in later (even safe) operations. /// - /// By using this method, you are also making a promise about the [`Deref`] and - /// [`DerefMut`] implementations of `Ptr`, if they exist. Most importantly, they + /// By using this method, you are also making a promise about the [`Deref`], + /// [`DerefMut`], and [`Drop`] implementations of `Ptr`, if they exist. Most importantly, they /// must not move out of their `self` arguments: `Pin::as_mut` and `Pin::as_ref` /// will call `DerefMut::deref_mut` and `Deref::deref` *on the pointer type `Ptr`* /// and expect these methods to uphold the pinning invariants. @@ -1352,7 +1352,7 @@ impl Pin { /// [`pin` module docs]: self #[lang = "new_unchecked"] #[inline(always)] - #[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_pin", since = "1.84.0")] #[stable(feature = "pin", since = "1.33.0")] pub const unsafe fn new_unchecked(pointer: Ptr) -> Pin { Pin { __pointer: pointer } @@ -1423,7 +1423,7 @@ impl Pin { /// move in the future, and this method does not enable the pointee to move. "Malicious" /// implementations of `Ptr::DerefMut` are likewise ruled out by the contract of /// `Pin::new_unchecked`. - #[stable(feature = "pin_deref_mut", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "pin_deref_mut", since = "1.84.0")] #[must_use = "`self` will be dropped if the result is not used"] #[inline(always)] pub fn as_deref_mut(self: Pin<&mut Pin>) -> Pin<&mut Ptr::Target> { @@ -1505,7 +1505,7 @@ impl Pin { /// instead. #[inline(always)] #[rustc_allow_const_fn_unstable(const_precise_live_drops)] - #[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_pin", since = "1.84.0")] #[stable(feature = "pin_into_inner", since = "1.39.0")] pub const unsafe fn into_inner_unchecked(pin: Pin) -> Ptr { pin.__pointer @@ -1561,7 +1561,7 @@ impl<'a, T: ?Sized> Pin<&'a T> { /// ["pinning projections"]: self#projections-and-structural-pinning #[inline(always)] #[must_use] - #[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_pin", since = "1.84.0")] #[stable(feature = "pin", since = "1.33.0")] pub const fn get_ref(self) -> &'a T { self.__pointer @@ -1572,7 +1572,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> { /// Converts this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime. #[inline(always)] #[must_use = "`self` will be dropped if the result is not used"] - #[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_pin", since = "1.84.0")] #[stable(feature = "pin", since = "1.33.0")] pub const fn into_ref(self) -> Pin<&'a T> { Pin { __pointer: self.__pointer } @@ -1590,7 +1590,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> { #[inline(always)] #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "pin", since = "1.33.0")] - #[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_pin", since = "1.84.0")] pub const fn get_mut(self) -> &'a mut T where T: Unpin, @@ -1611,7 +1611,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> { #[inline(always)] #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "pin", since = "1.33.0")] - #[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_pin", since = "1.84.0")] pub const unsafe fn get_unchecked_mut(self) -> &'a mut T { self.__pointer } @@ -1654,7 +1654,7 @@ impl Pin<&'static T> { /// This is safe because `T` is borrowed immutably for the `'static` lifetime, which /// never ends. #[stable(feature = "pin_static_ref", since = "1.61.0")] - #[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_pin", since = "1.84.0")] pub const fn static_ref(r: &'static T) -> Pin<&'static T> { // SAFETY: The 'static borrow guarantees the data will not be // moved/invalidated until it gets dropped (which is never). @@ -1668,7 +1668,7 @@ impl Pin<&'static mut T> { /// This is safe because `T` is borrowed for the `'static` lifetime, which /// never ends. #[stable(feature = "pin_static_ref", since = "1.61.0")] - #[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_pin", since = "1.84.0")] pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> { // SAFETY: The 'static borrow guarantees the data will not be // moved/invalidated until it gets dropped (which is never). diff --git a/core/src/prelude/mod.rs b/core/src/prelude/mod.rs index 496b78439ea6c..8d867a269a21a 100644 --- a/core/src/prelude/mod.rs +++ b/core/src/prelude/mod.rs @@ -9,26 +9,7 @@ #![stable(feature = "core_prelude", since = "1.4.0")] -mod common; - -/// The first version of the prelude of The Rust Standard Library. -/// -/// See the [module-level documentation](self) for more. -#[stable(feature = "rust1", since = "1.0.0")] -pub mod v1 { - #[stable(feature = "rust1", since = "1.0.0")] - pub use super::common::*; - - // Do not `doc(inline)` these `doc(hidden)` items. - #[unstable( - feature = "rustc_encodable_decodable", - issue = "none", - soft, - reason = "derive macro for `rustc-serialize`; should not be used in new code" - )] - #[allow(deprecated)] - pub use crate::macros::builtin::{RustcDecodable, RustcEncodable}; -} +pub mod v1; /// The 2015 version of the core prelude. /// @@ -71,10 +52,34 @@ pub mod rust_2021 { /// The 2024 version of the core prelude. /// /// See the [module-level documentation](self) for more. -#[unstable(feature = "prelude_2024", issue = "121042")] +#[stable(feature = "prelude_2024", since = "1.85.0")] pub mod rust_2024 { #[stable(feature = "rust1", since = "1.0.0")] - pub use super::common::*; + #[doc(no_inline)] + pub use super::v1::*; + + #[stable(feature = "prelude_2021", since = "1.55.0")] + #[doc(no_inline)] + pub use crate::iter::FromIterator; + + #[stable(feature = "prelude_2021", since = "1.55.0")] + #[doc(no_inline)] + pub use crate::convert::{TryFrom, TryInto}; + + #[stable(feature = "prelude_2024", since = "1.85.0")] + #[doc(no_inline)] + pub use crate::future::{Future, IntoFuture}; +} + +/// The Future version of the core prelude. +/// +/// See the [module-level documentation](self) for more. +#[doc(hidden)] +#[unstable(feature = "prelude_future", issue = "none")] +pub mod rust_future { + #[stable(feature = "rust1", since = "1.0.0")] + #[doc(no_inline)] + pub use super::v1::*; #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] @@ -84,7 +89,7 @@ pub mod rust_2024 { #[doc(no_inline)] pub use crate::convert::{TryFrom, TryInto}; - #[unstable(feature = "prelude_2024", issue = "121042")] + #[stable(feature = "prelude_2024", since = "1.85.0")] #[doc(no_inline)] pub use crate::future::{Future, IntoFuture}; } diff --git a/core/src/prelude/common.rs b/core/src/prelude/v1.rs similarity index 88% rename from core/src/prelude/common.rs rename to core/src/prelude/v1.rs index e38ef1e147c76..c5975c0305031 100644 --- a/core/src/prelude/common.rs +++ b/core/src/prelude/v1.rs @@ -1,7 +1,9 @@ -//! Items common to the prelude of all editions. +//! The first version of the core prelude. //! //! See the [module-level documentation](super) for more. +#![stable(feature = "core_prelude", since = "1.4.0")] + // No formatting: this file is nothing but re-exports, and their order is worth preserving. #![cfg_attr(rustfmt, rustfmt::skip)] @@ -12,6 +14,9 @@ pub use crate::marker::{Copy, Send, Sized, Sync, Unpin}; #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] pub use crate::ops::{Drop, Fn, FnMut, FnOnce}; +#[stable(feature = "async_closure", since = "1.85.0")] +#[doc(no_inline)] +pub use crate::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce}; // Re-exported functions #[stable(feature = "core_prelude", since = "1.4.0")] @@ -106,3 +111,11 @@ pub use crate::macros::builtin::type_ascribe; reason = "placeholder syntax for deref patterns" )] pub use crate::macros::builtin::deref; + +#[unstable( + feature = "type_alias_impl_trait", + issue = "63063", + reason = "`type_alias_impl_trait` has open design concerns" +)] +#[cfg(not(bootstrap))] +pub use crate::macros::builtin::define_opaque; diff --git a/core/src/primitive_docs.rs b/core/src/primitive_docs.rs index e105ceadff757..89c856fe10746 100644 --- a/core/src/primitive_docs.rs +++ b/core/src/primitive_docs.rs @@ -398,12 +398,12 @@ mod prim_never {} /// let v = vec!['h', 'e', 'l', 'l', 'o']; /// /// // five elements times four bytes for each element -/// assert_eq!(20, v.len() * std::mem::size_of::()); +/// assert_eq!(20, v.len() * size_of::()); /// /// let s = String::from("hello"); /// /// // five elements times one byte per element -/// assert_eq!(5, s.len() * std::mem::size_of::()); +/// assert_eq!(5, s.len() * size_of::()); /// ``` /// /// [`String`]: ../std/string/struct.String.html @@ -443,8 +443,8 @@ mod prim_never {} /// let s = String::from("love: ❤️"); /// let v: Vec = s.chars().collect(); /// -/// assert_eq!(12, std::mem::size_of_val(&s[..])); -/// assert_eq!(32, std::mem::size_of_val(&v[..])); +/// assert_eq!(12, size_of_val(&s[..])); +/// assert_eq!(32, size_of_val(&v[..])); /// ``` #[stable(feature = "rust1", since = "1.0.0")] mod prim_char {} @@ -563,11 +563,11 @@ impl () {} /// Note that here the call to [`drop`] is for clarity - it indicates /// that we are done with the given value and it should be destroyed. /// -/// ## 3. Create it using `ptr::addr_of!` +/// ## 3. Create it using `&raw` /// -/// Instead of coercing a reference to a raw pointer, you can use the macros -/// [`ptr::addr_of!`] (for `*const T`) and [`ptr::addr_of_mut!`] (for `*mut T`). -/// These macros allow you to create raw pointers to fields to which you cannot +/// Instead of coercing a reference to a raw pointer, you can use the raw borrow +/// operators `&raw const` (for `*const T`) and `&raw mut` (for `*mut T`). +/// These operators allow you to create raw pointers to fields to which you cannot /// create a reference (without causing undefined behavior), such as an /// unaligned field. This might be necessary if packed structs or uninitialized /// memory is involved. @@ -580,7 +580,7 @@ impl () {} /// unaligned: u32, /// } /// let s = S::default(); -/// let p = std::ptr::addr_of!(s.unaligned); // not allowed with coercion +/// let p = &raw const s.unaligned; // not allowed with coercion /// ``` /// /// ## 4. Get it from C. @@ -594,10 +594,8 @@ impl () {} /// #[allow(unused_extern_crates)] /// extern crate libc; /// -/// use std::mem; -/// /// unsafe { -/// let my_num: *mut i32 = libc::malloc(mem::size_of::()) as *mut i32; +/// let my_num: *mut i32 = libc::malloc(size_of::()) as *mut i32; /// if my_num.is_null() { /// panic!("failed to allocate memory"); /// } @@ -893,11 +891,11 @@ mod prim_array {} /// /// ``` /// # use std::rc::Rc; -/// let pointer_size = std::mem::size_of::<&u8>(); -/// assert_eq!(2 * pointer_size, std::mem::size_of::<&[u8]>()); -/// assert_eq!(2 * pointer_size, std::mem::size_of::<*const [u8]>()); -/// assert_eq!(2 * pointer_size, std::mem::size_of::>()); -/// assert_eq!(2 * pointer_size, std::mem::size_of::>()); +/// let pointer_size = size_of::<&u8>(); +/// assert_eq!(2 * pointer_size, size_of::<&[u8]>()); +/// assert_eq!(2 * pointer_size, size_of::<*const [u8]>()); +/// assert_eq!(2 * pointer_size, size_of::>()); +/// assert_eq!(2 * pointer_size, size_of::>()); /// ``` /// /// ## Trait Implementations @@ -1160,9 +1158,9 @@ impl (T,) {} /// /// Note that most common platforms will not support `f16` in hardware without enabling extra target /// features, with the notable exception of Apple Silicon (also known as M1, M2, etc.) processors. -/// Hardware support on x86-64 requires the avx512fp16 feature, while RISC-V requires Zhf. -/// Usually the fallback implementation will be to use `f32` hardware if it exists, and convert -/// between `f16` and `f32` when performing math. +/// Hardware support on x86/x86-64 requires the avx512fp16 or avx10.1 features, while RISC-V requires +/// Zfh, and Arm/AArch64 requires FEAT_FP16. Usually the fallback implementation will be to use `f32` +/// hardware if it exists, and convert between `f16` and `f32` when performing math. /// /// *[See also the `std::f16::consts` module](crate::f16::consts).* /// @@ -1344,10 +1342,10 @@ mod prim_f64 {} /// quad-precision values][wikipedia] for more information. /// /// Note that no platforms have hardware support for `f128` without enabling target specific features, -/// as for all instruction set architectures `f128` is considered an optional feature. -/// Only Power ISA ("PowerPC") and RISC-V specify it, and only certain microarchitectures -/// actually implement it. For x86-64 and AArch64, ISA support is not even specified, -/// so it will always be a software implementation significantly slower than `f64`. +/// as for all instruction set architectures `f128` is considered an optional feature. Only Power ISA +/// ("PowerPC") and RISC-V (via the Q extension) specify it, and only certain microarchitectures +/// actually implement it. For x86-64 and AArch64, ISA support is not even specified, so it will always +/// be a software implementation significantly slower than `f64`. /// /// _Note: `f128` support is incomplete. Many platforms will not be able to link math functions. On /// x86 in particular, these functions do link but their results are always incorrect._ @@ -1692,15 +1690,13 @@ mod prim_ref {} /// This zero-sized type *coerces* to a regular function pointer. For example: /// /// ```rust -/// use std::mem; -/// /// fn bar(x: i32) {} /// /// let not_bar_ptr = bar; // `not_bar_ptr` is zero-sized, uniquely identifying `bar` -/// assert_eq!(mem::size_of_val(¬_bar_ptr), 0); +/// assert_eq!(size_of_val(¬_bar_ptr), 0); /// /// let bar_ptr: fn(i32) = not_bar_ptr; // force coercion to function pointer -/// assert_eq!(mem::size_of_val(&bar_ptr), mem::size_of::()); +/// assert_eq!(size_of_val(&bar_ptr), size_of::()); /// /// let footgun = &bar; // this is a shared reference to the zero-sized type identifying `bar` /// ``` diff --git a/core/src/ptr/alignment.rs b/core/src/ptr/alignment.rs index 2538d60a8eee9..19311e39b454e 100644 --- a/core/src/ptr/alignment.rs +++ b/core/src/ptr/alignment.rs @@ -13,8 +13,8 @@ use crate::{cmp, fmt, hash, mem, num}; pub struct Alignment(AlignmentEnum); // Alignment is `repr(usize)`, but via extra steps. -const _: () = assert!(mem::size_of::() == mem::size_of::()); -const _: () = assert!(mem::align_of::() == mem::align_of::()); +const _: () = assert!(size_of::() == size_of::()); +const _: () = assert!(align_of::() == align_of::()); fn _alignment_can_be_structurally_matched(a: Alignment) -> bool { matches!(a, Alignment::MIN) @@ -38,14 +38,14 @@ impl Alignment { /// Returns the alignment for a type. /// - /// This provides the same numerical value as [`mem::align_of`], + /// This provides the same numerical value as [`align_of`], /// but in an `Alignment` instead of a `usize`. #[unstable(feature = "ptr_alignment_type", issue = "102070")] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070"))] #[inline] + #[must_use] pub const fn of() -> Self { - // SAFETY: rustc ensures that type alignment is always a power of two. - unsafe { Alignment::new_unchecked(mem::align_of::()) } + // This can't actually panic since type alignment is always a power of two. + const { Alignment::new(align_of::()).unwrap() } } /// Creates an `Alignment` from a `usize`, or returns `None` if it's @@ -53,7 +53,6 @@ impl Alignment { /// /// Note that `0` is not a power of two, nor a valid alignment. #[unstable(feature = "ptr_alignment_type", issue = "102070")] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070"))] #[inline] pub const fn new(align: usize) -> Option { if align.is_power_of_two() { @@ -73,7 +72,6 @@ impl Alignment { /// Equivalently, it must be `1 << exp` for some `exp` in `0..usize::BITS`. /// It must *not* be zero. #[unstable(feature = "ptr_alignment_type", issue = "102070")] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070"))] #[inline] pub const unsafe fn new_unchecked(align: usize) -> Self { assert_unsafe_precondition!( @@ -89,7 +87,6 @@ impl Alignment { /// Returns the alignment as a [`usize`]. #[unstable(feature = "ptr_alignment_type", issue = "102070")] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070"))] #[inline] pub const fn as_usize(self) -> usize { self.0 as usize @@ -97,11 +94,15 @@ impl Alignment { /// Returns the alignment as a [NonZero]<[usize]>. #[unstable(feature = "ptr_alignment_type", issue = "102070")] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070"))] #[inline] pub const fn as_nonzero(self) -> NonZero { + // This transmutes directly to avoid the UbCheck in `NonZero::new_unchecked` + // since there's no way for the user to trip that check anyway -- the + // validity invariant of the type would have to have been broken earlier -- + // and emitting it in an otherwise simple method is bad for compile time. + // SAFETY: All the discriminants are non-zero. - unsafe { NonZero::new_unchecked(self.as_usize()) } + unsafe { mem::transmute::>(self) } } /// Returns the base-2 logarithm of the alignment. @@ -118,7 +119,6 @@ impl Alignment { /// assert_eq!(Alignment::new(1024).unwrap().log2(), 10); /// ``` #[unstable(feature = "ptr_alignment_type", issue = "102070")] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070"))] #[inline] pub const fn log2(self) -> u32 { self.as_nonzero().trailing_zeros() @@ -148,7 +148,6 @@ impl Alignment { /// assert_ne!(one.mask(Alignment::of::().mask()), one); /// ``` #[unstable(feature = "ptr_alignment_type", issue = "102070")] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070"))] #[inline] pub const fn mask(self) -> usize { // SAFETY: The alignment is always nonzero, and therefore decrementing won't overflow. diff --git a/core/src/ptr/const_ptr.rs b/core/src/ptr/const_ptr.rs index 0dbe819acb1b9..9a4f916803e81 100644 --- a/core/src/ptr/const_ptr.rs +++ b/core/src/ptr/const_ptr.rs @@ -1,7 +1,7 @@ use super::*; use crate::cmp::Ordering::{Equal, Greater, Less}; use crate::intrinsics::const_eval_select; -use crate::mem::SizedTypeProperties; +use crate::mem::{self, SizedTypeProperties}; use crate::slice::{self, SliceIndex}; impl *const T { @@ -12,14 +12,17 @@ impl *const T { /// Therefore, two pointers that are null may still not compare equal to /// each other. /// - /// ## Behavior during const evaluation + /// # Panics during const evaluation /// - /// When this function is used during const evaluation, it may return `false` for pointers - /// that turn out to be null at runtime. Specifically, when a pointer to some memory - /// is offset beyond its bounds in such a way that the resulting pointer is null, - /// the function will still return `false`. There is no way for CTFE to know - /// the absolute position of that memory, so we cannot tell if the pointer is - /// null or not. + /// If this method is used during const evaluation, and `self` is a pointer + /// that is offset beyond the bounds of the memory it initially pointed to, + /// then there might not be enough information to determine whether the + /// pointer is null. This is because the absolute address in memory is not + /// known at compile time. If the nullness of the pointer cannot be + /// determined, this method will panic. + /// + /// In-bounds pointers are never null, so the method will never panic for + /// such pointers. /// /// # Examples /// @@ -29,7 +32,7 @@ impl *const T { /// assert!(!ptr.is_null()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_ptr_is_null", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_is_null", since = "1.84.0")] #[rustc_diagnostic_item = "ptr_const_is_null"] #[inline] #[rustc_allow_const_fn_unstable(const_eval_select)] @@ -113,7 +116,6 @@ impl *const T { /// println!("{:?}", unsafe { &*bad }); /// ``` #[unstable(feature = "set_ptr_value", issue = "75091")] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "ptr_metadata_const", since = "1.83.0"))] #[must_use = "returns a new pointer rather than modifying its argument"] #[inline] pub const fn with_metadata_of(self, meta: *const U) -> *const U @@ -159,7 +161,7 @@ impl *const T { /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. #[must_use] #[inline(always)] - #[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "strict_provenance", since = "1.84.0")] pub fn addr(self) -> usize { // A pointer-to-integer transmute currently has exactly the right semantics: it returns the // address without exposing the provenance. Note that this is *not* a stable guarantee about @@ -193,7 +195,7 @@ impl *const T { /// [`with_exposed_provenance`]: with_exposed_provenance #[must_use] #[inline(always)] - #[stable(feature = "exposed_provenance", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "exposed_provenance", since = "1.84.0")] pub fn expose_provenance(self) -> usize { self.cast::<()>() as usize } @@ -211,7 +213,7 @@ impl *const T { /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. #[must_use] #[inline] - #[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "strict_provenance", since = "1.84.0")] pub fn with_addr(self, addr: usize) -> Self { // This should probably be an intrinsic to avoid doing any sort of arithmetic, but // meanwhile, we can implement it with `wrapping_offset`, which preserves the pointer's @@ -230,7 +232,7 @@ impl *const T { /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. #[must_use] #[inline] - #[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "strict_provenance", since = "1.84.0")] pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self { self.with_addr(f(self.addr())) } @@ -255,6 +257,13 @@ impl *const T { /// When calling this method, you have to ensure that *either* the pointer is null *or* /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion). /// + /// # Panics during const evaluation + /// + /// This method will panic during const evaluation if the pointer cannot be + /// determined to be null or not. See [`is_null`] for more information. + /// + /// [`is_null`]: #method.is_null + /// /// # Examples /// /// ``` @@ -282,7 +291,7 @@ impl *const T { /// } /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] - #[rustc_const_stable(feature = "const_ptr_is_null", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_is_null", since = "1.84.0")] #[inline] pub const unsafe fn as_ref<'a>(self) -> Option<&'a T> { // SAFETY: the caller must guarantee that `self` is valid @@ -332,6 +341,13 @@ impl *const T { /// When calling this method, you have to ensure that *either* the pointer is null *or* /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion). /// + /// # Panics during const evaluation + /// + /// This method will panic during const evaluation if the pointer cannot be + /// determined to be null or not. See [`is_null`] for more information. + /// + /// [`is_null`]: #method.is_null + /// /// # Examples /// /// ``` @@ -347,7 +363,6 @@ impl *const T { /// ``` #[inline] #[unstable(feature = "ptr_as_uninit", issue = "75402")] - #[rustc_const_unstable(feature = "ptr_as_uninit", issue = "75402")] pub const unsafe fn as_uninit_ref<'a>(self) -> Option<&'a MaybeUninit> where T: Sized, @@ -504,11 +519,12 @@ impl *const T { /// let mut out = String::new(); /// while ptr != end_rounded_up { /// unsafe { - /// write!(&mut out, "{}, ", *ptr).unwrap(); + /// write!(&mut out, "{}, ", *ptr)?; /// } /// ptr = ptr.wrapping_offset(step); /// } /// assert_eq!(out.as_str(), "1, 3, 5, "); + /// # std::fmt::Result::Ok(()) /// ``` #[stable(feature = "ptr_wrapping_offset", since = "1.16.0")] #[must_use = "returns a new pointer rather than modifying its argument"] @@ -579,9 +595,9 @@ impl *const T { } /// Calculates the distance between two pointers within the same allocation. The returned value is in - /// units of T: the distance in bytes divided by `mem::size_of::()`. + /// units of T: the distance in bytes divided by `size_of::()`. /// - /// This is equivalent to `(self as isize - origin as isize) / (mem::size_of::() as isize)`, + /// This is equivalent to `(self as isize - origin as isize) / (size_of::() as isize)`, /// except that it has a lot more opportunities for UB, in exchange for the compiler /// better understanding what you are doing. /// @@ -617,7 +633,7 @@ impl *const T { /// objects is not known at compile-time. However, the requirement also exists at /// runtime and may be exploited by optimizations. If you wish to compute the difference between /// pointers that are not guaranteed to be from the same allocation, use `(self as isize - - /// origin as isize) / mem::size_of::()`. + /// origin as isize) / size_of::()`. // FIXME: recommend `addr()` instead of `as usize` once that is stable. /// /// [`add`]: #method.add @@ -667,7 +683,7 @@ impl *const T { where T: Sized, { - let pointee_size = mem::size_of::(); + let pointee_size = size_of::(); assert!(0 < pointee_size && pointee_size <= isize::MAX as usize); // SAFETY: the caller must uphold the safety contract for `ptr_offset_from`. unsafe { intrinsics::ptr_offset_from(self, origin) } @@ -693,7 +709,7 @@ impl *const T { /// Calculates the distance between two pointers within the same allocation, *where it's known that /// `self` is equal to or greater than `origin`*. The returned value is in - /// units of T: the distance in bytes is divided by `mem::size_of::()`. + /// units of T: the distance in bytes is divided by `size_of::()`. /// /// This computes the same value that [`offset_from`](#method.offset_from) /// would compute, but with the added precondition that the offset is @@ -707,14 +723,13 @@ impl *const T { /// to [`sub`](#method.sub)). The following are all equivalent, assuming /// that their safety preconditions are met: /// ```rust - /// # #![feature(ptr_sub_ptr)] - /// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool { - /// ptr.sub_ptr(origin) == count + /// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool { unsafe { + /// ptr.offset_from_unsigned(origin) == count /// # && /// origin.add(count) == ptr /// # && /// ptr.sub(count) == origin - /// # } + /// # } } /// ``` /// /// # Safety @@ -736,26 +751,24 @@ impl *const T { /// # Examples /// /// ``` - /// #![feature(ptr_sub_ptr)] - /// /// let a = [0; 5]; /// let ptr1: *const i32 = &a[1]; /// let ptr2: *const i32 = &a[3]; /// unsafe { - /// assert_eq!(ptr2.sub_ptr(ptr1), 2); + /// assert_eq!(ptr2.offset_from_unsigned(ptr1), 2); /// assert_eq!(ptr1.add(2), ptr2); /// assert_eq!(ptr2.sub(2), ptr1); - /// assert_eq!(ptr2.sub_ptr(ptr2), 0); + /// assert_eq!(ptr2.offset_from_unsigned(ptr2), 0); /// } /// /// // This would be incorrect, as the pointers are not correctly ordered: - /// // ptr1.sub_ptr(ptr2) + /// // ptr1.offset_from_unsigned(ptr2) /// ``` - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - pub const unsafe fn sub_ptr(self, origin: *const T) -> usize + pub const unsafe fn offset_from_unsigned(self, origin: *const T) -> usize where T: Sized, { @@ -773,14 +786,14 @@ impl *const T { ub_checks::assert_unsafe_precondition!( check_language_ub, - "ptr::sub_ptr requires `self >= origin`", + "ptr::offset_from_unsigned requires `self >= origin`", ( this: *const () = self as *const (), origin: *const () = origin as *const (), ) => runtime_ptr_ge(this, origin) ); - let pointee_size = mem::size_of::(); + let pointee_size = size_of::(); assert!(0 < pointee_size && pointee_size <= isize::MAX as usize); // SAFETY: the caller must uphold the safety contract for `ptr_offset_from_unsigned`. unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } @@ -791,18 +804,18 @@ impl *const T { /// units of **bytes**. /// /// This is purely a convenience for casting to a `u8` pointer and - /// using [`sub_ptr`][pointer::sub_ptr] on it. See that method for + /// using [`sub_ptr`][pointer::offset_from_unsigned] on it. See that method for /// documentation and safety requirements. /// /// For non-`Sized` pointees this operation considers only the data pointers, /// ignoring the metadata. - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - pub const unsafe fn byte_sub_ptr(self, origin: *const U) -> usize { + pub const unsafe fn byte_offset_from_unsigned(self, origin: *const U) -> usize { // SAFETY: the caller must uphold the safety contract for `sub_ptr`. - unsafe { self.cast::().sub_ptr(origin.cast::()) } + unsafe { self.cast::().offset_from_unsigned(origin.cast::()) } } /// Returns whether two pointers are guaranteed to be equal. @@ -1018,7 +1031,6 @@ impl *const T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[must_use = "returns a new pointer rather than modifying its argument"] #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_neg))] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn sub(self, count: usize) -> Self @@ -1128,11 +1140,12 @@ impl *const T { /// let mut out = String::new(); /// while ptr != end_rounded_up { /// unsafe { - /// write!(&mut out, "{}, ", *ptr).unwrap(); + /// write!(&mut out, "{}, ", *ptr)?; /// } /// ptr = ptr.wrapping_add(step); /// } /// assert_eq!(out, "1, 3, 5, "); + /// # std::fmt::Result::Ok(()) /// ``` #[stable(feature = "pointer_methods", since = "1.26.0")] #[must_use = "returns a new pointer rather than modifying its argument"] @@ -1206,11 +1219,12 @@ impl *const T { /// let mut out = String::new(); /// while ptr != start_rounded_down { /// unsafe { - /// write!(&mut out, "{}, ", *ptr).unwrap(); + /// write!(&mut out, "{}, ", *ptr)?; /// } /// ptr = ptr.wrapping_sub(step); /// } /// assert_eq!(out, "5, 3, 1, "); + /// # std::fmt::Result::Ok(()) /// ``` #[stable(feature = "pointer_methods", since = "1.26.0")] #[must_use = "returns a new pointer rather than modifying its argument"] @@ -1299,7 +1313,7 @@ impl *const T { unsafe { read_unaligned(self) } } - /// Copies `count * size_of` bytes from `self` to `dest`. The source + /// Copies `count * size_of::()` bytes from `self` to `dest`. The source /// and destination may overlap. /// /// NOTE: this has the *same* argument order as [`ptr::copy`]. @@ -1319,7 +1333,7 @@ impl *const T { unsafe { copy(self, dest, count) } } - /// Copies `count * size_of` bytes from `self` to `dest`. The source + /// Copies `count * size_of::()` bytes from `self` to `dest`. The source /// and destination may *not* overlap. /// /// NOTE: this has the *same* argument order as [`ptr::copy_nonoverlapping`]. @@ -1361,8 +1375,6 @@ impl *const T { /// Accessing adjacent `u8` as `u16` /// /// ``` - /// use std::mem::align_of; - /// /// # unsafe { /// let x = [5_u8, 6, 7, 8, 9]; /// let ptr = x.as_ptr(); @@ -1422,7 +1434,7 @@ impl *const T { where T: Sized, { - self.is_aligned_to(mem::align_of::()) + self.is_aligned_to(align_of::()) } /// Returns whether the pointer is aligned to `align`. @@ -1526,6 +1538,21 @@ impl *const [T] { self as *const T } + /// Gets a raw pointer to the underlying array. + /// + /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. + #[unstable(feature = "slice_as_array", issue = "133508")] + #[inline] + #[must_use] + pub const fn as_array(self) -> Option<*const [T; N]> { + if self.len() == N { + let me = self.as_ptr() as *const [T; N]; + Some(me) + } else { + None + } + } + /// Returns a raw pointer to an element or subslice, without doing bounds /// checking. /// @@ -1566,7 +1593,7 @@ impl *const [T] { /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// - /// * The pointer must be [valid] for reads for `ptr.len() * mem::size_of::()` many bytes, + /// * The pointer must be [valid] for reads for `ptr.len() * size_of::()` many bytes, /// and it must be properly aligned. This means in particular: /// /// * The entire memory range of this slice must be contained within a single [allocated object]! @@ -1578,7 +1605,7 @@ impl *const [T] { /// them from other data. You can obtain a pointer that is usable as `data` /// for zero-length slices using [`NonNull::dangling()`]. /// - /// * The total size `ptr.len() * mem::size_of::()` of the slice must be no larger than `isize::MAX`. + /// * The total size `ptr.len() * size_of::()` of the slice must be no larger than `isize::MAX`. /// See the safety documentation of [`pointer::offset`]. /// /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is @@ -1592,9 +1619,15 @@ impl *const [T] { /// /// [valid]: crate::ptr#safety /// [allocated object]: crate::ptr#allocated-object + /// + /// # Panics during const evaluation + /// + /// This method will panic during const evaluation if the pointer cannot be + /// determined to be null or not. See [`is_null`] for more information. + /// + /// [`is_null`]: #method.is_null #[inline] #[unstable(feature = "ptr_as_uninit", issue = "75402")] - #[rustc_const_unstable(feature = "ptr_as_uninit", issue = "75402")] pub const unsafe fn as_uninit_slice<'a>(self) -> Option<&'a [MaybeUninit]> { if self.is_null() { None @@ -1643,7 +1676,7 @@ impl *const [T; N] { } } -// Equality for pointers +/// Pointer equality is by address, as produced by the [`<*const T>::addr`](pointer::addr) method. #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for *const T { #[inline] @@ -1653,10 +1686,11 @@ impl PartialEq for *const T { } } +/// Pointer equality is an equivalence relation. #[stable(feature = "rust1", since = "1.0.0")] impl Eq for *const T {} -// Comparison for pointers +/// Pointer comparison is by address, as produced by the `[`<*const T>::addr`](pointer::addr)` method. #[stable(feature = "rust1", since = "1.0.0")] impl Ord for *const T { #[inline] @@ -1672,6 +1706,7 @@ impl Ord for *const T { } } +/// Pointer comparison is by address, as produced by the `[`<*const T>::addr`](pointer::addr)` method. #[stable(feature = "rust1", since = "1.0.0")] impl PartialOrd for *const T { #[inline] diff --git a/core/src/ptr/metadata.rs b/core/src/ptr/metadata.rs index 5f20cb2ee7206..4870750638957 100644 --- a/core/src/ptr/metadata.rs +++ b/core/src/ptr/metadata.rs @@ -53,7 +53,8 @@ use crate::ptr::NonNull; /// /// [`to_raw_parts`]: *const::to_raw_parts #[lang = "pointee_trait"] -#[rustc_deny_explicit_impl(implement_via_object = false)] +#[rustc_deny_explicit_impl] +#[rustc_do_not_implement_via_object] pub trait Pointee { /// The type for metadata in pointers and references to `Self`. #[lang = "metadata_type"] @@ -73,7 +74,7 @@ pub trait Pointee { /// #![feature(ptr_metadata)] /// /// fn this_never_panics() { -/// assert_eq!(std::mem::size_of::<&T>(), std::mem::size_of::()) +/// assert_eq!(size_of::<&T>(), size_of::()) /// } /// ``` #[unstable(feature = "ptr_metadata", issue = "81513")] @@ -92,7 +93,6 @@ pub trait Thin = Pointee; /// /// assert_eq!(std::ptr::metadata("foo"), 3_usize); /// ``` -#[cfg_attr(bootstrap, rustc_const_stable(feature = "ptr_metadata_const", since = "1.83.0"))] #[inline] pub const fn metadata(ptr: *const T) -> ::Metadata { ptr_metadata(ptr) @@ -106,7 +106,6 @@ pub const fn metadata(ptr: *const T) -> ::Metadata { /// /// [`slice::from_raw_parts`]: crate::slice::from_raw_parts #[unstable(feature = "ptr_metadata", issue = "81513")] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "ptr_metadata_const", since = "1.83.0"))] #[inline] pub const fn from_raw_parts( data_pointer: *const impl Thin, @@ -120,7 +119,6 @@ pub const fn from_raw_parts( /// /// See the documentation of [`from_raw_parts`] for more details. #[unstable(feature = "ptr_metadata", issue = "81513")] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "ptr_metadata_const", since = "1.83.0"))] #[inline] pub const fn from_raw_parts_mut( data_pointer: *mut impl Thin, @@ -157,7 +155,7 @@ pub struct DynMetadata { _phantom: crate::marker::PhantomData, } -extern "C" { +unsafe extern "C" { /// Opaque type for accessing vtables. /// /// Private implementation detail of `DynMetadata::size_of` etc. diff --git a/core/src/ptr/mod.rs b/core/src/ptr/mod.rs index 805edddfe6312..ea53da78d3bd2 100644 --- a/core/src/ptr/mod.rs +++ b/core/src/ptr/mod.rs @@ -15,8 +15,8 @@ //! The precise rules for validity are not determined yet. The guarantees that are //! provided at this point are very minimal: //! -//! * For operations of [size zero][zst], *every* pointer is valid, including the [null] pointer. -//! The following points are only concerned with non-zero-sized accesses. +//! * For memory accesses of [size zero][zst], *every* pointer is valid, including the [null] +//! pointer. The following points are only concerned with non-zero-sized accesses. //! * A [null] pointer is *never* valid. //! * For a pointer to be valid, it is necessary, but not always sufficient, that the pointer be //! *dereferenceable*. The [provenance] of the pointer is used to determine which [allocated @@ -48,7 +48,7 @@ //! //! Valid raw pointers as defined above are not necessarily properly aligned (where //! "proper" alignment is defined by the pointee type, i.e., `*const T` must be -//! aligned to `mem::align_of::()`). However, most functions require their +//! aligned to `align_of::()`). However, most functions require their //! arguments to be properly aligned, and will explicitly state //! this requirement in their documentation. Notable exceptions to this are //! [`read_unaligned`] and [`write_unaligned`]. @@ -84,7 +84,7 @@ // ^ we use this term instead of saying that the produced reference must // be valid, as the validity of a reference is easily confused for the // validity of the thing it refers to, and while the two concepts are -// closly related, they are not identical. +// closely related, they are not identical. //! //! These rules apply even if the result is unused! //! (The part about being initialized is not yet fully decided, but until @@ -200,7 +200,7 @@ //! //! But it *is* still sound to: //! -//! * Create a pointer without provenance from just an address (see [`ptr::dangling`]). Such a +//! * Create a pointer without provenance from just an address (see [`without_provenance`]). Such a //! pointer cannot be used for memory accesses (except for zero-sized accesses). This can still be //! useful for sentinel values like `null` *or* to represent a tagged pointer that will never be //! dereferenceable. In general, it is always sound for an integer to pretend to be a pointer "for @@ -297,7 +297,7 @@ //! //! // Our value, which must have enough alignment to have spare least-significant-bits. //! let my_precious_data: u32 = 17; -//! assert!(core::mem::align_of::() > 1); +//! assert!(align_of::() > 1); //! //! // Create a tagged pointer //! let ptr = &my_precious_data as *const u32; @@ -314,8 +314,8 @@ //! } //! ``` //! -//! (Yes, if you've been using AtomicUsize for pointers in concurrent datastructures, you should -//! be using AtomicPtr instead. If that messes up the way you atomically manipulate pointers, +//! (Yes, if you've been using [`AtomicUsize`] for pointers in concurrent datastructures, you should +//! be using [`AtomicPtr`] instead. If that messes up the way you atomically manipulate pointers, //! we would like to know why, and what needs to be done to fix it.) //! //! Situations where a valid pointer *must* be created from just an address, such as baremetal code @@ -381,7 +381,8 @@ //! [`with_addr`]: pointer::with_addr //! [`map_addr`]: pointer::map_addr //! [`addr`]: pointer::addr -//! [`ptr::dangling`]: core::ptr::dangling +//! [`AtomicUsize`]: crate::sync::atomic::AtomicUsize +//! [`AtomicPtr`]: crate::sync::atomic::AtomicPtr //! [`expose_provenance`]: pointer::expose_provenance //! [`with_exposed_provenance`]: with_exposed_provenance //! [Miri]: https://github.com/rust-lang/miri @@ -394,6 +395,7 @@ #![allow(clippy::not_unsafe_ptr_arg_deref)] use crate::cmp::Ordering; +use crate::intrinsics::const_eval_select; use crate::marker::FnPtr; use crate::mem::{self, MaybeUninit, SizedTypeProperties}; use crate::{fmt, hash, intrinsics, ub_checks}; @@ -591,15 +593,10 @@ pub const fn null_mut() -> *mut T { /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. #[inline(always)] #[must_use] -#[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] -#[rustc_const_stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "strict_provenance", since = "1.84.0")] +#[rustc_const_stable(feature = "strict_provenance", since = "1.84.0")] pub const fn without_provenance(addr: usize) -> *const T { - // An int-to-pointer transmute currently has exactly the intended semantics: it creates a - // pointer without provenance. Note that this is *not* a stable guarantee about transmute - // semantics, it relies on sysroot crates having special status. - // SAFETY: every valid integer is also a valid pointer (as long as you don't dereference that - // pointer). - unsafe { mem::transmute(addr) } + without_provenance_mut(addr) } /// Creates a new pointer that is dangling, but non-null and well-aligned. @@ -613,10 +610,10 @@ pub const fn without_provenance(addr: usize) -> *const T { /// some other means. #[inline(always)] #[must_use] -#[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] -#[rustc_const_stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "strict_provenance", since = "1.84.0")] +#[rustc_const_stable(feature = "strict_provenance", since = "1.84.0")] pub const fn dangling() -> *const T { - without_provenance(mem::align_of::()) + dangling_mut() } /// Creates a pointer with the given address and no [provenance][crate::ptr#provenance]. @@ -634,8 +631,8 @@ pub const fn dangling() -> *const T { /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. #[inline(always)] #[must_use] -#[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] -#[rustc_const_stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "strict_provenance", since = "1.84.0")] +#[rustc_const_stable(feature = "strict_provenance", since = "1.84.0")] pub const fn without_provenance_mut(addr: usize) -> *mut T { // An int-to-pointer transmute currently has exactly the intended semantics: it creates a // pointer without provenance. Note that this is *not* a stable guarantee about transmute @@ -656,10 +653,10 @@ pub const fn without_provenance_mut(addr: usize) -> *mut T { /// some other means. #[inline(always)] #[must_use] -#[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] -#[rustc_const_stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "strict_provenance", since = "1.84.0")] +#[rustc_const_stable(feature = "strict_provenance", since = "1.84.0")] pub const fn dangling_mut() -> *mut T { - without_provenance_mut(mem::align_of::()) + NonNull::dangling().as_ptr() } /// Converts an address back to a pointer, picking up some previously 'exposed' @@ -695,7 +692,7 @@ pub const fn dangling_mut() -> *mut T { /// This is an [Exposed Provenance][crate::ptr#exposed-provenance] API. #[must_use] #[inline(always)] -#[stable(feature = "exposed_provenance", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exposed_provenance", since = "1.84.0")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces #[allow(fuzzy_provenance_casts)] // this *is* the explicit provenance API one should use instead pub fn with_exposed_provenance(addr: usize) -> *const T { @@ -735,7 +732,7 @@ pub fn with_exposed_provenance(addr: usize) -> *const T { /// This is an [Exposed Provenance][crate::ptr#exposed-provenance] API. #[must_use] #[inline(always)] -#[stable(feature = "exposed_provenance", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exposed_provenance", since = "1.84.0")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces #[allow(fuzzy_provenance_casts)] // this *is* the explicit provenance API one should use instead pub fn with_exposed_provenance_mut(addr: usize) -> *mut T { @@ -775,7 +772,7 @@ pub fn with_exposed_provenance_mut(addr: usize) -> *mut T { /// # type T = i32; /// # fn foo() -> T { 42 } /// // The temporary holding the return value of `foo` does *not* have its lifetime extended, -/// // because the surrounding expression involves no function call. +/// // because the surrounding expression involves a function call. /// let p = ptr::from_ref(&foo()); /// unsafe { p.read() }; // UB! Reading from a dangling pointer ⚠️ /// ``` @@ -826,7 +823,7 @@ pub const fn from_ref(r: &T) -> *const T { /// # type T = i32; /// # fn foo() -> T { 42 } /// // The temporary holding the return value of `foo` does *not* have its lifetime extended, -/// // because the surrounding expression involves no function call. +/// // because the surrounding expression involves a function call. /// let p = ptr::from_mut(&mut foo()); /// unsafe { p.write(T::default()) }; // UB! Writing to a dangling pointer ⚠️ /// ``` @@ -1007,7 +1004,7 @@ pub const fn slice_from_raw_parts_mut(data: *mut T, len: usize) -> *mut [T] { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_swap", issue = "83163")] +#[rustc_const_stable(feature = "const_swap", since = "1.85.0")] #[rustc_diagnostic_item = "ptr_swap"] pub const unsafe fn swap(x: *mut T, y: *mut T) { // Give ourselves some scratch space to work with. @@ -1069,30 +1066,11 @@ pub const unsafe fn swap(x: *mut T, y: *mut T) { /// ``` #[inline] #[stable(feature = "swap_nonoverlapping", since = "1.27.0")] -#[rustc_const_unstable(feature = "const_swap", issue = "83163")] +#[rustc_const_unstable(feature = "const_swap_nonoverlapping", issue = "133668")] #[rustc_diagnostic_item = "ptr_swap_nonoverlapping"] pub const unsafe fn swap_nonoverlapping(x: *mut T, y: *mut T, count: usize) { - #[allow(unused)] - macro_rules! attempt_swap_as_chunks { - ($ChunkTy:ty) => { - if mem::align_of::() >= mem::align_of::<$ChunkTy>() - && mem::size_of::() % mem::size_of::<$ChunkTy>() == 0 - { - let x: *mut $ChunkTy = x.cast(); - let y: *mut $ChunkTy = y.cast(); - let count = count * (mem::size_of::() / mem::size_of::<$ChunkTy>()); - // SAFETY: these are the same bytes that the caller promised were - // ok, just typed as `MaybeUninit`s instead of as `T`s. - // The `if` condition above ensures that we're not violating - // alignment requirements, and that the division is exact so - // that we don't lose any bytes off the end. - return unsafe { swap_nonoverlapping_simple_untyped(x, y, count) }; - } - }; - } - ub_checks::assert_unsafe_precondition!( - check_language_ub, + check_library_ub, "ptr::swap_nonoverlapping requires that both pointer arguments are aligned and non-null \ and the specified memory ranges do not overlap", ( @@ -1109,19 +1087,48 @@ pub const unsafe fn swap_nonoverlapping(x: *mut T, y: *mut T, count: usize) { } ); - // Split up the slice into small power-of-two-sized chunks that LLVM is able - // to vectorize (unless it's a special type with more-than-pointer alignment, - // because we don't want to pessimize things like slices of SIMD vectors.) - if mem::align_of::() <= mem::size_of::() - && (!mem::size_of::().is_power_of_two() - || mem::size_of::() > mem::size_of::() * 2) - { - attempt_swap_as_chunks!(usize); - attempt_swap_as_chunks!(u8); - } + const_eval_select!( + @capture[T] { x: *mut T, y: *mut T, count: usize }: + if const { + // At compile-time we want to always copy this in chunks of `T`, to ensure that if there + // are pointers inside `T` we will copy them in one go rather than trying to copy a part + // of a pointer (which would not work). + // SAFETY: Same preconditions as this function + unsafe { swap_nonoverlapping_simple_untyped(x, y, count) } + } else { + macro_rules! attempt_swap_as_chunks { + ($ChunkTy:ty) => { + if align_of::() >= align_of::<$ChunkTy>() + && size_of::() % size_of::<$ChunkTy>() == 0 + { + let x: *mut $ChunkTy = x.cast(); + let y: *mut $ChunkTy = y.cast(); + let count = count * (size_of::() / size_of::<$ChunkTy>()); + // SAFETY: these are the same bytes that the caller promised were + // ok, just typed as `MaybeUninit`s instead of as `T`s. + // The `if` condition above ensures that we're not violating + // alignment requirements, and that the division is exact so + // that we don't lose any bytes off the end. + return unsafe { swap_nonoverlapping_simple_untyped(x, y, count) }; + } + }; + } + + // Split up the slice into small power-of-two-sized chunks that LLVM is able + // to vectorize (unless it's a special type with more-than-pointer alignment, + // because we don't want to pessimize things like slices of SIMD vectors.) + if align_of::() <= size_of::() + && (!size_of::().is_power_of_two() + || size_of::() > size_of::() * 2) + { + attempt_swap_as_chunks!(usize); + attempt_swap_as_chunks!(u8); + } - // SAFETY: Same preconditions as this function - unsafe { swap_nonoverlapping_simple_untyped(x, y, count) } + // SAFETY: Same preconditions as this function + unsafe { swap_nonoverlapping_simple_untyped(x, y, count) } + } + ) } /// Same behavior and safety conditions as [`swap_nonoverlapping`] @@ -1129,7 +1136,6 @@ pub const unsafe fn swap_nonoverlapping(x: *mut T, y: *mut T, count: usize) { /// LLVM can vectorize this (at least it can for the power-of-two-sized types /// `swap_nonoverlapping` tries to use) so no need to manually SIMD it. #[inline] -#[rustc_const_unstable(feature = "const_swap", issue = "83163")] const unsafe fn swap_nonoverlapping_simple_untyped(x: *mut T, y: *mut T, count: usize) { let x = x.cast::>(); let y = y.cast::>(); @@ -1392,8 +1398,6 @@ pub const unsafe fn read(src: *const T) -> T { /// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned /// value and the value at `*src` can [violate memory safety][read-ownership]. /// -/// Note that even if `T` has size `0`, the pointer must be non-null. -/// /// [read-ownership]: read#ownership-of-the-returned-value /// [valid]: self#safety /// @@ -1439,10 +1443,8 @@ pub const unsafe fn read(src: *const T) -> T { /// Read a `usize` value from a byte buffer: /// /// ``` -/// use std::mem; -/// /// fn read_usize(x: &[u8]) -> usize { -/// assert!(x.len() >= mem::size_of::()); +/// assert!(x.len() >= size_of::()); /// /// let ptr = x.as_ptr() as *const usize; /// @@ -1463,7 +1465,7 @@ pub const unsafe fn read_unaligned(src: *const T) -> T { // Also, since we just wrote a valid value into `tmp`, it is guaranteed // to be properly initialized. unsafe { - copy_nonoverlapping(src as *const u8, tmp.as_mut_ptr() as *mut u8, mem::size_of::()); + copy_nonoverlapping(src as *const u8, tmp.as_mut_ptr() as *mut u8, size_of::()); tmp.assume_init() } } @@ -1600,8 +1602,6 @@ pub const unsafe fn write(dst: *mut T, src: T) { /// /// * `dst` must be [valid] for writes. /// -/// Note that even if `T` has size `0`, the pointer must be non-null. -/// /// [valid]: self#safety /// /// ## On `packed` structs @@ -1645,10 +1645,8 @@ pub const unsafe fn write(dst: *mut T, src: T) { /// Write a `usize` value to a byte buffer: /// /// ``` -/// use std::mem; -/// /// fn write_usize(x: &mut [u8], val: usize) { -/// assert!(x.len() >= mem::size_of::()); +/// assert!(x.len() >= size_of::()); /// /// let ptr = x.as_mut_ptr() as *mut usize; /// @@ -1665,7 +1663,7 @@ pub const unsafe fn write_unaligned(dst: *mut T, src: T) { // `dst` cannot overlap `src` because the caller has mutable access // to `dst` while `src` is owned by this function. unsafe { - copy_nonoverlapping((&raw const src) as *const u8, dst as *mut u8, mem::size_of::()); + copy_nonoverlapping((&raw const src) as *const u8, dst as *mut u8, size_of::()); // We are calling the intrinsic directly to avoid function calls in the generated code. intrinsics::forget(src); } @@ -1909,7 +1907,7 @@ pub(crate) unsafe fn align_offset(p: *const T, a: usize) -> usize { inverse & m_minus_one } - let stride = mem::size_of::(); + let stride = size_of::(); let addr: usize = p.addr(); @@ -2111,7 +2109,6 @@ pub fn addr_eq(p: *const T, q: *const U) -> bool { /// when compiled with optimization: /// /// ``` -/// # #![feature(ptr_fn_addr_eq)] /// let f: fn(i32) -> i32 = |x| x; /// let g: fn(i32) -> i32 = |x| x + 0; // different closure, different body /// let h: fn(u32) -> u32 = |x| x + 0; // different signature too @@ -2136,7 +2133,6 @@ pub fn addr_eq(p: *const T, q: *const U) -> bool { /// # Examples /// /// ``` -/// #![feature(ptr_fn_addr_eq)] /// use std::ptr; /// /// fn a() { println!("a"); } @@ -2145,7 +2141,7 @@ pub fn addr_eq(p: *const T, q: *const U) -> bool { /// ``` /// /// [subtype]: https://doc.rust-lang.org/reference/subtyping.html -#[unstable(feature = "ptr_fn_addr_eq", issue = "129322")] +#[stable(feature = "ptr_fn_addr_eq", since = "1.85.0")] #[inline(always)] #[must_use = "function pointer comparison produces a value"] pub fn fn_addr_eq(f: T, g: U) -> bool { diff --git a/core/src/ptr/mut_ptr.rs b/core/src/ptr/mut_ptr.rs index f0204bd0f773d..b960a3d86bef0 100644 --- a/core/src/ptr/mut_ptr.rs +++ b/core/src/ptr/mut_ptr.rs @@ -1,7 +1,7 @@ use super::*; use crate::cmp::Ordering::{Equal, Greater, Less}; use crate::intrinsics::const_eval_select; -use crate::mem::SizedTypeProperties; +use crate::mem::{self, SizedTypeProperties}; use crate::slice::{self, SliceIndex}; impl *mut T { @@ -12,14 +12,17 @@ impl *mut T { /// Therefore, two pointers that are null may still not compare equal to /// each other. /// - /// ## Behavior during const evaluation + /// # Panics during const evaluation /// - /// When this function is used during const evaluation, it may return `false` for pointers - /// that turn out to be null at runtime. Specifically, when a pointer to some memory - /// is offset beyond its bounds in such a way that the resulting pointer is null, - /// the function will still return `false`. There is no way for CTFE to know - /// the absolute position of that memory, so we cannot tell if the pointer is - /// null or not. + /// If this method is used during const evaluation, and `self` is a pointer + /// that is offset beyond the bounds of the memory it initially pointed to, + /// then there might not be enough information to determine whether the + /// pointer is null. This is because the absolute address in memory is not + /// known at compile time. If the nullness of the pointer cannot be + /// determined, this method will panic. + /// + /// In-bounds pointers are never null, so the method will never panic for + /// such pointers. /// /// # Examples /// @@ -29,7 +32,7 @@ impl *mut T { /// assert!(!ptr.is_null()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_ptr_is_null", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_is_null", since = "1.84.0")] #[rustc_diagnostic_item = "ptr_is_null"] #[inline] pub const fn is_null(self) -> bool { @@ -94,7 +97,6 @@ impl *mut T { /// // This dereference is UB. The pointer only has provenance for `x` but points to `y`. /// println!("{:?}", unsafe { &*bad }); #[unstable(feature = "set_ptr_value", issue = "75091")] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "ptr_metadata_const", since = "1.83.0"))] #[must_use = "returns a new pointer rather than modifying its argument"] #[inline] pub const fn with_metadata_of(self, meta: *const U) -> *mut U @@ -146,7 +148,7 @@ impl *mut T { /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. #[must_use] #[inline(always)] - #[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "strict_provenance", since = "1.84.0")] pub fn addr(self) -> usize { // A pointer-to-integer transmute currently has exactly the right semantics: it returns the // address without exposing the provenance. Note that this is *not* a stable guarantee about @@ -179,7 +181,7 @@ impl *mut T { /// /// [`with_exposed_provenance_mut`]: with_exposed_provenance_mut #[inline(always)] - #[stable(feature = "exposed_provenance", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "exposed_provenance", since = "1.84.0")] pub fn expose_provenance(self) -> usize { self.cast::<()>() as usize } @@ -197,7 +199,7 @@ impl *mut T { /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. #[must_use] #[inline] - #[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "strict_provenance", since = "1.84.0")] pub fn with_addr(self, addr: usize) -> Self { // This should probably be an intrinsic to avoid doing any sort of arithmetic, but // meanwhile, we can implement it with `wrapping_offset`, which preserves the pointer's @@ -216,7 +218,7 @@ impl *mut T { /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. #[must_use] #[inline] - #[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "strict_provenance", since = "1.84.0")] pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self { self.with_addr(f(self.addr())) } @@ -244,6 +246,13 @@ impl *mut T { /// When calling this method, you have to ensure that *either* the pointer is null *or* /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion). /// + /// # Panics during const evaluation + /// + /// This method will panic during const evaluation if the pointer cannot be + /// determined to be null or not. See [`is_null`] for more information. + /// + /// [`is_null`]: #method.is_null-1 + /// /// # Examples /// /// ``` @@ -271,7 +280,7 @@ impl *mut T { /// } /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] - #[rustc_const_stable(feature = "const_ptr_is_null", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_is_null", since = "1.84.0")] #[inline] pub const unsafe fn as_ref<'a>(self) -> Option<&'a T> { // SAFETY: the caller must guarantee that `self` is valid for a @@ -328,6 +337,13 @@ impl *mut T { /// Note that because the created reference is to `MaybeUninit`, the /// source pointer can point to uninitialized memory. /// + /// # Panics during const evaluation + /// + /// This method will panic during const evaluation if the pointer cannot be + /// determined to be null or not. See [`is_null`] for more information. + /// + /// [`is_null`]: #method.is_null-1 + /// /// # Examples /// /// ``` @@ -343,7 +359,6 @@ impl *mut T { /// ``` #[inline] #[unstable(feature = "ptr_as_uninit", issue = "75402")] - #[rustc_const_unstable(feature = "ptr_as_uninit", issue = "75402")] pub const unsafe fn as_uninit_ref<'a>(self) -> Option<&'a MaybeUninit> where T: Sized, @@ -592,6 +607,12 @@ impl *mut T { /// the pointer is null *or* /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion). /// + /// # Panics during const evaluation + /// + /// This method will panic during const evaluation if the pointer cannot be + /// determined to be null or not. See [`is_null`] for more information. + /// + /// [`is_null`]: #method.is_null-1 /// /// # Examples /// @@ -619,7 +640,7 @@ impl *mut T { /// println!("{s:?}"); // It'll print: "[4, 2, 3]". /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] - #[rustc_const_stable(feature = "const_ptr_is_null", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_is_null", since = "1.84.0")] #[inline] pub const unsafe fn as_mut<'a>(self) -> Option<&'a mut T> { // SAFETY: the caller must guarantee that `self` is be valid for @@ -675,9 +696,15 @@ impl *mut T { /// /// When calling this method, you have to ensure that *either* the pointer is null *or* /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion). + /// + /// # Panics during const evaluation + /// + /// This method will panic during const evaluation if the pointer cannot be + /// determined to be null or not. See [`is_null`] for more information. + /// + /// [`is_null`]: #method.is_null-1 #[inline] #[unstable(feature = "ptr_as_uninit", issue = "75402")] - #[rustc_const_unstable(feature = "ptr_as_uninit", issue = "75402")] pub const unsafe fn as_uninit_mut<'a>(self) -> Option<&'a mut MaybeUninit> where T: Sized, @@ -742,9 +769,9 @@ impl *mut T { } /// Calculates the distance between two pointers within the same allocation. The returned value is in - /// units of T: the distance in bytes divided by `mem::size_of::()`. + /// units of T: the distance in bytes divided by `size_of::()`. /// - /// This is equivalent to `(self as isize - origin as isize) / (mem::size_of::() as isize)`, + /// This is equivalent to `(self as isize - origin as isize) / (size_of::() as isize)`, /// except that it has a lot more opportunities for UB, in exchange for the compiler /// better understanding what you are doing. /// @@ -780,7 +807,7 @@ impl *mut T { /// objects is not known at compile-time. However, the requirement also exists at /// runtime and may be exploited by optimizations. If you wish to compute the difference between /// pointers that are not guaranteed to be from the same allocation, use `(self as isize - - /// origin as isize) / mem::size_of::()`. + /// origin as isize) / size_of::()`. // FIXME: recommend `addr()` instead of `as usize` once that is stable. /// /// [`add`]: #method.add @@ -854,7 +881,7 @@ impl *mut T { /// Calculates the distance between two pointers within the same allocation, *where it's known that /// `self` is equal to or greater than `origin`*. The returned value is in - /// units of T: the distance in bytes is divided by `mem::size_of::()`. + /// units of T: the distance in bytes is divided by `size_of::()`. /// /// This computes the same value that [`offset_from`](#method.offset_from) /// would compute, but with the added precondition that the offset is @@ -868,14 +895,13 @@ impl *mut T { /// to [`sub`](#method.sub)). The following are all equivalent, assuming /// that their safety preconditions are met: /// ```rust - /// # #![feature(ptr_sub_ptr)] - /// # unsafe fn blah(ptr: *mut i32, origin: *mut i32, count: usize) -> bool { - /// ptr.sub_ptr(origin) == count + /// # unsafe fn blah(ptr: *mut i32, origin: *mut i32, count: usize) -> bool { unsafe { + /// ptr.offset_from_unsigned(origin) == count /// # && /// origin.add(count) == ptr /// # && /// ptr.sub(count) == origin - /// # } + /// # } } /// ``` /// /// # Safety @@ -897,32 +923,30 @@ impl *mut T { /// # Examples /// /// ``` - /// #![feature(ptr_sub_ptr)] - /// /// let mut a = [0; 5]; /// let p: *mut i32 = a.as_mut_ptr(); /// unsafe { /// let ptr1: *mut i32 = p.add(1); /// let ptr2: *mut i32 = p.add(3); /// - /// assert_eq!(ptr2.sub_ptr(ptr1), 2); + /// assert_eq!(ptr2.offset_from_unsigned(ptr1), 2); /// assert_eq!(ptr1.add(2), ptr2); /// assert_eq!(ptr2.sub(2), ptr1); - /// assert_eq!(ptr2.sub_ptr(ptr2), 0); + /// assert_eq!(ptr2.offset_from_unsigned(ptr2), 0); /// } /// /// // This would be incorrect, as the pointers are not correctly ordered: /// // ptr1.offset_from(ptr2) - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - pub const unsafe fn sub_ptr(self, origin: *const T) -> usize + pub const unsafe fn offset_from_unsigned(self, origin: *const T) -> usize where T: Sized, { // SAFETY: the caller must uphold the safety contract for `sub_ptr`. - unsafe { (self as *const T).sub_ptr(origin) } + unsafe { (self as *const T).offset_from_unsigned(origin) } } /// Calculates the distance between two pointers within the same allocation, *where it's known that @@ -930,18 +954,18 @@ impl *mut T { /// units of **bytes**. /// /// This is purely a convenience for casting to a `u8` pointer and - /// using [`sub_ptr`][pointer::sub_ptr] on it. See that method for + /// using [`sub_ptr`][pointer::offset_from_unsigned] on it. See that method for /// documentation and safety requirements. /// /// For non-`Sized` pointees this operation considers only the data pointers, /// ignoring the metadata. - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - pub const unsafe fn byte_sub_ptr(self, origin: *mut U) -> usize { + pub const unsafe fn byte_offset_from_unsigned(self, origin: *mut U) -> usize { // SAFETY: the caller must uphold the safety contract for `byte_sub_ptr`. - unsafe { (self as *const T).byte_sub_ptr(origin) } + unsafe { (self as *const T).byte_offset_from_unsigned(origin) } } /// Adds an unsigned offset to a pointer. @@ -1097,7 +1121,6 @@ impl *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[must_use = "returns a new pointer rather than modifying its argument"] #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_neg))] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn sub(self, count: usize) -> Self @@ -1374,7 +1397,7 @@ impl *mut T { unsafe { read_unaligned(self) } } - /// Copies `count * size_of` bytes from `self` to `dest`. The source + /// Copies `count * size_of::()` bytes from `self` to `dest`. The source /// and destination may overlap. /// /// NOTE: this has the *same* argument order as [`ptr::copy`]. @@ -1394,7 +1417,7 @@ impl *mut T { unsafe { copy(self, dest, count) } } - /// Copies `count * size_of` bytes from `self` to `dest`. The source + /// Copies `count * size_of::()` bytes from `self` to `dest`. The source /// and destination may *not* overlap. /// /// NOTE: this has the *same* argument order as [`ptr::copy_nonoverlapping`]. @@ -1414,7 +1437,7 @@ impl *mut T { unsafe { copy_nonoverlapping(self, dest, count) } } - /// Copies `count * size_of` bytes from `src` to `self`. The source + /// Copies `count * size_of::()` bytes from `src` to `self`. The source /// and destination may overlap. /// /// NOTE: this has the *opposite* argument order of [`ptr::copy`]. @@ -1434,7 +1457,7 @@ impl *mut T { unsafe { copy(src, self, count) } } - /// Copies `count * size_of` bytes from `src` to `self`. The source + /// Copies `count * size_of::()` bytes from `src` to `self`. The source /// and destination may *not* overlap. /// /// NOTE: this has the *opposite* argument order of [`ptr::copy_nonoverlapping`]. @@ -1568,7 +1591,7 @@ impl *mut T { /// /// [`ptr::swap`]: crate::ptr::swap() #[stable(feature = "pointer_methods", since = "1.26.0")] - #[rustc_const_unstable(feature = "const_swap", issue = "83163")] + #[rustc_const_stable(feature = "const_swap", since = "1.85.0")] #[inline(always)] pub const unsafe fn swap(self, with: *mut T) where @@ -1591,15 +1614,6 @@ impl *mut T { /// beyond the allocation that the pointer points into. It is up to the caller to ensure that /// the returned offset is correct in all terms other than alignment. /// - /// When this is called during compile-time evaluation (which is unstable), the implementation - /// may return `usize::MAX` in cases where that can never happen at runtime. This is because the - /// actual alignment of pointers is not known yet during compile-time, so an offset with - /// guaranteed alignment can sometimes not be computed. For example, a buffer declared as `[u8; - /// N]` might be allocated at an odd or an even address, but at compile-time this is not yet - /// known, so the execution has to be correct for either choice. It is therefore impossible to - /// find an offset that is guaranteed to be 2-aligned. (This behavior is subject to change, as usual - /// for unstable APIs.) - /// /// # Panics /// /// The function panics if `align` is not a power-of-two. @@ -1609,8 +1623,6 @@ impl *mut T { /// Accessing adjacent `u8` as `u16` /// /// ``` - /// use std::mem::align_of; - /// /// # unsafe { /// let mut x = [5_u8, 6, 7, 8, 9]; /// let ptr = x.as_mut_ptr(); @@ -1675,7 +1687,7 @@ impl *mut T { where T: Sized, { - self.is_aligned_to(mem::align_of::()) + self.is_aligned_to(align_of::()) } /// Returns whether the pointer is aligned to `align`. @@ -1760,6 +1772,21 @@ impl *mut [T] { self.len() == 0 } + /// Gets a raw, mutable pointer to the underlying array. + /// + /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. + #[unstable(feature = "slice_as_array", issue = "133508")] + #[inline] + #[must_use] + pub const fn as_mut_array(self) -> Option<*mut [T; N]> { + if self.len() == N { + let me = self.as_mut_ptr() as *mut [T; N]; + Some(me) + } else { + None + } + } + /// Divides one mutable raw slice into two at an index. /// /// The first will contain all indices from `[0, mid)` (excluding @@ -1921,7 +1948,7 @@ impl *mut [T] { /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// - /// * The pointer must be [valid] for reads for `ptr.len() * mem::size_of::()` many bytes, + /// * The pointer must be [valid] for reads for `ptr.len() * size_of::()` many bytes, /// and it must be properly aligned. This means in particular: /// /// * The entire memory range of this slice must be contained within a single [allocated object]! @@ -1933,7 +1960,7 @@ impl *mut [T] { /// them from other data. You can obtain a pointer that is usable as `data` /// for zero-length slices using [`NonNull::dangling()`]. /// - /// * The total size `ptr.len() * mem::size_of::()` of the slice must be no larger than `isize::MAX`. + /// * The total size `ptr.len() * size_of::()` of the slice must be no larger than `isize::MAX`. /// See the safety documentation of [`pointer::offset`]. /// /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is @@ -1947,9 +1974,15 @@ impl *mut [T] { /// /// [valid]: crate::ptr#safety /// [allocated object]: crate::ptr#allocated-object + /// + /// # Panics during const evaluation + /// + /// This method will panic during const evaluation if the pointer cannot be + /// determined to be null or not. See [`is_null`] for more information. + /// + /// [`is_null`]: #method.is_null-1 #[inline] #[unstable(feature = "ptr_as_uninit", issue = "75402")] - #[rustc_const_unstable(feature = "ptr_as_uninit", issue = "75402")] pub const unsafe fn as_uninit_slice<'a>(self) -> Option<&'a [MaybeUninit]> { if self.is_null() { None @@ -1973,7 +2006,7 @@ impl *mut [T] { /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// - /// * The pointer must be [valid] for reads and writes for `ptr.len() * mem::size_of::()` + /// * The pointer must be [valid] for reads and writes for `ptr.len() * size_of::()` /// many bytes, and it must be properly aligned. This means in particular: /// /// * The entire memory range of this slice must be contained within a single [allocated object]! @@ -1985,7 +2018,7 @@ impl *mut [T] { /// them from other data. You can obtain a pointer that is usable as `data` /// for zero-length slices using [`NonNull::dangling()`]. /// - /// * The total size `ptr.len() * mem::size_of::()` of the slice must be no larger than `isize::MAX`. + /// * The total size `ptr.len() * size_of::()` of the slice must be no larger than `isize::MAX`. /// See the safety documentation of [`pointer::offset`]. /// /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is @@ -1999,9 +2032,15 @@ impl *mut [T] { /// /// [valid]: crate::ptr#safety /// [allocated object]: crate::ptr#allocated-object + /// + /// # Panics during const evaluation + /// + /// This method will panic during const evaluation if the pointer cannot be + /// determined to be null or not. See [`is_null`] for more information. + /// + /// [`is_null`]: #method.is_null-1 #[inline] #[unstable(feature = "ptr_as_uninit", issue = "75402")] - #[rustc_const_unstable(feature = "ptr_as_uninit", issue = "75402")] pub const unsafe fn as_uninit_slice_mut<'a>(self) -> Option<&'a mut [MaybeUninit]> { if self.is_null() { None @@ -2053,7 +2092,7 @@ impl *mut [T; N] { } } -// Equality for pointers +/// Pointer equality is by address, as produced by the [`<*mut T>::addr`](pointer::addr) method. #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for *mut T { #[inline(always)] @@ -2063,9 +2102,11 @@ impl PartialEq for *mut T { } } +/// Pointer equality is an equivalence relation. #[stable(feature = "rust1", since = "1.0.0")] impl Eq for *mut T {} +/// Pointer comparison is by address, as produced by the [`<*mut T>::addr`](pointer::addr) method. #[stable(feature = "rust1", since = "1.0.0")] impl Ord for *mut T { #[inline] @@ -2081,6 +2122,7 @@ impl Ord for *mut T { } } +/// Pointer comparison is by address, as produced by the [`<*mut T>::addr`](pointer::addr) method. #[stable(feature = "rust1", since = "1.0.0")] impl PartialOrd for *mut T { #[inline(always)] diff --git a/core/src/ptr/non_null.rs b/core/src/ptr/non_null.rs index b69f8a4b9d3ea..c769ba673c61e 100644 --- a/core/src/ptr/non_null.rs +++ b/core/src/ptr/non_null.rs @@ -7,7 +7,7 @@ use crate::pin::PinCoerceUnsized; use crate::ptr::Unique; use crate::slice::{self, SliceIndex}; use crate::ub_checks::assert_unsafe_precondition; -use crate::{fmt, hash, intrinsics, ptr}; +use crate::{fmt, hash, intrinsics, mem, ptr}; /// `*mut T` but non-zero and [covariant]. /// @@ -49,7 +49,6 @@ use crate::{fmt, hash, intrinsics, ptr}; /// are guaranteed to have the same size and alignment: /// /// ``` -/// # use std::mem::{size_of, align_of}; /// use std::ptr::NonNull; /// /// assert_eq!(size_of::>(), size_of::>>()); @@ -69,6 +68,8 @@ use crate::{fmt, hash, intrinsics, ptr}; #[rustc_nonnull_optimization_guaranteed] #[rustc_diagnostic_item = "NonNull"] pub struct NonNull { + // Remember to use `.as_ptr()` instead of `.pointer`, as field projecting to + // this is banned by . pointer: *const T, } @@ -83,6 +84,20 @@ impl !Send for NonNull {} impl !Sync for NonNull {} impl NonNull { + /// Creates a pointer with the given address and no [provenance][crate::ptr#provenance]. + /// + /// For more details, see the equivalent method on a raw pointer, [`ptr::without_provenance_mut`]. + /// + /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. + #[unstable(feature = "nonnull_provenance", issue = "135243")] + #[must_use] + #[inline] + pub const fn without_provenance(addr: NonZero) -> Self { + let pointer = crate::ptr::without_provenance(addr.get()); + // SAFETY: we know `addr` is non-zero. + unsafe { NonNull { pointer } } + } + /// Creates a new `NonNull` that is dangling, but well-aligned. /// /// This is useful for initializing types which lazily allocate, like @@ -107,9 +122,22 @@ impl NonNull { #[must_use] #[inline] pub const fn dangling() -> Self { - // SAFETY: ptr::dangling_mut() returns a non-null well-aligned pointer. + let align = crate::ptr::Alignment::of::(); + NonNull::without_provenance(align.as_nonzero()) + } + + /// Converts an address back to a mutable pointer, picking up some previously 'exposed' + /// [provenance][crate::ptr#provenance]. + /// + /// For more details, see the equivalent method on a raw pointer, [`ptr::with_exposed_provenance_mut`]. + /// + /// This is an [Exposed Provenance][crate::ptr#exposed-provenance] API. + #[unstable(feature = "nonnull_provenance", issue = "135243")] + #[inline] + pub fn with_exposed_provenance(addr: NonZero) -> Self { + // SAFETY: we know `addr` is non-zero. unsafe { - let ptr = crate::ptr::dangling_mut::(); + let ptr = crate::ptr::with_exposed_provenance_mut(addr.get()); NonNull::new_unchecked(ptr) } } @@ -202,6 +230,13 @@ impl NonNull { /// Creates a new `NonNull` if `ptr` is non-null. /// + /// # Panics during const evaluation + /// + /// This method will panic during const evaluation if the pointer cannot be + /// determined to be null or not. See [`is_null`] for more information. + /// + /// [`is_null`]: ../primitive.pointer.html#method.is_null-1 + /// /// # Examples /// /// ``` @@ -215,7 +250,7 @@ impl NonNull { /// } /// ``` #[stable(feature = "nonnull", since = "1.25.0")] - #[rustc_const_unstable(feature = "const_nonnull_new", issue = "93235")] + #[rustc_const_stable(feature = "const_nonnull_new", since = "1.85.0")] #[inline] pub const fn new(ptr: *mut T) -> Option { if !ptr.is_null() { @@ -273,41 +308,54 @@ impl NonNull { /// Gets the "address" portion of the pointer. /// - /// For more details see the equivalent method on a raw pointer, [`pointer::addr`]. + /// For more details, see the equivalent method on a raw pointer, [`pointer::addr`]. /// /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. #[must_use] #[inline] - #[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "strict_provenance", since = "1.84.0")] pub fn addr(self) -> NonZero { // SAFETY: The pointer is guaranteed by the type to be non-null, // meaning that the address will be non-zero. - unsafe { NonZero::new_unchecked(self.pointer.addr()) } + unsafe { NonZero::new_unchecked(self.as_ptr().addr()) } + } + + /// Exposes the ["provenance"][crate::ptr#provenance] part of the pointer for future use in + /// [`with_exposed_provenance`][NonNull::with_exposed_provenance] and returns the "address" portion. + /// + /// For more details, see the equivalent method on a raw pointer, [`pointer::expose_provenance`]. + /// + /// This is an [Exposed Provenance][crate::ptr#exposed-provenance] API. + #[unstable(feature = "nonnull_provenance", issue = "135243")] + pub fn expose_provenance(self) -> NonZero { + // SAFETY: The pointer is guaranteed by the type to be non-null, + // meaning that the address will be non-zero. + unsafe { NonZero::new_unchecked(self.as_ptr().expose_provenance()) } } /// Creates a new pointer with the given address and the [provenance][crate::ptr#provenance] of /// `self`. /// - /// For more details see the equivalent method on a raw pointer, [`pointer::with_addr`]. + /// For more details, see the equivalent method on a raw pointer, [`pointer::with_addr`]. /// /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. #[must_use] #[inline] - #[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "strict_provenance", since = "1.84.0")] pub fn with_addr(self, addr: NonZero) -> Self { // SAFETY: The result of `ptr::from::with_addr` is non-null because `addr` is guaranteed to be non-zero. - unsafe { NonNull::new_unchecked(self.pointer.with_addr(addr.get()) as *mut _) } + unsafe { NonNull::new_unchecked(self.as_ptr().with_addr(addr.get()) as *mut _) } } /// Creates a new pointer by mapping `self`'s address to a new one, preserving the /// [provenance][crate::ptr#provenance] of `self`. /// - /// For more details see the equivalent method on a raw pointer, [`pointer::map_addr`]. + /// For more details, see the equivalent method on a raw pointer, [`pointer::map_addr`]. /// /// This is a [Strict Provenance][crate::ptr#strict-provenance] API. #[must_use] #[inline] - #[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "strict_provenance", since = "1.84.0")] pub fn map_addr(self, f: impl FnOnce(NonZero) -> NonZero) -> Self { self.with_addr(f(self.addr())) } @@ -335,7 +383,12 @@ impl NonNull { #[must_use] #[inline(always)] pub const fn as_ptr(self) -> *mut T { - self.pointer as *mut T + // This is a transmute for the same reasons as `NonZero::get`. + + // SAFETY: `NonNull` is `transparent` over a `*const T`, and `*const T` + // and `*mut T` have the same layout, so transitively we can transmute + // our `NonNull` to a `*mut T` directly. + unsafe { mem::transmute::(self) } } /// Returns a shared reference to the value. If the value may be uninitialized, [`as_uninit_ref`] @@ -484,7 +537,7 @@ impl NonNull { // Additionally safety contract of `offset` guarantees that the resulting pointer is // pointing to an allocation, there can't be an allocation at null, thus it's safe to // construct `NonNull`. - unsafe { NonNull { pointer: intrinsics::offset(self.pointer, count) } } + unsafe { NonNull { pointer: intrinsics::offset(self.as_ptr(), count) } } } /// Calculates the offset from a pointer in bytes. @@ -508,7 +561,7 @@ impl NonNull { // Additionally safety contract of `offset` guarantees that the resulting pointer is // pointing to an allocation, there can't be an allocation at null, thus it's safe to // construct `NonNull`. - unsafe { NonNull { pointer: self.pointer.byte_offset(count) } } + unsafe { NonNull { pointer: self.as_ptr().byte_offset(count) } } } /// Adds an offset to a pointer (convenience for `.offset(count as isize)`). @@ -560,7 +613,7 @@ impl NonNull { // Additionally safety contract of `offset` guarantees that the resulting pointer is // pointing to an allocation, there can't be an allocation at null, thus it's safe to // construct `NonNull`. - unsafe { NonNull { pointer: intrinsics::offset(self.pointer, count) } } + unsafe { NonNull { pointer: intrinsics::offset(self.as_ptr(), count) } } } /// Calculates the offset from a pointer in bytes (convenience for `.byte_offset(count as isize)`). @@ -584,7 +637,7 @@ impl NonNull { // Additionally safety contract of `add` guarantees that the resulting pointer is pointing // to an allocation, there can't be an allocation at null, thus it's safe to construct // `NonNull`. - unsafe { NonNull { pointer: self.pointer.byte_add(count) } } + unsafe { NonNull { pointer: self.as_ptr().byte_add(count) } } } /// Subtracts an offset from a pointer (convenience for @@ -629,7 +682,6 @@ impl NonNull { #[must_use = "returns a new pointer rather than modifying its argument"] #[stable(feature = "non_null_convenience", since = "1.80.0")] #[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")] - #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_neg))] pub const unsafe fn sub(self, count: usize) -> Self where T: Sized, @@ -667,13 +719,13 @@ impl NonNull { // Additionally safety contract of `sub` guarantees that the resulting pointer is pointing // to an allocation, there can't be an allocation at null, thus it's safe to construct // `NonNull`. - unsafe { NonNull { pointer: self.pointer.byte_sub(count) } } + unsafe { NonNull { pointer: self.as_ptr().byte_sub(count) } } } /// Calculates the distance between two pointers within the same allocation. The returned value is in - /// units of T: the distance in bytes divided by `mem::size_of::()`. + /// units of T: the distance in bytes divided by `size_of::()`. /// - /// This is equivalent to `(self as isize - origin as isize) / (mem::size_of::() as isize)`, + /// This is equivalent to `(self as isize - origin as isize) / (size_of::() as isize)`, /// except that it has a lot more opportunities for UB, in exchange for the compiler /// better understanding what you are doing. /// @@ -709,7 +761,7 @@ impl NonNull { /// objects is not known at compile-time. However, the requirement also exists at /// runtime and may be exploited by optimizations. If you wish to compute the difference between /// pointers that are not guaranteed to be from the same allocation, use `(self as isize - - /// origin as isize) / mem::size_of::()`. + /// origin as isize) / size_of::()`. // FIXME: recommend `addr()` instead of `as usize` once that is stable. /// /// [`add`]: #method.add @@ -764,7 +816,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `offset_from`. - unsafe { self.pointer.offset_from(origin.pointer) } + unsafe { self.as_ptr().offset_from(origin.as_ptr()) } } /// Calculates the distance between two pointers within the same allocation. The returned value is in @@ -782,14 +834,14 @@ impl NonNull { #[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")] pub const unsafe fn byte_offset_from(self, origin: NonNull) -> isize { // SAFETY: the caller must uphold the safety contract for `byte_offset_from`. - unsafe { self.pointer.byte_offset_from(origin.pointer) } + unsafe { self.as_ptr().byte_offset_from(origin.as_ptr()) } } // N.B. `wrapping_offset``, `wrapping_add`, etc are not implemented because they can wrap to null /// Calculates the distance between two pointers within the same allocation, *where it's known that /// `self` is equal to or greater than `origin`*. The returned value is in - /// units of T: the distance in bytes is divided by `mem::size_of::()`. + /// units of T: the distance in bytes is divided by `size_of::()`. /// /// This computes the same value that [`offset_from`](#method.offset_from) /// would compute, but with the added precondition that the offset is @@ -803,14 +855,13 @@ impl NonNull { /// to [`sub`](#method.sub)). The following are all equivalent, assuming /// that their safety preconditions are met: /// ```rust - /// # #![feature(ptr_sub_ptr)] - /// # unsafe fn blah(ptr: std::ptr::NonNull, origin: std::ptr::NonNull, count: usize) -> bool { - /// ptr.sub_ptr(origin) == count + /// # unsafe fn blah(ptr: std::ptr::NonNull, origin: std::ptr::NonNull, count: usize) -> bool { unsafe { + /// ptr.offset_from_unsigned(origin) == count /// # && /// origin.add(count) == ptr /// # && /// ptr.sub(count) == origin - /// # } + /// # } } /// ``` /// /// # Safety @@ -832,32 +883,31 @@ impl NonNull { /// # Examples /// /// ``` - /// #![feature(ptr_sub_ptr)] /// use std::ptr::NonNull; /// /// let a = [0; 5]; /// let ptr1: NonNull = NonNull::from(&a[1]); /// let ptr2: NonNull = NonNull::from(&a[3]); /// unsafe { - /// assert_eq!(ptr2.sub_ptr(ptr1), 2); + /// assert_eq!(ptr2.offset_from_unsigned(ptr1), 2); /// assert_eq!(ptr1.add(2), ptr2); /// assert_eq!(ptr2.sub(2), ptr1); - /// assert_eq!(ptr2.sub_ptr(ptr2), 0); + /// assert_eq!(ptr2.offset_from_unsigned(ptr2), 0); /// } /// /// // This would be incorrect, as the pointers are not correctly ordered: - /// // ptr1.sub_ptr(ptr2) + /// // ptr1.offset_from_unsigned(ptr2) /// ``` #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] - pub const unsafe fn sub_ptr(self, subtracted: NonNull) -> usize + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + pub const unsafe fn offset_from_unsigned(self, subtracted: NonNull) -> usize where T: Sized, { // SAFETY: the caller must uphold the safety contract for `sub_ptr`. - unsafe { self.pointer.sub_ptr(subtracted.pointer) } + unsafe { self.as_ptr().offset_from_unsigned(subtracted.as_ptr()) } } /// Calculates the distance between two pointers within the same allocation, *where it's known that @@ -865,18 +915,18 @@ impl NonNull { /// units of **bytes**. /// /// This is purely a convenience for casting to a `u8` pointer and - /// using [`sub_ptr`][NonNull::sub_ptr] on it. See that method for + /// using [`sub_ptr`][NonNull::offset_from_unsigned] on it. See that method for /// documentation and safety requirements. /// /// For non-`Sized` pointees this operation considers only the data pointers, /// ignoring the metadata. #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] - pub const unsafe fn byte_sub_ptr(self, origin: NonNull) -> usize { + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + pub const unsafe fn byte_offset_from_unsigned(self, origin: NonNull) -> usize { // SAFETY: the caller must uphold the safety contract for `byte_sub_ptr`. - unsafe { self.pointer.byte_sub_ptr(origin.pointer) } + unsafe { self.as_ptr().byte_offset_from_unsigned(origin.as_ptr()) } } /// Reads the value from `self` without moving it. This leaves the @@ -894,7 +944,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `read`. - unsafe { ptr::read(self.pointer) } + unsafe { ptr::read(self.as_ptr()) } } /// Performs a volatile read of the value from `self` without moving it. This @@ -915,7 +965,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `read_volatile`. - unsafe { ptr::read_volatile(self.pointer) } + unsafe { ptr::read_volatile(self.as_ptr()) } } /// Reads the value from `self` without moving it. This leaves the @@ -935,10 +985,10 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `read_unaligned`. - unsafe { ptr::read_unaligned(self.pointer) } + unsafe { ptr::read_unaligned(self.as_ptr()) } } - /// Copies `count * size_of` bytes from `self` to `dest`. The source + /// Copies `count * size_of::()` bytes from `self` to `dest`. The source /// and destination may overlap. /// /// NOTE: this has the *same* argument order as [`ptr::copy`]. @@ -955,10 +1005,10 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `copy`. - unsafe { ptr::copy(self.pointer, dest.as_ptr(), count) } + unsafe { ptr::copy(self.as_ptr(), dest.as_ptr(), count) } } - /// Copies `count * size_of` bytes from `self` to `dest`. The source + /// Copies `count * size_of::()` bytes from `self` to `dest`. The source /// and destination may *not* overlap. /// /// NOTE: this has the *same* argument order as [`ptr::copy_nonoverlapping`]. @@ -975,10 +1025,10 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `copy_nonoverlapping`. - unsafe { ptr::copy_nonoverlapping(self.pointer, dest.as_ptr(), count) } + unsafe { ptr::copy_nonoverlapping(self.as_ptr(), dest.as_ptr(), count) } } - /// Copies `count * size_of` bytes from `src` to `self`. The source + /// Copies `count * size_of::()` bytes from `src` to `self`. The source /// and destination may overlap. /// /// NOTE: this has the *opposite* argument order of [`ptr::copy`]. @@ -995,10 +1045,10 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `copy`. - unsafe { ptr::copy(src.pointer, self.as_ptr(), count) } + unsafe { ptr::copy(src.as_ptr(), self.as_ptr(), count) } } - /// Copies `count * size_of` bytes from `src` to `self`. The source + /// Copies `count * size_of::()` bytes from `src` to `self`. The source /// and destination may *not* overlap. /// /// NOTE: this has the *opposite* argument order of [`ptr::copy_nonoverlapping`]. @@ -1015,7 +1065,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `copy_nonoverlapping`. - unsafe { ptr::copy_nonoverlapping(src.pointer, self.as_ptr(), count) } + unsafe { ptr::copy_nonoverlapping(src.as_ptr(), self.as_ptr(), count) } } /// Executes the destructor (if any) of the pointed-to value. @@ -1133,7 +1183,7 @@ impl NonNull { /// [`ptr::swap`]: crate::ptr::swap() #[inline(always)] #[stable(feature = "non_null_convenience", since = "1.80.0")] - #[rustc_const_unstable(feature = "const_swap", issue = "83163")] + #[rustc_const_stable(feature = "const_swap", since = "1.85.0")] pub const unsafe fn swap(self, with: NonNull) where T: Sized, @@ -1172,7 +1222,6 @@ impl NonNull { /// Accessing adjacent `u8` as `u16` /// /// ``` - /// use std::mem::align_of; /// use std::ptr::NonNull; /// /// # unsafe { @@ -1202,7 +1251,7 @@ impl NonNull { { // SAFETY: `align` has been checked to be a power of 2 above. - unsafe { ptr::align_offset(self.pointer, align) } + unsafe { ptr::align_offset(self.as_ptr(), align) } } } @@ -1230,7 +1279,7 @@ impl NonNull { where T: Sized, { - self.pointer.is_aligned() + self.as_ptr().is_aligned() } /// Returns whether the pointer is aligned to `align`. @@ -1267,7 +1316,7 @@ impl NonNull { #[must_use] #[unstable(feature = "pointer_is_aligned_to", issue = "96284")] pub fn is_aligned_to(self, align: usize) -> bool { - self.pointer.is_aligned_to(align) + self.as_ptr().is_aligned_to(align) } } @@ -1392,7 +1441,7 @@ impl NonNull<[T]> { /// /// When calling this method, you have to ensure that all of the following is true: /// - /// * The pointer must be [valid] for reads for `ptr.len() * mem::size_of::()` many bytes, + /// * The pointer must be [valid] for reads for `ptr.len() * size_of::()` many bytes, /// and it must be properly aligned. This means in particular: /// /// * The entire memory range of this slice must be contained within a single allocated object! @@ -1404,7 +1453,7 @@ impl NonNull<[T]> { /// them from other data. You can obtain a pointer that is usable as `data` /// for zero-length slices using [`NonNull::dangling()`]. /// - /// * The total size `ptr.len() * mem::size_of::()` of the slice must be no larger than `isize::MAX`. + /// * The total size `ptr.len() * size_of::()` of the slice must be no larger than `isize::MAX`. /// See the safety documentation of [`pointer::offset`]. /// /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is @@ -1437,7 +1486,7 @@ impl NonNull<[T]> { /// /// When calling this method, you have to ensure that all of the following is true: /// - /// * The pointer must be [valid] for reads and writes for `ptr.len() * mem::size_of::()` + /// * The pointer must be [valid] for reads and writes for `ptr.len() * size_of::()` /// many bytes, and it must be properly aligned. This means in particular: /// /// * The entire memory range of this slice must be contained within a single allocated object! @@ -1449,7 +1498,7 @@ impl NonNull<[T]> { /// them from other data. You can obtain a pointer that is usable as `data` /// for zero-length slices using [`NonNull::dangling()`]. /// - /// * The total size `ptr.len() * mem::size_of::()` of the slice must be no larger than `isize::MAX`. + /// * The total size `ptr.len() * size_of::()` of the slice must be no larger than `isize::MAX`. /// See the safety documentation of [`pointer::offset`]. /// /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is @@ -1542,6 +1591,9 @@ impl DispatchFromDyn> for NonNull where T: U #[stable(feature = "pin", since = "1.33.0")] unsafe impl PinCoerceUnsized for NonNull {} +#[unstable(feature = "pointer_like_trait", issue = "none")] +impl core::marker::PointerLike for NonNull {} + #[stable(feature = "nonnull", since = "1.25.0")] impl fmt::Debug for NonNull { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/core/src/ptr/unique.rs b/core/src/ptr/unique.rs index a796820a7e468..4810ebe01f9bb 100644 --- a/core/src/ptr/unique.rs +++ b/core/src/ptr/unique.rs @@ -92,7 +92,6 @@ impl Unique { /// Creates a new `Unique` if `ptr` is non-null. #[inline] - #[rustc_const_unstable(feature = "ptr_internals", issue = "none")] pub const fn new(ptr: *mut T) -> Option { if let Some(pointer) = NonNull::new(ptr) { Some(Unique { pointer, _marker: PhantomData }) diff --git a/core/src/range.rs b/core/src/range.rs index 427526fd14b91..2276112a27bb3 100644 --- a/core/src/range.rs +++ b/core/src/range.rs @@ -31,7 +31,9 @@ pub use iter::{IterRange, IterRangeFrom, IterRangeInclusive}; #[doc(inline)] pub use crate::iter::Step; #[doc(inline)] -pub use crate::ops::{Bound, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive}; +pub use crate::ops::{ + Bound, IntoBounds, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive, +}; /// A (half-open) range bounded inclusively below and exclusively above /// (`start..end` in a future edition). @@ -48,6 +50,7 @@ pub use crate::ops::{Bound, OneSidedRange, RangeBounds, RangeFull, RangeTo, Rang /// assert_eq!(Range::from(3..5), Range { start: 3, end: 5 }); /// assert_eq!(3 + 4 + 5, Range::from(3..6).into_iter().sum()); /// ``` +#[lang = "RangeCopy"] #[derive(Clone, Copy, Default, PartialEq, Eq, Hash)] #[unstable(feature = "new_range_api", issue = "125687")] pub struct Range { @@ -174,6 +177,14 @@ impl RangeBounds for Range<&T> { } } +// #[unstable(feature = "range_into_bounds", issue = "136903")] +#[unstable(feature = "new_range_api", issue = "125687")] +impl IntoBounds for Range { + fn into_bounds(self) -> (Bound, Bound) { + (Included(self.start), Excluded(self.end)) + } +} + #[unstable(feature = "new_range_api", issue = "125687")] impl From> for legacy::Range { #[inline] @@ -205,6 +216,7 @@ impl From> for Range { /// assert_eq!(RangeInclusive::from(3..=5), RangeInclusive { start: 3, end: 5 }); /// assert_eq!(3 + 4 + 5, RangeInclusive::from(3..=5).into_iter().sum()); /// ``` +#[lang = "RangeInclusiveCopy"] #[derive(Clone, Copy, PartialEq, Eq, Hash)] #[unstable(feature = "new_range_api", issue = "125687")] pub struct RangeInclusive { @@ -341,6 +353,14 @@ impl RangeBounds for RangeInclusive<&T> { } } +// #[unstable(feature = "range_into_bounds", issue = "136903")] +#[unstable(feature = "new_range_api", issue = "125687")] +impl IntoBounds for RangeInclusive { + fn into_bounds(self) -> (Bound, Bound) { + (Included(self.start), Included(self.end)) + } +} + #[unstable(feature = "new_range_api", issue = "125687")] impl From> for legacy::RangeInclusive { #[inline] @@ -388,6 +408,7 @@ impl From> for RangeInclusive { /// assert_eq!(RangeFrom::from(2..), core::range::RangeFrom { start: 2 }); /// assert_eq!(2 + 3 + 4, RangeFrom::from(2..).into_iter().take(3).sum()); /// ``` +#[lang = "RangeFromCopy"] #[derive(Clone, Copy, PartialEq, Eq, Hash)] #[unstable(feature = "new_range_api", issue = "125687")] pub struct RangeFrom { @@ -476,6 +497,14 @@ impl RangeBounds for RangeFrom<&T> { } } +// #[unstable(feature = "range_into_bounds", issue = "136903")] +#[unstable(feature = "new_range_api", issue = "125687")] +impl IntoBounds for RangeFrom { + fn into_bounds(self) -> (Bound, Bound) { + (Included(self.start), Unbounded) + } +} + #[unstable(feature = "new_range_api", issue = "125687")] impl From> for legacy::RangeFrom { #[inline] diff --git a/core/src/result.rs b/core/src/result.rs index b450123c5aa90..ee98a47523fef 100644 --- a/core/src/result.rs +++ b/core/src/result.rs @@ -520,7 +520,7 @@ use crate::{convert, fmt, hint}; /// `Result` is a type that represents either success ([`Ok`]) or failure ([`Err`]). /// /// See the [module documentation](self) for details. -#[cfg_attr(not(bootstrap), doc(search_unbox))] +#[doc(search_unbox)] #[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] #[must_use = "this `Result` may be an `Err` variant, which should be handled"] #[rustc_diagnostic_item = "Result"] @@ -1065,10 +1065,15 @@ impl Result { /// Returns the contained [`Ok`] value, consuming the `self` value. /// /// Because this function may panic, its use is generally discouraged. - /// Instead, prefer to use pattern matching and handle the [`Err`] - /// case explicitly, or call [`unwrap_or`], [`unwrap_or_else`], or - /// [`unwrap_or_default`]. + /// Panics are meant for unrecoverable errors, and + /// [may abort the entire program][panic-abort]. + /// + /// Instead, prefer to use [the `?` (try) operator][try-operator], or pattern matching + /// to handle the [`Err`] case explicitly, or call [`unwrap_or`], + /// [`unwrap_or_else`], or [`unwrap_or_default`]. /// + /// [panic-abort]: https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html + /// [try-operator]: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-the--operator /// [`unwrap_or`]: Result::unwrap_or /// [`unwrap_or_else`]: Result::unwrap_or_else /// [`unwrap_or_default`]: Result::unwrap_or_default @@ -1739,6 +1744,14 @@ where } } +#[unstable(feature = "ergonomic_clones", issue = "132290")] +impl crate::clone::UseCloned for Result +where + T: crate::clone::UseCloned, + E: crate::clone::UseCloned, +{ +} + #[stable(feature = "rust1", since = "1.0.0")] impl IntoIterator for Result { type Item = T; diff --git a/core/src/slice/ascii.rs b/core/src/slice/ascii.rs index 17ad4fd8f677f..51b25fa40e3d9 100644 --- a/core/src/slice/ascii.rs +++ b/core/src/slice/ascii.rs @@ -3,8 +3,9 @@ use core::ascii::EscapeDefault; use crate::fmt::{self, Write}; +#[cfg(not(all(target_arch = "x86_64", target_feature = "sse2")))] use crate::intrinsics::const_eval_select; -use crate::{ascii, iter, mem, ops}; +use crate::{ascii, iter, ops}; #[cfg(not(test))] impl [u8] { @@ -88,7 +89,7 @@ impl [u8] { /// /// [`to_ascii_uppercase`]: #method.to_ascii_uppercase #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] - #[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_make_ascii", since = "1.84.0")] #[inline] pub const fn make_ascii_uppercase(&mut self) { // FIXME(const-hack): We would like to simply iterate using `for` loops but this isn't currently allowed in constant expressions. @@ -110,7 +111,7 @@ impl [u8] { /// /// [`to_ascii_lowercase`]: #method.to_ascii_lowercase #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] - #[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_make_ascii", since = "1.84.0")] #[inline] pub const fn make_ascii_lowercase(&mut self) { // FIXME(const-hack): We would like to simply iterate using `for` loops but this isn't currently allowed in constant expressions. @@ -328,14 +329,6 @@ impl<'a> fmt::Debug for EscapeAscii<'a> { } } -/// Returns `true` if any byte in the word `v` is nonascii (>= 128). Snarfed -/// from `../str/mod.rs`, which does something similar for utf8 validation. -#[inline] -const fn contains_nonascii(v: usize) -> bool { - const NONASCII_MASK: usize = usize::repeat_u8(0x80); - (NONASCII_MASK & v) != 0 -} - /// ASCII test *without* the chunk-at-a-time optimizations. /// /// This is carefully structured to produce nice small code -- it's smaller in @@ -366,6 +359,7 @@ pub const fn is_ascii_simple(mut bytes: &[u8]) -> bool { /// /// If any of these loads produces something for which `contains_nonascii` /// (above) returns true, then we know the answer is false. +#[cfg(not(all(target_arch = "x86_64", target_feature = "sse2")))] #[inline] #[rustc_allow_const_fn_unstable(const_eval_select)] // fallback impl has same behavior const fn is_ascii(s: &[u8]) -> bool { @@ -376,7 +370,14 @@ const fn is_ascii(s: &[u8]) -> bool { if const { is_ascii_simple(s) } else { - const USIZE_SIZE: usize = mem::size_of::(); + /// Returns `true` if any byte in the word `v` is nonascii (>= 128). Snarfed + /// from `../str/mod.rs`, which does something similar for utf8 validation. + const fn contains_nonascii(v: usize) -> bool { + const NONASCII_MASK: usize = usize::repeat_u8(0x80); + (NONASCII_MASK & v) != 0 + } + + const USIZE_SIZE: usize = size_of::(); let len = s.len(); let align_offset = s.as_ptr().align_offset(USIZE_SIZE); @@ -386,7 +387,7 @@ const fn is_ascii(s: &[u8]) -> bool { // // We also do this for architectures where `size_of::()` isn't // sufficient alignment for `usize`, because it's a weird edge case. - if len < USIZE_SIZE || len < align_offset || USIZE_SIZE < mem::align_of::() { + if len < USIZE_SIZE || len < align_offset || USIZE_SIZE < align_of::() { return is_ascii_simple(s); } @@ -420,7 +421,7 @@ const fn is_ascii(s: &[u8]) -> bool { // have alignment information it should have given a `usize::MAX` for // `align_offset` earlier, sending things through the scalar path instead of // this one, so this check should pass if it's reachable. - debug_assert!(word_ptr.is_aligned_to(mem::align_of::())); + debug_assert!(word_ptr.is_aligned_to(align_of::())); // Read subsequent words until the last aligned word, excluding the last // aligned word by itself to be done in tail check later, to ensure that @@ -455,3 +456,48 @@ const fn is_ascii(s: &[u8]) -> bool { } ) } + +/// ASCII test optimized to use the `pmovmskb` instruction available on `x86-64` +/// platforms. +/// +/// Other platforms are not likely to benefit from this code structure, so they +/// use SWAR techniques to test for ASCII in `usize`-sized chunks. +#[cfg(all(target_arch = "x86_64", target_feature = "sse2"))] +#[inline] +const fn is_ascii(bytes: &[u8]) -> bool { + // Process chunks of 32 bytes at a time in the fast path to enable + // auto-vectorization and use of `pmovmskb`. Two 128-bit vector registers + // can be OR'd together and then the resulting vector can be tested for + // non-ASCII bytes. + const CHUNK_SIZE: usize = 32; + + let mut i = 0; + + while i + CHUNK_SIZE <= bytes.len() { + let chunk_end = i + CHUNK_SIZE; + + // Get LLVM to produce a `pmovmskb` instruction on x86-64 which + // creates a mask from the most significant bit of each byte. + // ASCII bytes are less than 128 (0x80), so their most significant + // bit is unset. + let mut count = 0; + while i < chunk_end { + count += bytes[i].is_ascii() as u8; + i += 1; + } + + // All bytes should be <= 127 so count is equal to chunk size. + if count != CHUNK_SIZE as u8 { + return false; + } + } + + // Process the remaining `bytes.len() % N` bytes. + let mut is_ascii = true; + while i < bytes.len() { + is_ascii &= bytes[i].is_ascii(); + i += 1; + } + + is_ascii +} diff --git a/core/src/slice/cmp.rs b/core/src/slice/cmp.rs index 9cb00644e6442..804bdfcbb4fc7 100644 --- a/core/src/slice/cmp.rs +++ b/core/src/slice/cmp.rs @@ -1,10 +1,10 @@ //! Comparison traits for `[T]`. use super::{from_raw_parts, memchr}; +use crate::ascii; use crate::cmp::{self, BytewiseEq, Ordering}; use crate::intrinsics::compare_bytes; use crate::num::NonZero; -use crate::{ascii, mem}; #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq<[U]> for [T] @@ -87,7 +87,7 @@ where // SAFETY: `self` and `other` are references and are thus guaranteed to be valid. // The two slices have been checked to have the same size above. unsafe { - let size = mem::size_of_val(self); + let size = size_of_val(self); compare_bytes(self.as_ptr() as *const u8, other.as_ptr() as *const u8, size) == 0 } } @@ -266,7 +266,7 @@ macro_rules! impl_slice_contains { fn slice_contains(&self, arr: &[$t]) -> bool { // Make our LANE_COUNT 4x the normal lane count (aiming for 128 bit vectors). // The compiler will nicely unroll it. - const LANE_COUNT: usize = 4 * (128 / (mem::size_of::<$t>() * 8)); + const LANE_COUNT: usize = 4 * (128 / (size_of::<$t>() * 8)); // SIMD let mut chunks = arr.chunks_exact(LANE_COUNT); for chunk in &mut chunks { diff --git a/core/src/slice/iter.rs b/core/src/slice/iter.rs index c5746157d01b2..a687ed7129dc8 100644 --- a/core/src/slice/iter.rs +++ b/core/src/slice/iter.rs @@ -46,13 +46,19 @@ impl<'a, T> IntoIterator for &'a mut [T] { /// Basic usage: /// /// ``` -/// // First, we declare a type which has `iter` method to get the `Iter` struct (`&[usize]` here): +/// // First, we need a slice to call the `iter` method on: /// let slice = &[1, 2, 3]; /// -/// // Then, we iterate over it: +/// // Then we call `iter` on the slice to get the `Iter` iterator, +/// // and iterate over it: /// for element in slice.iter() { /// println!("{element}"); /// } +/// +/// // This for loop actually already works without calling `iter`: +/// for element in slice { +/// println!("{element}"); +/// } /// ``` /// /// [`iter`]: slice::iter @@ -68,7 +74,7 @@ pub struct Iter<'a, T: 'a> { ptr: NonNull, /// For non-ZSTs, the non-null pointer to the past-the-end element. /// - /// For ZSTs, this is `ptr::dangling(len)`. + /// For ZSTs, this is `ptr::without_provenance_mut(len)`. end_or_len: *const T, _marker: PhantomData<&'a T>, } @@ -101,27 +107,29 @@ impl<'a, T> Iter<'a, T> { /// Views the underlying data as a subslice of the original data. /// - /// This has the same lifetime as the original slice, and so the - /// iterator can continue to be used while this exists. - /// /// # Examples /// /// Basic usage: /// /// ``` - /// // First, we declare a type which has the `iter` method to get the `Iter` - /// // struct (`&[usize]` here): + /// // First, we need a slice to call the `iter` method on: /// let slice = &[1, 2, 3]; /// - /// // Then, we get the iterator: + /// // Then we call `iter` on the slice to get the `Iter` iterator: /// let mut iter = slice.iter(); - /// // So if we print what `as_slice` method returns here, we have "[1, 2, 3]": + /// // Here `as_slice` still returns the whole slice, so this prints "[1, 2, 3]": /// println!("{:?}", iter.as_slice()); /// - /// // Next, we move to the second element of the slice: + /// // Now, we call the `next` method to remove the first element from the iterator: /// iter.next(); - /// // Now `as_slice` returns "[2, 3]": + /// // Here the iterator does not contain the first element of the slice any more, + /// // so `as_slice` only returns the last two elements of the slice, + /// // and so this prints "[2, 3]": /// println!("{:?}", iter.as_slice()); + /// + /// // The underlying slice has not been modified and still contains three elements, + /// // so this prints "[1, 2, 3]": + /// println!("{:?}", slice); /// ``` #[must_use] #[stable(feature = "iter_to_slice", since = "1.4.0")] @@ -166,11 +174,11 @@ impl AsRef<[T]> for Iter<'_, T> { /// Basic usage: /// /// ``` -/// // First, we declare a type which has `iter_mut` method to get the `IterMut` -/// // struct (`&[usize]` here): -/// let mut slice = &mut [1, 2, 3]; +/// // First, we need a slice to call the `iter_mut` method on: +/// let slice = &mut [1, 2, 3]; /// -/// // Then, we iterate over it and increment each element value: +/// // Then we call `iter_mut` on the slice to get the `IterMut` iterator, +/// // iterate over it and increment each element value: /// for element in slice.iter_mut() { /// *element += 1; /// } @@ -247,28 +255,21 @@ impl<'a, T> IterMut<'a, T> { /// Basic usage: /// /// ``` - /// // First, we declare a type which has `iter_mut` method to get the `IterMut` - /// // struct (`&[usize]` here): + /// // First, we need a slice to call the `iter_mut` method on: /// let mut slice = &mut [1, 2, 3]; /// - /// { - /// // Then, we get the iterator: - /// let mut iter = slice.iter_mut(); - /// // We move to next element: - /// iter.next(); - /// // So if we print what `into_slice` method returns here, we have "[2, 3]": - /// println!("{:?}", iter.into_slice()); - /// } - /// - /// // Now let's modify a value of the slice: - /// { - /// // First we get back the iterator: - /// let mut iter = slice.iter_mut(); - /// // We change the value of the first element of the slice returned by the `next` method: - /// *iter.next().unwrap() += 1; - /// } - /// // Now slice is "[2, 2, 3]": - /// println!("{slice:?}"); + /// // Then we call `iter_mut` on the slice to get the `IterMut` struct: + /// let mut iter = slice.iter_mut(); + /// // Now, we call the `next` method to remove the first element of the iterator, + /// // unwrap and dereference what we get from `next` and increase its value by 1: + /// *iter.next().unwrap() += 1; + /// // Here the iterator does not contain the first element of the slice any more, + /// // so `into_slice` only returns the last two elements of the slice, + /// // and so this prints "[2, 3]": + /// println!("{:?}", iter.into_slice()); + /// // The underlying slice still contains three elements, but its first element + /// // was increased by 1, so this prints "[2, 2, 3]": + /// println!("{:?}", slice); /// ``` #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "iter_to_slice", since = "1.4.0")] @@ -281,25 +282,30 @@ impl<'a, T> IterMut<'a, T> { /// Views the underlying data as a subslice of the original data. /// - /// To avoid creating `&mut [T]` references that alias, the returned slice - /// borrows its lifetime from the iterator the method is applied on. - /// /// # Examples /// /// Basic usage: /// /// ``` - /// let mut slice: &mut [usize] = &mut [1, 2, 3]; + /// // First, we need a slice to call the `iter_mut` method on: + /// let slice = &mut [1, 2, 3]; /// - /// // First, we get the iterator: + /// // Then we call `iter_mut` on the slice to get the `IterMut` iterator: /// let mut iter = slice.iter_mut(); - /// // So if we check what the `as_slice` method returns here, we have "[1, 2, 3]": - /// assert_eq!(iter.as_slice(), &[1, 2, 3]); + /// // Here `as_slice` still returns the whole slice, so this prints "[1, 2, 3]": + /// println!("{:?}", iter.as_slice()); /// - /// // Next, we move to the second element of the slice: - /// iter.next(); - /// // Now `as_slice` returns "[2, 3]": - /// assert_eq!(iter.as_slice(), &[2, 3]); + /// // Now, we call the `next` method to remove the first element from the iterator + /// // and increment its value: + /// *iter.next().unwrap() += 1; + /// // Here the iterator does not contain the first element of the slice any more, + /// // so `as_slice` only returns the last two elements of the slice, + /// // and so this prints "[2, 3]": + /// println!("{:?}", iter.as_slice()); + /// + /// // The underlying slice still contains three elements, but its first element + /// // was increased by 1, so this prints "[2, 2, 3]": + /// println!("{:?}", slice); /// ``` #[must_use] #[stable(feature = "slice_iter_mut_as_slice", since = "1.53.0")] @@ -310,9 +316,6 @@ impl<'a, T> IterMut<'a, T> { /// Views the underlying data as a mutable subslice of the original data. /// - /// To avoid creating `&mut [T]` references that alias, the returned slice - /// borrows its lifetime from the iterator the method is applied on. - /// /// # Examples /// /// Basic usage: diff --git a/core/src/slice/iter/macros.rs b/core/src/slice/iter/macros.rs index 830debe02ea2b..7c1ed3fe8a246 100644 --- a/core/src/slice/iter/macros.rs +++ b/core/src/slice/iter/macros.rs @@ -30,7 +30,7 @@ macro_rules! if_zst { $zst_body } else { // SAFETY: for non-ZSTs, the type invariant ensures it cannot be null - let $end = unsafe { *(&raw const $this.end_or_len).cast::>() }; + let $end = unsafe { mem::transmute::<*const T, NonNull>($this.end_or_len) }; $other_body } }}; @@ -54,7 +54,7 @@ macro_rules! len { // To get rid of some bounds checks (see `position`), we use ptr_sub instead of // offset_from (Tested by `codegen/slice-position-bounds-check`.) // SAFETY: by the type invariant pointers are aligned and `start <= end` - unsafe { end.sub_ptr($self.ptr) } + unsafe { end.offset_from_unsigned($self.ptr) } }, ) }}; @@ -154,16 +154,39 @@ macro_rules! iterator { #[inline] fn next(&mut self) -> Option<$elem> { - // could be implemented with slices, but this avoids bounds checks + // intentionally not using the helpers because this is + // one of the most mono'd things in the library. - // SAFETY: The call to `next_unchecked` is - // safe since we check if the iterator is empty first. + let ptr = self.ptr; + let end_or_len = self.end_or_len; + // SAFETY: See inner comments. (For some reason having multiple + // block breaks inlining this -- if you can fix that please do!) unsafe { - if is_empty!(self) { - None + if T::IS_ZST { + let len = end_or_len.addr(); + if len == 0 { + return None; + } + // SAFETY: just checked that it's not zero, so subtracting one + // cannot wrap. (Ideally this would be `checked_sub`, which + // does the same thing internally, but as of 2025-02 that + // doesn't optimize quite as small in MIR.) + self.end_or_len = without_provenance_mut(len.unchecked_sub(1)); } else { - Some(self.next_unchecked()) + // SAFETY: by type invariant, the `end_or_len` field is always + // non-null for a non-ZST pointee. (This transmute ensures we + // get `!nonnull` metadata on the load of the field.) + if ptr == crate::intrinsics::transmute::<$ptr, NonNull>(end_or_len) { + return None; + } + // SAFETY: since it's not empty, per the check above, moving + // forward one keeps us inside the slice, and this is valid. + self.ptr = ptr.add(1); } + // SAFETY: Now that we know it wasn't empty and we've moved past + // the first one (to avoid giving a duplicate `&mut` next time), + // we can give out a reference to it. + Some({ptr}.$into_ref()) } } diff --git a/core/src/slice/memchr.rs b/core/src/slice/memchr.rs index 339adad1b17bf..1e1053583a617 100644 --- a/core/src/slice/memchr.rs +++ b/core/src/slice/memchr.rs @@ -2,11 +2,10 @@ // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch use crate::intrinsics::const_eval_select; -use crate::mem; const LO_USIZE: usize = usize::repeat_u8(0x01); const HI_USIZE: usize = usize::repeat_u8(0x80); -const USIZE_BYTES: usize = mem::size_of::(); +const USIZE_BYTES: usize = size_of::(); /// Returns `true` if `x` contains any zero byte. /// @@ -16,7 +15,6 @@ const USIZE_BYTES: usize = mem::size_of::(); /// bytes where the borrow propagated all the way to the most significant /// bit." #[inline] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_memchr", since = "1.65.0"))] const fn contains_zero_byte(x: usize) -> bool { x.wrapping_sub(LO_USIZE) & !x & HI_USIZE != 0 } @@ -24,7 +22,6 @@ const fn contains_zero_byte(x: usize) -> bool { /// Returns the first index matching the byte `x` in `text`. #[inline] #[must_use] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_memchr", since = "1.65.0"))] pub const fn memchr(x: u8, text: &[u8]) -> Option { // Fast path for small slices. if text.len() < 2 * USIZE_BYTES { @@ -35,7 +32,6 @@ pub const fn memchr(x: u8, text: &[u8]) -> Option { } #[inline] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_memchr", since = "1.65.0"))] const fn memchr_naive(x: u8, text: &[u8]) -> Option { let mut i = 0; @@ -52,7 +48,6 @@ const fn memchr_naive(x: u8, text: &[u8]) -> Option { } #[rustc_allow_const_fn_unstable(const_eval_select)] // fallback impl has same behavior -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_memchr", since = "1.65.0"))] const fn memchr_aligned(x: u8, text: &[u8]) -> Option { // The runtime version behaves the same as the compiletime version, it's // just more optimized. @@ -142,7 +137,7 @@ pub fn memrchr(x: u8, text: &[u8]) -> Option { // offset is always aligned, so just testing `>` is sufficient and avoids possible // overflow. let repeated_x = usize::repeat_u8(x); - let chunk_bytes = mem::size_of::(); + let chunk_bytes = size_of::(); while offset > min_aligned_offset { // SAFETY: offset starts at len - suffix.len(), as long as it is greater than diff --git a/core/src/slice/mod.rs b/core/src/slice/mod.rs index c855f963771ed..3570d8d087660 100644 --- a/core/src/slice/mod.rs +++ b/core/src/slice/mod.rs @@ -7,13 +7,14 @@ #![stable(feature = "rust1", since = "1.0.0")] use crate::cmp::Ordering::{self, Equal, Greater, Less}; -use crate::intrinsics::{exact_div, select_unpredictable, unchecked_sub}; +use crate::intrinsics::{exact_div, unchecked_sub}; use crate::mem::{self, SizedTypeProperties}; use crate::num::NonZero; -use crate::ops::{Bound, OneSidedRange, Range, RangeBounds}; +use crate::ops::{OneSidedRange, OneSidedRangeBound, Range, RangeBounds, RangeInclusive}; +use crate::panic::const_panic; use crate::simd::{self, Simd}; use crate::ub_checks::assert_unsafe_precondition; -use crate::{fmt, hint, ptr, slice}; +use crate::{fmt, hint, ptr, range, slice}; #[unstable( feature = "slice_internals", @@ -77,19 +78,17 @@ pub use raw::{from_raw_parts, from_raw_parts_mut}; /// Calculates the direction and split point of a one-sided range. /// -/// This is a helper function for `take` and `take_mut` that returns +/// This is a helper function for `split_off` and `split_off_mut` that returns /// the direction of the split (front or back) as well as the index at /// which to split. Returns `None` if the split index would overflow. #[inline] fn split_point_of(range: impl OneSidedRange) -> Option<(Direction, usize)> { - use Bound::*; - - Some(match (range.start_bound(), range.end_bound()) { - (Unbounded, Excluded(i)) => (Direction::Front, *i), - (Unbounded, Included(i)) => (Direction::Front, i.checked_add(1)?), - (Excluded(i), Unbounded) => (Direction::Back, i.checked_add(1)?), - (Included(i), Unbounded) => (Direction::Back, *i), - _ => unreachable!(), + use OneSidedRangeBound::{End, EndInclusive, StartInclusive}; + + Some(match range.bound() { + (StartInclusive, i) => (Direction::Back, i), + (End, i) => (Direction::Front, i), + (EndInclusive, i) => (Direction::Front, i.checked_add(1)?), }) } @@ -735,7 +734,7 @@ impl [T] { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_slice_as_ptr", since = "1.32.0")] #[rustc_never_returns_null_ptr] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[inline(always)] #[must_use] pub const fn as_ptr(&self) -> *const T { @@ -766,7 +765,7 @@ impl [T] { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")] #[rustc_never_returns_null_ptr] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[inline(always)] #[must_use] pub const fn as_mut_ptr(&mut self) -> *mut T { @@ -855,6 +854,42 @@ impl [T] { start..end } + /// Gets a reference to the underlying array. + /// + /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. + #[unstable(feature = "slice_as_array", issue = "133508")] + #[inline] + #[must_use] + pub const fn as_array(&self) -> Option<&[T; N]> { + if self.len() == N { + let ptr = self.as_ptr() as *const [T; N]; + + // SAFETY: The underlying array of a slice can be reinterpreted as an actual array `[T; N]` if `N` is not greater than the slice's length. + let me = unsafe { &*ptr }; + Some(me) + } else { + None + } + } + + /// Gets a mutable reference to the slice's underlying array. + /// + /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. + #[unstable(feature = "slice_as_array", issue = "133508")] + #[inline] + #[must_use] + pub const fn as_mut_array(&mut self) -> Option<&mut [T; N]> { + if self.len() == N { + let ptr = self.as_mut_ptr() as *mut [T; N]; + + // SAFETY: The underlying array of a slice can be reinterpreted as an actual array `[T; N]` if `N` is not greater than the slice's length. + let me = unsafe { &mut *ptr }; + Some(me) + } else { + None + } + } + /// Swaps two elements in the slice. /// /// If `a` equals to `b`, it's guaranteed that elements won't change value. @@ -876,7 +911,7 @@ impl [T] { /// assert!(v == ["a", "b", "e", "d", "c"]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_swap", issue = "83163")] + #[rustc_const_stable(feature = "const_swap", since = "1.85.0")] #[inline] #[track_caller] pub const fn swap(&mut self, a: usize, b: usize) { @@ -921,7 +956,6 @@ impl [T] { /// [`swap`]: slice::swap /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html #[unstable(feature = "slice_swap_unchecked", issue = "88539")] - #[rustc_const_unstable(feature = "const_swap", issue = "83163")] pub const unsafe fn swap_unchecked(&mut self, a: usize, b: usize) { assert_unsafe_precondition!( check_library_ub, @@ -950,8 +984,9 @@ impl [T] { /// assert!(v == [3, 2, 1]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_reverse", issue = "135120")] #[inline] - pub fn reverse(&mut self) { + pub const fn reverse(&mut self) { let half_len = self.len() / 2; let Range { start, end } = self.as_mut_ptr_range(); @@ -974,7 +1009,7 @@ impl [T] { revswap(front_half, back_half, half_len); #[inline] - fn revswap(a: &mut [T], b: &mut [T], n: usize) { + const fn revswap(a: &mut [T], b: &mut [T], n: usize) { debug_assert!(a.len() == n); debug_assert!(b.len() == n); @@ -982,7 +1017,8 @@ impl [T] { // this check tells LLVM that the indexing below is // in-bounds. Then after inlining -- once the actual // lengths of the slices are known -- it's removed. - let (a, b) = (&mut a[..n], &mut b[..n]); + let (a, _) = a.split_at_mut(n); + let (b, _) = b.split_at_mut(n); let mut i = 0; while i < n { @@ -1039,7 +1075,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `size` is 0. + /// Panics if `size` is zero. /// /// # Examples /// @@ -1060,10 +1096,15 @@ impl [T] { /// assert!(iter.next().is_none()); /// ``` /// - /// There's no `windows_mut`, as that existing would let safe code violate the - /// "only one `&mut` at a time to the same thing" rule. However, you can sometimes - /// use [`Cell::as_slice_of_cells`](crate::cell::Cell::as_slice_of_cells) in - /// conjunction with `windows` to accomplish something similar: + /// Because the [Iterator] trait cannot represent the required lifetimes, + /// there is no `windows_mut` analog to `windows`; + /// `[0,1,2].windows_mut(2).collect()` would violate [the rules of references] + /// (though a [LendingIterator] analog is possible). You can sometimes use + /// [`Cell::as_slice_of_cells`](crate::cell::Cell::as_slice_of_cells) in + /// conjunction with `windows` instead: + /// + /// [the rules of references]: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#the-rules-of-references + /// [LendingIterator]: https://blog.rust-lang.org/2022/10/28/gats-stabilization.html /// ``` /// use std::cell::Cell; /// @@ -1095,7 +1136,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `chunk_size` is 0. + /// Panics if `chunk_size` is zero. /// /// # Examples /// @@ -1130,7 +1171,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `chunk_size` is 0. + /// Panics if `chunk_size` is zero. /// /// # Examples /// @@ -1172,7 +1213,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `chunk_size` is 0. + /// Panics if `chunk_size` is zero. /// /// # Examples /// @@ -1211,7 +1252,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `chunk_size` is 0. + /// Panics if `chunk_size` is zero. /// /// # Examples /// @@ -1288,7 +1329,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `N` is 0. This check will most probably get changed to a compile time + /// Panics if `N` is zero. This check will most probably get changed to a compile time /// error before this method gets stabilized. /// /// # Examples @@ -1334,7 +1375,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `N` is 0. This check will most probably get changed to a compile time + /// Panics if `N` is zero. This check will most probably get changed to a compile time /// error before this method gets stabilized. /// /// # Examples @@ -1372,7 +1413,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `N` is 0. This check will most probably get changed to a compile time + /// Panics if `N` is zero. This check will most probably get changed to a compile time /// error before this method gets stabilized. /// /// # Examples @@ -1448,7 +1489,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `N` is 0. This check will most probably get changed to a compile time + /// Panics if `N` is zero. This check will most probably get changed to a compile time /// error before this method gets stabilized. /// /// # Examples @@ -1489,7 +1530,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `N` is 0. This check will most probably get changed to a compile time + /// Panics if `N` is zero. This check will most probably get changed to a compile time /// error before this method gets stabilized. /// /// # Examples @@ -1533,7 +1574,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `N` is 0. This check will most probably get changed to a compile time + /// Panics if `N` is zero. This check will most probably get changed to a compile time /// error before this method gets stabilized. /// /// # Examples @@ -1568,7 +1609,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `N` is 0. This check will most probably get changed to a compile time + /// Panics if `N` is zero. This check will most probably get changed to a compile time /// error before this method gets stabilized. /// /// # Examples @@ -1604,7 +1645,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `chunk_size` is 0. + /// Panics if `chunk_size` is zero. /// /// # Examples /// @@ -1639,7 +1680,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `chunk_size` is 0. + /// Panics if `chunk_size` is zero. /// /// # Examples /// @@ -1682,7 +1723,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `chunk_size` is 0. + /// Panics if `chunk_size` is zero. /// /// # Examples /// @@ -1722,7 +1763,7 @@ impl [T] { /// /// # Panics /// - /// Panics if `chunk_size` is 0. + /// Panics if `chunk_size` is zero. /// /// # Examples /// @@ -1846,23 +1887,23 @@ impl [T] { /// # Examples /// /// ``` - /// let v = [1, 2, 3, 4, 5, 6]; + /// let v = ['a', 'b', 'c']; /// /// { /// let (left, right) = v.split_at(0); /// assert_eq!(left, []); - /// assert_eq!(right, [1, 2, 3, 4, 5, 6]); + /// assert_eq!(right, ['a', 'b', 'c']); /// } /// /// { /// let (left, right) = v.split_at(2); - /// assert_eq!(left, [1, 2]); - /// assert_eq!(right, [3, 4, 5, 6]); + /// assert_eq!(left, ['a', 'b']); + /// assert_eq!(right, ['c']); /// } /// /// { - /// let (left, right) = v.split_at(6); - /// assert_eq!(left, [1, 2, 3, 4, 5, 6]); + /// let (left, right) = v.split_at(3); + /// assert_eq!(left, ['a', 'b', 'c']); /// assert_eq!(right, []); /// } /// ``` @@ -1932,23 +1973,23 @@ impl [T] { /// # Examples /// /// ``` - /// let v = [1, 2, 3, 4, 5, 6]; + /// let v = ['a', 'b', 'c']; /// /// unsafe { /// let (left, right) = v.split_at_unchecked(0); /// assert_eq!(left, []); - /// assert_eq!(right, [1, 2, 3, 4, 5, 6]); + /// assert_eq!(right, ['a', 'b', 'c']); /// } /// /// unsafe { /// let (left, right) = v.split_at_unchecked(2); - /// assert_eq!(left, [1, 2]); - /// assert_eq!(right, [3, 4, 5, 6]); + /// assert_eq!(left, ['a', 'b']); + /// assert_eq!(right, ['c']); /// } /// /// unsafe { - /// let (left, right) = v.split_at_unchecked(6); - /// assert_eq!(left, [1, 2, 3, 4, 5, 6]); + /// let (left, right) = v.split_at_unchecked(3); + /// assert_eq!(left, ['a', 'b', 'c']); /// assert_eq!(right, []); /// } /// ``` @@ -2798,7 +2839,7 @@ impl [T] { // Binary search interacts poorly with branch prediction, so force // the compiler to use conditional moves if supported by the target // architecture. - base = select_unpredictable(cmp == Greater, base, mid); + base = (cmp == Greater).select_unpredictable(base, mid); // This is imprecise in the case where `size` is odd and the // comparison returns Greater: the mid element still gets included @@ -2886,10 +2927,17 @@ impl [T] { /// This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not /// allocate), and *O*(*n* \* log(*n*)) worst-case. /// - /// If the implementation of [`Ord`] for `T` does not implement a [total order] the resulting - /// order of elements in the slice is unspecified. All original elements will remain in the - /// slice and any possible modifications via interior mutability are observed in the input. Same - /// is true if the implementation of [`Ord`] for `T` panics. + /// If the implementation of [`Ord`] for `T` does not implement a [total order], the function + /// may panic; even if the function exits normally, the resulting order of elements in the slice + /// is unspecified. See also the note on panicking below. + /// + /// For example `|a, b| (a - b).cmp(a)` is a comparison function that is neither transitive nor + /// reflexive nor total, `a < b < c < a` with `a = 1, b = 2, c = 3`. For more information and + /// examples see the [`Ord`] documentation. + /// + /// + /// All original elements will remain in the slice and any possible modifications via interior + /// mutability are observed in the input. Same is true if the implementation of [`Ord`] for `T` panics. /// /// Sorting types that only implement [`PartialOrd`] such as [`f32`] and [`f64`] require /// additional precautions. For example, `f32::NAN != f32::NAN`, which doesn't fulfill the @@ -2912,7 +2960,8 @@ impl [T] { /// /// # Panics /// - /// May panic if the implementation of [`Ord`] for `T` does not implement a [total order]. + /// May panic if the implementation of [`Ord`] for `T` does not implement a [total order], or if + /// the [`Ord`] implementation panics. /// /// # Examples /// @@ -2940,15 +2989,17 @@ impl [T] { /// This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not /// allocate), and *O*(*n* \* log(*n*)) worst-case. /// - /// If the comparison function `compare` does not implement a [total order] the resulting order - /// of elements in the slice is unspecified. All original elements will remain in the slice and - /// any possible modifications via interior mutability are observed in the input. Same is true - /// if `compare` panics. + /// If the comparison function `compare` does not implement a [total order], the function + /// may panic; even if the function exits normally, the resulting order of elements in the slice + /// is unspecified. See also the note on panicking below. /// /// For example `|a, b| (a - b).cmp(a)` is a comparison function that is neither transitive nor /// reflexive nor total, `a < b < c < a` with `a = 1, b = 2, c = 3`. For more information and /// examples see the [`Ord`] documentation. /// + /// All original elements will remain in the slice and any possible modifications via interior + /// mutability are observed in the input. Same is true if `compare` panics. + /// /// # Current implementation /// /// The current implementation is based on [ipnsort] by Lukas Bergdoll and Orson Peters, which @@ -2961,7 +3012,8 @@ impl [T] { /// /// # Panics /// - /// May panic if `compare` does not implement a [total order]. + /// May panic if the `compare` does not implement a [total order], or if + /// the `compare` itself panics. /// /// # Examples /// @@ -2992,10 +3044,16 @@ impl [T] { /// This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not /// allocate), and *O*(*n* \* log(*n*)) worst-case. /// - /// If the implementation of [`Ord`] for `K` does not implement a [total order] the resulting - /// order of elements in the slice is unspecified. All original elements will remain in the - /// slice and any possible modifications via interior mutability are observed in the input. Same - /// is true if the implementation of [`Ord`] for `K` panics. + /// If the implementation of [`Ord`] for `K` does not implement a [total order], the function + /// may panic; even if the function exits normally, the resulting order of elements in the slice + /// is unspecified. See also the note on panicking below. + /// + /// For example `|a, b| (a - b).cmp(a)` is a comparison function that is neither transitive nor + /// reflexive nor total, `a < b < c < a` with `a = 1, b = 2, c = 3`. For more information and + /// examples see the [`Ord`] documentation. + /// + /// All original elements will remain in the slice and any possible modifications via interior + /// mutability are observed in the input. Same is true if the implementation of [`Ord`] for `K` panics. /// /// # Current implementation /// @@ -3009,7 +3067,8 @@ impl [T] { /// /// # Panics /// - /// May panic if the implementation of [`Ord`] for `K` does not implement a [total order]. + /// May panic if the implementation of [`Ord`] for `K` does not implement a [total order], or if + /// the [`Ord`] implementation panics. /// /// # Examples /// @@ -3032,19 +3091,21 @@ impl [T] { sort::unstable::sort(self, &mut |a, b| f(a).lt(&f(b))); } - /// Reorders the slice such that the element at `index` after the reordering is at its final - /// sorted position. + /// Reorders the slice such that the element at `index` is at a sort-order position. All + /// elements before `index` will be `<=` to this value, and all elements after will be `>=` to + /// it. + /// + /// This reordering is unstable (i.e. any element that compares equal to the nth element may end + /// up at that position), in-place (i.e. does not allocate), and runs in *O*(*n*) time. This + /// function is also known as "kth element" in other libraries. /// - /// This reordering has the additional property that any value at position `i < index` will be - /// less than or equal to any value at a position `j > index`. Additionally, this reordering is - /// unstable (i.e. any number of equal elements may end up at position `index`), in-place (i.e. - /// does not allocate), and runs in *O*(*n*) time. This function is also known as "kth element" - /// in other libraries. + /// Returns a triple that partitions the reordered slice: /// - /// It returns a triplet of the following from the reordered slice: the subslice prior to - /// `index`, the element at `index`, and the subslice after `index`; accordingly, the values in - /// those two subslices will respectively all be less-than-or-equal-to and - /// greater-than-or-equal-to the value of the element at `index`. + /// * The unsorted subslice before `index`, whose elements all satisfy `x <= self[index]`. + /// + /// * The element at `index`. + /// + /// * The unsorted subslice after `index`, whose elements all satisfy `x >= self[index]`. /// /// # Current implementation /// @@ -3057,7 +3118,7 @@ impl [T] { /// /// # Panics /// - /// Panics when `index >= len()`, meaning it always panics on empty slices. + /// Panics when `index >= len()`, and so always panics on empty slices. /// /// May panic if the implementation of [`Ord`] for `T` does not implement a [total order]. /// @@ -3066,8 +3127,7 @@ impl [T] { /// ``` /// let mut v = [-5i32, 4, 2, -3, 1]; /// - /// // Find the items less than or equal to the median, the median, and greater than or equal to - /// // the median. + /// // Find the items `<=` to the median, the median itself, and the items `>=` to it. /// let (lesser, median, greater) = v.select_nth_unstable(2); /// /// assert!(lesser == [-3, -5] || lesser == [-5, -3]); @@ -3093,19 +3153,23 @@ impl [T] { sort::select::partition_at_index(self, index, T::lt) } - /// Reorders the slice with a comparator function such that the element at `index` after the - /// reordering is at its final sorted position. + /// Reorders the slice with a comparator function such that the element at `index` is at a + /// sort-order position. All elements before `index` will be `<=` to this value, and all + /// elements after will be `>=` to it, according to the comparator function. /// - /// This reordering has the additional property that any value at position `i < index` will be - /// less than or equal to any value at a position `j > index` using the comparator function. - /// Additionally, this reordering is unstable (i.e. any number of equal elements may end up at - /// position `index`), in-place (i.e. does not allocate), and runs in *O*(*n*) time. This + /// This reordering is unstable (i.e. any element that compares equal to the nth element may end + /// up at that position), in-place (i.e. does not allocate), and runs in *O*(*n*) time. This /// function is also known as "kth element" in other libraries. /// - /// It returns a triplet of the following from the slice reordered according to the provided - /// comparator function: the subslice prior to `index`, the element at `index`, and the subslice - /// after `index`; accordingly, the values in those two subslices will respectively all be - /// less-than-or-equal-to and greater-than-or-equal-to the value of the element at `index`. + /// Returns a triple partitioning the reordered slice: + /// + /// * The unsorted subslice before `index`, whose elements all satisfy + /// `compare(x, self[index]).is_le()`. + /// + /// * The element at `index`. + /// + /// * The unsorted subslice after `index`, whose elements all satisfy + /// `compare(x, self[index]).is_ge()`. /// /// # Current implementation /// @@ -3118,7 +3182,7 @@ impl [T] { /// /// # Panics /// - /// Panics when `index >= len()`, meaning it always panics on empty slices. + /// Panics when `index >= len()`, and so always panics on empty slices. /// /// May panic if `compare` does not implement a [total order]. /// @@ -3127,13 +3191,13 @@ impl [T] { /// ``` /// let mut v = [-5i32, 4, 2, -3, 1]; /// - /// // Find the items less than or equal to the median, the median, and greater than or equal to - /// // the median as if the slice were sorted in descending order. - /// let (lesser, median, greater) = v.select_nth_unstable_by(2, |a, b| b.cmp(a)); + /// // Find the items `>=` to the median, the median itself, and the items `<=` to it, by using + /// // a reversed comparator. + /// let (before, median, after) = v.select_nth_unstable_by(2, |a, b| b.cmp(a)); /// - /// assert!(lesser == [4, 2] || lesser == [2, 4]); + /// assert!(before == [4, 2] || before == [2, 4]); /// assert_eq!(median, &mut 1); - /// assert!(greater == [-3, -5] || greater == [-5, -3]); + /// assert!(after == [-3, -5] || after == [-5, -3]); /// /// // We are only guaranteed the slice will be one of the following, based on the way we sort /// // about the specified index. @@ -3158,19 +3222,21 @@ impl [T] { sort::select::partition_at_index(self, index, |a: &T, b: &T| compare(a, b) == Less) } - /// Reorders the slice with a key extraction function such that the element at `index` after the - /// reordering is at its final sorted position. + /// Reorders the slice with a key extraction function such that the element at `index` is at a + /// sort-order position. All elements before `index` will have keys `<=` to the key at `index`, + /// and all elements after will have keys `>=` to it. /// - /// This reordering has the additional property that any value at position `i < index` will be - /// less than or equal to any value at a position `j > index` using the key extraction function. - /// Additionally, this reordering is unstable (i.e. any number of equal elements may end up at - /// position `index`), in-place (i.e. does not allocate), and runs in *O*(*n*) time. This + /// This reordering is unstable (i.e. any element that compares equal to the nth element may end + /// up at that position), in-place (i.e. does not allocate), and runs in *O*(*n*) time. This /// function is also known as "kth element" in other libraries. /// - /// It returns a triplet of the following from the slice reordered according to the provided key - /// extraction function: the subslice prior to `index`, the element at `index`, and the subslice - /// after `index`; accordingly, the values in those two subslices will respectively all be - /// less-than-or-equal-to and greater-than-or-equal-to the value of the element at `index`. + /// Returns a triple partitioning the reordered slice: + /// + /// * The unsorted subslice before `index`, whose elements all satisfy `f(x) <= f(self[index])`. + /// + /// * The element at `index`. + /// + /// * The unsorted subslice after `index`, whose elements all satisfy `f(x) >= f(self[index])`. /// /// # Current implementation /// @@ -3192,8 +3258,8 @@ impl [T] { /// ``` /// let mut v = [-5i32, 4, 1, -3, 2]; /// - /// // Find the items less than or equal to the median, the median, and greater than or equal to - /// // the median as if the slice were sorted according to absolute value. + /// // Find the items `<=` to the absolute median, the absolute median itself, and the items + /// // `>=` to it. /// let (lesser, median, greater) = v.select_nth_unstable_by_key(2, |a| a.abs()); /// /// assert!(lesser == [1, 2] || lesser == [2, 1]); @@ -3664,9 +3730,11 @@ impl [T] { /// [`clone_from_slice`]: slice::clone_from_slice /// [`split_at_mut`]: slice::split_at_mut #[doc(alias = "memcpy")] + #[inline] #[stable(feature = "copy_from_slice", since = "1.9.0")] + #[rustc_const_stable(feature = "const_copy_from_slice", since = "CURRENT_RUSTC_VERSION")] #[track_caller] - pub fn copy_from_slice(&mut self, src: &[T]) + pub const fn copy_from_slice(&mut self, src: &[T]) where T: Copy, { @@ -3675,11 +3743,13 @@ impl [T] { #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[track_caller] - fn len_mismatch_fail(dst_len: usize, src_len: usize) -> ! { - panic!( - "source slice length ({}) does not match destination slice length ({})", - src_len, dst_len, - ); + const fn len_mismatch_fail(dst_len: usize, src_len: usize) -> ! { + const_panic!( + "copy_from_slice: source slice length does not match destination slice length", + "copy_from_slice: source slice length ({src_len}) does not match destination slice length ({dst_len})", + src_len: usize, + dst_len: usize, + ) } if self.len() != src.len() { @@ -3823,9 +3893,9 @@ impl [T] { // Explicitly wrap the function call in a const block so it gets // constant-evaluated even in debug mode. - let gcd: usize = const { gcd(mem::size_of::(), mem::size_of::()) }; - let ts: usize = mem::size_of::() / gcd; - let us: usize = mem::size_of::() / gcd; + let gcd: usize = const { gcd(size_of::(), size_of::()) }; + let ts: usize = size_of::() / gcd; + let us: usize = size_of::() / gcd; // Armed with this knowledge, we can find how many `U`s we can fit! let us_len = self.len() / ts * us; @@ -3875,7 +3945,7 @@ impl [T] { // ptr.align_offset. let ptr = self.as_ptr(); // SAFETY: See the `align_to_mut` method for the detailed safety comment. - let offset = unsafe { crate::ptr::align_offset(ptr, mem::align_of::()) }; + let offset = unsafe { crate::ptr::align_offset(ptr, align_of::()) }; if offset > self.len() { (self, &[], &[]) } else { @@ -3885,7 +3955,7 @@ impl [T] { #[cfg(miri)] crate::intrinsics::miri_promise_symbolic_alignment( rest.as_ptr().cast(), - mem::align_of::(), + align_of::(), ); // SAFETY: now `rest` is definitely aligned, so `from_raw_parts` below is okay, // since the caller guarantees that we can transmute `T` to `U` safely. @@ -3946,7 +4016,7 @@ impl [T] { // valid pointer `ptr` (it comes from a reference to `self`) and with // a size that is a power of two (since it comes from the alignment for U), // satisfying its safety constraints. - let offset = unsafe { crate::ptr::align_offset(ptr, mem::align_of::()) }; + let offset = unsafe { crate::ptr::align_offset(ptr, align_of::()) }; if offset > self.len() { (self, &mut [], &mut []) } else { @@ -3958,7 +4028,7 @@ impl [T] { #[cfg(miri)] crate::intrinsics::miri_promise_symbolic_alignment( mut_ptr.cast() as *const (), - mem::align_of::(), + align_of::(), ); // We can't use `rest` again after this, that would invalidate its alias `mut_ptr`! // SAFETY: see comments for `align_to`. @@ -4029,7 +4099,7 @@ impl [T] { // These are expected to always match, as vector types are laid out like // arrays per , but we // might as well double-check since it'll optimize away anyhow. - assert_eq!(mem::size_of::>(), mem::size_of::<[T; LANES]>()); + assert_eq!(size_of::>(), size_of::<[T; LANES]>()); // SAFETY: The simd types have the same layout as arrays, just with // potentially-higher alignment, so the de-facto transmutes are sound. @@ -4065,7 +4135,7 @@ impl [T] { // These are expected to always match, as vector types are laid out like // arrays per , but we // might as well double-check since it'll optimize away anyhow. - assert_eq!(mem::size_of::>(), mem::size_of::<[T; LANES]>()); + assert_eq!(size_of::>(), size_of::<[T; LANES]>()); // SAFETY: The simd types have the same layout as arrays, just with // potentially-higher alignment, so the de-facto transmutes are sound. @@ -4239,25 +4309,21 @@ impl [T] { /// /// # Examples /// - /// Taking the first three elements of a slice: + /// Splitting off the first three elements of a slice: /// /// ``` - /// #![feature(slice_take)] - /// /// let mut slice: &[_] = &['a', 'b', 'c', 'd']; - /// let mut first_three = slice.take(..3).unwrap(); + /// let mut first_three = slice.split_off(..3).unwrap(); /// /// assert_eq!(slice, &['d']); /// assert_eq!(first_three, &['a', 'b', 'c']); /// ``` /// - /// Taking the last two elements of a slice: + /// Splitting off the last two elements of a slice: /// /// ``` - /// #![feature(slice_take)] - /// /// let mut slice: &[_] = &['a', 'b', 'c', 'd']; - /// let mut tail = slice.take(2..).unwrap(); + /// let mut tail = slice.split_off(2..).unwrap(); /// /// assert_eq!(slice, &['a', 'b']); /// assert_eq!(tail, &['c', 'd']); @@ -4266,20 +4332,21 @@ impl [T] { /// Getting `None` when `range` is out of bounds: /// /// ``` - /// #![feature(slice_take)] - /// /// let mut slice: &[_] = &['a', 'b', 'c', 'd']; /// - /// assert_eq!(None, slice.take(5..)); - /// assert_eq!(None, slice.take(..5)); - /// assert_eq!(None, slice.take(..=4)); + /// assert_eq!(None, slice.split_off(5..)); + /// assert_eq!(None, slice.split_off(..5)); + /// assert_eq!(None, slice.split_off(..=4)); /// let expected: &[char] = &['a', 'b', 'c', 'd']; - /// assert_eq!(Some(expected), slice.take(..4)); + /// assert_eq!(Some(expected), slice.split_off(..4)); /// ``` #[inline] #[must_use = "method does not modify the slice if the range is out of bounds"] - #[unstable(feature = "slice_take", issue = "62280")] - pub fn take<'a, R: OneSidedRange>(self: &mut &'a Self, range: R) -> Option<&'a Self> { + #[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")] + pub fn split_off<'a, R: OneSidedRange>( + self: &mut &'a Self, + range: R, + ) -> Option<&'a Self> { let (direction, split_index) = split_point_of(range)?; if split_index > self.len() { return None; @@ -4308,13 +4375,11 @@ impl [T] { /// /// # Examples /// - /// Taking the first three elements of a slice: + /// Splitting off the first three elements of a slice: /// /// ``` - /// #![feature(slice_take)] - /// /// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd']; - /// let mut first_three = slice.take_mut(..3).unwrap(); + /// let mut first_three = slice.split_off_mut(..3).unwrap(); /// /// assert_eq!(slice, &mut ['d']); /// assert_eq!(first_three, &mut ['a', 'b', 'c']); @@ -4323,10 +4388,8 @@ impl [T] { /// Taking the last two elements of a slice: /// /// ``` - /// #![feature(slice_take)] - /// /// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd']; - /// let mut tail = slice.take_mut(2..).unwrap(); + /// let mut tail = slice.split_off_mut(2..).unwrap(); /// /// assert_eq!(slice, &mut ['a', 'b']); /// assert_eq!(tail, &mut ['c', 'd']); @@ -4335,20 +4398,18 @@ impl [T] { /// Getting `None` when `range` is out of bounds: /// /// ``` - /// #![feature(slice_take)] - /// /// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd']; /// - /// assert_eq!(None, slice.take_mut(5..)); - /// assert_eq!(None, slice.take_mut(..5)); - /// assert_eq!(None, slice.take_mut(..=4)); + /// assert_eq!(None, slice.split_off_mut(5..)); + /// assert_eq!(None, slice.split_off_mut(..5)); + /// assert_eq!(None, slice.split_off_mut(..=4)); /// let expected: &mut [_] = &mut ['a', 'b', 'c', 'd']; - /// assert_eq!(Some(expected), slice.take_mut(..4)); + /// assert_eq!(Some(expected), slice.split_off_mut(..4)); /// ``` #[inline] #[must_use = "method does not modify the slice if the range is out of bounds"] - #[unstable(feature = "slice_take", issue = "62280")] - pub fn take_mut<'a, R: OneSidedRange>( + #[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")] + pub fn split_off_mut<'a, R: OneSidedRange>( self: &mut &'a mut Self, range: R, ) -> Option<&'a mut Self> { @@ -4377,17 +4438,15 @@ impl [T] { /// # Examples /// /// ``` - /// #![feature(slice_take)] - /// /// let mut slice: &[_] = &['a', 'b', 'c']; - /// let first = slice.take_first().unwrap(); + /// let first = slice.split_off_first().unwrap(); /// /// assert_eq!(slice, &['b', 'c']); /// assert_eq!(first, &'a'); /// ``` #[inline] - #[unstable(feature = "slice_take", issue = "62280")] - pub fn take_first<'a>(self: &mut &'a Self) -> Option<&'a T> { + #[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")] + pub fn split_off_first<'a>(self: &mut &'a Self) -> Option<&'a T> { let (first, rem) = self.split_first()?; *self = rem; Some(first) @@ -4401,18 +4460,16 @@ impl [T] { /// # Examples /// /// ``` - /// #![feature(slice_take)] - /// /// let mut slice: &mut [_] = &mut ['a', 'b', 'c']; - /// let first = slice.take_first_mut().unwrap(); + /// let first = slice.split_off_first_mut().unwrap(); /// *first = 'd'; /// /// assert_eq!(slice, &['b', 'c']); /// assert_eq!(first, &'d'); /// ``` #[inline] - #[unstable(feature = "slice_take", issue = "62280")] - pub fn take_first_mut<'a>(self: &mut &'a mut Self) -> Option<&'a mut T> { + #[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")] + pub fn split_off_first_mut<'a>(self: &mut &'a mut Self) -> Option<&'a mut T> { let (first, rem) = mem::take(self).split_first_mut()?; *self = rem; Some(first) @@ -4426,17 +4483,15 @@ impl [T] { /// # Examples /// /// ``` - /// #![feature(slice_take)] - /// /// let mut slice: &[_] = &['a', 'b', 'c']; - /// let last = slice.take_last().unwrap(); + /// let last = slice.split_off_last().unwrap(); /// /// assert_eq!(slice, &['a', 'b']); /// assert_eq!(last, &'c'); /// ``` #[inline] - #[unstable(feature = "slice_take", issue = "62280")] - pub fn take_last<'a>(self: &mut &'a Self) -> Option<&'a T> { + #[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")] + pub fn split_off_last<'a>(self: &mut &'a Self) -> Option<&'a T> { let (last, rem) = self.split_last()?; *self = rem; Some(last) @@ -4450,18 +4505,16 @@ impl [T] { /// # Examples /// /// ``` - /// #![feature(slice_take)] - /// /// let mut slice: &mut [_] = &mut ['a', 'b', 'c']; - /// let last = slice.take_last_mut().unwrap(); + /// let last = slice.split_off_last_mut().unwrap(); /// *last = 'd'; /// /// assert_eq!(slice, &['a', 'b']); /// assert_eq!(last, &'d'); /// ``` #[inline] - #[unstable(feature = "slice_take", issue = "62280")] - pub fn take_last_mut<'a>(self: &mut &'a mut Self) -> Option<&'a mut T> { + #[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")] + pub fn split_off_last_mut<'a>(self: &mut &'a mut Self) -> Option<&'a mut T> { let (last, rem) = mem::take(self).split_last_mut()?; *self = rem; Some(last) @@ -4469,7 +4522,13 @@ impl [T] { /// Returns mutable references to many indices at once, without doing any checks. /// - /// For a safe alternative see [`get_many_mut`]. + /// An index can be either a `usize`, a [`Range`] or a [`RangeInclusive`]. Note + /// that this method takes an array, so all indices must be of the same type. + /// If passed an array of `usize`s this method gives back an array of mutable references + /// to single elements, while if passed an array of ranges it gives back an array of + /// mutable references to slices. + /// + /// For a safe alternative see [`get_disjoint_mut`]. /// /// # Safety /// @@ -4479,40 +4538,57 @@ impl [T] { /// # Examples /// /// ``` - /// #![feature(get_many_mut)] - /// /// let x = &mut [1, 2, 4]; /// /// unsafe { - /// let [a, b] = x.get_many_unchecked_mut([0, 2]); + /// let [a, b] = x.get_disjoint_unchecked_mut([0, 2]); /// *a *= 10; /// *b *= 100; /// } /// assert_eq!(x, &[10, 2, 400]); + /// + /// unsafe { + /// let [a, b] = x.get_disjoint_unchecked_mut([0..1, 1..3]); + /// a[0] = 8; + /// b[0] = 88; + /// b[1] = 888; + /// } + /// assert_eq!(x, &[8, 88, 888]); + /// + /// unsafe { + /// let [a, b] = x.get_disjoint_unchecked_mut([1..=2, 0..=0]); + /// a[0] = 11; + /// a[1] = 111; + /// b[0] = 1; + /// } + /// assert_eq!(x, &[1, 11, 111]); /// ``` /// - /// [`get_many_mut`]: slice::get_many_mut + /// [`get_disjoint_mut`]: slice::get_disjoint_mut /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html - #[unstable(feature = "get_many_mut", issue = "104642")] + #[stable(feature = "get_many_mut", since = "1.86.0")] #[inline] - pub unsafe fn get_many_unchecked_mut( + pub unsafe fn get_disjoint_unchecked_mut( &mut self, - indices: [usize; N], - ) -> [&mut T; N] { + indices: [I; N], + ) -> [&mut I::Output; N] + where + I: GetDisjointMutIndex + SliceIndex, + { // NB: This implementation is written as it is because any variation of // `indices.map(|i| self.get_unchecked_mut(i))` would make miri unhappy, // or generate worse code otherwise. This is also why we need to go // through a raw pointer here. let slice: *mut [T] = self; - let mut arr: mem::MaybeUninit<[&mut T; N]> = mem::MaybeUninit::uninit(); + let mut arr: mem::MaybeUninit<[&mut I::Output; N]> = mem::MaybeUninit::uninit(); let arr_ptr = arr.as_mut_ptr(); // SAFETY: We expect `indices` to contain disjunct values that are // in bounds of `self`. unsafe { for i in 0..N { - let idx = *indices.get_unchecked(i); - *(*arr_ptr).get_unchecked_mut(i) = &mut *slice.get_unchecked_mut(idx); + let idx = indices.get_unchecked(i).clone(); + arr_ptr.cast::<&mut I::Output>().add(i).write(&mut *slice.get_unchecked_mut(idx)); } arr.assume_init() } @@ -4520,38 +4596,61 @@ impl [T] { /// Returns mutable references to many indices at once. /// - /// Returns an error if any index is out-of-bounds, or if the same index was - /// passed more than once. + /// An index can be either a `usize`, a [`Range`] or a [`RangeInclusive`]. Note + /// that this method takes an array, so all indices must be of the same type. + /// If passed an array of `usize`s this method gives back an array of mutable references + /// to single elements, while if passed an array of ranges it gives back an array of + /// mutable references to slices. + /// + /// Returns an error if any index is out-of-bounds, or if there are overlapping indices. + /// An empty range is not considered to overlap if it is located at the beginning or at + /// the end of another range, but is considered to overlap if it is located in the middle. + /// + /// This method does a O(n^2) check to check that there are no overlapping indices, so be careful + /// when passing many indices. /// /// # Examples /// /// ``` - /// #![feature(get_many_mut)] - /// /// let v = &mut [1, 2, 3]; - /// if let Ok([a, b]) = v.get_many_mut([0, 2]) { + /// if let Ok([a, b]) = v.get_disjoint_mut([0, 2]) { /// *a = 413; /// *b = 612; /// } /// assert_eq!(v, &[413, 2, 612]); + /// + /// if let Ok([a, b]) = v.get_disjoint_mut([0..1, 1..3]) { + /// a[0] = 8; + /// b[0] = 88; + /// b[1] = 888; + /// } + /// assert_eq!(v, &[8, 88, 888]); + /// + /// if let Ok([a, b]) = v.get_disjoint_mut([1..=2, 0..=0]) { + /// a[0] = 11; + /// a[1] = 111; + /// b[0] = 1; + /// } + /// assert_eq!(v, &[1, 11, 111]); /// ``` - #[unstable(feature = "get_many_mut", issue = "104642")] + #[stable(feature = "get_many_mut", since = "1.86.0")] #[inline] - pub fn get_many_mut( + pub fn get_disjoint_mut( &mut self, - indices: [usize; N], - ) -> Result<[&mut T; N], GetManyMutError> { - if !get_many_check_valid(&indices, self.len()) { - return Err(GetManyMutError { _private: () }); - } - // SAFETY: The `get_many_check_valid()` call checked that all indices + indices: [I; N], + ) -> Result<[&mut I::Output; N], GetDisjointMutError> + where + I: GetDisjointMutIndex + SliceIndex, + { + get_disjoint_check_valid(&indices, self.len())?; + // SAFETY: The `get_disjoint_check_valid()` call checked that all indices // are disjunct and in bounds. - unsafe { Ok(self.get_many_unchecked_mut(indices)) } + unsafe { Ok(self.get_disjoint_unchecked_mut(indices)) } } /// Returns the index that an element reference points to. /// - /// Returns `None` if `element` does not point within the slice or if it points between elements. + /// Returns `None` if `element` does not point to the start of an element within the slice. /// /// This method is useful for extending slice iterators like [`slice::split`]. /// @@ -4571,9 +4670,9 @@ impl [T] { /// let num = &nums[2]; /// /// assert_eq!(num, &1); - /// assert_eq!(nums.elem_offset(num), Some(2)); + /// assert_eq!(nums.element_offset(num), Some(2)); /// ``` - /// Returning `None` with an in-between element: + /// Returning `None` with an unaligned element: /// ``` /// #![feature(substr_range)] /// @@ -4586,12 +4685,12 @@ impl [T] { /// assert_eq!(ok_elm, &[0, 1]); /// assert_eq!(weird_elm, &[1, 2]); /// - /// assert_eq!(arr.elem_offset(ok_elm), Some(0)); // Points to element 0 - /// assert_eq!(arr.elem_offset(weird_elm), None); // Points between element 0 and 1 + /// assert_eq!(arr.element_offset(ok_elm), Some(0)); // Points to element 0 + /// assert_eq!(arr.element_offset(weird_elm), None); // Points between element 0 and 1 /// ``` #[must_use] #[unstable(feature = "substr_range", issue = "126769")] - pub fn elem_offset(&self, element: &T) -> Option { + pub fn element_offset(&self, element: &T) -> Option { if T::IS_ZST { panic!("elements are zero-sized"); } @@ -4601,18 +4700,19 @@ impl [T] { let byte_offset = elem_start.wrapping_sub(self_start); - if byte_offset % mem::size_of::() != 0 { + if byte_offset % size_of::() != 0 { return None; } - let offset = byte_offset / mem::size_of::(); + let offset = byte_offset / size_of::(); if offset < self.len() { Some(offset) } else { None } } /// Returns the range of indices that a subslice points to. /// - /// Returns `None` if `subslice` does not point within the slice or if it points between elements. + /// Returns `None` if `subslice` does not point within the slice or if it is not aligned with the + /// elements in the slice. /// /// This method **does not compare elements**. Instead, this method finds the location in the slice that /// `subslice` was obtained from. To find the index of a subslice via comparison, instead use @@ -4654,11 +4754,11 @@ impl [T] { let byte_start = subslice_start.wrapping_sub(self_start); - if byte_start % core::mem::size_of::() != 0 { + if byte_start % size_of::() != 0 { return None; } - let start = byte_start / core::mem::size_of::(); + let start = byte_start / size_of::(); let end = start.wrapping_add(subslice.len()); if start <= self.len() && end <= self.len() { Some(start..end) } else { None } @@ -4693,7 +4793,7 @@ impl [[T; N]] { /// assert!(empty_slice_of_arrays.as_flattened().is_empty()); /// ``` #[stable(feature = "slice_flatten", since = "1.80.0")] - #[rustc_const_unstable(feature = "const_slice_flatten", issue = "95629")] + #[rustc_const_stable(feature = "const_slice_flatten", since = "CURRENT_RUSTC_VERSION")] pub const fn as_flattened(&self) -> &[T] { let len = if T::IS_ZST { self.len().checked_mul(N).expect("slice len overflow") @@ -4730,7 +4830,8 @@ impl [[T; N]] { /// assert_eq!(array, [[6, 7, 8], [9, 10, 11], [12, 13, 14]]); /// ``` #[stable(feature = "slice_flatten", since = "1.80.0")] - pub fn as_flattened_mut(&mut self) -> &mut [T] { + #[rustc_const_stable(feature = "const_slice_flatten", since = "CURRENT_RUSTC_VERSION")] + pub const fn as_flattened_mut(&mut self) -> &mut [T] { let len = if T::IS_ZST { self.len().checked_mul(N).expect("slice len overflow") } else { @@ -4885,51 +4986,168 @@ impl SlicePattern for [T; N] { /// /// This will do `binomial(N + 1, 2) = N * (N + 1) / 2 = 0, 1, 3, 6, 10, ..` /// comparison operations. -fn get_many_check_valid(indices: &[usize; N], len: usize) -> bool { +#[inline] +fn get_disjoint_check_valid( + indices: &[I; N], + len: usize, +) -> Result<(), GetDisjointMutError> { // NB: The optimizer should inline the loops into a sequence // of instructions without additional branching. - let mut valid = true; - for (i, &idx) in indices.iter().enumerate() { - valid &= idx < len; - for &idx2 in &indices[..i] { - valid &= idx != idx2; + for (i, idx) in indices.iter().enumerate() { + if !idx.is_in_bounds(len) { + return Err(GetDisjointMutError::IndexOutOfBounds); + } + for idx2 in &indices[..i] { + if idx.is_overlapping(idx2) { + return Err(GetDisjointMutError::OverlappingIndices); + } } } - valid + Ok(()) } -/// The error type returned by [`get_many_mut`][`slice::get_many_mut`]. +/// The error type returned by [`get_disjoint_mut`][`slice::get_disjoint_mut`]. /// /// It indicates one of two possible errors: /// - An index is out-of-bounds. -/// - The same index appeared multiple times in the array. +/// - The same index appeared multiple times in the array +/// (or different but overlapping indices when ranges are provided). /// /// # Examples /// /// ``` -/// #![feature(get_many_mut)] +/// use std::slice::GetDisjointMutError; /// /// let v = &mut [1, 2, 3]; -/// assert!(v.get_many_mut([0, 999]).is_err()); -/// assert!(v.get_many_mut([1, 1]).is_err()); +/// assert_eq!(v.get_disjoint_mut([0, 999]), Err(GetDisjointMutError::IndexOutOfBounds)); +/// assert_eq!(v.get_disjoint_mut([1, 1]), Err(GetDisjointMutError::OverlappingIndices)); /// ``` -#[unstable(feature = "get_many_mut", issue = "104642")] -// NB: The N here is there to be forward-compatible with adding more details -// to the error type at a later point -pub struct GetManyMutError { - _private: (), +#[stable(feature = "get_many_mut", since = "1.86.0")] +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum GetDisjointMutError { + /// An index provided was out-of-bounds for the slice. + IndexOutOfBounds, + /// Two indices provided were overlapping. + OverlappingIndices, } -#[unstable(feature = "get_many_mut", issue = "104642")] -impl fmt::Debug for GetManyMutError { +#[stable(feature = "get_many_mut", since = "1.86.0")] +impl fmt::Display for GetDisjointMutError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("GetManyMutError").finish_non_exhaustive() + let msg = match self { + GetDisjointMutError::IndexOutOfBounds => "an index is out of bounds", + GetDisjointMutError::OverlappingIndices => "there were overlapping indices", + }; + fmt::Display::fmt(msg, f) } } -#[unstable(feature = "get_many_mut", issue = "104642")] -impl fmt::Display for GetManyMutError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt("an index is out of bounds or appeared multiple times in the array", f) +mod private_get_disjoint_mut_index { + use super::{Range, RangeInclusive, range}; + + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] + pub trait Sealed {} + + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] + impl Sealed for usize {} + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] + impl Sealed for Range {} + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] + impl Sealed for RangeInclusive {} + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] + impl Sealed for range::Range {} + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] + impl Sealed for range::RangeInclusive {} +} + +/// A helper trait for `<[T]>::get_disjoint_mut()`. +/// +/// # Safety +/// +/// If `is_in_bounds()` returns `true` and `is_overlapping()` returns `false`, +/// it must be safe to index the slice with the indices. +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] +pub unsafe trait GetDisjointMutIndex: + Clone + private_get_disjoint_mut_index::Sealed +{ + /// Returns `true` if `self` is in bounds for `len` slice elements. + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] + fn is_in_bounds(&self, len: usize) -> bool; + + /// Returns `true` if `self` overlaps with `other`. + /// + /// Note that we don't consider zero-length ranges to overlap at the beginning or the end, + /// but do consider them to overlap in the middle. + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] + fn is_overlapping(&self, other: &Self) -> bool; +} + +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] +// SAFETY: We implement `is_in_bounds()` and `is_overlapping()` correctly. +unsafe impl GetDisjointMutIndex for usize { + #[inline] + fn is_in_bounds(&self, len: usize) -> bool { + *self < len + } + + #[inline] + fn is_overlapping(&self, other: &Self) -> bool { + *self == *other + } +} + +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] +// SAFETY: We implement `is_in_bounds()` and `is_overlapping()` correctly. +unsafe impl GetDisjointMutIndex for Range { + #[inline] + fn is_in_bounds(&self, len: usize) -> bool { + (self.start <= self.end) & (self.end <= len) + } + + #[inline] + fn is_overlapping(&self, other: &Self) -> bool { + (self.start < other.end) & (other.start < self.end) + } +} + +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] +// SAFETY: We implement `is_in_bounds()` and `is_overlapping()` correctly. +unsafe impl GetDisjointMutIndex for RangeInclusive { + #[inline] + fn is_in_bounds(&self, len: usize) -> bool { + (self.start <= self.end) & (self.end < len) + } + + #[inline] + fn is_overlapping(&self, other: &Self) -> bool { + (self.start <= other.end) & (other.start <= self.end) + } +} + +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] +// SAFETY: We implement `is_in_bounds()` and `is_overlapping()` correctly. +unsafe impl GetDisjointMutIndex for range::Range { + #[inline] + fn is_in_bounds(&self, len: usize) -> bool { + Range::from(*self).is_in_bounds(len) + } + + #[inline] + fn is_overlapping(&self, other: &Self) -> bool { + Range::from(*self).is_overlapping(&Range::from(*other)) + } +} + +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] +// SAFETY: We implement `is_in_bounds()` and `is_overlapping()` correctly. +unsafe impl GetDisjointMutIndex for range::RangeInclusive { + #[inline] + fn is_in_bounds(&self, len: usize) -> bool { + RangeInclusive::from(*self).is_in_bounds(len) + } + + #[inline] + fn is_overlapping(&self, other: &Self) -> bool { + RangeInclusive::from(*self).is_overlapping(&RangeInclusive::from(*other)) } } diff --git a/core/src/slice/raw.rs b/core/src/slice/raw.rs index 319b76899bf8e..3582c7e8b3f38 100644 --- a/core/src/slice/raw.rs +++ b/core/src/slice/raw.rs @@ -11,7 +11,7 @@ use crate::{array, ptr, ub_checks}; /// /// Behavior is undefined if any of the following conditions are violated: /// -/// * `data` must be non-null, [valid] for reads for `len * mem::size_of::()` many bytes, +/// * `data` must be non-null, [valid] for reads for `len * size_of::()` many bytes, /// and it must be properly aligned. This means in particular: /// /// * The entire memory range of this slice must be contained within a single allocated object! @@ -28,7 +28,7 @@ use crate::{array, ptr, ub_checks}; /// * The memory referenced by the returned slice must not be mutated for the duration /// of lifetime `'a`, except inside an `UnsafeCell`. /// -/// * The total size `len * mem::size_of::()` of the slice must be no larger than `isize::MAX`, +/// * The total size `len * size_of::()` of the slice must be no larger than `isize::MAX`, /// and adding that size to `data` must not "wrap around" the address space. /// See the safety documentation of [`pointer::offset`]. /// @@ -146,7 +146,7 @@ pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] /// /// Behavior is undefined if any of the following conditions are violated: /// -/// * `data` must be non-null, [valid] for both reads and writes for `len * mem::size_of::()` many bytes, +/// * `data` must be non-null, [valid] for both reads and writes for `len * size_of::()` many bytes, /// and it must be properly aligned. This means in particular: /// /// * The entire memory range of this slice must be contained within a single allocated object! @@ -163,7 +163,7 @@ pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] /// (not derived from the return value) for the duration of lifetime `'a`. /// Both read and write accesses are forbidden. /// -/// * The total size `len * mem::size_of::()` of the slice must be no larger than `isize::MAX`, +/// * The total size `len * size_of::()` of the slice must be no larger than `isize::MAX`, /// and adding that size to `data` must not "wrap around" the address space. /// See the safety documentation of [`pointer::offset`]. /// @@ -272,7 +272,7 @@ pub const fn from_mut(s: &mut T) -> &mut [T] { #[rustc_const_unstable(feature = "const_slice_from_ptr_range", issue = "89792")] pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] { // SAFETY: the caller must uphold the safety contract for `from_ptr_range`. - unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } + unsafe { from_raw_parts(range.start, range.end.offset_from_unsigned(range.start)) } } /// Forms a mutable slice from a pointer range. @@ -342,5 +342,5 @@ pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] { #[rustc_const_unstable(feature = "const_slice_from_mut_ptr_range", issue = "89792")] pub const unsafe fn from_mut_ptr_range<'a, T>(range: Range<*mut T>) -> &'a mut [T] { // SAFETY: the caller must uphold the safety contract for `from_mut_ptr_range`. - unsafe { from_raw_parts_mut(range.start, range.end.sub_ptr(range.start)) } + unsafe { from_raw_parts_mut(range.start, range.end.offset_from_unsigned(range.start)) } } diff --git a/core/src/slice/rotate.rs b/core/src/slice/rotate.rs index 1e4865a7caad9..80178f297eaae 100644 --- a/core/src/slice/rotate.rs +++ b/core/src/slice/rotate.rs @@ -1,6 +1,8 @@ -use crate::mem::{self, MaybeUninit, SizedTypeProperties}; +use crate::mem::{MaybeUninit, SizedTypeProperties}; use crate::{cmp, ptr}; +type BufType = [usize; 32]; + /// Rotates the range `[mid-left, mid+right)` such that the element at `mid` becomes the first /// element. Equivalently, rotates the range `left` elements to the left or `right` elements to the /// right. @@ -8,14 +10,82 @@ use crate::{cmp, ptr}; /// # Safety /// /// The specified range must be valid for reading and writing. +#[inline] +pub(super) unsafe fn ptr_rotate(left: usize, mid: *mut T, right: usize) { + if T::IS_ZST { + return; + } + // abort early if the rotate is a no-op + if (left == 0) || (right == 0) { + return; + } + // `T` is not a zero-sized type, so it's okay to divide by its size. + if !cfg!(feature = "optimize_for_size") + && cmp::min(left, right) <= size_of::() / size_of::() + { + // SAFETY: guaranteed by the caller + unsafe { ptr_rotate_memmove(left, mid, right) }; + } else if !cfg!(feature = "optimize_for_size") + && ((left + right < 24) || (size_of::() > size_of::<[usize; 4]>())) + { + // SAFETY: guaranteed by the caller + unsafe { ptr_rotate_gcd(left, mid, right) } + } else { + // SAFETY: guaranteed by the caller + unsafe { ptr_rotate_swap(left, mid, right) } + } +} + +/// Algorithm 1 is used if `min(left, right)` is small enough to fit onto a stack buffer. The +/// `min(left, right)` elements are copied onto the buffer, `memmove` is applied to the others, and +/// the ones on the buffer are moved back into the hole on the opposite side of where they +/// originated. /// -/// # Algorithm +/// # Safety /// -/// Algorithm 1 is used for small values of `left + right` or for large `T`. The elements are moved -/// into their final positions one at a time starting at `mid - left` and advancing by `right` steps -/// modulo `left + right`, such that only one temporary is needed. Eventually, we arrive back at -/// `mid - left`. However, if `gcd(left + right, right)` is not 1, the above steps skipped over -/// elements. For example: +/// The specified range must be valid for reading and writing. +#[inline] +unsafe fn ptr_rotate_memmove(left: usize, mid: *mut T, right: usize) { + // The `[T; 0]` here is to ensure this is appropriately aligned for T + let mut rawarray = MaybeUninit::<(BufType, [T; 0])>::uninit(); + let buf = rawarray.as_mut_ptr() as *mut T; + // SAFETY: `mid-left <= mid-left+right < mid+right` + let dim = unsafe { mid.sub(left).add(right) }; + if left <= right { + // SAFETY: + // + // 1) The `if` condition about the sizes ensures `[mid-left; left]` will fit in + // `buf` without overflow and `buf` was created just above and so cannot be + // overlapped with any value of `[mid-left; left]` + // 2) [mid-left, mid+right) are all valid for reading and writing and we don't care + // about overlaps here. + // 3) The `if` condition about `left <= right` ensures writing `left` elements to + // `dim = mid-left+right` is valid because: + // - `buf` is valid and `left` elements were written in it in 1) + // - `dim+left = mid-left+right+left = mid+right` and we write `[dim, dim+left)` + unsafe { + // 1) + ptr::copy_nonoverlapping(mid.sub(left), buf, left); + // 2) + ptr::copy(mid, mid.sub(left), right); + // 3) + ptr::copy_nonoverlapping(buf, dim, left); + } + } else { + // SAFETY: same reasoning as above but with `left` and `right` reversed + unsafe { + ptr::copy_nonoverlapping(mid, buf, right); + ptr::copy(mid.sub(left), dim, left); + ptr::copy_nonoverlapping(buf, mid.sub(left), right); + } + } +} + +/// Algorithm 2 is used for small values of `left + right` or for large `T`. The elements +/// are moved into their final positions one at a time starting at `mid - left` and advancing by +/// `right` steps modulo `left + right`, such that only one temporary is needed. Eventually, we +/// arrive back at `mid - left`. However, if `gcd(left + right, right)` is not 1, the above steps +/// skipped over elements. For example: /// ```text /// left = 10, right = 6 /// the `^` indicates an element in its final place @@ -39,17 +109,104 @@ use crate::{cmp, ptr}; /// `gcd(left + right, right)` value). The end result is that all elements are finalized once and /// only once. /// -/// Algorithm 2 is used if `left + right` is large but `min(left, right)` is small enough to -/// fit onto a stack buffer. The `min(left, right)` elements are copied onto the buffer, `memmove` -/// is applied to the others, and the ones on the buffer are moved back into the hole on the -/// opposite side of where they originated. -/// -/// Algorithms that can be vectorized outperform the above once `left + right` becomes large enough. -/// Algorithm 1 can be vectorized by chunking and performing many rounds at once, but there are too +/// Algorithm 2 can be vectorized by chunking and performing many rounds at once, but there are too /// few rounds on average until `left + right` is enormous, and the worst case of a single -/// round is always there. Instead, algorithm 3 utilizes repeated swapping of -/// `min(left, right)` elements until a smaller rotate problem is left. +/// round is always there. +/// +/// # Safety +/// +/// The specified range must be valid for reading and writing. +#[inline] +unsafe fn ptr_rotate_gcd(left: usize, mid: *mut T, right: usize) { + // Algorithm 2 + // Microbenchmarks indicate that the average performance for random shifts is better all + // the way until about `left + right == 32`, but the worst case performance breaks even + // around 16. 24 was chosen as middle ground. If the size of `T` is larger than 4 + // `usize`s, this algorithm also outperforms other algorithms. + // SAFETY: callers must ensure `mid - left` is valid for reading and writing. + let x = unsafe { mid.sub(left) }; + // beginning of first round + // SAFETY: see previous comment. + let mut tmp: T = unsafe { x.read() }; + let mut i = right; + // `gcd` can be found before hand by calculating `gcd(left + right, right)`, + // but it is faster to do one loop which calculates the gcd as a side effect, then + // doing the rest of the chunk + let mut gcd = right; + // benchmarks reveal that it is faster to swap temporaries all the way through instead + // of reading one temporary once, copying backwards, and then writing that temporary at + // the very end. This is possibly due to the fact that swapping or replacing temporaries + // uses only one memory address in the loop instead of needing to manage two. + loop { + // [long-safety-expl] + // SAFETY: callers must ensure `[left, left+mid+right)` are all valid for reading and + // writing. + // + // - `i` start with `right` so `mid-left <= x+i = x+right = mid-left+right < mid+right` + // - `i <= left+right-1` is always true + // - if `i < left`, `right` is added so `i < left+right` and on the next + // iteration `left` is removed from `i` so it doesn't go further + // - if `i >= left`, `left` is removed immediately and so it doesn't go further. + // - overflows cannot happen for `i` since the function's safety contract ask for + // `mid+right-1 = x+left+right` to be valid for writing + // - underflows cannot happen because `i` must be bigger or equal to `left` for + // a subtraction of `left` to happen. + // + // So `x+i` is valid for reading and writing if the caller respected the contract + tmp = unsafe { x.add(i).replace(tmp) }; + // instead of incrementing `i` and then checking if it is outside the bounds, we + // check if `i` will go outside the bounds on the next increment. This prevents + // any wrapping of pointers or `usize`. + if i >= left { + i -= left; + if i == 0 { + // end of first round + // SAFETY: tmp has been read from a valid source and x is valid for writing + // according to the caller. + unsafe { x.write(tmp) }; + break; + } + // this conditional must be here if `left + right >= 15` + if i < gcd { + gcd = i; + } + } else { + i += right; + } + } + // finish the chunk with more rounds + for start in 1..gcd { + // SAFETY: `gcd` is at most equal to `right` so all values in `1..gcd` are valid for + // reading and writing as per the function's safety contract, see [long-safety-expl] + // above + tmp = unsafe { x.add(start).read() }; + // [safety-expl-addition] + // + // Here `start < gcd` so `start < right` so `i < right+right`: `right` being the + // greatest common divisor of `(left+right, right)` means that `left = right` so + // `i < left+right` so `x+i = mid-left+i` is always valid for reading and writing + // according to the function's safety contract. + i = start + right; + loop { + // SAFETY: see [long-safety-expl] and [safety-expl-addition] + tmp = unsafe { x.add(i).replace(tmp) }; + if i >= left { + i -= left; + if i == start { + // SAFETY: see [long-safety-expl] and [safety-expl-addition] + unsafe { x.add(start).write(tmp) }; + break; + } + } else { + i += right; + } + } + } +} + +/// Algorithm 3 utilizes repeated swapping of `min(left, right)` elements. /// +/// /// /// ```text /// left = 11, right = 4 /// [4 5 6 7 8 9 10 11 12 13 14 . 0 1 2 3] @@ -60,144 +217,14 @@ use crate::{cmp, ptr}; /// we cannot swap any more, but a smaller rotation problem is left to solve /// ``` /// when `left < right` the swapping happens from the left instead. -pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) { - type BufType = [usize; 32]; - if T::IS_ZST { - return; - } +/// +/// # Safety +/// +/// The specified range must be valid for reading and writing. +#[inline] +unsafe fn ptr_rotate_swap(mut left: usize, mut mid: *mut T, mut right: usize) { loop { - // N.B. the below algorithms can fail if these cases are not checked - if (right == 0) || (left == 0) { - return; - } - if !cfg!(feature = "optimize_for_size") - && ((left + right < 24) || (mem::size_of::() > mem::size_of::<[usize; 4]>())) - { - // Algorithm 1 - // Microbenchmarks indicate that the average performance for random shifts is better all - // the way until about `left + right == 32`, but the worst case performance breaks even - // around 16. 24 was chosen as middle ground. If the size of `T` is larger than 4 - // `usize`s, this algorithm also outperforms other algorithms. - // SAFETY: callers must ensure `mid - left` is valid for reading and writing. - let x = unsafe { mid.sub(left) }; - // beginning of first round - // SAFETY: see previous comment. - let mut tmp: T = unsafe { x.read() }; - let mut i = right; - // `gcd` can be found before hand by calculating `gcd(left + right, right)`, - // but it is faster to do one loop which calculates the gcd as a side effect, then - // doing the rest of the chunk - let mut gcd = right; - // benchmarks reveal that it is faster to swap temporaries all the way through instead - // of reading one temporary once, copying backwards, and then writing that temporary at - // the very end. This is possibly due to the fact that swapping or replacing temporaries - // uses only one memory address in the loop instead of needing to manage two. - loop { - // [long-safety-expl] - // SAFETY: callers must ensure `[left, left+mid+right)` are all valid for reading and - // writing. - // - // - `i` start with `right` so `mid-left <= x+i = x+right = mid-left+right < mid+right` - // - `i <= left+right-1` is always true - // - if `i < left`, `right` is added so `i < left+right` and on the next - // iteration `left` is removed from `i` so it doesn't go further - // - if `i >= left`, `left` is removed immediately and so it doesn't go further. - // - overflows cannot happen for `i` since the function's safety contract ask for - // `mid+right-1 = x+left+right` to be valid for writing - // - underflows cannot happen because `i` must be bigger or equal to `left` for - // a subtraction of `left` to happen. - // - // So `x+i` is valid for reading and writing if the caller respected the contract - tmp = unsafe { x.add(i).replace(tmp) }; - // instead of incrementing `i` and then checking if it is outside the bounds, we - // check if `i` will go outside the bounds on the next increment. This prevents - // any wrapping of pointers or `usize`. - if i >= left { - i -= left; - if i == 0 { - // end of first round - // SAFETY: tmp has been read from a valid source and x is valid for writing - // according to the caller. - unsafe { x.write(tmp) }; - break; - } - // this conditional must be here if `left + right >= 15` - if i < gcd { - gcd = i; - } - } else { - i += right; - } - } - // finish the chunk with more rounds - for start in 1..gcd { - // SAFETY: `gcd` is at most equal to `right` so all values in `1..gcd` are valid for - // reading and writing as per the function's safety contract, see [long-safety-expl] - // above - tmp = unsafe { x.add(start).read() }; - // [safety-expl-addition] - // - // Here `start < gcd` so `start < right` so `i < right+right`: `right` being the - // greatest common divisor of `(left+right, right)` means that `left = right` so - // `i < left+right` so `x+i = mid-left+i` is always valid for reading and writing - // according to the function's safety contract. - i = start + right; - loop { - // SAFETY: see [long-safety-expl] and [safety-expl-addition] - tmp = unsafe { x.add(i).replace(tmp) }; - if i >= left { - i -= left; - if i == start { - // SAFETY: see [long-safety-expl] and [safety-expl-addition] - unsafe { x.add(start).write(tmp) }; - break; - } - } else { - i += right; - } - } - } - return; - // `T` is not a zero-sized type, so it's okay to divide by its size. - } else if !cfg!(feature = "optimize_for_size") - && cmp::min(left, right) <= mem::size_of::() / mem::size_of::() - { - // Algorithm 2 - // The `[T; 0]` here is to ensure this is appropriately aligned for T - let mut rawarray = MaybeUninit::<(BufType, [T; 0])>::uninit(); - let buf = rawarray.as_mut_ptr() as *mut T; - // SAFETY: `mid-left <= mid-left+right < mid+right` - let dim = unsafe { mid.sub(left).add(right) }; - if left <= right { - // SAFETY: - // - // 1) The `else if` condition about the sizes ensures `[mid-left; left]` will fit in - // `buf` without overflow and `buf` was created just above and so cannot be - // overlapped with any value of `[mid-left; left]` - // 2) [mid-left, mid+right) are all valid for reading and writing and we don't care - // about overlaps here. - // 3) The `if` condition about `left <= right` ensures writing `left` elements to - // `dim = mid-left+right` is valid because: - // - `buf` is valid and `left` elements were written in it in 1) - // - `dim+left = mid-left+right+left = mid+right` and we write `[dim, dim+left)` - unsafe { - // 1) - ptr::copy_nonoverlapping(mid.sub(left), buf, left); - // 2) - ptr::copy(mid, mid.sub(left), right); - // 3) - ptr::copy_nonoverlapping(buf, dim, left); - } - } else { - // SAFETY: same reasoning as above but with `left` and `right` reversed - unsafe { - ptr::copy_nonoverlapping(mid, buf, right); - ptr::copy(mid.sub(left), dim, left); - ptr::copy_nonoverlapping(buf, mid.sub(left), right); - } - } - return; - } else if left >= right { + if left >= right { // Algorithm 3 // There is an alternate way of swapping that involves finding where the last swap // of this algorithm would be, and swapping using that last chunk instead of swapping @@ -233,5 +260,8 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) } } } + if (right == 0) || (left == 0) { + return; + } } } diff --git a/core/src/slice/sort/shared/pivot.rs b/core/src/slice/sort/shared/pivot.rs index 255a1eb6c88a8..3aace484b6a89 100644 --- a/core/src/slice/sort/shared/pivot.rs +++ b/core/src/slice/sort/shared/pivot.rs @@ -31,9 +31,9 @@ pub fn choose_pivot bool>(v: &[T], is_less: &mut F) -> us let c = v_base.add(len_div_8 * 7); // [7*floor(n/8), 8*floor(n/8)) if len < PSEUDO_MEDIAN_REC_THRESHOLD { - median3(&*a, &*b, &*c, is_less).sub_ptr(v_base) + median3(&*a, &*b, &*c, is_less).offset_from_unsigned(v_base) } else { - median3_rec(a, b, c, len_div_8, is_less).sub_ptr(v_base) + median3_rec(a, b, c, len_div_8, is_less).offset_from_unsigned(v_base) } } } diff --git a/core/src/slice/sort/shared/smallsort.rs b/core/src/slice/sort/shared/smallsort.rs index 09f898309bd65..95f196a40d01c 100644 --- a/core/src/slice/sort/shared/smallsort.rs +++ b/core/src/slice/sort/shared/smallsort.rs @@ -113,7 +113,7 @@ pub(crate) trait UnstableSmallSortFreezeTypeImpl: Sized + FreezeMarker { impl UnstableSmallSortFreezeTypeImpl for T { #[inline(always)] default fn small_sort_threshold() -> usize { - if (mem::size_of::() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { + if (size_of::() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { SMALL_SORT_GENERAL_THRESHOLD } else { SMALL_SORT_FALLBACK_THRESHOLD @@ -125,7 +125,7 @@ impl UnstableSmallSortFreezeTypeImpl for T { where F: FnMut(&T, &T) -> bool, { - if (mem::size_of::() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { + if (size_of::() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { small_sort_general(v, is_less); } else { small_sort_fallback(v, is_less); @@ -143,10 +143,10 @@ impl UnstableSmallSortFreezeTypeImpl for T { #[inline(always)] fn small_sort_threshold() -> usize { if has_efficient_in_place_swap::() - && (mem::size_of::() * SMALL_SORT_NETWORK_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE + && (size_of::() * SMALL_SORT_NETWORK_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { SMALL_SORT_NETWORK_THRESHOLD - } else if (mem::size_of::() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { + } else if (size_of::() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { SMALL_SORT_GENERAL_THRESHOLD } else { SMALL_SORT_FALLBACK_THRESHOLD @@ -159,10 +159,10 @@ impl UnstableSmallSortFreezeTypeImpl for T { F: FnMut(&T, &T) -> bool, { if has_efficient_in_place_swap::() - && (mem::size_of::() * SMALL_SORT_NETWORK_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE + && (size_of::() * SMALL_SORT_NETWORK_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { small_sort_network(v, is_less); - } else if (mem::size_of::() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { + } else if (size_of::() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { small_sort_general(v, is_less); } else { small_sort_fallback(v, is_less); @@ -238,7 +238,7 @@ fn small_sort_general_with_scratch bool>( unsafe { let scratch_base = scratch.as_mut_ptr() as *mut T; - let presorted_len = if const { mem::size_of::() <= 16 } && len >= 16 { + let presorted_len = if const { size_of::() <= 16 } && len >= 16 { // SAFETY: scratch_base is valid and has enough space. sort8_stable(v_base, scratch_base, scratch_base.add(len), is_less); sort8_stable( @@ -387,7 +387,7 @@ unsafe fn swap_if_less(v_base: *mut T, a_pos: usize, b_pos: usize, is_less where F: FnMut(&T, &T) -> bool, { - // SAFETY: the caller must guarantee that `a` and `b` each added to `v_base` yield valid + // SAFETY: the caller must guarantee that `a_pos` and `b_pos` each added to `v_base` yield valid // pointers into `v_base`, and are properly aligned, and part of the same allocation. unsafe { let v_a = v_base.add(a_pos); @@ -404,16 +404,16 @@ where // The equivalent code with a branch would be: // // if should_swap { - // ptr::swap(left, right, 1); + // ptr::swap(v_a, v_b, 1); // } // The goal is to generate cmov instructions here. - let left_swap = if should_swap { v_b } else { v_a }; - let right_swap = if should_swap { v_a } else { v_b }; + let v_a_swap = should_swap.select_unpredictable(v_b, v_a); + let v_b_swap = should_swap.select_unpredictable(v_a, v_b); - let right_swap_tmp = ManuallyDrop::new(ptr::read(right_swap)); - ptr::copy(left_swap, v_a, 1); - ptr::copy_nonoverlapping(&*right_swap_tmp, v_b, 1); + let v_b_swap_tmp = ManuallyDrop::new(ptr::read(v_b_swap)); + ptr::copy(v_a_swap, v_a, 1); + ptr::copy_nonoverlapping(&*v_b_swap_tmp, v_b, 1); } } @@ -640,26 +640,21 @@ pub unsafe fn sort4_stable bool>( // 1, 1 | c b a d let c3 = is_less(&*c, &*a); let c4 = is_less(&*d, &*b); - let min = select(c3, c, a); - let max = select(c4, b, d); - let unknown_left = select(c3, a, select(c4, c, b)); - let unknown_right = select(c4, d, select(c3, b, c)); + let min = c3.select_unpredictable(c, a); + let max = c4.select_unpredictable(b, d); + let unknown_left = c3.select_unpredictable(a, c4.select_unpredictable(c, b)); + let unknown_right = c4.select_unpredictable(d, c3.select_unpredictable(b, c)); // Sort the last two unknown elements. let c5 = is_less(&*unknown_right, &*unknown_left); - let lo = select(c5, unknown_right, unknown_left); - let hi = select(c5, unknown_left, unknown_right); + let lo = c5.select_unpredictable(unknown_right, unknown_left); + let hi = c5.select_unpredictable(unknown_left, unknown_right); ptr::copy_nonoverlapping(min, dst, 1); ptr::copy_nonoverlapping(lo, dst.add(1), 1); ptr::copy_nonoverlapping(hi, dst.add(2), 1); ptr::copy_nonoverlapping(max, dst.add(3), 1); } - - #[inline(always)] - fn select(cond: bool, if_true: *const T, if_false: *const T) -> *const T { - if cond { if_true } else { if_false } - } } /// SAFETY: The caller MUST guarantee that `v_base` is valid for 8 reads and @@ -868,5 +863,5 @@ fn panic_on_ord_violation() -> ! { #[must_use] pub(crate) const fn has_efficient_in_place_swap() -> bool { // Heuristic that holds true on all tested 64-bit capable architectures. - mem::size_of::() <= 8 // mem::size_of::() + size_of::() <= 8 // size_of::() } diff --git a/core/src/slice/sort/stable/drift.rs b/core/src/slice/sort/stable/drift.rs index 644e75a4581e9..cf1df1e91a50d 100644 --- a/core/src/slice/sort/stable/drift.rs +++ b/core/src/slice/sort/stable/drift.rs @@ -10,8 +10,8 @@ use crate::{cmp, intrinsics}; /// Sorts `v` based on comparison function `is_less`. If `eager_sort` is true, /// it will only do small-sorts and physical merges, ensuring O(N * log(N)) -/// worst-case complexity. `scratch.len()` must be at least `max(v.len() / 2, -/// MIN_SMALL_SORT_SCRATCH_LEN)` otherwise the implementation may abort. +/// worst-case complexity. `scratch.len()` must be at least +/// `max(v.len() - v.len() / 2, SMALL_SORT_GENERAL_SCRATCH_LEN)` otherwise the implementation may abort. /// Fully ascending and descending inputs will be sorted with exactly N - 1 /// comparisons. /// diff --git a/core/src/slice/sort/stable/merge.rs b/core/src/slice/sort/stable/merge.rs index 0cb21740795b7..bb2747bfc78ac 100644 --- a/core/src/slice/sort/stable/merge.rs +++ b/core/src/slice/sort/stable/merge.rs @@ -143,7 +143,7 @@ impl Drop for MergeState { // leave the input slice `v` with each original element and all possible // modifications observed. unsafe { - let len = self.end.sub_ptr(self.start); + let len = self.end.offset_from_unsigned(self.start); ptr::copy_nonoverlapping(self.start, self.dst, len); } } diff --git a/core/src/slice/sort/stable/mod.rs b/core/src/slice/sort/stable/mod.rs index 7adcc83b818d1..090367cdabadd 100644 --- a/core/src/slice/sort/stable/mod.rs +++ b/core/src/slice/sort/stable/mod.rs @@ -3,7 +3,7 @@ #[cfg(not(any(feature = "optimize_for_size", target_pointer_width = "16")))] use crate::cmp; use crate::intrinsics; -use crate::mem::{self, MaybeUninit, SizedTypeProperties}; +use crate::mem::{MaybeUninit, SizedTypeProperties}; #[cfg(not(any(feature = "optimize_for_size", target_pointer_width = "16")))] use crate::slice::sort::shared::smallsort::{ SMALL_SORT_GENERAL_SCRATCH_LEN, StableSmallSortTypeImpl, insertion_sort_shift_left, @@ -41,6 +41,8 @@ pub fn sort bool, BufT: BufGuard>(v: &mut [T], is_less cfg_if! { if #[cfg(any(feature = "optimize_for_size", target_pointer_width = "16"))] { + // Unlike driftsort, mergesort only requires len / 2, + // not len - len / 2. let alloc_len = len / 2; cfg_if! { @@ -91,16 +93,26 @@ fn driftsort_main bool, BufT: BufGuard>(v: &mut [T], i // By allocating n elements of memory we can ensure the entire input can // be sorted using stable quicksort, which allows better performance on // random and low-cardinality distributions. However, we still want to - // reduce our memory usage to n / 2 for large inputs. We do this by scaling - // our allocation as max(n / 2, min(n, 8MB)), ensuring we scale like n for - // small inputs and n / 2 for large inputs, without a sudden drop off. We - // also need to ensure our alloc >= MIN_SMALL_SORT_SCRATCH_LEN, as the + // reduce our memory usage to n - n / 2 for large inputs. We do this by scaling + // our allocation as max(n - n / 2, min(n, 8MB)), ensuring we scale like n for + // small inputs and n - n / 2 for large inputs, without a sudden drop off. We + // also need to ensure our alloc >= SMALL_SORT_GENERAL_SCRATCH_LEN, as the // small-sort always needs this much memory. + // + // driftsort will produce unsorted runs of up to min_good_run_len, which + // is at most len - len / 2. + // Unsorted runs need to be processed by quicksort, which requires as much + // scratch space as the run length, therefore the scratch space must be at + // least len - len / 2. + // If min_good_run_len is ever modified, this code must be updated to allocate + // the correct scratch size for it. const MAX_FULL_ALLOC_BYTES: usize = 8_000_000; // 8MB - let max_full_alloc = MAX_FULL_ALLOC_BYTES / mem::size_of::(); + let max_full_alloc = MAX_FULL_ALLOC_BYTES / size_of::(); let len = v.len(); - let alloc_len = - cmp::max(cmp::max(len / 2, cmp::min(len, max_full_alloc)), SMALL_SORT_GENERAL_SCRATCH_LEN); + let alloc_len = cmp::max( + cmp::max(len - len / 2, cmp::min(len, max_full_alloc)), + SMALL_SORT_GENERAL_SCRATCH_LEN, + ); // For small inputs 4KiB of stack storage suffices, which allows us to avoid // calling the (de-)allocator. Benchmarks showed this was quite beneficial. @@ -143,7 +155,7 @@ impl AlignedStorage { } fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit] { - let len = N / mem::size_of::(); + let len = N / size_of::(); // SAFETY: `_align` ensures we are correctly aligned. unsafe { core::slice::from_raw_parts_mut(self.storage.as_mut_ptr().cast(), len) } diff --git a/core/src/slice/sort/stable/quicksort.rs b/core/src/slice/sort/stable/quicksort.rs index 0c8308bfce00e..3c9688790c40b 100644 --- a/core/src/slice/sort/stable/quicksort.rs +++ b/core/src/slice/sort/stable/quicksort.rs @@ -1,12 +1,14 @@ //! This module contains a stable quicksort and partition implementation. -use crate::mem::{self, ManuallyDrop, MaybeUninit}; +use crate::mem::{ManuallyDrop, MaybeUninit}; use crate::slice::sort::shared::FreezeMarker; use crate::slice::sort::shared::pivot::choose_pivot; use crate::slice::sort::shared::smallsort::StableSmallSortTypeImpl; use crate::{intrinsics, ptr}; /// Sorts `v` recursively using quicksort. +/// `scratch.len()` must be at least `max(v.len() - v.len() / 2, SMALL_SORT_GENERAL_SCRATCH_LEN)` +/// otherwise the implementation may abort. /// /// `limit` when initialized with `c*log(v.len())` for some c ensures we do not /// overflow the stack or go quadratic. @@ -124,7 +126,7 @@ fn stable_partition bool>( // this gave significant performance boosts in benchmarks. Unrolling // through for _ in 0..UNROLL_LEN { .. } instead of manually improves // compile times but has a ~10-20% performance penalty on opt-level=s. - if const { mem::size_of::() <= 16 } { + if const { size_of::() <= 16 } { const UNROLL_LEN: usize = 4; let unroll_end = v_base.add(loop_end_pos.saturating_sub(UNROLL_LEN - 1)); while state.scan < unroll_end { diff --git a/core/src/slice/sort/unstable/quicksort.rs b/core/src/slice/sort/unstable/quicksort.rs index 4feef5deeb0fb..68a1611871699 100644 --- a/core/src/slice/sort/unstable/quicksort.rs +++ b/core/src/slice/sort/unstable/quicksort.rs @@ -1,6 +1,8 @@ //! This module contains an unstable quicksort and two partition implementations. -use crate::mem::{self, ManuallyDrop}; +#[cfg(not(feature = "optimize_for_size"))] +use crate::mem; +use crate::mem::ManuallyDrop; #[cfg(not(feature = "optimize_for_size"))] use crate::slice::sort::shared::pivot::choose_pivot; #[cfg(not(feature = "optimize_for_size"))] @@ -137,7 +139,7 @@ where const fn inst_partition bool>() -> fn(&mut [T], &T, &mut F) -> usize { const MAX_BRANCHLESS_PARTITION_SIZE: usize = 96; - if mem::size_of::() <= MAX_BRANCHLESS_PARTITION_SIZE { + if size_of::() <= MAX_BRANCHLESS_PARTITION_SIZE { // Specialize for types that are relatively cheap to copy, where branchless optimizations // have large leverage e.g. `u64` and `String`. cfg_if! { @@ -224,7 +226,7 @@ where left = left.add(1); } - left.sub_ptr(v_base) + left.offset_from_unsigned(v_base) // `gap_opt` goes out of scope and overwrites the last wrong-side element on the right side // with the first wrong-side element of the left side that was initially overwritten by the @@ -304,7 +306,7 @@ where // Manual unrolling that works well on x86, Arm and with opt-level=s without murdering // compile-times. Leaving this to the compiler yields ok to bad results. - let unroll_len = const { if mem::size_of::() <= 16 { 2 } else { 1 } }; + let unroll_len = const { if size_of::() <= 16 { 2 } else { 1 } }; let unroll_end = v_base.add(len - (unroll_len - 1)); while state.right < unroll_end { diff --git a/core/src/str/converts.rs b/core/src/str/converts.rs index c7bae42765f4e..1276d9014f0ef 100644 --- a/core/src/str/converts.rs +++ b/core/src/str/converts.rs @@ -47,10 +47,11 @@ use crate::{mem, ptr}; /// // some bytes, in a vector /// let sparkle_heart = vec![240, 159, 146, 150]; /// -/// // We know these bytes are valid, so just use `unwrap()`. -/// let sparkle_heart = str::from_utf8(&sparkle_heart).unwrap(); +/// // We can use the ? (try) operator to check if the bytes are valid +/// let sparkle_heart = str::from_utf8(&sparkle_heart)?; /// /// assert_eq!("💖", sparkle_heart); +/// # Ok::<_, str::Utf8Error>(()) /// ``` /// /// Incorrect bytes: @@ -125,7 +126,7 @@ pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> { /// See the docs for [`Utf8Error`] for more details on the kinds of /// errors that can be returned. #[stable(feature = "str_mut_extras", since = "1.20.0")] -#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")] +#[rustc_const_stable(feature = "const_str_from_utf8", since = "CURRENT_RUSTC_VERSION")] #[rustc_diagnostic_item = "str_from_utf8_mut"] pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> { // FIXME(const-hack): This should use `?` again, once it's `const` diff --git a/core/src/str/count.rs b/core/src/str/count.rs index b5d7aaf05d4bd..452403b23dee1 100644 --- a/core/src/str/count.rs +++ b/core/src/str/count.rs @@ -20,7 +20,7 @@ use core::intrinsics::unlikely; -const USIZE_SIZE: usize = core::mem::size_of::(); +const USIZE_SIZE: usize = size_of::(); const UNROLL_INNER: usize = 4; #[inline] diff --git a/core/src/str/lossy.rs b/core/src/str/lossy.rs index e7677c8317a9f..ed2cefc59a51c 100644 --- a/core/src/str/lossy.rs +++ b/core/src/str/lossy.rs @@ -8,7 +8,7 @@ impl [u8] { /// Creates an iterator over the contiguous valid UTF-8 ranges of this /// slice, and the non-UTF-8 fragments in between. /// - /// See the [`Utf8Chunk`] type for documenation of the items yielded by this iterator. + /// See the [`Utf8Chunk`] type for documentation of the items yielded by this iterator. /// /// # Examples /// @@ -150,7 +150,7 @@ impl fmt::Debug for Debug<'_> { /// If you want a simple conversion from UTF-8 byte slices to string slices, /// [`from_utf8`] is easier to use. /// -/// See the [`Utf8Chunk`] type for documenation of the items yielded by this iterator. +/// See the [`Utf8Chunk`] type for documentation of the items yielded by this iterator. /// /// [byteslice]: slice /// [`from_utf8`]: super::from_utf8 diff --git a/core/src/str/mod.rs b/core/src/str/mod.rs index 4629b770cb46d..83ad10db2da45 100644 --- a/core/src/str/mod.rs +++ b/core/src/str/mod.rs @@ -160,6 +160,175 @@ impl str { self.len() == 0 } + /// Converts a slice of bytes to a string slice. + /// + /// A string slice ([`&str`]) is made of bytes ([`u8`]), and a byte slice + /// ([`&[u8]`][byteslice]) is made of bytes, so this function converts between + /// the two. Not all byte slices are valid string slices, however: [`&str`] requires + /// that it is valid UTF-8. `from_utf8()` checks to ensure that the bytes are valid + /// UTF-8, and then does the conversion. + /// + /// [`&str`]: str + /// [byteslice]: prim@slice + /// + /// If you are sure that the byte slice is valid UTF-8, and you don't want to + /// incur the overhead of the validity check, there is an unsafe version of + /// this function, [`from_utf8_unchecked`], which has the same + /// behavior but skips the check. + /// + /// If you need a `String` instead of a `&str`, consider + /// [`String::from_utf8`][string]. + /// + /// [string]: ../std/string/struct.String.html#method.from_utf8 + /// + /// Because you can stack-allocate a `[u8; N]`, and you can take a + /// [`&[u8]`][byteslice] of it, this function is one way to have a + /// stack-allocated string. There is an example of this in the + /// examples section below. + /// + /// [byteslice]: slice + /// + /// # Errors + /// + /// Returns `Err` if the slice is not UTF-8 with a description as to why the + /// provided slice is not UTF-8. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// // some bytes, in a vector + /// let sparkle_heart = vec![240, 159, 146, 150]; + /// + /// // We can use the ? (try) operator to check if the bytes are valid + /// let sparkle_heart = str::from_utf8(&sparkle_heart)?; + /// + /// assert_eq!("💖", sparkle_heart); + /// # Ok::<_, std::str::Utf8Error>(()) + /// ``` + /// + /// Incorrect bytes: + /// + /// ``` + /// // some invalid bytes, in a vector + /// let sparkle_heart = vec![0, 159, 146, 150]; + /// + /// assert!(str::from_utf8(&sparkle_heart).is_err()); + /// ``` + /// + /// See the docs for [`Utf8Error`] for more details on the kinds of + /// errors that can be returned. + /// + /// A "stack allocated string": + /// + /// ``` + /// // some bytes, in a stack-allocated array + /// let sparkle_heart = [240, 159, 146, 150]; + /// + /// // We know these bytes are valid, so just use `unwrap()`. + /// let sparkle_heart: &str = str::from_utf8(&sparkle_heart).unwrap(); + /// + /// assert_eq!("💖", sparkle_heart); + /// ``` + #[stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_diagnostic_item = "str_inherent_from_utf8"] + pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> { + converts::from_utf8(v) + } + + /// Converts a mutable slice of bytes to a mutable string slice. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// // "Hello, Rust!" as a mutable vector + /// let mut hellorust = vec![72, 101, 108, 108, 111, 44, 32, 82, 117, 115, 116, 33]; + /// + /// // As we know these bytes are valid, we can use `unwrap()` + /// let outstr = str::from_utf8_mut(&mut hellorust).unwrap(); + /// + /// assert_eq!("Hello, Rust!", outstr); + /// ``` + /// + /// Incorrect bytes: + /// + /// ``` + /// // Some invalid bytes in a mutable vector + /// let mut invalid = vec![128, 223]; + /// + /// assert!(str::from_utf8_mut(&mut invalid).is_err()); + /// ``` + /// See the docs for [`Utf8Error`] for more details on the kinds of + /// errors that can be returned. + #[stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_str_from_utf8", since = "CURRENT_RUSTC_VERSION")] + #[rustc_diagnostic_item = "str_inherent_from_utf8_mut"] + pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> { + converts::from_utf8_mut(v) + } + + /// Converts a slice of bytes to a string slice without checking + /// that the string contains valid UTF-8. + /// + /// See the safe version, [`from_utf8`], for more information. + /// + /// # Safety + /// + /// The bytes passed in must be valid UTF-8. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// // some bytes, in a vector + /// let sparkle_heart = vec![240, 159, 146, 150]; + /// + /// let sparkle_heart = unsafe { + /// str::from_utf8_unchecked(&sparkle_heart) + /// }; + /// + /// assert_eq!("💖", sparkle_heart); + /// ``` + #[inline] + #[must_use] + #[stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_diagnostic_item = "str_inherent_from_utf8_unchecked"] + pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str { + // SAFETY: converts::from_utf8_unchecked has the same safety requirements as this function. + unsafe { converts::from_utf8_unchecked(v) } + } + + /// Converts a slice of bytes to a string slice without checking + /// that the string contains valid UTF-8; mutable version. + /// + /// See the immutable version, [`from_utf8_unchecked()`] for more information. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// let mut heart = vec![240, 159, 146, 150]; + /// let heart = unsafe { str::from_utf8_unchecked_mut(&mut heart) }; + /// + /// assert_eq!("💖", heart); + /// ``` + #[inline] + #[must_use] + #[stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_diagnostic_item = "str_inherent_from_utf8_unchecked_mut"] + pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str { + // SAFETY: converts::from_utf8_unchecked_mut has the same safety requirements as this function. + unsafe { converts::from_utf8_unchecked_mut(v) } + } + /// Checks that `index`-th byte is the first byte in a UTF-8 code point /// sequence or the end of the string. /// @@ -185,7 +354,7 @@ impl str { /// ``` #[must_use] #[stable(feature = "is_char_boundary", since = "1.9.0")] - #[rustc_const_unstable(feature = "const_is_char_boundary", issue = "131516")] + #[rustc_const_stable(feature = "const_is_char_boundary", since = "1.86.0")] #[inline] pub const fn is_char_boundary(&self, index: usize) -> bool { // 0 is always ok. @@ -373,7 +542,7 @@ impl str { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "rustc_str_as_ptr", since = "1.32.0")] #[rustc_never_returns_null_ptr] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[must_use] #[inline(always)] pub const fn as_ptr(&self) -> *const u8 { @@ -391,7 +560,7 @@ impl str { #[stable(feature = "str_as_mut_ptr", since = "1.36.0")] #[rustc_const_stable(feature = "const_str_as_mut", since = "1.83.0")] #[rustc_never_returns_null_ptr] - #[cfg_attr(not(bootstrap), rustc_as_ptr)] + #[rustc_as_ptr] #[must_use] #[inline(always)] pub const fn as_mut_ptr(&mut self) -> *mut u8 { @@ -642,7 +811,7 @@ impl str { #[inline] #[must_use] #[stable(feature = "str_split_at", since = "1.4.0")] - #[rustc_const_unstable(feature = "const_str_split_at", issue = "131518")] + #[rustc_const_stable(feature = "const_str_split_at", since = "1.86.0")] pub const fn split_at(&self, mid: usize) -> (&str, &str) { match self.split_at_checked(mid) { None => slice_error_fail(self, 0, mid), @@ -683,7 +852,7 @@ impl str { #[inline] #[must_use] #[stable(feature = "str_split_at", since = "1.4.0")] - #[rustc_const_unstable(feature = "const_str_split_at", issue = "131518")] + #[rustc_const_stable(feature = "const_str_split_at", since = "1.86.0")] pub const fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str) { // is_char_boundary checks that the index is in [0, .len()] if self.is_char_boundary(mid) { @@ -723,7 +892,7 @@ impl str { #[inline] #[must_use] #[stable(feature = "split_at_checked", since = "1.80.0")] - #[rustc_const_unstable(feature = "const_str_split_at", issue = "131518")] + #[rustc_const_stable(feature = "const_str_split_at", since = "1.86.0")] pub const fn split_at_checked(&self, mid: usize) -> Option<(&str, &str)> { // is_char_boundary checks that the index is in [0, .len()] if self.is_char_boundary(mid) { @@ -764,7 +933,7 @@ impl str { #[inline] #[must_use] #[stable(feature = "split_at_checked", since = "1.80.0")] - #[rustc_const_unstable(feature = "const_str_split_at", issue = "131518")] + #[rustc_const_stable(feature = "const_str_split_at", since = "1.86.0")] pub const fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut str, &mut str)> { // is_char_boundary checks that the index is in [0, .len()] if self.is_char_boundary(mid) { @@ -1108,7 +1277,8 @@ impl str { LinesAny(self.lines()) } - /// Returns an iterator of `u16` over the string encoded as UTF-16. + /// Returns an iterator of `u16` over the string encoded + /// as native endian UTF-16 (without byte-order mark). /// /// # Examples /// @@ -2503,7 +2673,7 @@ impl str { /// assert_eq!("GRüßE, JüRGEN ❤", s); /// ``` #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] - #[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_make_ascii", since = "1.84.0")] #[inline] pub const fn make_ascii_uppercase(&mut self) { // SAFETY: changing ASCII letters only does not invalidate UTF-8. @@ -2531,7 +2701,7 @@ impl str { /// assert_eq!("grÜße, jÜrgen ❤", s); /// ``` #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] - #[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_make_ascii", since = "1.84.0")] #[inline] pub const fn make_ascii_lowercase(&mut self) { // SAFETY: changing ASCII letters only does not invalidate UTF-8. diff --git a/core/src/str/pattern.rs b/core/src/str/pattern.rs index 52e2364893eb1..2d941adfd859c 100644 --- a/core/src/str/pattern.rs +++ b/core/src/str/pattern.rs @@ -38,6 +38,7 @@ issue = "27721" )] +use crate::char::MAX_LEN_UTF8; use crate::cmp::Ordering; use crate::convert::TryInto as _; use crate::slice::memchr; @@ -561,8 +562,8 @@ impl Pattern for char { type Searcher<'a> = CharSearcher<'a>; #[inline] - fn into_searcher(self, haystack: &str) -> Self::Searcher<'_> { - let mut utf8_encoded = [0; 4]; + fn into_searcher<'a>(self, haystack: &'a str) -> Self::Searcher<'a> { + let mut utf8_encoded = [0; MAX_LEN_UTF8]; let utf8_size = self .encode_utf8(&mut utf8_encoded) .len() diff --git a/core/src/str/validations.rs b/core/src/str/validations.rs index 0f724dd961329..8174e4ff97dfc 100644 --- a/core/src/str/validations.rs +++ b/core/src/str/validations.rs @@ -2,7 +2,6 @@ use super::Utf8Error; use crate::intrinsics::const_eval_select; -use crate::mem; /// Returns the initial codepoint accumulator for the first byte. /// The first byte is special, only want bottom 5 bits for width 2, 4 bits @@ -128,7 +127,7 @@ pub(super) const fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> { let mut index = 0; let len = v.len(); - const USIZE_BYTES: usize = mem::size_of::(); + const USIZE_BYTES: usize = size_of::(); let ascii_block_size = 2 * USIZE_BYTES; let blocks_end = if len >= ascii_block_size { len - ascii_block_size + 1 } else { 0 }; diff --git a/core/src/sync/atomic.rs b/core/src/sync/atomic.rs index 7f2a5424787f7..54a65c8459e96 100644 --- a/core/src/sync/atomic.rs +++ b/core/src/sync/atomic.rs @@ -44,8 +44,9 @@ //! The most important aspect of this model is that *data races* are undefined behavior. A data race //! is defined as conflicting non-synchronized accesses where at least one of the accesses is //! non-atomic. Here, accesses are *conflicting* if they affect overlapping regions of memory and at -//! least one of them is a write. They are *non-synchronized* if neither of them *happens-before* -//! the other, according to the happens-before order of the memory model. +//! least one of them is a write. (A `compare_exchange` or `compare_exchange_weak` that does not +//! succeed is not considered a write.) They are *non-synchronized* if neither of them +//! *happens-before* the other, according to the happens-before order of the memory model. //! //! The other possible cause of undefined behavior in the memory model are mixed-size accesses: Rust //! inherits the C++ limitation that non-synchronized conflicting atomic accesses may not partially @@ -86,7 +87,7 @@ //! // This is fine: `join` synchronizes the code in a way such that the atomic //! // store happens-before the non-atomic write. //! let handle = s.spawn(|| atomic.store(1, Ordering::Relaxed)); // atomic store -//! handle.join().unwrap(); // synchronize +//! handle.join().expect("thread won't panic"); // synchronize //! s.spawn(|| unsafe { atomic.as_ptr().write(2) }); // non-atomic write //! }); //! @@ -103,7 +104,7 @@ //! // This is fine: `join` synchronizes the code in a way such that //! // the 1-byte store happens-before the 2-byte store. //! let handle = s.spawn(|| atomic.store(1, Ordering::Relaxed)); -//! handle.join().unwrap(); +//! handle.join().expect("thread won't panic"); //! s.spawn(|| unsafe { //! let differently_sized = transmute::<&AtomicU16, &AtomicU8>(&atomic); //! differently_sized.store(2, Ordering::Relaxed); @@ -469,7 +470,7 @@ impl AtomicBool { /// [valid]: crate::ptr#safety /// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses #[stable(feature = "atomic_from_ptr", since = "1.75.0")] - #[rustc_const_stable(feature = "const_atomic_from_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_atomic_from_ptr", since = "1.84.0")] pub const unsafe fn from_ptr<'a>(ptr: *mut bool) -> &'a AtomicBool { // SAFETY: guaranteed by the caller unsafe { &*ptr.cast() } @@ -716,6 +717,12 @@ impl AtomicBool { /// AcqRel | AcqRel | Acquire /// SeqCst | SeqCst | SeqCst /// + /// `compare_and_swap` and `compare_exchange` also differ in their return type. You can use + /// `compare_exchange(...).unwrap_or_else(|x| x)` to recover the behavior of `compare_and_swap`, + /// but in most cases it is more idiomatic to check whether the return value is `Ok` or `Err` + /// rather than to infer success vs failure based on the value that was read. + /// + /// During migration, consider whether it makes sense to use `compare_exchange_weak` instead. /// `compare_exchange_weak` is allowed to fail spuriously even when the comparison succeeds, /// which allows the compiler to generate better assembly code when the compare and swap /// is used in a loop. @@ -1164,7 +1171,7 @@ impl AtomicBool { /// /// # Considerations /// - /// This method is not magic; it is not provided by the hardware. + /// This method is not magic; it is not provided by the hardware. /// It is implemented in terms of [`AtomicBool::compare_exchange_weak`], and suffers from the same drawbacks. /// In particular, this method will not circumvent the [ABA Problem]. /// @@ -1203,6 +1210,125 @@ impl AtomicBool { } Err(prev) } + + /// Fetches the value, and applies a function to it that returns an optional + /// new value. Returns a `Result` of `Ok(previous_value)` if the function + /// returned `Some(_)`, else `Err(previous_value)`. + /// + /// See also: [`update`](`AtomicBool::update`). + /// + /// Note: This may call the function multiple times if the value has been + /// changed from other threads in the meantime, as long as the function + /// returns `Some(_)`, but the function will have been applied only once to + /// the stored value. + /// + /// `try_update` takes two [`Ordering`] arguments to describe the memory + /// ordering of this operation. The first describes the required ordering for + /// when the operation finally succeeds while the second describes the + /// required ordering for loads. These correspond to the success and failure + /// orderings of [`AtomicBool::compare_exchange`] respectively. + /// + /// Using [`Acquire`] as success ordering makes the store part of this + /// operation [`Relaxed`], and using [`Release`] makes the final successful + /// load [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], + /// [`Acquire`] or [`Relaxed`]. + /// + /// **Note:** This method is only available on platforms that support atomic + /// operations on `u8`. + /// + /// # Considerations + /// + /// This method is not magic; it is not provided by the hardware. + /// It is implemented in terms of [`AtomicBool::compare_exchange_weak`], and suffers from the same drawbacks. + /// In particular, this method will not circumvent the [ABA Problem]. + /// + /// [ABA Problem]: https://en.wikipedia.org/wiki/ABA_problem + /// + /// # Examples + /// + /// ```rust + /// #![feature(atomic_try_update)] + /// use std::sync::atomic::{AtomicBool, Ordering}; + /// + /// let x = AtomicBool::new(false); + /// assert_eq!(x.try_update(Ordering::SeqCst, Ordering::SeqCst, |_| None), Err(false)); + /// assert_eq!(x.try_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(!x)), Ok(false)); + /// assert_eq!(x.try_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(!x)), Ok(true)); + /// assert_eq!(x.load(Ordering::SeqCst), false); + /// ``` + #[inline] + #[unstable(feature = "atomic_try_update", issue = "135894")] + #[cfg(target_has_atomic = "8")] + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + pub fn try_update( + &self, + set_order: Ordering, + fetch_order: Ordering, + f: impl FnMut(bool) -> Option, + ) -> Result { + // FIXME(atomic_try_update): this is currently an unstable alias to `fetch_update`; + // when stabilizing, turn `fetch_update` into a deprecated alias to `try_update`. + self.fetch_update(set_order, fetch_order, f) + } + + /// Fetches the value, applies a function to it that it return a new value. + /// The new value is stored and the old value is returned. + /// + /// See also: [`try_update`](`AtomicBool::try_update`). + /// + /// Note: This may call the function multiple times if the value has been changed from other threads in + /// the meantime, but the function will have been applied only once to the stored value. + /// + /// `update` takes two [`Ordering`] arguments to describe the memory + /// ordering of this operation. The first describes the required ordering for + /// when the operation finally succeeds while the second describes the + /// required ordering for loads. These correspond to the success and failure + /// orderings of [`AtomicBool::compare_exchange`] respectively. + /// + /// Using [`Acquire`] as success ordering makes the store part + /// of this operation [`Relaxed`], and using [`Release`] makes the final successful load + /// [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]. + /// + /// **Note:** This method is only available on platforms that support atomic operations on `u8`. + /// + /// # Considerations + /// + /// This method is not magic; it is not provided by the hardware. + /// It is implemented in terms of [`AtomicBool::compare_exchange_weak`], and suffers from the same drawbacks. + /// In particular, this method will not circumvent the [ABA Problem]. + /// + /// [ABA Problem]: https://en.wikipedia.org/wiki/ABA_problem + /// + /// # Examples + /// + /// ```rust + /// #![feature(atomic_try_update)] + /// + /// use std::sync::atomic::{AtomicBool, Ordering}; + /// + /// let x = AtomicBool::new(false); + /// assert_eq!(x.update(Ordering::SeqCst, Ordering::SeqCst, |x| !x), false); + /// assert_eq!(x.update(Ordering::SeqCst, Ordering::SeqCst, |x| !x), true); + /// assert_eq!(x.load(Ordering::SeqCst), false); + /// ``` + #[inline] + #[unstable(feature = "atomic_try_update", issue = "135894")] + #[cfg(target_has_atomic = "8")] + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + pub fn update( + &self, + set_order: Ordering, + fetch_order: Ordering, + mut f: impl FnMut(bool) -> bool, + ) -> bool { + let mut prev = self.load(fetch_order); + loop { + match self.compare_exchange_weak(prev, f(prev), set_order, fetch_order) { + Ok(x) => break x, + Err(next_prev) => prev = next_prev, + } + } + } } #[cfg(target_has_atomic_load_store = "ptr")] @@ -1264,7 +1390,7 @@ impl AtomicPtr { /// [valid]: crate::ptr#safety /// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses #[stable(feature = "atomic_from_ptr", since = "1.75.0")] - #[rustc_const_stable(feature = "const_atomic_from_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_atomic_from_ptr", since = "1.84.0")] pub const unsafe fn from_ptr<'a>(ptr: *mut *mut T) -> &'a AtomicPtr { // SAFETY: guaranteed by the caller unsafe { &*ptr.cast() } @@ -1532,6 +1658,12 @@ impl AtomicPtr { /// AcqRel | AcqRel | Acquire /// SeqCst | SeqCst | SeqCst /// + /// `compare_and_swap` and `compare_exchange` also differ in their return type. You can use + /// `compare_exchange(...).unwrap_or_else(|x| x)` to recover the behavior of `compare_and_swap`, + /// but in most cases it is more idiomatic to check whether the return value is `Ok` or `Err` + /// rather than to infer success vs failure based on the value that was read. + /// + /// During migration, consider whether it makes sense to use `compare_exchange_weak` instead. /// `compare_exchange_weak` is allowed to fail spuriously even when the comparison succeeds, /// which allows the compiler to generate better assembly code when the compare and swap /// is used in a loop. @@ -1684,7 +1816,7 @@ impl AtomicPtr { /// /// # Considerations /// - /// This method is not magic; it is not provided by the hardware. + /// This method is not magic; it is not provided by the hardware. /// It is implemented in terms of [`AtomicPtr::compare_exchange_weak`], and suffers from the same drawbacks. /// In particular, this method will not circumvent the [ABA Problem]. /// @@ -1732,6 +1864,137 @@ impl AtomicPtr { } Err(prev) } + /// Fetches the value, and applies a function to it that returns an optional + /// new value. Returns a `Result` of `Ok(previous_value)` if the function + /// returned `Some(_)`, else `Err(previous_value)`. + /// + /// See also: [`update`](`AtomicPtr::update`). + /// + /// Note: This may call the function multiple times if the value has been + /// changed from other threads in the meantime, as long as the function + /// returns `Some(_)`, but the function will have been applied only once to + /// the stored value. + /// + /// `try_update` takes two [`Ordering`] arguments to describe the memory + /// ordering of this operation. The first describes the required ordering for + /// when the operation finally succeeds while the second describes the + /// required ordering for loads. These correspond to the success and failure + /// orderings of [`AtomicPtr::compare_exchange`] respectively. + /// + /// Using [`Acquire`] as success ordering makes the store part of this + /// operation [`Relaxed`], and using [`Release`] makes the final successful + /// load [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], + /// [`Acquire`] or [`Relaxed`]. + /// + /// **Note:** This method is only available on platforms that support atomic + /// operations on pointers. + /// + /// # Considerations + /// + /// This method is not magic; it is not provided by the hardware. + /// It is implemented in terms of [`AtomicPtr::compare_exchange_weak`], and suffers from the same drawbacks. + /// In particular, this method will not circumvent the [ABA Problem]. + /// + /// [ABA Problem]: https://en.wikipedia.org/wiki/ABA_problem + /// + /// # Examples + /// + /// ```rust + /// #![feature(atomic_try_update)] + /// use std::sync::atomic::{AtomicPtr, Ordering}; + /// + /// let ptr: *mut _ = &mut 5; + /// let some_ptr = AtomicPtr::new(ptr); + /// + /// let new: *mut _ = &mut 10; + /// assert_eq!(some_ptr.try_update(Ordering::SeqCst, Ordering::SeqCst, |_| None), Err(ptr)); + /// let result = some_ptr.try_update(Ordering::SeqCst, Ordering::SeqCst, |x| { + /// if x == ptr { + /// Some(new) + /// } else { + /// None + /// } + /// }); + /// assert_eq!(result, Ok(ptr)); + /// assert_eq!(some_ptr.load(Ordering::SeqCst), new); + /// ``` + #[inline] + #[unstable(feature = "atomic_try_update", issue = "135894")] + #[cfg(target_has_atomic = "ptr")] + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + pub fn try_update( + &self, + set_order: Ordering, + fetch_order: Ordering, + f: impl FnMut(*mut T) -> Option<*mut T>, + ) -> Result<*mut T, *mut T> { + // FIXME(atomic_try_update): this is currently an unstable alias to `fetch_update`; + // when stabilizing, turn `fetch_update` into a deprecated alias to `try_update`. + self.fetch_update(set_order, fetch_order, f) + } + + /// Fetches the value, applies a function to it that it return a new value. + /// The new value is stored and the old value is returned. + /// + /// See also: [`try_update`](`AtomicPtr::try_update`). + /// + /// Note: This may call the function multiple times if the value has been changed from other threads in + /// the meantime, but the function will have been applied only once to the stored value. + /// + /// `update` takes two [`Ordering`] arguments to describe the memory + /// ordering of this operation. The first describes the required ordering for + /// when the operation finally succeeds while the second describes the + /// required ordering for loads. These correspond to the success and failure + /// orderings of [`AtomicPtr::compare_exchange`] respectively. + /// + /// Using [`Acquire`] as success ordering makes the store part + /// of this operation [`Relaxed`], and using [`Release`] makes the final successful load + /// [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]. + /// + /// **Note:** This method is only available on platforms that support atomic + /// operations on pointers. + /// + /// # Considerations + /// + /// This method is not magic; it is not provided by the hardware. + /// It is implemented in terms of [`AtomicPtr::compare_exchange_weak`], and suffers from the same drawbacks. + /// In particular, this method will not circumvent the [ABA Problem]. + /// + /// [ABA Problem]: https://en.wikipedia.org/wiki/ABA_problem + /// + /// # Examples + /// + /// ```rust + /// #![feature(atomic_try_update)] + /// + /// use std::sync::atomic::{AtomicPtr, Ordering}; + /// + /// let ptr: *mut _ = &mut 5; + /// let some_ptr = AtomicPtr::new(ptr); + /// + /// let new: *mut _ = &mut 10; + /// let result = some_ptr.update(Ordering::SeqCst, Ordering::SeqCst, |_| new); + /// assert_eq!(result, ptr); + /// assert_eq!(some_ptr.load(Ordering::SeqCst), new); + /// ``` + #[inline] + #[unstable(feature = "atomic_try_update", issue = "135894")] + #[cfg(target_has_atomic = "8")] + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + pub fn update( + &self, + set_order: Ordering, + fetch_order: Ordering, + mut f: impl FnMut(*mut T) -> *mut T, + ) -> *mut T { + let mut prev = self.load(fetch_order); + loop { + match self.compare_exchange_weak(prev, f(prev), set_order, fetch_order) { + Ok(x) => break x, + Err(next_prev) => prev = next_prev, + } + } + } /// Offsets the pointer's address by adding `val` (in units of `T`), /// returning the previous pointer. @@ -1771,7 +2034,7 @@ impl AtomicPtr { #[unstable(feature = "strict_provenance_atomic_ptr", issue = "99108")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn fetch_ptr_add(&self, val: usize, order: Ordering) -> *mut T { - self.fetch_byte_add(val.wrapping_mul(core::mem::size_of::()), order) + self.fetch_byte_add(val.wrapping_mul(size_of::()), order) } /// Offsets the pointer's address by subtracting `val` (in units of `T`), @@ -1816,7 +2079,7 @@ impl AtomicPtr { #[unstable(feature = "strict_provenance_atomic_ptr", issue = "99108")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn fetch_ptr_sub(&self, val: usize, order: Ordering) -> *mut T { - self.fetch_byte_sub(val.wrapping_mul(core::mem::size_of::()), order) + self.fetch_byte_sub(val.wrapping_mul(size_of::()), order) } /// Offsets the pointer's address by adding `val` *bytes*, returning the @@ -2263,7 +2526,7 @@ macro_rules! atomic_int { /// [valid]: crate::ptr#safety /// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses #[stable(feature = "atomic_from_ptr", since = "1.75.0")] - #[rustc_const_stable(feature = "const_atomic_from_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_atomic_from_ptr", since = "1.84.0")] pub const unsafe fn from_ptr<'a>(ptr: *mut $int_type) -> &'a $atomic_type { // SAFETY: guaranteed by the caller unsafe { &*ptr.cast() } @@ -2297,7 +2560,7 @@ macro_rules! atomic_int { $int_type, no = [ "**Note:** This function is only available on targets where `", - stringify!($int_type), "` has an alignment of ", $align, " bytes." + stringify!($atomic_type), "` has the same alignment as `", stringify!($int_type), "`." ], }] /// @@ -2521,6 +2784,12 @@ macro_rules! atomic_int { /// AcqRel | AcqRel | Acquire /// SeqCst | SeqCst | SeqCst /// + /// `compare_and_swap` and `compare_exchange` also differ in their return type. You can use + /// `compare_exchange(...).unwrap_or_else(|x| x)` to recover the behavior of `compare_and_swap`, + /// but in most cases it is more idiomatic to check whether the return value is `Ok` or `Err` + /// rather than to infer success vs failure based on the value that was read. + /// + /// During migration, consider whether it makes sense to use `compare_exchange_weak` instead. /// `compare_exchange_weak` is allowed to fail spuriously even when the comparison succeeds, /// which allows the compiler to generate better assembly code when the compare and swap /// is used in a loop. @@ -2875,7 +3144,7 @@ macro_rules! atomic_int { /// /// # Considerations /// - /// This method is not magic; it is not provided by the hardware. + /// This method is not magic; it is not provided by the hardware. /// It is implemented in terms of #[doc = concat!("[`", stringify!($atomic_type), "::compare_exchange_weak`],")] /// and suffers from the same drawbacks. @@ -2913,6 +3182,127 @@ macro_rules! atomic_int { Err(prev) } + /// Fetches the value, and applies a function to it that returns an optional + /// new value. Returns a `Result` of `Ok(previous_value)` if the function returned `Some(_)`, else + /// `Err(previous_value)`. + /// + #[doc = concat!("See also: [`update`](`", stringify!($atomic_type), "::update`).")] + /// + /// Note: This may call the function multiple times if the value has been changed from other threads in + /// the meantime, as long as the function returns `Some(_)`, but the function will have been applied + /// only once to the stored value. + /// + /// `try_update` takes two [`Ordering`] arguments to describe the memory ordering of this operation. + /// The first describes the required ordering for when the operation finally succeeds while the second + /// describes the required ordering for loads. These correspond to the success and failure orderings of + #[doc = concat!("[`", stringify!($atomic_type), "::compare_exchange`]")] + /// respectively. + /// + /// Using [`Acquire`] as success ordering makes the store part + /// of this operation [`Relaxed`], and using [`Release`] makes the final successful load + /// [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]. + /// + /// **Note**: This method is only available on platforms that support atomic operations on + #[doc = concat!("[`", $s_int_type, "`].")] + /// + /// # Considerations + /// + /// This method is not magic; it is not provided by the hardware. + /// It is implemented in terms of + #[doc = concat!("[`", stringify!($atomic_type), "::compare_exchange_weak`],")] + /// and suffers from the same drawbacks. + /// In particular, this method will not circumvent the [ABA Problem]. + /// + /// [ABA Problem]: https://en.wikipedia.org/wiki/ABA_problem + /// + /// # Examples + /// + /// ```rust + /// #![feature(atomic_try_update)] + #[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")] + /// + #[doc = concat!("let x = ", stringify!($atomic_type), "::new(7);")] + /// assert_eq!(x.try_update(Ordering::SeqCst, Ordering::SeqCst, |_| None), Err(7)); + /// assert_eq!(x.try_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(x + 1)), Ok(7)); + /// assert_eq!(x.try_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(x + 1)), Ok(8)); + /// assert_eq!(x.load(Ordering::SeqCst), 9); + /// ``` + #[inline] + #[unstable(feature = "atomic_try_update", issue = "135894")] + #[$cfg_cas] + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + pub fn try_update( + &self, + set_order: Ordering, + fetch_order: Ordering, + f: impl FnMut($int_type) -> Option<$int_type>, + ) -> Result<$int_type, $int_type> { + // FIXME(atomic_try_update): this is currently an unstable alias to `fetch_update`; + // when stabilizing, turn `fetch_update` into a deprecated alias to `try_update`. + self.fetch_update(set_order, fetch_order, f) + } + + /// Fetches the value, applies a function to it that it return a new value. + /// The new value is stored and the old value is returned. + /// + #[doc = concat!("See also: [`try_update`](`", stringify!($atomic_type), "::try_update`).")] + /// + /// Note: This may call the function multiple times if the value has been changed from other threads in + /// the meantime, but the function will have been applied only once to the stored value. + /// + /// `update` takes two [`Ordering`] arguments to describe the memory ordering of this operation. + /// The first describes the required ordering for when the operation finally succeeds while the second + /// describes the required ordering for loads. These correspond to the success and failure orderings of + #[doc = concat!("[`", stringify!($atomic_type), "::compare_exchange`]")] + /// respectively. + /// + /// Using [`Acquire`] as success ordering makes the store part + /// of this operation [`Relaxed`], and using [`Release`] makes the final successful load + /// [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]. + /// + /// **Note**: This method is only available on platforms that support atomic operations on + #[doc = concat!("[`", $s_int_type, "`].")] + /// + /// # Considerations + /// + /// This method is not magic; it is not provided by the hardware. + /// It is implemented in terms of + #[doc = concat!("[`", stringify!($atomic_type), "::compare_exchange_weak`],")] + /// and suffers from the same drawbacks. + /// In particular, this method will not circumvent the [ABA Problem]. + /// + /// [ABA Problem]: https://en.wikipedia.org/wiki/ABA_problem + /// + /// # Examples + /// + /// ```rust + /// #![feature(atomic_try_update)] + #[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")] + /// + #[doc = concat!("let x = ", stringify!($atomic_type), "::new(7);")] + /// assert_eq!(x.update(Ordering::SeqCst, Ordering::SeqCst, |x| x + 1), 7); + /// assert_eq!(x.update(Ordering::SeqCst, Ordering::SeqCst, |x| x + 1), 8); + /// assert_eq!(x.load(Ordering::SeqCst), 9); + /// ``` + #[inline] + #[unstable(feature = "atomic_try_update", issue = "135894")] + #[$cfg_cas] + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + pub fn update( + &self, + set_order: Ordering, + fetch_order: Ordering, + mut f: impl FnMut($int_type) -> $int_type, + ) -> $int_type { + let mut prev = self.load(fetch_order); + loop { + match self.compare_exchange_weak(prev, f(prev), set_order, fetch_order) { + Ok(x) => break x, + Err(next_prev) => prev = next_prev, + } + } + } + /// Maximum with the current value. /// /// Finds the maximum of the current value and the argument `val`, and @@ -3608,24 +3998,24 @@ unsafe fn atomic_umin(dst: *mut T, val: T, order: Ordering) -> T { /// /// A fence 'A' which has (at least) [`Release`] ordering semantics, synchronizes /// with a fence 'B' with (at least) [`Acquire`] semantics, if and only if there -/// exist operations X and Y, both operating on some atomic object 'M' such +/// exist operations X and Y, both operating on some atomic object 'm' such /// that A is sequenced before X, Y is sequenced before B and Y observes -/// the change to M. This provides a happens-before dependence between A and B. +/// the change to m. This provides a happens-before dependence between A and B. /// /// ```text /// Thread 1 Thread 2 /// /// fence(Release); A -------------- -/// x.store(3, Relaxed); X --------- | +/// m.store(3, Relaxed); X --------- | /// | | /// | | -/// -------------> Y if x.load(Relaxed) == 3 { +/// -------------> Y if m.load(Relaxed) == 3 { /// |-------> B fence(Acquire); /// ... /// } /// ``` /// -/// Note that in the example above, it is crucial that the accesses to `x` are atomic. Fences cannot +/// Note that in the example above, it is crucial that the accesses to `m` are atomic. Fences cannot /// be used to establish synchronization among non-atomic accesses in different threads. However, /// thanks to the happens-before relationship between A and B, any non-atomic accesses that /// happen-before A are now also properly synchronized with any non-atomic accesses that @@ -3727,33 +4117,33 @@ pub fn fence(order: Ordering) { /// /// # Examples /// -/// Without `compiler_fence`, the `assert_eq!` in following code -/// is *not* guaranteed to succeed, despite everything happening in a single thread. -/// To see why, remember that the compiler is free to swap the stores to -/// `IMPORTANT_VARIABLE` and `IS_READY` since they are both -/// `Ordering::Relaxed`. If it does, and the signal handler is invoked right -/// after `IS_READY` is updated, then the signal handler will see -/// `IS_READY=1`, but `IMPORTANT_VARIABLE=0`. -/// Using a `compiler_fence` remedies this situation. +/// Without the two `compiler_fence` calls, the read of `IMPORTANT_VARIABLE` in `signal_handler` +/// is *undefined behavior* due to a data race, despite everything happening in a single thread. +/// This is because the signal handler is considered to run concurrently with its associated +/// thread, and explicit synchronization is required to pass data between a thread and its +/// signal handler. The code below uses two `compiler_fence` calls to establish the usual +/// release-acquire synchronization pattern (see [`fence`] for an image). /// /// ``` -/// use std::sync::atomic::{AtomicBool, AtomicUsize}; +/// use std::sync::atomic::AtomicBool; /// use std::sync::atomic::Ordering; /// use std::sync::atomic::compiler_fence; /// -/// static IMPORTANT_VARIABLE: AtomicUsize = AtomicUsize::new(0); +/// static mut IMPORTANT_VARIABLE: usize = 0; /// static IS_READY: AtomicBool = AtomicBool::new(false); /// /// fn main() { -/// IMPORTANT_VARIABLE.store(42, Ordering::Relaxed); -/// // prevent earlier writes from being moved beyond this point +/// unsafe { IMPORTANT_VARIABLE = 42 }; +/// // Marks earlier writes as being released with future relaxed stores. /// compiler_fence(Ordering::Release); /// IS_READY.store(true, Ordering::Relaxed); /// } /// /// fn signal_handler() { /// if IS_READY.load(Ordering::Relaxed) { -/// assert_eq!(IMPORTANT_VARIABLE.load(Ordering::Relaxed), 42); +/// // Acquires writes that were released with relaxed stores that we read from. +/// compiler_fence(Ordering::Acquire); +/// assert_eq!(unsafe { IMPORTANT_VARIABLE }, 42); /// } /// } /// ``` diff --git a/core/src/task/wake.rs b/core/src/task/wake.rs index 34673707f010a..3f57b04753a6b 100644 --- a/core/src/task/wake.rs +++ b/core/src/task/wake.rs @@ -40,17 +40,14 @@ impl RawWaker { /// of the `vtable` as the first parameter. /// /// It is important to consider that the `data` pointer must point to a - /// thread safe type such as an `[Arc]` + /// thread safe type such as an `Arc` /// when used to construct a [`Waker`]. This restriction is lifted when /// constructing a [`LocalWaker`], which allows using types that do not implement - /// [Send] + [Sync] like `[Rc]`. + /// [Send] + [Sync] like `Rc`. /// /// The `vtable` customizes the behavior of a `Waker` which gets created /// from a `RawWaker`. For each operation on the `Waker`, the associated /// function in the `vtable` of the underlying `RawWaker` will be called. - /// - /// [`Arc`]: std::sync::Arc - /// [`Rc`]: std::rc::Rc #[inline] #[rustc_promotable] #[stable(feature = "futures_api", since = "1.36.0")] @@ -60,7 +57,7 @@ impl RawWaker { RawWaker { data, vtable } } - #[unstable(feature = "noop_waker", issue = "98286")] + #[stable(feature = "noop_waker", since = "1.85.0")] const NOOP: RawWaker = { const VTABLE: RawWakerVTable = RawWakerVTable::new( // Cloning just returns a new no-op raw waker @@ -283,7 +280,6 @@ impl fmt::Debug for Context<'_> { /// # Examples /// ``` /// #![feature(local_waker)] -/// #![feature(noop_waker)] /// use std::task::{ContextBuilder, LocalWaker, Waker, Poll}; /// use std::future::Future; /// @@ -319,12 +315,11 @@ impl<'a> ContextBuilder<'a> { /// Creates a ContextBuilder from a Waker. #[inline] #[unstable(feature = "local_waker", issue = "118959")] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_waker", since = "1.82.0"))] pub const fn from_waker(waker: &'a Waker) -> Self { // SAFETY: LocalWaker is just Waker without thread safety let local_waker = unsafe { transmute(waker) }; Self { - waker: waker, + waker, local_waker, ext: ExtData::None(()), _marker: PhantomData, @@ -373,7 +368,6 @@ impl<'a> ContextBuilder<'a> { /// Builds the `Context`. #[inline] #[unstable(feature = "local_waker", issue = "118959")] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_waker", since = "1.82.0"))] pub const fn build(self) -> Context<'a> { let ContextBuilder { waker, local_waker, ext, _marker, _marker2 } = self; Context { waker, local_waker, ext: AssertUnwindSafe(ext), _marker, _marker2 } @@ -557,8 +551,6 @@ impl Waker { /// # Examples /// /// ``` - /// #![feature(noop_waker)] - /// /// use std::future::Future; /// use std::task; /// @@ -569,7 +561,8 @@ impl Waker { /// ``` #[inline] #[must_use] - #[unstable(feature = "noop_waker", issue = "98286")] + #[stable(feature = "noop_waker", since = "1.85.0")] + #[rustc_const_stable(feature = "noop_waker", since = "1.85.0")] pub const fn noop() -> &'static Waker { const WAKER: &Waker = &Waker { waker: RawWaker::NOOP }; WAKER @@ -852,8 +845,6 @@ impl LocalWaker { /// /// ``` /// #![feature(local_waker)] - /// #![feature(noop_waker)] - /// /// use std::future::Future; /// use std::task::{ContextBuilder, LocalWaker, Waker, Poll}; /// @@ -866,7 +857,7 @@ impl LocalWaker { /// ``` #[inline] #[must_use] - #[unstable(feature = "noop_waker", issue = "98286")] + #[unstable(feature = "local_waker", issue = "118959")] pub const fn noop() -> &'static LocalWaker { const WAKER: &LocalWaker = &LocalWaker { waker: RawWaker::NOOP }; WAKER diff --git a/core/src/time.rs b/core/src/time.rs index 2d93148bac09f..37b5c1076fa2a 100644 --- a/core/src/time.rs +++ b/core/src/time.rs @@ -21,6 +21,7 @@ use crate::fmt; use crate::iter::Sum; +use crate::num::niche_types::Nanoseconds; use crate::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; const NANOS_PER_SEC: u32 = 1_000_000_000; @@ -37,24 +38,6 @@ const HOURS_PER_DAY: u64 = 24; #[unstable(feature = "duration_units", issue = "120301")] const DAYS_PER_WEEK: u64 = 7; -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(0)] -#[rustc_layout_scalar_valid_range_end(999_999_999)] -struct Nanoseconds(u32); - -impl Nanoseconds { - // SAFETY: 0 is within the valid range - const ZERO: Self = unsafe { Nanoseconds(0) }; -} - -impl Default for Nanoseconds { - #[inline] - fn default() -> Self { - Self::ZERO - } -} - /// A `Duration` type to represent a span of time, typically used for system /// timeouts. /// @@ -211,14 +194,14 @@ impl Duration { pub const fn new(secs: u64, nanos: u32) -> Duration { if nanos < NANOS_PER_SEC { // SAFETY: nanos < NANOS_PER_SEC, therefore nanos is within the valid range - Duration { secs, nanos: unsafe { Nanoseconds(nanos) } } + Duration { secs, nanos: unsafe { Nanoseconds::new_unchecked(nanos) } } } else { let secs = secs .checked_add((nanos / NANOS_PER_SEC) as u64) .expect("overflow in Duration::new"); let nanos = nanos % NANOS_PER_SEC; // SAFETY: nanos % NANOS_PER_SEC < NANOS_PER_SEC, therefore nanos is within the valid range - Duration { secs, nanos: unsafe { Nanoseconds(nanos) } } + Duration { secs, nanos: unsafe { Nanoseconds::new_unchecked(nanos) } } } } @@ -263,7 +246,7 @@ impl Duration { let subsec_millis = (millis % MILLIS_PER_SEC) as u32; // SAFETY: (x % 1_000) * 1_000_000 < 1_000_000_000 // => x % 1_000 < 1_000 - let subsec_nanos = unsafe { Nanoseconds(subsec_millis * NANOS_PER_MILLI) }; + let subsec_nanos = unsafe { Nanoseconds::new_unchecked(subsec_millis * NANOS_PER_MILLI) }; Duration { secs, nanos: subsec_nanos } } @@ -289,7 +272,7 @@ impl Duration { let subsec_micros = (micros % MICROS_PER_SEC) as u32; // SAFETY: (x % 1_000_000) * 1_000 < 1_000_000_000 // => x % 1_000_000 < 1_000_000 - let subsec_nanos = unsafe { Nanoseconds(subsec_micros * NANOS_PER_MICRO) }; + let subsec_nanos = unsafe { Nanoseconds::new_unchecked(subsec_micros * NANOS_PER_MICRO) }; Duration { secs, nanos: subsec_nanos } } @@ -320,7 +303,7 @@ impl Duration { let secs = nanos / NANOS_PER_SEC; let subsec_nanos = (nanos % NANOS_PER_SEC) as u32; // SAFETY: x % 1_000_000_000 < 1_000_000_000 - let subsec_nanos = unsafe { Nanoseconds(subsec_nanos) }; + let subsec_nanos = unsafe { Nanoseconds::new_unchecked(subsec_nanos) }; Duration { secs, nanos: subsec_nanos } } @@ -458,7 +441,7 @@ impl Duration { #[rustc_const_stable(feature = "duration_zero", since = "1.53.0")] #[inline] pub const fn is_zero(&self) -> bool { - self.secs == 0 && self.nanos.0 == 0 + self.secs == 0 && self.nanos.as_inner() == 0 } /// Returns the number of _whole_ seconds contained by this `Duration`. @@ -509,7 +492,7 @@ impl Duration { #[must_use] #[inline] pub const fn subsec_millis(&self) -> u32 { - self.nanos.0 / NANOS_PER_MILLI + self.nanos.as_inner() / NANOS_PER_MILLI } /// Returns the fractional part of this `Duration`, in whole microseconds. @@ -532,7 +515,7 @@ impl Duration { #[must_use] #[inline] pub const fn subsec_micros(&self) -> u32 { - self.nanos.0 / NANOS_PER_MICRO + self.nanos.as_inner() / NANOS_PER_MICRO } /// Returns the fractional part of this `Duration`, in nanoseconds. @@ -555,7 +538,7 @@ impl Duration { #[must_use] #[inline] pub const fn subsec_nanos(&self) -> u32 { - self.nanos.0 + self.nanos.as_inner() } /// Returns the total number of whole milliseconds contained by this `Duration`. @@ -573,7 +556,8 @@ impl Duration { #[must_use] #[inline] pub const fn as_millis(&self) -> u128 { - self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos.0 / NANOS_PER_MILLI) as u128 + self.secs as u128 * MILLIS_PER_SEC as u128 + + (self.nanos.as_inner() / NANOS_PER_MILLI) as u128 } /// Returns the total number of whole microseconds contained by this `Duration`. @@ -591,7 +575,8 @@ impl Duration { #[must_use] #[inline] pub const fn as_micros(&self) -> u128 { - self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos.0 / NANOS_PER_MICRO) as u128 + self.secs as u128 * MICROS_PER_SEC as u128 + + (self.nanos.as_inner() / NANOS_PER_MICRO) as u128 } /// Returns the total number of nanoseconds contained by this `Duration`. @@ -609,7 +594,7 @@ impl Duration { #[must_use] #[inline] pub const fn as_nanos(&self) -> u128 { - self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos.0 as u128 + self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos.as_inner() as u128 } /// Computes the absolute difference between `self` and `other`. @@ -649,7 +634,7 @@ impl Duration { #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] pub const fn checked_add(self, rhs: Duration) -> Option { if let Some(mut secs) = self.secs.checked_add(rhs.secs) { - let mut nanos = self.nanos.0 + rhs.nanos.0; + let mut nanos = self.nanos.as_inner() + rhs.nanos.as_inner(); if nanos >= NANOS_PER_SEC { nanos -= NANOS_PER_SEC; if let Some(new_secs) = secs.checked_add(1) { @@ -707,11 +692,11 @@ impl Duration { #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] pub const fn checked_sub(self, rhs: Duration) -> Option { if let Some(mut secs) = self.secs.checked_sub(rhs.secs) { - let nanos = if self.nanos.0 >= rhs.nanos.0 { - self.nanos.0 - rhs.nanos.0 + let nanos = if self.nanos.as_inner() >= rhs.nanos.as_inner() { + self.nanos.as_inner() - rhs.nanos.as_inner() } else if let Some(sub_secs) = secs.checked_sub(1) { secs = sub_secs; - self.nanos.0 + NANOS_PER_SEC - rhs.nanos.0 + self.nanos.as_inner() + NANOS_PER_SEC - rhs.nanos.as_inner() } else { return None; }; @@ -763,7 +748,7 @@ impl Duration { #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] pub const fn checked_mul(self, rhs: u32) -> Option { // Multiply nanoseconds as u64, because it cannot overflow that way. - let total_nanos = self.nanos.0 as u64 * rhs as u64; + let total_nanos = self.nanos.as_inner() as u64 * rhs as u64; let extra_secs = total_nanos / (NANOS_PER_SEC as u64); let nanos = (total_nanos % (NANOS_PER_SEC as u64)) as u32; // FIXME(const-hack): use `and_then` once that is possible. @@ -820,7 +805,8 @@ impl Duration { pub const fn checked_div(self, rhs: u32) -> Option { if rhs != 0 { let (secs, extra_secs) = (self.secs / (rhs as u64), self.secs % (rhs as u64)); - let (mut nanos, extra_nanos) = (self.nanos.0 / rhs, self.nanos.0 % rhs); + let (mut nanos, extra_nanos) = + (self.nanos.as_inner() / rhs, self.nanos.as_inner() % rhs); nanos += ((extra_secs * (NANOS_PER_SEC as u64) + extra_nanos as u64) / (rhs as u64)) as u32; debug_assert!(nanos < NANOS_PER_SEC); @@ -846,7 +832,7 @@ impl Duration { #[inline] #[rustc_const_stable(feature = "duration_consts_float", since = "1.83.0")] pub const fn as_secs_f64(&self) -> f64 { - (self.secs as f64) + (self.nanos.0 as f64) / (NANOS_PER_SEC as f64) + (self.secs as f64) + (self.nanos.as_inner() as f64) / (NANOS_PER_SEC as f64) } /// Returns the number of seconds contained by this `Duration` as `f32`. @@ -865,7 +851,7 @@ impl Duration { #[inline] #[rustc_const_stable(feature = "duration_consts_float", since = "1.83.0")] pub const fn as_secs_f32(&self) -> f32 { - (self.secs as f32) + (self.nanos.0 as f32) / (NANOS_PER_SEC as f32) + (self.secs as f32) + (self.nanos.as_inner() as f32) / (NANOS_PER_SEC as f32) } /// Returns the number of milliseconds contained by this `Duration` as `f64`. @@ -885,7 +871,7 @@ impl Duration { #[inline] pub const fn as_millis_f64(&self) -> f64 { (self.secs as f64) * (MILLIS_PER_SEC as f64) - + (self.nanos.0 as f64) / (NANOS_PER_MILLI as f64) + + (self.nanos.as_inner() as f64) / (NANOS_PER_MILLI as f64) } /// Returns the number of milliseconds contained by this `Duration` as `f32`. @@ -905,7 +891,7 @@ impl Duration { #[inline] pub const fn as_millis_f32(&self) -> f32 { (self.secs as f32) * (MILLIS_PER_SEC as f32) - + (self.nanos.0 as f32) / (NANOS_PER_MILLI as f32) + + (self.nanos.as_inner() as f32) / (NANOS_PER_MILLI as f32) } /// Creates a new `Duration` from the specified number of seconds represented @@ -1084,8 +1070,9 @@ impl Duration { #[inline] #[rustc_const_stable(feature = "duration_consts_float", since = "1.83.0")] pub const fn div_duration_f64(self, rhs: Duration) -> f64 { - let self_nanos = (self.secs as f64) * (NANOS_PER_SEC as f64) + (self.nanos.0 as f64); - let rhs_nanos = (rhs.secs as f64) * (NANOS_PER_SEC as f64) + (rhs.nanos.0 as f64); + let self_nanos = + (self.secs as f64) * (NANOS_PER_SEC as f64) + (self.nanos.as_inner() as f64); + let rhs_nanos = (rhs.secs as f64) * (NANOS_PER_SEC as f64) + (rhs.nanos.as_inner() as f64); self_nanos / rhs_nanos } @@ -1105,8 +1092,9 @@ impl Duration { #[inline] #[rustc_const_stable(feature = "duration_consts_float", since = "1.83.0")] pub const fn div_duration_f32(self, rhs: Duration) -> f32 { - let self_nanos = (self.secs as f32) * (NANOS_PER_SEC as f32) + (self.nanos.0 as f32); - let rhs_nanos = (rhs.secs as f32) * (NANOS_PER_SEC as f32) + (rhs.nanos.0 as f32); + let self_nanos = + (self.secs as f32) * (NANOS_PER_SEC as f32) + (self.nanos.as_inner() as f32); + let rhs_nanos = (rhs.secs as f32) * (NANOS_PER_SEC as f32) + (rhs.nanos.as_inner() as f32); self_nanos / rhs_nanos } } @@ -1180,6 +1168,7 @@ impl Div for Duration { type Output = Duration; #[inline] + #[track_caller] fn div(self, rhs: u32) -> Duration { self.checked_div(rhs).expect("divide by zero error when dividing duration by scalar") } @@ -1188,6 +1177,7 @@ impl Div for Duration { #[stable(feature = "time_augmented_assignment", since = "1.9.0")] impl DivAssign for Duration { #[inline] + #[track_caller] fn div_assign(&mut self, rhs: u32) { *self = *self / rhs; } @@ -1201,13 +1191,13 @@ macro_rules! sum_durations { for entry in $iter { total_secs = total_secs.checked_add(entry.secs).expect("overflow in iter::sum over durations"); - total_nanos = match total_nanos.checked_add(entry.nanos.0 as u64) { + total_nanos = match total_nanos.checked_add(entry.nanos.as_inner() as u64) { Some(n) => n, None => { total_secs = total_secs .checked_add(total_nanos / NANOS_PER_SEC as u64) .expect("overflow in iter::sum over durations"); - (total_nanos % NANOS_PER_SEC as u64) + entry.nanos.0 as u64 + (total_nanos % NANOS_PER_SEC as u64) + entry.nanos.as_inner() as u64 } }; } @@ -1387,7 +1377,8 @@ impl fmt::Debug for Duration { } else { // We need to add padding. Use the `Formatter::padding` helper function. let default_align = fmt::Alignment::Left; - let post_padding = f.padding(requested_w - actual_w, default_align)?; + let post_padding = + f.padding((requested_w - actual_w) as u16, default_align)?; emit_without_padding(f)?; post_padding.write(f) } @@ -1399,27 +1390,27 @@ impl fmt::Debug for Duration { let prefix = if f.sign_plus() { "+" } else { "" }; if self.secs > 0 { - fmt_decimal(f, self.secs, self.nanos.0, NANOS_PER_SEC / 10, prefix, "s") - } else if self.nanos.0 >= NANOS_PER_MILLI { + fmt_decimal(f, self.secs, self.nanos.as_inner(), NANOS_PER_SEC / 10, prefix, "s") + } else if self.nanos.as_inner() >= NANOS_PER_MILLI { fmt_decimal( f, - (self.nanos.0 / NANOS_PER_MILLI) as u64, - self.nanos.0 % NANOS_PER_MILLI, + (self.nanos.as_inner() / NANOS_PER_MILLI) as u64, + self.nanos.as_inner() % NANOS_PER_MILLI, NANOS_PER_MILLI / 10, prefix, "ms", ) - } else if self.nanos.0 >= NANOS_PER_MICRO { + } else if self.nanos.as_inner() >= NANOS_PER_MICRO { fmt_decimal( f, - (self.nanos.0 / NANOS_PER_MICRO) as u64, - self.nanos.0 % NANOS_PER_MICRO, + (self.nanos.as_inner() / NANOS_PER_MICRO) as u64, + self.nanos.as_inner() % NANOS_PER_MICRO, NANOS_PER_MICRO / 10, prefix, "µs", ) } else { - fmt_decimal(f, self.nanos.0 as u64, 0, 1, prefix, "ns") + fmt_decimal(f, self.nanos.as_inner() as u64, 0, 1, prefix, "ns") } } } diff --git a/core/src/ub_checks.rs b/core/src/ub_checks.rs index 3e6110c9c88a7..9eb71922218f3 100644 --- a/core/src/ub_checks.rs +++ b/core/src/ub_checks.rs @@ -47,7 +47,6 @@ use crate::intrinsics::{self, const_eval_select}; /// order to call it. Since the precompiled standard library is built with full debuginfo and these /// variables cannot be optimized out in MIR, an innocent-looking `let` can produce enough /// debuginfo to have a measurable compile-time impact on debug builds. -#[cfg_attr(bootstrap, allow_internal_unstable(const_ub_checks))] // permit this to be called in stably-const fn #[macro_export] #[unstable(feature = "ub_checks", issue = "none")] macro_rules! assert_unsafe_precondition { @@ -66,9 +65,9 @@ macro_rules! assert_unsafe_precondition { #[rustc_nounwind] const fn precondition_check($($name:$ty),*) { if !$e { - ::core::panicking::panic_nounwind( - concat!("unsafe precondition(s) violated: ", $message) - ); + ::core::panicking::panic_nounwind(concat!("unsafe precondition(s) violated: ", $message, + "\n\nThis indicates a bug in the program. \ + This Undefined Behavior check is optional, and cannot be relied on for safety.")); } } @@ -89,7 +88,6 @@ pub use intrinsics::ub_checks as check_library_ub; /// /// The intention is to not do that when running in the interpreter, as that one has its own /// language UB checks which generally produce better errors. -#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_ub_checks", issue = "none"))] #[inline] #[rustc_allow_const_fn_unstable(const_eval_select)] pub(crate) const fn check_language_ub() -> bool { diff --git a/core/src/unicode/mod.rs b/core/src/unicode/mod.rs index 6066aa9921607..49dbdeb1a6d1c 100644 --- a/core/src/unicode/mod.rs +++ b/core/src/unicode/mod.rs @@ -17,6 +17,8 @@ pub(crate) use unicode_data::uppercase::lookup as Uppercase; pub(crate) use unicode_data::white_space::lookup as White_Space; pub(crate) mod printable; + +#[allow(unreachable_pub)] mod unicode_data; /// The version of [Unicode](https://www.unicode.org/) that the Unicode parts of diff --git a/core/src/unicode/printable.py b/core/src/unicode/printable.py index 4d39ace066c46..260fa9f9e6ad2 100755 --- a/core/src/unicode/printable.py +++ b/core/src/unicode/printable.py @@ -9,7 +9,8 @@ import os import subprocess -NUM_CODEPOINTS=0x110000 +NUM_CODEPOINTS = 0x110000 + def to_ranges(iter): current = None @@ -23,11 +24,15 @@ def to_ranges(iter): if current is not None: yield tuple(current) + def get_escaped(codepoints): for c in codepoints: - if (c.class_ or "Cn") in "Cc Cf Cs Co Cn Zl Zp Zs".split() and c.value != ord(' '): + if (c.class_ or "Cn") in "Cc Cf Cs Co Cn Zl Zp Zs".split() and c.value != ord( + " " + ): yield c.value + def get_file(f): try: return open(os.path.basename(f)) @@ -35,7 +40,9 @@ def get_file(f): subprocess.run(["curl", "-O", f], check=True) return open(os.path.basename(f)) -Codepoint = namedtuple('Codepoint', 'value class_') + +Codepoint = namedtuple("Codepoint", "value class_") + def get_codepoints(f): r = csv.reader(f, delimiter=";") @@ -66,13 +73,14 @@ def get_codepoints(f): for c in range(prev_codepoint + 1, NUM_CODEPOINTS): yield Codepoint(c, None) + def compress_singletons(singletons): - uppers = [] # (upper, # items in lowers) + uppers = [] # (upper, # items in lowers) lowers = [] for i in singletons: upper = i >> 8 - lower = i & 0xff + lower = i & 0xFF if len(uppers) == 0 or uppers[-1][0] != upper: uppers.append((upper, 1)) else: @@ -82,10 +90,11 @@ def compress_singletons(singletons): return uppers, lowers + def compress_normal(normal): # lengths 0x00..0x7f are encoded as 00, 01, ..., 7e, 7f # lengths 0x80..0x7fff are encoded as 80 80, 80 81, ..., ff fe, ff ff - compressed = [] # [truelen, (truelenaux), falselen, (falselenaux)] + compressed = [] # [truelen, (truelenaux), falselen, (falselenaux)] prev_start = 0 for start, count in normal: @@ -95,21 +104,22 @@ def compress_normal(normal): assert truelen < 0x8000 and falselen < 0x8000 entry = [] - if truelen > 0x7f: + if truelen > 0x7F: entry.append(0x80 | (truelen >> 8)) - entry.append(truelen & 0xff) + entry.append(truelen & 0xFF) else: - entry.append(truelen & 0x7f) - if falselen > 0x7f: + entry.append(truelen & 0x7F) + if falselen > 0x7F: entry.append(0x80 | (falselen >> 8)) - entry.append(falselen & 0xff) + entry.append(falselen & 0xFF) else: - entry.append(falselen & 0x7f) + entry.append(falselen & 0x7F) compressed.append(entry) return compressed + def print_singletons(uppers, lowers, uppersname, lowersname): print("#[rustfmt::skip]") print("const {}: &[(u8, u8)] = &[".format(uppersname)) @@ -119,9 +129,12 @@ def print_singletons(uppers, lowers, uppersname, lowersname): print("#[rustfmt::skip]") print("const {}: &[u8] = &[".format(lowersname)) for i in range(0, len(lowers), 8): - print(" {}".format(" ".join("{:#04x},".format(x) for x in lowers[i:i+8]))) + print( + " {}".format(" ".join("{:#04x},".format(x) for x in lowers[i : i + 8])) + ) print("];") + def print_normal(normal, normalname): print("#[rustfmt::skip]") print("const {}: &[u8] = &[".format(normalname)) @@ -129,12 +142,13 @@ def print_normal(normal, normalname): print(" {}".format(" ".join("{:#04x},".format(i) for i in v))) print("];") + def main(): file = get_file("https://www.unicode.org/Public/UNIDATA/UnicodeData.txt") codepoints = get_codepoints(file) - CUTOFF=0x10000 + CUTOFF = 0x10000 singletons0 = [] singletons1 = [] normal0 = [] @@ -234,10 +248,11 @@ def main(): }\ """) print() - print_singletons(singletons0u, singletons0l, 'SINGLETONS0U', 'SINGLETONS0L') - print_singletons(singletons1u, singletons1l, 'SINGLETONS1U', 'SINGLETONS1L') - print_normal(normal0, 'NORMAL0') - print_normal(normal1, 'NORMAL1') + print_singletons(singletons0u, singletons0l, "SINGLETONS0U", "SINGLETONS0L") + print_singletons(singletons1u, singletons1l, "SINGLETONS1U", "SINGLETONS1L") + print_normal(normal0, "NORMAL0") + print_normal(normal1, "NORMAL1") + -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/core/src/unicode/unicode_data.rs b/core/src/unicode/unicode_data.rs index 7f4826402eb53..4655d35e9c437 100644 --- a/core/src/unicode/unicode_data.rs +++ b/core/src/unicode/unicode_data.rs @@ -1,7 +1,6 @@ ///! This file is generated by `./x run src/tools/unicode-table-generator`; do not edit manually! #[inline(always)] -#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_unicode_case_lookup", since = "1.84.0"))] const fn bitset_search< const N: usize, const CHUNK_SIZE: usize, @@ -424,7 +423,6 @@ pub mod lowercase { (5, 187), (6, 78), (7, 132), ]; - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_unicode_case_lookup", since = "1.84.0"))] pub const fn lookup(c: char) -> bool { super::bitset_search( c as u32, @@ -549,7 +547,6 @@ pub mod uppercase { (2, 146), (2, 20), (3, 146), (3, 140), (3, 134), (4, 178), (4, 171), ]; - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_unicode_case_lookup", since = "1.84.0"))] pub const fn lookup(c: char) -> bool { super::bitset_search( c as u32, diff --git a/core/src/unsafe_binder.rs b/core/src/unsafe_binder.rs new file mode 100644 index 0000000000000..98f53e07d9d8d --- /dev/null +++ b/core/src/unsafe_binder.rs @@ -0,0 +1,25 @@ +//! Operators used to turn types into unsafe binders and back. + +/// Unwrap an unsafe binder into its underlying type. +#[allow_internal_unstable(builtin_syntax)] +#[unstable(feature = "unsafe_binders", issue = "130516")] +pub macro unwrap_binder { + ($expr:expr) => { + builtin # unwrap_binder ( $expr ) + }, + ($expr:expr ; $ty:ty) => { + builtin # unwrap_binder ( $expr, $ty ) + }, +} + +/// Wrap a type into an unsafe binder. +#[allow_internal_unstable(builtin_syntax)] +#[unstable(feature = "unsafe_binders", issue = "130516")] +pub macro wrap_binder { + ($expr:expr) => { + builtin # wrap_binder ( $expr ) + }, + ($expr:expr ; $ty:ty) => { + builtin # wrap_binder ( $expr, $ty ) + }, +} diff --git a/core/tests/fmt/mod.rs b/core/tests/fmt/mod.rs deleted file mode 100644 index 704d246139947..0000000000000 --- a/core/tests/fmt/mod.rs +++ /dev/null @@ -1,45 +0,0 @@ -mod builders; -mod float; -mod num; - -#[test] -fn test_format_flags() { - // No residual flags left by pointer formatting - let p = "".as_ptr(); - assert_eq!(format!("{:p} {:x}", p, 16), format!("{p:p} 10")); - - assert_eq!(format!("{: >3}", 'a'), " a"); -} - -#[test] -fn test_pointer_formats_data_pointer() { - let b: &[u8] = b""; - let s: &str = ""; - assert_eq!(format!("{s:p}"), format!("{:p}", s.as_ptr())); - assert_eq!(format!("{b:p}"), format!("{:p}", b.as_ptr())); -} - -#[test] -fn test_estimated_capacity() { - assert_eq!(format_args!("").estimated_capacity(), 0); - assert_eq!(format_args!("{}", { "" }).estimated_capacity(), 0); - assert_eq!(format_args!("Hello").estimated_capacity(), 5); - assert_eq!(format_args!("Hello, {}!", { "" }).estimated_capacity(), 16); - assert_eq!(format_args!("{}, hello!", { "World" }).estimated_capacity(), 0); - assert_eq!(format_args!("{}. 16-bytes piece", { "World" }).estimated_capacity(), 32); -} - -#[test] -fn pad_integral_resets() { - struct Bar; - - impl core::fmt::Display for Bar { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - "1".fmt(f)?; - f.pad_integral(true, "", "5")?; - "1".fmt(f) - } - } - - assert_eq!(format!("{Bar:<03}"), "1 0051 "); -} diff --git a/core/tests/num/dec2flt/float.rs b/core/tests/num/dec2flt/float.rs deleted file mode 100644 index 7a9587a18d030..0000000000000 --- a/core/tests/num/dec2flt/float.rs +++ /dev/null @@ -1,33 +0,0 @@ -use core::num::dec2flt::float::RawFloat; - -#[test] -fn test_f32_integer_decode() { - assert_eq!(3.14159265359f32.integer_decode(), (13176795, -22, 1)); - assert_eq!((-8573.5918555f32).integer_decode(), (8779358, -10, -1)); - assert_eq!(2f32.powf(100.0).integer_decode(), (8388608, 77, 1)); - assert_eq!(0f32.integer_decode(), (0, -150, 1)); - assert_eq!((-0f32).integer_decode(), (0, -150, -1)); - assert_eq!(f32::INFINITY.integer_decode(), (8388608, 105, 1)); - assert_eq!(f32::NEG_INFINITY.integer_decode(), (8388608, 105, -1)); - - // Ignore the "sign" (quiet / signalling flag) of NAN. - // It can vary between runtime operations and LLVM folding. - let (nan_m, nan_e, _nan_s) = f32::NAN.integer_decode(); - assert_eq!((nan_m, nan_e), (12582912, 105)); -} - -#[test] -fn test_f64_integer_decode() { - assert_eq!(3.14159265359f64.integer_decode(), (7074237752028906, -51, 1)); - assert_eq!((-8573.5918555f64).integer_decode(), (4713381968463931, -39, -1)); - assert_eq!(2f64.powf(100.0).integer_decode(), (4503599627370496, 48, 1)); - assert_eq!(0f64.integer_decode(), (0, -1075, 1)); - assert_eq!((-0f64).integer_decode(), (0, -1075, -1)); - assert_eq!(f64::INFINITY.integer_decode(), (4503599627370496, 972, 1)); - assert_eq!(f64::NEG_INFINITY.integer_decode(), (4503599627370496, 972, -1)); - - // Ignore the "sign" (quiet / signalling flag) of NAN. - // It can vary between runtime operations and LLVM folding. - let (nan_m, nan_e, _nan_s) = f64::NAN.integer_decode(); - assert_eq!((nan_m, nan_e), (6755399441055744, 972)); -} diff --git a/core/tests/num/i128.rs b/core/tests/num/i128.rs deleted file mode 100644 index 1ddd20f33d0b1..0000000000000 --- a/core/tests/num/i128.rs +++ /dev/null @@ -1 +0,0 @@ -int_module!(i128); diff --git a/core/tests/num/i16.rs b/core/tests/num/i16.rs deleted file mode 100644 index c7aa9fff964ed..0000000000000 --- a/core/tests/num/i16.rs +++ /dev/null @@ -1 +0,0 @@ -int_module!(i16); diff --git a/core/tests/num/i64.rs b/core/tests/num/i64.rs deleted file mode 100644 index 93d23c10adf7e..0000000000000 --- a/core/tests/num/i64.rs +++ /dev/null @@ -1 +0,0 @@ -int_module!(i64); diff --git a/core/tests/num/i8.rs b/core/tests/num/i8.rs deleted file mode 100644 index 887d4f17d25ff..0000000000000 --- a/core/tests/num/i8.rs +++ /dev/null @@ -1 +0,0 @@ -int_module!(i8); diff --git a/core/tests/num/uint_macros.rs b/core/tests/num/uint_macros.rs deleted file mode 100644 index ad8e48491e829..0000000000000 --- a/core/tests/num/uint_macros.rs +++ /dev/null @@ -1,306 +0,0 @@ -macro_rules! uint_module { - ($T:ident) => { - use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr}; - use core::$T::*; - - use crate::num; - - #[test] - fn test_overflows() { - assert!(MAX > 0); - assert!(MIN <= 0); - assert!((MIN + MAX).wrapping_add(1) == 0); - } - - #[test] - fn test_num() { - num::test_num(10 as $T, 2 as $T); - } - - #[test] - fn test_bitwise_operators() { - assert!(0b1110 as $T == (0b1100 as $T).bitor(0b1010 as $T)); - assert!(0b1000 as $T == (0b1100 as $T).bitand(0b1010 as $T)); - assert!(0b0110 as $T == (0b1100 as $T).bitxor(0b1010 as $T)); - assert!(0b1110 as $T == (0b0111 as $T).shl(1)); - assert!(0b0111 as $T == (0b1110 as $T).shr(1)); - assert!(MAX - (0b1011 as $T) == (0b1011 as $T).not()); - } - - const A: $T = 0b0101100; - const B: $T = 0b0100001; - const C: $T = 0b1111001; - - const _0: $T = 0; - const _1: $T = !0; - - test_runtime_and_compiletime! { - fn test_count_ones() { - assert!(A.count_ones() == 3); - assert!(B.count_ones() == 2); - assert!(C.count_ones() == 5); - } - - fn test_count_zeros() { - assert!(A.count_zeros() == $T::BITS - 3); - assert!(B.count_zeros() == $T::BITS - 2); - assert!(C.count_zeros() == $T::BITS - 5); - } - - fn test_leading_trailing_ones() { - const A: $T = 0b0101_1111; - assert_eq_const_safe!(A.trailing_ones(), 5); - assert_eq_const_safe!((!A).leading_ones(), $T::BITS - 7); - - assert_eq_const_safe!(A.reverse_bits().leading_ones(), 5); - - assert_eq_const_safe!(_1.leading_ones(), $T::BITS); - assert_eq_const_safe!(_1.trailing_ones(), $T::BITS); - - assert_eq_const_safe!((_1 << 1).trailing_ones(), 0); - assert_eq_const_safe!((_1 >> 1).leading_ones(), 0); - - assert_eq_const_safe!((_1 << 1).leading_ones(), $T::BITS - 1); - assert_eq_const_safe!((_1 >> 1).trailing_ones(), $T::BITS - 1); - - assert_eq_const_safe!(_0.leading_ones(), 0); - assert_eq_const_safe!(_0.trailing_ones(), 0); - - const X: $T = 0b0010_1100; - assert_eq_const_safe!(X.leading_ones(), 0); - assert_eq_const_safe!(X.trailing_ones(), 0); - } - - fn test_rotate() { - assert_eq_const_safe!(A.rotate_left(6).rotate_right(2).rotate_right(4), A); - assert_eq_const_safe!(B.rotate_left(3).rotate_left(2).rotate_right(5), B); - assert_eq_const_safe!(C.rotate_left(6).rotate_right(2).rotate_right(4), C); - - // Rotating these should make no difference - // - // We test using 124 bits because to ensure that overlong bit shifts do - // not cause undefined behavior. See #10183. - assert_eq_const_safe!(_0.rotate_left(124), _0); - assert_eq_const_safe!(_1.rotate_left(124), _1); - assert_eq_const_safe!(_0.rotate_right(124), _0); - assert_eq_const_safe!(_1.rotate_right(124), _1); - - // Rotating by 0 should have no effect - assert_eq_const_safe!(A.rotate_left(0), A); - assert_eq_const_safe!(B.rotate_left(0), B); - assert_eq_const_safe!(C.rotate_left(0), C); - // Rotating by a multiple of word size should also have no effect - assert_eq_const_safe!(A.rotate_left(128), A); - assert_eq_const_safe!(B.rotate_left(128), B); - assert_eq_const_safe!(C.rotate_left(128), C); - } - - fn test_swap_bytes() { - assert_eq_const_safe!(A.swap_bytes().swap_bytes(), A); - assert_eq_const_safe!(B.swap_bytes().swap_bytes(), B); - assert_eq_const_safe!(C.swap_bytes().swap_bytes(), C); - - // Swapping these should make no difference - assert_eq_const_safe!(_0.swap_bytes(), _0); - assert_eq_const_safe!(_1.swap_bytes(), _1); - } - - fn test_reverse_bits() { - assert_eq_const_safe!(A.reverse_bits().reverse_bits(), A); - assert_eq_const_safe!(B.reverse_bits().reverse_bits(), B); - assert_eq_const_safe!(C.reverse_bits().reverse_bits(), C); - - // Swapping these should make no difference - assert_eq_const_safe!(_0.reverse_bits(), _0); - assert_eq_const_safe!(_1.reverse_bits(), _1); - } - - fn test_le() { - assert_eq_const_safe!($T::from_le(A.to_le()), A); - assert_eq_const_safe!($T::from_le(B.to_le()), B); - assert_eq_const_safe!($T::from_le(C.to_le()), C); - assert_eq_const_safe!($T::from_le(_0), _0); - assert_eq_const_safe!($T::from_le(_1), _1); - assert_eq_const_safe!(_0.to_le(), _0); - assert_eq_const_safe!(_1.to_le(), _1); - } - - fn test_be() { - assert_eq_const_safe!($T::from_be(A.to_be()), A); - assert_eq_const_safe!($T::from_be(B.to_be()), B); - assert_eq_const_safe!($T::from_be(C.to_be()), C); - assert_eq_const_safe!($T::from_be(_0), _0); - assert_eq_const_safe!($T::from_be(_1), _1); - assert_eq_const_safe!(_0.to_be(), _0); - assert_eq_const_safe!(_1.to_be(), _1); - } - - fn test_unsigned_checked_div() { - assert_eq_const_safe!((10 as $T).checked_div(2), Some(5)); - assert_eq_const_safe!((5 as $T).checked_div(0), None); - } - } - - fn from_str(t: &str) -> Option { - core::str::FromStr::from_str(t).ok() - } - - #[test] - pub fn test_from_str() { - assert_eq!(from_str::<$T>("0"), Some(0 as $T)); - assert_eq!(from_str::<$T>("3"), Some(3 as $T)); - assert_eq!(from_str::<$T>("10"), Some(10 as $T)); - assert_eq!(from_str::("123456789"), Some(123456789 as u32)); - assert_eq!(from_str::<$T>("00100"), Some(100 as $T)); - - assert_eq!(from_str::<$T>(""), None); - assert_eq!(from_str::<$T>(" "), None); - assert_eq!(from_str::<$T>("x"), None); - } - - test_runtime_and_compiletime! { - fn test_parse_bytes() { - assert_eq_const_safe!($T::from_str_radix("123", 10), Ok(123 as $T)); - assert_eq_const_safe!($T::from_str_radix("1001", 2), Ok(9 as $T)); - assert_eq_const_safe!($T::from_str_radix("123", 8), Ok(83 as $T)); - assert_eq_const_safe!(u16::from_str_radix("123", 16), Ok(291 as u16)); - assert_eq_const_safe!(u16::from_str_radix("ffff", 16), Ok(65535 as u16)); - assert_eq_const_safe!($T::from_str_radix("z", 36), Ok(35 as $T)); - - assert!($T::from_str_radix("Z", 10).is_err()); - assert!($T::from_str_radix("_", 2).is_err()); - } - - fn test_pow() { - { - const R: $T = 2; - assert_eq_const_safe!(R.pow(2), 4 as $T); - assert_eq_const_safe!(R.pow(0), 1 as $T); - assert_eq_const_safe!(R.wrapping_pow(2), 4 as $T); - assert_eq_const_safe!(R.wrapping_pow(0), 1 as $T); - assert_eq_const_safe!(R.checked_pow(2), Some(4 as $T)); - assert_eq_const_safe!(R.checked_pow(0), Some(1 as $T)); - assert_eq_const_safe!(R.overflowing_pow(2), (4 as $T, false)); - assert_eq_const_safe!(R.overflowing_pow(0), (1 as $T, false)); - assert_eq_const_safe!(R.saturating_pow(2), 4 as $T); - assert_eq_const_safe!(R.saturating_pow(0), 1 as $T); - } - - { - const R: $T = $T::MAX; - // use `^` to represent .pow() with no overflow. - // if itest::MAX == 2^j-1, then itest is a `j` bit int, - // so that `itest::MAX*itest::MAX == 2^(2*j)-2^(j+1)+1`, - // thussaturating_pow the overflowing result is exactly 1. - assert_eq_const_safe!(R.wrapping_pow(2), 1 as $T); - assert_eq_const_safe!(R.checked_pow(2), None); - assert_eq_const_safe!(R.overflowing_pow(2), (1 as $T, true)); - assert_eq_const_safe!(R.saturating_pow(2), MAX); - } - } - - fn test_isqrt() { - assert_eq_const_safe!((0 as $T).isqrt(), 0 as $T); - assert_eq_const_safe!((1 as $T).isqrt(), 1 as $T); - assert_eq_const_safe!((2 as $T).isqrt(), 1 as $T); - assert_eq_const_safe!((99 as $T).isqrt(), 9 as $T); - assert_eq_const_safe!((100 as $T).isqrt(), 10 as $T); - assert_eq_const_safe!($T::MAX.isqrt(), (1 << ($T::BITS / 2)) - 1); - } - } - - #[cfg(not(miri))] // Miri is too slow - #[test] - fn test_lots_of_isqrt() { - let n_max: $T = (1024 * 1024).min($T::MAX as u128) as $T; - for n in 0..=n_max { - let isqrt: $T = n.isqrt(); - - assert!(isqrt.pow(2) <= n); - assert!(isqrt + 1 == (1 as $T) << ($T::BITS / 2) || (isqrt + 1).pow(2) > n); - } - - for n in ($T::MAX - 255)..=$T::MAX { - let isqrt: $T = n.isqrt(); - - assert!(isqrt.pow(2) <= n); - assert!(isqrt + 1 == (1 as $T) << ($T::BITS / 2) || (isqrt + 1).pow(2) > n); - } - } - - test_runtime_and_compiletime! { - fn test_div_floor() { - assert_eq_const_safe!((8 as $T).div_floor(3), 2); - } - - fn test_div_ceil() { - assert_eq_const_safe!((8 as $T).div_ceil(3), 3); - } - - fn test_next_multiple_of() { - assert_eq_const_safe!((16 as $T).next_multiple_of(8), 16); - assert_eq_const_safe!((23 as $T).next_multiple_of(8), 24); - assert_eq_const_safe!(MAX.next_multiple_of(1), MAX); - } - - fn test_checked_next_multiple_of() { - assert_eq_const_safe!((16 as $T).checked_next_multiple_of(8), Some(16)); - assert_eq_const_safe!((23 as $T).checked_next_multiple_of(8), Some(24)); - assert_eq_const_safe!((1 as $T).checked_next_multiple_of(0), None); - assert_eq_const_safe!(MAX.checked_next_multiple_of(2), None); - } - - fn test_is_next_multiple_of() { - assert!((12 as $T).is_multiple_of(4)); - assert!(!(12 as $T).is_multiple_of(5)); - assert!((0 as $T).is_multiple_of(0)); - assert!(!(12 as $T).is_multiple_of(0)); - } - - fn test_carrying_add() { - assert_eq_const_safe!($T::MAX.carrying_add(1, false), (0, true)); - assert_eq_const_safe!($T::MAX.carrying_add(0, true), (0, true)); - assert_eq_const_safe!($T::MAX.carrying_add(1, true), (1, true)); - - assert_eq_const_safe!($T::MIN.carrying_add($T::MAX, false), ($T::MAX, false)); - assert_eq_const_safe!($T::MIN.carrying_add(0, true), (1, false)); - assert_eq_const_safe!($T::MIN.carrying_add($T::MAX, true), (0, true)); - } - - fn test_borrowing_sub() { - assert_eq_const_safe!($T::MIN.borrowing_sub(1, false), ($T::MAX, true)); - assert_eq_const_safe!($T::MIN.borrowing_sub(0, true), ($T::MAX, true)); - assert_eq_const_safe!($T::MIN.borrowing_sub(1, true), ($T::MAX - 1, true)); - - assert_eq_const_safe!($T::MAX.borrowing_sub($T::MAX, false), (0, false)); - assert_eq_const_safe!($T::MAX.borrowing_sub(0, true), ($T::MAX - 1, false)); - assert_eq_const_safe!($T::MAX.borrowing_sub($T::MAX, true), ($T::MAX, true)); - } - - fn test_midpoint() { - assert_eq_const_safe!(<$T>::midpoint(1, 3), 2); - assert_eq_const_safe!(<$T>::midpoint(3, 1), 2); - - assert_eq_const_safe!(<$T>::midpoint(0, 0), 0); - assert_eq_const_safe!(<$T>::midpoint(0, 2), 1); - assert_eq_const_safe!(<$T>::midpoint(2, 0), 1); - assert_eq_const_safe!(<$T>::midpoint(2, 2), 2); - - assert_eq_const_safe!(<$T>::midpoint(1, 4), 2); - assert_eq_const_safe!(<$T>::midpoint(4, 1), 2); - assert_eq_const_safe!(<$T>::midpoint(3, 4), 3); - assert_eq_const_safe!(<$T>::midpoint(4, 3), 3); - - assert_eq_const_safe!(<$T>::midpoint(<$T>::MIN, <$T>::MAX), (<$T>::MAX - <$T>::MIN) / 2); - assert_eq_const_safe!(<$T>::midpoint(<$T>::MAX, <$T>::MIN), (<$T>::MAX - <$T>::MIN) / 2); - assert_eq_const_safe!(<$T>::midpoint(<$T>::MIN, <$T>::MIN), <$T>::MIN); - assert_eq_const_safe!(<$T>::midpoint(<$T>::MAX, <$T>::MAX), <$T>::MAX); - - assert_eq_const_safe!(<$T>::midpoint(<$T>::MIN, 6), <$T>::MIN / 2 + 3); - assert_eq_const_safe!(<$T>::midpoint(6, <$T>::MIN), <$T>::MIN / 2 + 3); - assert_eq_const_safe!(<$T>::midpoint(<$T>::MAX, 6), (<$T>::MAX - <$T>::MIN) / 2 + 3); - assert_eq_const_safe!(<$T>::midpoint(6, <$T>::MAX), (<$T>::MAX - <$T>::MIN) / 2 + 3); - } - } - }; -} diff --git a/coretests/Cargo.toml b/coretests/Cargo.toml new file mode 100644 index 0000000000000..e44f01d347b3d --- /dev/null +++ b/coretests/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "coretests" +version = "0.0.0" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/rust.git" +description = "Tests for the Rust Core Library" +autotests = false +autobenches = false +edition = "2024" + +[lib] +path = "lib.rs" +test = false +bench = false + +[[test]] +name = "coretests" +path = "tests/lib.rs" + +[[bench]] +name = "corebenches" +path = "benches/lib.rs" +test = true + +[dev-dependencies] +rand = { version = "0.9.0", default-features = false } +rand_xorshift = { version = "0.4.0", default-features = false } diff --git a/core/benches/any.rs b/coretests/benches/any.rs similarity index 100% rename from core/benches/any.rs rename to coretests/benches/any.rs diff --git a/core/benches/array.rs b/coretests/benches/array.rs similarity index 100% rename from core/benches/array.rs rename to coretests/benches/array.rs diff --git a/core/benches/ascii.rs b/coretests/benches/ascii.rs similarity index 100% rename from core/benches/ascii.rs rename to coretests/benches/ascii.rs diff --git a/core/benches/ascii/is_ascii.rs b/coretests/benches/ascii/is_ascii.rs similarity index 56% rename from core/benches/ascii/is_ascii.rs rename to coretests/benches/ascii/is_ascii.rs index 4b2920c5eb45f..a6c718409ee85 100644 --- a/core/benches/ascii/is_ascii.rs +++ b/coretests/benches/ascii/is_ascii.rs @@ -10,9 +10,12 @@ macro_rules! benches { // Ensure we benchmark cases where the functions are called with strings // that are not perfectly aligned or have a length which is not a // multiple of size_of::() (or both) - benches!(mod unaligned_head MEDIUM[1..] $($name $arg $body)+); - benches!(mod unaligned_tail MEDIUM[..(MEDIUM.len() - 1)] $($name $arg $body)+); - benches!(mod unaligned_both MEDIUM[1..(MEDIUM.len() - 1)] $($name $arg $body)+); + benches!(mod unaligned_head_medium MEDIUM[1..] $($name $arg $body)+); + benches!(mod unaligned_tail_medium MEDIUM[..(MEDIUM.len() - 1)] $($name $arg $body)+); + benches!(mod unaligned_both_medium MEDIUM[1..(MEDIUM.len() - 1)] $($name $arg $body)+); + benches!(mod unaligned_head_long LONG[1..] $($name $arg $body)+); + benches!(mod unaligned_tail_long LONG[..(LONG.len() - 1)] $($name $arg $body)+); + benches!(mod unaligned_both_long LONG[1..(LONG.len() - 1)] $($name $arg $body)+); }; (mod $mod_name: ident $input: ident [$range: expr] $($name: ident $arg: ident $body: block)+) => { @@ -49,12 +52,50 @@ benches! { fn case03_align_to_unrolled(bytes: &[u8]) { is_ascii_align_to_unrolled(bytes) } + + fn case04_while_loop(bytes: &[u8]) { + // Process chunks of 32 bytes at a time in the fast path to enable + // auto-vectorization and use of `pmovmskb`. Two 128-bit vector registers + // can be OR'd together and then the resulting vector can be tested for + // non-ASCII bytes. + const CHUNK_SIZE: usize = 32; + + let mut i = 0; + + while i + CHUNK_SIZE <= bytes.len() { + let chunk_end = i + CHUNK_SIZE; + + // Get LLVM to produce a `pmovmskb` instruction on x86-64 which + // creates a mask from the most significant bit of each byte. + // ASCII bytes are less than 128 (0x80), so their most significant + // bit is unset. + let mut count = 0; + while i < chunk_end { + count += bytes[i].is_ascii() as u8; + i += 1; + } + + // All bytes should be <= 127 so count is equal to chunk size. + if count != CHUNK_SIZE as u8 { + return false; + } + } + + // Process the remaining `bytes.len() % N` bytes. + let mut is_ascii = true; + while i < bytes.len() { + is_ascii &= bytes[i].is_ascii(); + i += 1; + } + + is_ascii + } } // These are separate since it's easier to debug errors if they don't go through // macro expansion first. fn is_ascii_align_to(bytes: &[u8]) -> bool { - if bytes.len() < core::mem::size_of::() { + if bytes.len() < size_of::() { return bytes.iter().all(|b| b.is_ascii()); } // SAFETY: transmuting a sequence of `u8` to `usize` is always fine @@ -65,7 +106,7 @@ fn is_ascii_align_to(bytes: &[u8]) -> bool { } fn is_ascii_align_to_unrolled(bytes: &[u8]) -> bool { - if bytes.len() < core::mem::size_of::() { + if bytes.len() < size_of::() { return bytes.iter().all(|b| b.is_ascii()); } // SAFETY: transmuting a sequence of `u8` to `[usize; 2]` is always fine @@ -77,6 +118,6 @@ fn is_ascii_align_to_unrolled(bytes: &[u8]) -> bool { #[inline] fn contains_nonascii(v: usize) -> bool { - const NONASCII_MASK: usize = usize::from_ne_bytes([0x80; core::mem::size_of::()]); + const NONASCII_MASK: usize = usize::from_ne_bytes([0x80; size_of::()]); (NONASCII_MASK & v) != 0 } diff --git a/core/benches/char/methods.rs b/coretests/benches/char/methods.rs similarity index 100% rename from core/benches/char/methods.rs rename to coretests/benches/char/methods.rs diff --git a/core/benches/char/mod.rs b/coretests/benches/char/mod.rs similarity index 100% rename from core/benches/char/mod.rs rename to coretests/benches/char/mod.rs diff --git a/core/benches/fmt.rs b/coretests/benches/fmt.rs similarity index 90% rename from core/benches/fmt.rs rename to coretests/benches/fmt.rs index ed478b0f1e055..ee8e981b46b97 100644 --- a/core/benches/fmt.rs +++ b/coretests/benches/fmt.rs @@ -124,42 +124,41 @@ fn write_str_macro_debug_ascii(bh: &mut Bencher) { #[bench] fn write_u128_max(bh: &mut Bencher) { bh.iter(|| { - test::black_box(format!("{}", u128::MAX)); + black_box(format!("{}", black_box(u128::MAX))); }); } #[bench] fn write_u128_min(bh: &mut Bencher) { bh.iter(|| { - let s = format!("{}", 0u128); - test::black_box(s); + black_box(format!("{}", black_box(u128::MIN))); }); } #[bench] fn write_u64_max(bh: &mut Bencher) { bh.iter(|| { - test::black_box(format!("{}", u64::MAX)); + black_box(format!("{}", black_box(u64::MAX))); }); } #[bench] fn write_u64_min(bh: &mut Bencher) { bh.iter(|| { - test::black_box(format!("{}", 0u64)); + black_box(format!("{}", black_box(u64::MIN))); }); } #[bench] fn write_u8_max(bh: &mut Bencher) { bh.iter(|| { - test::black_box(format!("{}", u8::MAX)); + black_box(format!("{}", black_box(u8::MAX))); }); } #[bench] fn write_u8_min(bh: &mut Bencher) { bh.iter(|| { - test::black_box(format!("{}", 0u8)); + black_box(format!("{}", black_box(u8::MIN))); }); } diff --git a/core/benches/hash/mod.rs b/coretests/benches/hash/mod.rs similarity index 100% rename from core/benches/hash/mod.rs rename to coretests/benches/hash/mod.rs diff --git a/core/benches/hash/sip.rs b/coretests/benches/hash/sip.rs similarity index 100% rename from core/benches/hash/sip.rs rename to coretests/benches/hash/sip.rs diff --git a/core/benches/iter.rs b/coretests/benches/iter.rs similarity index 98% rename from core/benches/iter.rs rename to coretests/benches/iter.rs index e14f26b729032..e49d152eb539f 100644 --- a/core/benches/iter.rs +++ b/coretests/benches/iter.rs @@ -1,6 +1,5 @@ use core::borrow::Borrow; use core::iter::*; -use core::mem; use core::num::Wrapping; use core::ops::Range; @@ -477,7 +476,7 @@ fn bench_next_chunk_copied(b: &mut Bencher) { let mut iter = black_box(&v).iter().copied(); let mut acc = Wrapping(0); // This uses a while-let loop to side-step the TRA specialization in ArrayChunks - while let Ok(chunk) = iter.next_chunk::<{ mem::size_of::() }>() { + while let Ok(chunk) = iter.next_chunk::<{ size_of::() }>() { let d = u64::from_ne_bytes(chunk); acc += Wrapping(d.rotate_left(7).wrapping_add(1)); } @@ -496,7 +495,7 @@ fn bench_next_chunk_trusted_random_access(b: &mut Bencher) { .iter() // this shows that we're not relying on the slice::Iter specialization in Copied .map(|b| *b.borrow()) - .array_chunks::<{ mem::size_of::() }>() + .array_chunks::<{ size_of::() }>() .map(|ary| { let d = u64::from_ne_bytes(ary); Wrapping(d.rotate_left(7).wrapping_add(1)) diff --git a/core/benches/lib.rs b/coretests/benches/lib.rs similarity index 100% rename from core/benches/lib.rs rename to coretests/benches/lib.rs diff --git a/core/benches/net/addr_parser.rs b/coretests/benches/net/addr_parser.rs similarity index 100% rename from core/benches/net/addr_parser.rs rename to coretests/benches/net/addr_parser.rs diff --git a/core/benches/net/mod.rs b/coretests/benches/net/mod.rs similarity index 100% rename from core/benches/net/mod.rs rename to coretests/benches/net/mod.rs diff --git a/core/benches/num/dec2flt/mod.rs b/coretests/benches/num/dec2flt/mod.rs similarity index 100% rename from core/benches/num/dec2flt/mod.rs rename to coretests/benches/num/dec2flt/mod.rs diff --git a/core/benches/num/flt2dec/mod.rs b/coretests/benches/num/flt2dec/mod.rs similarity index 100% rename from core/benches/num/flt2dec/mod.rs rename to coretests/benches/num/flt2dec/mod.rs diff --git a/core/benches/num/flt2dec/strategy/dragon.rs b/coretests/benches/num/flt2dec/strategy/dragon.rs similarity index 100% rename from core/benches/num/flt2dec/strategy/dragon.rs rename to coretests/benches/num/flt2dec/strategy/dragon.rs diff --git a/core/benches/num/flt2dec/strategy/grisu.rs b/coretests/benches/num/flt2dec/strategy/grisu.rs similarity index 100% rename from core/benches/num/flt2dec/strategy/grisu.rs rename to coretests/benches/num/flt2dec/strategy/grisu.rs diff --git a/core/benches/num/int_log/mod.rs b/coretests/benches/num/int_log/mod.rs similarity index 92% rename from core/benches/num/int_log/mod.rs rename to coretests/benches/num/int_log/mod.rs index e5874ddf03b5b..171d7e31cdb1a 100644 --- a/core/benches/num/int_log/mod.rs +++ b/coretests/benches/num/int_log/mod.rs @@ -21,7 +21,7 @@ macro_rules! int_log10_bench { /* Exponentially distributed random numbers from the whole range of the type. */ let numbers: Vec<$t> = (0..256) .map(|_| { - let x = rng.gen::<$t>() >> rng.gen_range(0..<$t>::BITS); + let x = rng.random::<$t>() >> rng.random_range(0..<$t>::BITS); if x != 0 { x } else { 1 } }) .collect(); @@ -38,7 +38,7 @@ macro_rules! int_log10_bench { /* Exponentially distributed random numbers from the range 0..256. */ let numbers: Vec<$t> = (0..256) .map(|_| { - let x = (rng.gen::() >> rng.gen_range(0..u8::BITS)) as $t; + let x = (rng.random::() >> rng.random_range(0..u8::BITS)) as $t; if x != 0 { x } else { 1 } }) .collect(); @@ -65,7 +65,7 @@ macro_rules! int_log_bench { /* Exponentially distributed random numbers from the whole range of the type. */ let numbers: Vec<$t> = (0..256) .map(|_| { - let x = rng.gen::<$t>() >> rng.gen_range(0..<$t>::BITS); + let x = rng.random::<$t>() >> rng.random_range(0..<$t>::BITS); if x >= 2 { x } else { 2 } }) .collect(); @@ -84,7 +84,7 @@ macro_rules! int_log_bench { /* Exponentially distributed random numbers from the range 0..256. */ let numbers: Vec<$t> = (0..256) .map(|_| { - let x = (rng.gen::() >> rng.gen_range(0..u8::BITS)) as $t; + let x = (rng.random::() >> rng.random_range(0..u8::BITS)) as $t; if x >= 2 { x } else { 2 } }) .collect(); diff --git a/core/benches/num/int_pow/mod.rs b/coretests/benches/num/int_pow/mod.rs similarity index 93% rename from core/benches/num/int_pow/mod.rs rename to coretests/benches/num/int_pow/mod.rs index 6cf9021358283..6b603d2f7b3b4 100644 --- a/core/benches/num/int_pow/mod.rs +++ b/coretests/benches/num/int_pow/mod.rs @@ -15,9 +15,9 @@ macro_rules! pow_bench_template { // reference through black_box outside of the loop. let mut rng = crate::bench_rng(); let base_array: [IntType; ITERATIONS] = - core::array::from_fn(|_| rng.gen_range((-MAX_BASE..=MAX_BASE))); + core::array::from_fn(|_| rng.random_range((-MAX_BASE..=MAX_BASE))); let exp_array: [u32; ITERATIONS] = - core::array::from_fn(|_| rng.gen_range((0..=EXPONENT_MAX))); + core::array::from_fn(|_| rng.random_range((0..=EXPONENT_MAX))); bench.iter(|| { #[allow(unused, unused_mut)] @@ -25,7 +25,7 @@ macro_rules! pow_bench_template { let mut exp_iter = black_box(&exp_array).into_iter(); (0..ITERATIONS).fold((0 as IntType, false), |acc, _| { - // Sometimes constants don't propogate all the way to the + // Sometimes constants don't propagate all the way to the // inside of the loop, so we call a custom expression every cycle // rather than iter::repeat(CONST) let base: IntType = $base_macro!(base_iter); diff --git a/core/benches/num/int_sqrt/mod.rs b/coretests/benches/num/int_sqrt/mod.rs similarity index 86% rename from core/benches/num/int_sqrt/mod.rs rename to coretests/benches/num/int_sqrt/mod.rs index e47b92e866eff..05cb3c5383b27 100644 --- a/core/benches/num/int_sqrt/mod.rs +++ b/coretests/benches/num/int_sqrt/mod.rs @@ -20,7 +20,7 @@ macro_rules! int_sqrt_bench { let mut rng = crate::bench_rng(); /* Exponentially distributed random numbers from the whole range of the type. */ let numbers: Vec<$t> = - (0..256).map(|_| rng.gen::<$t>() >> rng.gen_range(0..<$t>::BITS)).collect(); + (0..256).map(|_| rng.random::<$t>() >> rng.random_range(0..<$t>::BITS)).collect(); bench.iter(|| { for x in &numbers { black_box(black_box(x).isqrt()); @@ -32,8 +32,9 @@ macro_rules! int_sqrt_bench { fn $random_small(bench: &mut Bencher) { let mut rng = crate::bench_rng(); /* Exponentially distributed random numbers from the range 0..256. */ - let numbers: Vec<$t> = - (0..256).map(|_| (rng.gen::() >> rng.gen_range(0..u8::BITS)) as $t).collect(); + let numbers: Vec<$t> = (0..256) + .map(|_| (rng.random::() >> rng.random_range(0..u8::BITS)) as $t) + .collect(); bench.iter(|| { for x in &numbers { black_box(black_box(x).isqrt()); @@ -45,7 +46,7 @@ macro_rules! int_sqrt_bench { fn $random_uniform(bench: &mut Bencher) { let mut rng = crate::bench_rng(); /* Exponentially distributed random numbers from the whole range of the type. */ - let numbers: Vec<$t> = (0..256).map(|_| rng.gen::<$t>()).collect(); + let numbers: Vec<$t> = (0..256).map(|_| rng.random::<$t>()).collect(); bench.iter(|| { for x in &numbers { black_box(black_box(x).isqrt()); diff --git a/core/benches/num/mod.rs b/coretests/benches/num/mod.rs similarity index 100% rename from core/benches/num/mod.rs rename to coretests/benches/num/mod.rs diff --git a/core/benches/ops.rs b/coretests/benches/ops.rs similarity index 100% rename from core/benches/ops.rs rename to coretests/benches/ops.rs diff --git a/core/benches/pattern.rs b/coretests/benches/pattern.rs similarity index 100% rename from core/benches/pattern.rs rename to coretests/benches/pattern.rs diff --git a/core/benches/slice.rs b/coretests/benches/slice.rs similarity index 96% rename from core/benches/slice.rs rename to coretests/benches/slice.rs index 29a66b6219976..71027981d94a1 100644 --- a/core/benches/slice.rs +++ b/coretests/benches/slice.rs @@ -94,7 +94,7 @@ fn binary_search_l3_worst_case(b: &mut Bencher) { struct Rgb(#[allow(dead_code)] u8, #[allow(dead_code)] u8, #[allow(dead_code)] u8); impl Rgb { - fn gen(i: usize) -> Self { + fn new(i: usize) -> Self { Rgb(i as u8, (i as u8).wrapping_add(7), (i as u8).wrapping_add(42)) } } @@ -115,7 +115,7 @@ macro_rules! rotate { } rotate!(rotate_u8, 32, |i| i as u8); -rotate!(rotate_rgb, 32, Rgb::gen); +rotate!(rotate_rgb, 32, Rgb::new); rotate!(rotate_usize, 32, |i| i); rotate!(rotate_16_usize_4, 16, |i| [i; 4]); rotate!(rotate_16_usize_5, 16, |i| [i; 5]); @@ -142,8 +142,8 @@ macro_rules! swap_with_slice { swap_with_slice!(swap_with_slice_u8_30, 30, |i| i as u8); swap_with_slice!(swap_with_slice_u8_3000, 3000, |i| i as u8); -swap_with_slice!(swap_with_slice_rgb_30, 30, Rgb::gen); -swap_with_slice!(swap_with_slice_rgb_3000, 3000, Rgb::gen); +swap_with_slice!(swap_with_slice_rgb_30, 30, Rgb::new); +swap_with_slice!(swap_with_slice_rgb_3000, 3000, Rgb::new); swap_with_slice!(swap_with_slice_usize_30, 30, |i| i); swap_with_slice!(swap_with_slice_usize_3000, 3000, |i| i); swap_with_slice!(swap_with_slice_4x_usize_30, 30, |i| [i; 4]); diff --git a/core/benches/str.rs b/coretests/benches/str.rs similarity index 100% rename from core/benches/str.rs rename to coretests/benches/str.rs diff --git a/core/benches/str/char_count.rs b/coretests/benches/str/char_count.rs similarity index 100% rename from core/benches/str/char_count.rs rename to coretests/benches/str/char_count.rs diff --git a/core/benches/str/corpora.rs b/coretests/benches/str/corpora.rs similarity index 100% rename from core/benches/str/corpora.rs rename to coretests/benches/str/corpora.rs diff --git a/core/benches/str/debug.rs b/coretests/benches/str/debug.rs similarity index 100% rename from core/benches/str/debug.rs rename to coretests/benches/str/debug.rs diff --git a/core/benches/str/iter.rs b/coretests/benches/str/iter.rs similarity index 100% rename from core/benches/str/iter.rs rename to coretests/benches/str/iter.rs diff --git a/core/benches/tuple.rs b/coretests/benches/tuple.rs similarity index 100% rename from core/benches/tuple.rs rename to coretests/benches/tuple.rs diff --git a/coretests/lib.rs b/coretests/lib.rs new file mode 100644 index 0000000000000..b49208cd4eb3a --- /dev/null +++ b/coretests/lib.rs @@ -0,0 +1 @@ +// Intentionally left empty. diff --git a/core/tests/alloc.rs b/coretests/tests/alloc.rs similarity index 99% rename from core/tests/alloc.rs rename to coretests/tests/alloc.rs index b88f1821cd77c..72fdf82c1f8cf 100644 --- a/core/tests/alloc.rs +++ b/coretests/tests/alloc.rs @@ -1,5 +1,4 @@ use core::alloc::Layout; -use core::mem::size_of; use core::ptr::{self, NonNull}; #[test] diff --git a/core/tests/any.rs b/coretests/tests/any.rs similarity index 92% rename from core/tests/any.rs rename to coretests/tests/any.rs index 25002617d0bbd..117ef0042380d 100644 --- a/core/tests/any.rs +++ b/coretests/tests/any.rs @@ -118,6 +118,14 @@ fn any_unsized() { is_any::<[i32]>(); } +#[cfg(feature = "debug_typeid")] +#[test] +fn debug_typeid_includes_name() { + let type_id = TypeId::of::<[usize; 2]>(); + let debug_str = format!("{type_id:?}"); + assert!(debug_str.ends_with("= [usize; 2])"), "{debug_str:?} did not match"); +} + #[test] fn distinct_type_names() { // https://github.com/rust-lang/rust/issues/84666 diff --git a/core/tests/array.rs b/coretests/tests/array.rs similarity index 100% rename from core/tests/array.rs rename to coretests/tests/array.rs diff --git a/core/tests/ascii.rs b/coretests/tests/ascii.rs similarity index 100% rename from core/tests/ascii.rs rename to coretests/tests/ascii.rs diff --git a/core/tests/ascii_char.rs b/coretests/tests/ascii_char.rs similarity index 74% rename from core/tests/ascii_char.rs rename to coretests/tests/ascii_char.rs index 75b5fd4b9e61d..f5a15a9469f3f 100644 --- a/core/tests/ascii_char.rs +++ b/coretests/tests/ascii_char.rs @@ -26,3 +26,15 @@ fn test_debug_control() { assert_eq!(want, format!("{chr:?}"), "byte: {byte}"); } } + +/// Tests Extend implementation for ascii::Char. +#[test] +fn test_extend() { + let mut s = String::from("abc"); + s.extend_one(Char::SmallD); + assert_eq!(s, String::from("abcd")); + + let mut s = String::from("abc"); + s.extend(Char::CapitalA..=Char::CapitalC); + assert_eq!(s, String::from("abcABC")); +} diff --git a/core/tests/asserting.rs b/coretests/tests/asserting.rs similarity index 100% rename from core/tests/asserting.rs rename to coretests/tests/asserting.rs diff --git a/core/tests/async_iter/mod.rs b/coretests/tests/async_iter/mod.rs similarity index 100% rename from core/tests/async_iter/mod.rs rename to coretests/tests/async_iter/mod.rs diff --git a/core/tests/atomic.rs b/coretests/tests/atomic.rs similarity index 99% rename from core/tests/atomic.rs rename to coretests/tests/atomic.rs index 0ffba538b2074..e0c0fe4790c04 100644 --- a/core/tests/atomic.rs +++ b/coretests/tests/atomic.rs @@ -250,8 +250,6 @@ fn atomic_access_bool() { #[test] fn atomic_alignment() { - use std::mem::{align_of, size_of}; - #[cfg(target_has_atomic = "8")] assert_eq!(align_of::(), size_of::()); #[cfg(target_has_atomic = "ptr")] diff --git a/core/tests/bool.rs b/coretests/tests/bool.rs similarity index 96% rename from core/tests/bool.rs rename to coretests/tests/bool.rs index 47f6459915b3e..bcd6dc2abac6c 100644 --- a/core/tests/bool.rs +++ b/coretests/tests/bool.rs @@ -71,14 +71,14 @@ fn test_bool() { #[test] pub fn test_bool_not() { if !false { - assert!((true)); + assert!(true); } else { - assert!((false)); + assert!(false); } if !true { - assert!((false)); + assert!(false); } else { - assert!((true)); + assert!(true); } } diff --git a/coretests/tests/bstr.rs b/coretests/tests/bstr.rs new file mode 100644 index 0000000000000..cd4d69d6b337d --- /dev/null +++ b/coretests/tests/bstr.rs @@ -0,0 +1,52 @@ +use core::bstr::ByteStr; + +#[test] +fn test_debug() { + assert_eq!( + r#""\0\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x11\x12\r\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f \x7f\x80\x81\xfe\xff""#, + format!("{:?}", ByteStr::new(b"\0\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x11\x12\r\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f \x7f\x80\x81\xfe\xff")), + ); +} + +#[test] +fn test_display() { + let b1 = ByteStr::new("abc"); + let b2 = ByteStr::new(b"\xf0\x28\x8c\xbc"); + + assert_eq!(&format!("{b1}"), "abc"); + assert_eq!(&format!("{b2}"), "�(��"); + + assert_eq!(&format!("{b1:<7}!"), "abc !"); + assert_eq!(&format!("{b1:>7}!"), " abc!"); + assert_eq!(&format!("{b1:^7}!"), " abc !"); + assert_eq!(&format!("{b1:^6}!"), " abc !"); + assert_eq!(&format!("{b1:-<7}!"), "abc----!"); + assert_eq!(&format!("{b1:->7}!"), "----abc!"); + assert_eq!(&format!("{b1:-^7}!"), "--abc--!"); + assert_eq!(&format!("{b1:-^6}!"), "-abc--!"); + + assert_eq!(&format!("{b2:<7}!"), "�(�� !"); + assert_eq!(&format!("{b2:>7}!"), " �(��!"); + assert_eq!(&format!("{b2:^7}!"), " �(�� !"); + assert_eq!(&format!("{b2:^6}!"), " �(�� !"); + assert_eq!(&format!("{b2:-<7}!"), "�(��---!"); + assert_eq!(&format!("{b2:->7}!"), "---�(��!"); + assert_eq!(&format!("{b2:-^7}!"), "-�(��--!"); + assert_eq!(&format!("{b2:-^6}!"), "-�(��-!"); + + assert_eq!(&format!("{b1:<2}!"), "abc!"); + assert_eq!(&format!("{b1:>2}!"), "abc!"); + assert_eq!(&format!("{b1:^2}!"), "abc!"); + assert_eq!(&format!("{b1:-<2}!"), "abc!"); + assert_eq!(&format!("{b1:->2}!"), "abc!"); + assert_eq!(&format!("{b1:-^2}!"), "abc!"); + + assert_eq!(&format!("{b2:<3}!"), "�(��!"); + assert_eq!(&format!("{b2:>3}!"), "�(��!"); + assert_eq!(&format!("{b2:^3}!"), "�(��!"); + assert_eq!(&format!("{b2:^2}!"), "�(��!"); + assert_eq!(&format!("{b2:-<3}!"), "�(��!"); + assert_eq!(&format!("{b2:->3}!"), "�(��!"); + assert_eq!(&format!("{b2:-^3}!"), "�(��!"); + assert_eq!(&format!("{b2:-^2}!"), "�(��!"); +} diff --git a/core/tests/cell.rs b/coretests/tests/cell.rs similarity index 100% rename from core/tests/cell.rs rename to coretests/tests/cell.rs diff --git a/core/tests/char.rs b/coretests/tests/char.rs similarity index 99% rename from core/tests/char.rs rename to coretests/tests/char.rs index 6422387e9560b..153fb36925e66 100644 --- a/core/tests/char.rs +++ b/coretests/tests/char.rs @@ -1,3 +1,4 @@ +use std::char::MAX_LEN_UTF8; use std::str::FromStr; use std::{char, str}; @@ -259,7 +260,7 @@ fn test_escape_unicode() { #[test] fn test_encode_utf8() { fn check(input: char, expect: &[u8]) { - let mut buf = [0; 4]; + let mut buf = [0; MAX_LEN_UTF8]; let ptr = buf.as_ptr(); let s = input.encode_utf8(&mut buf); assert_eq!(s.as_ptr() as usize, ptr as usize); diff --git a/core/tests/clone.rs b/coretests/tests/clone.rs similarity index 100% rename from core/tests/clone.rs rename to coretests/tests/clone.rs diff --git a/core/tests/cmp.rs b/coretests/tests/cmp.rs similarity index 100% rename from core/tests/cmp.rs rename to coretests/tests/cmp.rs diff --git a/core/tests/const_ptr.rs b/coretests/tests/const_ptr.rs similarity index 100% rename from core/tests/const_ptr.rs rename to coretests/tests/const_ptr.rs diff --git a/core/tests/convert.rs b/coretests/tests/convert.rs similarity index 100% rename from core/tests/convert.rs rename to coretests/tests/convert.rs diff --git a/core/tests/error.rs b/coretests/tests/error.rs similarity index 100% rename from core/tests/error.rs rename to coretests/tests/error.rs diff --git a/core/tests/ffi.rs b/coretests/tests/ffi.rs similarity index 100% rename from core/tests/ffi.rs rename to coretests/tests/ffi.rs diff --git a/core/tests/ffi/cstr.rs b/coretests/tests/ffi/cstr.rs similarity index 100% rename from core/tests/ffi/cstr.rs rename to coretests/tests/ffi/cstr.rs diff --git a/core/tests/fmt/builders.rs b/coretests/tests/fmt/builders.rs similarity index 100% rename from core/tests/fmt/builders.rs rename to coretests/tests/fmt/builders.rs diff --git a/core/tests/fmt/float.rs b/coretests/tests/fmt/float.rs similarity index 100% rename from core/tests/fmt/float.rs rename to coretests/tests/fmt/float.rs diff --git a/coretests/tests/fmt/mod.rs b/coretests/tests/fmt/mod.rs new file mode 100644 index 0000000000000..025c69c4f6236 --- /dev/null +++ b/coretests/tests/fmt/mod.rs @@ -0,0 +1,82 @@ +mod builders; +mod float; +mod num; + +#[test] +fn test_format_flags() { + // No residual flags left by pointer formatting + let p = "".as_ptr(); + assert_eq!(format!("{:p} {:x}", p, 16), format!("{p:p} 10")); + + assert_eq!(format!("{: >3}", 'a'), " a"); +} + +#[test] +fn test_pointer_formats_data_pointer() { + let b: &[u8] = b""; + let s: &str = ""; + assert_eq!(format!("{s:p}"), format!("{:p}", s.as_ptr())); + assert_eq!(format!("{b:p}"), format!("{:p}", b.as_ptr())); +} + +#[test] +fn test_estimated_capacity() { + assert_eq!(format_args!("").estimated_capacity(), 0); + assert_eq!(format_args!("{}", { "" }).estimated_capacity(), 0); + assert_eq!(format_args!("Hello").estimated_capacity(), 5); + assert_eq!(format_args!("Hello, {}!", { "" }).estimated_capacity(), 16); + assert_eq!(format_args!("{}, hello!", { "World" }).estimated_capacity(), 0); + assert_eq!(format_args!("{}. 16-bytes piece", { "World" }).estimated_capacity(), 32); +} + +#[test] +fn pad_integral_resets() { + struct Bar; + + impl core::fmt::Display for Bar { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + "1".fmt(f)?; + f.pad_integral(true, "", "5")?; + "1".fmt(f) + } + } + + assert_eq!(format!("{Bar:<03}"), "1 0051 "); +} + +#[test] +fn test_maybe_uninit_short() { + // Ensure that the trimmed `MaybeUninit` Debug implementation doesn't break + let x = core::mem::MaybeUninit::new(0u32); + assert_eq!(format!("{x:?}"), "MaybeUninit"); +} + +#[test] +fn formatting_options_ctor() { + use core::fmt::FormattingOptions; + assert_eq!(FormattingOptions::new(), FormattingOptions::default()); +} + +#[test] +fn formatting_options_flags() { + use core::fmt::*; + for sign in [None, Some(Sign::Plus), Some(Sign::Minus)] { + for alternate in [true, false] { + for sign_aware_zero_pad in [true, false] { + for debug_as_hex in [None, Some(DebugAsHex::Lower), Some(DebugAsHex::Upper)] { + let mut formatting_options = FormattingOptions::new(); + formatting_options + .sign(sign) + .sign_aware_zero_pad(sign_aware_zero_pad) + .alternate(alternate) + .debug_as_hex(debug_as_hex); + + assert_eq!(formatting_options.get_sign(), sign); + assert_eq!(formatting_options.get_alternate(), alternate); + assert_eq!(formatting_options.get_sign_aware_zero_pad(), sign_aware_zero_pad); + assert_eq!(formatting_options.get_debug_as_hex(), debug_as_hex); + } + } + } + } +} diff --git a/core/tests/fmt/num.rs b/coretests/tests/fmt/num.rs similarity index 100% rename from core/tests/fmt/num.rs rename to coretests/tests/fmt/num.rs diff --git a/core/tests/future.rs b/coretests/tests/future.rs similarity index 100% rename from core/tests/future.rs rename to coretests/tests/future.rs diff --git a/core/tests/hash/mod.rs b/coretests/tests/hash/mod.rs similarity index 90% rename from core/tests/hash/mod.rs rename to coretests/tests/hash/mod.rs index bf91e9e5df0e2..1f10a4733b053 100644 --- a/core/tests/hash/mod.rs +++ b/coretests/tests/hash/mod.rs @@ -4,16 +4,11 @@ use std::hash::{BuildHasher, Hash, Hasher}; use std::ptr; use std::rc::Rc; +#[derive(Default)] struct MyHasher { hash: u64, } -impl Default for MyHasher { - fn default() -> MyHasher { - MyHasher { hash: 0 } - } -} - impl Hasher for MyHasher { fn write(&mut self, buf: &[u8]) { for byte in buf { @@ -107,6 +102,8 @@ fn test_writer_hasher() { struct Custom { hash: u64, } + +#[derive(Default)] struct CustomHasher { output: u64, } @@ -123,12 +120,6 @@ impl Hasher for CustomHasher { } } -impl Default for CustomHasher { - fn default() -> CustomHasher { - CustomHasher { output: 0 } - } -} - impl Hash for Custom { fn hash(&self, state: &mut H) { state.write_u64(self.hash); @@ -150,9 +141,6 @@ fn test_custom_state() { // const { assert!(hash(&Custom { hash: 6 }) == 6) }; } -// FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten. -// See https://github.com/kripken/emscripten-fastcomp/issues/169 -#[cfg(not(target_os = "emscripten"))] #[test] fn test_indirect_hasher() { let mut hasher = MyHasher { hash: 0 }; diff --git a/core/tests/hash/sip.rs b/coretests/tests/hash/sip.rs similarity index 99% rename from core/tests/hash/sip.rs rename to coretests/tests/hash/sip.rs index f79954f916b77..6add1a33cb931 100644 --- a/core/tests/hash/sip.rs +++ b/coretests/tests/hash/sip.rs @@ -1,7 +1,7 @@ #![allow(deprecated)] use core::hash::{Hash, Hasher, SipHasher, SipHasher13}; -use core::{mem, slice}; +use core::slice; // Hash just the bytes of the slice, without length prefix struct Bytes<'a>(&'a [u8]); @@ -314,7 +314,7 @@ fn test_write_short_works() { h1.write_u8(0x01u8); let mut h2 = SipHasher::new(); h2.write(unsafe { - slice::from_raw_parts(&test_usize as *const _ as *const u8, mem::size_of::()) + slice::from_raw_parts(&test_usize as *const _ as *const u8, size_of::()) }); h2.write(b"bytes"); h2.write(b"string"); diff --git a/core/tests/intrinsics.rs b/coretests/tests/intrinsics.rs similarity index 62% rename from core/tests/intrinsics.rs rename to coretests/tests/intrinsics.rs index 8b731cf5b25d1..744a6a0d2dd8f 100644 --- a/core/tests/intrinsics.rs +++ b/coretests/tests/intrinsics.rs @@ -125,3 +125,71 @@ fn test_three_way_compare_in_const_contexts() { assert_eq!(SIGNED_EQUAL, Equal); assert_eq!(SIGNED_GREATER, Greater); } + +fn fallback_cma( + a: T, + b: T, + c: T, + d: T, +) -> (T::Unsigned, T) { + a.carrying_mul_add(b, c, d) +} + +#[test] +fn carrying_mul_add_fallback_u32() { + let r = fallback_cma::(0x9e37_79b9, 0x7f4a_7c15, 0xf39c_c060, 0x5ced_c834); + assert_eq!(r, (0x2087_20c1, 0x4eab_8e1d)); + let r = fallback_cma::(0x1082_276b, 0xf3a2_7251, 0xf86c_6a11, 0xd0c1_8e95); + assert_eq!(r, (0x7aa0_1781, 0x0fb6_0528)); +} + +#[test] +fn carrying_mul_add_fallback_i32() { + let r = fallback_cma::(-1, -1, -1, -1); + assert_eq!(r, (u32::MAX, -1)); + let r = fallback_cma::(1, -1, 1, 1); + assert_eq!(r, (1, 0)); +} + +#[test] +fn carrying_mul_add_fallback_u128() { + assert_eq!(fallback_cma::(u128::MAX, u128::MAX, 0, 0), (1, u128::MAX - 1)); + assert_eq!(fallback_cma::(1, 1, 1, 1), (3, 0)); + assert_eq!(fallback_cma::(0, 0, u128::MAX, u128::MAX), (u128::MAX - 1, 1)); + assert_eq!( + fallback_cma::(u128::MAX, u128::MAX, u128::MAX, u128::MAX), + (u128::MAX, u128::MAX), + ); + + let r = fallback_cma::( + 0x243f6a8885a308d313198a2e03707344, + 0xa4093822299f31d0082efa98ec4e6c89, + 0x452821e638d01377be5466cf34e90c6c, + 0xc0ac29b7c97c50dd3f84d5b5b5470917, + ); + assert_eq!(r, (0x8050ec20ed554e40338d277e00b674e7, 0x1739ee6cea07da409182d003859b59d8)); + let r = fallback_cma::( + 0x9216d5d98979fb1bd1310ba698dfb5ac, + 0x2ffd72dbd01adfb7b8e1afed6a267e96, + 0xba7c9045f12c7f9924a19947b3916cf7, + 0x0801f2e2858efc16636920d871574e69, + ); + assert_eq!(r, (0x185525545fdb2fefb502a3a602efd628, 0x1b62d35fe3bff6b566f99667ef7ebfd6)); +} + +#[test] +fn carrying_mul_add_fallback_i128() { + assert_eq!(fallback_cma::(-1, -1, 0, 0), (1, 0)); + let r = fallback_cma::(-1, -1, -1, -1); + assert_eq!(r, (u128::MAX, -1)); + let r = fallback_cma::(1, -1, 1, 1); + assert_eq!(r, (1, 0)); + assert_eq!( + fallback_cma::(i128::MAX, i128::MAX, i128::MAX, i128::MAX), + (u128::MAX, i128::MAX / 2), + ); + assert_eq!( + fallback_cma::(i128::MIN, i128::MIN, i128::MAX, i128::MAX), + (u128::MAX - 1, -(i128::MIN / 2)), + ); +} diff --git a/core/tests/io/borrowed_buf.rs b/coretests/tests/io/borrowed_buf.rs similarity index 96% rename from core/tests/io/borrowed_buf.rs rename to coretests/tests/io/borrowed_buf.rs index a5dd4e525777a..fbd3864dcac14 100644 --- a/core/tests/io/borrowed_buf.rs +++ b/coretests/tests/io/borrowed_buf.rs @@ -145,7 +145,7 @@ fn cursor_set_init() { assert_eq!(rbuf.unfilled().init_ref().len(), 8); assert_eq!(rbuf.unfilled().init_mut().len(), 8); assert_eq!(rbuf.unfilled().uninit_mut().len(), 8); - assert_eq!(unsafe { rbuf.unfilled().as_mut() }.len(), 16); + assert_eq!(unsafe { rbuf.unfilled().as_mut().len() }, 16); rbuf.unfilled().advance(4); @@ -163,5 +163,5 @@ fn cursor_set_init() { assert_eq!(rbuf.unfilled().init_ref().len(), 8); assert_eq!(rbuf.unfilled().init_mut().len(), 8); assert_eq!(rbuf.unfilled().uninit_mut().len(), 4); - assert_eq!(unsafe { rbuf.unfilled().as_mut() }.len(), 12); + assert_eq!(unsafe { rbuf.unfilled().as_mut().len() }, 12); } diff --git a/core/tests/io/mod.rs b/coretests/tests/io/mod.rs similarity index 100% rename from core/tests/io/mod.rs rename to coretests/tests/io/mod.rs diff --git a/core/tests/iter/adapters/array_chunks.rs b/coretests/tests/iter/adapters/array_chunks.rs similarity index 100% rename from core/tests/iter/adapters/array_chunks.rs rename to coretests/tests/iter/adapters/array_chunks.rs diff --git a/core/tests/iter/adapters/by_ref_sized.rs b/coretests/tests/iter/adapters/by_ref_sized.rs similarity index 100% rename from core/tests/iter/adapters/by_ref_sized.rs rename to coretests/tests/iter/adapters/by_ref_sized.rs diff --git a/core/tests/iter/adapters/chain.rs b/coretests/tests/iter/adapters/chain.rs similarity index 100% rename from core/tests/iter/adapters/chain.rs rename to coretests/tests/iter/adapters/chain.rs diff --git a/core/tests/iter/adapters/cloned.rs b/coretests/tests/iter/adapters/cloned.rs similarity index 100% rename from core/tests/iter/adapters/cloned.rs rename to coretests/tests/iter/adapters/cloned.rs diff --git a/core/tests/iter/adapters/copied.rs b/coretests/tests/iter/adapters/copied.rs similarity index 100% rename from core/tests/iter/adapters/copied.rs rename to coretests/tests/iter/adapters/copied.rs diff --git a/core/tests/iter/adapters/cycle.rs b/coretests/tests/iter/adapters/cycle.rs similarity index 100% rename from core/tests/iter/adapters/cycle.rs rename to coretests/tests/iter/adapters/cycle.rs diff --git a/core/tests/iter/adapters/enumerate.rs b/coretests/tests/iter/adapters/enumerate.rs similarity index 100% rename from core/tests/iter/adapters/enumerate.rs rename to coretests/tests/iter/adapters/enumerate.rs diff --git a/core/tests/iter/adapters/filter.rs b/coretests/tests/iter/adapters/filter.rs similarity index 100% rename from core/tests/iter/adapters/filter.rs rename to coretests/tests/iter/adapters/filter.rs diff --git a/core/tests/iter/adapters/filter_map.rs b/coretests/tests/iter/adapters/filter_map.rs similarity index 100% rename from core/tests/iter/adapters/filter_map.rs rename to coretests/tests/iter/adapters/filter_map.rs diff --git a/core/tests/iter/adapters/flat_map.rs b/coretests/tests/iter/adapters/flat_map.rs similarity index 100% rename from core/tests/iter/adapters/flat_map.rs rename to coretests/tests/iter/adapters/flat_map.rs diff --git a/core/tests/iter/adapters/flatten.rs b/coretests/tests/iter/adapters/flatten.rs similarity index 100% rename from core/tests/iter/adapters/flatten.rs rename to coretests/tests/iter/adapters/flatten.rs diff --git a/core/tests/iter/adapters/fuse.rs b/coretests/tests/iter/adapters/fuse.rs similarity index 100% rename from core/tests/iter/adapters/fuse.rs rename to coretests/tests/iter/adapters/fuse.rs diff --git a/core/tests/iter/adapters/inspect.rs b/coretests/tests/iter/adapters/inspect.rs similarity index 100% rename from core/tests/iter/adapters/inspect.rs rename to coretests/tests/iter/adapters/inspect.rs diff --git a/core/tests/iter/adapters/intersperse.rs b/coretests/tests/iter/adapters/intersperse.rs similarity index 100% rename from core/tests/iter/adapters/intersperse.rs rename to coretests/tests/iter/adapters/intersperse.rs diff --git a/core/tests/iter/adapters/map.rs b/coretests/tests/iter/adapters/map.rs similarity index 100% rename from core/tests/iter/adapters/map.rs rename to coretests/tests/iter/adapters/map.rs diff --git a/core/tests/iter/adapters/map_windows.rs b/coretests/tests/iter/adapters/map_windows.rs similarity index 98% rename from core/tests/iter/adapters/map_windows.rs rename to coretests/tests/iter/adapters/map_windows.rs index b677f1cfd55e7..01cebc9b27fd8 100644 --- a/core/tests/iter/adapters/map_windows.rs +++ b/coretests/tests/iter/adapters/map_windows.rs @@ -159,11 +159,10 @@ fn output_n2() { >::new(), ); assert_eq!("ab".chars().map_windows(|a: &[_; 2]| *a).collect::>(), vec![['a', 'b']]); - assert_eq!("abcd".chars().map_windows(|a: &[_; 2]| *a).collect::>(), vec![ - ['a', 'b'], - ['b', 'c'], - ['c', 'd'] - ],); + assert_eq!( + "abcd".chars().map_windows(|a: &[_; 2]| *a).collect::>(), + vec![['a', 'b'], ['b', 'c'], ['c', 'd']], + ); } #[test] diff --git a/core/tests/iter/adapters/mod.rs b/coretests/tests/iter/adapters/mod.rs similarity index 100% rename from core/tests/iter/adapters/mod.rs rename to coretests/tests/iter/adapters/mod.rs diff --git a/core/tests/iter/adapters/peekable.rs b/coretests/tests/iter/adapters/peekable.rs similarity index 100% rename from core/tests/iter/adapters/peekable.rs rename to coretests/tests/iter/adapters/peekable.rs diff --git a/core/tests/iter/adapters/scan.rs b/coretests/tests/iter/adapters/scan.rs similarity index 100% rename from core/tests/iter/adapters/scan.rs rename to coretests/tests/iter/adapters/scan.rs diff --git a/core/tests/iter/adapters/skip.rs b/coretests/tests/iter/adapters/skip.rs similarity index 100% rename from core/tests/iter/adapters/skip.rs rename to coretests/tests/iter/adapters/skip.rs diff --git a/core/tests/iter/adapters/skip_while.rs b/coretests/tests/iter/adapters/skip_while.rs similarity index 100% rename from core/tests/iter/adapters/skip_while.rs rename to coretests/tests/iter/adapters/skip_while.rs diff --git a/core/tests/iter/adapters/step_by.rs b/coretests/tests/iter/adapters/step_by.rs similarity index 100% rename from core/tests/iter/adapters/step_by.rs rename to coretests/tests/iter/adapters/step_by.rs diff --git a/core/tests/iter/adapters/take.rs b/coretests/tests/iter/adapters/take.rs similarity index 99% rename from core/tests/iter/adapters/take.rs rename to coretests/tests/iter/adapters/take.rs index 65a8a93b4a916..b932059afec8a 100644 --- a/core/tests/iter/adapters/take.rs +++ b/coretests/tests/iter/adapters/take.rs @@ -255,7 +255,7 @@ fn test_reverse_on_zip() { let zipped_iter = vec_1.iter().zip(core::iter::repeat(0).take(20)); - // Cannot call rev here for automatic reversed zip constuction + // Cannot call rev here for automatic reversed zip construction for (&one, zero) in zipped_iter.rev() { assert_eq!((1, 0), (one, zero)); } diff --git a/core/tests/iter/adapters/take_while.rs b/coretests/tests/iter/adapters/take_while.rs similarity index 100% rename from core/tests/iter/adapters/take_while.rs rename to coretests/tests/iter/adapters/take_while.rs diff --git a/core/tests/iter/adapters/zip.rs b/coretests/tests/iter/adapters/zip.rs similarity index 100% rename from core/tests/iter/adapters/zip.rs rename to coretests/tests/iter/adapters/zip.rs diff --git a/core/tests/iter/mod.rs b/coretests/tests/iter/mod.rs similarity index 100% rename from core/tests/iter/mod.rs rename to coretests/tests/iter/mod.rs diff --git a/core/tests/iter/range.rs b/coretests/tests/iter/range.rs similarity index 100% rename from core/tests/iter/range.rs rename to coretests/tests/iter/range.rs diff --git a/core/tests/iter/sources.rs b/coretests/tests/iter/sources.rs similarity index 100% rename from core/tests/iter/sources.rs rename to coretests/tests/iter/sources.rs diff --git a/core/tests/iter/traits/accum.rs b/coretests/tests/iter/traits/accum.rs similarity index 100% rename from core/tests/iter/traits/accum.rs rename to coretests/tests/iter/traits/accum.rs diff --git a/core/tests/iter/traits/double_ended.rs b/coretests/tests/iter/traits/double_ended.rs similarity index 100% rename from core/tests/iter/traits/double_ended.rs rename to coretests/tests/iter/traits/double_ended.rs diff --git a/core/tests/iter/traits/iterator.rs b/coretests/tests/iter/traits/iterator.rs similarity index 96% rename from core/tests/iter/traits/iterator.rs rename to coretests/tests/iter/traits/iterator.rs index 93ef9c0812b16..e31d2e15b6d7e 100644 --- a/core/tests/iter/traits/iterator.rs +++ b/coretests/tests/iter/traits/iterator.rs @@ -617,6 +617,31 @@ fn test_next_chunk() { assert_eq!(it.next_chunk::<0>().unwrap(), []); } +#[test] +fn test_collect_into_tuples() { + let a = vec![(1, 2, 3), (4, 5, 6), (7, 8, 9)]; + let b = vec![1, 4, 7]; + let c = vec![2, 5, 8]; + let d = vec![3, 6, 9]; + let mut e = (Vec::new(), Vec::new(), Vec::new()); + a.iter().cloned().collect_into(&mut e); + assert!(e.0 == b); + assert!(e.1 == c); + assert!(e.2 == d); +} + +#[test] +fn test_collect_for_tuples() { + let a = vec![(1, 2, 3), (4, 5, 6), (7, 8, 9)]; + let b = vec![1, 4, 7]; + let c = vec![2, 5, 8]; + let d = vec![3, 6, 9]; + let e: (Vec<_>, Vec<_>, Vec<_>) = a.into_iter().collect(); + assert!(e.0 == b); + assert!(e.1 == c); + assert!(e.2 == d); +} + // just tests by whether or not this compiles fn _empty_impl_all_auto_traits() { use std::panic::{RefUnwindSafe, UnwindSafe}; diff --git a/core/tests/iter/traits/mod.rs b/coretests/tests/iter/traits/mod.rs similarity index 100% rename from core/tests/iter/traits/mod.rs rename to coretests/tests/iter/traits/mod.rs diff --git a/core/tests/iter/traits/step.rs b/coretests/tests/iter/traits/step.rs similarity index 100% rename from core/tests/iter/traits/step.rs rename to coretests/tests/iter/traits/step.rs diff --git a/core/tests/lazy.rs b/coretests/tests/lazy.rs similarity index 100% rename from core/tests/lazy.rs rename to coretests/tests/lazy.rs diff --git a/core/tests/lib.rs b/coretests/tests/lib.rs similarity index 89% rename from core/tests/lib.rs rename to coretests/tests/lib.rs index f7825571cd7a8..79022fec8a20c 100644 --- a/core/tests/lib.rs +++ b/coretests/tests/lib.rs @@ -1,7 +1,4 @@ // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(const_three_way_compare))] -#![cfg_attr(bootstrap, feature(strict_provenance))] -#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] #![cfg_attr(target_has_atomic = "128", feature(integer_atomics))] #![cfg_attr(test, feature(cfg_match))] #![feature(alloc_layout_extra)] @@ -14,15 +11,15 @@ #![feature(async_iter_from_iter)] #![feature(async_iterator)] #![feature(bigint_helper_methods)] +#![feature(bstr)] #![feature(cell_update)] +#![feature(char_max_len)] #![feature(clone_to_uninit)] -#![feature(const_align_of_val_raw)] -#![feature(const_black_box)] #![feature(const_eval_select)] -#![feature(const_heap)] -#![feature(const_nonnull_new)] +#![feature(const_swap_nonoverlapping)] #![feature(const_trait_impl)] #![feature(core_intrinsics)] +#![feature(core_intrinsics_fallbacks)] #![feature(core_io_borrowed_buf)] #![feature(core_private_bignum)] #![feature(core_private_diy_float)] @@ -31,14 +28,15 @@ #![feature(duration_constructors)] #![feature(error_generic_member_access)] #![feature(exact_size_is_empty)] +#![feature(extend_one)] #![feature(extern_types)] #![feature(float_minimum_maximum)] #![feature(flt2dec)] #![feature(fmt_internals)] +#![feature(formatting_options)] #![feature(freeze)] #![feature(future_join)] #![feature(generic_assert_internals)] -#![feature(get_many_mut)] #![feature(hasher_prefixfree_extras)] #![feature(hashmap_internals)] #![feature(inline_const_pat)] @@ -46,6 +44,7 @@ #![feature(ip)] #![feature(ip_from)] #![feature(is_ascii_octdigit)] +#![feature(isolate_most_least_significant_one)] #![feature(iter_advance_by)] #![feature(iter_array_chunks)] #![feature(iter_chain)] @@ -65,8 +64,6 @@ #![feature(maybe_uninit_write_slice)] #![feature(min_specialization)] #![feature(never_type)] -#![feature(noop_waker)] -#![feature(num_midpoint)] #![feature(numfmt)] #![feature(pattern)] #![feature(pointer_is_aligned_to)] @@ -76,23 +73,20 @@ #![feature(slice_internals)] #![feature(slice_partition_dedup)] #![feature(slice_split_once)] -#![feature(slice_take)] #![feature(split_array)] #![feature(split_as_slice)] #![feature(std_internals)] #![feature(step_trait)] #![feature(str_internals)] #![feature(strict_provenance_atomic_ptr)] +#![feature(strict_provenance_lints)] #![feature(test)] -#![feature(trait_upcasting)] #![feature(trusted_len)] #![feature(trusted_random_access)] #![feature(try_blocks)] #![feature(try_find)] #![feature(try_trait_v2)] -#![feature(unsigned_is_multiple_of)] #![feature(unsize)] -#![feature(unsized_tuple_coercion)] #![feature(unwrap_infallible)] // tidy-alphabetical-end #![allow(internal_features)] @@ -101,10 +95,13 @@ /// Version of `assert_matches` that ignores fancy runtime printing in const context and uses structural equality. macro_rules! assert_eq_const_safe { + ($left:expr, $right:expr) => { + assert_eq_const_safe!($left, $right, concat!(stringify!($left), " == ", stringify!($right))); + }; ($left:expr, $right:expr$(, $($arg:tt)+)?) => { { fn runtime() { - assert_eq!($left, $right, $($arg)*); + assert_eq!($left, $right, $($($arg)*),*); } const fn compiletime() { assert!(matches!($left, const { $right })); @@ -139,6 +136,7 @@ mod asserting; mod async_iter; mod atomic; mod bool; +mod bstr; mod cell; mod char; mod clone; diff --git a/core/tests/macros.rs b/coretests/tests/macros.rs similarity index 72% rename from core/tests/macros.rs rename to coretests/tests/macros.rs index fdb4ea2941285..b30a40b7df28e 100644 --- a/core/tests/macros.rs +++ b/coretests/tests/macros.rs @@ -10,7 +10,7 @@ struct Struct; impl Trait for Struct { cfg_match! { - cfg(feature = "blah") => { + feature = "blah" => { fn blah(&self) { unimplemented!(); } @@ -47,21 +47,21 @@ fn matches_leading_pipe() { #[test] fn cfg_match_basic() { cfg_match! { - cfg(target_pointer_width = "64") => { fn f0_() -> bool { true }} + target_pointer_width = "64" => { fn f0_() -> bool { true }} } cfg_match! { - cfg(unix) => { fn f1_() -> bool { true }} - cfg(any(target_os = "macos", target_os = "linux")) => { fn f1_() -> bool { false }} + unix => { fn f1_() -> bool { true } } + any(target_os = "macos", target_os = "linux") => { fn f1_() -> bool { false }} } cfg_match! { - cfg(target_pointer_width = "32") => { fn f2_() -> bool { false }} - cfg(target_pointer_width = "64") => { fn f2_() -> bool { true }} + target_pointer_width = "32" => { fn f2_() -> bool { false } } + target_pointer_width = "64" => { fn f2_() -> bool { true } } } cfg_match! { - cfg(target_pointer_width = "16") => { fn f3_() -> i32 { 1 }} + target_pointer_width = "16" => { fn f3_() -> i32 { 1 } } _ => { fn f3_() -> i32 { 2 }} } @@ -83,7 +83,7 @@ fn cfg_match_basic() { #[test] fn cfg_match_debug_assertions() { cfg_match! { - cfg(debug_assertions) => { + debug_assertions => { assert!(cfg!(debug_assertions)); assert_eq!(4, 2+2); } @@ -98,13 +98,13 @@ fn cfg_match_debug_assertions() { #[test] fn cfg_match_no_duplication_on_64() { cfg_match! { - cfg(windows) => { + windows => { fn foo() {} } - cfg(unix) => { + unix => { fn foo() {} } - cfg(target_pointer_width = "64") => { + target_pointer_width = "64" => { fn foo() {} } } @@ -114,7 +114,7 @@ fn cfg_match_no_duplication_on_64() { #[test] fn cfg_match_options() { cfg_match! { - cfg(test) => { + test => { use core::option::Option as Option2; fn works1() -> Option2 { Some(1) } } @@ -122,26 +122,26 @@ fn cfg_match_options() { } cfg_match! { - cfg(feature = "foo") => { fn works2() -> bool { false } } - cfg(test) => { fn works2() -> bool { true } } + feature = "foo" => { fn works2() -> bool { false } } + test => { fn works2() -> bool { true } } _ => { fn works2() -> bool { false } } } cfg_match! { - cfg(feature = "foo") => { fn works3() -> bool { false } } + feature = "foo" => { fn works3() -> bool { false } } _ => { fn works3() -> bool { true } } } cfg_match! { - cfg(test) => { + test => { use core::option::Option as Option3; fn works4() -> Option3 { Some(1) } } } cfg_match! { - cfg(feature = "foo") => { fn works5() -> bool { false } } - cfg(test) => { fn works5() -> bool { true } } + feature = "foo" => { fn works5() -> bool { false } } + test => { fn works5() -> bool { true } } } assert!(works1().is_some()); @@ -154,7 +154,7 @@ fn cfg_match_options() { #[test] fn cfg_match_two_functions() { cfg_match! { - cfg(target_pointer_width = "64") => { + target_pointer_width = "64" => { fn foo1() {} fn bar1() {} } @@ -178,7 +178,7 @@ fn cfg_match_two_functions() { fn _accepts_expressions() -> i32 { cfg_match! { - cfg(unix) => { 1 } + unix => { 1 } _ => { 2 } } } @@ -189,7 +189,18 @@ fn _allows_stmt_expr_attributes() { let one = 1; let two = 2; cfg_match! { - cfg(unix) => { one * two; } + unix => { one * two; } _ => { one + two; } } } + +fn _expression() { + let _ = cfg_match!({ + windows => { + " XP" + } + _ => { + "" + } + }); +} diff --git a/core/tests/manually_drop.rs b/coretests/tests/manually_drop.rs similarity index 100% rename from core/tests/manually_drop.rs rename to coretests/tests/manually_drop.rs diff --git a/core/tests/mem.rs b/coretests/tests/mem.rs similarity index 95% rename from core/tests/mem.rs rename to coretests/tests/mem.rs index f3b4387f6a898..9cb94ca3b0ff0 100644 --- a/core/tests/mem.rs +++ b/coretests/tests/mem.rs @@ -200,60 +200,60 @@ fn uninit_array_assume_init() { } #[test] -fn uninit_write_slice() { +fn uninit_write_copy_of_slice() { let mut dst = [MaybeUninit::new(255); 64]; let src = [0; 64]; - assert_eq!(MaybeUninit::copy_from_slice(&mut dst, &src), &src); + assert_eq!(dst.write_copy_of_slice(&src), &src); } #[test] #[should_panic(expected = "source slice length (32) does not match destination slice length (64)")] -fn uninit_write_slice_panic_lt() { +fn uninit_write_copy_of_slice_panic_lt() { let mut dst = [MaybeUninit::uninit(); 64]; let src = [0; 32]; - MaybeUninit::copy_from_slice(&mut dst, &src); + dst.write_copy_of_slice(&src); } #[test] #[should_panic(expected = "source slice length (128) does not match destination slice length (64)")] -fn uninit_write_slice_panic_gt() { +fn uninit_write_copy_of_slice_panic_gt() { let mut dst = [MaybeUninit::uninit(); 64]; let src = [0; 128]; - MaybeUninit::copy_from_slice(&mut dst, &src); + dst.write_copy_of_slice(&src); } #[test] -fn uninit_clone_from_slice() { +fn uninit_write_clone_of_slice() { let mut dst = [MaybeUninit::new(255); 64]; let src = [0; 64]; - assert_eq!(MaybeUninit::clone_from_slice(&mut dst, &src), &src); + assert_eq!(dst.write_clone_of_slice(&src), &src); } #[test] #[should_panic(expected = "destination and source slices have different lengths")] -fn uninit_write_slice_cloned_panic_lt() { +fn uninit_write_clone_of_slice_panic_lt() { let mut dst = [MaybeUninit::uninit(); 64]; let src = [0; 32]; - MaybeUninit::clone_from_slice(&mut dst, &src); + dst.write_clone_of_slice(&src); } #[test] #[should_panic(expected = "destination and source slices have different lengths")] -fn uninit_write_slice_cloned_panic_gt() { +fn uninit_write_clone_of_slice_panic_gt() { let mut dst = [MaybeUninit::uninit(); 64]; let src = [0; 128]; - MaybeUninit::clone_from_slice(&mut dst, &src); + dst.write_clone_of_slice(&src); } #[test] #[cfg(panic = "unwind")] -fn uninit_write_slice_cloned_mid_panic() { +fn uninit_write_clone_of_slice_mid_panic() { use std::panic; enum IncrementOrPanic { @@ -289,7 +289,7 @@ fn uninit_write_slice_cloned_mid_panic() { ]; let err = panic::catch_unwind(panic::AssertUnwindSafe(|| { - MaybeUninit::clone_from_slice(&mut dst, &src); + dst.write_clone_of_slice(&src); })); drop(src); @@ -317,11 +317,11 @@ impl Drop for Bomb { } #[test] -fn uninit_write_slice_cloned_no_drop() { +fn uninit_write_clone_of_slice_no_drop() { let mut dst = [MaybeUninit::uninit()]; let src = [Bomb]; - MaybeUninit::clone_from_slice(&mut dst, &src); + dst.write_clone_of_slice(&src); forget(src); } @@ -648,7 +648,7 @@ fn offset_of_dst() { z: dyn Trait, } - extern "C" { + unsafe extern "C" { type Extern; } diff --git a/core/tests/net/ip_addr.rs b/coretests/tests/net/ip_addr.rs similarity index 99% rename from core/tests/net/ip_addr.rs rename to coretests/tests/net/ip_addr.rs index 707f9a160e127..f01b43282ec42 100644 --- a/core/tests/net/ip_addr.rs +++ b/coretests/tests/net/ip_addr.rs @@ -332,6 +332,7 @@ fn ip_properties() { check!("ff08::", global | multicast); check!("ff0e::", global | multicast); check!("2001:db8:85a3::8a2e:370:7334", doc); + check!("3fff:fff:ffff:ffff:ffff:ffff:ffff:ffff", doc); check!("2001:2::ac32:23ff:21", benchmarking); check!("102:304:506:708:90a:b0c:d0e:f10", global); } @@ -790,6 +791,15 @@ fn ipv6_properties() { documentation ); + check!( + "3fff:fff:ffff:ffff:ffff:ffff:ffff:ffff", + &[ + 0x3f, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff + ], + documentation + ); + check!( "2001:2::ac32:23ff:21", &[0x20, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0xac, 0x32, 0x23, 0xff, 0, 0x21], diff --git a/core/tests/net/mod.rs b/coretests/tests/net/mod.rs similarity index 100% rename from core/tests/net/mod.rs rename to coretests/tests/net/mod.rs diff --git a/core/tests/net/parser.rs b/coretests/tests/net/parser.rs similarity index 100% rename from core/tests/net/parser.rs rename to coretests/tests/net/parser.rs diff --git a/core/tests/net/socket_addr.rs b/coretests/tests/net/socket_addr.rs similarity index 100% rename from core/tests/net/socket_addr.rs rename to coretests/tests/net/socket_addr.rs diff --git a/core/tests/nonzero.rs b/coretests/tests/nonzero.rs similarity index 79% rename from core/tests/nonzero.rs rename to coretests/tests/nonzero.rs index 43c279053d829..00232c9b7061a 100644 --- a/core/tests/nonzero.rs +++ b/coretests/tests/nonzero.rs @@ -1,6 +1,5 @@ use core::num::{IntErrorKind, NonZero}; use core::option::Option::None; -use std::mem::size_of; #[test] fn test_create_nonzero_instance() { @@ -321,6 +320,106 @@ fn nonzero_trailing_zeros() { assert_eq!(TRAILING_ZEROS, 2); } +#[test] +fn test_nonzero_isolate_most_significant_one() { + // Signed most significant one + macro_rules! nonzero_int_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = -1; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + // Right shift the most significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS >> i).unwrap().isolate_most_significant_one(), + NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_most_significant_one() + ); + i += 1; + } + } + )+ + }; + } + + // Unsigned most significant one + macro_rules! nonzero_uint_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = <$T>::MAX; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS >> i).unwrap().isolate_most_significant_one(), + NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_most_significant_one(), + ); + i += 1; + } + } + )+ + }; + } + + nonzero_int_impl!(i8, i16, i32, i64, i128, isize); + nonzero_uint_impl!(u8, u16, u32, u64, u128, usize); +} + +#[test] +fn test_nonzero_isolate_least_significant_one() { + // Signed least significant one + macro_rules! nonzero_int_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = -1; + const LEAST_SIG_ONE: $T = 1; + + // Left shift the least significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS << i).unwrap().isolate_least_significant_one(), + NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_least_significant_one() + ); + i += 1; + } + } + )+ + }; + } + + // Unsigned least significant one + macro_rules! nonzero_uint_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = <$T>::MAX; + const LEAST_SIG_ONE: $T = 1; + + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS << i).unwrap().isolate_least_significant_one(), + NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_least_significant_one(), + ); + i += 1; + } + } + )+ + }; + } + + nonzero_int_impl!(i8, i16, i32, i64, i128, isize); + nonzero_uint_impl!(u8, u16, u32, u64, u128, usize); +} + #[test] fn test_nonzero_uint_div() { let nz = NonZero::new(1).unwrap(); diff --git a/core/tests/num/bignum.rs b/coretests/tests/num/bignum.rs similarity index 100% rename from core/tests/num/bignum.rs rename to coretests/tests/num/bignum.rs diff --git a/core/tests/num/const_from.rs b/coretests/tests/num/const_from.rs similarity index 100% rename from core/tests/num/const_from.rs rename to coretests/tests/num/const_from.rs diff --git a/coretests/tests/num/dec2flt/decimal.rs b/coretests/tests/num/dec2flt/decimal.rs new file mode 100644 index 0000000000000..1fa06de692e07 --- /dev/null +++ b/coretests/tests/num/dec2flt/decimal.rs @@ -0,0 +1,28 @@ +use core::num::dec2flt::decimal::Decimal; + +type FPath = ((i64, u64, bool, bool), Option); + +const FPATHS_F32: &[FPath] = + &[((0, 0, false, false), Some(0.0)), ((0, 0, false, false), Some(0.0))]; +const FPATHS_F64: &[FPath] = + &[((0, 0, false, false), Some(0.0)), ((0, 0, false, false), Some(0.0))]; + +#[test] +fn check_fast_path_f32() { + for ((exponent, mantissa, negative, many_digits), expected) in FPATHS_F32.iter().copied() { + let dec = Decimal { exponent, mantissa, negative, many_digits }; + let actual = dec.try_fast_path::(); + + assert_eq!(actual, expected); + } +} + +#[test] +fn check_fast_path_f64() { + for ((exponent, mantissa, negative, many_digits), expected) in FPATHS_F64.iter().copied() { + let dec = Decimal { exponent, mantissa, negative, many_digits }; + let actual = dec.try_fast_path::(); + + assert_eq!(actual, expected); + } +} diff --git a/coretests/tests/num/dec2flt/decimal_seq.rs b/coretests/tests/num/dec2flt/decimal_seq.rs new file mode 100644 index 0000000000000..f46ba7c465a6e --- /dev/null +++ b/coretests/tests/num/dec2flt/decimal_seq.rs @@ -0,0 +1,30 @@ +use core::num::dec2flt::decimal_seq::{DecimalSeq, parse_decimal_seq}; + +#[test] +fn test_trim() { + let mut dec = DecimalSeq::default(); + let digits = [1, 2, 3, 4]; + + dec.digits[0..4].copy_from_slice(&digits); + dec.num_digits = 8; + dec.trim(); + + assert_eq!(dec.digits[0..4], digits); + assert_eq!(dec.num_digits, 4); +} + +#[test] +fn test_parse() { + let tests = [("1.234", [1, 2, 3, 4], 1)]; + + for (s, exp_digits, decimal_point) in tests { + let actual = parse_decimal_seq(s.as_bytes()); + let mut digits = [0; DecimalSeq::MAX_DIGITS]; + digits[..exp_digits.len()].copy_from_slice(&exp_digits); + + let expected = + DecimalSeq { num_digits: exp_digits.len(), decimal_point, truncated: false, digits }; + + assert_eq!(actual, expected); + } +} diff --git a/coretests/tests/num/dec2flt/float.rs b/coretests/tests/num/dec2flt/float.rs new file mode 100644 index 0000000000000..b5afd3e3b2436 --- /dev/null +++ b/coretests/tests/num/dec2flt/float.rs @@ -0,0 +1,73 @@ +use core::num::dec2flt::float::RawFloat; + +#[test] +fn test_f32_integer_decode() { + assert_eq!(3.14159265359f32.integer_decode(), (13176795, -22, 1)); + assert_eq!((-8573.5918555f32).integer_decode(), (8779358, -10, -1)); + assert_eq!(2f32.powf(100.0).integer_decode(), (8388608, 77, 1)); + assert_eq!(0f32.integer_decode(), (0, -150, 1)); + assert_eq!((-0f32).integer_decode(), (0, -150, -1)); + assert_eq!(f32::INFINITY.integer_decode(), (8388608, 105, 1)); + assert_eq!(f32::NEG_INFINITY.integer_decode(), (8388608, 105, -1)); + + // Ignore the "sign" (quiet / signalling flag) of NAN. + // It can vary between runtime operations and LLVM folding. + let (nan_m, nan_p, _nan_s) = f32::NAN.integer_decode(); + assert_eq!((nan_m, nan_p), (12582912, 105)); +} + +#[test] +fn test_f64_integer_decode() { + assert_eq!(3.14159265359f64.integer_decode(), (7074237752028906, -51, 1)); + assert_eq!((-8573.5918555f64).integer_decode(), (4713381968463931, -39, -1)); + assert_eq!(2f64.powf(100.0).integer_decode(), (4503599627370496, 48, 1)); + assert_eq!(0f64.integer_decode(), (0, -1075, 1)); + assert_eq!((-0f64).integer_decode(), (0, -1075, -1)); + assert_eq!(f64::INFINITY.integer_decode(), (4503599627370496, 972, 1)); + assert_eq!(f64::NEG_INFINITY.integer_decode(), (4503599627370496, 972, -1)); + + // Ignore the "sign" (quiet / signalling flag) of NAN. + // It can vary between runtime operations and LLVM folding. + let (nan_m, nan_p, _nan_s) = f64::NAN.integer_decode(); + assert_eq!((nan_m, nan_p), (6755399441055744, 972)); +} + +/* Sanity checks of computed magic numbers */ + +#[test] +fn test_f32_consts() { + assert_eq!(::INFINITY, f32::INFINITY); + assert_eq!(::NEG_INFINITY, -f32::INFINITY); + assert_eq!(::NAN.to_bits(), f32::NAN.to_bits()); + assert_eq!(::NEG_NAN.to_bits(), (-f32::NAN).to_bits()); + assert_eq!(::SIG_BITS, 23); + assert_eq!(::MIN_EXPONENT_ROUND_TO_EVEN, -17); + assert_eq!(::MAX_EXPONENT_ROUND_TO_EVEN, 10); + assert_eq!(::MIN_EXPONENT_FAST_PATH, -10); + assert_eq!(::MAX_EXPONENT_FAST_PATH, 10); + assert_eq!(::MAX_EXPONENT_DISGUISED_FAST_PATH, 17); + assert_eq!(::EXP_MIN, -126); + assert_eq!(::EXP_SAT, 0xff); + assert_eq!(::SMALLEST_POWER_OF_TEN, -65); + assert_eq!(::LARGEST_POWER_OF_TEN, 38); + assert_eq!(::MAX_MANTISSA_FAST_PATH, 16777216); +} + +#[test] +fn test_f64_consts() { + assert_eq!(::INFINITY, f64::INFINITY); + assert_eq!(::NEG_INFINITY, -f64::INFINITY); + assert_eq!(::NAN.to_bits(), f64::NAN.to_bits()); + assert_eq!(::NEG_NAN.to_bits(), (-f64::NAN).to_bits()); + assert_eq!(::SIG_BITS, 52); + assert_eq!(::MIN_EXPONENT_ROUND_TO_EVEN, -4); + assert_eq!(::MAX_EXPONENT_ROUND_TO_EVEN, 23); + assert_eq!(::MIN_EXPONENT_FAST_PATH, -22); + assert_eq!(::MAX_EXPONENT_FAST_PATH, 22); + assert_eq!(::MAX_EXPONENT_DISGUISED_FAST_PATH, 37); + assert_eq!(::EXP_MIN, -1022); + assert_eq!(::EXP_SAT, 0x7ff); + assert_eq!(::SMALLEST_POWER_OF_TEN, -342); + assert_eq!(::LARGEST_POWER_OF_TEN, 308); + assert_eq!(::MAX_MANTISSA_FAST_PATH, 9007199254740992); +} diff --git a/core/tests/num/dec2flt/lemire.rs b/coretests/tests/num/dec2flt/lemire.rs similarity index 84% rename from core/tests/num/dec2flt/lemire.rs rename to coretests/tests/num/dec2flt/lemire.rs index f71bbb7c7a318..0db80fbd52506 100644 --- a/core/tests/num/dec2flt/lemire.rs +++ b/coretests/tests/num/dec2flt/lemire.rs @@ -1,13 +1,14 @@ +use core::num::dec2flt::float::RawFloat; use core::num::dec2flt::lemire::compute_float; fn compute_float32(q: i64, w: u64) -> (i32, u64) { let fp = compute_float::(q, w); - (fp.e, fp.f) + (fp.p_biased, fp.m) } fn compute_float64(q: i64, w: u64) -> (i32, u64) { let fp = compute_float::(q, w); - (fp.e, fp.f) + (fp.p_biased, fp.m) } #[test] @@ -27,6 +28,11 @@ fn compute_float_f32_rounding() { // Let's check the lines to see if anything is different in table... assert_eq!(compute_float32(-10, 167772190000000000), (151, 2)); assert_eq!(compute_float32(-10, 167772200000000000), (151, 2)); + + // Check the rounding point between infinity and the next representable number down + assert_eq!(compute_float32(38, 3), (f32::INFINITE_POWER - 1, 6402534)); + assert_eq!(compute_float32(38, 4), (f32::INFINITE_POWER, 0)); // infinity + assert_eq!(compute_float32(20, 3402823470000000000), (f32::INFINITE_POWER - 1, 8388607)); } #[test] diff --git a/core/tests/num/dec2flt/mod.rs b/coretests/tests/num/dec2flt/mod.rs similarity index 99% rename from core/tests/num/dec2flt/mod.rs rename to coretests/tests/num/dec2flt/mod.rs index 874e0ec7093c7..a9025be5ca7f1 100644 --- a/core/tests/num/dec2flt/mod.rs +++ b/coretests/tests/num/dec2flt/mod.rs @@ -1,5 +1,7 @@ #![allow(overflowing_literals)] +mod decimal; +mod decimal_seq; mod float; mod lemire; mod parse; diff --git a/core/tests/num/dec2flt/parse.rs b/coretests/tests/num/dec2flt/parse.rs similarity index 91% rename from core/tests/num/dec2flt/parse.rs rename to coretests/tests/num/dec2flt/parse.rs index 4a5d24ba7d5fa..59be3915052d8 100644 --- a/core/tests/num/dec2flt/parse.rs +++ b/coretests/tests/num/dec2flt/parse.rs @@ -1,9 +1,9 @@ -use core::num::dec2flt::number::Number; +use core::num::dec2flt::decimal::Decimal; use core::num::dec2flt::parse::parse_number; use core::num::dec2flt::{dec2flt, pfe_invalid}; -fn new_number(e: i64, m: u64) -> Number { - Number { exponent: e, mantissa: m, negative: false, many_digits: false } +fn new_dec(e: i64, m: u64) -> Decimal { + Decimal { exponent: e, mantissa: m, negative: false, many_digits: false } } #[test] @@ -31,23 +31,23 @@ fn invalid_chars() { } } -fn parse_positive(s: &[u8]) -> Option { +fn parse_positive(s: &[u8]) -> Option { parse_number(s) } #[test] fn valid() { - assert_eq!(parse_positive(b"123.456e789"), Some(new_number(786, 123456))); - assert_eq!(parse_positive(b"123.456e+789"), Some(new_number(786, 123456))); - assert_eq!(parse_positive(b"123.456e-789"), Some(new_number(-792, 123456))); - assert_eq!(parse_positive(b".050"), Some(new_number(-3, 50))); - assert_eq!(parse_positive(b"999"), Some(new_number(0, 999))); - assert_eq!(parse_positive(b"1.e300"), Some(new_number(300, 1))); - assert_eq!(parse_positive(b".1e300"), Some(new_number(299, 1))); - assert_eq!(parse_positive(b"101e-33"), Some(new_number(-33, 101))); + assert_eq!(parse_positive(b"123.456e789"), Some(new_dec(786, 123456))); + assert_eq!(parse_positive(b"123.456e+789"), Some(new_dec(786, 123456))); + assert_eq!(parse_positive(b"123.456e-789"), Some(new_dec(-792, 123456))); + assert_eq!(parse_positive(b".050"), Some(new_dec(-3, 50))); + assert_eq!(parse_positive(b"999"), Some(new_dec(0, 999))); + assert_eq!(parse_positive(b"1.e300"), Some(new_dec(300, 1))); + assert_eq!(parse_positive(b".1e300"), Some(new_dec(299, 1))); + assert_eq!(parse_positive(b"101e-33"), Some(new_dec(-33, 101))); let zeros = "0".repeat(25); let s = format!("1.5e{zeros}"); - assert_eq!(parse_positive(s.as_bytes()), Some(new_number(-1, 15))); + assert_eq!(parse_positive(s.as_bytes()), Some(new_dec(-1, 15))); } macro_rules! assert_float_result_bits_eq { @@ -57,6 +57,21 @@ macro_rules! assert_float_result_bits_eq { }}; } +#[test] +fn regression() { + // These showed up in fuzz tests when the minimum exponent was incorrect. + assert_float_result_bits_eq!( + 0x0, + f64, + "3313756768023998018398807867233977556112078681253148176737587500333136120852692315608454494981109839693784033457129423181787087843504060087613228932431e-475" + ); + assert_float_result_bits_eq!( + 0x0, + f64, + "5298127456259331337220.92759278003098321644501973966679724599271041396379712108366679824365568578569680024083293475291869842408884554511641179110778276695274832779269225510492006696321279587846006535230380114430977056662212751544508159333199129106162019382177820713609e-346" + ); +} + #[test] fn issue31109() { // Regression test for #31109. diff --git a/core/tests/num/float_iter_sum_identity.rs b/coretests/tests/num/float_iter_sum_identity.rs similarity index 100% rename from core/tests/num/float_iter_sum_identity.rs rename to coretests/tests/num/float_iter_sum_identity.rs diff --git a/core/tests/num/flt2dec/estimator.rs b/coretests/tests/num/flt2dec/estimator.rs similarity index 100% rename from core/tests/num/flt2dec/estimator.rs rename to coretests/tests/num/flt2dec/estimator.rs diff --git a/core/tests/num/flt2dec/mod.rs b/coretests/tests/num/flt2dec/mod.rs similarity index 98% rename from core/tests/num/flt2dec/mod.rs rename to coretests/tests/num/flt2dec/mod.rs index 3d82522481316..c64bb0a30720a 100644 --- a/core/tests/num/flt2dec/mod.rs +++ b/coretests/tests/num/flt2dec/mod.rs @@ -80,7 +80,7 @@ fn ldexp_f32(a: f32, b: i32) -> f32 { } fn ldexp_f64(a: f64, b: i32) -> f64 { - extern "C" { + unsafe extern "C" { fn ldexp(x: f64, n: i32) -> f64; } // SAFETY: assuming a correct `ldexp` has been supplied, the given arguments cannot possibly @@ -577,7 +577,7 @@ where } // very large output - assert_eq!(to_string(f, 1.1, Minus, 80000), format!("1.1{:0>79999}", "")); + assert_eq!(to_string(f, 1.1, Minus, 50000), format!("1.1{:0>49999}", "")); } pub fn to_shortest_exp_str_test(mut f_: F) @@ -914,22 +914,22 @@ where ); // very large output - assert_eq!(to_string(f, 0.0, Minus, 80000, false), format!("0.{:0>79999}e0", "")); - assert_eq!(to_string(f, 1.0e1, Minus, 80000, false), format!("1.{:0>79999}e1", "")); - assert_eq!(to_string(f, 1.0e0, Minus, 80000, false), format!("1.{:0>79999}e0", "")); + assert_eq!(to_string(f, 0.0, Minus, 50000, false), format!("0.{:0>49999}e0", "")); + assert_eq!(to_string(f, 1.0e1, Minus, 50000, false), format!("1.{:0>49999}e1", "")); + assert_eq!(to_string(f, 1.0e0, Minus, 50000, false), format!("1.{:0>49999}e0", "")); assert_eq!( - to_string(f, 1.0e-1, Minus, 80000, false), + to_string(f, 1.0e-1, Minus, 50000, false), format!( - "1.000000000000000055511151231257827021181583404541015625{:0>79945}\ + "1.000000000000000055511151231257827021181583404541015625{:0>49945}\ e-1", "" ) ); assert_eq!( - to_string(f, 1.0e-20, Minus, 80000, false), + to_string(f, 1.0e-20, Minus, 50000, false), format!( "9.999999999999999451532714542095716517295037027873924471077157760\ - 66783064379706047475337982177734375{:0>79901}e-21", + 66783064379706047475337982177734375{:0>49901}e-21", "" ) ); @@ -1150,18 +1150,18 @@ where ); // very large output - assert_eq!(to_string(f, 0.0, Minus, 80000), format!("0.{:0>80000}", "")); - assert_eq!(to_string(f, 1.0e1, Minus, 80000), format!("10.{:0>80000}", "")); - assert_eq!(to_string(f, 1.0e0, Minus, 80000), format!("1.{:0>80000}", "")); + assert_eq!(to_string(f, 0.0, Minus, 50000), format!("0.{:0>50000}", "")); + assert_eq!(to_string(f, 1.0e1, Minus, 50000), format!("10.{:0>50000}", "")); + assert_eq!(to_string(f, 1.0e0, Minus, 50000), format!("1.{:0>50000}", "")); assert_eq!( - to_string(f, 1.0e-1, Minus, 80000), - format!("0.1000000000000000055511151231257827021181583404541015625{:0>79945}", "") + to_string(f, 1.0e-1, Minus, 50000), + format!("0.1000000000000000055511151231257827021181583404541015625{:0>49945}", "") ); assert_eq!( - to_string(f, 1.0e-20, Minus, 80000), + to_string(f, 1.0e-20, Minus, 50000), format!( "0.0000000000000000000099999999999999994515327145420957165172950370\ - 2787392447107715776066783064379706047475337982177734375{:0>79881}", + 2787392447107715776066783064379706047475337982177734375{:0>49881}", "" ) ); diff --git a/core/tests/num/flt2dec/random.rs b/coretests/tests/num/flt2dec/random.rs similarity index 94% rename from core/tests/num/flt2dec/random.rs rename to coretests/tests/num/flt2dec/random.rs index 99fc23af7ea9d..586b49df7d9b2 100644 --- a/core/tests/num/flt2dec/random.rs +++ b/coretests/tests/num/flt2dec/random.rs @@ -5,7 +5,7 @@ use core::num::flt2dec::{DecodableFloat, Decoded, FullDecoded, MAX_SIG_DIGITS, d use std::mem::MaybeUninit; use std::str; -use rand::distributions::{Distribution, Uniform}; +use rand::distr::{Distribution, Uniform}; pub fn decode_finite(v: T) -> Decoded { match decode(v).1 { @@ -84,11 +84,8 @@ where F: for<'a> FnMut(&Decoded, &'a mut [MaybeUninit]) -> Option<(&'a [u8], i16)>, G: for<'a> FnMut(&Decoded, &'a mut [MaybeUninit]) -> (&'a [u8], i16), { - if cfg!(target_os = "emscripten") { - return; // using rng pulls in i128 support, which doesn't work - } let mut rng = crate::test_rng(); - let f32_range = Uniform::new(0x0000_0001u32, 0x7f80_0000); + let f32_range = Uniform::new(0x0000_0001u32, 0x7f80_0000).unwrap(); iterate("f32_random_equivalence_test", k, n, f, g, |_| { let x = f32::from_bits(f32_range.sample(&mut rng)); decode_finite(x) @@ -100,11 +97,8 @@ where F: for<'a> FnMut(&Decoded, &'a mut [MaybeUninit]) -> Option<(&'a [u8], i16)>, G: for<'a> FnMut(&Decoded, &'a mut [MaybeUninit]) -> (&'a [u8], i16), { - if cfg!(target_os = "emscripten") { - return; // using rng pulls in i128 support, which doesn't work - } let mut rng = crate::test_rng(); - let f64_range = Uniform::new(0x0000_0000_0000_0001u64, 0x7ff0_0000_0000_0000); + let f64_range = Uniform::new(0x0000_0000_0000_0001u64, 0x7ff0_0000_0000_0000).unwrap(); iterate("f64_random_equivalence_test", k, n, f, g, |_| { let x = f64::from_bits(f64_range.sample(&mut rng)); decode_finite(x) diff --git a/core/tests/num/flt2dec/strategy/dragon.rs b/coretests/tests/num/flt2dec/strategy/dragon.rs similarity index 100% rename from core/tests/num/flt2dec/strategy/dragon.rs rename to coretests/tests/num/flt2dec/strategy/dragon.rs diff --git a/core/tests/num/flt2dec/strategy/grisu.rs b/coretests/tests/num/flt2dec/strategy/grisu.rs similarity index 100% rename from core/tests/num/flt2dec/strategy/grisu.rs rename to coretests/tests/num/flt2dec/strategy/grisu.rs diff --git a/coretests/tests/num/i128.rs b/coretests/tests/num/i128.rs new file mode 100644 index 0000000000000..745fee05164c9 --- /dev/null +++ b/coretests/tests/num/i128.rs @@ -0,0 +1 @@ +int_module!(i128, u128); diff --git a/coretests/tests/num/i16.rs b/coretests/tests/num/i16.rs new file mode 100644 index 0000000000000..6acb8371b87d8 --- /dev/null +++ b/coretests/tests/num/i16.rs @@ -0,0 +1 @@ +int_module!(i16, u16); diff --git a/core/tests/num/i32.rs b/coretests/tests/num/i32.rs similarity index 97% rename from core/tests/num/i32.rs rename to coretests/tests/num/i32.rs index efd5b1596a80d..38d5071f71d6c 100644 --- a/core/tests/num/i32.rs +++ b/coretests/tests/num/i32.rs @@ -1,4 +1,4 @@ -int_module!(i32); +int_module!(i32, u32); #[test] fn test_arith_operation() { diff --git a/coretests/tests/num/i64.rs b/coretests/tests/num/i64.rs new file mode 100644 index 0000000000000..f8dd5f9be7fe2 --- /dev/null +++ b/coretests/tests/num/i64.rs @@ -0,0 +1 @@ +int_module!(i64, u64); diff --git a/coretests/tests/num/i8.rs b/coretests/tests/num/i8.rs new file mode 100644 index 0000000000000..a10906618c937 --- /dev/null +++ b/coretests/tests/num/i8.rs @@ -0,0 +1 @@ +int_module!(i8, u8); diff --git a/core/tests/num/ieee754.rs b/coretests/tests/num/ieee754.rs similarity index 100% rename from core/tests/num/ieee754.rs rename to coretests/tests/num/ieee754.rs diff --git a/core/tests/num/int_log.rs b/coretests/tests/num/int_log.rs similarity index 68% rename from core/tests/num/int_log.rs rename to coretests/tests/num/int_log.rs index 60902752dab64..e8d35fc21ce6e 100644 --- a/core/tests/num/int_log.rs +++ b/coretests/tests/num/int_log.rs @@ -1,5 +1,13 @@ //! Tests for the `Integer::{ilog,log2,log10}` methods. +/// Rounds the argument down to the next integer, except that we account for potential imprecision +/// in the input, so if `f` is very close to an integer, it will round to that. +fn round_down_imprecise(f: f32) -> u32 { + // Rounds up for values less than 16*EPSILON below an integer, + // and rounds down for everything else. + (f + 16.0 * f32::EPSILON) as u32 +} + #[test] fn checked_ilog() { assert_eq!(999u32.checked_ilog(10), Some(2)); @@ -25,15 +33,24 @@ fn checked_ilog() { } #[cfg(not(miri))] // Miri is too slow for i in 1..=i16::MAX { - assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32), "checking {i}"); + assert_eq!( + i.checked_ilog(13), + Some(round_down_imprecise((i as f32).log(13.0))), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=u16::MAX { - assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32), "checking {i}"); + assert_eq!( + i.checked_ilog(13), + Some(round_down_imprecise((i as f32).log(13.0))), + "checking {i}" + ); } } #[test] +#[cfg_attr(miri, ignore)] // FIXME test is broken on Miri: https://github.com/rust-lang/rust/issues/137591 fn checked_ilog2() { assert_eq!(5u32.checked_ilog2(), Some(2)); assert_eq!(0u64.checked_ilog2(), None); @@ -45,25 +62,34 @@ fn checked_ilog2() { assert_eq!(0i8.checked_ilog2(), None); assert_eq!(0i16.checked_ilog2(), None); - assert_eq!(8192u16.checked_ilog2(), Some((8192f32).log2() as u32)); - assert_eq!(32768u16.checked_ilog2(), Some((32768f32).log2() as u32)); - assert_eq!(8192i16.checked_ilog2(), Some((8192f32).log2() as u32)); + assert_eq!(8192u16.checked_ilog2(), Some(round_down_imprecise((8192f32).log2()))); + assert_eq!(32768u16.checked_ilog2(), Some(round_down_imprecise((32768f32).log2()))); + assert_eq!(8192i16.checked_ilog2(), Some(round_down_imprecise((8192f32).log2()))); for i in 1..=u8::MAX { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=u16::MAX { - // Guard against Android's imprecise f32::ilog2 implementation. - if i != 8192 && i != 32768 { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); - } + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } for i in i8::MIN..=0 { assert_eq!(i.checked_ilog2(), None, "checking {i}"); } for i in 1..=i8::MAX { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in i16::MIN..=0 { @@ -71,10 +97,11 @@ fn checked_ilog2() { } #[cfg(not(miri))] // Miri is too slow for i in 1..=i16::MAX { - // Guard against Android's imprecise f32::ilog2 implementation. - if i != 8192 { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); - } + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } } @@ -91,15 +118,27 @@ fn checked_ilog10() { } #[cfg(not(miri))] // Miri is too slow for i in 1..=i16::MAX { - assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog10(), + Some(round_down_imprecise((i as f32).log10())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=u16::MAX { - assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog10(), + Some(round_down_imprecise((i as f32).log10())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=100_000u32 { - assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog10(), + Some(round_down_imprecise((i as f32).log10())), + "checking {i}" + ); } } diff --git a/core/tests/num/int_macros.rs b/coretests/tests/num/int_macros.rs similarity index 50% rename from core/tests/num/int_macros.rs rename to coretests/tests/num/int_macros.rs index 474d57049ab65..bbf19d2b444f9 100644 --- a/core/tests/num/int_macros.rs +++ b/coretests/tests/num/int_macros.rs @@ -1,8 +1,10 @@ macro_rules! int_module { - ($T:ident) => { + ($T:ident, $U:ident) => { use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr}; use core::$T::*; + const UMAX: $U = $U::MAX; + use crate::num; #[test] @@ -190,6 +192,40 @@ macro_rules! int_module { } } + #[test] + fn test_isolate_most_significant_one() { + const BITS: $T = -1; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + // Right shift the most significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS >> i).isolate_most_significant_one(), + (MOST_SIG_ONE >> i).isolate_most_significant_one() + ); + i += 1; + } + } + + #[test] + fn test_isolate_least_significant_one() { + const BITS: $T = -1; + const LEAST_SIG_ONE: $T = 1; + + // Left shift the least significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS << i).isolate_least_significant_one(), + (LEAST_SIG_ONE << i).isolate_least_significant_one() + ); + i += 1; + } + } + #[test] fn test_from_str() { fn from_str(t: &str) -> Option { @@ -355,6 +391,102 @@ macro_rules! int_module { assert_eq_const_safe!((0 as $T).borrowing_sub(MIN, true), (MAX, false)); } + fn test_widening_mul() { + assert_eq_const_safe!(MAX.widening_mul(MAX), (1, MAX / 2)); + assert_eq_const_safe!(MIN.widening_mul(MAX), (MIN as $U, MIN / 2)); + assert_eq_const_safe!(MIN.widening_mul(MIN), (0, MAX / 2 + 1)); + } + + fn test_carrying_mul() { + assert_eq_const_safe!(MAX.carrying_mul(MAX, 0), (1, MAX / 2)); + assert_eq_const_safe!( + MAX.carrying_mul(MAX, MAX), + (UMAX / 2 + 1, MAX / 2) + ); + assert_eq_const_safe!( + MAX.carrying_mul(MAX, MIN), + (UMAX / 2 + 2, MAX / 2 - 1) + ); + assert_eq_const_safe!(MIN.carrying_mul(MAX, 0), (MIN as $U, MIN / 2)); + assert_eq_const_safe!(MIN.carrying_mul(MAX, MAX), (UMAX, MIN / 2)); + assert_eq_const_safe!(MIN.carrying_mul(MAX, MIN), (0, MIN / 2)); + assert_eq_const_safe!(MIN.carrying_mul(MIN, 0), (0, MAX / 2 + 1)); + assert_eq_const_safe!( + MIN.carrying_mul(MIN, MAX), + (UMAX / 2, MAX / 2 + 1) + ); + assert_eq_const_safe!( + MIN.carrying_mul(MIN, MIN), + (UMAX / 2 + 1, MAX / 2) + ); + } + + fn test_carrying_mul_add() { + assert_eq_const_safe!(MAX.carrying_mul_add(MAX, 0, 0), (1, MAX / 2)); + assert_eq_const_safe!( + MAX.carrying_mul_add(MAX, MAX, 0), + (UMAX / 2 + 1, MAX / 2) + ); + assert_eq_const_safe!( + MAX.carrying_mul_add(MAX, MIN, 0), + (UMAX / 2 + 2, MAX / 2 - 1) + ); + assert_eq_const_safe!( + MAX.carrying_mul_add(MAX, MAX, MAX), + (UMAX, MAX / 2) + ); + assert_eq_const_safe!( + MAX.carrying_mul_add(MAX, MAX, MIN), + (0, MAX / 2) + ); + assert_eq_const_safe!( + MAX.carrying_mul_add(MAX, MIN, MIN), + (1, MAX / 2 - 1) + ); + assert_eq_const_safe!( + MIN.carrying_mul_add(MAX, 0, 0), + (MIN as $U, MIN / 2) + ); + assert_eq_const_safe!( + MIN.carrying_mul_add(MAX, MAX, 0), + (UMAX, MIN / 2) + ); + assert_eq_const_safe!(MIN.carrying_mul_add(MAX, MIN, 0), (0, MIN / 2)); + assert_eq_const_safe!( + MIN.carrying_mul_add(MAX, MAX, MAX), + (UMAX / 2 - 1, MIN / 2 + 1) + ); + assert_eq_const_safe!( + MIN.carrying_mul_add(MAX, MAX, MIN), + (UMAX / 2, MIN / 2) + ); + assert_eq_const_safe!( + MIN.carrying_mul_add(MAX, MIN, MIN), + (UMAX / 2 + 1, MIN / 2 - 1) + ); + assert_eq_const_safe!(MIN.carrying_mul_add(MIN, 0, 0), (0, MAX / 2 + 1)); + assert_eq_const_safe!( + MIN.carrying_mul_add(MIN, MAX, 0), + (UMAX / 2, MAX / 2 + 1) + ); + assert_eq_const_safe!( + MIN.carrying_mul_add(MIN, MIN, 0), + (UMAX / 2 + 1, MAX / 2) + ); + assert_eq_const_safe!( + MIN.carrying_mul_add(MIN, MAX, MAX), + (UMAX - 1, MAX / 2 + 1) + ); + assert_eq_const_safe!( + MIN.carrying_mul_add(MIN, MAX, MIN), + (UMAX, MAX / 2) + ); + assert_eq_const_safe!( + MIN.carrying_mul_add(MIN, MIN, MIN), + (0, MAX / 2) + ); + } + fn test_midpoint() { assert_eq_const_safe!(<$T>::midpoint(1, 3), 2); assert_eq_const_safe!(<$T>::midpoint(3, 1), 2); @@ -380,5 +512,169 @@ macro_rules! int_module { assert_eq_const_safe!(<$T>::midpoint(6, <$T>::MAX), <$T>::MAX / 2 + 3); } } + + // test_unbounded_sh* constants + const SHIFT_AMOUNT_OVERFLOW: u32 = <$T>::BITS; + const SHIFT_AMOUNT_OVERFLOW2: u32 = <$T>::BITS + 3; + const SHIFT_AMOUNT_OVERFLOW3: u32 = <$T>::BITS << 2; + + const SHIFT_AMOUNT_TEST_ONE: u32 = <$T>::BITS >> 1; + const SHIFT_AMOUNT_TEST_TWO: u32 = <$T>::BITS >> 3; + const SHIFT_AMOUNT_TEST_THREE: u32 = (<$T>::BITS >> 1) - 1; + const SHIFT_AMOUNT_TEST_FOUR: u32 = <$T>::BITS - 1; + + test_runtime_and_compiletime! { + fn test_unbounded_shl() { + // <$T>::MIN + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_ONE), (<$T>::MIN << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_TWO), (<$T>::MIN << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_THREE), (<$T>::MIN << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MIN << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 1), (<$T>::MIN << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 3), (<$T>::MIN << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 5), (<$T>::MIN << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW3), 0); + + // <$T>::MAX + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_ONE), (<$T>::MAX << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_TWO), (<$T>::MAX << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_THREE), (<$T>::MAX << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MAX << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 1), (<$T>::MAX << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 3), (<$T>::MAX << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 5), (<$T>::MAX << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 1 + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_ONE), (1 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_TWO), (1 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_THREE), (1 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_FOUR), (1 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 1), (1 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 3), (1 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 5), (1 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW3), 0); + + // -1 + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_TEST_ONE), (-1 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_TEST_TWO), (-1 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_TEST_THREE), (-1 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_TEST_FOUR), (-1 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, 1), (-1 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, 3), (-1 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, 5), (-1 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 8 + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_ONE), (8 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_TWO), (8 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_THREE), (8 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_FOUR), (8 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 1), (8 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 3), (8 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 5), (8 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 17 + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_ONE), (17 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_TWO), (17 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_THREE), (17 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_FOUR), (17 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 1), (17 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 3), (17 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 5), (17 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW3), 0); + } + + fn test_unbounded_shr() { + // <$T>::MIN + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_ONE), (<$T>::MIN >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_TWO), (<$T>::MIN >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_THREE), (<$T>::MIN >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MIN >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 1), (<$T>::MIN >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 3), (<$T>::MIN >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 5), (<$T>::MIN >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW), -1); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW2), -1); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW3), -1); + + // <$T>::MAX + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_ONE), (<$T>::MAX >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_TWO), (<$T>::MAX >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_THREE), (<$T>::MAX >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MAX >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 1), (<$T>::MAX >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 3), (<$T>::MAX >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 5), (<$T>::MAX >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 1 + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_ONE), (1 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_TWO), (1 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_THREE), (1 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_FOUR), (1 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 1), (1 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 3), (1 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 5), (1 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW3), 0); + + // -1 + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_TEST_ONE), (-1 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_TEST_TWO), (-1 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_TEST_THREE), (-1 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_TEST_FOUR), (-1 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, 1), (-1 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, 3), (-1 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, 5), (-1 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_OVERFLOW), -1); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_OVERFLOW), -1); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_OVERFLOW2), -1); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_OVERFLOW3), -1); + + // 8 + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_ONE), (8 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_TWO), (8 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_THREE), (8 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_FOUR), (8 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 1), (8 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 3), (8 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 5), (8 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 17 + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_ONE), (17 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_TWO), (17 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_THREE), (17 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_FOUR), (17 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 1), (17 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 3), (17 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 5), (17 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW3), 0); + } + } }; } diff --git a/core/tests/num/int_sqrt.rs b/coretests/tests/num/int_sqrt.rs similarity index 100% rename from core/tests/num/int_sqrt.rs rename to coretests/tests/num/int_sqrt.rs diff --git a/core/tests/num/midpoint.rs b/coretests/tests/num/midpoint.rs similarity index 100% rename from core/tests/num/midpoint.rs rename to coretests/tests/num/midpoint.rs diff --git a/core/tests/num/mod.rs b/coretests/tests/num/mod.rs similarity index 100% rename from core/tests/num/mod.rs rename to coretests/tests/num/mod.rs diff --git a/core/tests/num/nan.rs b/coretests/tests/num/nan.rs similarity index 100% rename from core/tests/num/nan.rs rename to coretests/tests/num/nan.rs diff --git a/core/tests/num/ops.rs b/coretests/tests/num/ops.rs similarity index 81% rename from core/tests/num/ops.rs rename to coretests/tests/num/ops.rs index ae8b938250ec9..7b2aad4897808 100644 --- a/core/tests/num/ops.rs +++ b/coretests/tests/num/ops.rs @@ -51,9 +51,7 @@ macro_rules! test_op { }; } -test_op!(test_neg_defined, Neg::neg(0), 0, i8, i16, i32, i64, f32, f64); -#[cfg(not(target_os = "emscripten"))] -test_op!(test_neg_defined_128, Neg::neg(0), 0, i128); +test_op!(test_neg_defined, Neg::neg(0), 0, i8, i16, i32, i64, i128, f32, f64); test_op!(test_not_defined_bool, Not::not(true), false, bool); @@ -69,17 +67,17 @@ macro_rules! test_arith_op { i16, i32, i64, + i128, isize, u8, u16, u32, u64, + u128, usize, f32, f64 ); - #[cfg(not(target_os = "emscripten"))] - impls_defined!($op, $method($lhs, $rhs), 0, i128, u128); } }; ($fn_name:ident, $op:ident::$method:ident(&mut $lhs:literal, $rhs:literal)) => { @@ -93,17 +91,17 @@ macro_rules! test_arith_op { i16, i32, i64, + i128, isize, u8, u16, u32, u64, + u128, usize, f32, f64 ); - #[cfg(not(target_os = "emscripten"))] - impls_defined!($op, $method(&mut $lhs, $rhs), 0, i128, u128); } }; } @@ -131,15 +129,15 @@ macro_rules! test_bitop { i16, i32, i64, + i128, isize, u8, u16, u32, u64, + u128, usize ); - #[cfg(not(target_os = "emscripten"))] - impls_defined!($op, $method(0, 0), 0, i128, u128); impls_defined!($op, $method(false, false), false, bool); } }; @@ -156,15 +154,15 @@ macro_rules! test_bitop_assign { i16, i32, i64, + i128, isize, u8, u16, u32, u64, + u128, usize ); - #[cfg(not(target_os = "emscripten"))] - impls_defined!($op, $method(&mut 0, 0), 0, i128, u128); impls_defined!($op, $method(&mut false, false), false, bool); } }; @@ -182,9 +180,11 @@ macro_rules! test_shift_inner { $(impl_defined!($op, $method(0,0), 0, $lt, $rt);)+ }; ($op:ident::$method:ident, $lt:ty) => { - test_shift_inner!($op::$method, $lt, i8, i16, i32, i64, isize, u8, u16, u32, u64, usize); - #[cfg(not(target_os = "emscripten"))] - test_shift_inner!($op::$method, $lt, i128, u128); + test_shift_inner!( + $op::$method, $lt, + i8, i16, i32, i64, i128, isize, + u8, u16, u32, u64, u128, usize + ); }; } @@ -195,9 +195,11 @@ macro_rules! test_shift { ($test_name:ident, $op:ident::$method:ident) => { #[test] fn $test_name() { - test_shift!($op::$method, i8, i16, i32, i64, isize, u8, u16, u32, u64, usize); - #[cfg(not(target_os = "emscripten"))] - test_shift!($op::$method, i128, u128); + test_shift!( + $op::$method, + i8, i16, i32, i64, i128, isize, + u8, u16, u32, u64, u128, usize + ); } }; } @@ -207,9 +209,11 @@ macro_rules! test_shift_assign_inner { $(impl_defined!($op, $method(&mut 0,0), 0, $lt, $rt);)+ }; ($op:ident::$method:ident, $lt:ty) => { - test_shift_assign_inner!($op::$method, $lt, i8, i16, i32, i64, isize, u8, u16, u32, u64, usize); - #[cfg(not(target_os = "emscripten"))] - test_shift_assign_inner!($op::$method, $lt, i128, u128); + test_shift_assign_inner!( + $op::$method, $lt, + i8, i16, i32, i64, i128, isize, + u8, u16, u32, u64, u128, usize + ); }; } @@ -220,9 +224,11 @@ macro_rules! test_shift_assign { ($test_name:ident, $op:ident::$method:ident) => { #[test] fn $test_name() { - test_shift_assign!($op::$method, i8, i16, i32, i64, isize, u8, u16, u32, u64, usize); - #[cfg(not(target_os = "emscripten"))] - test_shift_assign!($op::$method, i128, u128); + test_shift_assign!( + $op::$method, + i8, i16, i32, i64, i128, isize, + u8, u16, u32, u64, u128, usize + ); } }; } diff --git a/core/tests/num/u128.rs b/coretests/tests/num/u128.rs similarity index 100% rename from core/tests/num/u128.rs rename to coretests/tests/num/u128.rs diff --git a/core/tests/num/u16.rs b/coretests/tests/num/u16.rs similarity index 100% rename from core/tests/num/u16.rs rename to coretests/tests/num/u16.rs diff --git a/core/tests/num/u32.rs b/coretests/tests/num/u32.rs similarity index 100% rename from core/tests/num/u32.rs rename to coretests/tests/num/u32.rs diff --git a/core/tests/num/u64.rs b/coretests/tests/num/u64.rs similarity index 100% rename from core/tests/num/u64.rs rename to coretests/tests/num/u64.rs diff --git a/core/tests/num/u8.rs b/coretests/tests/num/u8.rs similarity index 100% rename from core/tests/num/u8.rs rename to coretests/tests/num/u8.rs diff --git a/coretests/tests/num/uint_macros.rs b/coretests/tests/num/uint_macros.rs new file mode 100644 index 0000000000000..d09eb97b17e06 --- /dev/null +++ b/coretests/tests/num/uint_macros.rs @@ -0,0 +1,519 @@ +macro_rules! uint_module { + ($T:ident) => { + use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr}; + use core::$T::*; + + use crate::num; + + #[test] + fn test_overflows() { + assert!(MAX > 0); + assert!(MIN <= 0); + assert!((MIN + MAX).wrapping_add(1) == 0); + } + + #[test] + fn test_num() { + num::test_num(10 as $T, 2 as $T); + } + + #[test] + fn test_bitwise_operators() { + assert!(0b1110 as $T == (0b1100 as $T).bitor(0b1010 as $T)); + assert!(0b1000 as $T == (0b1100 as $T).bitand(0b1010 as $T)); + assert!(0b0110 as $T == (0b1100 as $T).bitxor(0b1010 as $T)); + assert!(0b1110 as $T == (0b0111 as $T).shl(1)); + assert!(0b0111 as $T == (0b1110 as $T).shr(1)); + assert!(MAX - (0b1011 as $T) == (0b1011 as $T).not()); + } + + const A: $T = 0b0101100; + const B: $T = 0b0100001; + const C: $T = 0b1111001; + + const _0: $T = 0; + const _1: $T = !0; + + test_runtime_and_compiletime! { + fn test_count_ones() { + assert!(A.count_ones() == 3); + assert!(B.count_ones() == 2); + assert!(C.count_ones() == 5); + } + + fn test_count_zeros() { + assert!(A.count_zeros() == $T::BITS - 3); + assert!(B.count_zeros() == $T::BITS - 2); + assert!(C.count_zeros() == $T::BITS - 5); + } + + fn test_leading_trailing_ones() { + const A: $T = 0b0101_1111; + assert_eq_const_safe!(A.trailing_ones(), 5); + assert_eq_const_safe!((!A).leading_ones(), $T::BITS - 7); + + assert_eq_const_safe!(A.reverse_bits().leading_ones(), 5); + + assert_eq_const_safe!(_1.leading_ones(), $T::BITS); + assert_eq_const_safe!(_1.trailing_ones(), $T::BITS); + + assert_eq_const_safe!((_1 << 1).trailing_ones(), 0); + assert_eq_const_safe!((_1 >> 1).leading_ones(), 0); + + assert_eq_const_safe!((_1 << 1).leading_ones(), $T::BITS - 1); + assert_eq_const_safe!((_1 >> 1).trailing_ones(), $T::BITS - 1); + + assert_eq_const_safe!(_0.leading_ones(), 0); + assert_eq_const_safe!(_0.trailing_ones(), 0); + + const X: $T = 0b0010_1100; + assert_eq_const_safe!(X.leading_ones(), 0); + assert_eq_const_safe!(X.trailing_ones(), 0); + } + + fn test_rotate() { + assert_eq_const_safe!(A.rotate_left(6).rotate_right(2).rotate_right(4), A); + assert_eq_const_safe!(B.rotate_left(3).rotate_left(2).rotate_right(5), B); + assert_eq_const_safe!(C.rotate_left(6).rotate_right(2).rotate_right(4), C); + + // Rotating these should make no difference + // + // We test using 124 bits because to ensure that overlong bit shifts do + // not cause undefined behavior. See #10183. + assert_eq_const_safe!(_0.rotate_left(124), _0); + assert_eq_const_safe!(_1.rotate_left(124), _1); + assert_eq_const_safe!(_0.rotate_right(124), _0); + assert_eq_const_safe!(_1.rotate_right(124), _1); + + // Rotating by 0 should have no effect + assert_eq_const_safe!(A.rotate_left(0), A); + assert_eq_const_safe!(B.rotate_left(0), B); + assert_eq_const_safe!(C.rotate_left(0), C); + // Rotating by a multiple of word size should also have no effect + assert_eq_const_safe!(A.rotate_left(128), A); + assert_eq_const_safe!(B.rotate_left(128), B); + assert_eq_const_safe!(C.rotate_left(128), C); + } + + fn test_swap_bytes() { + assert_eq_const_safe!(A.swap_bytes().swap_bytes(), A); + assert_eq_const_safe!(B.swap_bytes().swap_bytes(), B); + assert_eq_const_safe!(C.swap_bytes().swap_bytes(), C); + + // Swapping these should make no difference + assert_eq_const_safe!(_0.swap_bytes(), _0); + assert_eq_const_safe!(_1.swap_bytes(), _1); + } + + fn test_reverse_bits() { + assert_eq_const_safe!(A.reverse_bits().reverse_bits(), A); + assert_eq_const_safe!(B.reverse_bits().reverse_bits(), B); + assert_eq_const_safe!(C.reverse_bits().reverse_bits(), C); + + // Swapping these should make no difference + assert_eq_const_safe!(_0.reverse_bits(), _0); + assert_eq_const_safe!(_1.reverse_bits(), _1); + } + + fn test_le() { + assert_eq_const_safe!($T::from_le(A.to_le()), A); + assert_eq_const_safe!($T::from_le(B.to_le()), B); + assert_eq_const_safe!($T::from_le(C.to_le()), C); + assert_eq_const_safe!($T::from_le(_0), _0); + assert_eq_const_safe!($T::from_le(_1), _1); + assert_eq_const_safe!(_0.to_le(), _0); + assert_eq_const_safe!(_1.to_le(), _1); + } + + fn test_be() { + assert_eq_const_safe!($T::from_be(A.to_be()), A); + assert_eq_const_safe!($T::from_be(B.to_be()), B); + assert_eq_const_safe!($T::from_be(C.to_be()), C); + assert_eq_const_safe!($T::from_be(_0), _0); + assert_eq_const_safe!($T::from_be(_1), _1); + assert_eq_const_safe!(_0.to_be(), _0); + assert_eq_const_safe!(_1.to_be(), _1); + } + + fn test_unsigned_checked_div() { + assert_eq_const_safe!((10 as $T).checked_div(2), Some(5)); + assert_eq_const_safe!((5 as $T).checked_div(0), None); + } + } + + #[test] + fn test_isolate_most_significant_one() { + const BITS: $T = <$T>::MAX; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + // Right shift the most significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS >> i).isolate_most_significant_one(), + (MOST_SIG_ONE >> i).isolate_most_significant_one(), + ); + i += 1; + } + } + + #[test] + fn test_isolate_least_significant_one() { + const BITS: $T = <$T>::MAX; + const LEAST_SIG_ONE: $T = 1; + + // Left shift the least significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS << i).isolate_least_significant_one(), + (LEAST_SIG_ONE << i).isolate_least_significant_one(), + ); + i += 1; + } + } + + fn from_str(t: &str) -> Option { + core::str::FromStr::from_str(t).ok() + } + + #[test] + pub fn test_from_str() { + assert_eq!(from_str::<$T>("0"), Some(0 as $T)); + assert_eq!(from_str::<$T>("3"), Some(3 as $T)); + assert_eq!(from_str::<$T>("10"), Some(10 as $T)); + assert_eq!(from_str::("123456789"), Some(123456789 as u32)); + assert_eq!(from_str::<$T>("00100"), Some(100 as $T)); + + assert_eq!(from_str::<$T>(""), None); + assert_eq!(from_str::<$T>(" "), None); + assert_eq!(from_str::<$T>("x"), None); + } + + test_runtime_and_compiletime! { + fn test_parse_bytes() { + assert_eq_const_safe!($T::from_str_radix("123", 10), Ok(123 as $T)); + assert_eq_const_safe!($T::from_str_radix("1001", 2), Ok(9 as $T)); + assert_eq_const_safe!($T::from_str_radix("123", 8), Ok(83 as $T)); + assert_eq_const_safe!(u16::from_str_radix("123", 16), Ok(291 as u16)); + assert_eq_const_safe!(u16::from_str_radix("ffff", 16), Ok(65535 as u16)); + assert_eq_const_safe!($T::from_str_radix("z", 36), Ok(35 as $T)); + + assert!($T::from_str_radix("Z", 10).is_err()); + assert!($T::from_str_radix("_", 2).is_err()); + } + + fn test_pow() { + { + const R: $T = 2; + assert_eq_const_safe!(R.pow(2), 4 as $T); + assert_eq_const_safe!(R.pow(0), 1 as $T); + assert_eq_const_safe!(R.wrapping_pow(2), 4 as $T); + assert_eq_const_safe!(R.wrapping_pow(0), 1 as $T); + assert_eq_const_safe!(R.checked_pow(2), Some(4 as $T)); + assert_eq_const_safe!(R.checked_pow(0), Some(1 as $T)); + assert_eq_const_safe!(R.overflowing_pow(2), (4 as $T, false)); + assert_eq_const_safe!(R.overflowing_pow(0), (1 as $T, false)); + assert_eq_const_safe!(R.saturating_pow(2), 4 as $T); + assert_eq_const_safe!(R.saturating_pow(0), 1 as $T); + } + + { + const R: $T = $T::MAX; + // use `^` to represent .pow() with no overflow. + // if itest::MAX == 2^j-1, then itest is a `j` bit int, + // so that `itest::MAX*itest::MAX == 2^(2*j)-2^(j+1)+1`, + // thussaturating_pow the overflowing result is exactly 1. + assert_eq_const_safe!(R.wrapping_pow(2), 1 as $T); + assert_eq_const_safe!(R.checked_pow(2), None); + assert_eq_const_safe!(R.overflowing_pow(2), (1 as $T, true)); + assert_eq_const_safe!(R.saturating_pow(2), MAX); + } + } + + fn test_isqrt() { + assert_eq_const_safe!((0 as $T).isqrt(), 0 as $T); + assert_eq_const_safe!((1 as $T).isqrt(), 1 as $T); + assert_eq_const_safe!((2 as $T).isqrt(), 1 as $T); + assert_eq_const_safe!((99 as $T).isqrt(), 9 as $T); + assert_eq_const_safe!((100 as $T).isqrt(), 10 as $T); + assert_eq_const_safe!($T::MAX.isqrt(), (1 << ($T::BITS / 2)) - 1); + } + } + + #[cfg(not(miri))] // Miri is too slow + #[test] + fn test_lots_of_isqrt() { + let n_max: $T = (1024 * 1024).min($T::MAX as u128) as $T; + for n in 0..=n_max { + let isqrt: $T = n.isqrt(); + + assert!(isqrt.pow(2) <= n); + assert!(isqrt + 1 == (1 as $T) << ($T::BITS / 2) || (isqrt + 1).pow(2) > n); + } + + for n in ($T::MAX - 255)..=$T::MAX { + let isqrt: $T = n.isqrt(); + + assert!(isqrt.pow(2) <= n); + assert!(isqrt + 1 == (1 as $T) << ($T::BITS / 2) || (isqrt + 1).pow(2) > n); + } + } + + test_runtime_and_compiletime! { + fn test_div_floor() { + assert_eq_const_safe!((8 as $T).div_floor(3), 2); + } + + fn test_div_ceil() { + assert_eq_const_safe!((8 as $T).div_ceil(3), 3); + } + + fn test_next_multiple_of() { + assert_eq_const_safe!((16 as $T).next_multiple_of(8), 16); + assert_eq_const_safe!((23 as $T).next_multiple_of(8), 24); + assert_eq_const_safe!(MAX.next_multiple_of(1), MAX); + } + + fn test_checked_next_multiple_of() { + assert_eq_const_safe!((16 as $T).checked_next_multiple_of(8), Some(16)); + assert_eq_const_safe!((23 as $T).checked_next_multiple_of(8), Some(24)); + assert_eq_const_safe!((1 as $T).checked_next_multiple_of(0), None); + assert_eq_const_safe!(MAX.checked_next_multiple_of(2), None); + } + + fn test_is_next_multiple_of() { + assert!((12 as $T).is_multiple_of(4)); + assert!(!(12 as $T).is_multiple_of(5)); + assert!((0 as $T).is_multiple_of(0)); + assert!(!(12 as $T).is_multiple_of(0)); + } + + fn test_carrying_add() { + assert_eq_const_safe!($T::MAX.carrying_add(1, false), (0, true)); + assert_eq_const_safe!($T::MAX.carrying_add(0, true), (0, true)); + assert_eq_const_safe!($T::MAX.carrying_add(1, true), (1, true)); + + assert_eq_const_safe!($T::MIN.carrying_add($T::MAX, false), ($T::MAX, false)); + assert_eq_const_safe!($T::MIN.carrying_add(0, true), (1, false)); + assert_eq_const_safe!($T::MIN.carrying_add($T::MAX, true), (0, true)); + } + + fn test_borrowing_sub() { + assert_eq_const_safe!($T::MIN.borrowing_sub(1, false), ($T::MAX, true)); + assert_eq_const_safe!($T::MIN.borrowing_sub(0, true), ($T::MAX, true)); + assert_eq_const_safe!($T::MIN.borrowing_sub(1, true), ($T::MAX - 1, true)); + + assert_eq_const_safe!($T::MAX.borrowing_sub($T::MAX, false), (0, false)); + assert_eq_const_safe!($T::MAX.borrowing_sub(0, true), ($T::MAX - 1, false)); + assert_eq_const_safe!($T::MAX.borrowing_sub($T::MAX, true), ($T::MAX, true)); + } + + fn test_widening_mul() { + assert_eq_const_safe!($T::MAX.widening_mul($T::MAX), (1, $T::MAX - 1)); + } + + fn test_carrying_mul() { + assert_eq_const_safe!($T::MAX.carrying_mul($T::MAX, 0), (1, $T::MAX - 1)); + assert_eq_const_safe!($T::MAX.carrying_mul($T::MAX, $T::MAX), (0, $T::MAX)); + } + + fn test_carrying_mul_add() { + assert_eq_const_safe!($T::MAX.carrying_mul_add($T::MAX, 0, 0), (1, $T::MAX - 1)); + assert_eq_const_safe!($T::MAX.carrying_mul_add($T::MAX, $T::MAX, 0), (0, $T::MAX)); + assert_eq_const_safe!($T::MAX.carrying_mul_add($T::MAX, $T::MAX, $T::MAX), ($T::MAX, $T::MAX)); + } + + fn test_midpoint() { + assert_eq_const_safe!(<$T>::midpoint(1, 3), 2); + assert_eq_const_safe!(<$T>::midpoint(3, 1), 2); + + assert_eq_const_safe!(<$T>::midpoint(0, 0), 0); + assert_eq_const_safe!(<$T>::midpoint(0, 2), 1); + assert_eq_const_safe!(<$T>::midpoint(2, 0), 1); + assert_eq_const_safe!(<$T>::midpoint(2, 2), 2); + + assert_eq_const_safe!(<$T>::midpoint(1, 4), 2); + assert_eq_const_safe!(<$T>::midpoint(4, 1), 2); + assert_eq_const_safe!(<$T>::midpoint(3, 4), 3); + assert_eq_const_safe!(<$T>::midpoint(4, 3), 3); + + assert_eq_const_safe!(<$T>::midpoint(<$T>::MIN, <$T>::MAX), (<$T>::MAX - <$T>::MIN) / 2); + assert_eq_const_safe!(<$T>::midpoint(<$T>::MAX, <$T>::MIN), (<$T>::MAX - <$T>::MIN) / 2); + assert_eq_const_safe!(<$T>::midpoint(<$T>::MIN, <$T>::MIN), <$T>::MIN); + assert_eq_const_safe!(<$T>::midpoint(<$T>::MAX, <$T>::MAX), <$T>::MAX); + + assert_eq_const_safe!(<$T>::midpoint(<$T>::MIN, 6), <$T>::MIN / 2 + 3); + assert_eq_const_safe!(<$T>::midpoint(6, <$T>::MIN), <$T>::MIN / 2 + 3); + assert_eq_const_safe!(<$T>::midpoint(<$T>::MAX, 6), (<$T>::MAX - <$T>::MIN) / 2 + 3); + assert_eq_const_safe!(<$T>::midpoint(6, <$T>::MAX), (<$T>::MAX - <$T>::MIN) / 2 + 3); + } + } + + // test_unbounded_sh* constants + const SHIFT_AMOUNT_OVERFLOW: u32 = <$T>::BITS; + const SHIFT_AMOUNT_OVERFLOW2: u32 = <$T>::BITS + 3; + const SHIFT_AMOUNT_OVERFLOW3: u32 = <$T>::BITS << 2; + + const SHIFT_AMOUNT_TEST_ONE: u32 = <$T>::BITS >> 1; + const SHIFT_AMOUNT_TEST_TWO: u32 = <$T>::BITS >> 3; + const SHIFT_AMOUNT_TEST_THREE: u32 = (<$T>::BITS >> 1) - 1; + const SHIFT_AMOUNT_TEST_FOUR: u32 = <$T>::BITS - 1; + + test_runtime_and_compiletime! { + fn test_unbounded_shl() { + // <$T>::MIN + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_ONE), (<$T>::MIN << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_TWO), (<$T>::MIN << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_THREE), (<$T>::MIN << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MIN << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 1), (<$T>::MIN << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 3), (<$T>::MIN << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 5), (<$T>::MIN << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW3), 0); + + // <$T>::MAX + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_ONE), (<$T>::MAX << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_TWO), (<$T>::MAX << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_THREE), (<$T>::MAX << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MAX << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 1), (<$T>::MAX << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 3), (<$T>::MAX << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 5), (<$T>::MAX << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 1 + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_ONE), (1 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_TWO), (1 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_THREE), (1 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_FOUR), (1 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 1), (1 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 3), (1 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 5), (1 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW3), 0); + + // !0 + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_TEST_ONE), (!0 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_TEST_TWO), (!0 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_TEST_THREE), (!0 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_TEST_FOUR), (!0 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, 1), (!0 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, 3), (!0 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, 5), (!0 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 8 + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_ONE), (8 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_TWO), (8 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_THREE), (8 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_FOUR), (8 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 1), (8 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 3), (8 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 5), (8 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 17 + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_ONE), (17 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_TWO), (17 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_THREE), (17 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_FOUR), (17 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 1), (17 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 3), (17 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 5), (17 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW3), 0); + } + + fn test_unbounded_shr() { + // <$T>::MIN + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_ONE), (<$T>::MIN >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_TWO), (<$T>::MIN >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_THREE), (<$T>::MIN >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MIN >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 1), (<$T>::MIN >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 3), (<$T>::MIN >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 5), (<$T>::MIN >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW3), 0); + + // <$T>::MAX + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_ONE), (<$T>::MAX >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_TWO), (<$T>::MAX >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_THREE), (<$T>::MAX >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MAX >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 1), (<$T>::MAX >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 3), (<$T>::MAX >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 5), (<$T>::MAX >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 1 + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_ONE), (1 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_TWO), (1 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_THREE), (1 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_FOUR), (1 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 1), (1 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 3), (1 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 5), (1 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW3), 0); + + // !0 + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_TEST_ONE), (!0 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_TEST_TWO), (!0 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_TEST_THREE), (!0 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_TEST_FOUR), (!0 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, 1), (!0 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, 3), (!0 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, 5), (!0 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 8 + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_ONE), (8 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_TWO), (8 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_THREE), (8 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_FOUR), (8 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 1), (8 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 3), (8 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 5), (8 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 17 + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_ONE), (17 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_TWO), (17 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_THREE), (17 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_FOUR), (17 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 1), (17 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 3), (17 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 5), (17 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW3), 0); + } + } + }; +} diff --git a/core/tests/num/wrapping.rs b/coretests/tests/num/wrapping.rs similarity index 99% rename from core/tests/num/wrapping.rs rename to coretests/tests/num/wrapping.rs index c5a7198839517..0b9fca8455b81 100644 --- a/core/tests/num/wrapping.rs +++ b/coretests/tests/num/wrapping.rs @@ -64,14 +64,12 @@ wrapping_test!(test_wrapping_i8, i8, i8::MIN, i8::MAX); wrapping_test!(test_wrapping_i16, i16, i16::MIN, i16::MAX); wrapping_test!(test_wrapping_i32, i32, i32::MIN, i32::MAX); wrapping_test!(test_wrapping_i64, i64, i64::MIN, i64::MAX); -#[cfg(not(target_os = "emscripten"))] wrapping_test!(test_wrapping_i128, i128, i128::MIN, i128::MAX); wrapping_test!(test_wrapping_isize, isize, isize::MIN, isize::MAX); wrapping_test!(test_wrapping_u8, u8, u8::MIN, u8::MAX); wrapping_test!(test_wrapping_u16, u16, u16::MIN, u16::MAX); wrapping_test!(test_wrapping_u32, u32, u32::MIN, u32::MAX); wrapping_test!(test_wrapping_u64, u64, u64::MIN, u64::MAX); -#[cfg(not(target_os = "emscripten"))] wrapping_test!(test_wrapping_u128, u128, u128::MIN, u128::MAX); wrapping_test!(test_wrapping_usize, usize, usize::MIN, usize::MAX); diff --git a/core/tests/ops.rs b/coretests/tests/ops.rs similarity index 100% rename from core/tests/ops.rs rename to coretests/tests/ops.rs diff --git a/core/tests/ops/control_flow.rs b/coretests/tests/ops/control_flow.rs similarity index 100% rename from core/tests/ops/control_flow.rs rename to coretests/tests/ops/control_flow.rs diff --git a/core/tests/ops/from_residual.rs b/coretests/tests/ops/from_residual.rs similarity index 100% rename from core/tests/ops/from_residual.rs rename to coretests/tests/ops/from_residual.rs diff --git a/core/tests/option.rs b/coretests/tests/option.rs similarity index 100% rename from core/tests/option.rs rename to coretests/tests/option.rs diff --git a/core/tests/panic.rs b/coretests/tests/panic.rs similarity index 100% rename from core/tests/panic.rs rename to coretests/tests/panic.rs diff --git a/core/tests/panic/location.rs b/coretests/tests/panic/location.rs similarity index 100% rename from core/tests/panic/location.rs rename to coretests/tests/panic/location.rs diff --git a/core/tests/pattern.rs b/coretests/tests/pattern.rs similarity index 100% rename from core/tests/pattern.rs rename to coretests/tests/pattern.rs diff --git a/core/tests/pin.rs b/coretests/tests/pin.rs similarity index 96% rename from core/tests/pin.rs rename to coretests/tests/pin.rs index 026d2ca8de26a..b3fb06e710d44 100644 --- a/core/tests/pin.rs +++ b/coretests/tests/pin.rs @@ -28,7 +28,9 @@ fn pin_const() { const fn pin_mut_const() { let _ = Pin::new(&mut 2).into_ref(); let _ = Pin::new(&mut 2).get_mut(); - let _ = unsafe { Pin::new(&mut 2).get_unchecked_mut() }; + unsafe { + let _ = Pin::new(&mut 2).get_unchecked_mut(); + } } pin_mut_const(); diff --git a/core/tests/pin_macro.rs b/coretests/tests/pin_macro.rs similarity index 100% rename from core/tests/pin_macro.rs rename to coretests/tests/pin_macro.rs diff --git a/core/tests/ptr.rs b/coretests/tests/ptr.rs similarity index 90% rename from core/tests/ptr.rs rename to coretests/tests/ptr.rs index 91f8c977d088a..6091926084a35 100644 --- a/core/tests/ptr.rs +++ b/coretests/tests/ptr.rs @@ -1,6 +1,6 @@ use core::cell::RefCell; use core::marker::Freeze; -use core::mem::{self, MaybeUninit}; +use core::mem::MaybeUninit; use core::num::NonZero; use core::ptr; use core::ptr::*; @@ -42,11 +42,11 @@ fn test() { let mut v1 = vec![0u16, 0u16, 0u16]; copy(v0.as_ptr().offset(1), v1.as_mut_ptr().offset(1), 1); - assert!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16)); + assert!(v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16); copy(v0.as_ptr().offset(2), v1.as_mut_ptr(), 1); - assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16)); + assert!(v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16); copy(v0.as_ptr(), v1.as_mut_ptr().offset(2), 1); - assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16)); + assert!(v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16); } } @@ -97,7 +97,7 @@ fn test_is_null() { let nmi: *mut dyn ToString = null_mut::(); assert!(nmi.is_null()); - extern "C" { + unsafe extern "C" { type Extern; } let ec: *const Extern = null::(); @@ -304,10 +304,11 @@ fn test_const_nonnull_new() { #[test] #[cfg(unix)] // printf may not be available on other platforms #[allow(deprecated)] // For SipHasher +#[allow(unpredictable_function_pointer_comparisons)] pub fn test_variadic_fnptr() { use core::ffi; use core::hash::{Hash, SipHasher}; - extern "C" { + unsafe extern "C" { // This needs to use the correct function signature even though it isn't called as some // codegen backends make it UB to declare a function with multiple conflicting signatures // (like LLVM) while others straight up return an error (like Cranelift). @@ -387,7 +388,7 @@ fn align_offset_various_strides() { let mut expected = usize::MAX; // Naive but definitely correct way to find the *first* aligned element of stride::. for el in 0..align { - if (numptr + el * ::std::mem::size_of::()) % align == 0 { + if (numptr + el * size_of::()) % align == 0 { expected = el; break; } @@ -397,7 +398,7 @@ fn align_offset_various_strides() { eprintln!( "aligning {:p} (with stride of {}) to {}, expected {}, got {}", ptr, - ::std::mem::size_of::(), + size_of::(), align, expected, got @@ -505,7 +506,7 @@ fn offset_from() { fn ptr_metadata() { struct Unit; struct Pair(A, B); - extern "C" { + unsafe extern "C" { type Extern; } let () = metadata(&()); @@ -524,31 +525,24 @@ fn ptr_metadata() { assert_eq!(metadata("foo"), 3_usize); assert_eq!(metadata(&[4, 7][..]), 2_usize); - let dst_tuple: &(bool, [u8]) = &(true, [0x66, 0x6F, 0x6F]); let dst_struct: &Pair = &Pair(true, [0x66, 0x6F, 0x6F]); - assert_eq!(metadata(dst_tuple), 3_usize); assert_eq!(metadata(dst_struct), 3_usize); unsafe { - let dst_tuple: &(bool, str) = std::mem::transmute(dst_tuple); let dst_struct: &Pair = std::mem::transmute(dst_struct); - assert_eq!(&dst_tuple.1, "foo"); assert_eq!(&dst_struct.1, "foo"); - assert_eq!(metadata(dst_tuple), 3_usize); assert_eq!(metadata(dst_struct), 3_usize); } let vtable_1: DynMetadata = metadata(&4_u16 as &dyn Debug); let vtable_2: DynMetadata = metadata(&4_u16 as &dyn Display); let vtable_3: DynMetadata = metadata(&4_u32 as &dyn Display); - let vtable_4: DynMetadata = metadata(&(true, 7_u32) as &(bool, dyn Display)); - let vtable_5: DynMetadata = + let vtable_4: DynMetadata = metadata(&Pair(true, 7_u32) as &Pair); unsafe { let address_1: *const () = std::mem::transmute(vtable_1); let address_2: *const () = std::mem::transmute(vtable_2); let address_3: *const () = std::mem::transmute(vtable_3); let address_4: *const () = std::mem::transmute(vtable_4); - let address_5: *const () = std::mem::transmute(vtable_5); // Different trait => different vtable pointer assert_ne!(address_1, address_2); // Different erased type => different vtable pointer @@ -557,7 +551,6 @@ fn ptr_metadata() { // This is *not guaranteed*, so we skip it in Miri. if !cfg!(miri) { assert_eq!(address_3, address_4); - assert_eq!(address_3, address_5); } } } @@ -612,9 +605,9 @@ fn dyn_metadata() { let meta = metadata(trait_object); assert_eq!(meta.size_of(), 64); - assert_eq!(meta.size_of(), std::mem::size_of::()); + assert_eq!(meta.size_of(), size_of::()); assert_eq!(meta.align_of(), 32); - assert_eq!(meta.align_of(), std::mem::align_of::()); + assert_eq!(meta.align_of(), align_of::()); assert_eq!(meta.layout(), std::alloc::Layout::new::()); assert!(format!("{meta:?}").starts_with("DynMetadata(0x")); @@ -788,7 +781,7 @@ fn nonnull_tagged_pointer_with_provenance() { impl TaggedPointer { /// The ABI-required minimum alignment of the `P` type. - pub const ALIGNMENT: usize = core::mem::align_of::(); + pub const ALIGNMENT: usize = align_of::(); /// A mask for data-carrying bits of the address. pub const DATA_MASK: usize = !Self::ADDRESS_MASK; /// Number of available bits of storage in the address. @@ -859,7 +852,10 @@ fn swap_copy_untyped() { } #[test] -fn test_const_copy() { +fn test_const_copy_ptr() { + // `copy` and `copy_nonoverlapping` are thin layers on top of intrinsics. Ensure they correctly + // deal with pointers even when the pointers cross the boundary from one "element" being copied + // to another. const { let ptr1 = &1; let mut ptr2 = &666; @@ -869,7 +865,7 @@ fn test_const_copy() { ptr::copy( &ptr1 as *const _ as *const MaybeUninit, &mut ptr2 as *mut _ as *mut MaybeUninit, - mem::size_of::<&i32>(), + size_of::<&i32>(), ); } @@ -887,7 +883,7 @@ fn test_const_copy() { ptr::copy_nonoverlapping( &ptr1 as *const _ as *const MaybeUninit, &mut ptr2 as *mut _ as *mut MaybeUninit, - mem::size_of::<&i32>(), + size_of::<&i32>(), ); } @@ -897,6 +893,65 @@ fn test_const_copy() { }; } +#[test] +fn test_const_swap_ptr() { + // The `swap` functions are implemented in the library, they are not primitives. + // Only `swap_nonoverlapping` takes a count; pointers that cross multiple elements + // are *not* supported. + // We put the pointer at an odd offset in the type and copy them as an array of bytes, + // which should catch most of the ways that the library implementation can get it wrong. + + #[cfg(target_pointer_width = "32")] + type HalfPtr = i16; + #[cfg(target_pointer_width = "64")] + type HalfPtr = i32; + + #[repr(C, packed)] + #[allow(unused)] + struct S { + f1: HalfPtr, + // Crucially this field is at an offset that is not a multiple of the pointer size. + ptr: &'static i32, + // Make sure the entire type does not have a power-of-2 size: + // make it 3 pointers in size. This used to hit a bug in `swap_nonoverlapping`. + f2: [HalfPtr; 3], + } + + // Ensure the entire thing is usize-aligned, so in principle this + // looks like it could be eligible for a `usize` copying loop. + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + struct A(S); + + const { + let mut s1 = A(S { ptr: &1, f1: 0, f2: [0; 3] }); + let mut s2 = A(S { ptr: &666, f1: 0, f2: [0; 3] }); + + // Swap ptr1 and ptr2, as an array. + type T = [u8; size_of::()]; + unsafe { + ptr::swap(ptr::from_mut(&mut s1).cast::(), ptr::from_mut(&mut s2).cast::()); + } + + // Make sure they still work. + assert!(*s1.0.ptr == 666); + assert!(*s2.0.ptr == 1); + + // Swap them back, again as an array. + unsafe { + ptr::swap_nonoverlapping( + ptr::from_mut(&mut s1).cast::(), + ptr::from_mut(&mut s2).cast::(), + 1, + ); + } + + // Make sure they still work. + assert!(*s1.0.ptr == 1); + assert!(*s2.0.ptr == 666); + }; +} + #[test] fn test_null_array_as_slice() { let arr: *mut [u8; 4] = null_mut(); diff --git a/core/tests/result.rs b/coretests/tests/result.rs similarity index 100% rename from core/tests/result.rs rename to coretests/tests/result.rs diff --git a/core/tests/simd.rs b/coretests/tests/simd.rs similarity index 100% rename from core/tests/simd.rs rename to coretests/tests/simd.rs diff --git a/core/tests/slice.rs b/coretests/tests/slice.rs similarity index 92% rename from core/tests/slice.rs rename to coretests/tests/slice.rs index 9ae2bcc852649..d17e681480c70 100644 --- a/core/tests/slice.rs +++ b/coretests/tests/slice.rs @@ -2,6 +2,7 @@ use core::cell::Cell; use core::cmp::Ordering; use core::mem::MaybeUninit; use core::num::NonZero; +use core::ops::{Range, RangeInclusive}; use core::slice; #[test] @@ -1290,7 +1291,7 @@ fn test_iter_ref_consistency() { fn test(x: T) { let v: &[T] = &[x, x, x]; let v_ptrs: [*const T; 3] = match v { - [ref v1, ref v2, ref v3] => [v1 as *const _, v2 as *const _, v3 as *const _], + [v1, v2, v3] => [v1 as *const _, v2 as *const _, v3 as *const _], _ => unreachable!(), }; let len = v.len(); @@ -1345,7 +1346,7 @@ fn test_iter_ref_consistency() { fn test_mut(x: T) { let v: &mut [T] = &mut [x, x, x]; let v_ptrs: [*mut T; 3] = match v { - [ref v1, ref v2, ref v3] => { + &mut [ref v1, ref v2, ref v3] => { [v1 as *const _ as *mut _, v2 as *const _ as *mut _, v3 as *const _ as *mut _] } _ => unreachable!(), @@ -1807,7 +1808,7 @@ fn select_nth_unstable() { use core::cmp::Ordering::{Equal, Greater, Less}; use rand::Rng; - use rand::seq::SliceRandom; + use rand::seq::IndexedRandom; let mut rng = crate::test_rng(); @@ -1817,7 +1818,7 @@ fn select_nth_unstable() { for &modulus in &[5, 10, 1000] { for _ in 0..10 { for i in 0..len { - orig[i] = rng.gen::() % modulus; + orig[i] = rng.random::() % modulus; } let v_sorted = { @@ -2056,15 +2057,13 @@ fn test_align_to_non_trivial() { #[test] fn test_align_to_empty_mid() { - use core::mem; - // Make sure that we do not create empty unaligned slices for the mid part, even when the // overall slice is too short to contain an aligned address. let bytes = [1, 2, 3, 4, 5, 6, 7]; type Chunk = u32; for offset in 0..4 { let (_, mid, _) = unsafe { bytes[offset..offset + 1].align_to::() }; - assert_eq!(mid.as_ptr() as usize % mem::align_of::(), 0); + assert_eq!(mid.as_ptr() as usize % align_of::(), 0); } } @@ -2398,18 +2397,18 @@ fn slice_rsplit_once() { assert_eq!(v.rsplit_once(|&x| x == 0), None); } -macro_rules! take_tests { +macro_rules! split_off_tests { (slice: &[], $($tts:tt)*) => { - take_tests!(ty: &[()], slice: &[], $($tts)*); + split_off_tests!(ty: &[()], slice: &[], $($tts)*); }; (slice: &mut [], $($tts:tt)*) => { - take_tests!(ty: &mut [()], slice: &mut [], $($tts)*); + split_off_tests!(ty: &mut [()], slice: &mut [], $($tts)*); }; (slice: &$slice:expr, $($tts:tt)*) => { - take_tests!(ty: &[_], slice: &$slice, $($tts)*); + split_off_tests!(ty: &[_], slice: &$slice, $($tts)*); }; (slice: &mut $slice:expr, $($tts:tt)*) => { - take_tests!(ty: &mut [_], slice: &mut $slice, $($tts)*); + split_off_tests!(ty: &mut [_], slice: &mut $slice, $($tts)*); }; (ty: $ty:ty, slice: $slice:expr, method: $method:ident, $(($test_name:ident, ($($args:expr),*), $output:expr, $remaining:expr),)*) => { $( @@ -2424,64 +2423,64 @@ macro_rules! take_tests { }; } -take_tests! { - slice: &[0, 1, 2, 3], method: take, - (take_in_bounds_range_to, (..1), Some(&[0] as _), &[1, 2, 3]), - (take_in_bounds_range_to_inclusive, (..=0), Some(&[0] as _), &[1, 2, 3]), - (take_in_bounds_range_from, (2..), Some(&[2, 3] as _), &[0, 1]), - (take_oob_range_to, (..5), None, &[0, 1, 2, 3]), - (take_oob_range_to_inclusive, (..=4), None, &[0, 1, 2, 3]), - (take_oob_range_from, (5..), None, &[0, 1, 2, 3]), +split_off_tests! { + slice: &[0, 1, 2, 3], method: split_off, + (split_off_in_bounds_range_to, (..1), Some(&[0] as _), &[1, 2, 3]), + (split_off_in_bounds_range_to_inclusive, (..=0), Some(&[0] as _), &[1, 2, 3]), + (split_off_in_bounds_range_from, (2..), Some(&[2, 3] as _), &[0, 1]), + (split_off_oob_range_to, (..5), None, &[0, 1, 2, 3]), + (split_off_oob_range_to_inclusive, (..=4), None, &[0, 1, 2, 3]), + (split_off_oob_range_from, (5..), None, &[0, 1, 2, 3]), } -take_tests! { - slice: &mut [0, 1, 2, 3], method: take_mut, - (take_mut_in_bounds_range_to, (..1), Some(&mut [0] as _), &mut [1, 2, 3]), - (take_mut_in_bounds_range_to_inclusive, (..=0), Some(&mut [0] as _), &mut [1, 2, 3]), - (take_mut_in_bounds_range_from, (2..), Some(&mut [2, 3] as _), &mut [0, 1]), - (take_mut_oob_range_to, (..5), None, &mut [0, 1, 2, 3]), - (take_mut_oob_range_to_inclusive, (..=4), None, &mut [0, 1, 2, 3]), - (take_mut_oob_range_from, (5..), None, &mut [0, 1, 2, 3]), +split_off_tests! { + slice: &mut [0, 1, 2, 3], method: split_off_mut, + (split_off_mut_in_bounds_range_to, (..1), Some(&mut [0] as _), &mut [1, 2, 3]), + (split_off_mut_in_bounds_range_to_inclusive, (..=0), Some(&mut [0] as _), &mut [1, 2, 3]), + (split_off_mut_in_bounds_range_from, (2..), Some(&mut [2, 3] as _), &mut [0, 1]), + (split_off_mut_oob_range_to, (..5), None, &mut [0, 1, 2, 3]), + (split_off_mut_oob_range_to_inclusive, (..=4), None, &mut [0, 1, 2, 3]), + (split_off_mut_oob_range_from, (5..), None, &mut [0, 1, 2, 3]), } -take_tests! { - slice: &[1, 2], method: take_first, - (take_first_nonempty, (), Some(&1), &[2]), +split_off_tests! { + slice: &[1, 2], method: split_off_first, + (split_off_first_nonempty, (), Some(&1), &[2]), } -take_tests! { - slice: &mut [1, 2], method: take_first_mut, - (take_first_mut_nonempty, (), Some(&mut 1), &mut [2]), +split_off_tests! { + slice: &mut [1, 2], method: split_off_first_mut, + (split_off_first_mut_nonempty, (), Some(&mut 1), &mut [2]), } -take_tests! { - slice: &[1, 2], method: take_last, - (take_last_nonempty, (), Some(&2), &[1]), +split_off_tests! { + slice: &[1, 2], method: split_off_last, + (split_off_last_nonempty, (), Some(&2), &[1]), } -take_tests! { - slice: &mut [1, 2], method: take_last_mut, - (take_last_mut_nonempty, (), Some(&mut 2), &mut [1]), +split_off_tests! { + slice: &mut [1, 2], method: split_off_last_mut, + (split_off_last_mut_nonempty, (), Some(&mut 2), &mut [1]), } -take_tests! { - slice: &[], method: take_first, - (take_first_empty, (), None, &[]), +split_off_tests! { + slice: &[], method: split_off_first, + (split_off_first_empty, (), None, &[]), } -take_tests! { - slice: &mut [], method: take_first_mut, - (take_first_mut_empty, (), None, &mut []), +split_off_tests! { + slice: &mut [], method: split_off_first_mut, + (split_off_first_mut_empty, (), None, &mut []), } -take_tests! { - slice: &[], method: take_last, - (take_last_empty, (), None, &[]), +split_off_tests! { + slice: &[], method: split_off_last, + (split_off_last_empty, (), None, &[]), } -take_tests! { - slice: &mut [], method: take_last_mut, - (take_last_mut_empty, (), None, &mut []), +split_off_tests! { + slice: &mut [], method: split_off_last_mut, + (split_off_last_mut_empty, (), None, &mut []), } #[cfg(not(miri))] // unused in Miri @@ -2496,19 +2495,19 @@ macro_rules! empty_max_mut { } #[cfg(not(miri))] // Comparing usize::MAX many elements takes forever in Miri (and in rustc without optimizations) -take_tests! { - slice: &[(); usize::MAX], method: take, - (take_in_bounds_max_range_to, (..usize::MAX), Some(EMPTY_MAX), &[(); 0]), - (take_oob_max_range_to_inclusive, (..=usize::MAX), None, EMPTY_MAX), - (take_in_bounds_max_range_from, (usize::MAX..), Some(&[] as _), EMPTY_MAX), +split_off_tests! { + slice: &[(); usize::MAX], method: split_off, + (split_off_in_bounds_max_range_to, (..usize::MAX), Some(EMPTY_MAX), &[(); 0]), + (split_off_oob_max_range_to_inclusive, (..=usize::MAX), None, EMPTY_MAX), + (split_off_in_bounds_max_range_from, (usize::MAX..), Some(&[] as _), EMPTY_MAX), } #[cfg(not(miri))] // Comparing usize::MAX many elements takes forever in Miri (and in rustc without optimizations) -take_tests! { - slice: &mut [(); usize::MAX], method: take_mut, - (take_mut_in_bounds_max_range_to, (..usize::MAX), Some(empty_max_mut!()), &mut [(); 0]), - (take_mut_oob_max_range_to_inclusive, (..=usize::MAX), None, empty_max_mut!()), - (take_mut_in_bounds_max_range_from, (usize::MAX..), Some(&mut [] as _), empty_max_mut!()), +split_off_tests! { + slice: &mut [(); usize::MAX], method: split_off_mut, + (split_off_mut_in_bounds_max_range_to, (..usize::MAX), Some(empty_max_mut!()), &mut [(); 0]), + (split_off_mut_oob_max_range_to_inclusive, (..=usize::MAX), None, empty_max_mut!()), + (split_off_mut_in_bounds_max_range_from, (usize::MAX..), Some(&mut [] as _), empty_max_mut!()), } #[test] @@ -2547,63 +2546,130 @@ fn test_flatten_mut_size_overflow() { } #[test] -fn test_get_many_mut_normal_2() { +fn test_get_disjoint_mut_normal_2() { let mut v = vec![1, 2, 3, 4, 5]; - let [a, b] = v.get_many_mut([3, 0]).unwrap(); + let [a, b] = v.get_disjoint_mut([3, 0]).unwrap(); *a += 10; *b += 100; assert_eq!(v, vec![101, 2, 3, 14, 5]); + + let [a, b] = v.get_disjoint_mut([0..=1, 2..=2]).unwrap(); + assert_eq!(a, &mut [101, 2][..]); + assert_eq!(b, &mut [3][..]); + a[0] += 10; + a[1] += 20; + b[0] += 100; + assert_eq!(v, vec![111, 22, 103, 14, 5]); } #[test] -fn test_get_many_mut_normal_3() { +fn test_get_disjoint_mut_normal_3() { let mut v = vec![1, 2, 3, 4, 5]; - let [a, b, c] = v.get_many_mut([0, 4, 2]).unwrap(); + let [a, b, c] = v.get_disjoint_mut([0, 4, 2]).unwrap(); *a += 10; *b += 100; *c += 1000; assert_eq!(v, vec![11, 2, 1003, 4, 105]); + + let [a, b, c] = v.get_disjoint_mut([0..1, 4..5, 1..4]).unwrap(); + assert_eq!(a, &mut [11][..]); + assert_eq!(b, &mut [105][..]); + assert_eq!(c, &mut [2, 1003, 4][..]); + a[0] += 10; + b[0] += 100; + c[0] += 1000; + assert_eq!(v, vec![21, 1002, 1003, 4, 205]); } #[test] -fn test_get_many_mut_empty() { +fn test_get_disjoint_mut_empty() { let mut v = vec![1, 2, 3, 4, 5]; - let [] = v.get_many_mut([]).unwrap(); + let [] = v.get_disjoint_mut::([]).unwrap(); + let [] = v.get_disjoint_mut::, 0>([]).unwrap(); + let [] = v.get_disjoint_mut::, 0>([]).unwrap(); assert_eq!(v, vec![1, 2, 3, 4, 5]); } #[test] -fn test_get_many_mut_single_first() { +fn test_get_disjoint_mut_single_first() { let mut v = vec![1, 2, 3, 4, 5]; - let [a] = v.get_many_mut([0]).unwrap(); + let [a] = v.get_disjoint_mut([0]).unwrap(); *a += 10; assert_eq!(v, vec![11, 2, 3, 4, 5]); } #[test] -fn test_get_many_mut_single_last() { +fn test_get_disjoint_mut_single_last() { let mut v = vec![1, 2, 3, 4, 5]; - let [a] = v.get_many_mut([4]).unwrap(); + let [a] = v.get_disjoint_mut([4]).unwrap(); *a += 10; assert_eq!(v, vec![1, 2, 3, 4, 15]); } #[test] -fn test_get_many_mut_oob_nonempty() { +fn test_get_disjoint_mut_oob_nonempty() { let mut v = vec![1, 2, 3, 4, 5]; - assert!(v.get_many_mut([5]).is_err()); + assert!(v.get_disjoint_mut([5]).is_err()); } #[test] -fn test_get_many_mut_oob_empty() { +fn test_get_disjoint_mut_oob_empty() { let mut v: Vec = vec![]; - assert!(v.get_many_mut([0]).is_err()); + assert!(v.get_disjoint_mut([0]).is_err()); } #[test] -fn test_get_many_mut_duplicate() { +fn test_get_disjoint_mut_duplicate() { let mut v = vec![1, 2, 3, 4, 5]; - assert!(v.get_many_mut([1, 3, 3, 4]).is_err()); + assert!(v.get_disjoint_mut([1, 3, 3, 4]).is_err()); +} + +#[test] +fn test_get_disjoint_mut_range_oob() { + let mut v = vec![1, 2, 3, 4, 5]; + assert!(v.get_disjoint_mut([0..6]).is_err()); + assert!(v.get_disjoint_mut([5..6]).is_err()); + assert!(v.get_disjoint_mut([6..6]).is_err()); + assert!(v.get_disjoint_mut([0..=5]).is_err()); + assert!(v.get_disjoint_mut([0..=6]).is_err()); + assert!(v.get_disjoint_mut([5..=5]).is_err()); +} + +#[test] +fn test_get_disjoint_mut_range_overlapping() { + let mut v = vec![1, 2, 3, 4, 5]; + assert!(v.get_disjoint_mut([0..1, 0..2]).is_err()); + assert!(v.get_disjoint_mut([0..1, 1..2, 0..1]).is_err()); + assert!(v.get_disjoint_mut([0..3, 1..1]).is_err()); + assert!(v.get_disjoint_mut([0..3, 1..2]).is_err()); + assert!(v.get_disjoint_mut([0..=0, 2..=2, 0..=1]).is_err()); + assert!(v.get_disjoint_mut([0..=4, 0..=0]).is_err()); + assert!(v.get_disjoint_mut([4..=4, 0..=0, 3..=4]).is_err()); +} + +#[test] +fn test_get_disjoint_mut_range_empty_at_edge() { + let mut v = vec![1, 2, 3, 4, 5]; + assert_eq!( + v.get_disjoint_mut([0..0, 0..5, 5..5]), + Ok([&mut [][..], &mut [1, 2, 3, 4, 5], &mut []]), + ); + assert_eq!( + v.get_disjoint_mut([0..0, 0..1, 1..1, 1..2, 2..2, 2..3, 3..3, 3..4, 4..4, 4..5, 5..5]), + Ok([ + &mut [][..], + &mut [1], + &mut [], + &mut [2], + &mut [], + &mut [3], + &mut [], + &mut [4], + &mut [], + &mut [5], + &mut [], + ]), + ); } #[test] diff --git a/core/tests/str.rs b/coretests/tests/str.rs similarity index 100% rename from core/tests/str.rs rename to coretests/tests/str.rs diff --git a/core/tests/str_lossy.rs b/coretests/tests/str_lossy.rs similarity index 100% rename from core/tests/str_lossy.rs rename to coretests/tests/str_lossy.rs diff --git a/core/tests/task.rs b/coretests/tests/task.rs similarity index 100% rename from core/tests/task.rs rename to coretests/tests/task.rs diff --git a/core/tests/time.rs b/coretests/tests/time.rs similarity index 100% rename from core/tests/time.rs rename to coretests/tests/time.rs diff --git a/core/tests/tuple.rs b/coretests/tests/tuple.rs similarity index 100% rename from core/tests/tuple.rs rename to coretests/tests/tuple.rs diff --git a/core/tests/unicode.rs b/coretests/tests/unicode.rs similarity index 100% rename from core/tests/unicode.rs rename to coretests/tests/unicode.rs diff --git a/core/tests/waker.rs b/coretests/tests/waker.rs similarity index 100% rename from core/tests/waker.rs rename to coretests/tests/waker.rs diff --git a/panic_abort/src/android.rs b/panic_abort/src/android.rs index 47c22834597de..1cc2077d14bd4 100644 --- a/panic_abort/src/android.rs +++ b/panic_abort/src/android.rs @@ -16,9 +16,10 @@ type SetAbortMessageType = unsafe extern "C" fn(*const libc::c_char) -> (); // Weakly resolve the symbol for android_set_abort_message. This function is only available // for API >= 21. pub(crate) unsafe fn android_set_abort_message(payload: &mut dyn PanicPayload) { - let func_addr = + let func_addr = unsafe { libc::dlsym(libc::RTLD_DEFAULT, ANDROID_SET_ABORT_MESSAGE.as_ptr() as *const libc::c_char) - as usize; + as usize + }; if func_addr == 0 { return; } @@ -37,13 +38,14 @@ pub(crate) unsafe fn android_set_abort_message(payload: &mut dyn PanicPayload) { // Allocate a new buffer to append the null byte. let size = msg.len() + 1usize; - let buf = libc::malloc(size) as *mut libc::c_char; + let buf = unsafe { libc::malloc(size) as *mut libc::c_char }; if buf.is_null() { return; // allocation failure } - copy_nonoverlapping(msg.as_ptr(), buf as *mut u8, msg.len()); - buf.add(msg.len()).write(0); - - let func = transmute::(func_addr); - func(buf); + unsafe { + copy_nonoverlapping(msg.as_ptr(), buf as *mut u8, msg.len()); + buf.add(msg.len()).write(0); + let func = transmute::(func_addr); + func(buf); + } } diff --git a/panic_abort/src/lib.rs b/panic_abort/src/lib.rs index dc2b42bb90ae8..b2ad0f4ac3d04 100644 --- a/panic_abort/src/lib.rs +++ b/panic_abort/src/lib.rs @@ -15,6 +15,7 @@ #![feature(staged_api)] #![feature(rustc_attrs)] #![allow(internal_features)] +#![deny(unsafe_op_in_unsafe_fn)] #[cfg(target_os = "android")] mod android; @@ -36,16 +37,22 @@ pub unsafe extern "C" fn __rust_panic_cleanup(_: *mut u8) -> *mut (dyn Any + Sen pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { // Android has the ability to attach a message as part of the abort. #[cfg(target_os = "android")] - android::android_set_abort_message(_payload); + unsafe { + android::android_set_abort_message(_payload); + } #[cfg(target_os = "zkvm")] - zkvm::zkvm_set_abort_message(_payload); + unsafe { + zkvm::zkvm_set_abort_message(_payload); + } - abort(); + unsafe { + abort(); + } cfg_if::cfg_if! { if #[cfg(any(unix, target_os = "solid_asp3"))] { unsafe fn abort() -> ! { - libc::abort(); + unsafe { libc::abort(); } } } else if #[cfg(any(target_os = "hermit", all(target_vendor = "fortanix", target_env = "sgx"), @@ -54,10 +61,10 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { ))] { unsafe fn abort() -> ! { // call std::sys::abort_internal - extern "C" { + unsafe extern "C" { pub fn __rust_abort() -> !; } - __rust_abort(); + unsafe { __rust_abort(); } } } else if #[cfg(all(windows, not(miri)))] { // On Windows, use the processor-specific __fastfail mechanism. In Windows 8 @@ -75,11 +82,17 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { const FAST_FAIL_FATAL_APP_EXIT: usize = 7; cfg_if::cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { - core::arch::asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + unsafe { + core::arch::asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + } } else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] { - core::arch::asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + unsafe { + core::arch::asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + } } else if #[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))] { - core::arch::asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + unsafe { + core::arch::asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + } } else { core::intrinsics::abort(); } @@ -87,13 +100,13 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { } } else if #[cfg(target_os = "teeos")] { mod teeos { - extern "C" { + unsafe extern "C" { pub fn TEE_Panic(code: u32) -> !; } } unsafe fn abort() -> ! { - teeos::TEE_Panic(1); + unsafe { teeos::TEE_Panic(1); } } } else { unsafe fn abort() -> ! { diff --git a/panic_abort/src/zkvm.rs b/panic_abort/src/zkvm.rs index a6a02abf10976..7b1e89c6a8e63 100644 --- a/panic_abort/src/zkvm.rs +++ b/panic_abort/src/zkvm.rs @@ -16,9 +16,11 @@ pub(crate) unsafe fn zkvm_set_abort_message(payload: &mut dyn PanicPayload) { return; } - extern "C" { + unsafe extern "C" { fn sys_panic(msg_ptr: *const u8, len: usize) -> !; } - sys_panic(msg.as_ptr(), msg.len()); + unsafe { + sys_panic(msg.as_ptr(), msg.len()); + } } diff --git a/panic_unwind/Cargo.toml b/panic_unwind/Cargo.toml index 6d1f9764efbfd..c2abb79192e9f 100644 --- a/panic_unwind/Cargo.toml +++ b/panic_unwind/Cargo.toml @@ -23,7 +23,4 @@ libc = { version = "0.2", default-features = false } [lints.rust.unexpected_cfgs] level = "warn" -check-cfg = [ - # #[cfg(bootstrap)] rtems - 'cfg(target_os, values("rtems"))', -] +check-cfg = ['cfg(emscripten_wasm_eh)'] diff --git a/panic_unwind/src/dummy.rs b/panic_unwind/src/dummy.rs index a4bcd216c60f0..a0d6876691833 100644 --- a/panic_unwind/src/dummy.rs +++ b/panic_unwind/src/dummy.rs @@ -6,10 +6,10 @@ use alloc::boxed::Box; use core::any::Any; use core::intrinsics; -pub unsafe fn cleanup(_ptr: *mut u8) -> Box { +pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box { intrinsics::abort() } -pub unsafe fn panic(_data: Box) -> u32 { +pub(crate) unsafe fn panic(_data: Box) -> u32 { intrinsics::abort() } diff --git a/panic_unwind/src/emcc.rs b/panic_unwind/src/emcc.rs index b986fc1c2a829..bad795a019c9a 100644 --- a/panic_unwind/src/emcc.rs +++ b/panic_unwind/src/emcc.rs @@ -9,7 +9,7 @@ use alloc::boxed::Box; use core::any::Any; use core::sync::atomic::{AtomicBool, Ordering}; -use core::{intrinsics, mem, ptr}; +use core::{intrinsics, ptr}; use unwind as uw; @@ -21,7 +21,7 @@ struct TypeInfo { } unsafe impl Sync for TypeInfo {} -extern "C" { +unsafe extern "C" { // The leading `\x01` byte here is actually a magical signal to LLVM to // *not* apply any other mangling like prefixing with a `_` character. // @@ -64,46 +64,53 @@ struct Exception { data: Option>, } -pub unsafe fn cleanup(ptr: *mut u8) -> Box { +pub(crate) unsafe fn cleanup(ptr: *mut u8) -> Box { // intrinsics::try actually gives us a pointer to this structure. #[repr(C)] struct CatchData { ptr: *mut u8, is_rust_panic: bool, } - let catch_data = &*(ptr as *mut CatchData); + unsafe { + let catch_data = &*(ptr as *mut CatchData); - let adjusted_ptr = __cxa_begin_catch(catch_data.ptr as *mut libc::c_void) as *mut Exception; - if !catch_data.is_rust_panic { - super::__rust_foreign_exception(); - } + let adjusted_ptr = __cxa_begin_catch(catch_data.ptr as *mut libc::c_void) as *mut Exception; + if !catch_data.is_rust_panic { + super::__rust_foreign_exception(); + } - let canary = (&raw const (*adjusted_ptr).canary).read(); - if !ptr::eq(canary, &EXCEPTION_TYPE_INFO) { - super::__rust_foreign_exception(); - } + let canary = (&raw const (*adjusted_ptr).canary).read(); + if !ptr::eq(canary, &EXCEPTION_TYPE_INFO) { + super::__rust_foreign_exception(); + } - let was_caught = (*adjusted_ptr).caught.swap(true, Ordering::Relaxed); - if was_caught { - // Since cleanup() isn't allowed to panic, we just abort instead. - intrinsics::abort(); + let was_caught = (*adjusted_ptr).caught.swap(true, Ordering::Relaxed); + if was_caught { + // Since cleanup() isn't allowed to panic, we just abort instead. + intrinsics::abort(); + } + let out = (*adjusted_ptr).data.take().unwrap(); + __cxa_end_catch(); + out } - let out = (*adjusted_ptr).data.take().unwrap(); - __cxa_end_catch(); - out } -pub unsafe fn panic(data: Box) -> u32 { - let exception = __cxa_allocate_exception(mem::size_of::()) as *mut Exception; - if exception.is_null() { - return uw::_URC_FATAL_PHASE1_ERROR as u32; +pub(crate) unsafe fn panic(data: Box) -> u32 { + unsafe { + let exception = __cxa_allocate_exception(size_of::()) as *mut Exception; + if exception.is_null() { + return uw::_URC_FATAL_PHASE1_ERROR as u32; + } + ptr::write( + exception, + Exception { + canary: &EXCEPTION_TYPE_INFO, + caught: AtomicBool::new(false), + data: Some(data), + }, + ); + __cxa_throw(exception as *mut _, &EXCEPTION_TYPE_INFO, exception_cleanup); } - ptr::write(exception, Exception { - canary: &EXCEPTION_TYPE_INFO, - caught: AtomicBool::new(false), - data: Some(data), - }); - __cxa_throw(exception as *mut _, &EXCEPTION_TYPE_INFO, exception_cleanup); } extern "C" fn exception_cleanup(ptr: *mut libc::c_void) -> *mut libc::c_void { @@ -116,7 +123,7 @@ extern "C" fn exception_cleanup(ptr: *mut libc::c_void) -> *mut libc::c_void { } } -extern "C" { +unsafe extern "C" { fn __cxa_allocate_exception(thrown_size: libc::size_t) -> *mut libc::c_void; fn __cxa_begin_catch(thrown_exception: *mut libc::c_void) -> *mut libc::c_void; fn __cxa_end_catch(); diff --git a/panic_unwind/src/gcc.rs b/panic_unwind/src/gcc.rs index 925af6c08322e..5f95870069dc5 100644 --- a/panic_unwind/src/gcc.rs +++ b/panic_unwind/src/gcc.rs @@ -5,7 +5,7 @@ //! documents linked from it. //! These are also good reads: //! * -//! * +//! * //! * //! //! ## A brief summary @@ -58,7 +58,7 @@ struct Exception { cause: Box, } -pub unsafe fn panic(data: Box) -> u32 { +pub(crate) unsafe fn panic(data: Box) -> u32 { let exception = Box::new(Exception { _uwe: uw::_Unwind_Exception { exception_class: RUST_EXCEPTION_CLASS, @@ -69,7 +69,7 @@ pub unsafe fn panic(data: Box) -> u32 { cause: data, }); let exception_param = Box::into_raw(exception) as *mut uw::_Unwind_Exception; - return uw::_Unwind_RaiseException(exception_param) as u32; + return unsafe { uw::_Unwind_RaiseException(exception_param) as u32 }; extern "C" fn exception_cleanup( _unwind_code: uw::_Unwind_Reason_Code, @@ -82,27 +82,29 @@ pub unsafe fn panic(data: Box) -> u32 { } } -pub unsafe fn cleanup(ptr: *mut u8) -> Box { - let exception = ptr as *mut uw::_Unwind_Exception; - if (*exception).exception_class != RUST_EXCEPTION_CLASS { - uw::_Unwind_DeleteException(exception); - super::__rust_foreign_exception(); - } +pub(crate) unsafe fn cleanup(ptr: *mut u8) -> Box { + unsafe { + let exception = ptr as *mut uw::_Unwind_Exception; + if (*exception).exception_class != RUST_EXCEPTION_CLASS { + uw::_Unwind_DeleteException(exception); + super::__rust_foreign_exception(); + } - let exception = exception.cast::(); - // Just access the canary field, avoid accessing the entire `Exception` as - // it can be a foreign Rust exception. - let canary = (&raw const (*exception).canary).read(); - if !ptr::eq(canary, &CANARY) { - // A foreign Rust exception, treat it slightly differently from other - // foreign exceptions, because call into `_Unwind_DeleteException` will - // call into `__rust_drop_panic` which produces a confusing - // "Rust panic must be rethrown" message. - super::__rust_foreign_exception(); - } + let exception = exception.cast::(); + // Just access the canary field, avoid accessing the entire `Exception` as + // it can be a foreign Rust exception. + let canary = (&raw const (*exception).canary).read(); + if !ptr::eq(canary, &CANARY) { + // A foreign Rust exception, treat it slightly differently from other + // foreign exceptions, because call into `_Unwind_DeleteException` will + // call into `__rust_drop_panic` which produces a confusing + // "Rust panic must be rethrown" message. + super::__rust_foreign_exception(); + } - let exception = Box::from_raw(exception as *mut Exception); - exception.cause + let exception = Box::from_raw(exception as *mut Exception); + exception.cause + } } // Rust's exception class identifier. This is used by personality routines to diff --git a/panic_unwind/src/hermit.rs b/panic_unwind/src/hermit.rs index 69b9edb77c564..8f4562d07fc4e 100644 --- a/panic_unwind/src/hermit.rs +++ b/panic_unwind/src/hermit.rs @@ -5,16 +5,20 @@ use alloc::boxed::Box; use core::any::Any; -pub unsafe fn cleanup(_ptr: *mut u8) -> Box { - extern "C" { - pub fn __rust_abort() -> !; +pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box { + unsafe extern "C" { + fn __rust_abort() -> !; + } + unsafe { + __rust_abort(); } - __rust_abort(); } -pub unsafe fn panic(_data: Box) -> u32 { - extern "C" { - pub fn __rust_abort() -> !; +pub(crate) unsafe fn panic(_data: Box) -> u32 { + unsafe extern "C" { + fn __rust_abort() -> !; + } + unsafe { + __rust_abort(); } - __rust_abort(); } diff --git a/panic_unwind/src/lib.rs b/panic_unwind/src/lib.rs index 1981675f40922..a284633ea2fc7 100644 --- a/panic_unwind/src/lib.rs +++ b/panic_unwind/src/lib.rs @@ -14,6 +14,7 @@ #![no_std] #![unstable(feature = "panic_unwind", issue = "32837")] #![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] +#![feature(cfg_emscripten_wasm_eh)] #![feature(core_intrinsics)] #![feature(lang_items)] #![feature(panic_unwind)] @@ -25,13 +26,15 @@ // `real_imp` is unused with Miri, so silence warnings. #![cfg_attr(miri, allow(dead_code))] #![allow(internal_features)] +#![warn(unreachable_pub)] +#![deny(unsafe_op_in_unsafe_fn)] use alloc::boxed::Box; use core::any::Any; use core::panic::PanicPayload; cfg_if::cfg_if! { - if #[cfg(target_os = "emscripten")] { + if #[cfg(all(target_os = "emscripten", not(emscripten_wasm_eh)))] { #[path = "emcc.rs"] mod imp; } else if #[cfg(target_os = "hermit")] { @@ -46,7 +49,7 @@ cfg_if::cfg_if! { target_os = "psp", target_os = "xous", target_os = "solid_asp3", - all(target_family = "unix", not(any(target_os = "espidf", target_os = "rtems", target_os = "nuttx"))), + all(target_family = "unix", not(any(target_os = "espidf", target_os = "nuttx"))), all(target_vendor = "fortanix", target_env = "sgx"), target_family = "wasm", ))] { @@ -73,7 +76,7 @@ cfg_if::cfg_if! { } } -extern "C" { +unsafe extern "C" { /// Handler in std called when a panic object is dropped outside of /// `catch_unwind`. fn __rust_drop_panic() -> !; @@ -85,14 +88,16 @@ extern "C" { #[rustc_std_internal_symbol] #[allow(improper_ctypes_definitions)] pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static) { - Box::into_raw(imp::cleanup(payload)) + unsafe { Box::into_raw(imp::cleanup(payload)) } } // Entry point for raising an exception, just delegates to the platform-specific // implementation. #[rustc_std_internal_symbol] pub unsafe fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32 { - let payload = Box::from_raw(payload.take_box()); + unsafe { + let payload = Box::from_raw(payload.take_box()); - imp::panic(payload) + imp::panic(payload) + } } diff --git a/panic_unwind/src/miri.rs b/panic_unwind/src/miri.rs index 695adadd59b55..d6d4af8218d31 100644 --- a/panic_unwind/src/miri.rs +++ b/panic_unwind/src/miri.rs @@ -7,20 +7,20 @@ use core::any::Any; // Must be pointer-sized. type Payload = Box>; -extern "Rust" { +unsafe extern "Rust" { /// Miri-provided extern function to begin unwinding. fn miri_start_unwind(payload: *mut u8) -> !; } -pub unsafe fn panic(payload: Box) -> u32 { +pub(crate) unsafe fn panic(payload: Box) -> u32 { // The payload we pass to `miri_start_unwind` will be exactly the argument we get // in `cleanup` below. So we just box it up once, to get something pointer-sized. let payload_box: Payload = Box::new(payload); - miri_start_unwind(Box::into_raw(payload_box) as *mut u8) + unsafe { miri_start_unwind(Box::into_raw(payload_box) as *mut u8) } } -pub unsafe fn cleanup(payload_box: *mut u8) -> Box { +pub(crate) unsafe fn cleanup(payload_box: *mut u8) -> Box { // Recover the underlying `Box`. - let payload_box: Payload = Box::from_raw(payload_box as *mut _); + let payload_box: Payload = unsafe { Box::from_raw(payload_box as *mut _) }; *payload_box } diff --git a/panic_unwind/src/seh.rs b/panic_unwind/src/seh.rs index 565a2b8c573b4..3794b56c0898f 100644 --- a/panic_unwind/src/seh.rs +++ b/panic_unwind/src/seh.rs @@ -49,7 +49,7 @@ use alloc::boxed::Box; use core::any::Any; use core::ffi::{c_int, c_uint, c_void}; -use core::mem::{self, ManuallyDrop}; +use core::mem::ManuallyDrop; // NOTE(nbdd0121): The `canary` field is part of stable ABI. #[repr(C)] @@ -111,18 +111,18 @@ struct Exception { mod imp { #[repr(transparent)] #[derive(Copy, Clone)] - pub struct ptr_t(*mut u8); + pub(super) struct ptr_t(*mut u8); impl ptr_t { - pub const fn null() -> Self { + pub(super) const fn null() -> Self { Self(core::ptr::null_mut()) } - pub const fn new(ptr: *mut u8) -> Self { + pub(super) const fn new(ptr: *mut u8) -> Self { Self(ptr) } - pub const fn raw(self) -> *mut u8 { + pub(super) const fn raw(self) -> *mut u8 { self.0 } } @@ -133,18 +133,18 @@ mod imp { // On 64-bit systems, SEH represents pointers as 32-bit offsets from `__ImageBase`. #[repr(transparent)] #[derive(Copy, Clone)] - pub struct ptr_t(u32); + pub(super) struct ptr_t(u32); - extern "C" { - pub static __ImageBase: u8; + unsafe extern "C" { + static __ImageBase: u8; } impl ptr_t { - pub const fn null() -> Self { + pub(super) const fn null() -> Self { Self(0) } - pub fn new(ptr: *mut u8) -> Self { + pub(super) fn new(ptr: *mut u8) -> Self { // We need to expose the provenance of the pointer because it is not carried by // the `u32`, while the FFI needs to have this provenance to excess our statics. // @@ -159,7 +159,7 @@ mod imp { Self(offset as u32) } - pub const fn raw(self) -> u32 { + pub(super) const fn raw(self) -> u32 { self.0 } } @@ -168,7 +168,7 @@ mod imp { use imp::ptr_t; #[repr(C)] -pub struct _ThrowInfo { +struct _ThrowInfo { pub attributes: c_uint, pub pmfnUnwind: ptr_t, pub pForwardCompat: ptr_t, @@ -176,13 +176,13 @@ pub struct _ThrowInfo { } #[repr(C)] -pub struct _CatchableTypeArray { +struct _CatchableTypeArray { pub nCatchableTypes: c_int, pub arrayOfCatchableTypes: [ptr_t; 1], } #[repr(C)] -pub struct _CatchableType { +struct _CatchableType { pub properties: c_uint, pub pType: ptr_t, pub thisDisplacement: _PMD, @@ -191,14 +191,14 @@ pub struct _CatchableType { } #[repr(C)] -pub struct _PMD { +struct _PMD { pub mdisp: c_int, pub pdisp: c_int, pub vdisp: c_int, } #[repr(C)] -pub struct _TypeDescriptor { +struct _TypeDescriptor { pub pVFTable: *const u8, pub spare: *mut u8, pub name: [u8; 11], @@ -225,11 +225,11 @@ static mut CATCHABLE_TYPE: _CatchableType = _CatchableType { properties: 0, pType: ptr_t::null(), thisDisplacement: _PMD { mdisp: 0, pdisp: -1, vdisp: 0 }, - sizeOrOffset: mem::size_of::() as c_int, + sizeOrOffset: size_of::() as c_int, copyFunction: ptr_t::null(), }; -extern "C" { +unsafe extern "C" { // The leading `\x01` byte here is actually a magical signal to LLVM to // *not* apply any other mangling like prefixing with a `_` character. // @@ -268,9 +268,11 @@ static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor { macro_rules! define_cleanup { ($abi:tt $abi2:tt) => { unsafe extern $abi fn exception_cleanup(e: *mut Exception) { - if let Exception { data: Some(b), .. } = e.read() { - drop(b); - super::__rust_drop_panic(); + unsafe { + if let Exception { data: Some(b), .. } = e.read() { + drop(b); + super::__rust_drop_panic(); + } } } unsafe extern $abi2 fn exception_copy( @@ -288,9 +290,7 @@ cfg_if::cfg_if! { } } -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint -#[allow(static_mut_refs)] -pub unsafe fn panic(data: Box) -> u32 { +pub(crate) unsafe fn panic(data: Box) -> u32 { use core::intrinsics::atomic_store_seqcst; // _CxxThrowException executes entirely on this stack frame, so there's no @@ -324,45 +324,51 @@ pub unsafe fn panic(data: Box) -> u32 { // // In any case, we basically need to do something like this until we can // express more operations in statics (and we may never be able to). - atomic_store_seqcst( - (&raw mut THROW_INFO.pmfnUnwind).cast(), - ptr_t::new(exception_cleanup as *mut u8).raw(), - ); - atomic_store_seqcst( - (&raw mut THROW_INFO.pCatchableTypeArray).cast(), - ptr_t::new((&raw mut CATCHABLE_TYPE_ARRAY).cast()).raw(), - ); - atomic_store_seqcst( - (&raw mut CATCHABLE_TYPE_ARRAY.arrayOfCatchableTypes[0]).cast(), - ptr_t::new((&raw mut CATCHABLE_TYPE).cast()).raw(), - ); - atomic_store_seqcst( - (&raw mut CATCHABLE_TYPE.pType).cast(), - ptr_t::new((&raw mut TYPE_DESCRIPTOR).cast()).raw(), - ); - atomic_store_seqcst( - (&raw mut CATCHABLE_TYPE.copyFunction).cast(), - ptr_t::new(exception_copy as *mut u8).raw(), - ); - - extern "system-unwind" { + unsafe { + atomic_store_seqcst( + (&raw mut THROW_INFO.pmfnUnwind).cast(), + ptr_t::new(exception_cleanup as *mut u8).raw(), + ); + atomic_store_seqcst( + (&raw mut THROW_INFO.pCatchableTypeArray).cast(), + ptr_t::new((&raw mut CATCHABLE_TYPE_ARRAY).cast()).raw(), + ); + atomic_store_seqcst( + (&raw mut CATCHABLE_TYPE_ARRAY.arrayOfCatchableTypes[0]).cast(), + ptr_t::new((&raw mut CATCHABLE_TYPE).cast()).raw(), + ); + atomic_store_seqcst( + (&raw mut CATCHABLE_TYPE.pType).cast(), + ptr_t::new((&raw mut TYPE_DESCRIPTOR).cast()).raw(), + ); + atomic_store_seqcst( + (&raw mut CATCHABLE_TYPE.copyFunction).cast(), + ptr_t::new(exception_copy as *mut u8).raw(), + ); + } + + unsafe extern "system-unwind" { fn _CxxThrowException(pExceptionObject: *mut c_void, pThrowInfo: *mut u8) -> !; } - _CxxThrowException(throw_ptr, (&raw mut THROW_INFO) as *mut _); + unsafe { + _CxxThrowException(throw_ptr, (&raw mut THROW_INFO) as *mut _); + } } -pub unsafe fn cleanup(payload: *mut u8) -> Box { - // A null payload here means that we got here from the catch (...) of - // __rust_try. This happens when a non-Rust foreign exception is caught. - if payload.is_null() { - super::__rust_foreign_exception(); - } - let exception = payload as *mut Exception; - let canary = (&raw const (*exception).canary).read(); - if !core::ptr::eq(canary, &raw const TYPE_DESCRIPTOR) { - // A foreign Rust exception. - super::__rust_foreign_exception(); +pub(crate) unsafe fn cleanup(payload: *mut u8) -> Box { + unsafe { + // A null payload here means that we got here from the catch (...) of + // __rust_try. This happens when a non-Rust foreign exception is caught. + if payload.is_null() { + super::__rust_foreign_exception(); + } + let exception = payload as *mut Exception; + let canary = (&raw const (*exception).canary).read(); + if !core::ptr::eq(canary, &raw const TYPE_DESCRIPTOR) { + // A foreign Rust exception. + super::__rust_foreign_exception(); + } + (*exception).data.take().unwrap() } - (*exception).data.take().unwrap() } diff --git a/portable-simd/.github/workflows/ci.yml b/portable-simd/.github/workflows/ci.yml index b292be2d6f999..3984d8f0d8d99 100644 --- a/portable-simd/.github/workflows/ci.yml +++ b/portable-simd/.github/workflows/ci.yml @@ -9,6 +9,7 @@ on: env: CARGO_NET_RETRY: 10 RUSTUP_MAX_RETRIES: 10 + PROPTEST_CASES: 64 jobs: rustfmt: @@ -16,12 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - rustup component add rustfmt + - uses: actions/checkout@v4 - name: Run rustfmt run: cargo fmt --all -- --check @@ -37,7 +33,9 @@ jobs: - i686-unknown-linux-gnu - i586-unknown-linux-gnu - aarch64-unknown-linux-gnu + - arm64ec-pc-windows-msvc - armv7-unknown-linux-gnueabihf + - loongarch64-unknown-linux-gnu # non-nightly since https://github.com/rust-lang/rust/pull/113274 # - mips-unknown-linux-gnu # - mips64-unknown-linux-gnuabi64 @@ -49,13 +47,9 @@ jobs: - wasm32-unknown-unknown steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - rustup target add ${{ matrix.target }} - rustup component add clippy + run: rustup target add ${{ matrix.target }} - name: Run Clippy run: cargo clippy --all-targets --target ${{ matrix.target }} @@ -65,26 +59,19 @@ jobs: strategy: fail-fast: false matrix: - target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, i586-pc-windows-msvc, x86_64-unknown-linux-gnu, x86_64-apple-darwin] + target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, i586-pc-windows-msvc, x86_64-unknown-linux-gnu] # `default` means we use the default target config for the target, # `native` means we run with `-Ctarget-cpu=native`, and anything else is # an arg to `-Ctarget-feature` target_feature: [default, native, +sse3, +ssse3, +sse4.1, +sse4.2, +avx, +avx2] exclude: - # The macos runners seem to only reliably support up to `avx`. - - { target: x86_64-apple-darwin, target_feature: +avx2 } - # These features are statically known to be present for all 64 bit - # macs, and thus are covered by the `default` test - - { target: x86_64-apple-darwin, target_feature: +sse3 } - - { target: x86_64-apple-darwin, target_feature: +ssse3 } # -Ctarget-cpu=native sounds like bad-news if target != host - { target: i686-pc-windows-msvc, target_feature: native } - { target: i586-pc-windows-msvc, target_feature: native } include: # Populate the `matrix.os` field - - { target: x86_64-apple-darwin, os: macos-latest } - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest } - { target: x86_64-pc-windows-msvc, os: windows-latest } - { target: i686-pc-windows-msvc, os: windows-latest } @@ -98,12 +85,9 @@ jobs: # avx512vl, but occasionally doesn't. Maybe one day we can enable it. steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - rustup target add ${{ matrix.target }} + run: rustup target add ${{ matrix.target }} - name: Configure RUSTFLAGS shell: bash @@ -145,6 +129,35 @@ jobs: run: cargo doc --verbose --target=${{ matrix.target }} env: RUSTDOCFLAGS: -Dwarnings + + macos-tests: + name: ${{ matrix.target }} + runs-on: macos-latest + strategy: + fail-fast: false + matrix: + target: + - aarch64-apple-darwin + - x86_64-apple-darwin + steps: + - uses: actions/checkout@v4 + - name: Setup Rust + run: rustup target add ${{ matrix.target }} + + - name: Configure RUSTFLAGS + shell: bash + run: echo "RUSTFLAGS=-Dwarnings" >> $GITHUB_ENV + + - name: Test (debug) + run: cargo test --verbose --target=${{ matrix.target }} + + - name: Test (release) + run: cargo test --verbose --target=${{ matrix.target }} --release + + - name: Generate docs + run: cargo doc --verbose --target=${{ matrix.target }} + env: + RUSTDOCFLAGS: -Dwarnings wasm-tests: name: "wasm (firefox, ${{ matrix.name }})" @@ -155,11 +168,7 @@ jobs: - { name: default, RUSTFLAGS: "" } - { name: simd128, RUSTFLAGS: "-C target-feature=+simd128" } steps: - - uses: actions/checkout@v2 - - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly + - uses: actions/checkout@v4 - name: Install wasm-pack run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Test (debug) @@ -174,6 +183,8 @@ jobs: cross-tests: name: "${{ matrix.target_feature }} on ${{ matrix.target }} (via cross)" runs-on: ubuntu-latest + env: + PROPTEST_CASES: 16 strategy: fail-fast: false @@ -185,6 +196,7 @@ jobs: - powerpc-unknown-linux-gnu - powerpc64le-unknown-linux-gnu # includes altivec by default - riscv64gc-unknown-linux-gnu + - loongarch64-unknown-linux-gnu # MIPS uses a nonstandard binary representation for NaNs which makes it worth testing # non-nightly since https://github.com/rust-lang/rust/pull/113274 # - mips-unknown-linux-gnu @@ -201,24 +213,14 @@ jobs: # - { target: riscv64gc-unknown-linux-gnu, target_feature: "+v,+zvl128b" } steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - rustup target add ${{ matrix.target }} - rustup component add rust-src + run: rustup target add ${{ matrix.target }} - name: Install Cross - # Equivalent to `cargo install cross`, but downloading a prebuilt - # binary. Ideally we wouldn't hardcode a version, but the version number - # being part of the tarball means we can't just use the download/latest - # URL :( + # Install the latest git version for newer targets. run: | - CROSS_URL=https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-gnu.tar.gz - mkdir -p "$HOME/.bin" - curl -sfSL --retry-delay 10 --retry 5 "${CROSS_URL}" | tar zxf - -C "$HOME/.bin" - echo "$HOME/.bin" >> $GITHUB_PATH + cargo install cross --git https://github.com/cross-rs/cross --rev 4090beca3cfffa44371a5bba524de3a578aa46c3 - name: Configure Emulated CPUs run: | @@ -242,34 +244,11 @@ jobs: - name: Test (release) run: cross test --verbose --target=${{ matrix.target }} --release - features: - name: "Test cargo features (${{ matrix.simd }} × ${{ matrix.features }})" + miri: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - simd: - - "" - - "avx512" - features: - - "" - - "--features std" - - "--features all_lane_counts" - - "--all-features" - + env: + PROPTEST_CASES: 16 steps: - - uses: actions/checkout@v2 - - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - - name: Detect AVX512 - run: echo "CPU_FEATURE=$(lscpu | grep -o avx512[a-z]* | sed s/avx/+avx/ | tr '\n' ',' )" >> $GITHUB_ENV - - name: Check build - if: ${{ matrix.simd == '' }} - run: RUSTFLAGS="-Dwarnings" cargo test --all-targets --no-default-features ${{ matrix.features }} - - name: Check AVX - if: ${{ matrix.simd == 'avx512' && contains(env.CPU_FEATURE, 'avx512') }} - run: | - echo "Found AVX features: $CPU_FEATURE" - RUSTFLAGS="-Dwarnings -Ctarget-feature=$CPU_FEATURE" cargo test --all-targets --no-default-features ${{ matrix.features }} + - uses: actions/checkout@v4 + - name: Test (Miri) + run: cargo miri test diff --git a/portable-simd/.github/workflows/doc.yml b/portable-simd/.github/workflows/doc.yml index 9d1fa66ccb595..22c2cb3f67f1b 100644 --- a/portable-simd/.github/workflows/doc.yml +++ b/portable-simd/.github/workflows/doc.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Setup Rust run: | diff --git a/portable-simd/.gitignore b/portable-simd/.gitignore index ea8c4bf7f35f6..9673e52dcadba 100644 --- a/portable-simd/.gitignore +++ b/portable-simd/.gitignore @@ -1 +1,2 @@ /target +git-subtree.sh diff --git a/portable-simd/Cargo.toml b/portable-simd/Cargo.toml index d1732aaec2f92..21d4584a9f4d9 100644 --- a/portable-simd/Cargo.toml +++ b/portable-simd/Cargo.toml @@ -5,3 +5,9 @@ members = [ "crates/std_float", "crates/test_helpers", ] + +[profile.test.package."*"] +opt-level = 2 + +[profile.test.package.test_helpers] +opt-level = 2 diff --git a/portable-simd/Cross.toml b/portable-simd/Cross.toml new file mode 100644 index 0000000000000..d21e76b92dd1a --- /dev/null +++ b/portable-simd/Cross.toml @@ -0,0 +1,2 @@ +[build.env] +passthrough = ["PROPTEST_CASES"] diff --git a/portable-simd/crates/core_simd/Cargo.toml b/portable-simd/crates/core_simd/Cargo.toml index b4a8fd70f4c0e..a7a6d43b11d3c 100644 --- a/portable-simd/crates/core_simd/Cargo.toml +++ b/portable-simd/crates/core_simd/Cargo.toml @@ -9,10 +9,9 @@ categories = ["hardware-support", "no-std"] license = "MIT OR Apache-2.0" [features] -default = ["as_crate"] +default = ["as_crate", "std"] as_crate = [] std = [] -all_lane_counts = [] [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen = "0.2" diff --git a/portable-simd/crates/core_simd/src/lane_count.rs b/portable-simd/crates/core_simd/src/lane_count.rs index 4cd7265ed671e..280b27bc9bc6f 100644 --- a/portable-simd/crates/core_simd/src/lane_count.rs +++ b/portable-simd/crates/core_simd/src/lane_count.rs @@ -33,10 +33,8 @@ macro_rules! supported_lane_count { }; } -supported_lane_count!(1, 2, 4, 8, 16, 32, 64); -#[cfg(feature = "all_lane_counts")] supported_lane_count!( - 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63 + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 ); diff --git a/portable-simd/crates/core_simd/src/lib.rs b/portable-simd/crates/core_simd/src/lib.rs index 992a7705e3c52..7f57847c9c234 100644 --- a/portable-simd/crates/core_simd/src/lib.rs +++ b/portable-simd/crates/core_simd/src/lib.rs @@ -1,7 +1,6 @@ #![no_std] #![feature( - const_refs_to_cell, - const_mut_refs, + const_eval_select, convert_float_to_int, core_intrinsics, decl_macro, @@ -26,6 +25,7 @@ all(target_arch = "arm", target_feature = "v7"), feature(stdarch_arm_neon_intrinsics) )] +#![cfg_attr(target_arch = "loongarch64", feature(stdarch_loongarch))] #![cfg_attr( any(target_arch = "powerpc", target_arch = "powerpc64"), feature(stdarch_powerpc) diff --git a/portable-simd/crates/core_simd/src/masks.rs b/portable-simd/crates/core_simd/src/masks.rs index 04de3a968276d..19d45f4d3b31a 100644 --- a/portable-simd/crates/core_simd/src/masks.rs +++ b/portable-simd/crates/core_simd/src/masks.rs @@ -308,48 +308,6 @@ where Self(mask_impl::Mask::from_bitmask_integer(bitmask)) } - /// Creates a bitmask vector from a mask. - /// - /// Each bit is set if the corresponding element in the mask is `true`. - /// The remaining bits are unset. - /// - /// The bits are packed into the first N bits of the vector: - /// ``` - /// # #![feature(portable_simd)] - /// # #[cfg(feature = "as_crate")] use core_simd::simd; - /// # #[cfg(not(feature = "as_crate"))] use core::simd; - /// # use simd::mask32x8; - /// let mask = mask32x8::from_array([true, false, true, false, false, false, true, false]); - /// assert_eq!(mask.to_bitmask_vector()[0], 0b01000101); - /// ``` - #[inline] - #[must_use = "method returns a new integer and does not mutate the original value"] - pub fn to_bitmask_vector(self) -> Simd { - self.0.to_bitmask_vector() - } - - /// Creates a mask from a bitmask vector. - /// - /// For each bit, if it is set, the corresponding element in the mask is set to `true`. - /// - /// The bits are packed into the first N bits of the vector: - /// ``` - /// # #![feature(portable_simd)] - /// # #[cfg(feature = "as_crate")] use core_simd::simd; - /// # #[cfg(not(feature = "as_crate"))] use core::simd; - /// # use simd::{mask32x8, u8x8}; - /// let bitmask = u8x8::from_array([0b01000101, 0, 0, 0, 0, 0, 0, 0]); - /// assert_eq!( - /// mask32x8::from_bitmask_vector(bitmask), - /// mask32x8::from_array([true, false, true, false, false, false, true, false]), - /// ); - /// ``` - #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] - pub fn from_bitmask_vector(bitmask: Simd) -> Self { - Self(mask_impl::Mask::from_bitmask_vector(bitmask)) - } - /// Finds the index of the first set element. /// /// ``` @@ -443,7 +401,6 @@ where LaneCount: SupportedLaneCount, { #[inline] - #[must_use = "method returns a defaulted mask with all elements set to false (0)"] fn default() -> Self { Self::splat(false) } @@ -455,7 +412,6 @@ where LaneCount: SupportedLaneCount, { #[inline] - #[must_use = "method returns a new bool and does not mutate the original value"] fn eq(&self, other: &Self) -> bool { self.0 == other.0 } @@ -467,7 +423,6 @@ where LaneCount: SupportedLaneCount, { #[inline] - #[must_use = "method returns a new Ordering and does not mutate the original value"] fn partial_cmp(&self, other: &Self) -> Option { self.0.partial_cmp(&other.0) } @@ -493,7 +448,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitand(self, rhs: Self) -> Self { Self(self.0 & rhs.0) } @@ -506,7 +460,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitand(self, rhs: bool) -> Self { self & Self::splat(rhs) } @@ -519,7 +472,6 @@ where { type Output = Mask; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitand(self, rhs: Mask) -> Mask { Mask::splat(self) & rhs } @@ -532,7 +484,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitor(self, rhs: Self) -> Self { Self(self.0 | rhs.0) } @@ -545,7 +496,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitor(self, rhs: bool) -> Self { self | Self::splat(rhs) } @@ -558,7 +508,6 @@ where { type Output = Mask; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitor(self, rhs: Mask) -> Mask { Mask::splat(self) | rhs } @@ -571,7 +520,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitxor(self, rhs: Self) -> Self::Output { Self(self.0 ^ rhs.0) } @@ -584,7 +532,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitxor(self, rhs: bool) -> Self::Output { self ^ Self::splat(rhs) } @@ -597,7 +544,6 @@ where { type Output = Mask; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitxor(self, rhs: Mask) -> Self::Output { Mask::splat(self) ^ rhs } @@ -610,7 +556,6 @@ where { type Output = Mask; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn not(self) -> Self::Output { Self(!self.0) } diff --git a/portable-simd/crates/core_simd/src/masks/bitmask.rs b/portable-simd/crates/core_simd/src/masks/bitmask.rs index 96c553426ee74..db4312d5bf88a 100644 --- a/portable-simd/crates/core_simd/src/masks/bitmask.rs +++ b/portable-simd/crates/core_simd/src/masks/bitmask.rs @@ -122,23 +122,6 @@ where unsafe { Self(core::intrinsics::simd::simd_bitmask(value), PhantomData) } } - #[inline] - #[must_use = "method returns a new vector and does not mutate the original value"] - pub fn to_bitmask_vector(self) -> Simd { - let mut bitmask = Simd::splat(0); - bitmask.as_mut_array()[..self.0.as_ref().len()].copy_from_slice(self.0.as_ref()); - bitmask - } - - #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] - pub fn from_bitmask_vector(bitmask: Simd) -> Self { - let mut bytes = as SupportedLaneCount>::BitMask::default(); - let len = bytes.as_ref().len(); - bytes.as_mut().copy_from_slice(&bitmask.as_array()[..len]); - Self(bytes, PhantomData) - } - #[inline] pub fn to_bitmask_integer(self) -> u64 { let mut bitmask = [0u8; 8]; diff --git a/portable-simd/crates/core_simd/src/masks/full_masks.rs b/portable-simd/crates/core_simd/src/masks/full_masks.rs index 87f031a9f367a..387b508c4b4ef 100644 --- a/portable-simd/crates/core_simd/src/masks/full_masks.rs +++ b/portable-simd/crates/core_simd/src/masks/full_masks.rs @@ -21,7 +21,6 @@ where LaneCount: SupportedLaneCount, { #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn clone(&self) -> Self { *self } @@ -140,62 +139,6 @@ where unsafe { Mask(core::intrinsics::simd::simd_cast(self.0)) } } - #[inline] - #[must_use = "method returns a new vector and does not mutate the original value"] - pub fn to_bitmask_vector(self) -> Simd { - let mut bitmask = Simd::splat(0); - - // Safety: Bytes is the right size array - unsafe { - // Compute the bitmask - let mut bytes: as SupportedLaneCount>::BitMask = - core::intrinsics::simd::simd_bitmask(self.0); - - // LLVM assumes bit order should match endianness - if cfg!(target_endian = "big") { - for x in bytes.as_mut() { - *x = x.reverse_bits() - } - if N % 8 > 0 { - bytes.as_mut()[N / 8] >>= 8 - N % 8; - } - } - - bitmask.as_mut_array()[..bytes.as_ref().len()].copy_from_slice(bytes.as_ref()); - } - - bitmask - } - - #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] - pub fn from_bitmask_vector(bitmask: Simd) -> Self { - let mut bytes = as SupportedLaneCount>::BitMask::default(); - - // Safety: Bytes is the right size array - unsafe { - let len = bytes.as_ref().len(); - bytes.as_mut().copy_from_slice(&bitmask.as_array()[..len]); - - // LLVM assumes bit order should match endianness - if cfg!(target_endian = "big") { - for x in bytes.as_mut() { - *x = x.reverse_bits(); - } - if N % 8 > 0 { - bytes.as_mut()[N / 8] >>= 8 - N % 8; - } - } - - // Compute the regular mask - Self::from_int_unchecked(core::intrinsics::simd::simd_select_bitmask( - bytes, - Self::splat(true).to_int(), - Self::splat(false).to_int(), - )) - } - } - #[inline] unsafe fn to_bitmask_impl(self) -> U where @@ -283,7 +226,7 @@ where } #[inline] - #[must_use = "method returns a new vector and does not mutate the original value"] + #[must_use = "method returns a new bool and does not mutate the original value"] pub fn all(self) -> bool { // Safety: use `self` as an integer vector unsafe { core::intrinsics::simd::simd_reduce_all(self.to_int()) } @@ -308,7 +251,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitand(self, rhs: Self) -> Self { // Safety: `self` is an integer vector unsafe { Self(core::intrinsics::simd::simd_and(self.0, rhs.0)) } @@ -322,7 +264,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitor(self, rhs: Self) -> Self { // Safety: `self` is an integer vector unsafe { Self(core::intrinsics::simd::simd_or(self.0, rhs.0)) } @@ -336,7 +277,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitxor(self, rhs: Self) -> Self { // Safety: `self` is an integer vector unsafe { Self(core::intrinsics::simd::simd_xor(self.0, rhs.0)) } @@ -350,7 +290,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn not(self) -> Self::Output { Self::splat(true) ^ self } diff --git a/portable-simd/crates/core_simd/src/ops.rs b/portable-simd/crates/core_simd/src/ops.rs index dd7303a97b197..4ac64a253a3bd 100644 --- a/portable-simd/crates/core_simd/src/ops.rs +++ b/portable-simd/crates/core_simd/src/ops.rs @@ -77,7 +77,7 @@ macro_rules! int_divrem_guard { ( $lhs:ident, $rhs:ident, { const PANIC_ZERO: &'static str = $zero:literal; - $simd_call:ident + $simd_call:ident, $op:tt }, $int:ident ) => { if $rhs.simd_eq(Simd::splat(0 as _)).any() { @@ -96,8 +96,23 @@ macro_rules! int_divrem_guard { // Nice base case to make it easy to const-fold away the other branch. $rhs }; - // Safety: $lhs and rhs are vectors - unsafe { core::intrinsics::simd::$simd_call($lhs, rhs) } + + // aarch64 div fails for arbitrary `v % 0`, mod fails when rhs is MIN, for non-powers-of-two + // these operations aren't vectorized on aarch64 anyway + #[cfg(target_arch = "aarch64")] + { + let mut out = Simd::splat(0 as _); + for i in 0..Self::LEN { + out[i] = $lhs[i] $op rhs[i]; + } + out + } + + #[cfg(not(target_arch = "aarch64"))] + { + // Safety: $lhs and rhs are vectors + unsafe { core::intrinsics::simd::$simd_call($lhs, rhs) } + } } }; } @@ -120,7 +135,6 @@ macro_rules! for_base_types { type Output = $out; #[inline] - #[must_use = "operator returns a new vector without mutating the inputs"] // TODO: only useful for int Div::div, but we hope that this // will essentially always get inlined anyway. #[track_caller] @@ -205,14 +219,14 @@ for_base_ops! { impl Div::div { int_divrem_guard { const PANIC_ZERO: &'static str = "attempt to divide by zero"; - simd_div + simd_div, / } } impl Rem::rem { int_divrem_guard { const PANIC_ZERO: &'static str = "attempt to calculate the remainder with a divisor of zero"; - simd_rem + simd_rem, % } } diff --git a/portable-simd/crates/core_simd/src/ops/deref.rs b/portable-simd/crates/core_simd/src/ops/deref.rs index 0ff76cfba39bb..913cbbe977c46 100644 --- a/portable-simd/crates/core_simd/src/ops/deref.rs +++ b/portable-simd/crates/core_simd/src/ops/deref.rs @@ -18,7 +18,6 @@ macro_rules! deref_lhs { type Output = Simd; #[inline] - #[must_use = "operator returns a new vector without mutating the inputs"] fn $call(self, rhs: $simd) -> Self::Output { (*self).$call(rhs) } @@ -39,7 +38,6 @@ macro_rules! deref_rhs { type Output = Simd; #[inline] - #[must_use = "operator returns a new vector without mutating the inputs"] fn $call(self, rhs: &$simd) -> Self::Output { self.$call(*rhs) } @@ -71,7 +69,6 @@ macro_rules! deref_ops { type Output = $simd; #[inline] - #[must_use = "operator returns a new vector without mutating the inputs"] fn $call(self, rhs: &'rhs $simd) -> Self::Output { (*self).$call(*rhs) } diff --git a/portable-simd/crates/core_simd/src/ops/unary.rs b/portable-simd/crates/core_simd/src/ops/unary.rs index bdae96332a3ae..412a5b801171b 100644 --- a/portable-simd/crates/core_simd/src/ops/unary.rs +++ b/portable-simd/crates/core_simd/src/ops/unary.rs @@ -11,7 +11,6 @@ macro_rules! neg { type Output = Self; #[inline] - #[must_use = "operator returns a new vector without mutating the input"] fn neg(self) -> Self::Output { // Safety: `self` is a signed vector unsafe { core::intrinsics::simd::simd_neg(self) } @@ -46,7 +45,6 @@ macro_rules! not { type Output = Self; #[inline] - #[must_use = "operator returns a new vector without mutating the input"] fn not(self) -> Self::Output { self ^ (Simd::splat(!(0 as $scalar))) } diff --git a/portable-simd/crates/core_simd/src/simd/cmp/eq.rs b/portable-simd/crates/core_simd/src/simd/cmp/eq.rs index 5b4615ce51d79..93989ce91b89d 100644 --- a/portable-simd/crates/core_simd/src/simd/cmp/eq.rs +++ b/portable-simd/crates/core_simd/src/simd/cmp/eq.rs @@ -12,7 +12,7 @@ pub trait SimdPartialEq { #[must_use = "method returns a new mask and does not mutate the original value"] fn simd_eq(self, other: Self) -> Self::Mask; - /// Test if each element is equal to the corresponding element in `other`. + /// Test if each element is not equal to the corresponding element in `other`. #[must_use = "method returns a new mask and does not mutate the original value"] fn simd_ne(self, other: Self) -> Self::Mask; } diff --git a/portable-simd/crates/core_simd/src/simd/num/float.rs b/portable-simd/crates/core_simd/src/simd/num/float.rs index 59e43851ea8da..db705dfe20221 100644 --- a/portable-simd/crates/core_simd/src/simd/num/float.rs +++ b/portable-simd/crates/core_simd/src/simd/num/float.rs @@ -255,6 +255,7 @@ macro_rules! impl_trait { type Bits = Simd<$bits_ty, N>; type Cast = Simd; + #[cfg(not(target_arch = "aarch64"))] #[inline] fn cast(self) -> Self::Cast { @@ -262,6 +263,33 @@ macro_rules! impl_trait { unsafe { core::intrinsics::simd::simd_as(self) } } + // https://github.com/llvm/llvm-project/issues/94694 + #[cfg(target_arch = "aarch64")] + #[inline] + fn cast(self) -> Self::Cast + { + const { assert!(N <= 64) }; + if N <= 2 || N == 4 || N == 8 || N == 16 || N == 32 || N == 64 { + // Safety: supported types are guaranteed by SimdCast + unsafe { core::intrinsics::simd::simd_as(self) } + } else if N < 4 { + let x = self.resize::<4>(Default::default()).cast(); + x.resize::(x[0]) + } else if N < 8 { + let x = self.resize::<8>(Default::default()).cast(); + x.resize::(x[0]) + } else if N < 16 { + let x = self.resize::<16>(Default::default()).cast(); + x.resize::(x[0]) + } else if N < 32 { + let x = self.resize::<32>(Default::default()).cast(); + x.resize::(x[0]) + } else { + let x = self.resize::<64>(Default::default()).cast(); + x.resize::(x[0]) + } + } + #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces unsafe fn to_int_unchecked(self) -> Self::Cast @@ -343,7 +371,6 @@ macro_rules! impl_trait { } #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn is_normal(self) -> Self::Mask { !(self.abs().simd_eq(Self::splat(0.0)) | self.is_nan() | self.is_subnormal() | self.is_infinite()) } @@ -391,7 +418,7 @@ macro_rules! impl_trait { self.as_array().iter().sum() } else { // Safety: `self` is a float vector - unsafe { core::intrinsics::simd::simd_reduce_add_ordered(self, 0.) } + unsafe { core::intrinsics::simd::simd_reduce_add_ordered(self, -0.) } } } diff --git a/portable-simd/crates/core_simd/src/simd/num/int.rs b/portable-simd/crates/core_simd/src/simd/num/int.rs index d7598d9ceaf92..3a51235ff954e 100644 --- a/portable-simd/crates/core_simd/src/simd/num/int.rs +++ b/portable-simd/crates/core_simd/src/simd/num/int.rs @@ -1,6 +1,6 @@ use super::sealed::Sealed; use crate::simd::{ - cmp::SimdPartialOrd, num::SimdUint, LaneCount, Mask, Simd, SimdCast, SimdElement, + cmp::SimdOrd, cmp::SimdPartialOrd, num::SimdUint, LaneCount, Mask, Simd, SimdCast, SimdElement, SupportedLaneCount, }; @@ -70,11 +70,27 @@ pub trait SimdInt: Copy + Sealed { /// # #[cfg(not(feature = "as_crate"))] use core::simd; /// # use simd::prelude::*; /// use core::i32::{MIN, MAX}; - /// let xs = Simd::from_array([MIN, MIN +1, -5, 0]); + /// let xs = Simd::from_array([MIN, MIN + 1, -5, 0]); /// assert_eq!(xs.abs(), Simd::from_array([MIN, MAX, 5, 0])); /// ``` fn abs(self) -> Self; + /// Lanewise absolute difference. + /// Every element becomes the absolute difference of `self` and `second`. + /// + /// # Examples + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::prelude::*; + /// use core::i32::{MIN, MAX}; + /// let a = Simd::from_array([MIN, MAX, 100, -100]); + /// let b = Simd::from_array([MAX, MIN, -80, -120]); + /// assert_eq!(a.abs_diff(b), Simd::from_array([u32::MAX, u32::MAX, 180, 20])); + /// ``` + fn abs_diff(self, second: Self) -> Self::Unsigned; + /// Lanewise saturating absolute value, implemented in Rust. /// As abs(), except the MIN value becomes MAX instead of itself. /// @@ -203,6 +219,12 @@ pub trait SimdInt: Copy + Sealed { /// The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc. fn reverse_bits(self) -> Self; + /// Returns the number of ones in the binary representation of each element. + fn count_ones(self) -> Self::Unsigned; + + /// Returns the number of zeros in the binary representation of each element. + fn count_zeros(self) -> Self::Unsigned; + /// Returns the number of leading zeros in the binary representation of each element. fn leading_zeros(self) -> Self::Unsigned; @@ -259,6 +281,13 @@ macro_rules! impl_trait { (self^m) - m } + #[inline] + fn abs_diff(self, second: Self) -> Self::Unsigned { + let max = self.simd_max(second); + let min = self.simd_min(second); + (max - min).cast() + } + #[inline] fn saturating_abs(self) -> Self { // arith shift for -1 or 0 mask based on sign bit, giving 2s complement @@ -344,6 +373,16 @@ macro_rules! impl_trait { unsafe { core::intrinsics::simd::simd_bitreverse(self) } } + #[inline] + fn count_ones(self) -> Self::Unsigned { + self.cast::<$unsigned>().count_ones() + } + + #[inline] + fn count_zeros(self) -> Self::Unsigned { + self.cast::<$unsigned>().count_zeros() + } + #[inline] fn leading_zeros(self) -> Self::Unsigned { self.cast::<$unsigned>().leading_zeros() diff --git a/portable-simd/crates/core_simd/src/simd/num/uint.rs b/portable-simd/crates/core_simd/src/simd/num/uint.rs index 53dd97f501c63..1ab2d8c7b7316 100644 --- a/portable-simd/crates/core_simd/src/simd/num/uint.rs +++ b/portable-simd/crates/core_simd/src/simd/num/uint.rs @@ -1,5 +1,5 @@ use super::sealed::Sealed; -use crate::simd::{LaneCount, Simd, SimdCast, SimdElement, SupportedLaneCount}; +use crate::simd::{cmp::SimdOrd, LaneCount, Simd, SimdCast, SimdElement, SupportedLaneCount}; /// Operations on SIMD vectors of unsigned integers. pub trait SimdUint: Copy + Sealed { @@ -57,6 +57,22 @@ pub trait SimdUint: Copy + Sealed { /// assert_eq!(sat, Simd::splat(0)); fn saturating_sub(self, second: Self) -> Self; + /// Lanewise absolute difference. + /// Every element becomes the absolute difference of `self` and `second`. + /// + /// # Examples + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::prelude::*; + /// use core::u32::MAX; + /// let a = Simd::from_array([0, MAX, 100, 20]); + /// let b = Simd::from_array([MAX, 0, 80, 200]); + /// assert_eq!(a.abs_diff(b), Simd::from_array([MAX, MAX, 20, 180])); + /// ``` + fn abs_diff(self, second: Self) -> Self; + /// Returns the sum of the elements of the vector, with wrapping addition. fn reduce_sum(self) -> Self::Scalar; @@ -85,6 +101,12 @@ pub trait SimdUint: Copy + Sealed { /// The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc. fn reverse_bits(self) -> Self; + /// Returns the number of ones in the binary representation of each element. + fn count_ones(self) -> Self; + + /// Returns the number of zeros in the binary representation of each element. + fn count_zeros(self) -> Self; + /// Returns the number of leading zeros in the binary representation of each element. fn leading_zeros(self) -> Self; @@ -138,6 +160,13 @@ macro_rules! impl_trait { unsafe { core::intrinsics::simd::simd_saturating_sub(self, second) } } + #[inline] + fn abs_diff(self, second: Self) -> Self { + let max = self.simd_max(second); + let min = self.simd_min(second); + max - min + } + #[inline] fn reduce_sum(self) -> Self::Scalar { // Safety: `self` is an integer vector @@ -192,6 +221,17 @@ macro_rules! impl_trait { unsafe { core::intrinsics::simd::simd_bitreverse(self) } } + #[inline] + fn count_ones(self) -> Self { + // Safety: `self` is an integer vector + unsafe { core::intrinsics::simd::simd_ctpop(self) } + } + + #[inline] + fn count_zeros(self) -> Self { + (!self).count_ones() + } + #[inline] fn leading_zeros(self) -> Self { // Safety: `self` is an integer vector diff --git a/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs b/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs index be635ea640b86..47383809ffbae 100644 --- a/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs +++ b/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs @@ -42,6 +42,19 @@ pub trait SimdConstPtr: Copy + Sealed { /// Equivalent to calling [`pointer::addr`] on each element. fn addr(self) -> Self::Usize; + /// Converts an address to a pointer without giving it any provenance. + /// + /// Without provenance, this pointer is not associated with any actual allocation. Such a + /// no-provenance pointer may be used for zero-sized memory accesses (if suitably aligned), but + /// non-zero-sized memory accesses with a no-provenance pointer are UB. No-provenance pointers + /// are little more than a usize address in disguise. + /// + /// This is different from [`Self::with_exposed_provenance`], which creates a pointer that picks up a + /// previously exposed provenance. + /// + /// Equivalent to calling [`core::ptr::without_provenance`] on each element. + fn without_provenance(addr: Self::Usize) -> Self; + /// Creates a new pointer with the given address. /// /// This performs the same operation as a cast, but copies the *address-space* and @@ -118,6 +131,14 @@ where unsafe { core::mem::transmute_copy(&self) } } + #[inline] + fn without_provenance(addr: Self::Usize) -> Self { + // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. + // SAFETY: Integer-to-pointer transmutes are valid (if you are okay with not getting any + // provenance). + unsafe { core::mem::transmute_copy(&addr) } + } + #[inline] fn with_addr(self, addr: Self::Usize) -> Self { // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. diff --git a/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs b/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs index f6823a949e32a..3f20eef21a312 100644 --- a/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs +++ b/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs @@ -39,6 +39,19 @@ pub trait SimdMutPtr: Copy + Sealed { /// Equivalent to calling [`pointer::addr`] on each element. fn addr(self) -> Self::Usize; + /// Converts an address to a pointer without giving it any provenance. + /// + /// Without provenance, this pointer is not associated with any actual allocation. Such a + /// no-provenance pointer may be used for zero-sized memory accesses (if suitably aligned), but + /// non-zero-sized memory accesses with a no-provenance pointer are UB. No-provenance pointers + /// are little more than a usize address in disguise. + /// + /// This is different from [`Self::with_exposed_provenance`], which creates a pointer that picks up a + /// previously exposed provenance. + /// + /// Equivalent to calling [`core::ptr::without_provenance`] on each element. + fn without_provenance(addr: Self::Usize) -> Self; + /// Creates a new pointer with the given address. /// /// This performs the same operation as a cast, but copies the *address-space* and @@ -115,6 +128,14 @@ where unsafe { core::mem::transmute_copy(&self) } } + #[inline] + fn without_provenance(addr: Self::Usize) -> Self { + // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. + // SAFETY: Integer-to-pointer transmutes are valid (if you are okay with not getting any + // provenance). + unsafe { core::mem::transmute_copy(&addr) } + } + #[inline] fn with_addr(self, addr: Self::Usize) -> Self { // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. diff --git a/portable-simd/crates/core_simd/src/swizzle.rs b/portable-simd/crates/core_simd/src/swizzle.rs index d62642fb9061b..42425ef37e50b 100644 --- a/portable-simd/crates/core_simd/src/swizzle.rs +++ b/portable-simd/crates/core_simd/src/swizzle.rs @@ -155,8 +155,7 @@ pub trait Swizzle { /// Creates a new mask from the elements of `mask`. /// - /// Element `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of - /// `first` and `second`. + /// Element `i` of the output is `mask[Self::INDEX[i]]`. #[inline] #[must_use = "method returns a new mask and does not mutate the original inputs"] fn swizzle_mask(mask: Mask) -> Mask @@ -260,6 +259,50 @@ where Rotate::::swizzle(self) } + /// Shifts the vector elements to the left by `OFFSET`, filling in with + /// `padding` from the right. + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn shift_elements_left(self, padding: T) -> Self { + struct Shift; + + impl Swizzle for Shift { + const INDEX: [usize; N] = const { + let mut index = [N; N]; + let mut i = 0; + while i + OFFSET < N { + index[i] = i + OFFSET; + i += 1; + } + index + }; + } + + Shift::::concat_swizzle(self, Simd::splat(padding)) + } + + /// Shifts the vector elements to the right by `OFFSET`, filling in with + /// `padding` from the left. + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn shift_elements_right(self, padding: T) -> Self { + struct Shift; + + impl Swizzle for Shift { + const INDEX: [usize; N] = const { + let mut index = [N; N]; + let mut i = OFFSET; + while i < N { + index[i] = i - OFFSET; + i += 1; + } + index + }; + } + + Shift::::concat_swizzle(self, Simd::splat(padding)) + } + /// Interleave two vectors. /// /// The resulting vectors contain elements taken alternatively from `self` and `other`, first @@ -320,7 +363,9 @@ where /// /// ``` /// # #![feature(portable_simd)] - /// # use core::simd::Simd; + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::Simd; /// let a = Simd::from_array([0, 4, 1, 5]); /// let b = Simd::from_array([2, 6, 3, 7]); /// let (x, y) = a.deinterleave(b); @@ -391,4 +436,210 @@ where } Resize::::concat_swizzle(self, Simd::splat(value)) } + + /// Extract a vector from another vector. + /// + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::u32x4; + /// let x = u32x4::from_array([0, 1, 2, 3]); + /// assert_eq!(x.extract::<1, 2>().to_array(), [1, 2]); + /// ``` + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn extract(self) -> Simd + where + LaneCount: SupportedLaneCount, + { + struct Extract; + impl Swizzle for Extract { + const INDEX: [usize; LEN] = const { + assert!(START + LEN <= N, "index out of bounds"); + let mut index = [0; LEN]; + let mut i = 0; + while i < LEN { + index[i] = START + i; + i += 1; + } + index + }; + } + Extract::::swizzle(self) + } +} + +impl Mask +where + T: MaskElement, + LaneCount: SupportedLaneCount, +{ + /// Reverse the order of the elements in the mask. + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn reverse(self) -> Self { + // Safety: swizzles are safe for masks + unsafe { Self::from_int_unchecked(self.to_int().reverse()) } + } + + /// Rotates the mask such that the first `OFFSET` elements of the slice move to the end + /// while the last `self.len() - OFFSET` elements move to the front. After calling `rotate_elements_left`, + /// the element previously at index `OFFSET` will become the first element in the slice. + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn rotate_elements_left(self) -> Self { + // Safety: swizzles are safe for masks + unsafe { Self::from_int_unchecked(self.to_int().rotate_elements_left::()) } + } + + /// Rotates the mask such that the first `self.len() - OFFSET` elements of the mask move to + /// the end while the last `OFFSET` elements move to the front. After calling `rotate_elements_right`, + /// the element previously at index `self.len() - OFFSET` will become the first element in the slice. + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn rotate_elements_right(self) -> Self { + // Safety: swizzles are safe for masks + unsafe { Self::from_int_unchecked(self.to_int().rotate_elements_right::()) } + } + + /// Shifts the mask elements to the left by `OFFSET`, filling in with + /// `padding` from the right. + #[inline] + #[must_use = "method returns a new mask and does not mutate the original inputs"] + pub fn shift_elements_left(self, padding: bool) -> Self { + // Safety: swizzles are safe for masks + unsafe { + Self::from_int_unchecked(self.to_int().shift_elements_left::(if padding { + T::TRUE + } else { + T::FALSE + })) + } + } + + /// Shifts the mask elements to the right by `OFFSET`, filling in with + /// `padding` from the left. + #[inline] + #[must_use = "method returns a new mask and does not mutate the original inputs"] + pub fn shift_elements_right(self, padding: bool) -> Self { + // Safety: swizzles are safe for masks + unsafe { + Self::from_int_unchecked(self.to_int().shift_elements_right::(if padding { + T::TRUE + } else { + T::FALSE + })) + } + } + + /// Interleave two masks. + /// + /// The resulting masks contain elements taken alternatively from `self` and `other`, first + /// filling the first result, and then the second. + /// + /// The reverse of this operation is [`Mask::deinterleave`]. + /// + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::mask32x4; + /// let a = mask32x4::from_array([false, true, false, true]); + /// let b = mask32x4::from_array([false, false, true, true]); + /// let (x, y) = a.interleave(b); + /// assert_eq!(x.to_array(), [false, false, true, false]); + /// assert_eq!(y.to_array(), [false, true, true, true]); + /// ``` + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn interleave(self, other: Self) -> (Self, Self) { + let (lo, hi) = self.to_int().interleave(other.to_int()); + // Safety: swizzles are safe for masks + unsafe { (Self::from_int_unchecked(lo), Self::from_int_unchecked(hi)) } + } + + /// Deinterleave two masks. + /// + /// The first result takes every other element of `self` and then `other`, starting with + /// the first element. + /// + /// The second result takes every other element of `self` and then `other`, starting with + /// the second element. + /// + /// The reverse of this operation is [`Mask::interleave`]. + /// + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::mask32x4; + /// let a = mask32x4::from_array([false, true, false, true]); + /// let b = mask32x4::from_array([false, false, true, true]); + /// let (x, y) = a.deinterleave(b); + /// assert_eq!(x.to_array(), [false, false, false, true]); + /// assert_eq!(y.to_array(), [true, true, false, true]); + /// ``` + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn deinterleave(self, other: Self) -> (Self, Self) { + let (even, odd) = self.to_int().deinterleave(other.to_int()); + // Safety: swizzles are safe for masks + unsafe { + ( + Self::from_int_unchecked(even), + Self::from_int_unchecked(odd), + ) + } + } + + /// Resize a mask. + /// + /// If `M` > `N`, extends the length of a mask, setting the new elements to `value`. + /// If `M` < `N`, truncates the mask to the first `M` elements. + /// + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::mask32x4; + /// let x = mask32x4::from_array([false, true, true, false]); + /// assert_eq!(x.resize::<8>(true).to_array(), [false, true, true, false, true, true, true, true]); + /// assert_eq!(x.resize::<2>(true).to_array(), [false, true]); + /// ``` + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn resize(self, value: bool) -> Mask + where + LaneCount: SupportedLaneCount, + { + // Safety: swizzles are safe for masks + unsafe { + Mask::::from_int_unchecked(self.to_int().resize::(if value { + T::TRUE + } else { + T::FALSE + })) + } + } + + /// Extract a vector from another vector. + /// + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::mask32x4; + /// let x = mask32x4::from_array([false, true, true, false]); + /// assert_eq!(x.extract::<1, 2>().to_array(), [true, true]); + /// ``` + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn extract(self) -> Mask + where + LaneCount: SupportedLaneCount, + { + // Safety: swizzles are safe for masks + unsafe { Mask::::from_int_unchecked(self.to_int().extract::()) } + } } diff --git a/portable-simd/crates/core_simd/src/swizzle_dyn.rs b/portable-simd/crates/core_simd/src/swizzle_dyn.rs index 3b6388d0f2759..773bd028bae09 100644 --- a/portable-simd/crates/core_simd/src/swizzle_dyn.rs +++ b/portable-simd/crates/core_simd/src/swizzle_dyn.rs @@ -59,15 +59,40 @@ where target_endian = "little" ))] 16 => transize(vqtbl1q_u8, self, idxs), + #[cfg(all( + target_arch = "arm", + target_feature = "v7", + target_feature = "neon", + target_endian = "little" + ))] + 16 => transize(armv7_neon_swizzle_u8x16, self, idxs), #[cfg(all(target_feature = "avx2", not(target_feature = "avx512vbmi")))] 32 => transize(avx2_pshufb, self, idxs), #[cfg(all(target_feature = "avx512vl", target_feature = "avx512vbmi"))] - 32 => transize(x86::_mm256_permutexvar_epi8, zeroing_idxs(idxs), self), - // Notable absence: avx512bw shuffle - // If avx512bw is available, odds of avx512vbmi are good - // FIXME: initial AVX512VBMI variant didn't actually pass muster - // #[cfg(target_feature = "avx512vbmi")] - // 64 => transize(x86::_mm512_permutexvar_epi8, self, idxs), + 32 => { + // Unlike vpshufb, vpermb doesn't zero out values in the result based on the index high bit + let swizzler = |bytes, idxs| { + let mask = x86::_mm256_cmp_epu8_mask::<{ x86::_MM_CMPINT_LT }>( + idxs, + Simd::::splat(N as u8).into(), + ); + x86::_mm256_maskz_permutexvar_epi8(mask, idxs, bytes) + }; + transize(swizzler, self, idxs) + } + // Notable absence: avx512bw pshufb shuffle + #[cfg(all(target_feature = "avx512vl", target_feature = "avx512vbmi"))] + 64 => { + // Unlike vpshufb, vpermb doesn't zero out values in the result based on the index high bit + let swizzler = |bytes, idxs| { + let mask = x86::_mm512_cmp_epu8_mask::<{ x86::_MM_CMPINT_LT }>( + idxs, + Simd::::splat(N as u8).into(), + ); + x86::_mm512_maskz_permutexvar_epi8(mask, idxs, bytes) + }; + transize(swizzler, self, idxs) + } _ => { let mut array = [0; N]; for (i, k) in idxs.to_array().into_iter().enumerate() { @@ -82,6 +107,28 @@ where } } +/// armv7 neon supports swizzling `u8x16` by swizzling two u8x8 blocks +/// with a u8x8x2 lookup table. +/// +/// # Safety +/// This requires armv7 neon to work +#[cfg(all( + target_arch = "arm", + target_feature = "v7", + target_feature = "neon", + target_endian = "little" +))] +unsafe fn armv7_neon_swizzle_u8x16(bytes: Simd, idxs: Simd) -> Simd { + use core::arch::arm::{uint8x8x2_t, vcombine_u8, vget_high_u8, vget_low_u8, vtbl2_u8}; + // SAFETY: Caller promised arm neon support + unsafe { + let bytes = uint8x8x2_t(vget_low_u8(bytes.into()), vget_high_u8(bytes.into())); + let lo = vtbl2_u8(bytes, vget_low_u8(idxs.into())); + let hi = vtbl2_u8(bytes, vget_high_u8(idxs.into())); + vcombine_u8(lo, hi).into() + } +} + /// "vpshufb like it was meant to be" on AVX2 /// /// # Safety diff --git a/portable-simd/crates/core_simd/src/vector.rs b/portable-simd/crates/core_simd/src/vector.rs index 3e23916914963..9c4dd36c24fe8 100644 --- a/portable-simd/crates/core_simd/src/vector.rs +++ b/portable-simd/crates/core_simd/src/vector.rs @@ -99,7 +99,7 @@ use crate::simd::{ // directly constructing an instance of the type (i.e. `let vector = Simd(array)`) should be // avoided, as it will likely become illegal on `#[repr(simd)]` structs in the future. It also // causes rustc to emit illegal LLVM IR in some cases. -#[repr(simd)] +#[repr(simd, packed)] pub struct Simd([T; N]) where LaneCount: SupportedLaneCount, @@ -144,14 +144,32 @@ where /// assert_eq!(v.as_array(), &[8, 8, 8, 8]); /// ``` #[inline] - pub fn splat(value: T) -> Self { - // This is preferred over `[value; N]`, since it's explicitly a splat: - // https://github.com/rust-lang/rust/issues/97804 - struct Splat; - impl Swizzle for Splat { - const INDEX: [usize; N] = [0; N]; + #[rustc_const_unstable(feature = "portable_simd", issue = "86656")] + pub const fn splat(value: T) -> Self { + const fn splat_const(value: T) -> Simd + where + T: SimdElement, + LaneCount: SupportedLaneCount, + { + Simd::from_array([value; N]) } - Splat::swizzle::(Simd::::from([value])) + + fn splat_rt(value: T) -> Simd + where + T: SimdElement, + LaneCount: SupportedLaneCount, + { + // This is preferred over `[value; N]`, since it's explicitly a splat: + // https://github.com/rust-lang/rust/issues/97804 + struct Splat; + impl Swizzle for Splat { + const INDEX: [usize; N] = [0; N]; + } + + Splat::swizzle::(Simd::::from([value])) + } + + core::intrinsics::const_eval_select((value,), splat_const, splat_rt) } /// Returns an array reference containing the entire SIMD vector. @@ -425,6 +443,9 @@ where /// /// When the element is disabled, that memory location is not accessed and the corresponding /// value from `or` is passed through. + /// + /// # Safety + /// Enabled loads must not exceed the length of `slice`. #[must_use] #[inline] pub unsafe fn load_select_unchecked( @@ -442,6 +463,9 @@ where /// /// When the element is disabled, that memory location is not accessed and the corresponding /// value from `or` is passed through. + /// + /// # Safety + /// Enabled `ptr` elements must be safe to read as if by `std::ptr::read`. #[must_use] #[inline] pub unsafe fn load_select_ptr( @@ -924,6 +948,7 @@ where } } +/// Lexicographic order. For the SIMD elementwise minimum and maximum, use simd_min and simd_max instead. impl PartialOrd for Simd where LaneCount: SupportedLaneCount, @@ -943,6 +968,7 @@ where { } +/// Lexicographic order. For the SIMD elementwise minimum and maximum, use simd_min and simd_max instead. impl Ord for Simd where LaneCount: SupportedLaneCount, @@ -1195,6 +1221,7 @@ fn lane_indices() -> Simd where LaneCount: SupportedLaneCount, { + #![allow(clippy::needless_range_loop)] let mut index = [0; N]; for i in 0..N { index[i] = i; diff --git a/portable-simd/crates/core_simd/src/vendor.rs b/portable-simd/crates/core_simd/src/vendor.rs index 1a34a3a8de5c4..57536e4fc77dc 100644 --- a/portable-simd/crates/core_simd/src/vendor.rs +++ b/portable-simd/crates/core_simd/src/vendor.rs @@ -29,3 +29,6 @@ mod arm; #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] mod powerpc; + +#[cfg(target_arch = "loongarch64")] +mod loongarch64; diff --git a/portable-simd/crates/core_simd/src/vendor/arm.rs b/portable-simd/crates/core_simd/src/vendor/arm.rs index f8878d11f094d..3dc54481b6fd4 100644 --- a/portable-simd/crates/core_simd/src/vendor/arm.rs +++ b/portable-simd/crates/core_simd/src/vendor/arm.rs @@ -48,17 +48,6 @@ mod neon { from_transmute! { unsafe u64x2 => poly64x2_t } } -#[cfg(any( - all(target_feature = "v5te", not(target_feature = "mclass")), - all(target_feature = "mclass", target_feature = "dsp"), -))] -mod dsp { - use super::*; - - from_transmute! { unsafe Simd => uint16x2_t } - from_transmute! { unsafe Simd => int16x2_t } -} - #[cfg(any( all(target_feature = "v6", not(target_feature = "mclass")), all(target_feature = "mclass", target_feature = "dsp"), @@ -68,6 +57,8 @@ mod simd32 { from_transmute! { unsafe Simd => uint8x4_t } from_transmute! { unsafe Simd => int8x4_t } + from_transmute! { unsafe Simd => uint16x2_t } + from_transmute! { unsafe Simd => int16x2_t } } #[cfg(all( diff --git a/portable-simd/crates/core_simd/src/vendor/loongarch64.rs b/portable-simd/crates/core_simd/src/vendor/loongarch64.rs new file mode 100644 index 0000000000000..1290bc166b2b8 --- /dev/null +++ b/portable-simd/crates/core_simd/src/vendor/loongarch64.rs @@ -0,0 +1,31 @@ +use crate::simd::*; +use core::arch::loongarch64::*; + +from_transmute! { unsafe u8x16 => v16u8 } +from_transmute! { unsafe u8x32 => v32u8 } +from_transmute! { unsafe i8x16 => v16i8 } +from_transmute! { unsafe i8x32 => v32i8 } + +from_transmute! { unsafe u16x8 => v8u16 } +from_transmute! { unsafe u16x16 => v16u16 } +from_transmute! { unsafe i16x8 => v8i16 } +from_transmute! { unsafe i16x16 => v16i16 } + +from_transmute! { unsafe u32x4 => v4u32 } +from_transmute! { unsafe u32x8 => v8u32 } +from_transmute! { unsafe i32x4 => v4i32 } +from_transmute! { unsafe i32x8 => v8i32 } +from_transmute! { unsafe f32x4 => v4f32 } +from_transmute! { unsafe f32x8 => v8f32 } + +from_transmute! { unsafe u64x2 => v2u64 } +from_transmute! { unsafe u64x4 => v4u64 } +from_transmute! { unsafe i64x2 => v2i64 } +from_transmute! { unsafe i64x4 => v4i64 } +from_transmute! { unsafe f64x2 => v2f64 } +from_transmute! { unsafe f64x4 => v4f64 } + +from_transmute! { unsafe usizex2 => v2u64 } +from_transmute! { unsafe usizex4 => v4u64 } +from_transmute! { unsafe isizex2 => v2i64 } +from_transmute! { unsafe isizex4 => v4i64 } diff --git a/portable-simd/crates/core_simd/tests/layout.rs b/portable-simd/crates/core_simd/tests/layout.rs new file mode 100644 index 0000000000000..24114c2d261e7 --- /dev/null +++ b/portable-simd/crates/core_simd/tests/layout.rs @@ -0,0 +1,35 @@ +#![feature(portable_simd)] + +macro_rules! layout_tests { + { $($mod:ident, $ty:ty,)* } => { + $( + mod $mod { + test_helpers::test_lanes! { + fn no_padding() { + assert_eq!( + core::mem::size_of::>(), + core::mem::size_of::<[$ty; LANES]>(), + ); + } + } + } + )* + } +} + +layout_tests! { + i8, i8, + i16, i16, + i32, i32, + i64, i64, + isize, isize, + u8, u8, + u16, u16, + u32, u32, + u64, u64, + usize, usize, + f32, f32, + f64, f64, + mut_ptr, *mut (), + const_ptr, *const (), +} diff --git a/portable-simd/crates/core_simd/tests/masks.rs b/portable-simd/crates/core_simd/tests/masks.rs index fc6a3476b7c60..48786d02440b3 100644 --- a/portable-simd/crates/core_simd/tests/masks.rs +++ b/portable-simd/crates/core_simd/tests/masks.rs @@ -99,7 +99,6 @@ macro_rules! test_mask_api { assert_eq!(Mask::<$type, 2>::from_bitmask(bitmask), mask); } - #[cfg(feature = "all_lane_counts")] #[test] fn roundtrip_bitmask_conversion_odd() { let values = [ @@ -134,48 +133,6 @@ macro_rules! test_mask_api { cast_impl::(); cast_impl::(); } - - #[test] - fn roundtrip_bitmask_vector_conversion() { - use core_simd::simd::ToBytes; - let values = [ - true, false, false, true, false, false, true, false, - true, true, false, false, false, false, false, true, - ]; - let mask = Mask::<$type, 16>::from_array(values); - let bitmask = mask.to_bitmask_vector(); - assert_eq!(bitmask.resize::<2>(0).to_ne_bytes()[..2], [0b01001001, 0b10000011]); - assert_eq!(Mask::<$type, 16>::from_bitmask_vector(bitmask), mask); - } - - // rust-lang/portable-simd#379 - #[test] - fn roundtrip_bitmask_vector_conversion_small() { - use core_simd::simd::ToBytes; - let values = [ - true, false, true, true - ]; - let mask = Mask::<$type, 4>::from_array(values); - let bitmask = mask.to_bitmask_vector(); - assert_eq!(bitmask.resize::<1>(0).to_ne_bytes()[0], 0b00001101); - assert_eq!(Mask::<$type, 4>::from_bitmask_vector(bitmask), mask); - } - - /* FIXME doesn't work with non-powers-of-two, yet - // rust-lang/portable-simd#379 - #[cfg(feature = "all_lane_counts")] - #[test] - fn roundtrip_bitmask_vector_conversion_odd() { - use core_simd::simd::ToBytes; - let values = [ - true, false, true, false, true, true, false, false, false, true, true, - ]; - let mask = Mask::<$type, 11>::from_array(values); - let bitmask = mask.to_bitmask_vector(); - assert_eq!(bitmask.resize::<2>(0).to_ne_bytes()[..2], [0b00110101, 0b00000110]); - assert_eq!(Mask::<$type, 11>::from_bitmask_vector(bitmask), mask); - } - */ } } } diff --git a/portable-simd/crates/core_simd/tests/ops_macros.rs b/portable-simd/crates/core_simd/tests/ops_macros.rs index aa565a137527e..6de78f51e59df 100644 --- a/portable-simd/crates/core_simd/tests/ops_macros.rs +++ b/portable-simd/crates/core_simd/tests/ops_macros.rs @@ -216,6 +216,22 @@ macro_rules! impl_common_integer_tests { ) } + fn count_ones() { + test_helpers::test_unary_elementwise( + &$vector::::count_ones, + &|x| x.count_ones() as _, + &|_| true, + ) + } + + fn count_zeros() { + test_helpers::test_unary_elementwise( + &$vector::::count_zeros, + &|x| x.count_zeros() as _, + &|_| true, + ) + } + fn leading_zeros() { test_helpers::test_unary_elementwise( &$vector::::leading_zeros, @@ -307,6 +323,14 @@ macro_rules! impl_signed_tests { assert_eq!(a % b, Vector::::splat(0)); } + fn abs_diff() { + test_helpers::test_binary_elementwise( + &Vector::::abs_diff, + &Scalar::abs_diff, + &|_, _| true, + ) + } + fn simd_min() { use core_simd::simd::cmp::SimdOrd; let a = Vector::::splat(Scalar::MIN); @@ -419,6 +443,14 @@ macro_rules! impl_unsigned_tests { &|_| true, ); } + + fn abs_diff() { + test_helpers::test_binary_elementwise( + &Vector::::abs_diff, + &Scalar::abs_diff, + &|_, _| true, + ) + } } impl_binary_op_test!(Scalar, Add::add, AddAssign::add_assign, Scalar::wrapping_add); @@ -495,6 +527,9 @@ macro_rules! impl_float_tests { } fn is_normal() { + // Arm v7 Neon violates float opsem re: subnormals, see + // https://github.com/rust-lang/portable-simd/issues/439 + #[cfg(not(target_arch = "arm"))] test_helpers::test_unary_mask_elementwise( &Vector::::is_normal, &Scalar::is_normal, @@ -503,6 +538,9 @@ macro_rules! impl_float_tests { } fn is_subnormal() { + // Arm v7 Neon violates float opsem re: subnormals, see + // https://github.com/rust-lang/portable-simd/issues/439 + #[cfg(not(target_arch = "arm"))] test_helpers::test_unary_mask_elementwise( &Vector::::is_subnormal, &Scalar::is_subnormal, diff --git a/portable-simd/crates/core_simd/tests/swizzle.rs b/portable-simd/crates/core_simd/tests/swizzle.rs index 522d71439b77d..7001e5f6bf87b 100644 --- a/portable-simd/crates/core_simd/tests/swizzle.rs +++ b/portable-simd/crates/core_simd/tests/swizzle.rs @@ -48,6 +48,24 @@ fn rotate() { assert_eq!(a.rotate_elements_right::<5>().to_array(), [4, 1, 2, 3]); } +#[test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +fn shift() { + let a = Simd::from_array([1, 2, 3, 4]); + assert_eq!(a.shift_elements_left::<0>(0).to_array(), [1, 2, 3, 4]); + assert_eq!(a.shift_elements_left::<1>(0).to_array(), [2, 3, 4, 0]); + assert_eq!(a.shift_elements_left::<2>(9).to_array(), [3, 4, 9, 9]); + assert_eq!(a.shift_elements_left::<3>(8).to_array(), [4, 8, 8, 8]); + assert_eq!(a.shift_elements_left::<4>(7).to_array(), [7, 7, 7, 7]); + assert_eq!(a.shift_elements_left::<5>(6).to_array(), [6, 6, 6, 6]); + assert_eq!(a.shift_elements_right::<0>(0).to_array(), [1, 2, 3, 4]); + assert_eq!(a.shift_elements_right::<1>(0).to_array(), [0, 1, 2, 3]); + assert_eq!(a.shift_elements_right::<2>(-1).to_array(), [-1, -1, 1, 2]); + assert_eq!(a.shift_elements_right::<3>(-2).to_array(), [-2, -2, -2, 1]); + assert_eq!(a.shift_elements_right::<4>(-3).to_array(), [-3, -3, -3, -3]); + assert_eq!(a.shift_elements_right::<5>(-4).to_array(), [-4, -4, -4, -4]); +} + #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn interleave() { diff --git a/portable-simd/crates/test_helpers/Cargo.toml b/portable-simd/crates/test_helpers/Cargo.toml index 23dae7c93381e..a5359b9abc84d 100644 --- a/portable-simd/crates/test_helpers/Cargo.toml +++ b/portable-simd/crates/test_helpers/Cargo.toml @@ -6,6 +6,3 @@ publish = false [dependencies] proptest = { version = "0.10", default-features = false, features = ["alloc"] } - -[features] -all_lane_counts = [] diff --git a/portable-simd/crates/test_helpers/src/lib.rs b/portable-simd/crates/test_helpers/src/lib.rs index 51b860a863560..197c920e11eac 100644 --- a/portable-simd/crates/test_helpers/src/lib.rs +++ b/portable-simd/crates/test_helpers/src/lib.rs @@ -539,32 +539,22 @@ macro_rules! test_lanes { #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]; lanes_1 1; lanes_2 2; - lanes_4 4; - ); - - #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow - $crate::test_lanes_helper!( - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]; - lanes_8 8; - lanes_16 16; - lanes_32 32; - lanes_64 64; - ); - - #[cfg(feature = "all_lane_counts")] - $crate::test_lanes_helper!( - // test some odd and even non-power-of-2 lengths on miri - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]; + // Cover an odd and an even non-power-of-2 length in Miri. + // (Even non-power-of-2 vectors have alignment between element + // and vector size, so we want to cover that case as well.) lanes_3 3; - lanes_5 5; + lanes_6 6; ); - #[cfg(feature = "all_lane_counts")] #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow $crate::test_lanes_helper!( #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]; + lanes_4 4; + lanes_5 5; + lanes_7 7; + lanes_8 8; lanes_9 9; lanes_10 10; lanes_11 11; @@ -572,52 +562,55 @@ macro_rules! test_lanes { lanes_13 13; lanes_14 14; lanes_15 15; + lanes_16 16; lanes_17 17; - lanes_18 18; - lanes_19 19; - lanes_20 20; - lanes_21 21; - lanes_22 22; - lanes_23 23; + //lanes_18 18; + //lanes_19 19; + //lanes_20 20; + //lanes_21 21; + //lanes_22 22; + //lanes_23 23; lanes_24 24; - lanes_25 25; - lanes_26 26; - lanes_27 27; - lanes_28 28; - lanes_29 29; - lanes_30 30; - lanes_31 31; - lanes_33 33; - lanes_34 34; - lanes_35 35; - lanes_36 36; - lanes_37 37; - lanes_38 38; - lanes_39 39; - lanes_40 40; - lanes_41 41; - lanes_42 42; - lanes_43 43; - lanes_44 44; - lanes_45 45; - lanes_46 46; + //lanes_25 25; + //lanes_26 26; + //lanes_27 27; + //lanes_28 28; + //lanes_29 29; + //lanes_30 30; + //lanes_31 31; + lanes_32 32; + //lanes_33 33; + //lanes_34 34; + //lanes_35 35; + //lanes_36 36; + //lanes_37 37; + //lanes_38 38; + //lanes_39 39; + //lanes_40 40; + //lanes_41 41; + //lanes_42 42; + //lanes_43 43; + //lanes_44 44; + //lanes_45 45; + //lanes_46 46; lanes_47 47; - lanes_48 48; - lanes_49 49; - lanes_50 50; - lanes_51 51; - lanes_52 52; - lanes_53 53; - lanes_54 54; - lanes_55 55; + //lanes_48 48; + //lanes_49 49; + //lanes_50 50; + //lanes_51 51; + //lanes_52 52; + //lanes_53 53; + //lanes_54 54; + //lanes_55 55; lanes_56 56; lanes_57 57; - lanes_58 58; - lanes_59 59; - lanes_60 60; - lanes_61 61; - lanes_62 62; + //lanes_58 58; + //lanes_59 59; + //lanes_60 60; + //lanes_61 61; + //lanes_62 62; lanes_63 63; + lanes_64 64; ); } )* @@ -639,36 +632,24 @@ macro_rules! test_lanes_panic { core_simd::simd::LaneCount<$lanes>: core_simd::simd::SupportedLaneCount, $body + // test some odd and even non-power-of-2 lengths on miri $crate::test_lanes_helper!( #[should_panic]; lanes_1 1; lanes_2 2; - lanes_4 4; - ); - - #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow - $crate::test_lanes_helper!( - #[should_panic]; - lanes_8 8; - lanes_16 16; - lanes_32 32; - lanes_64 64; - ); - - #[cfg(feature = "all_lane_counts")] - $crate::test_lanes_helper!( - // test some odd and even non-power-of-2 lengths on miri - #[should_panic]; lanes_3 3; - lanes_5 5; + lanes_6 6; ); - #[cfg(feature = "all_lane_counts")] #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow $crate::test_lanes_helper!( #[should_panic]; + lanes_4 4; + lanes_5 5; + lanes_7 7; + lanes_8 8; lanes_9 9; lanes_10 10; lanes_11 11; @@ -676,52 +657,55 @@ macro_rules! test_lanes_panic { lanes_13 13; lanes_14 14; lanes_15 15; + lanes_16 16; lanes_17 17; - lanes_18 18; - lanes_19 19; - lanes_20 20; - lanes_21 21; - lanes_22 22; - lanes_23 23; + //lanes_18 18; + //lanes_19 19; + //lanes_20 20; + //lanes_21 21; + //lanes_22 22; + //lanes_23 23; lanes_24 24; - lanes_25 25; - lanes_26 26; - lanes_27 27; - lanes_28 28; - lanes_29 29; - lanes_30 30; - lanes_31 31; - lanes_33 33; - lanes_34 34; - lanes_35 35; - lanes_36 36; - lanes_37 37; - lanes_38 38; - lanes_39 39; - lanes_40 40; - lanes_41 41; - lanes_42 42; - lanes_43 43; - lanes_44 44; - lanes_45 45; - lanes_46 46; + //lanes_25 25; + //lanes_26 26; + //lanes_27 27; + //lanes_28 28; + //lanes_29 29; + //lanes_30 30; + //lanes_31 31; + lanes_32 32; + //lanes_33 33; + //lanes_34 34; + //lanes_35 35; + //lanes_36 36; + //lanes_37 37; + //lanes_38 38; + //lanes_39 39; + //lanes_40 40; + //lanes_41 41; + //lanes_42 42; + //lanes_43 43; + //lanes_44 44; + //lanes_45 45; + //lanes_46 46; lanes_47 47; - lanes_48 48; - lanes_49 49; - lanes_50 50; - lanes_51 51; - lanes_52 52; - lanes_53 53; - lanes_54 54; - lanes_55 55; + //lanes_48 48; + //lanes_49 49; + //lanes_50 50; + //lanes_51 51; + //lanes_52 52; + //lanes_53 53; + //lanes_54 54; + //lanes_55 55; lanes_56 56; lanes_57 57; - lanes_58 58; - lanes_59 59; - lanes_60 60; - lanes_61 61; - lanes_62 62; + //lanes_58 58; + //lanes_59 59; + //lanes_60 60; + //lanes_61 61; + //lanes_62 62; lanes_63 63; + lanes_64 64; ); } )* diff --git a/portable-simd/rust-toolchain.toml b/portable-simd/rust-toolchain.toml new file mode 100644 index 0000000000000..d17c6d2e88946 --- /dev/null +++ b/portable-simd/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "nightly-2025-01-16" +components = ["rustfmt", "clippy", "miri", "rust-src"] diff --git a/portable-simd/subtree-sync.sh b/portable-simd/subtree-sync.sh new file mode 100755 index 0000000000000..18360077623b1 --- /dev/null +++ b/portable-simd/subtree-sync.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +set -eou pipefail + +git fetch origin +pushd $2 +git fetch origin +popd + +if [ "$(git rev-parse --show-prefix)" != "" ]; then + echo "Run this script from the git root" >&2 + exit 1 +fi + +if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/master)" ]; then + echo "$(pwd) is not at origin/master" >&2 + exit 1 +fi + +if [ ! -f library/portable-simd/git-subtree.sh ]; then + curl -sS https://raw.githubusercontent.com/bjorn3/git/tqc-subtree-portable/contrib/subtree/git-subtree.sh -o library/portable-simd/git-subtree.sh + chmod +x library/portable-simd/git-subtree.sh +fi + +today=$(date +%Y-%m-%d) + +case $1 in + "push") + upstream=rust-upstream-$today + merge=sync-from-rust-$today + + pushd $2 + git checkout master + git pull + popd + + library/portable-simd/git-subtree.sh push -P library/portable-simd $2 $upstream + + pushd $2 + git checkout -B $merge origin/master + git merge $upstream + popd + echo "Branch \`$merge\` created in \`$2\`. You may need to resolve merge conflicts." + ;; + "pull") + branch=sync-from-portable-simd-$today + + git checkout -B $branch + echo "Creating branch \`$branch\`... You may need to resolve merge conflicts." + library/portable-simd/git-subtree.sh pull -P library/portable-simd $2 origin/master + ;; +esac diff --git a/proc_macro/src/bridge/arena.rs b/proc_macro/src/bridge/arena.rs index 1d5986093c8a4..29636e793f614 100644 --- a/proc_macro/src/bridge/arena.rs +++ b/proc_macro/src/bridge/arena.rs @@ -102,7 +102,7 @@ impl Arena { #[allow(clippy::mut_from_ref)] // arena allocator pub(crate) fn alloc_str<'a>(&'a self, string: &str) -> &'a mut str { let alloc = self.alloc_raw(string.len()); - let bytes = MaybeUninit::copy_from_slice(alloc, string.as_bytes()); + let bytes = alloc.write_copy_of_slice(string.as_bytes()); // SAFETY: we convert from `&str` to `&[u8]`, clone it into the arena, // and immediately convert the clone back to `&str`. diff --git a/proc_macro/src/bridge/closure.rs b/proc_macro/src/bridge/closure.rs index d371ae3cea098..e0e688434dce5 100644 --- a/proc_macro/src/bridge/closure.rs +++ b/proc_macro/src/bridge/closure.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; #[repr(C)] -pub struct Closure<'a, A, R> { +pub(super) struct Closure<'a, A, R> { call: unsafe extern "C" fn(*mut Env, A) -> R, env: *mut Env, // Prevent Send and Sync impls. `!Send`/`!Sync` is the usual way of doing @@ -19,14 +19,14 @@ struct Env; impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> { fn from(f: &'a mut F) -> Self { unsafe extern "C" fn call R>(env: *mut Env, arg: A) -> R { - (*(env as *mut _ as *mut F))(arg) + unsafe { (*(env as *mut _ as *mut F))(arg) } } Closure { call: call::, env: f as *mut _ as *mut Env, _marker: PhantomData } } } impl<'a, A, R> Closure<'a, A, R> { - pub fn call(&mut self, arg: A) -> R { + pub(super) fn call(&mut self, arg: A) -> R { unsafe { (self.call)(self.env, arg) } } } diff --git a/proc_macro/src/bridge/fxhash.rs b/proc_macro/src/bridge/fxhash.rs index 74a41451825ff..5f6b3d1b929e4 100644 --- a/proc_macro/src/bridge/fxhash.rs +++ b/proc_macro/src/bridge/fxhash.rs @@ -9,7 +9,7 @@ use std::hash::{BuildHasherDefault, Hasher}; use std::ops::BitXor; /// Type alias for a hashmap using the `fx` hash algorithm. -pub type FxHashMap = HashMap>; +pub(super) type FxHashMap = HashMap>; /// A speedy hash algorithm for use within rustc. The hashmap in alloc by /// default uses SipHash which isn't quite as speedy as we want. In the compiler @@ -22,7 +22,8 @@ pub type FxHashMap = HashMap>; /// out-performs an FNV-based hash within rustc itself -- the collision rate is /// similar or slightly worse than FNV, but the speed of the hash function /// itself is much higher because it works on up to 8 bytes at a time. -pub struct FxHasher { +#[derive(Default)] +pub(super) struct FxHasher { hash: usize, } @@ -31,13 +32,6 @@ const K: usize = 0x9e3779b9; #[cfg(target_pointer_width = "64")] const K: usize = 0x517cc1b727220a95; -impl Default for FxHasher { - #[inline] - fn default() -> FxHasher { - FxHasher { hash: 0 } - } -} - impl FxHasher { #[inline] fn add_to_hash(&mut self, i: usize) { diff --git a/proc_macro/src/bridge/rpc.rs b/proc_macro/src/bridge/rpc.rs index 202a8e04543b2..85fd7d138585c 100644 --- a/proc_macro/src/bridge/rpc.rs +++ b/proc_macro/src/bridge/rpc.rs @@ -67,7 +67,7 @@ macro_rules! rpc_encode_decode { mod tag { #[repr(u8)] enum Tag { $($variant),* } - $(pub const $variant: u8 = Tag::$variant as u8;)* + $(pub(crate) const $variant: u8 = Tag::$variant as u8;)* } match self { @@ -89,7 +89,7 @@ macro_rules! rpc_encode_decode { mod tag { #[repr(u8)] enum Tag { $($variant),* } - $(pub const $variant: u8 = Tag::$variant as u8;)* + $(pub(crate) const $variant: u8 = Tag::$variant as u8;)* } match u8::decode(r, s) { diff --git a/proc_macro/src/bridge/selfless_reify.rs b/proc_macro/src/bridge/selfless_reify.rs index 907ad256e4b43..b06434a5ffee2 100644 --- a/proc_macro/src/bridge/selfless_reify.rs +++ b/proc_macro/src/bridge/selfless_reify.rs @@ -44,13 +44,13 @@ macro_rules! define_reify_functions { fn $name:ident $(<$($param:ident),*>)? for $(extern $abi:tt)? fn($($arg:ident: $arg_ty:ty),*) -> $ret_ty:ty; )+) => { - $(pub const fn $name< + $(pub(super) const fn $name< $($($param,)*)? F: Fn($($arg_ty),*) -> $ret_ty + Copy >(f: F) -> $(extern $abi)? fn($($arg_ty),*) -> $ret_ty { // FIXME(eddyb) describe the `F` type (e.g. via `type_name::`) once panic // formatting becomes possible in `const fn`. - assert!(mem::size_of::() == 0, "selfless_reify: closure must be zero-sized"); + assert!(size_of::() == 0, "selfless_reify: closure must be zero-sized"); $(extern $abi)? fn wrapper< $($($param,)*)? diff --git a/proc_macro/src/bridge/symbol.rs b/proc_macro/src/bridge/symbol.rs index edad6e7ac393f..6a1cecd69fb5f 100644 --- a/proc_macro/src/bridge/symbol.rs +++ b/proc_macro/src/bridge/symbol.rs @@ -91,12 +91,6 @@ impl fmt::Debug for Symbol { } } -impl ToString for Symbol { - fn to_string(&self) -> String { - self.with(|s| s.to_owned()) - } -} - impl fmt::Display for Symbol { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.with(|s| fmt::Display::fmt(s, f)) diff --git a/proc_macro/src/lib.rs b/proc_macro/src/lib.rs index 15770248b3106..d9141eab5919f 100644 --- a/proc_macro/src/lib.rs +++ b/proc_macro/src/lib.rs @@ -19,10 +19,6 @@ )] #![doc(rust_logo)] #![feature(rustdoc_internals)] -// This library is copied into rust-analyzer to allow loading rustc compiled proc macros. -// Please avoid unstable features where possible to minimize the amount of changes necessary -// to make it compile with rust-analyzer on stable. -#![feature(rustc_allow_const_fn_unstable)] #![feature(staged_api)] #![feature(allow_internal_unstable)] #![feature(decl_macro)] @@ -31,12 +27,13 @@ #![feature(panic_can_unwind)] #![feature(restricted_std)] #![feature(rustc_attrs)] -#![feature(min_specialization)] #![feature(extend_one)] #![recursion_limit = "256"] #![allow(internal_features)] #![deny(ffi_unwind_calls)] #![warn(rustdoc::unescaped_backticks)] +#![warn(unreachable_pub)] +#![deny(unsafe_op_in_unsafe_fn)] #[unstable(feature = "proc_macro_internals", issue = "27812")] #[doc(hidden)] @@ -186,16 +183,6 @@ impl FromStr for TokenStream { } } -// N.B., the bridge only provides `to_string`, implement `fmt::Display` -// based on it (the reverse of the usual relationship between the two). -#[doc(hidden)] -#[stable(feature = "proc_macro_lib", since = "1.15.0")] -impl ToString for TokenStream { - fn to_string(&self) -> String { - self.0.as_ref().map(|t| t.to_string()).unwrap_or_default() - } -} - /// Prints the token stream as a string that is supposed to be losslessly convertible back /// into the same token stream (modulo spans), except for possibly `TokenTree::Group`s /// with `Delimiter::None` delimiters and negative numeric literals. @@ -211,7 +198,10 @@ impl ToString for TokenStream { impl fmt::Display for TokenStream { #[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(&self.to_string()) + match &self.0 { + Some(ts) => write!(f, "{}", ts.to_string()), + None => Ok(()), + } } } @@ -431,7 +421,7 @@ pub mod token_stream { /// Unquoting is done with `$`, and works by taking the single next ident as the unquoted term. /// To quote `$` itself, use `$$`. #[unstable(feature = "proc_macro_quote", issue = "54722")] -#[allow_internal_unstable(proc_macro_def_site, proc_macro_internals)] +#[allow_internal_unstable(proc_macro_def_site, proc_macro_internals, proc_macro_totokens)] #[rustc_builtin_macro] pub macro quote($($t:tt)*) { /* compiler built-in */ @@ -757,21 +747,6 @@ impl From for TokenTree { } } -// N.B., the bridge only provides `to_string`, implement `fmt::Display` -// based on it (the reverse of the usual relationship between the two). -#[doc(hidden)] -#[stable(feature = "proc_macro_lib", since = "1.15.0")] -impl ToString for TokenTree { - fn to_string(&self) -> String { - match *self { - TokenTree::Group(ref t) => t.to_string(), - TokenTree::Ident(ref t) => t.to_string(), - TokenTree::Punct(ref t) => t.to_string(), - TokenTree::Literal(ref t) => t.to_string(), - } - } -} - /// Prints the token tree as a string that is supposed to be losslessly convertible back /// into the same token tree (modulo spans), except for possibly `TokenTree::Group`s /// with `Delimiter::None` delimiters and negative numeric literals. @@ -787,7 +762,12 @@ impl ToString for TokenTree { impl fmt::Display for TokenTree { #[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(&self.to_string()) + match self { + TokenTree::Group(t) => write!(f, "{t}"), + TokenTree::Ident(t) => write!(f, "{t}"), + TokenTree::Punct(t) => write!(f, "{t}"), + TokenTree::Literal(t) => write!(f, "{t}"), + } } } @@ -913,16 +893,6 @@ impl Group { } } -// N.B., the bridge only provides `to_string`, implement `fmt::Display` -// based on it (the reverse of the usual relationship between the two). -#[doc(hidden)] -#[stable(feature = "proc_macro_lib", since = "1.15.0")] -impl ToString for Group { - fn to_string(&self) -> String { - TokenStream::from(TokenTree::from(self.clone())).to_string() - } -} - /// Prints the group as a string that should be losslessly convertible back /// into the same group (modulo spans), except for possibly `TokenTree::Group`s /// with `Delimiter::None` delimiters. @@ -930,7 +900,7 @@ impl ToString for Group { impl fmt::Display for Group { #[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(&self.to_string()) + write!(f, "{}", TokenStream::from(TokenTree::from(self.clone()))) } } @@ -1036,14 +1006,6 @@ impl Punct { } } -#[doc(hidden)] -#[stable(feature = "proc_macro_lib2", since = "1.29.0")] -impl ToString for Punct { - fn to_string(&self) -> String { - self.as_char().to_string() - } -} - /// Prints the punctuation character as a string that should be losslessly convertible /// back into the same character. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] @@ -1139,14 +1101,6 @@ impl Ident { } } -#[doc(hidden)] -#[stable(feature = "proc_macro_lib2", since = "1.29.0")] -impl ToString for Ident { - fn to_string(&self) -> String { - self.0.sym.with(|sym| if self.0.is_raw { ["r#", sym].concat() } else { sym.to_owned() }) - } -} - /// Prints the identifier as a string that should be losslessly convertible back /// into the same identifier. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] @@ -1521,14 +1475,6 @@ impl FromStr for Literal { } } -#[doc(hidden)] -#[stable(feature = "proc_macro_lib2", since = "1.29.0")] -impl ToString for Literal { - fn to_string(&self) -> String { - self.with_stringify_parts(|parts| parts.concat()) - } -} - /// Prints the literal as a string that should be losslessly convertible /// back into the same literal (except for possible rounding for floating point literals). #[stable(feature = "proc_macro_lib2", since = "1.29.0")] diff --git a/proc_macro/src/quote.rs b/proc_macro/src/quote.rs index 04fa696d5e6be..bcb15912bb65e 100644 --- a/proc_macro/src/quote.rs +++ b/proc_macro/src/quote.rs @@ -4,12 +4,14 @@ //! This quasiquoter uses macros 2.0 hygiene to reliably access //! items from `proc_macro`, to build a `proc_macro::TokenStream`. -use crate::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; +use crate::{ + Delimiter, Group, Ident, Literal, Punct, Spacing, Span, ToTokens, TokenStream, TokenTree, +}; -macro_rules! quote_tt { - (($($t:tt)*)) => { Group::new(Delimiter::Parenthesis, quote!($($t)*)) }; - ([$($t:tt)*]) => { Group::new(Delimiter::Bracket, quote!($($t)*)) }; - ({$($t:tt)*}) => { Group::new(Delimiter::Brace, quote!($($t)*)) }; +macro_rules! minimal_quote_tt { + (($($t:tt)*)) => { Group::new(Delimiter::Parenthesis, minimal_quote!($($t)*)) }; + ([$($t:tt)*]) => { Group::new(Delimiter::Bracket, minimal_quote!($($t)*)) }; + ({$($t:tt)*}) => { Group::new(Delimiter::Brace, minimal_quote!($($t)*)) }; (,) => { Punct::new(',', Spacing::Alone) }; (.) => { Punct::new('.', Spacing::Alone) }; (;) => { Punct::new(';', Spacing::Alone) }; @@ -21,21 +23,20 @@ macro_rules! quote_tt { ($i:ident) => { Ident::new(stringify!($i), Span::def_site()) }; } -macro_rules! quote_ts { +macro_rules! minimal_quote_ts { ((@ $($t:tt)*)) => { $($t)* }; (::) => { - [ - TokenTree::from(Punct::new(':', Spacing::Joint)), - TokenTree::from(Punct::new(':', Spacing::Alone)), - ].iter() - .cloned() - .map(|mut x| { - x.set_span(Span::def_site()); - x - }) - .collect::() + { + let mut c = ( + TokenTree::from(Punct::new(':', Spacing::Joint)), + TokenTree::from(Punct::new(':', Spacing::Alone)) + ); + c.0.set_span(Span::def_site()); + c.1.set_span(Span::def_site()); + [c.0, c.1].into_iter().collect::() + } }; - ($t:tt) => { TokenTree::from(quote_tt!($t)) }; + ($t:tt) => { TokenTree::from(minimal_quote_tt!($t)) }; } /// Simpler version of the real `quote!` macro, implemented solely @@ -46,12 +47,14 @@ macro_rules! quote_ts { /// /// Note: supported tokens are a subset of the real `quote!`, but /// unquoting is different: instead of `$x`, this uses `(@ expr)`. -macro_rules! quote { - () => { TokenStream::new() }; +macro_rules! minimal_quote { ($($t:tt)*) => { - [ - $(TokenStream::from(quote_ts!($t)),)* - ].iter().cloned().collect::() + { + #[allow(unused_mut)] // In case the expansion is empty + let mut ts = TokenStream::new(); + $(ToTokens::to_tokens(&minimal_quote_ts!($t), &mut ts);)* + ts + } }; } @@ -62,52 +65,66 @@ macro_rules! quote { #[unstable(feature = "proc_macro_quote", issue = "54722")] pub fn quote(stream: TokenStream) -> TokenStream { if stream.is_empty() { - return quote!(crate::TokenStream::new()); + return minimal_quote!(crate::TokenStream::new()); } - let proc_macro_crate = quote!(crate); + let proc_macro_crate = minimal_quote!(crate); let mut after_dollar = false; - let tokens = stream - .into_iter() - .filter_map(|tree| { - if after_dollar { - after_dollar = false; - match tree { - TokenTree::Ident(_) => { - return Some(quote!(Into::::into( - Clone::clone(&(@ tree))),)); - } - TokenTree::Punct(ref tt) if tt.as_char() == '$' => {} - _ => panic!("`$` must be followed by an ident or `$` in `quote!`"), - } - } else if let TokenTree::Punct(ref tt) = tree { - if tt.as_char() == '$' { - after_dollar = true; - return None; + + let mut tokens = crate::TokenStream::new(); + for tree in stream { + if after_dollar { + after_dollar = false; + match tree { + TokenTree::Ident(_) => { + minimal_quote!(crate::ToTokens::to_tokens(&(@ tree), &mut ts);) + .to_tokens(&mut tokens); + continue; } + TokenTree::Punct(ref tt) if tt.as_char() == '$' => {} + _ => panic!("`$` must be followed by an ident or `$` in `quote!`"), } + } else if let TokenTree::Punct(ref tt) = tree { + if tt.as_char() == '$' { + after_dollar = true; + continue; + } + } - Some(quote!(crate::TokenStream::from((@ match tree { - TokenTree::Punct(tt) => quote!(crate::TokenTree::Punct(crate::Punct::new( + match tree { + TokenTree::Punct(tt) => { + minimal_quote!(crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new( (@ TokenTree::from(Literal::character(tt.as_char()))), (@ match tt.spacing() { - Spacing::Alone => quote!(crate::Spacing::Alone), - Spacing::Joint => quote!(crate::Spacing::Joint), + Spacing::Alone => minimal_quote!(crate::Spacing::Alone), + Spacing::Joint => minimal_quote!(crate::Spacing::Joint), }), - ))), - TokenTree::Group(tt) => quote!(crate::TokenTree::Group(crate::Group::new( + )), &mut ts);) + } + TokenTree::Group(tt) => { + minimal_quote!(crate::ToTokens::to_tokens(&crate::TokenTree::Group(crate::Group::new( (@ match tt.delimiter() { - Delimiter::Parenthesis => quote!(crate::Delimiter::Parenthesis), - Delimiter::Brace => quote!(crate::Delimiter::Brace), - Delimiter::Bracket => quote!(crate::Delimiter::Bracket), - Delimiter::None => quote!(crate::Delimiter::None), + Delimiter::Parenthesis => minimal_quote!(crate::Delimiter::Parenthesis), + Delimiter::Brace => minimal_quote!(crate::Delimiter::Brace), + Delimiter::Bracket => minimal_quote!(crate::Delimiter::Bracket), + Delimiter::None => minimal_quote!(crate::Delimiter::None), }), (@ quote(tt.stream())), - ))), - TokenTree::Ident(tt) => quote!(crate::TokenTree::Ident(crate::Ident::new( - (@ TokenTree::from(Literal::string(&tt.to_string()))), + )), &mut ts);) + } + TokenTree::Ident(tt) => { + let literal = tt.to_string(); + let (literal, ctor) = if let Some(stripped) = literal.strip_prefix("r#") { + (stripped, minimal_quote!(crate::Ident::new_raw)) + } else { + (literal.as_str(), minimal_quote!(crate::Ident::new)) + }; + minimal_quote!(crate::ToTokens::to_tokens(&crate::TokenTree::Ident((@ ctor)( + (@ TokenTree::from(Literal::string(literal))), (@ quote_span(proc_macro_crate.clone(), tt.span())), - ))), - TokenTree::Literal(tt) => quote!(crate::TokenTree::Literal({ + )), &mut ts);) + } + TokenTree::Literal(tt) => { + minimal_quote!(crate::ToTokens::to_tokens(&crate::TokenTree::Literal({ let mut iter = (@ TokenTree::from(Literal::string(&tt.to_string()))) .parse::() .unwrap() @@ -120,16 +137,22 @@ pub fn quote(stream: TokenStream) -> TokenStream { } else { unreachable!() } - })) - })),)) - }) - .collect::(); - + }), &mut ts);) + } + } + .to_tokens(&mut tokens); + } if after_dollar { panic!("unexpected trailing `$` in `quote!`"); } - quote!([(@ tokens)].iter().cloned().collect::()) + minimal_quote! { + { + let mut ts = crate::TokenStream::new(); + (@ tokens) + ts + } + } } /// Quote a `Span` into a `TokenStream`. @@ -137,5 +160,5 @@ pub fn quote(stream: TokenStream) -> TokenStream { #[unstable(feature = "proc_macro_quote", issue = "54722")] pub fn quote_span(proc_macro_crate: TokenStream, span: Span) -> TokenStream { let id = span.save_span(); - quote!((@ proc_macro_crate ) ::Span::recover_proc_macro_span((@ TokenTree::from(Literal::usize_unsuffixed(id))))) + minimal_quote!((@ proc_macro_crate ) ::Span::recover_proc_macro_span((@ TokenTree::from(Literal::usize_unsuffixed(id))))) } diff --git a/profiler_builtins/Cargo.toml b/profiler_builtins/Cargo.toml index 9aadefce3b39e..230e8051602e4 100644 --- a/profiler_builtins/Cargo.toml +++ b/profiler_builtins/Cargo.toml @@ -9,8 +9,7 @@ bench = false doc = false [dependencies] -core = { path = "../core" } -compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] } [build-dependencies] -cc = "1.2" +# Pinned so `cargo update` bumps don't cause breakage +cc = "=1.2.0" diff --git a/profiler_builtins/src/lib.rs b/profiler_builtins/src/lib.rs index ac685b18c2911..a258f7d31a191 100644 --- a/profiler_builtins/src/lib.rs +++ b/profiler_builtins/src/lib.rs @@ -1,11 +1,15 @@ -#![no_std] +// tidy-alphabetical-start +#![allow(internal_features)] +#![feature(no_core)] #![feature(profiler_runtime)] +#![feature(staged_api)] +// tidy-alphabetical-end + +// Other attributes: +#![no_core] #![profiler_runtime] #![unstable( feature = "profiler_runtime_lib", reason = "internal implementation detail of rustc right now", issue = "none" )] -#![allow(unused_features)] -#![allow(internal_features)] -#![feature(staged_api)] diff --git a/rtstartup/rsbegin.rs b/rtstartup/rsbegin.rs index 9a3d95bd8ddfb..67b09599d9d2b 100644 --- a/rtstartup/rsbegin.rs +++ b/rtstartup/rsbegin.rs @@ -19,6 +19,7 @@ #![no_core] #![allow(non_camel_case_types)] #![allow(internal_features)] +#![warn(unreachable_pub)] #[lang = "sized"] trait Sized {} @@ -51,7 +52,7 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { #[cfg(all(target_os = "windows", target_arch = "x86", target_env = "gnu"))] pub mod eh_frames { #[no_mangle] - #[link_section = ".eh_frame"] + #[unsafe(link_section = ".eh_frame")] // Marks beginning of the stack frame unwind info section pub static __EH_FRAME_BEGIN__: [u8; 0] = []; @@ -75,7 +76,7 @@ pub mod eh_frames { } // Unwind info registration/deregistration routines. - extern "C" { + unsafe extern "C" { fn __register_frame_info(eh_frame_begin: *const u8, object: *mut u8); fn __deregister_frame_info(eh_frame_begin: *const u8, object: *mut u8); } @@ -100,10 +101,10 @@ pub mod eh_frames { // end of the list. Since constructors are run in reverse order, this ensures that our // callbacks are the first and last ones executed. - #[link_section = ".ctors.65535"] // .ctors.* : C initialization callbacks + #[unsafe(link_section = ".ctors.65535")] // .ctors.* : C initialization callbacks pub static P_INIT: unsafe extern "C" fn() = super::init; - #[link_section = ".dtors.65535"] // .dtors.* : C termination callbacks + #[unsafe(link_section = ".dtors.65535")] // .dtors.* : C termination callbacks pub static P_UNINIT: unsafe extern "C" fn() = super::uninit; } } diff --git a/rtstartup/rsend.rs b/rtstartup/rsend.rs index 2514eb0034402..a6f7d103356bf 100644 --- a/rtstartup/rsend.rs +++ b/rtstartup/rsend.rs @@ -6,6 +6,7 @@ #![crate_type = "rlib"] #![no_core] #![allow(internal_features)] +#![warn(unreachable_pub)] #[lang = "sized"] trait Sized {} @@ -31,6 +32,6 @@ pub mod eh_frames { // Terminate the frame unwind info section with a 0 as a sentinel; // this would be the 'length' field in a real FDE. #[no_mangle] - #[link_section = ".eh_frame"] + #[unsafe(link_section = ".eh_frame")] pub static __EH_FRAME_END__: u32 = 0; } diff --git a/std/Cargo.toml b/std/Cargo.toml index c1ab70b714a4c..f7379c413f15e 100644 --- a/std/Cargo.toml +++ b/std/Cargo.toml @@ -7,6 +7,7 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/rust.git" description = "The Rust Standard Library" edition = "2021" +autobenches = false [lib] crate-type = ["dylib", "rlib"] @@ -17,7 +18,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] } panic_unwind = { path = "../panic_unwind", optional = true } panic_abort = { path = "../panic_abort" } core = { path = "../core", public = true } -compiler_builtins = { version = "=0.1.138" } +compiler_builtins = { version = "=0.1.151" } unwind = { path = "../unwind" } hashbrown = { version = "0.15", default-features = false, features = [ 'rustc-dep-of-std', @@ -30,11 +31,11 @@ std_detect = { path = "../stdarch/crates/std_detect", default-features = false, rustc-demangle = { version = "0.1.24", features = ['rustc-dep-of-std'] } [target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies] -miniz_oxide = { version = "0.7.0", optional = true, default-features = false } -addr2line = { version = "0.22.0", optional = true, default-features = false } +miniz_oxide = { version = "0.8.0", optional = true, default-features = false } +addr2line = { version = "0.24.0", optional = true, default-features = false } [target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies] -libc = { version = "0.2.162", default-features = false, features = [ +libc = { version = "0.2.170", default-features = false, features = [ 'rustc-dep-of-std', ], public = true } @@ -60,8 +61,8 @@ object = { version = "0.36.0", default-features = false, optional = true, featur path = "../windows_targets" [dev-dependencies] -rand = { version = "0.8.5", default-features = false, features = ["alloc"] } -rand_xorshift = "0.3.0" +rand = { version = "0.9.0", default-features = false, features = ["alloc"] } +rand_xorshift = "0.4.0" [target.'cfg(any(all(target_family = "wasm", target_os = "unknown"), target_os = "xous", all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies] dlmalloc = { version = "0.2.4", features = ['rustc-dep-of-std'] } @@ -72,7 +73,7 @@ fortanix-sgx-abi = { version = "0.5.0", features = [ ], public = true } [target.'cfg(target_os = "hermit")'.dependencies] -hermit-abi = { version = "0.4.0", features = [ +hermit-abi = { version = "0.5.0", features = [ 'rustc-dep-of-std', ], public = true } @@ -109,6 +110,13 @@ panic_immediate_abort = [ # Choose algorithms that are optimized for binary size instead of runtime performance optimize_for_size = ["core/optimize_for_size", "alloc/optimize_for_size"] +# Make `RefCell` store additional debugging information, which is printed out when +# a borrow error occurs +debug_refcell = ["core/debug_refcell"] +# Make `TypeId` store a reference to the name of the type, so that it can print that name. +debug_typeid = ["core/debug_typeid"] + + # Enable std_detect default features for stdarch/crates/std_detect: # https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/Cargo.toml std_detect_file_io = ["std_detect/std_detect_file_io"] @@ -130,6 +138,18 @@ name = "pipe-subprocess" path = "tests/pipe_subprocess.rs" harness = false +[[test]] +name = "sync" +path = "tests/sync/lib.rs" + +[[test]] +name = "floats" +path = "tests/floats/lib.rs" + +[[test]] +name = "thread_local" +path = "tests/thread_local/lib.rs" + [[bench]] name = "stdbenches" path = "benches/lib.rs" @@ -139,11 +159,8 @@ test = true level = "warn" check-cfg = [ 'cfg(bootstrap)', - 'cfg(target_arch, values("xtensa"))', # std use #[path] imports to portable-simd `std_float` crate # and to the `backtrace` crate which messes-up with Cargo list # of declared features, we therefor expect any feature cfg 'cfg(feature, values(any()))', - # #[cfg(bootstrap)] rtems - 'cfg(target_os, values("rtems"))', ] diff --git a/std/benches/lib.rs b/std/benches/lib.rs index 1b21c230a0bf2..e749d9c0f7998 100644 --- a/std/benches/lib.rs +++ b/std/benches/lib.rs @@ -5,3 +5,5 @@ extern crate test; mod hash; +mod path; +mod time; diff --git a/std/benches/path.rs b/std/benches/path.rs new file mode 100644 index 0000000000000..094c00894a8ee --- /dev/null +++ b/std/benches/path.rs @@ -0,0 +1,114 @@ +use core::hint::black_box; +use std::collections::{BTreeSet, HashSet}; +use std::hash::{DefaultHasher, Hash, Hasher}; +use std::path::*; + +#[bench] +#[cfg_attr(miri, ignore)] // Miri isn't fast... +fn bench_path_cmp_fast_path_buf_sort(b: &mut test::Bencher) { + let prefix = "my/home"; + let mut paths: Vec<_> = + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); + + paths.sort(); + + b.iter(|| { + black_box(paths.as_mut_slice()).sort_unstable(); + }); +} + +#[bench] +#[cfg_attr(miri, ignore)] // Miri isn't fast... +fn bench_path_cmp_fast_path_long(b: &mut test::Bencher) { + let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; + let paths: Vec<_> = + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); + + let mut set = BTreeSet::new(); + + paths.iter().for_each(|p| { + set.insert(p.as_path()); + }); + + b.iter(|| { + set.remove(paths[500].as_path()); + set.insert(paths[500].as_path()); + }); +} + +#[bench] +#[cfg_attr(miri, ignore)] // Miri isn't fast... +fn bench_path_cmp_fast_path_short(b: &mut test::Bencher) { + let prefix = "my/home"; + let paths: Vec<_> = + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); + + let mut set = BTreeSet::new(); + + paths.iter().for_each(|p| { + set.insert(p.as_path()); + }); + + b.iter(|| { + set.remove(paths[500].as_path()); + set.insert(paths[500].as_path()); + }); +} + +#[bench] +#[cfg_attr(miri, ignore)] // Miri isn't fast... +fn bench_path_hashset(b: &mut test::Bencher) { + let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; + let paths: Vec<_> = + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); + + let mut set = HashSet::new(); + + paths.iter().for_each(|p| { + set.insert(p.as_path()); + }); + + b.iter(|| { + set.remove(paths[500].as_path()); + set.insert(black_box(paths[500].as_path())) + }); +} + +#[bench] +#[cfg_attr(miri, ignore)] // Miri isn't fast... +fn bench_path_hashset_miss(b: &mut test::Bencher) { + let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; + let paths: Vec<_> = + (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); + + let mut set = HashSet::new(); + + paths.iter().for_each(|p| { + set.insert(p.as_path()); + }); + + let probe = PathBuf::from(prefix).join("other"); + + b.iter(|| set.remove(black_box(probe.as_path()))); +} + +#[bench] +fn bench_hash_path_short(b: &mut test::Bencher) { + let mut hasher = DefaultHasher::new(); + let path = Path::new("explorer.exe"); + + b.iter(|| black_box(path).hash(&mut hasher)); + + black_box(hasher.finish()); +} + +#[bench] +fn bench_hash_path_long(b: &mut test::Bencher) { + let mut hasher = DefaultHasher::new(); + let path = + Path::new("/aaaaa/aaaaaa/./../aaaaaaaa/bbbbbbbbbbbbb/ccccccccccc/ddddddddd/eeeeeee.fff"); + + b.iter(|| black_box(path).hash(&mut hasher)); + + black_box(hasher.finish()); +} diff --git a/std/benches/time.rs b/std/benches/time.rs new file mode 100644 index 0000000000000..dfd886738f984 --- /dev/null +++ b/std/benches/time.rs @@ -0,0 +1,46 @@ +#[cfg(not(target_arch = "wasm32"))] +use test::{Bencher, black_box}; + +macro_rules! bench_instant_threaded { + ($bench_name:ident, $thread_count:expr) => { + #[bench] + #[cfg(not(target_arch = "wasm32"))] + fn $bench_name(b: &mut Bencher) -> std::thread::Result<()> { + use std::sync::Arc; + use std::sync::atomic::{AtomicBool, Ordering}; + use std::time::Instant; + + let running = Arc::new(AtomicBool::new(true)); + + let threads: Vec<_> = (0..$thread_count) + .map(|_| { + let flag = Arc::clone(&running); + std::thread::spawn(move || { + while flag.load(Ordering::Relaxed) { + black_box(Instant::now()); + } + }) + }) + .collect(); + + b.iter(|| { + let a = Instant::now(); + let b = Instant::now(); + assert!(b >= a); + }); + + running.store(false, Ordering::Relaxed); + + for t in threads { + t.join()?; + } + Ok(()) + } + }; +} + +bench_instant_threaded!(instant_contention_01_threads, 0); +bench_instant_threaded!(instant_contention_02_threads, 1); +bench_instant_threaded!(instant_contention_04_threads, 3); +bench_instant_threaded!(instant_contention_08_threads, 7); +bench_instant_threaded!(instant_contention_16_threads, 15); diff --git a/std/build.rs b/std/build.rs index 8dc326a3dde6a..cedfd7406a1aa 100644 --- a/std/build.rs +++ b/std/build.rs @@ -12,6 +12,11 @@ fn main() { .expect("CARGO_CFG_TARGET_POINTER_WIDTH was not set") .parse() .unwrap(); + let target_features: Vec<_> = env::var("CARGO_CFG_TARGET_FEATURE") + .unwrap_or_default() + .split(",") + .map(ToOwned::to_owned) + .collect(); let is_miri = env::var_os("CARGO_CFG_MIRI").is_some(); println!("cargo:rustc-check-cfg=cfg(netbsd10)"); @@ -101,13 +106,13 @@ fn main() { ("s390x", _) => false, // Unsupported ("arm64ec", _) => false, + // LLVM crash + ("aarch64", _) if !target_features.iter().any(|f| f == "neon") => false, // MinGW ABI bugs ("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false, // Infinite recursion ("csky", _) => false, ("hexagon", _) => false, - ("loongarch64", _) => false, - ("mips" | "mips64" | "mips32r6" | "mips64r6", _) => false, ("powerpc" | "powerpc64", _) => false, ("sparc" | "sparc64", _) => false, ("wasm32" | "wasm64", _) => false, diff --git a/std/src/alloc.rs b/std/src/alloc.rs index 5d51d6a0c78a8..99d105a2454a5 100644 --- a/std/src/alloc.rs +++ b/std/src/alloc.rs @@ -20,11 +20,11 @@ //! //! unsafe impl GlobalAlloc for MyAllocator { //! unsafe fn alloc(&self, layout: Layout) -> *mut u8 { -//! System.alloc(layout) +//! unsafe { System.alloc(layout) } //! } //! //! unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { -//! System.dealloc(ptr, layout) +//! unsafe { System.dealloc(ptr, layout) } //! } //! } //! @@ -102,7 +102,7 @@ pub use alloc_crate::alloc::*; /// /// unsafe impl GlobalAlloc for Counter { /// unsafe fn alloc(&self, layout: Layout) -> *mut u8 { -/// let ret = System.alloc(layout); +/// let ret = unsafe { System.alloc(layout) }; /// if !ret.is_null() { /// ALLOCATED.fetch_add(layout.size(), Relaxed); /// } @@ -110,7 +110,7 @@ pub use alloc_crate::alloc::*; /// } /// /// unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { -/// System.dealloc(ptr, layout); +/// unsafe { System.dealloc(ptr, layout); } /// ALLOCATED.fetch_sub(layout.size(), Relaxed); /// } /// } @@ -345,7 +345,7 @@ pub fn take_alloc_error_hook() -> fn(Layout) { } fn default_alloc_error_hook(layout: Layout) { - extern "Rust" { + unsafe extern "Rust" { // This symbol is emitted by rustc next to __rust_alloc_error_handler. // Its value depends on the -Zoom={panic,abort} compiler option. static __rust_alloc_error_handler_should_panic: u8; diff --git a/std/src/backtrace.rs b/std/src/backtrace.rs index fc333d7ff3f95..3e641ac5d9041 100644 --- a/std/src/backtrace.rs +++ b/std/src/backtrace.rs @@ -432,6 +432,7 @@ mod helper { use super::*; pub(super) type LazyResolve = impl (FnOnce() -> Capture) + Send + Sync + UnwindSafe; + #[cfg_attr(not(bootstrap), define_opaque(LazyResolve))] pub(super) fn lazy_resolve(mut capture: Capture) -> LazyResolve { move || { // Use the global backtrace lock to synchronize this as it's a diff --git a/std/src/bstr.rs b/std/src/bstr.rs new file mode 100644 index 0000000000000..dd49177162833 --- /dev/null +++ b/std/src/bstr.rs @@ -0,0 +1,4 @@ +//! The `ByteStr` and `ByteString` types and trait implementations. + +#[unstable(feature = "bstr", issue = "134915")] +pub use alloc::bstr::{ByteStr, ByteString}; diff --git a/std/src/collections/hash/map.rs b/std/src/collections/hash/map.rs index 24bbc2f32cf6d..ff4a4b35ce450 100644 --- a/std/src/collections/hash/map.rs +++ b/std/src/collections/hash/map.rs @@ -204,6 +204,25 @@ use crate::ops::Index; /// println!("{viking:?} has {health} hp"); /// } /// ``` +/// +/// # Usage in `const` and `static` +/// +/// As explained above, `HashMap` is randomly seeded: each `HashMap` instance uses a different seed, +/// which means that `HashMap::new` cannot be used in const context. To construct a `HashMap` in the +/// initializer of a `const` or `static` item, you will have to use a different hasher that does not +/// involve a random seed, as demonstrated in the following example. **A `HashMap` constructed this +/// way is not resistant against HashDoS!** +/// +/// ```rust +/// use std::collections::HashMap; +/// use std::hash::{BuildHasherDefault, DefaultHasher}; +/// use std::sync::Mutex; +/// +/// const EMPTY_MAP: HashMap, BuildHasherDefault> = +/// HashMap::with_hasher(BuildHasherDefault::new()); +/// static MAP: Mutex, BuildHasherDefault>> = +/// Mutex::new(HashMap::with_hasher(BuildHasherDefault::new())); +/// ``` #[cfg_attr(not(test), rustc_diagnostic_item = "HashMap")] #[stable(feature = "rust1", since = "1.0.0")] @@ -235,7 +254,7 @@ impl HashMap { /// /// The hash map will be able to hold at least `capacity` elements without /// reallocating. This method is allowed to allocate for more elements than - /// `capacity`. If `capacity` is 0, the hash map will not allocate. + /// `capacity`. If `capacity` is zero, the hash map will not allocate. /// /// # Examples /// @@ -263,7 +282,7 @@ impl HashMap { /// manually using this function can expose a DoS attack vector. /// /// The `hash_builder` passed should implement the [`BuildHasher`] trait for - /// the HashMap to be useful, see its documentation for details. + /// the `HashMap` to be useful, see its documentation for details. /// /// # Examples /// @@ -277,7 +296,7 @@ impl HashMap { /// ``` #[inline] #[stable(feature = "hashmap_build_hasher", since = "1.7.0")] - #[rustc_const_unstable(feature = "const_collections_with_hasher", issue = "102575")] + #[rustc_const_stable(feature = "const_collections_with_hasher", since = "1.85.0")] pub const fn with_hasher(hash_builder: S) -> HashMap { HashMap { base: base::HashMap::with_hasher(hash_builder) } } @@ -287,7 +306,7 @@ impl HashMap { /// /// The hash map will be able to hold at least `capacity` elements without /// reallocating. This method is allowed to allocate for more elements than - /// `capacity`. If `capacity` is 0, the hash map will not allocate. + /// `capacity`. If `capacity` is zero, the hash map will not allocate. /// /// Warning: `hasher` is normally randomly generated, and /// is designed to allow HashMaps to be resistant to attacks that @@ -295,7 +314,7 @@ impl HashMap { /// manually using this function can expose a DoS attack vector. /// /// The `hasher` passed should implement the [`BuildHasher`] trait for - /// the HashMap to be useful, see its documentation for details. + /// the `HashMap` to be useful, see its documentation for details. /// /// # Examples /// @@ -637,7 +656,6 @@ impl HashMap { /// Splitting a map into even and odd keys, reusing the original map: /// /// ``` - /// #![feature(hash_extract_if)] /// use std::collections::HashMap; /// /// let mut map: HashMap = (0..8).map(|x| (x, x)).collect(); @@ -653,7 +671,7 @@ impl HashMap { /// ``` #[inline] #[rustc_lint_query_instability] - #[unstable(feature = "hash_extract_if", issue = "59618")] + #[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] pub fn extract_if(&mut self, pred: F) -> ExtractIf<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool, @@ -950,7 +968,6 @@ where /// # Examples /// /// ``` - /// #![feature(map_many_mut)] /// use std::collections::HashMap; /// /// let mut libraries = HashMap::new(); @@ -960,13 +977,13 @@ where /// libraries.insert("Library of Congress".to_string(), 1800); /// /// // Get Athenæum and Bodleian Library - /// let [Some(a), Some(b)] = libraries.get_many_mut([ + /// let [Some(a), Some(b)] = libraries.get_disjoint_mut([ /// "Athenæum", /// "Bodleian Library", /// ]) else { panic!() }; /// /// // Assert values of Athenæum and Library of Congress - /// let got = libraries.get_many_mut([ + /// let got = libraries.get_disjoint_mut([ /// "Athenæum", /// "Library of Congress", /// ]); @@ -979,7 +996,7 @@ where /// ); /// /// // Missing keys result in None - /// let got = libraries.get_many_mut([ + /// let got = libraries.get_disjoint_mut([ /// "Athenæum", /// "New York Public Library", /// ]); @@ -993,21 +1010,24 @@ where /// ``` /// /// ```should_panic - /// #![feature(map_many_mut)] /// use std::collections::HashMap; /// /// let mut libraries = HashMap::new(); /// libraries.insert("Athenæum".to_string(), 1807); /// /// // Duplicate keys panic! - /// let got = libraries.get_many_mut([ + /// let got = libraries.get_disjoint_mut([ /// "Athenæum", /// "Athenæum", /// ]); /// ``` #[inline] - #[unstable(feature = "map_many_mut", issue = "97601")] - pub fn get_many_mut(&mut self, ks: [&Q; N]) -> [Option<&'_ mut V>; N] + #[doc(alias = "get_many_mut")] + #[stable(feature = "map_many_mut", since = "1.86.0")] + pub fn get_disjoint_mut( + &mut self, + ks: [&Q; N], + ) -> [Option<&'_ mut V>; N] where K: Borrow, Q: Hash + Eq, @@ -1021,7 +1041,7 @@ where /// Returns an array of length `N` with the results of each query. `None` will be used if /// the key is missing. /// - /// For a safe alternative see [`get_many_mut`](`HashMap::get_many_mut`). + /// For a safe alternative see [`get_disjoint_mut`](`HashMap::get_disjoint_mut`). /// /// # Safety /// @@ -1033,7 +1053,6 @@ where /// # Examples /// /// ``` - /// #![feature(map_many_mut)] /// use std::collections::HashMap; /// /// let mut libraries = HashMap::new(); @@ -1043,13 +1062,13 @@ where /// libraries.insert("Library of Congress".to_string(), 1800); /// /// // SAFETY: The keys do not overlap. - /// let [Some(a), Some(b)] = (unsafe { libraries.get_many_unchecked_mut([ + /// let [Some(a), Some(b)] = (unsafe { libraries.get_disjoint_unchecked_mut([ /// "Athenæum", /// "Bodleian Library", /// ]) }) else { panic!() }; /// /// // SAFETY: The keys do not overlap. - /// let got = unsafe { libraries.get_many_unchecked_mut([ + /// let got = unsafe { libraries.get_disjoint_unchecked_mut([ /// "Athenæum", /// "Library of Congress", /// ]) }; @@ -1062,7 +1081,7 @@ where /// ); /// /// // SAFETY: The keys do not overlap. - /// let got = unsafe { libraries.get_many_unchecked_mut([ + /// let got = unsafe { libraries.get_disjoint_unchecked_mut([ /// "Athenæum", /// "New York Public Library", /// ]) }; @@ -1070,8 +1089,9 @@ where /// assert_eq!(got, [Some(&mut 1807), None]); /// ``` #[inline] - #[unstable(feature = "map_many_mut", issue = "97601")] - pub unsafe fn get_many_unchecked_mut( + #[doc(alias = "get_many_unchecked_mut")] + #[stable(feature = "map_many_mut", since = "1.86.0")] + pub unsafe fn get_disjoint_unchecked_mut( &mut self, ks: [&Q; N], ) -> [Option<&'_ mut V>; N] @@ -1262,7 +1282,7 @@ impl HashMap where S: BuildHasher, { - /// Creates a raw entry builder for the HashMap. + /// Creates a raw entry builder for the `HashMap`. /// /// Raw entries provide the lowest level of control for searching and /// manipulating a map. They must be manually initialized with a hash and @@ -1277,13 +1297,13 @@ where /// * Using custom comparison logic without newtype wrappers /// /// Because raw entries provide much more low-level control, it's much easier - /// to put the HashMap into an inconsistent state which, while memory-safe, + /// to put the `HashMap` into an inconsistent state which, while memory-safe, /// will cause the map to produce seemingly random results. Higher-level and /// more foolproof APIs like `entry` should be preferred when possible. /// /// In particular, the hash used to initialize the raw entry must still be /// consistent with the hash of the key that is ultimately stored in the entry. - /// This is because implementations of HashMap may need to recompute hashes + /// This is because implementations of `HashMap` may need to recompute hashes /// when resizing, at which point only the keys are available. /// /// Raw entries give mutable access to the keys. This must not be used @@ -1299,7 +1319,7 @@ where RawEntryBuilderMut { map: self } } - /// Creates a raw immutable entry builder for the HashMap. + /// Creates a raw immutable entry builder for the `HashMap`. /// /// Raw entries provide the lowest level of control for searching and /// manipulating a map. They must be manually initialized with a hash and @@ -1424,6 +1444,11 @@ impl From<[(K, V); N]> for HashMap where K: Eq + Hash, { + /// Converts a `[(K, V); N]` into a `HashMap`. + /// + /// If any entries in the array have equal keys, + /// all but one of the corresponding values will be dropped. + /// /// # Examples /// /// ``` @@ -1696,8 +1721,6 @@ impl<'a, K, V> Drain<'a, K, V> { /// # Example /// /// ``` -/// #![feature(hash_extract_if)] -/// /// use std::collections::HashMap; /// /// let mut map = HashMap::from([ @@ -1705,7 +1728,7 @@ impl<'a, K, V> Drain<'a, K, V> { /// ]); /// let iter = map.extract_if(|_k, v| *v % 2 == 0); /// ``` -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct ExtractIf<'a, K, V, F> where @@ -2720,7 +2743,7 @@ where } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool, @@ -2737,10 +2760,10 @@ where } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl FusedIterator for ExtractIf<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool {} -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl<'a, K, V, F> fmt::Debug for ExtractIf<'a, K, V, F> where F: FnMut(&K, &mut V) -> bool, @@ -3197,6 +3220,10 @@ where K: Eq + Hash, S: BuildHasher + Default, { + /// Constructs a `HashMap` from an iterator of key-value pairs. + /// + /// If the iterator produces any pairs with equal keys, + /// all but one of the corresponding values will be dropped. fn from_iter>(iter: T) -> HashMap { let mut map = HashMap::with_hasher(Default::default()); map.extend(iter); diff --git a/std/src/collections/hash/set.rs b/std/src/collections/hash/set.rs index f86bcdb4796ec..a547a9943c1a0 100644 --- a/std/src/collections/hash/set.rs +++ b/std/src/collections/hash/set.rs @@ -101,6 +101,25 @@ use crate::ops::{BitAnd, BitOr, BitXor, Sub}; /// [`HashMap`]: crate::collections::HashMap /// [`RefCell`]: crate::cell::RefCell /// [`Cell`]: crate::cell::Cell +/// +/// # Usage in `const` and `static` +/// +/// Like `HashMap`, `HashSet` is randomly seeded: each `HashSet` instance uses a different seed, +/// which means that `HashSet::new` cannot be used in const context. To construct a `HashSet` in the +/// initializer of a `const` or `static` item, you will have to use a different hasher that does not +/// involve a random seed, as demonstrated in the following example. **A `HashSet` constructed this +/// way is not resistant against HashDoS!** +/// +/// ```rust +/// use std::collections::HashSet; +/// use std::hash::{BuildHasherDefault, DefaultHasher}; +/// use std::sync::Mutex; +/// +/// const EMPTY_SET: HashSet> = +/// HashSet::with_hasher(BuildHasherDefault::new()); +/// static SET: Mutex>> = +/// Mutex::new(HashSet::with_hasher(BuildHasherDefault::new())); +/// ``` #[cfg_attr(not(test), rustc_diagnostic_item = "HashSet")] #[stable(feature = "rust1", since = "1.0.0")] pub struct HashSet { @@ -130,7 +149,7 @@ impl HashSet { /// /// The hash set will be able to hold at least `capacity` elements without /// reallocating. This method is allowed to allocate for more elements than - /// `capacity`. If `capacity` is 0, the hash set will not allocate. + /// `capacity`. If `capacity` is zero, the hash set will not allocate. /// /// # Examples /// @@ -274,7 +293,6 @@ impl HashSet { /// Splitting a set into even and odd values, reusing the original set: /// /// ``` - /// #![feature(hash_extract_if)] /// use std::collections::HashSet; /// /// let mut set: HashSet = (0..8).collect(); @@ -290,7 +308,7 @@ impl HashSet { /// ``` #[inline] #[rustc_lint_query_instability] - #[unstable(feature = "hash_extract_if", issue = "59618")] + #[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] pub fn extract_if(&mut self, pred: F) -> ExtractIf<'_, T, F> where F: FnMut(&T) -> bool, @@ -355,7 +373,7 @@ impl HashSet { /// manually using this function can expose a DoS attack vector. /// /// The `hash_builder` passed should implement the [`BuildHasher`] trait for - /// the HashMap to be useful, see its documentation for details. + /// the `HashSet` to be useful, see its documentation for details. /// /// # Examples /// @@ -369,7 +387,7 @@ impl HashSet { /// ``` #[inline] #[stable(feature = "hashmap_build_hasher", since = "1.7.0")] - #[rustc_const_unstable(feature = "const_collections_with_hasher", issue = "102575")] + #[rustc_const_stable(feature = "const_collections_with_hasher", since = "1.85.0")] pub const fn with_hasher(hasher: S) -> HashSet { HashSet { base: base::HashSet::with_hasher(hasher) } } @@ -379,7 +397,7 @@ impl HashSet { /// /// The hash set will be able to hold at least `capacity` elements without /// reallocating. This method is allowed to allocate for more elements than - /// `capacity`. If `capacity` is 0, the hash set will not allocate. + /// `capacity`. If `capacity` is zero, the hash set will not allocate. /// /// Warning: `hasher` is normally randomly generated, and /// is designed to allow `HashSet`s to be resistant to attacks that @@ -387,7 +405,7 @@ impl HashSet { /// manually using this function can expose a DoS attack vector. /// /// The `hash_builder` passed should implement the [`BuildHasher`] trait for - /// the HashMap to be useful, see its documentation for details. + /// the `HashSet` to be useful, see its documentation for details. /// /// # Examples /// @@ -1069,6 +1087,11 @@ impl From<[T; N]> for HashSet where T: Eq + Hash, { + /// Converts a `[T; N]` into a `HashSet`. + /// + /// If the array contains any equal values, + /// all but one will be dropped. + /// /// # Examples /// /// ``` @@ -1361,15 +1384,13 @@ pub struct Drain<'a, K: 'a> { /// # Examples /// /// ``` -/// #![feature(hash_extract_if)] -/// /// use std::collections::HashSet; /// /// let mut a = HashSet::from([1, 2, 3]); /// /// let mut extract_ifed = a.extract_if(|v| v % 2 == 0); /// ``` -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] pub struct ExtractIf<'a, K, F> where F: FnMut(&K) -> bool, @@ -1652,7 +1673,7 @@ impl fmt::Debug for Drain<'_, K> { } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, K, F> where F: FnMut(&K) -> bool, @@ -1669,10 +1690,10 @@ where } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl FusedIterator for ExtractIf<'_, K, F> where F: FnMut(&K) -> bool {} -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl<'a, K, F> fmt::Debug for ExtractIf<'a, K, F> where F: FnMut(&K) -> bool, diff --git a/std/src/env.rs b/std/src/env.rs index 27f4daba44bf6..6961fa8ea947f 100644 --- a/std/src/env.rs +++ b/std/src/env.rs @@ -10,9 +10,6 @@ #![stable(feature = "env", since = "1.0.0")] -#[cfg(test)] -mod tests; - use crate::error::Error; use crate::ffi::{OsStr, OsString}; use crate::path::{Path, PathBuf}; @@ -205,6 +202,9 @@ impl fmt::Debug for VarsOs { /// Returns [`VarError::NotUnicode`] if the variable's value is not valid /// Unicode. If this is not desired, consider using [`var_os`]. /// +/// Use [`env!`] or [`option_env!`] instead if you want to check environment +/// variables at compile time. +/// /// # Examples /// /// ``` @@ -336,7 +336,10 @@ impl Error for VarError { /// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188) /// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2) /// +/// To pass an environment variable to a child process, you can instead use [`Command::env`]. +/// /// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs +/// [`Command::env`]: crate::process::Command::env /// /// # Panics /// @@ -396,7 +399,12 @@ pub unsafe fn set_var, V: AsRef>(key: K, value: V) { /// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188) /// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2) /// +/// To prevent a child process from inheriting an environment variable, you can +/// instead use [`Command::env_remove`] or [`Command::env_clear`]. +/// /// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs +/// [`Command::env_remove`]: crate::process::Command::env_remove +/// [`Command::env_clear`]: crate::process::Command::env_clear /// /// # Panics /// @@ -563,7 +571,7 @@ pub struct JoinPathsError { /// let mut paths = env::split_paths(&path).collect::>(); /// paths.push(PathBuf::from("/home/xyz/bin")); /// let new_path = env::join_paths(paths)?; -/// env::set_var("PATH", &new_path); +/// unsafe { env::set_var("PATH", &new_path); } /// } /// /// Ok(()) @@ -597,6 +605,13 @@ impl Error for JoinPathsError { /// Returns the path of the current user's home directory if known. /// +/// This may return `None` if getting the directory fails or if the platform does not have user home directories. +/// +/// For storing user data and configuration it is often preferable to use more specific directories. +/// For example, [XDG Base Directories] on Unix or the `LOCALAPPDATA` and `APPDATA` environment variables on Windows. +/// +/// [XDG Base Directories]: https://specifications.freedesktop.org/basedir-spec/latest/ +/// /// # Unix /// /// - Returns the value of the 'HOME' environment variable if it is set @@ -608,20 +623,16 @@ impl Error for JoinPathsError { /// /// # Windows /// -/// - Returns the value of the 'HOME' environment variable if it is set -/// (including to an empty string). -/// - Otherwise, returns the value of the 'USERPROFILE' environment variable if it is set -/// (including to an empty string). -/// - If both do not exist, [`GetUserProfileDirectory`][msdn] is used to return the path. +/// - Returns the value of the 'USERPROFILE' environment variable if it is set, and is not an empty string. +/// - Otherwise, [`GetUserProfileDirectory`][msdn] is used to return the path. This may change in the future. /// /// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-getuserprofiledirectorya /// -/// # Deprecation +/// In UWP (Universal Windows Platform) targets this function is unimplemented and always returns `None`. /// -/// This function is deprecated because the behavior on Windows is not correct. -/// The 'HOME' environment variable is not standard on Windows, and may not produce -/// desired results; for instance, under Cygwin or Mingw it will return `/home/you` -/// when it should return `C:\Users\you`. +/// Before Rust 1.85.0, this function used to return the value of the 'HOME' environment variable +/// on Windows, which in Cygwin or Mingw environments could return non-standard paths like `/home/you` +/// instead of `C:\Users\you`. /// /// # Examples /// @@ -633,11 +644,6 @@ impl Error for JoinPathsError { /// None => println!("Impossible to get your home dir!"), /// } /// ``` -#[deprecated( - since = "1.29.0", - note = "This function's behavior may be unexpected on Windows. \ - Consider using a crate from crates.io instead." -)] #[must_use] #[stable(feature = "env", since = "1.0.0")] pub fn home_dir() -> Option { @@ -660,7 +666,9 @@ pub fn home_dir() -> Option { /// On Unix, returns the value of the `TMPDIR` environment variable if it is /// set, otherwise the value is OS-specific: /// - On Android, there is no global temporary folder (it is usually allocated -/// per-app), it returns `/data/local/tmp`. +/// per-app), it will return the application's cache dir if the program runs +/// in application's namespace and system version is Android 13 (or above), or +/// `/data/local/tmp` otherwise. /// - On Darwin-based OSes (macOS, iOS, etc) it returns the directory provided /// by `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)`, as recommended by [Apple's /// security guidelines][appledoc]. diff --git a/std/src/env/tests.rs b/std/src/env/tests.rs deleted file mode 100644 index d021726106872..0000000000000 --- a/std/src/env/tests.rs +++ /dev/null @@ -1,120 +0,0 @@ -use super::*; - -#[test] -#[cfg_attr(any(target_os = "emscripten", target_os = "wasi", target_env = "sgx"), ignore)] -fn test_self_exe_path() { - let path = current_exe(); - assert!(path.is_ok()); - let path = path.unwrap(); - - // Hard to test this function - assert!(path.is_absolute()); -} - -#[test] -fn test() { - assert!((!Path::new("test-path").is_absolute())); - - #[cfg(not(target_env = "sgx"))] - current_dir().unwrap(); -} - -#[test] -#[cfg(windows)] -fn split_paths_windows() { - use crate::path::PathBuf; - - fn check_parse(unparsed: &str, parsed: &[&str]) -> bool { - split_paths(unparsed).collect::>() - == parsed.iter().map(|s| PathBuf::from(*s)).collect::>() - } - - assert!(check_parse("", &mut [""])); - assert!(check_parse(r#""""#, &mut [""])); - assert!(check_parse(";;", &mut ["", "", ""])); - assert!(check_parse(r"c:\", &mut [r"c:\"])); - assert!(check_parse(r"c:\;", &mut [r"c:\", ""])); - assert!(check_parse(r"c:\;c:\Program Files\", &mut [r"c:\", r"c:\Program Files\"])); - assert!(check_parse(r#"c:\;c:\"foo"\"#, &mut [r"c:\", r"c:\foo\"])); - assert!(check_parse(r#"c:\;c:\"foo;bar"\;c:\baz"#, &mut [r"c:\", r"c:\foo;bar\", r"c:\baz"])); -} - -#[test] -#[cfg(unix)] -fn split_paths_unix() { - use crate::path::PathBuf; - - fn check_parse(unparsed: &str, parsed: &[&str]) -> bool { - split_paths(unparsed).collect::>() - == parsed.iter().map(|s| PathBuf::from(*s)).collect::>() - } - - assert!(check_parse("", &mut [""])); - assert!(check_parse("::", &mut ["", "", ""])); - assert!(check_parse("/", &mut ["/"])); - assert!(check_parse("/:", &mut ["/", ""])); - assert!(check_parse("/:/usr/local", &mut ["/", "/usr/local"])); -} - -#[test] -#[cfg(unix)] -fn join_paths_unix() { - use crate::ffi::OsStr; - - fn test_eq(input: &[&str], output: &str) -> bool { - &*join_paths(input.iter().cloned()).unwrap() == OsStr::new(output) - } - - assert!(test_eq(&[], "")); - assert!(test_eq(&["/bin", "/usr/bin", "/usr/local/bin"], "/bin:/usr/bin:/usr/local/bin")); - assert!(test_eq(&["", "/bin", "", "", "/usr/bin", ""], ":/bin:::/usr/bin:")); - assert!(join_paths(["/te:st"].iter().cloned()).is_err()); -} - -#[test] -#[cfg(windows)] -fn join_paths_windows() { - use crate::ffi::OsStr; - - fn test_eq(input: &[&str], output: &str) -> bool { - &*join_paths(input.iter().cloned()).unwrap() == OsStr::new(output) - } - - assert!(test_eq(&[], "")); - assert!(test_eq(&[r"c:\windows", r"c:\"], r"c:\windows;c:\")); - assert!(test_eq(&["", r"c:\windows", "", "", r"c:\", ""], r";c:\windows;;;c:\;")); - assert!(test_eq(&[r"c:\te;st", r"c:\"], r#""c:\te;st";c:\"#)); - assert!(join_paths([r#"c:\te"st"#].iter().cloned()).is_err()); -} - -#[test] -fn args_debug() { - assert_eq!( - format!("Args {{ inner: {:?} }}", args().collect::>()), - format!("{:?}", args()) - ); -} - -#[test] -fn args_os_debug() { - assert_eq!( - format!("ArgsOs {{ inner: {:?} }}", args_os().collect::>()), - format!("{:?}", args_os()) - ); -} - -#[test] -fn vars_debug() { - assert_eq!( - format!("Vars {{ inner: {:?} }}", vars().collect::>()), - format!("{:?}", vars()) - ); -} - -#[test] -fn vars_os_debug() { - assert_eq!( - format!("VarsOs {{ inner: {:?} }}", vars_os().collect::>()), - format!("{:?}", vars_os()) - ); -} diff --git a/std/src/error.rs b/std/src/error.rs index b3e63aaf1c567..def5f984c88e4 100644 --- a/std/src/error.rs +++ b/std/src/error.rs @@ -1,9 +1,6 @@ #![doc = include_str!("../../core/src/error.md")] #![stable(feature = "rust1", since = "1.0.0")] -#[cfg(test)] -mod tests; - #[stable(feature = "rust1", since = "1.0.0")] pub use core::error::Error; #[unstable(feature = "error_generic_member_access", issue = "99301")] diff --git a/std/src/f128.rs b/std/src/f128.rs index e93e915159e40..974514c9c4556 100644 --- a/std/src/f128.rs +++ b/std/src/f128.rs @@ -1,12 +1,9 @@ -//! Constants for the `f128` double-precision floating point type. +//! Constants for the `f128` quadruple-precision floating point type. //! //! *[See also the `f128` primitive type](primitive@f128).* //! //! Mathematically significant numbers are provided in the `consts` sub-module. -#[cfg(test)] -mod tests; - #[unstable(feature = "f128", issue = "116909")] pub use core::f128::consts; @@ -129,7 +126,7 @@ impl f128 { #[unstable(feature = "f128", issue = "116909")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn round_ties_even(self) -> f128 { - unsafe { intrinsics::rintf128(self) } + intrinsics::round_ties_even_f128(self) } /// Returns the integer part of `self`. @@ -227,6 +224,7 @@ impl f128 { /// ``` #[inline] #[rustc_allow_incoherent_impl] + #[doc(alias = "fmaf128", alias = "fusedMultiplyAdd")] #[unstable(feature = "f128", issue = "116909")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn mul_add(self, a: f128, b: f128) -> f128 { @@ -323,6 +321,20 @@ impl f128 { /// /// The precision of this function is non-deterministic. This means it varies by platform, /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// # Examples + /// + /// ``` + /// #![feature(f128)] + /// # #[cfg(reliable_f128_math)] { + /// + /// let x = 2.0_f128; + /// let abs_difference = (x.powi(2) - (x * x)).abs(); + /// assert!(abs_difference <= f128::EPSILON); + /// + /// assert_eq!(f128::powi(f128::NAN, 0), 1.0); + /// # } + /// ``` #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f128", issue = "116909")] @@ -346,8 +358,10 @@ impl f128 { /// /// let x = 2.0_f128; /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); - /// /// assert!(abs_difference <= f128::EPSILON); + /// + /// assert_eq!(f128::powf(1.0, f128::NAN), 1.0); + /// assert_eq!(f128::powf(f128::NAN, 0.0), 1.0); /// # } /// ``` #[inline] @@ -384,6 +398,7 @@ impl f128 { /// # } /// ``` #[inline] + #[doc(alias = "squareRoot")] #[rustc_allow_incoherent_impl] #[unstable(feature = "f128", issue = "116909")] #[must_use = "method returns a new number and does not mutate the original value"] @@ -1211,6 +1226,7 @@ impl f128 { #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f128", issue = "116909")] + // #[unstable(feature = "float_gamma", issue = "99842")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn gamma(self) -> f128 { unsafe { cmath::tgammaf128(self) } @@ -1245,10 +1261,83 @@ impl f128 { #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f128", issue = "116909")] + // #[unstable(feature = "float_gamma", issue = "99842")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn ln_gamma(self) -> (f128, i32) { let mut signgamp: i32 = 0; let x = unsafe { cmath::lgammaf128_r(self, &mut signgamp) }; (x, signgamp) } + + /// Error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erff128` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(f128)] + /// #![feature(float_erf)] + /// # #[cfg(reliable_f128_math)] { + /// /// The error function relates what percent of a normal distribution lies + /// /// within `x` standard deviations (scaled by `1/sqrt(2)`). + /// fn within_standard_deviations(x: f128) -> f128 { + /// (x * std::f128::consts::FRAC_1_SQRT_2).erf() * 100.0 + /// } + /// + /// // 68% of a normal distribution is within one standard deviation + /// assert!((within_standard_deviations(1.0) - 68.269).abs() < 0.01); + /// // 95% of a normal distribution is within two standard deviations + /// assert!((within_standard_deviations(2.0) - 95.450).abs() < 0.01); + /// // 99.7% of a normal distribution is within three standard deviations + /// assert!((within_standard_deviations(3.0) - 99.730).abs() < 0.01); + /// # } + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "f128", issue = "116909")] + // #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erf(self) -> f128 { + unsafe { cmath::erff128(self) } + } + + /// Complementary error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erfcf128` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(f128)] + /// #![feature(float_erf)] + /// # #[cfg(reliable_f128_math)] { + /// let x: f128 = 0.123; + /// + /// let one = x.erf() + x.erfc(); + /// let abs_difference = (one - 1.0).abs(); + /// + /// assert!(abs_difference <= f128::EPSILON); + /// # } + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "f128", issue = "116909")] + // #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erfc(self) -> f128 { + unsafe { cmath::erfcf128(self) } + } } diff --git a/std/src/f16.rs b/std/src/f16.rs index 5b7fcaa28e064..c3b51bf31de70 100644 --- a/std/src/f16.rs +++ b/std/src/f16.rs @@ -1,12 +1,9 @@ -//! Constants for the `f16` double-precision floating point type. +//! Constants for the `f16` half-precision floating point type. //! //! *[See also the `f16` primitive type](primitive@f16).* //! //! Mathematically significant numbers are provided in the `consts` sub-module. -#[cfg(test)] -mod tests; - #[unstable(feature = "f16", issue = "116909")] pub use core::f16::consts; @@ -129,7 +126,7 @@ impl f16 { #[unstable(feature = "f16", issue = "116909")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn round_ties_even(self) -> f16 { - unsafe { intrinsics::rintf16(self) } + intrinsics::round_ties_even_f16(self) } /// Returns the integer part of `self`. @@ -228,6 +225,7 @@ impl f16 { #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f16", issue = "116909")] + #[doc(alias = "fmaf16", alias = "fusedMultiplyAdd")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn mul_add(self, a: f16, b: f16) -> f16 { unsafe { intrinsics::fmaf16(self, a, b) } @@ -323,6 +321,20 @@ impl f16 { /// /// The precision of this function is non-deterministic. This means it varies by platform, /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// # Examples + /// + /// ``` + /// #![feature(f16)] + /// # #[cfg(reliable_f16_math)] { + /// + /// let x = 2.0_f16; + /// let abs_difference = (x.powi(2) - (x * x)).abs(); + /// assert!(abs_difference <= f16::EPSILON); + /// + /// assert_eq!(f16::powi(f16::NAN, 0), 1.0); + /// # } + /// ``` #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f16", issue = "116909")] @@ -346,8 +358,10 @@ impl f16 { /// /// let x = 2.0_f16; /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); - /// /// assert!(abs_difference <= f16::EPSILON); + /// + /// assert_eq!(f16::powf(1.0, f16::NAN), 1.0); + /// assert_eq!(f16::powf(f16::NAN, 0.0), 1.0); /// # } /// ``` #[inline] @@ -384,6 +398,7 @@ impl f16 { /// # } /// ``` #[inline] + #[doc(alias = "squareRoot")] #[rustc_allow_incoherent_impl] #[unstable(feature = "f16", issue = "116909")] #[must_use = "method returns a new number and does not mutate the original value"] @@ -1209,6 +1224,7 @@ impl f16 { #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f16", issue = "116909")] + // #[unstable(feature = "float_gamma", issue = "99842")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn gamma(self) -> f16 { (unsafe { cmath::tgammaf(self as f32) }) as f16 @@ -1243,10 +1259,83 @@ impl f16 { #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f16", issue = "116909")] + // #[unstable(feature = "float_gamma", issue = "99842")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn ln_gamma(self) -> (f16, i32) { let mut signgamp: i32 = 0; let x = (unsafe { cmath::lgammaf_r(self as f32, &mut signgamp) }) as f16; (x, signgamp) } + + /// Error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erff` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(f16)] + /// #![feature(float_erf)] + /// # #[cfg(reliable_f16_math)] { + /// /// The error function relates what percent of a normal distribution lies + /// /// within `x` standard deviations (scaled by `1/sqrt(2)`). + /// fn within_standard_deviations(x: f16) -> f16 { + /// (x * std::f16::consts::FRAC_1_SQRT_2).erf() * 100.0 + /// } + /// + /// // 68% of a normal distribution is within one standard deviation + /// assert!((within_standard_deviations(1.0) - 68.269).abs() < 0.1); + /// // 95% of a normal distribution is within two standard deviations + /// assert!((within_standard_deviations(2.0) - 95.450).abs() < 0.1); + /// // 99.7% of a normal distribution is within three standard deviations + /// assert!((within_standard_deviations(3.0) - 99.730).abs() < 0.1); + /// # } + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "f16", issue = "116909")] + // #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erf(self) -> f16 { + (unsafe { cmath::erff(self as f32) }) as f16 + } + + /// Complementary error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erfcf` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(f16)] + /// #![feature(float_erf)] + /// # #[cfg(reliable_f16_math)] { + /// let x: f16 = 0.123; + /// + /// let one = x.erf() + x.erfc(); + /// let abs_difference = (one - 1.0).abs(); + /// + /// assert!(abs_difference <= f16::EPSILON); + /// # } + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "f16", issue = "116909")] + // #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erfc(self) -> f16 { + (unsafe { cmath::erfcf(self as f32) }) as f16 + } } diff --git a/std/src/f32.rs b/std/src/f32.rs index 7cb285bbff5f7..19fb24c8ee26c 100644 --- a/std/src/f32.rs +++ b/std/src/f32.rs @@ -12,9 +12,6 @@ #![stable(feature = "rust1", since = "1.0.0")] #![allow(missing_docs)] -#[cfg(test)] -mod tests; - #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated, deprecated_in_future)] pub use core::f32::{ @@ -125,7 +122,7 @@ impl f32 { #[stable(feature = "round_ties_even", since = "1.77.0")] #[inline] pub fn round_ties_even(self) -> f32 { - unsafe { intrinsics::rintf32(self) } + intrinsics::round_ties_even_f32(self) } /// Returns the integer part of `self`. @@ -210,6 +207,7 @@ impl f32 { /// assert_eq!(one_plus_eps * one_minus_eps + minus_one, 0.0); /// ``` #[rustc_allow_incoherent_impl] + #[doc(alias = "fmaf", alias = "fusedMultiplyAdd")] #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -305,8 +303,9 @@ impl f32 { /// ``` /// let x = 2.0_f32; /// let abs_difference = (x.powi(2) - (x * x)).abs(); - /// /// assert!(abs_difference <= f32::EPSILON); + /// + /// assert_eq!(f32::powi(f32::NAN, 0), 1.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -328,8 +327,10 @@ impl f32 { /// ``` /// let x = 2.0_f32; /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); - /// /// assert!(abs_difference <= f32::EPSILON); + /// + /// assert_eq!(f32::powf(1.0, f32::NAN), 1.0); + /// assert_eq!(f32::powf(f32::NAN, 0.0), 1.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -360,6 +361,7 @@ impl f32 { /// assert!(negative.sqrt().is_nan()); /// assert!(negative_zero.sqrt() == negative_zero); /// ``` + #[doc(alias = "squareRoot")] #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] @@ -1149,4 +1151,68 @@ impl f32 { let x = unsafe { cmath::lgammaf_r(self, &mut signgamp) }; (x, signgamp) } + + /// Error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erff` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(float_erf)] + /// /// The error function relates what percent of a normal distribution lies + /// /// within `x` standard deviations (scaled by `1/sqrt(2)`). + /// fn within_standard_deviations(x: f32) -> f32 { + /// (x * std::f32::consts::FRAC_1_SQRT_2).erf() * 100.0 + /// } + /// + /// // 68% of a normal distribution is within one standard deviation + /// assert!((within_standard_deviations(1.0) - 68.269).abs() < 0.01); + /// // 95% of a normal distribution is within two standard deviations + /// assert!((within_standard_deviations(2.0) - 95.450).abs() < 0.01); + /// // 99.7% of a normal distribution is within three standard deviations + /// assert!((within_standard_deviations(3.0) - 99.730).abs() < 0.01); + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erf(self) -> f32 { + unsafe { cmath::erff(self) } + } + + /// Complementary error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erfcf` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(float_erf)] + /// let x: f32 = 0.123; + /// + /// let one = x.erf() + x.erfc(); + /// let abs_difference = (one - 1.0).abs(); + /// + /// assert!(abs_difference <= f32::EPSILON); + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erfc(self) -> f32 { + unsafe { cmath::erfcf(self) } + } } diff --git a/std/src/f64.rs b/std/src/f64.rs index 47163c272de32..f1c3cb561271a 100644 --- a/std/src/f64.rs +++ b/std/src/f64.rs @@ -12,9 +12,6 @@ #![stable(feature = "rust1", since = "1.0.0")] #![allow(missing_docs)] -#[cfg(test)] -mod tests; - #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated, deprecated_in_future)] pub use core::f64::{ @@ -125,7 +122,7 @@ impl f64 { #[stable(feature = "round_ties_even", since = "1.77.0")] #[inline] pub fn round_ties_even(self) -> f64 { - unsafe { intrinsics::rintf64(self) } + intrinsics::round_ties_even_f64(self) } /// Returns the integer part of `self`. @@ -210,6 +207,7 @@ impl f64 { /// assert_eq!(one_plus_eps * one_minus_eps + minus_one, 0.0); /// ``` #[rustc_allow_incoherent_impl] + #[doc(alias = "fma", alias = "fusedMultiplyAdd")] #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -305,8 +303,9 @@ impl f64 { /// ``` /// let x = 2.0_f64; /// let abs_difference = (x.powi(2) - (x * x)).abs(); + /// assert!(abs_difference <= f64::EPSILON); /// - /// assert!(abs_difference < 1e-10); + /// assert_eq!(f64::powi(f64::NAN, 0), 1.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -328,8 +327,10 @@ impl f64 { /// ``` /// let x = 2.0_f64; /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); + /// assert!(abs_difference <= f64::EPSILON); /// - /// assert!(abs_difference < 1e-10); + /// assert_eq!(f64::powf(1.0, f64::NAN), 1.0); + /// assert_eq!(f64::powf(f64::NAN, 0.0), 1.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -360,6 +361,7 @@ impl f64 { /// assert!(negative.sqrt().is_nan()); /// assert!(negative_zero.sqrt() == negative_zero); /// ``` + #[doc(alias = "squareRoot")] #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] @@ -1149,4 +1151,68 @@ impl f64 { let x = unsafe { cmath::lgamma_r(self, &mut signgamp) }; (x, signgamp) } + + /// Error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erf` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(float_erf)] + /// /// The error function relates what percent of a normal distribution lies + /// /// within `x` standard deviations (scaled by `1/sqrt(2)`). + /// fn within_standard_deviations(x: f64) -> f64 { + /// (x * std::f64::consts::FRAC_1_SQRT_2).erf() * 100.0 + /// } + /// + /// // 68% of a normal distribution is within one standard deviation + /// assert!((within_standard_deviations(1.0) - 68.269).abs() < 0.01); + /// // 95% of a normal distribution is within two standard deviations + /// assert!((within_standard_deviations(2.0) - 95.450).abs() < 0.01); + /// // 99.7% of a normal distribution is within three standard deviations + /// assert!((within_standard_deviations(3.0) - 99.730).abs() < 0.01); + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erf(self) -> f64 { + unsafe { cmath::erf(self) } + } + + /// Complementary error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erfc` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(float_erf)] + /// let x: f64 = 0.123; + /// + /// let one = x.erf() + x.erfc(); + /// let abs_difference = (one - 1.0).abs(); + /// + /// assert!(abs_difference <= f64::EPSILON); + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erfc(self) -> f64 { + unsafe { cmath::erfc(self) } + } } diff --git a/std/src/ffi/mod.rs b/std/src/ffi/mod.rs index 469136be8838a..860ec3a6be16e 100644 --- a/std/src/ffi/mod.rs +++ b/std/src/ffi/mod.rs @@ -179,19 +179,19 @@ pub use core::ffi::{ c_ulong, c_ulonglong, c_ushort, }; -#[doc(no_inline)] +#[doc(inline)] #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] pub use self::c_str::FromBytesUntilNulError; -#[doc(no_inline)] +#[doc(inline)] #[stable(feature = "cstr_from_bytes", since = "1.10.0")] pub use self::c_str::FromBytesWithNulError; -#[doc(no_inline)] +#[doc(inline)] #[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")] pub use self::c_str::FromVecWithNulError; -#[doc(no_inline)] +#[doc(inline)] #[stable(feature = "cstring_into", since = "1.7.0")] pub use self::c_str::IntoStringError; -#[doc(no_inline)] +#[doc(inline)] #[stable(feature = "rust1", since = "1.0.0")] pub use self::c_str::NulError; #[doc(inline)] @@ -201,5 +201,5 @@ pub use self::c_str::{CStr, CString}; #[doc(inline)] pub use self::os_str::{OsStr, OsString}; -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] pub mod os_str; diff --git a/std/src/ffi/os_str.rs b/std/src/ffi/os_str.rs index 328185d1f2b0c..aa25ff5293c71 100644 --- a/std/src/ffi/os_str.rs +++ b/std/src/ffi/os_str.rs @@ -203,8 +203,8 @@ impl OsString { self } - /// Converts the `OsString` into a byte slice. To convert the byte slice back into an - /// `OsString`, use the [`OsStr::from_encoded_bytes_unchecked`] function. + /// Converts the `OsString` into a byte vector. To convert the byte vector back into an + /// `OsString`, use the [`OsString::from_encoded_bytes_unchecked`] function. /// /// The byte encoding is an unspecified, platform-specific, self-synchronizing superset of UTF-8. /// By being a self-synchronizing superset of UTF-8, this encoding is also a superset of 7-bit @@ -257,7 +257,30 @@ impl OsString { #[inline] #[rustc_confusables("append", "put")] pub fn push>(&mut self, s: T) { - self.inner.push_slice(&s.as_ref().inner) + trait SpecPushTo { + fn spec_push_to(&self, buf: &mut OsString); + } + + impl> SpecPushTo for T { + #[inline] + default fn spec_push_to(&self, buf: &mut OsString) { + buf.inner.push_slice(&self.as_ref().inner); + } + } + + // Use a more efficient implementation when the string is UTF-8. + macro spec_str($T:ty) { + impl SpecPushTo for $T { + #[inline] + fn spec_push_to(&self, buf: &mut OsString) { + buf.inner.push_str(self); + } + } + } + spec_str!(str); + spec_str!(String); + + s.spec_push_to(self) } /// Creates a new `OsString` with at least the given capacity. @@ -550,7 +573,7 @@ impl OsString { OsStr::from_inner_mut(self.inner.leak()) } - /// Truncate the the `OsString` to the specified length. + /// Truncate the `OsString` to the specified length. /// /// # Panics /// Panics if `len` does not lie on a valid `OsStr` boundary @@ -587,7 +610,30 @@ impl> From<&T> for OsString { /// Copies any value implementing [AsRef]<[OsStr]> /// into a newly allocated [`OsString`]. fn from(s: &T) -> OsString { - s.as_ref().to_os_string() + trait SpecToOsString { + fn spec_to_os_string(&self) -> OsString; + } + + impl> SpecToOsString for T { + #[inline] + default fn spec_to_os_string(&self) -> OsString { + self.as_ref().to_os_string() + } + } + + // Preserve the known-UTF-8 property for strings. + macro spec_str($T:ty) { + impl SpecToOsString for $T { + #[inline] + fn spec_to_os_string(&self) -> OsString { + OsString::from(String::from(self)) + } + } + } + spec_str!(str); + spec_str!(String); + + s.spec_to_os_string() } } @@ -1204,13 +1250,12 @@ impl OsStr { /// # Examples /// /// ``` - /// #![feature(os_str_display)] /// use std::ffi::OsStr; /// /// let s = OsStr::new("Hello, world!"); /// println!("{}", s.display()); /// ``` - #[unstable(feature = "os_str_display", issue = "120048")] + #[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this does not display the `OsStr`; \ it returns an object that can be displayed"] #[inline] @@ -1229,7 +1274,7 @@ impl From<&OsStr> for Box { } } -#[stable(feature = "box_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "box_from_mut_slice", since = "1.84.0")] impl From<&mut OsStr> for Box { /// Copies the string into a newly allocated [Box]<[OsStr]>. #[inline] @@ -1309,7 +1354,7 @@ impl From<&OsStr> for Arc { } } -#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "shared_from_mut_slice", since = "1.84.0")] impl From<&mut OsStr> for Arc { /// Copies the string into a newly allocated [Arc]<[OsStr]>. #[inline] @@ -1339,7 +1384,7 @@ impl From<&OsStr> for Rc { } } -#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "shared_from_mut_slice", since = "1.84.0")] impl From<&mut OsStr> for Rc { /// Copies the string into a newly allocated [Rc]<[OsStr]>. #[inline] @@ -1559,7 +1604,6 @@ impl fmt::Debug for OsStr { /// # Examples /// /// ``` -/// #![feature(os_str_display)] /// use std::ffi::OsStr; /// /// let s = OsStr::new("Hello, world!"); @@ -1568,19 +1612,19 @@ impl fmt::Debug for OsStr { /// /// [`Display`]: fmt::Display /// [`format!`]: crate::format -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] pub struct Display<'a> { os_str: &'a OsStr, } -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] impl fmt::Debug for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.os_str, f) } } -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.os_str.inner, f) diff --git a/std/src/ffi/os_str/tests.rs b/std/src/ffi/os_str/tests.rs index cbec44c862646..2572b71fd9ac6 100644 --- a/std/src/ffi/os_str/tests.rs +++ b/std/src/ffi/os_str/tests.rs @@ -295,7 +295,7 @@ fn clone_to_uninit() { let mut storage = vec![MaybeUninit::::uninit(); size_of_val::(a)]; unsafe { a.clone_to_uninit(ptr::from_mut::<[_]>(storage.as_mut_slice()).cast()) }; - assert_eq!(a.as_encoded_bytes(), unsafe { MaybeUninit::slice_assume_init_ref(&storage) }); + assert_eq!(a.as_encoded_bytes(), unsafe { storage.assume_init_ref() }); let mut b: Box = OsStr::new("world.exe").into(); assert_eq!(size_of_val::(a), size_of_val::(&b)); diff --git a/std/src/fs.rs b/std/src/fs.rs index d846a4e5f0916..46b5860123fc1 100644 --- a/std/src/fs.rs +++ b/std/src/fs.rs @@ -624,20 +624,23 @@ impl File { self.inner.datasync() } - /// Acquire an exclusive advisory lock on the file. Blocks until the lock can be acquired. + /// Acquire an exclusive lock on the file. Blocks until the lock can be acquired. /// - /// This acquires an exclusive advisory lock; no other file handle to this file may acquire - /// another lock. + /// This acquires an exclusive lock; no other file handle to this file may acquire another lock. /// - /// If this file handle, or a clone of it, already holds an advisory lock the exact behavior is - /// unspecified and platform dependent, including the possibility that it will deadlock. + /// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`], + /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with + /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not + /// cause non-lockholders to block. + /// + /// If this file handle/descriptor, or a clone of it, already holds an lock the exact behavior + /// is unspecified and platform dependent, including the possibility that it will deadlock. /// However, if this method returns, then an exclusive lock is held. /// /// If the file not open for writing, it is unspecified whether this function returns an error. /// - /// Note, this is an advisory lock meant to interact with [`lock_shared`], [`try_lock`], - /// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`] - /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block. + /// The lock will be released when this file (along with any other file descriptors/handles + /// duplicated or inherited from it) is closed, or if the [`unlock`] method is called. /// /// # Platform-specific behavior /// @@ -645,8 +648,12 @@ impl File { /// and the `LockFileEx` function on Windows with the `LOCKFILE_EXCLUSIVE_LOCK` flag. Note that, /// this [may change in the future][changes]. /// + /// On Windows, locking a file will fail if the file is opened only for append. To lock a file, + /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`. + /// /// [changes]: io#platform-specific-behavior /// + /// [`lock`]: File::lock /// [`lock_shared`]: File::lock_shared /// [`try_lock`]: File::try_lock /// [`try_lock_shared`]: File::try_lock_shared @@ -657,32 +664,35 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { - /// let f = File::open("foo.txt")?; + /// let f = File::create("foo.txt")?; /// f.lock()?; /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn lock(&self) -> io::Result<()> { self.inner.lock() } - /// Acquire a shared advisory lock on the file. Blocks until the lock can be acquired. + /// Acquire a shared (non-exclusive) lock on the file. Blocks until the lock can be acquired. /// - /// This acquires a shared advisory lock; more than one file handle may hold a shared lock, but - /// none may hold an exclusive lock. + /// This acquires a shared lock; more than one file handle may hold a shared lock, but none may + /// hold an exclusive lock at the same time. /// - /// If this file handle, or a clone of it, already holds an advisory lock, the exact behavior is - /// unspecified and platform dependent, including the possibility that it will deadlock. + /// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`], + /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with + /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not + /// cause non-lockholders to block. + /// + /// If this file handle/descriptor, or a clone of it, already holds an lock, the exact behavior + /// is unspecified and platform dependent, including the possibility that it will deadlock. /// However, if this method returns, then a shared lock is held. /// - /// Note, this is an advisory lock meant to interact with [`lock`], [`try_lock`], - /// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`] - /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block. + /// The lock will be released when this file (along with any other file descriptors/handles + /// duplicated or inherited from it) is closed, or if the [`unlock`] method is called. /// /// # Platform-specific behavior /// @@ -690,9 +700,13 @@ impl File { /// and the `LockFileEx` function on Windows. Note that, this /// [may change in the future][changes]. /// + /// On Windows, locking a file will fail if the file is opened only for append. To lock a file, + /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`. + /// /// [changes]: io#platform-specific-behavior /// /// [`lock`]: File::lock + /// [`lock_shared`]: File::lock_shared /// [`try_lock`]: File::try_lock /// [`try_lock_shared`]: File::try_lock_shared /// [`unlock`]: File::unlock @@ -702,7 +716,6 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { @@ -711,25 +724,31 @@ impl File { /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn lock_shared(&self) -> io::Result<()> { self.inner.lock_shared() } - /// Acquire an exclusive advisory lock on the file. Returns `Ok(false)` if the file is locked. + /// Try to acquire an exclusive lock on the file. /// - /// This acquires an exclusive advisory lock; no other file handle to this file may acquire - /// another lock. + /// Returns `Ok(false)` if a different lock is already held on this file (via another + /// handle/descriptor). /// - /// If this file handle, or a clone of it, already holds an advisory lock, the exact behavior is - /// unspecified and platform dependent, including the possibility that it will deadlock. - /// However, if this method returns, then an exclusive lock is held. + /// This acquires an exclusive lock; no other file handle to this file may acquire another lock. + /// + /// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`], + /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with + /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not + /// cause non-lockholders to block. + /// + /// If this file handle/descriptor, or a clone of it, already holds an lock, the exact behavior + /// is unspecified and platform dependent, including the possibility that it will deadlock. + /// However, if this method returns `Ok(true)`, then it has acquired an exclusive lock. /// /// If the file not open for writing, it is unspecified whether this function returns an error. /// - /// Note, this is an advisory lock meant to interact with [`lock`], [`lock_shared`], - /// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`] - /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block. + /// The lock will be released when this file (along with any other file descriptors/handles + /// duplicated or inherited from it) is closed, or if the [`unlock`] method is called. /// /// # Platform-specific behavior /// @@ -738,10 +757,14 @@ impl File { /// and `LOCKFILE_FAIL_IMMEDIATELY` flags. Note that, this /// [may change in the future][changes]. /// + /// On Windows, locking a file will fail if the file is opened only for append. To lock a file, + /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`. + /// /// [changes]: io#platform-specific-behavior /// /// [`lock`]: File::lock /// [`lock_shared`]: File::lock_shared + /// [`try_lock`]: File::try_lock /// [`try_lock_shared`]: File::try_lock_shared /// [`unlock`]: File::unlock /// [`read`]: Read::read @@ -750,33 +773,38 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { - /// let f = File::open("foo.txt")?; + /// let f = File::create("foo.txt")?; /// f.try_lock()?; /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn try_lock(&self) -> io::Result { self.inner.try_lock() } - /// Acquire a shared advisory lock on the file. - /// Returns `Ok(false)` if the file is exclusively locked. + /// Try to acquire a shared (non-exclusive) lock on the file. /// - /// This acquires a shared advisory lock; more than one file handle may hold a shared lock, but - /// none may hold an exclusive lock. + /// Returns `Ok(false)` if an exclusive lock is already held on this file (via another + /// handle/descriptor). /// - /// If this file handle, or a clone of it, already holds an advisory lock, the exact behavior is + /// This acquires a shared lock; more than one file handle may hold a shared lock, but none may + /// hold an exclusive lock at the same time. + /// + /// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`], + /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with + /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not + /// cause non-lockholders to block. + /// + /// If this file handle, or a clone of it, already holds an lock, the exact behavior is /// unspecified and platform dependent, including the possibility that it will deadlock. - /// However, if this method returns, then a shared lock is held. + /// However, if this method returns `Ok(true)`, then it has acquired a shared lock. /// - /// Note, this is an advisory lock meant to interact with [`lock`], [`try_lock`], - /// [`try_lock`], and [`unlock`]. Its interactions with other methods, such as [`read`] - /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block. + /// The lock will be released when this file (along with any other file descriptors/handles + /// duplicated or inherited from it) is closed, or if the [`unlock`] method is called. /// /// # Platform-specific behavior /// @@ -785,11 +813,15 @@ impl File { /// `LOCKFILE_FAIL_IMMEDIATELY` flag. Note that, this /// [may change in the future][changes]. /// + /// On Windows, locking a file will fail if the file is opened only for append. To lock a file, + /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`. + /// /// [changes]: io#platform-specific-behavior /// /// [`lock`]: File::lock /// [`lock_shared`]: File::lock_shared /// [`try_lock`]: File::try_lock + /// [`try_lock_shared`]: File::try_lock_shared /// [`unlock`]: File::unlock /// [`read`]: Read::read /// [`write`]: Write::write @@ -797,7 +829,6 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { @@ -806,14 +837,19 @@ impl File { /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn try_lock_shared(&self) -> io::Result { self.inner.try_lock_shared() } /// Release all locks on the file. /// - /// All remaining locks are released when the file handle, and all clones of it, are dropped. + /// All locks are released when the file (along with any other file descriptors/handles + /// duplicated or inherited from it) is closed. This method allows releasing locks without + /// closing the file. + /// + /// If no lock is currently held via this file descriptor/handle, this method may return an + /// error, or may return successfully without taking any action. /// /// # Platform-specific behavior /// @@ -821,12 +857,14 @@ impl File { /// and the `UnlockFile` function on Windows. Note that, this /// [may change in the future][changes]. /// + /// On Windows, locking a file will fail if the file is opened only for append. To lock a file, + /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`. + /// /// [changes]: io#platform-specific-behavior /// /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { @@ -836,7 +874,7 @@ impl File { /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn unlock(&self) -> io::Result<()> { self.inner.unlock() } @@ -1206,6 +1244,9 @@ impl Seek for &File { fn seek(&mut self, pos: SeekFrom) -> io::Result { self.inner.seek(pos) } + fn stream_position(&mut self) -> io::Result { + self.inner.tell() + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1252,6 +1293,9 @@ impl Seek for File { fn seek(&mut self, pos: SeekFrom) -> io::Result { (&*self).seek(pos) } + fn stream_position(&mut self) -> io::Result { + (&*self).stream_position() + } } #[stable(feature = "io_traits_arc", since = "1.73.0")] @@ -1869,8 +1913,10 @@ impl Permissions { /// /// # Note /// - /// This function does not take Access Control Lists (ACLs) or Unix group - /// membership into account. + /// This function does not take Access Control Lists (ACLs), Unix group + /// membership and other nuances into account. + /// Therefore the return value of this function cannot be relied upon + /// to predict whether attempts to read or write the file will actually succeed. /// /// # Windows /// @@ -1885,10 +1931,13 @@ impl Permissions { /// # Unix (including macOS) /// /// On Unix-based platforms this checks if *any* of the owner, group or others - /// write permission bits are set. It does not check if the current - /// user is in the file's assigned group. It also does not check ACLs. - /// Therefore the return value of this function cannot be relied upon - /// to predict whether attempts to read or write the file will actually succeed. + /// write permission bits are set. It does not consider anything else, including: + /// + /// * Whether the current user is in the file's assigned group. + /// * Permissions granted by ACL. + /// * That `root` user can write to files that do not have any write bits set. + /// * Writable files on a filesystem that is mounted read-only. + /// /// The [`PermissionsExt`] trait gives direct access to the permission bits but /// also does not read ACLs. /// @@ -2279,8 +2328,8 @@ impl AsInner for DirEntry { /// /// # Platform-specific behavior /// -/// This function currently corresponds to the `unlink` function on Unix -/// and the `DeleteFile` function on Windows. +/// This function currently corresponds to the `unlink` function on Unix. +/// On Windows, `DeleteFile` is used or `CreateFileW` and `SetInformationByHandle` for readonly files. /// Note that, this [may change in the future][changes]. /// /// [changes]: io#platform-specific-behavior @@ -2397,12 +2446,14 @@ pub fn symlink_metadata>(path: P) -> io::Result { /// # Platform-specific behavior /// /// This function currently corresponds to the `rename` function on Unix -/// and the `MoveFileEx` function with the `MOVEFILE_REPLACE_EXISTING` flag on Windows. +/// and the `MoveFileExW` or `SetFileInformationByHandle` function on Windows. /// /// Because of this, the behavior when both `from` and `to` exist differs. On /// Unix, if `from` is a directory, `to` must also be an (empty) directory. If -/// `from` is not a directory, `to` must also be not a directory. In contrast, -/// on Windows, `from` can be anything, but `to` must *not* be a directory. +/// `from` is not a directory, `to` must also be not a directory. The behavior +/// on Windows is the same on Windows 10 1607 and higher if `FileRenameInfoEx` +/// is supported by the filesystem; otherwise, `from` can be anything, but +/// `to` must *not* be a directory. /// /// Note that, this [may change in the future][changes]. /// @@ -2475,6 +2526,7 @@ pub fn rename, Q: AsRef>(from: P, to: Q) -> io::Result<()> /// * `from` does not exist. /// * The current process does not have the permission rights to read /// `from` or write `to`. +/// * The parent directory of `to` doesn't exist. /// /// # Examples /// @@ -2522,6 +2574,7 @@ pub fn copy, Q: AsRef>(from: P, to: Q) -> io::Result { /// limited to just these cases: /// /// * The `original` path is not a file or doesn't exist. +/// * The 'link' path already exists. /// /// # Examples /// @@ -2804,9 +2857,11 @@ pub fn remove_dir>(path: P) -> io::Result<()> { /// /// See [`fs::remove_file`] and [`fs::remove_dir`]. /// -/// `remove_dir_all` will fail if `remove_dir` or `remove_file` fail on any constituent paths, including the root `path`. -/// As a result, the directory you are deleting must exist, meaning that this function is not idempotent. -/// Additionally, `remove_dir_all` will also fail if the `path` is not a directory. +/// [`remove_dir_all`] will fail if [`remove_dir`] or [`remove_file`] fail on *any* constituent +/// paths, *including* the root `path`. Consequently, +/// +/// - The directory you are deleting *must* exist, meaning that this function is *not idempotent*. +/// - [`remove_dir_all`] will fail if the `path` is *not* a directory. /// /// Consider ignoring the error if validating the removal is not required for your use case. /// @@ -3020,7 +3075,7 @@ impl DirBuilder { match path.parent() { Some(p) => self.create_dir_all(p)?, None => { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::Uncategorized, "failed to create whole tree", )); diff --git a/std/src/fs/tests.rs b/std/src/fs/tests.rs index 018e19586418e..6dd18e4f4c837 100644 --- a/std/src/fs/tests.rs +++ b/std/src/fs/tests.rs @@ -1,5 +1,6 @@ use rand::RngCore; +use crate::char::MAX_LEN_UTF8; use crate::fs::{self, File, FileTimes, OpenOptions}; use crate::io::prelude::*; use crate::io::{BorrowedBuf, ErrorKind, SeekFrom}; @@ -14,7 +15,7 @@ use crate::os::unix::fs::symlink as junction_point; use crate::os::windows::fs::{OpenOptionsExt, junction_point, symlink_dir, symlink_file}; use crate::path::Path; use crate::sync::Arc; -use crate::sys_common::io::test::{TempDir, tmpdir}; +use crate::test_helpers::{TempDir, tmpdir}; use crate::time::{Duration, Instant, SystemTime}; use crate::{env, str, thread}; @@ -155,7 +156,7 @@ fn file_test_io_non_positional_read() { #[test] fn file_test_io_seek_and_tell_smoke_test() { let message = "ten-four"; - let mut read_mem = [0; 4]; + let mut read_mem = [0; MAX_LEN_UTF8]; let set_cursor = 4 as u64; let tell_pos_pre_read; let tell_pos_post_read; @@ -356,7 +357,7 @@ fn file_test_io_seek_shakedown() { let chunk_one: &str = "qwer"; let chunk_two: &str = "asdf"; let chunk_three: &str = "zxcv"; - let mut read_mem = [0; 4]; + let mut read_mem = [0; MAX_LEN_UTF8]; let tmpdir = tmpdir(); let filename = &tmpdir.join("file_rt_io_file_test_seek_shakedown.txt"); { @@ -621,7 +622,7 @@ fn file_test_directoryinfo_readdir() { check!(w.write(msg)); } let files = check!(fs::read_dir(dir)); - let mut mem = [0; 4]; + let mut mem = [0; MAX_LEN_UTF8]; for f in files { let f = f.unwrap().path(); { @@ -1384,7 +1385,7 @@ fn file_try_clone() { } #[test] -#[cfg(not(windows))] +#[cfg(not(target_vendor = "win7"))] fn unlink_readonly() { let tmpdir = tmpdir(); let path = tmpdir.join("file"); @@ -1877,7 +1878,7 @@ fn windows_unix_socket_exists() { let bytes = socket_path.as_os_str().as_encoded_bytes(); let bytes = core::slice::from_raw_parts(bytes.as_ptr().cast::(), bytes.len()); addr.sun_path[..bytes.len()].copy_from_slice(bytes); - let len = mem::size_of_val(&addr) as i32; + let len = size_of_val(&addr) as i32; let result = c::bind(socket, (&raw const addr).cast::(), len); c::closesocket(socket); assert_eq!(result, 0); @@ -1912,3 +1913,81 @@ fn test_hidden_file_truncation() { let metadata = file.metadata().unwrap(); assert_eq!(metadata.len(), 0); } + +// See https://github.com/rust-lang/rust/pull/131072 for more details about why +// these two tests are disabled under Windows 7 here. +#[cfg(windows)] +#[test] +#[cfg_attr(target_vendor = "win7", ignore = "Unsupported under Windows 7.")] +fn test_rename_file_over_open_file() { + // Make sure that std::fs::rename works if the target file is already opened with FILE_SHARE_DELETE. See #123985. + let tmpdir = tmpdir(); + + // Create source with test data to read. + let source_path = tmpdir.join("source_file.txt"); + fs::write(&source_path, b"source hello world").unwrap(); + + // Create target file with test data to read; + let target_path = tmpdir.join("target_file.txt"); + fs::write(&target_path, b"target hello world").unwrap(); + + // Open target file + let target_file = fs::File::open(&target_path).unwrap(); + + // Rename source + fs::rename(source_path, &target_path).unwrap(); + + core::mem::drop(target_file); + assert_eq!(fs::read(target_path).unwrap(), b"source hello world"); +} + +#[test] +#[cfg(windows)] +#[cfg_attr(target_vendor = "win7", ignore = "Unsupported under Windows 7.")] +fn test_rename_directory_to_non_empty_directory() { + // Renaming a directory over a non-empty existing directory should fail on Windows. + let tmpdir: TempDir = tmpdir(); + + let source_path = tmpdir.join("source_directory"); + let target_path = tmpdir.join("target_directory"); + + fs::create_dir(&source_path).unwrap(); + fs::create_dir(&target_path).unwrap(); + + fs::write(target_path.join("target_file.txt"), b"target hello world").unwrap(); + + error!(fs::rename(source_path, target_path), 145); // ERROR_DIR_NOT_EMPTY +} + +#[test] +fn test_rename_symlink() { + let tmpdir = tmpdir(); + if !got_symlink_permission(&tmpdir) { + return; + }; + + let original = tmpdir.join("original"); + let dest = tmpdir.join("dest"); + let not_exist = Path::new("does not exist"); + + symlink_file(not_exist, &original).unwrap(); + fs::rename(&original, &dest).unwrap(); + // Make sure that renaming `original` to `dest` preserves the symlink. + assert_eq!(fs::read_link(&dest).unwrap().as_path(), not_exist); +} + +#[test] +#[cfg(windows)] +fn test_rename_junction() { + let tmpdir = tmpdir(); + let original = tmpdir.join("original"); + let dest = tmpdir.join("dest"); + let not_exist = Path::new("does not exist"); + + junction_point(¬_exist, &original).unwrap(); + fs::rename(&original, &dest).unwrap(); + + // Make sure that renaming `original` to `dest` preserves the junction point. + // Junction links are always absolute so we just check the file name is correct. + assert_eq!(fs::read_link(&dest).unwrap().file_name(), Some(not_exist.as_os_str())); +} diff --git a/std/src/io/buffered/bufreader.rs b/std/src/io/buffered/bufreader.rs index 8b46738ab8aee..697fb5974a3dd 100644 --- a/std/src/io/buffered/bufreader.rs +++ b/std/src/io/buffered/bufreader.rs @@ -118,16 +118,16 @@ impl BufReader { /// #![feature(bufreader_peek)] /// use std::io::{Read, BufReader}; /// - /// let mut bytes = &b"oh, hello"[..]; + /// let mut bytes = &b"oh, hello there"[..]; /// let mut rdr = BufReader::with_capacity(6, &mut bytes); /// assert_eq!(rdr.peek(2).unwrap(), b"oh"); /// let mut buf = [0; 4]; /// rdr.read(&mut buf[..]).unwrap(); /// assert_eq!(&buf, b"oh, "); - /// assert_eq!(rdr.peek(2).unwrap(), b"he"); + /// assert_eq!(rdr.peek(5).unwrap(), b"hello"); /// let mut s = String::new(); /// rdr.read_to_string(&mut s).unwrap(); - /// assert_eq!(&s, "hello"); + /// assert_eq!(&s, "hello there"); /// assert_eq!(rdr.peek(1).unwrap().len(), 0); /// ``` #[unstable(feature = "bufreader_peek", issue = "128405")] diff --git a/std/src/io/buffered/bufreader/buffer.rs b/std/src/io/buffered/bufreader/buffer.rs index 52fe49985c65a..9fd2472ebdfdb 100644 --- a/std/src/io/buffered/bufreader/buffer.rs +++ b/std/src/io/buffered/bufreader/buffer.rs @@ -41,7 +41,7 @@ impl Buffer { match Box::try_new_uninit_slice(capacity) { Ok(buf) => Ok(Self { buf, pos: 0, filled: 0, initialized: 0 }), Err(_) => { - Err(io::const_io_error!(ErrorKind::OutOfMemory, "failed to allocate read buffer")) + Err(io::const_error!(ErrorKind::OutOfMemory, "failed to allocate read buffer")) } } } @@ -50,7 +50,7 @@ impl Buffer { pub fn buffer(&self) -> &[u8] { // SAFETY: self.pos and self.cap are valid, and self.cap => self.pos, and // that region is initialized because those are all invariants of this type. - unsafe { MaybeUninit::slice_assume_init_ref(self.buf.get_unchecked(self.pos..self.filled)) } + unsafe { self.buf.get_unchecked(self.pos..self.filled).assume_init_ref() } } #[inline] @@ -109,8 +109,8 @@ impl Buffer { /// Read more bytes into the buffer without discarding any of its contents pub fn read_more(&mut self, mut reader: impl Read) -> io::Result { - let mut buf = BorrowedBuf::from(&mut self.buf[self.pos..]); - let old_init = self.initialized - self.pos; + let mut buf = BorrowedBuf::from(&mut self.buf[self.filled..]); + let old_init = self.initialized - self.filled; unsafe { buf.set_init(old_init); } diff --git a/std/src/io/buffered/bufwriter.rs b/std/src/io/buffered/bufwriter.rs index c41bae2aa4e81..574eb83dc5649 100644 --- a/std/src/io/buffered/bufwriter.rs +++ b/std/src/io/buffered/bufwriter.rs @@ -96,7 +96,7 @@ impl BufWriter { pub(crate) fn try_new_buffer() -> io::Result> { Vec::try_with_capacity(DEFAULT_BUF_SIZE).map_err(|_| { - io::const_io_error!(ErrorKind::OutOfMemory, "failed to allocate write buffer") + io::const_error!(ErrorKind::OutOfMemory, "failed to allocate write buffer") }) } @@ -238,7 +238,7 @@ impl BufWriter { match r { Ok(0) => { - return Err(io::const_io_error!( + return Err(io::const_error!( ErrorKind::WriteZero, "failed to write the buffered data", )); diff --git a/std/src/io/buffered/linewritershim.rs b/std/src/io/buffered/linewritershim.rs index 3d04ccd1c7d81..5ebeada59bb53 100644 --- a/std/src/io/buffered/linewritershim.rs +++ b/std/src/io/buffered/linewritershim.rs @@ -119,7 +119,14 @@ impl<'a, W: ?Sized + Write> Write for LineWriterShim<'a, W> { // the buffer? // - If not, scan for the last newline that *does* fit in the buffer let tail = if flushed >= newline_idx { - &buf[flushed..] + let tail = &buf[flushed..]; + // Avoid unnecessary short writes by not splitting the remaining + // bytes if they're larger than the buffer. + // They can be written in full by the next call to write. + if tail.len() >= self.buffer.capacity() { + return Ok(flushed); + } + tail } else if newline_idx - flushed <= self.buffer.capacity() { &buf[flushed..newline_idx] } else { diff --git a/std/src/io/buffered/tests.rs b/std/src/io/buffered/tests.rs index bff0f823c4b5a..17f6107aa030c 100644 --- a/std/src/io/buffered/tests.rs +++ b/std/src/io/buffered/tests.rs @@ -847,8 +847,7 @@ fn long_line_flushed() { } /// Test that, given a very long partial line *after* successfully -/// flushing a complete line, the very long partial line is buffered -/// unconditionally, and no additional writes take place. This assures +/// flushing a complete line, no additional writes take place. This assures /// the property that `write` should make at-most-one attempt to write /// new data. #[test] @@ -856,13 +855,22 @@ fn line_long_tail_not_flushed() { let writer = ProgrammableSink::default(); let mut writer = LineWriter::with_capacity(5, writer); - // Assert that Line 1\n is flushed, and 01234 is buffered - assert_eq!(writer.write(b"Line 1\n0123456789").unwrap(), 12); + // Assert that Line 1\n is flushed and the long tail isn't. + let bytes = b"Line 1\n0123456789"; + writer.write(bytes).unwrap(); assert_eq!(&writer.get_ref().buffer, b"Line 1\n"); +} + +// Test that appending to a full buffer emits a single write, flushing the buffer. +#[test] +fn line_full_buffer_flushed() { + let writer = ProgrammableSink::default(); + let mut writer = LineWriter::with_capacity(5, writer); + assert_eq!(writer.write(b"01234").unwrap(), 5); // Because the buffer is full, this subsequent write will flush it assert_eq!(writer.write(b"5").unwrap(), 1); - assert_eq!(&writer.get_ref().buffer, b"Line 1\n01234"); + assert_eq!(&writer.get_ref().buffer, b"01234"); } /// Test that, if an attempt to pre-flush buffered data returns Ok(0), diff --git a/std/src/io/copy/tests.rs b/std/src/io/copy/tests.rs index 2e0eb6cdce666..25b1ece2745b9 100644 --- a/std/src/io/copy/tests.rs +++ b/std/src/io/copy/tests.rs @@ -126,6 +126,7 @@ mod io_benches { use crate::io::prelude::*; #[bench] + #[cfg_attr(target_os = "emscripten", ignore)] // no /dev fn bench_copy_buf_reader(b: &mut Bencher) { let mut file_in = File::open("/dev/zero").expect("opening /dev/zero failed"); // use dyn to avoid specializations unrelated to readbuf diff --git a/std/src/io/cursor.rs b/std/src/io/cursor.rs index fbfdb4fa02323..d7131e2fe92fd 100644 --- a/std/src/io/cursor.rs +++ b/std/src/io/cursor.rs @@ -153,7 +153,7 @@ impl Cursor { /// let reference = buff.get_mut(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_mut_cursor", issue = "130801")] + #[rustc_const_stable(feature = "const_mut_cursor", since = "1.86.0")] pub const fn get_mut(&mut self) -> &mut T { &mut self.inner } @@ -201,7 +201,7 @@ impl Cursor { /// assert_eq!(buff.position(), 4); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_mut_cursor", issue = "130801")] + #[rustc_const_stable(feature = "const_mut_cursor", since = "1.86.0")] pub const fn set_position(&mut self, pos: u64) { self.pos = pos; } @@ -304,7 +304,7 @@ where self.pos = n; Ok(self.pos) } - None => Err(io::const_io_error!( + None => Err(io::const_error!( ErrorKind::InvalidInput, "invalid seek to a negative or overflowing position", )), @@ -439,6 +439,27 @@ fn slice_write_vectored( Ok(nwritten) } +#[inline] +fn slice_write_all(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result<()> { + let n = slice_write(pos_mut, slice, buf)?; + if n < buf.len() { Err(io::Error::WRITE_ALL_EOF) } else { Ok(()) } +} + +#[inline] +fn slice_write_all_vectored( + pos_mut: &mut u64, + slice: &mut [u8], + bufs: &[IoSlice<'_>], +) -> io::Result<()> { + for buf in bufs { + let n = slice_write(pos_mut, slice, buf)?; + if n < buf.len() { + return Err(io::Error::WRITE_ALL_EOF); + } + } + Ok(()) +} + /// Reserves the required space, and pads the vec with 0s if necessary. fn reserve_and_pad( pos_mut: &mut u64, @@ -446,7 +467,7 @@ fn reserve_and_pad( buf_len: usize, ) -> io::Result { let pos: usize = (*pos_mut).try_into().map_err(|_| { - io::const_io_error!( + io::const_error!( ErrorKind::InvalidInput, "cursor position exceeds maximum possible vector length", ) @@ -481,9 +502,12 @@ fn reserve_and_pad( Ok(pos) } -/// Writes the slice to the vec without allocating -/// # Safety: vec must have buf.len() spare capacity -unsafe fn vec_write_unchecked(pos: usize, vec: &mut Vec, buf: &[u8]) -> usize +/// Writes the slice to the vec without allocating. +/// +/// # Safety +/// +/// `vec` must have `buf.len()` spare capacity. +unsafe fn vec_write_all_unchecked(pos: usize, vec: &mut Vec, buf: &[u8]) -> usize where A: Allocator, { @@ -492,7 +516,7 @@ where pos + buf.len() } -/// Resizing write implementation for [`Cursor`] +/// Resizing `write_all` implementation for [`Cursor`]. /// /// Cursor is allowed to have a pre-allocated and initialised /// vector body, but with a position of 0. This means the [`Write`] @@ -501,7 +525,7 @@ where /// This also allows for the vec body to be empty, but with a position of N. /// This means that [`Write`] will pad the vec with 0 initially, /// before writing anything from that point -fn vec_write(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result +fn vec_write_all(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result where A: Allocator, { @@ -512,7 +536,7 @@ where // Safety: we have ensured that the capacity is available // and that all bytes get written up to pos unsafe { - pos = vec_write_unchecked(pos, vec, buf); + pos = vec_write_all_unchecked(pos, vec, buf); if pos > vec.len() { vec.set_len(pos); } @@ -523,7 +547,7 @@ where Ok(buf_len) } -/// Resizing write_vectored implementation for [`Cursor`] +/// Resizing `write_all_vectored` implementation for [`Cursor`]. /// /// Cursor is allowed to have a pre-allocated and initialised /// vector body, but with a position of 0. This means the [`Write`] @@ -532,7 +556,7 @@ where /// This also allows for the vec body to be empty, but with a position of N. /// This means that [`Write`] will pad the vec with 0 initially, /// before writing anything from that point -fn vec_write_vectored( +fn vec_write_all_vectored( pos_mut: &mut u64, vec: &mut Vec, bufs: &[IoSlice<'_>], @@ -550,7 +574,7 @@ where // and that all bytes get written up to the last pos unsafe { for buf in bufs { - pos = vec_write_unchecked(pos, vec, buf); + pos = vec_write_all_unchecked(pos, vec, buf); } if pos > vec.len() { vec.set_len(pos); @@ -579,6 +603,16 @@ impl Write for Cursor<&mut [u8]> { true } + #[inline] + fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { + slice_write_all(&mut self.pos, self.inner, buf) + } + + #[inline] + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + slice_write_all_vectored(&mut self.pos, self.inner, bufs) + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) @@ -591,11 +625,11 @@ where A: Allocator, { fn write(&mut self, buf: &[u8]) -> io::Result { - vec_write(&mut self.pos, self.inner, buf) + vec_write_all(&mut self.pos, self.inner, buf) } fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { - vec_write_vectored(&mut self.pos, self.inner, bufs) + vec_write_all_vectored(&mut self.pos, self.inner, bufs) } #[inline] @@ -603,6 +637,16 @@ where true } + fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { + vec_write_all(&mut self.pos, self.inner, buf)?; + Ok(()) + } + + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + vec_write_all_vectored(&mut self.pos, self.inner, bufs)?; + Ok(()) + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) @@ -615,11 +659,11 @@ where A: Allocator, { fn write(&mut self, buf: &[u8]) -> io::Result { - vec_write(&mut self.pos, &mut self.inner, buf) + vec_write_all(&mut self.pos, &mut self.inner, buf) } fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { - vec_write_vectored(&mut self.pos, &mut self.inner, bufs) + vec_write_all_vectored(&mut self.pos, &mut self.inner, bufs) } #[inline] @@ -627,6 +671,16 @@ where true } + fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { + vec_write_all(&mut self.pos, &mut self.inner, buf)?; + Ok(()) + } + + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + vec_write_all_vectored(&mut self.pos, &mut self.inner, bufs)?; + Ok(()) + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) @@ -653,6 +707,16 @@ where true } + #[inline] + fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { + slice_write_all(&mut self.pos, &mut self.inner, buf) + } + + #[inline] + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + slice_write_all_vectored(&mut self.pos, &mut self.inner, bufs) + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) @@ -676,6 +740,16 @@ impl Write for Cursor<[u8; N]> { true } + #[inline] + fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { + slice_write_all(&mut self.pos, &mut self.inner, buf) + } + + #[inline] + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + slice_write_all_vectored(&mut self.pos, &mut self.inner, bufs) + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) diff --git a/std/src/io/error.rs b/std/src/io/error.rs index 5d7adcace5247..5aa048c4cbc85 100644 --- a/std/src/io/error.rs +++ b/std/src/io/error.rs @@ -76,31 +76,31 @@ impl fmt::Debug for Error { #[allow(dead_code)] impl Error { pub(crate) const INVALID_UTF8: Self = - const_io_error!(ErrorKind::InvalidData, "stream did not contain valid UTF-8"); + const_error!(ErrorKind::InvalidData, "stream did not contain valid UTF-8"); pub(crate) const READ_EXACT_EOF: Self = - const_io_error!(ErrorKind::UnexpectedEof, "failed to fill whole buffer"); + const_error!(ErrorKind::UnexpectedEof, "failed to fill whole buffer"); - pub(crate) const UNKNOWN_THREAD_COUNT: Self = const_io_error!( + pub(crate) const UNKNOWN_THREAD_COUNT: Self = const_error!( ErrorKind::NotFound, - "The number of hardware threads is not known for the target platform" + "the number of hardware threads is not known for the target platform", ); pub(crate) const UNSUPPORTED_PLATFORM: Self = - const_io_error!(ErrorKind::Unsupported, "operation not supported on this platform"); + const_error!(ErrorKind::Unsupported, "operation not supported on this platform"); pub(crate) const WRITE_ALL_EOF: Self = - const_io_error!(ErrorKind::WriteZero, "failed to write whole buffer"); + const_error!(ErrorKind::WriteZero, "failed to write whole buffer"); pub(crate) const ZERO_TIMEOUT: Self = - const_io_error!(ErrorKind::InvalidInput, "cannot set a 0 duration timeout"); + const_error!(ErrorKind::InvalidInput, "cannot set a 0 duration timeout"); } #[stable(feature = "rust1", since = "1.0.0")] impl From for Error { /// Converts a [`alloc::ffi::NulError`] into a [`Error`]. fn from(_: alloc::ffi::NulError) -> Error { - const_io_error!(ErrorKind::InvalidInput, "data provided contains a nul byte") + const_error!(ErrorKind::InvalidInput, "data provided contains a nul byte") } } @@ -151,27 +151,38 @@ pub type RawOsError = sys::RawOsError; // (For the sake of being explicit: the alignment requirement here only matters // if `error/repr_bitpacked.rs` is in use — for the unpacked repr it doesn't // matter at all) +#[doc(hidden)] +#[unstable(feature = "io_const_error_internals", issue = "none")] #[repr(align(4))] #[derive(Debug)] -pub(crate) struct SimpleMessage { - kind: ErrorKind, - message: &'static str, +pub struct SimpleMessage { + pub kind: ErrorKind, + pub message: &'static str, } -impl SimpleMessage { - pub(crate) const fn new(kind: ErrorKind, message: &'static str) -> Self { - Self { kind, message } - } -} - -/// Creates and returns an `io::Error` for a given `ErrorKind` and constant -/// message. This doesn't allocate. -pub(crate) macro const_io_error($kind:expr, $message:expr $(,)?) { - $crate::io::error::Error::from_static_message({ - const MESSAGE_DATA: $crate::io::error::SimpleMessage = - $crate::io::error::SimpleMessage::new($kind, $message); - &MESSAGE_DATA - }) +/// Creates a new I/O error from a known kind of error and a string literal. +/// +/// Contrary to [`Error::new`], this macro does not allocate and can be used in +/// `const` contexts. +/// +/// # Example +/// ``` +/// #![feature(io_const_error)] +/// use std::io::{const_error, Error, ErrorKind}; +/// +/// const FAIL: Error = const_error!(ErrorKind::Unsupported, "tried something that never works"); +/// +/// fn not_here() -> Result<(), Error> { +/// Err(FAIL) +/// } +/// ``` +#[rustc_macro_transparency = "semitransparent"] +#[unstable(feature = "io_const_error", issue = "133448")] +#[allow_internal_unstable(hint_must_use, io_const_error_internals)] +pub macro const_error($kind:expr, $message:expr $(,)?) { + $crate::hint::must_use($crate::io::Error::from_static_message( + const { &$crate::io::SimpleMessage { kind: $kind, message: $message } }, + )) } // As with `SimpleMessage`: `#[repr(align(4))]` here is just because @@ -327,9 +338,9 @@ pub enum ErrorKind { /// example, on Unix, a named pipe opened with `File::open`. #[stable(feature = "io_error_a_bit_more", since = "1.83.0")] NotSeekable, - /// Filesystem quota was exceeded. - #[unstable(feature = "io_error_more", issue = "86442")] - FilesystemQuotaExceeded, + /// Filesystem quota or some other kind of quota was exceeded. + #[stable(feature = "io_error_quota_exceeded", since = "1.85.0")] + QuotaExceeded, /// File larger than allowed or supported. /// /// This might arise from a hard limit of the underlying filesystem or file access API, or from @@ -353,7 +364,7 @@ pub enum ErrorKind { #[stable(feature = "io_error_a_bit_more", since = "1.83.0")] Deadlock, /// Cross-device or cross-filesystem (hard) link or rename. - #[unstable(feature = "io_error_more", issue = "86442")] + #[stable(feature = "io_error_crosses_devices", since = "1.85.0")] CrossesDevices, /// Too many (hard) links to the same filesystem object. /// @@ -435,8 +446,8 @@ pub enum ErrorKind { impl ErrorKind { pub(crate) fn as_str(&self) -> &'static str { use ErrorKind::*; - // tidy-alphabetical-start match *self { + // tidy-alphabetical-start AddrInUse => "address in use", AddrNotAvailable => "address not available", AlreadyExists => "entity already exists", @@ -449,12 +460,11 @@ impl ErrorKind { Deadlock => "deadlock", DirectoryNotEmpty => "directory not empty", ExecutableFileBusy => "executable file busy", - FileTooLarge => "file too large", FilesystemLoop => "filesystem loop or indirection limit (e.g. symlink loop)", - FilesystemQuotaExceeded => "filesystem quota exceeded", + FileTooLarge => "file too large", HostUnreachable => "host unreachable", - Interrupted => "operation interrupted", InProgress => "in progress", + Interrupted => "operation interrupted", InvalidData => "invalid data", InvalidFilename => "invalid filename", InvalidInput => "invalid input parameter", @@ -468,6 +478,7 @@ impl ErrorKind { Other => "other error", OutOfMemory => "out of memory", PermissionDenied => "permission denied", + QuotaExceeded => "quota exceeded", ReadOnlyFilesystem => "read-only filesystem or storage medium", ResourceBusy => "resource busy", StaleNetworkFileHandle => "stale network file handle", @@ -479,8 +490,8 @@ impl ErrorKind { Unsupported => "unsupported", WouldBlock => "operation would block", WriteZero => "write zero", + // tidy-alphabetical-end } - // tidy-alphabetical-end } } @@ -592,13 +603,15 @@ impl Error { /// /// This function does not allocate. /// - /// You should not use this directly, and instead use the `const_io_error!` - /// macro: `io::const_io_error!(ErrorKind::Something, "some_message")`. + /// You should not use this directly, and instead use the `const_error!` + /// macro: `io::const_error!(ErrorKind::Something, "some_message")`. /// /// This function should maybe change to `from_static_message(kind: ErrorKind)` in the future, when const generics allow that. #[inline] - pub(crate) const fn from_static_message(msg: &'static SimpleMessage) -> Error { + #[doc(hidden)] + #[unstable(feature = "io_const_error_internals", issue = "none")] + pub const fn from_static_message(msg: &'static SimpleMessage) -> Error { Self { repr: Repr::new_simple_message(msg) } } diff --git a/std/src/io/error/repr_bitpacked.rs b/std/src/io/error/repr_bitpacked.rs index a839a2fbac117..716da37168d01 100644 --- a/std/src/io/error/repr_bitpacked.rs +++ b/std/src/io/error/repr_bitpacked.rs @@ -103,7 +103,8 @@ //! the time. use core::marker::PhantomData; -use core::ptr::{self, NonNull}; +use core::num::NonZeroUsize; +use core::ptr::NonNull; use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage}; @@ -176,7 +177,7 @@ impl Repr { let utagged = ((code as usize) << 32) | TAG_OS; // Safety: `TAG_OS` is not zero, so the result of the `|` is not 0. let res = Self( - unsafe { NonNull::new_unchecked(ptr::without_provenance_mut(utagged)) }, + NonNull::without_provenance(unsafe { NonZeroUsize::new_unchecked(utagged) }), PhantomData, ); // quickly smoke-check we encoded the right thing (This generally will @@ -193,7 +194,7 @@ impl Repr { let utagged = ((kind as usize) << 32) | TAG_SIMPLE; // Safety: `TAG_SIMPLE` is not zero, so the result of the `|` is not 0. let res = Self( - unsafe { NonNull::new_unchecked(ptr::without_provenance_mut(utagged)) }, + NonNull::without_provenance(unsafe { NonZeroUsize::new_unchecked(utagged) }), PhantomData, ); // quickly smoke-check we encoded the right thing (This generally will @@ -335,7 +336,7 @@ fn kind_from_prim(ek: u32) -> Option { WriteZero, StorageFull, NotSeekable, - FilesystemQuotaExceeded, + QuotaExceeded, FileTooLarge, ResourceBusy, ExecutableFileBusy, diff --git a/std/src/io/error/tests.rs b/std/src/io/error/tests.rs index 00d04984a3854..3e4029768eb85 100644 --- a/std/src/io/error/tests.rs +++ b/std/src/io/error/tests.rs @@ -1,6 +1,5 @@ -use super::{Custom, Error, ErrorData, ErrorKind, Repr, SimpleMessage, const_io_error}; +use super::{Custom, Error, ErrorData, ErrorKind, Repr, SimpleMessage, const_error}; use crate::assert_matches::assert_matches; -use crate::mem::size_of; use crate::sys::decode_error_kind; use crate::sys::os::error_string; use crate::{error, fmt}; @@ -60,7 +59,7 @@ fn test_downcasting() { #[test] fn test_const() { - const E: Error = const_io_error!(ErrorKind::NotFound, "hello"); + const E: Error = const_error!(ErrorKind::NotFound, "hello"); assert_eq!(E.kind(), ErrorKind::NotFound); assert_eq!(E.to_string(), "hello"); @@ -110,13 +109,13 @@ fn test_simple_message_packing() { }}; } - let not_static = const_io_error!(Uncategorized, "not a constant!"); + let not_static = const_error!(Uncategorized, "not a constant!"); check_simple_msg!(not_static, Uncategorized, "not a constant!"); - const CONST: Error = const_io_error!(NotFound, "definitely a constant!"); + const CONST: Error = const_error!(NotFound, "definitely a constant!"); check_simple_msg!(CONST, NotFound, "definitely a constant!"); - static STATIC: Error = const_io_error!(BrokenPipe, "a constant, sort of!"); + static STATIC: Error = const_error!(BrokenPipe, "a constant, sort of!"); check_simple_msg!(STATIC, BrokenPipe, "a constant, sort of!"); } diff --git a/std/src/io/impls.rs b/std/src/io/impls.rs index b952c85addf65..d0245f3d4984c 100644 --- a/std/src/io/impls.rs +++ b/std/src/io/impls.rs @@ -45,6 +45,7 @@ impl Read for &mut R { fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { (**self).read_exact(buf) } + #[inline] fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> io::Result<()> { (**self).read_buf_exact(cursor) @@ -77,6 +78,11 @@ impl Write for &mut W { (**self).write_all(buf) } + #[inline] + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + (**self).write_all_vectored(bufs) + } + #[inline] fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> { (**self).write_fmt(fmt) @@ -89,10 +95,25 @@ impl Seek for &mut S { (**self).seek(pos) } + #[inline] + fn rewind(&mut self) -> io::Result<()> { + (**self).rewind() + } + + #[inline] + fn stream_len(&mut self) -> io::Result { + (**self).stream_len() + } + #[inline] fn stream_position(&mut self) -> io::Result { (**self).stream_position() } + + #[inline] + fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + (**self).seek_relative(offset) + } } #[stable(feature = "rust1", since = "1.0.0")] impl BufRead for &mut B { @@ -106,11 +127,21 @@ impl BufRead for &mut B { (**self).consume(amt) } + #[inline] + fn has_data_left(&mut self) -> io::Result { + (**self).has_data_left() + } + #[inline] fn read_until(&mut self, byte: u8, buf: &mut Vec) -> io::Result { (**self).read_until(byte, buf) } + #[inline] + fn skip_until(&mut self, byte: u8) -> io::Result { + (**self).skip_until(byte) + } + #[inline] fn read_line(&mut self, buf: &mut String) -> io::Result { (**self).read_line(buf) @@ -153,6 +184,7 @@ impl Read for Box { fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { (**self).read_exact(buf) } + #[inline] fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> io::Result<()> { (**self).read_buf_exact(cursor) @@ -185,6 +217,11 @@ impl Write for Box { (**self).write_all(buf) } + #[inline] + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + (**self).write_all_vectored(bufs) + } + #[inline] fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> { (**self).write_fmt(fmt) @@ -197,10 +234,25 @@ impl Seek for Box { (**self).seek(pos) } + #[inline] + fn rewind(&mut self) -> io::Result<()> { + (**self).rewind() + } + + #[inline] + fn stream_len(&mut self) -> io::Result { + (**self).stream_len() + } + #[inline] fn stream_position(&mut self) -> io::Result { (**self).stream_position() } + + #[inline] + fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + (**self).seek_relative(offset) + } } #[stable(feature = "rust1", since = "1.0.0")] impl BufRead for Box { @@ -214,11 +266,21 @@ impl BufRead for Box { (**self).consume(amt) } + #[inline] + fn has_data_left(&mut self) -> io::Result { + (**self).has_data_left() + } + #[inline] fn read_until(&mut self, byte: u8, buf: &mut Vec) -> io::Result { (**self).read_until(byte, buf) } + #[inline] + fn skip_until(&mut self, byte: u8) -> io::Result { + (**self).skip_until(byte) + } + #[inline] fn read_line(&mut self, buf: &mut String) -> io::Result { (**self).read_line(buf) @@ -393,7 +455,17 @@ impl Write for &mut [u8] { #[inline] fn write_all(&mut self, data: &[u8]) -> io::Result<()> { - if self.write(data)? == data.len() { Ok(()) } else { Err(io::Error::WRITE_ALL_EOF) } + if self.write(data)? < data.len() { Err(io::Error::WRITE_ALL_EOF) } else { Ok(()) } + } + + #[inline] + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + for buf in bufs { + if self.write(buf)? < buf.len() { + return Err(io::Error::WRITE_ALL_EOF); + } + } + Ok(()) } #[inline] @@ -433,6 +505,12 @@ impl Write for Vec { Ok(()) } + #[inline] + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + self.write_vectored(bufs)?; + Ok(()) + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) @@ -453,6 +531,7 @@ impl Read for VecDeque { Ok(n) } + #[inline] fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { let (front, back) = self.as_slices(); @@ -485,6 +564,7 @@ impl Read for VecDeque { Ok(()) } + #[inline] fn read_buf_exact(&mut self, mut cursor: BorrowedCursor<'_>) -> io::Result<()> { let len = cursor.capacity(); let (front, back) = self.as_slices(); @@ -576,6 +656,12 @@ impl Write for VecDeque { Ok(()) } + #[inline] + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + self.write_vectored(bufs)?; + Ok(()) + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) @@ -584,12 +670,46 @@ impl Write for VecDeque { #[unstable(feature = "read_buf", issue = "78485")] impl<'a> io::Write for core::io::BorrowedCursor<'a> { + #[inline] fn write(&mut self, buf: &[u8]) -> io::Result { let amt = cmp::min(buf.len(), self.capacity()); self.append(&buf[..amt]); Ok(amt) } + #[inline] + fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { + let mut nwritten = 0; + for buf in bufs { + let n = self.write(buf)?; + nwritten += n; + if n < buf.len() { + break; + } + } + Ok(nwritten) + } + + #[inline] + fn is_write_vectored(&self) -> bool { + true + } + + #[inline] + fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { + if self.write(buf)? < buf.len() { Err(io::Error::WRITE_ALL_EOF) } else { Ok(()) } + } + + #[inline] + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + for buf in bufs { + if self.write(buf)? < buf.len() { + return Err(io::Error::WRITE_ALL_EOF); + } + } + Ok(()) + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) diff --git a/std/src/io/mod.rs b/std/src/io/mod.rs index 21e7077495450..7f610bc88bfd7 100644 --- a/std/src/io/mod.rs +++ b/std/src/io/mod.rs @@ -301,12 +301,17 @@ mod tests; pub use core::io::{BorrowedBuf, BorrowedCursor}; use core::slice::memchr; -pub(crate) use error::const_io_error; - #[stable(feature = "bufwriter_into_parts", since = "1.56.0")] pub use self::buffered::WriterPanicked; #[unstable(feature = "raw_os_error_ty", issue = "107792")] pub use self::error::RawOsError; +#[doc(hidden)] +#[unstable(feature = "io_const_error_internals", issue = "none")] +pub use self::error::SimpleMessage; +#[unstable(feature = "io_const_error", issue = "133448")] +pub use self::error::const_error; +#[unstable(feature = "anonymous_pipe", issue = "127154")] +pub use self::pipe::{PipeReader, PipeWriter, pipe}; #[stable(feature = "is_terminal", since = "1.70.0")] pub use self::stdio::IsTerminal; pub(crate) use self::stdio::attempt_print_to_stderr; @@ -334,11 +339,12 @@ pub(crate) mod copy; mod cursor; mod error; mod impls; +mod pipe; pub mod prelude; mod stdio; mod util; -const DEFAULT_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE; +const DEFAULT_BUF_SIZE: usize = crate::sys::io::DEFAULT_BUF_SIZE; pub(crate) use stdio::cleanup; @@ -1080,7 +1086,7 @@ pub trait Read { /// let f = BufReader::new(File::open("foo.txt")?); /// /// for byte in f.bytes() { - /// println!("{}", byte.unwrap()); + /// println!("{}", byte?); /// } /// Ok(()) /// } @@ -1992,15 +1998,16 @@ pub trait Seek { /// .write(true) /// .read(true) /// .create(true) - /// .open("foo.txt").unwrap(); + /// .open("foo.txt")?; /// /// let hello = "Hello!\n"; - /// write!(f, "{hello}").unwrap(); - /// f.rewind().unwrap(); + /// write!(f, "{hello}")?; + /// f.rewind()?; /// /// let mut buf = String::new(); - /// f.read_to_string(&mut buf).unwrap(); + /// f.read_to_string(&mut buf)?; /// assert_eq!(&buf, hello); + /// # std::io::Result::Ok(()) /// ``` #[stable(feature = "seek_rewind", since = "1.55.0")] fn rewind(&mut self) -> Result<()> { @@ -2209,8 +2216,9 @@ fn skip_until(r: &mut R, delim: u8) -> Result { /// /// let stdin = io::stdin(); /// for line in stdin.lock().lines() { -/// println!("{}", line.unwrap()); +/// println!("{}", line?); /// } +/// # std::io::Result::Ok(()) /// ``` /// /// If you have something that implements [`Read`], you can use the [`BufReader` @@ -2233,13 +2241,15 @@ fn skip_until(r: &mut R, delim: u8) -> Result { /// let f = BufReader::new(f); /// /// for line in f.lines() { -/// println!("{}", line.unwrap()); +/// let line = line?; +/// println!("{line}"); /// } /// /// Ok(()) /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "IoBufRead")] pub trait BufRead: Read { /// Returns the contents of the internal buffer, filling it with more data /// from the inner reader if it is empty. @@ -2271,7 +2281,7 @@ pub trait BufRead: Read { /// let stdin = io::stdin(); /// let mut stdin = stdin.lock(); /// - /// let buffer = stdin.fill_buf().unwrap(); + /// let buffer = stdin.fill_buf()?; /// /// // work with buffer /// println!("{buffer:?}"); @@ -2279,6 +2289,7 @@ pub trait BufRead: Read { /// // ensure the bytes we worked with aren't returned again later /// let length = buffer.len(); /// stdin.consume(length); + /// # std::io::Result::Ok(()) /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn fill_buf(&mut self) -> Result<&[u8]>; @@ -2324,12 +2335,13 @@ pub trait BufRead: Read { /// let stdin = io::stdin(); /// let mut stdin = stdin.lock(); /// - /// while stdin.has_data_left().unwrap() { + /// while stdin.has_data_left()? { /// let mut line = String::new(); - /// stdin.read_line(&mut line).unwrap(); + /// stdin.read_line(&mut line)?; /// // work with line /// println!("{line:?}"); /// } + /// # std::io::Result::Ok(()) /// ``` #[unstable(feature = "buf_read_has_data_left", reason = "recently added", issue = "86423")] fn has_data_left(&mut self) -> Result { @@ -2522,7 +2534,7 @@ pub trait BufRead: Read { fn read_line(&mut self, buf: &mut String) -> Result { // Note that we are not calling the `.read_until` method here, but // rather our hardcoded implementation. For more details as to why, see - // the comments in `read_to_end`. + // the comments in `default_read_to_string`. unsafe { append_to_string(buf, |b| read_until(self, b'\n', b)) } } diff --git a/std/src/io/pipe.rs b/std/src/io/pipe.rs new file mode 100644 index 0000000000000..266c7bc96389b --- /dev/null +++ b/std/src/io/pipe.rs @@ -0,0 +1,260 @@ +use crate::io; +use crate::sys::anonymous_pipe::{AnonPipe, pipe as pipe_inner}; + +/// Create an anonymous pipe. +/// +/// # Behavior +/// +/// A pipe is a one-way data channel provided by the OS, which works across processes. A pipe is +/// typically used to communicate between two or more separate processes, as there are better, +/// faster ways to communicate within a single process. +/// +/// In particular: +/// +/// * A read on a [`PipeReader`] blocks until the pipe is non-empty. +/// * A write on a [`PipeWriter`] blocks when the pipe is full. +/// * When all copies of a [`PipeWriter`] are closed, a read on the corresponding [`PipeReader`] +/// returns EOF. +/// * [`PipeWriter`] can be shared, and multiple processes or threads can write to it at once, but +/// writes (above a target-specific threshold) may have their data interleaved. +/// * [`PipeReader`] can be shared, and multiple processes or threads can read it at once. Any +/// given byte will only get consumed by one reader. There are no guarantees about data +/// interleaving. +/// * Portable applications cannot assume any atomicity of messages larger than a single byte. +/// +/// # Platform-specific behavior +/// +/// This function currently corresponds to the `pipe` function on Unix and the +/// `CreatePipe` function on Windows. +/// +/// Note that this [may change in the future][changes]. +/// +/// # Capacity +/// +/// Pipe capacity is platform dependent. To quote the Linux [man page]: +/// +/// > Different implementations have different limits for the pipe capacity. Applications should +/// > not rely on a particular capacity: an application should be designed so that a reading process +/// > consumes data as soon as it is available, so that a writing process does not remain blocked. +/// +/// # Examples +/// +/// ```no_run +/// #![feature(anonymous_pipe)] +/// # #[cfg(miri)] fn main() {} +/// # #[cfg(not(miri))] +/// # fn main() -> std::io::Result<()> { +/// use std::process::Command; +/// use std::io::{pipe, Read, Write}; +/// let (ping_rx, mut ping_tx) = pipe()?; +/// let (mut pong_rx, pong_tx) = pipe()?; +/// +/// // Spawn a process that echoes its input. +/// let mut echo_server = Command::new("cat").stdin(ping_rx).stdout(pong_tx).spawn()?; +/// +/// ping_tx.write_all(b"hello")?; +/// // Close to unblock echo_server's reader. +/// drop(ping_tx); +/// +/// let mut buf = String::new(); +/// // Block until echo_server's writer is closed. +/// pong_rx.read_to_string(&mut buf)?; +/// assert_eq!(&buf, "hello"); +/// +/// echo_server.wait()?; +/// # Ok(()) +/// # } +/// ``` +/// [changes]: io#platform-specific-behavior +/// [man page]: https://man7.org/linux/man-pages/man7/pipe.7.html +#[unstable(feature = "anonymous_pipe", issue = "127154")] +#[inline] +pub fn pipe() -> io::Result<(PipeReader, PipeWriter)> { + pipe_inner().map(|(reader, writer)| (PipeReader(reader), PipeWriter(writer))) +} + +/// Read end of an anonymous pipe. +#[unstable(feature = "anonymous_pipe", issue = "127154")] +#[derive(Debug)] +pub struct PipeReader(pub(crate) AnonPipe); + +/// Write end of an anonymous pipe. +#[unstable(feature = "anonymous_pipe", issue = "127154")] +#[derive(Debug)] +pub struct PipeWriter(pub(crate) AnonPipe); + +impl PipeReader { + /// Create a new [`PipeReader`] instance that shares the same underlying file description. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(anonymous_pipe)] + /// # #[cfg(miri)] fn main() {} + /// # #[cfg(not(miri))] + /// # fn main() -> std::io::Result<()> { + /// use std::fs; + /// use std::io::{pipe, Write}; + /// use std::process::Command; + /// const NUM_SLOT: u8 = 2; + /// const NUM_PROC: u8 = 5; + /// const OUTPUT: &str = "work.txt"; + /// + /// let mut jobs = vec![]; + /// let (reader, mut writer) = pipe()?; + /// + /// // Write NUM_SLOT characters the pipe. + /// writer.write_all(&[b'|'; NUM_SLOT as usize])?; + /// + /// // Spawn several processes that read a character from the pipe, do some work, then + /// // write back to the pipe. When the pipe is empty, the processes block, so only + /// // NUM_SLOT processes can be working at any given time. + /// for _ in 0..NUM_PROC { + /// jobs.push( + /// Command::new("bash") + /// .args(["-c", + /// &format!( + /// "read -n 1\n\ + /// echo -n 'x' >> '{OUTPUT}'\n\ + /// echo -n '|'", + /// ), + /// ]) + /// .stdin(reader.try_clone()?) + /// .stdout(writer.try_clone()?) + /// .spawn()?, + /// ); + /// } + /// + /// // Wait for all jobs to finish. + /// for mut job in jobs { + /// job.wait()?; + /// } + /// + /// // Check our work and clean up. + /// let xs = fs::read_to_string(OUTPUT)?; + /// fs::remove_file(OUTPUT)?; + /// assert_eq!(xs, "x".repeat(NUM_PROC.into())); + /// # Ok(()) + /// # } + /// ``` + #[unstable(feature = "anonymous_pipe", issue = "127154")] + pub fn try_clone(&self) -> io::Result { + self.0.try_clone().map(Self) + } +} + +impl PipeWriter { + /// Create a new [`PipeWriter`] instance that shares the same underlying file description. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(anonymous_pipe)] + /// # #[cfg(miri)] fn main() {} + /// # #[cfg(not(miri))] + /// # fn main() -> std::io::Result<()> { + /// use std::process::Command; + /// use std::io::{pipe, Read}; + /// let (mut reader, writer) = pipe()?; + /// + /// // Spawn a process that writes to stdout and stderr. + /// let mut peer = Command::new("bash") + /// .args([ + /// "-c", + /// "echo -n foo\n\ + /// echo -n bar >&2" + /// ]) + /// .stdout(writer.try_clone()?) + /// .stderr(writer) + /// .spawn()?; + /// + /// // Read and check the result. + /// let mut msg = String::new(); + /// reader.read_to_string(&mut msg)?; + /// assert_eq!(&msg, "foobar"); + /// + /// peer.wait()?; + /// # Ok(()) + /// # } + /// ``` + #[unstable(feature = "anonymous_pipe", issue = "127154")] + pub fn try_clone(&self) -> io::Result { + self.0.try_clone().map(Self) + } +} + +#[unstable(feature = "anonymous_pipe", issue = "127154")] +impl io::Read for &PipeReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + self.0.read(buf) + } + fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut<'_>]) -> io::Result { + self.0.read_vectored(bufs) + } + #[inline] + fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() + } + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + self.0.read_to_end(buf) + } + fn read_buf(&mut self, buf: io::BorrowedCursor<'_>) -> io::Result<()> { + self.0.read_buf(buf) + } +} + +#[unstable(feature = "anonymous_pipe", issue = "127154")] +impl io::Read for PipeReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + self.0.read(buf) + } + fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut<'_>]) -> io::Result { + self.0.read_vectored(bufs) + } + #[inline] + fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() + } + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + self.0.read_to_end(buf) + } + fn read_buf(&mut self, buf: io::BorrowedCursor<'_>) -> io::Result<()> { + self.0.read_buf(buf) + } +} + +#[unstable(feature = "anonymous_pipe", issue = "127154")] +impl io::Write for &PipeWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + self.0.write(buf) + } + #[inline] + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } + fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result { + self.0.write_vectored(bufs) + } + #[inline] + fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() + } +} + +#[unstable(feature = "anonymous_pipe", issue = "127154")] +impl io::Write for PipeWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + self.0.write(buf) + } + #[inline] + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } + fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result { + self.0.write_vectored(bufs) + } + #[inline] + fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() + } +} diff --git a/std/src/pipe/tests.rs b/std/src/io/pipe/tests.rs similarity index 78% rename from std/src/pipe/tests.rs rename to std/src/io/pipe/tests.rs index 9c38e10678752..f113b157459d3 100644 --- a/std/src/pipe/tests.rs +++ b/std/src/io/pipe/tests.rs @@ -1,8 +1,7 @@ -use crate::io::{Read, Write}; -use crate::pipe::pipe; +use crate::io::{Read, Write, pipe}; #[test] -#[cfg(all(windows, unix, not(miri)))] +#[cfg(all(any(unix, windows), not(miri)))] fn pipe_creation_clone_and_rw() { let (rx, tx) = pipe().unwrap(); diff --git a/std/src/io/stdio.rs b/std/src/io/stdio.rs index 35b38ed783ff2..ce46241f8e84d 100644 --- a/std/src/io/stdio.rs +++ b/std/src/io/stdio.rs @@ -20,7 +20,7 @@ type LocalStream = Arc>>; thread_local! { /// Used by the test crate to capture the output of the print macros and panics. - static OUTPUT_CAPTURE: Cell> = { + static OUTPUT_CAPTURE: Cell> = const { Cell::new(None) } } @@ -239,6 +239,7 @@ fn handle_ebadf_lazy(r: io::Result, default: impl FnOnce() -> T) -> io::Re /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "Stdin")] pub struct Stdin { inner: &'static Mutex>, } @@ -574,6 +575,11 @@ impl fmt::Debug for StdinLock<'_> { /// output stream. Access is also synchronized via a lock and explicit control /// over locking is available via the [`lock`] method. /// +/// By default, the handle is line-buffered when connected to a terminal, meaning +/// it flushes automatically when a newline (`\n`) is encountered. For immediate +/// output, you can manually call the [`flush`] method. When the handle goes out +/// of scope, the buffer is automatically flushed. +/// /// Created by the [`io::stdout`] method. /// /// ### Note: Windows Portability Considerations @@ -589,6 +595,7 @@ impl fmt::Debug for StdinLock<'_> { /// standard library or via raw Windows API calls, will fail. /// /// [`lock`]: Stdout::lock +/// [`flush`]: Write::flush /// [`io::stdout`]: stdout #[stable(feature = "rust1", since = "1.0.0")] pub struct Stdout { @@ -603,6 +610,11 @@ pub struct Stdout { /// This handle implements the [`Write`] trait, and is constructed via /// the [`Stdout::lock`] method. See its documentation for more. /// +/// By default, the handle is line-buffered when connected to a terminal, meaning +/// it flushes automatically when a newline (`\n`) is encountered. For immediate +/// output, you can manually call the [`flush`] method. When the handle goes out +/// of scope, the buffer is automatically flushed. +/// /// ### Note: Windows Portability Considerations /// /// When operating in a console, the Windows implementation of this stream does not support @@ -614,6 +626,8 @@ pub struct Stdout { /// the contained handle will be null. In such cases, the standard library's `Read` and /// `Write` will do nothing and silently succeed. All other I/O operations, via the /// standard library or via raw Windows API calls, will fail. +/// +/// [`flush`]: Write::flush #[must_use = "if unused stdout will immediately unlock"] #[stable(feature = "rust1", since = "1.0.0")] pub struct StdoutLock<'a> { @@ -628,6 +642,11 @@ static STDOUT: OnceLock>>> = OnceLoc /// is synchronized via a mutex. If you need more explicit control over /// locking, see the [`Stdout::lock`] method. /// +/// By default, the handle is line-buffered when connected to a terminal, meaning +/// it flushes automatically when a newline (`\n`) is encountered. For immediate +/// output, you can manually call the [`flush`] method. When the handle goes out +/// of scope, the buffer is automatically flushed. +/// /// ### Note: Windows Portability Considerations /// /// When operating in a console, the Windows implementation of this stream does not support @@ -668,6 +687,22 @@ static STDOUT: OnceLock>>> = OnceLoc /// Ok(()) /// } /// ``` +/// +/// Ensuring output is flushed immediately: +/// +/// ```no_run +/// use std::io::{self, Write}; +/// +/// fn main() -> io::Result<()> { +/// let mut stdout = io::stdout(); +/// stdout.write_all(b"hello, ")?; +/// stdout.flush()?; // Manual flush +/// stdout.write_all(b"world!\n")?; // Automatically flushed +/// Ok(()) +/// } +/// ``` +/// +/// [`flush`]: Write::flush #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "io_stdout")] @@ -1200,6 +1235,7 @@ pub trait IsTerminal: crate::sealed::Sealed { /// /// [changes]: io#platform-specific-behavior /// [`Stdin`]: crate::io::Stdin + #[doc(alias = "isatty")] #[stable(feature = "is_terminal", since = "1.70.0")] fn is_terminal(&self) -> bool; } diff --git a/std/src/io/stdio/tests.rs b/std/src/io/stdio/tests.rs index bf8f3a5adfb6f..e68d8c29fbce2 100644 --- a/std/src/io/stdio/tests.rs +++ b/std/src/io/stdio/tests.rs @@ -159,7 +159,8 @@ where assert_eq!(rx2.recv().unwrap(), Release2); // release th2 th2.join().unwrap(); th1.join().unwrap(); - assert_eq!(*log.lock().unwrap(), [ - Start1, Acquire1, Start2, Release1, Acquire2, Release2, Acquire1, Release1 - ]); + assert_eq!( + *log.lock().unwrap(), + [Start1, Acquire1, Start2, Release1, Acquire2, Release2, Acquire1, Release1] + ); } diff --git a/std/src/io/tests.rs b/std/src/io/tests.rs index 89e806c08911c..f64f034cce779 100644 --- a/std/src/io/tests.rs +++ b/std/src/io/tests.rs @@ -7,7 +7,6 @@ use crate::mem::MaybeUninit; use crate::ops::Deref; #[test] -#[cfg_attr(target_os = "emscripten", ignore)] fn read_until() { let mut buf = Cursor::new(&b"12"[..]); let mut v = Vec::new(); @@ -225,12 +224,12 @@ fn take_eof() { impl Read for R { fn read(&mut self, _: &mut [u8]) -> io::Result { - Err(io::const_io_error!(io::ErrorKind::Other, "")) + Err(io::const_error!(io::ErrorKind::Other, "")) } } impl BufRead for R { fn fill_buf(&mut self) -> io::Result<&[u8]> { - Err(io::const_io_error!(io::ErrorKind::Other, "")) + Err(io::const_error!(io::ErrorKind::Other, "")) } fn consume(&mut self, _amt: usize) {} } @@ -359,7 +358,6 @@ fn chain_zero_length_read_is_not_eof() { } #[bench] -#[cfg_attr(target_os = "emscripten", ignore)] #[cfg_attr(miri, ignore)] // Miri isn't fast... fn bench_read_to_end(b: &mut test::Bencher) { b.iter(|| { diff --git a/std/src/io/util.rs b/std/src/io/util.rs index b4c4dffc371c1..cb3f864fd4e1e 100644 --- a/std/src/io/util.rs +++ b/std/src/io/util.rs @@ -7,6 +7,7 @@ use crate::fmt; use crate::io::{ self, BorrowedCursor, BufRead, IoSlice, IoSliceMut, Read, Seek, SeekFrom, SizeHint, Write, }; +use crate::mem::MaybeUninit; /// `Empty` ignores any data written via [`Write`], and will always be empty /// (returning zero bytes) when read via [`Read`]. @@ -182,28 +183,30 @@ pub const fn repeat(byte: u8) -> Repeat { impl Read for Repeat { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::Result { - for slot in &mut *buf { - *slot = self.byte; - } + buf.fill(self.byte); Ok(buf.len()) } - fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> { - // SAFETY: No uninit bytes are being written - for slot in unsafe { buf.as_mut() } { - slot.write(self.byte); - } - - let remaining = buf.capacity(); - - // SAFETY: the entire unfilled portion of buf has been initialized - unsafe { - buf.advance_unchecked(remaining); - } + #[inline] + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + buf.fill(self.byte); + Ok(()) + } + #[inline] + fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> { + // SAFETY: No uninit bytes are being written. + MaybeUninit::fill(unsafe { buf.as_mut() }, self.byte); + // SAFETY: the entire unfilled portion of buf has been initialized. + unsafe { buf.advance_unchecked(buf.capacity()) }; Ok(()) } + #[inline] + fn read_buf_exact(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> { + self.read_buf(buf) + } + /// This function is not supported by `io::Repeat`, because there's no end of its data fn read_to_end(&mut self, _: &mut Vec) -> io::Result { Err(io::Error::from(io::ErrorKind::OutOfMemory)) diff --git a/std/src/keyword_docs.rs b/std/src/keyword_docs.rs index 4302e24781ee8..5ac3dbc3e9852 100644 --- a/std/src/keyword_docs.rs +++ b/std/src/keyword_docs.rs @@ -398,7 +398,7 @@ mod enum_keyword {} /// The mirror use case of FFI is also done via the `extern` keyword: /// /// ```rust -/// #[no_mangle] +/// #[unsafe(no_mangle)] /// pub extern "C" fn callable_from_c(x: i32) -> bool { /// x % 3 == 0 /// } @@ -651,16 +651,24 @@ mod if_keyword {} #[doc(keyword = "impl")] // -/// Implement some functionality for a type. +/// Implementations of functionality for a type, or a type implementing some functionality. +/// +/// There are two uses of the keyword `impl`: +/// * An `impl` block is an item that is used to implement some functionality for a type. +/// * An `impl Trait` in a type-position can be used to designate a type that implements a trait called `Trait`. +/// +/// # Implementing Functionality for a Type /// /// The `impl` keyword is primarily used to define implementations on types. Inherent /// implementations are standalone, while trait implementations are used to implement traits for /// types, or other traits. /// -/// Functions and consts can both be defined in an implementation. A function defined in an -/// `impl` block can be standalone, meaning it would be called like `Foo::bar()`. If the function +/// An implementation consists of definitions of functions and consts. A function defined in an +/// `impl` block can be standalone, meaning it would be called like `Vec::new()`. If the function /// takes `self`, `&self`, or `&mut self` as its first argument, it can also be called using -/// method-call syntax, a familiar feature to any object oriented programmer, like `foo.bar()`. +/// method-call syntax, a familiar feature to any object-oriented programmer, like `vec.len()`. +/// +/// ## Inherent Implementations /// /// ```rust /// struct Example { @@ -680,6 +688,17 @@ mod if_keyword {} /// self.number /// } /// } +/// ``` +/// +/// It matters little where an inherent implementation is defined; +/// its functionality is in scope wherever its implementing type is. +/// +/// ## Trait Implementations +/// +/// ```rust +/// struct Example { +/// number: i32, +/// } /// /// trait Thingy { /// fn do_thingy(&self); @@ -692,11 +711,19 @@ mod if_keyword {} /// } /// ``` /// +/// It matters little where a trait implementation is defined; +/// its functionality can be brought into scope by importing the trait it implements. +/// /// For more information on implementations, see the [Rust book][book1] or the [Reference]. /// -/// The other use of the `impl` keyword is in `impl Trait` syntax, which can be seen as a shorthand -/// for "a concrete type that implements this trait". Its primary use is working with closures, -/// which have type definitions generated at compile time that can't be simply typed out. +/// # Designating a Type that Implements Some Functionality +/// +/// The other use of the `impl` keyword is in `impl Trait` syntax, which can be understood to mean +/// "any (or some) concrete type that implements Trait". +/// It can be used as the type of a variable declaration, +/// in [argument position](https://rust-lang.github.io/rfcs/1951-expand-impl-trait.html) +/// or in [return position](https://rust-lang.github.io/rfcs/3425-return-position-impl-trait-in-traits.html). +/// One pertinent use case is in working with closures, which have unnameable types. /// /// ```rust /// fn thing_returning_closure() -> impl Fn(i32) -> bool { @@ -807,64 +834,6 @@ mod in_keyword {} /// [Reference]: ../reference/statements.html#let-statements mod let_keyword {} -#[doc(keyword = "while")] -// -/// Loop while a condition is upheld. -/// -/// A `while` expression is used for predicate loops. The `while` expression runs the conditional -/// expression before running the loop body, then runs the loop body if the conditional -/// expression evaluates to `true`, or exits the loop otherwise. -/// -/// ```rust -/// let mut counter = 0; -/// -/// while counter < 10 { -/// println!("{counter}"); -/// counter += 1; -/// } -/// ``` -/// -/// Like the [`for`] expression, we can use `break` and `continue`. A `while` expression -/// cannot break with a value and always evaluates to `()` unlike [`loop`]. -/// -/// ```rust -/// let mut i = 1; -/// -/// while i < 100 { -/// i *= 2; -/// if i == 64 { -/// break; // Exit when `i` is 64. -/// } -/// } -/// ``` -/// -/// As `if` expressions have their pattern matching variant in `if let`, so too do `while` -/// expressions with `while let`. The `while let` expression matches the pattern against the -/// expression, then runs the loop body if pattern matching succeeds, or exits the loop otherwise. -/// We can use `break` and `continue` in `while let` expressions just like in `while`. -/// -/// ```rust -/// let mut counter = Some(0); -/// -/// while let Some(i) = counter { -/// if i == 10 { -/// counter = None; -/// } else { -/// println!("{i}"); -/// counter = Some (i + 1); -/// } -/// } -/// ``` -/// -/// For more information on `while` and loops in general, see the [reference]. -/// -/// See also, [`for`], [`loop`]. -/// -/// [`for`]: keyword.for.html -/// [`loop`]: keyword.loop.html -/// [reference]: ../reference/expressions/loop-expr.html#predicate-loops -mod while_keyword {} - #[doc(keyword = "loop")] // /// Loop indefinitely. @@ -1321,10 +1290,10 @@ mod return_keyword {} /// [Reference]: ../reference/items/associated-items.html#methods mod self_keyword {} -// FIXME: Once rustdoc can handle URL conflicts on case insensitive file systems, we can remove the -// three next lines and put back: `#[doc(keyword = "Self")]`. +// FIXME: Once rustdoc can handle URL conflicts on case insensitive file systems, we can replace +// these two lines with `#[doc(keyword = "Self")]` and update `is_doc_keyword` in +// `CheckAttrVisitor`. #[doc(alias = "Self")] -#[allow(rustc::existing_doc_keyword)] #[doc(keyword = "SelfTy")] // /// The implementing type within a [`trait`] or [`impl`] block, or the current type within a type @@ -1459,7 +1428,7 @@ mod self_upper_keyword {} /// /// ```rust,no_run /// # #![allow(dead_code)] -/// extern "C" { +/// unsafe extern "C" { /// static mut ERROR_MESSAGE: *mut std::os::raw::c_char; /// } /// ``` @@ -1956,7 +1925,7 @@ mod type_keyword {} /// /// unsafe fn unsafe_fn() {} /// -/// extern "C" { +/// unsafe extern "C" { /// fn unsafe_extern_fn(); /// static BAR: *mut u32; /// } @@ -2152,8 +2121,8 @@ mod unsafe_keyword {} #[doc(keyword = "use")] // -/// Import or rename items from other crates or modules, or specify precise capturing -/// with `use<..>`. +/// Import or rename items from other crates or modules, use values under ergonomic clones +/// semantic, or specify precise capturing with `use<..>`. /// /// ## Importing items /// @@ -2236,6 +2205,11 @@ mod unsafe_keyword {} /// /// For more details about precise capturing, see the [Reference][ref-impl-trait]. /// +/// ## Ergonomic clones +/// +/// Use a values, copying its content if the value implements `Copy`, cloning the contents if the +/// value implements `UseCloned` or moving it otherwise. +/// /// [`crate`]: keyword.crate.html /// [`self`]: keyword.self.html /// [`super`]: keyword.super.html @@ -2343,6 +2317,64 @@ mod use_keyword {} /// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/0135-where.md mod where_keyword {} +#[doc(keyword = "while")] +// +/// Loop while a condition is upheld. +/// +/// A `while` expression is used for predicate loops. The `while` expression runs the conditional +/// expression before running the loop body, then runs the loop body if the conditional +/// expression evaluates to `true`, or exits the loop otherwise. +/// +/// ```rust +/// let mut counter = 0; +/// +/// while counter < 10 { +/// println!("{counter}"); +/// counter += 1; +/// } +/// ``` +/// +/// Like the [`for`] expression, we can use `break` and `continue`. A `while` expression +/// cannot break with a value and always evaluates to `()` unlike [`loop`]. +/// +/// ```rust +/// let mut i = 1; +/// +/// while i < 100 { +/// i *= 2; +/// if i == 64 { +/// break; // Exit when `i` is 64. +/// } +/// } +/// ``` +/// +/// As `if` expressions have their pattern matching variant in `if let`, so too do `while` +/// expressions with `while let`. The `while let` expression matches the pattern against the +/// expression, then runs the loop body if pattern matching succeeds, or exits the loop otherwise. +/// We can use `break` and `continue` in `while let` expressions just like in `while`. +/// +/// ```rust +/// let mut counter = Some(0); +/// +/// while let Some(i) = counter { +/// if i == 10 { +/// counter = None; +/// } else { +/// println!("{i}"); +/// counter = Some (i + 1); +/// } +/// } +/// ``` +/// +/// For more information on `while` and loops in general, see the [reference]. +/// +/// See also, [`for`], [`loop`]. +/// +/// [`for`]: keyword.for.html +/// [`loop`]: keyword.loop.html +/// [reference]: ../reference/expressions/loop-expr.html#predicate-loops +mod while_keyword {} + // 2018 Edition keywords #[doc(alias = "promise")] @@ -2387,13 +2419,12 @@ mod async_keyword {} /// [`async`]: ../std/keyword.async.html mod await_keyword {} -// FIXME(dyn_compat_renaming): Update URL and link text. #[doc(keyword = "dyn")] // /// `dyn` is a prefix of a [trait object]'s type. /// /// The `dyn` keyword is used to highlight that calls to methods on the associated `Trait` -/// are [dynamically dispatched]. To use the trait this way, it must be 'dyn-compatible'[^1]. +/// are [dynamically dispatched]. To use the trait this way, it must be *dyn compatible*[^1]. /// /// Unlike generic parameters or `impl Trait`, the compiler does not know the concrete type that /// is being passed. That is, the type has been [erased]. @@ -2406,7 +2437,7 @@ mod await_keyword {} /// the function pointer and then that function pointer is called. /// /// See the Reference for more information on [trait objects][ref-trait-obj] -/// and [object safety][ref-obj-safety]. +/// and [dyn compatibility][ref-dyn-compat]. /// /// ## Trade-offs /// @@ -2419,9 +2450,9 @@ mod await_keyword {} /// [trait object]: ../book/ch17-02-trait-objects.html /// [dynamically dispatched]: https://en.wikipedia.org/wiki/Dynamic_dispatch /// [ref-trait-obj]: ../reference/types/trait-object.html -/// [ref-obj-safety]: ../reference/items/traits.html#object-safety +/// [ref-dyn-compat]: ../reference/items/traits.html#dyn-compatibility /// [erased]: https://en.wikipedia.org/wiki/Type_erasure -/// [^1]: Formerly known as 'object safe'. +/// [^1]: Formerly known as *object safe*. mod dyn_keyword {} #[doc(keyword = "union")] diff --git a/std/src/lib.rs b/std/src/lib.rs index ee6fceb024fd7..938b8c6e4f41b 100644 --- a/std/src/lib.rs +++ b/std/src/lib.rs @@ -89,7 +89,7 @@ //! Check out the Rust contribution guidelines [here]( //! https://rustc-dev-guide.rust-lang.org/contributing.html#writing-documentation). //! The source for this documentation can be found on -//! [GitHub](https://github.com/rust-lang/rust). +//! [GitHub](https://github.com/rust-lang/rust) in the 'library/std/' directory. //! To contribute changes, make sure you read the guidelines first, then submit //! pull-requests for your suggested changes. //! @@ -251,7 +251,6 @@ #![allow(explicit_outlives_requirements)] #![allow(unused_lifetimes)] #![allow(internal_features)] -#![deny(rustc::existing_doc_keyword)] #![deny(fuzzy_provenance_casts)] #![deny(unsafe_op_in_unsafe_fn)] #![allow(rustdoc::redundant_explicit_links)] @@ -262,7 +261,6 @@ #![allow(unused_features)] // // Features: -#![cfg_attr(not(bootstrap), feature(autodiff))] #![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count, rt))] #![cfg_attr( all(target_vendor = "fortanix", target_env = "sgx"), @@ -274,16 +272,18 @@ // // Language features: // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(strict_provenance))] -#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] + +// stabilization was reverted after it hit beta #![feature(alloc_error_handler)] #![feature(allocator_internals)] #![feature(allow_internal_unsafe)] #![feature(allow_internal_unstable)] #![feature(asm_experimental_arch)] +#![feature(autodiff)] #![feature(cfg_sanitizer_cfi)] #![feature(cfg_target_thread_local)] #![feature(cfi_encoding)] +#![feature(char_max_len)] #![feature(concat_idents)] #![feature(decl_macro)] #![feature(deprecated_suggestion)] @@ -295,6 +295,7 @@ #![feature(extended_varargs_abi_support)] #![feature(f128)] #![feature(f16)] +#![feature(formatting_options)] #![feature(if_let_guard)] #![feature(intra_doc_pointers)] #![feature(lang_items)] @@ -302,6 +303,7 @@ #![feature(link_cfg)] #![feature(linkage)] #![feature(macro_metavar_expr_concat)] +#![feature(maybe_uninit_fill)] #![feature(min_specialization)] #![feature(must_not_suspend)] #![feature(needs_panic_runtime)] @@ -314,6 +316,7 @@ #![feature(rustdoc_internals)] #![feature(staged_api)] #![feature(stmt_expr_attributes)] +#![feature(strict_provenance_lints)] #![feature(thread_local)] #![feature(try_blocks)] #![feature(type_alias_impl_trait)] @@ -322,7 +325,8 @@ // Library features (core): // tidy-alphabetical-start #![feature(array_chunks)] -#![feature(build_hasher_default_const_new)] +#![feature(bstr)] +#![feature(bstr_internals)] #![feature(c_str_module)] #![feature(char_internals)] #![feature(clone_to_uninit)] @@ -336,20 +340,20 @@ #![feature(extend_one)] #![feature(float_gamma)] #![feature(float_minimum_maximum)] -#![feature(float_next_up_down)] #![feature(fmt_internals)] #![feature(hasher_prefixfree_extras)] #![feature(hashmap_internals)] +#![feature(hint_must_use)] #![feature(ip)] #![feature(lazy_get)] #![feature(maybe_uninit_slice)] #![feature(maybe_uninit_write_slice)] +#![feature(nonnull_provenance)] #![feature(panic_can_unwind)] #![feature(panic_internals)] #![feature(pin_coerce_unsized_trait)] #![feature(pointer_is_aligned_to)] #![feature(portable_simd)] -#![feature(prelude_2024)] #![feature(ptr_as_uninit)] #![feature(ptr_mask)] #![feature(random)] @@ -360,7 +364,9 @@ #![feature(str_internals)] #![feature(strict_provenance_atomic_ptr)] #![feature(sync_unsafe_cell)] +#![feature(temporary_niche_types)] #![feature(ub_checks)] +#![feature(used_with_arg)] // tidy-alphabetical-end // // Library features (alloc): @@ -374,6 +380,7 @@ #![feature(thin_box)] #![feature(try_reserve_kind)] #![feature(try_with_capacity)] +#![feature(unique_rc_arc)] #![feature(vec_into_raw_parts)] // tidy-alphabetical-end // @@ -399,7 +406,6 @@ #![feature(custom_test_frameworks)] #![feature(edition_panic)] #![feature(format_args_nl)] -#![feature(get_many_mut)] #![feature(log_syntax)] #![feature(test)] #![feature(trace_macros)] @@ -409,8 +415,7 @@ // // Only for const-ness: // tidy-alphabetical-start -#![feature(const_collections_with_hasher)] -#![feature(thread_local_internals)] +#![feature(io_const_error)] // tidy-alphabetical-end // #![default_lib_allocator] @@ -529,6 +534,8 @@ pub use core::option; pub use core::pin; #[stable(feature = "rust1", since = "1.0.0")] pub use core::ptr; +#[unstable(feature = "new_range_api", issue = "125687")] +pub use core::range; #[stable(feature = "rust1", since = "1.0.0")] pub use core::result; #[stable(feature = "rust1", since = "1.0.0")] @@ -546,6 +553,8 @@ pub use core::u64; #[stable(feature = "i128", since = "1.26.0")] #[allow(deprecated, deprecated_in_future)] pub use core::u128; +#[unstable(feature = "unsafe_binders", issue = "130516")] +pub use core::unsafe_binder; #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated, deprecated_in_future)] pub use core::usize; @@ -580,6 +589,8 @@ pub mod f64; pub mod thread; pub mod ascii; pub mod backtrace; +#[unstable(feature = "bstr", issue = "134915")] +pub mod bstr; pub mod collections; pub mod env; pub mod error; @@ -591,11 +602,9 @@ pub mod net; pub mod num; pub mod os; pub mod panic; -#[unstable(feature = "core_pattern_types", issue = "123646")] +#[unstable(feature = "pattern_type_macro", issue = "123646")] pub mod pat; pub mod path; -#[unstable(feature = "anonymous_pipe", issue = "127154")] -pub mod pipe; pub mod process; #[unstable(feature = "random", issue = "130703")] pub mod random; @@ -620,7 +629,6 @@ pub mod simd { #[doc(inline)] pub use crate::std_float::StdFloat; } -#[cfg(not(bootstrap))] #[unstable(feature = "autodiff", issue = "124509")] /// This module provides support for automatic differentiation. pub mod autodiff { @@ -735,27 +743,4 @@ mod sealed { #[cfg(test)] #[allow(dead_code)] // Not used in all configurations. -pub(crate) mod test_helpers { - /// Test-only replacement for `rand::thread_rng()`, which is unusable for - /// us, as we want to allow running stdlib tests on tier-3 targets which may - /// not have `getrandom` support. - /// - /// Does a bit of a song and dance to ensure that the seed is different on - /// each call (as some tests sadly rely on this), but doesn't try that hard. - /// - /// This is duplicated in the `core`, `alloc` test suites (as well as - /// `std`'s integration tests), but figuring out a mechanism to share these - /// seems far more painful than copy-pasting a 7 line function a couple - /// times, given that even under a perma-unstable feature, I don't think we - /// want to expose types from `rand` from `std`. - #[track_caller] - pub(crate) fn test_rng() -> rand_xorshift::XorShiftRng { - use core::hash::{BuildHasher, Hash, Hasher}; - let mut hasher = crate::hash::RandomState::new().build_hasher(); - core::panic::Location::caller().hash(&mut hasher); - let hc64 = hasher.finish(); - let seed_vec = hc64.to_le_bytes().into_iter().chain(0u8..8).collect::>(); - let seed: [u8; 16] = seed_vec.as_slice().try_into().unwrap(); - rand::SeedableRng::from_seed(seed) - } -} +pub(crate) mod test_helpers; diff --git a/std/src/macros.rs b/std/src/macros.rs index 1b0d7f3dbf2c9..e0f9f0bb5cee4 100644 --- a/std/src/macros.rs +++ b/std/src/macros.rs @@ -372,18 +372,3 @@ macro_rules! dbg { ($($crate::dbg!($val)),+,) }; } - -/// Verify that floats are within a tolerance of each other, 1.0e-6 by default. -#[cfg(test)] -macro_rules! assert_approx_eq { - ($a:expr, $b:expr) => {{ assert_approx_eq!($a, $b, 1.0e-6) }}; - ($a:expr, $b:expr, $lim:expr) => {{ - let (a, b) = (&$a, &$b); - let diff = (*a - *b).abs(); - assert!( - diff < $lim, - "{a:?} is not approximately equal to {b:?} (threshold {lim:?}, difference {diff:?})", - lim = $lim - ); - }}; -} diff --git a/std/src/net/ip_addr.rs b/std/src/net/ip_addr.rs index 4d673a1d66db6..7262899b3bbbe 100644 --- a/std/src/net/ip_addr.rs +++ b/std/src/net/ip_addr.rs @@ -8,32 +8,3 @@ pub use core::net::IpAddr; pub use core::net::Ipv6MulticastScope; #[stable(feature = "rust1", since = "1.0.0")] pub use core::net::{Ipv4Addr, Ipv6Addr}; - -use crate::sys::net::netc as c; -use crate::sys_common::{FromInner, IntoInner}; - -impl IntoInner for Ipv4Addr { - #[inline] - fn into_inner(self) -> c::in_addr { - // `s_addr` is stored as BE on all machines and the array is in BE order. - // So the native endian conversion method is used so that it's never swapped. - c::in_addr { s_addr: u32::from_ne_bytes(self.octets()) } - } -} -impl FromInner for Ipv4Addr { - fn from_inner(addr: c::in_addr) -> Ipv4Addr { - Ipv4Addr::from(addr.s_addr.to_ne_bytes()) - } -} - -impl IntoInner for Ipv6Addr { - fn into_inner(self) -> c::in6_addr { - c::in6_addr { s6_addr: self.octets() } - } -} -impl FromInner for Ipv6Addr { - #[inline] - fn from_inner(addr: c::in6_addr) -> Ipv6Addr { - Ipv6Addr::from(addr.s6_addr) - } -} diff --git a/std/src/net/mod.rs b/std/src/net/mod.rs index 3b19c743b1e24..ddd3b68dd2d63 100644 --- a/std/src/net/mod.rs +++ b/std/src/net/mod.rs @@ -84,6 +84,6 @@ where } } Err(last_err.unwrap_or_else(|| { - io::const_io_error!(ErrorKind::InvalidInput, "could not resolve to any addresses") + io::const_error!(ErrorKind::InvalidInput, "could not resolve to any addresses") })) } diff --git a/std/src/net/socket_addr.rs b/std/src/net/socket_addr.rs index ba9c948a2e96f..4c8905c0d4609 100644 --- a/std/src/net/socket_addr.rs +++ b/std/src/net/socket_addr.rs @@ -6,51 +6,8 @@ mod tests; pub use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6}; use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr}; -use crate::sys::net::netc as c; -use crate::sys_common::net::LookupHost; -use crate::sys_common::{FromInner, IntoInner}; -use crate::{io, iter, mem, option, slice, vec}; - -impl FromInner for SocketAddrV4 { - fn from_inner(addr: c::sockaddr_in) -> SocketAddrV4 { - SocketAddrV4::new(Ipv4Addr::from_inner(addr.sin_addr), u16::from_be(addr.sin_port)) - } -} - -impl FromInner for SocketAddrV6 { - fn from_inner(addr: c::sockaddr_in6) -> SocketAddrV6 { - SocketAddrV6::new( - Ipv6Addr::from_inner(addr.sin6_addr), - u16::from_be(addr.sin6_port), - addr.sin6_flowinfo, - addr.sin6_scope_id, - ) - } -} - -impl IntoInner for SocketAddrV4 { - fn into_inner(self) -> c::sockaddr_in { - c::sockaddr_in { - sin_family: c::AF_INET as c::sa_family_t, - sin_port: self.port().to_be(), - sin_addr: self.ip().into_inner(), - ..unsafe { mem::zeroed() } - } - } -} - -impl IntoInner for SocketAddrV6 { - fn into_inner(self) -> c::sockaddr_in6 { - c::sockaddr_in6 { - sin6_family: c::AF_INET6 as c::sa_family_t, - sin6_port: self.port().to_be(), - sin6_addr: self.ip().into_inner(), - sin6_flowinfo: self.flowinfo(), - sin6_scope_id: self.scope_id(), - ..unsafe { mem::zeroed() } - } - } -} +use crate::sys::net::LookupHost; +use crate::{io, iter, option, slice, vec}; /// A trait for objects which can be converted or resolved to one or more /// [`SocketAddr`] values. diff --git a/std/src/net/tcp.rs b/std/src/net/tcp.rs index 67a0f7e439d55..9b68f872955c0 100644 --- a/std/src/net/tcp.rs +++ b/std/src/net/tcp.rs @@ -15,7 +15,8 @@ use crate::io::prelude::*; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; use crate::iter::FusedIterator; use crate::net::{Shutdown, SocketAddr, ToSocketAddrs}; -use crate::sys_common::{AsInner, FromInner, IntoInner, net as net_imp}; +use crate::sys::net as net_imp; +use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::Duration; /// A TCP stream between a local and a remote socket. diff --git a/std/src/net/test.rs b/std/src/net/test.rs index d318d457f3569..df48b2f2420c3 100644 --- a/std/src/net/test.rs +++ b/std/src/net/test.rs @@ -5,14 +5,15 @@ use crate::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToS use crate::sync::atomic::{AtomicUsize, Ordering}; static PORT: AtomicUsize = AtomicUsize::new(0); +const BASE_PORT: u16 = 19600; pub fn next_test_ip4() -> SocketAddr { - let port = PORT.fetch_add(1, Ordering::Relaxed) as u16 + base_port(); + let port = PORT.fetch_add(1, Ordering::Relaxed) as u16 + BASE_PORT; SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), port)) } pub fn next_test_ip6() -> SocketAddr { - let port = PORT.fetch_add(1, Ordering::Relaxed) as u16 + base_port(); + let port = PORT.fetch_add(1, Ordering::Relaxed) as u16 + BASE_PORT; SocketAddr::V6(SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), port, 0, 0)) } @@ -31,30 +32,13 @@ pub fn tsa(a: A) -> Result, String> { } } -// The bots run multiple builds at the same time, and these builds -// all want to use ports. This function figures out which workspace -// it is running in and assigns a port range based on it. -fn base_port() -> u16 { - let cwd = if cfg!(target_env = "sgx") { - String::from("sgx") - } else { - env::current_dir().unwrap().into_os_string().into_string().unwrap() - }; - let dirs = [ - "32-opt", - "32-nopt", - "musl-64-opt", - "cross-opt", - "64-opt", - "64-nopt", - "64-opt-vg", - "64-debug-opt", - "all-opt", - "snap3", - "dist", - "sgx", - ]; - dirs.iter().enumerate().find(|&(_, dir)| cwd.contains(dir)).map(|p| p.0).unwrap_or(0) as u16 - * 1000 - + 19600 +pub fn compare_ignore_zoneid(a: &SocketAddr, b: &SocketAddr) -> bool { + match (a, b) { + (SocketAddr::V6(a), SocketAddr::V6(b)) => { + a.ip().segments() == b.ip().segments() + && a.flowinfo() == b.flowinfo() + && a.port() == b.port() + } + _ => a == b, + } } diff --git a/std/src/net/udp.rs b/std/src/net/udp.rs index 6df47d7b0e0cd..3eb798ad34aaa 100644 --- a/std/src/net/udp.rs +++ b/std/src/net/udp.rs @@ -12,7 +12,8 @@ mod tests; use crate::fmt; use crate::io::{self, ErrorKind}; use crate::net::{Ipv4Addr, Ipv6Addr, SocketAddr, ToSocketAddrs}; -use crate::sys_common::{AsInner, FromInner, IntoInner, net as net_imp}; +use crate::sys::net as net_imp; +use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::Duration; /// A UDP socket. @@ -203,9 +204,7 @@ impl UdpSocket { pub fn send_to(&self, buf: &[u8], addr: A) -> io::Result { match addr.to_socket_addrs()?.next() { Some(addr) => self.0.send_to(buf, &addr), - None => { - Err(io::const_io_error!(ErrorKind::InvalidInput, "no addresses to send data to")) - } + None => Err(io::const_error!(ErrorKind::InvalidInput, "no addresses to send data to")), } } diff --git a/std/src/net/udp/tests.rs b/std/src/net/udp/tests.rs index 1c8c58d187957..91da3135f97c6 100644 --- a/std/src/net/udp/tests.rs +++ b/std/src/net/udp/tests.rs @@ -1,4 +1,4 @@ -use crate::net::test::{next_test_ip4, next_test_ip6}; +use crate::net::test::{compare_ignore_zoneid, next_test_ip4, next_test_ip6}; use crate::net::*; use crate::sync::mpsc::channel; use crate::thread; @@ -46,7 +46,7 @@ fn socket_smoke_test_ip4() { let (nread, src) = t!(server.recv_from(&mut buf)); assert_eq!(nread, 1); assert_eq!(buf[0], 99); - assert_eq!(src, client_ip); + assert_eq!(compare_ignore_zoneid(&src, &client_ip), true); rx2.recv().unwrap(); }) } @@ -78,7 +78,9 @@ fn udp_clone_smoke() { let _t = thread::spawn(move || { let mut buf = [0, 0]; - assert_eq!(sock2.recv_from(&mut buf).unwrap(), (1, addr1)); + let res = sock2.recv_from(&mut buf).unwrap(); + assert_eq!(res.0, 1); + assert_eq!(compare_ignore_zoneid(&res.1, &addr1), true); assert_eq!(buf[0], 1); t!(sock2.send_to(&[2], &addr1)); }); @@ -94,7 +96,9 @@ fn udp_clone_smoke() { }); tx1.send(()).unwrap(); let mut buf = [0, 0]; - assert_eq!(sock1.recv_from(&mut buf).unwrap(), (1, addr2)); + let res = sock1.recv_from(&mut buf).unwrap(); + assert_eq!(res.0, 1); + assert_eq!(compare_ignore_zoneid(&res.1, &addr2), true); rx2.recv().unwrap(); }) } diff --git a/std/src/num.rs b/std/src/num.rs index d2f679e7dde54..ffb8789c906ef 100644 --- a/std/src/num.rs +++ b/std/src/num.rs @@ -6,9 +6,6 @@ #![stable(feature = "rust1", since = "1.0.0")] #![allow(missing_docs)] -#[cfg(test)] -mod tests; - #[stable(feature = "int_error_matching", since = "1.55.0")] pub use core::num::IntErrorKind; #[stable(feature = "generic_nonzero", since = "1.79.0")] @@ -29,28 +26,3 @@ pub use core::num::{FpCategory, ParseFloatError, ParseIntError, TryFromIntError} pub use core::num::{NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroIsize}; #[stable(feature = "nonzero", since = "1.28.0")] pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize}; - -#[cfg(test)] -use crate::fmt; -#[cfg(test)] -use crate::ops::{Add, Div, Mul, Rem, Sub}; - -/// Helper function for testing numeric operations -#[cfg(test)] -pub fn test_num(ten: T, two: T) -where - T: PartialEq - + Add - + Sub - + Mul - + Div - + Rem - + fmt::Debug - + Copy, -{ - assert_eq!(ten.add(two), ten + two); - assert_eq!(ten.sub(two), ten - two); - assert_eq!(ten.mul(two), ten * two); - assert_eq!(ten.div(two), ten / two); - assert_eq!(ten.rem(two), ten % two); -} diff --git a/std/src/os/darwin/mod.rs b/std/src/os/darwin/mod.rs index 7a057ddb861b7..3b1bd974fa313 100644 --- a/std/src/os/darwin/mod.rs +++ b/std/src/os/darwin/mod.rs @@ -13,7 +13,7 @@ //! `aarch64-apple-darwin` target names, which are mostly named that way for //! legacy reasons. -#![stable(feature = "os_darwin", since = "CURRENT_RUSTC_VERSION")] +#![stable(feature = "os_darwin", since = "1.84.0")] #![doc(cfg(target_vendor = "apple"))] pub mod fs; diff --git a/std/src/os/emscripten/fs.rs b/std/src/os/emscripten/fs.rs index 3282b79ac1c81..81f9ef331a5fa 100644 --- a/std/src/os/emscripten/fs.rs +++ b/std/src/os/emscripten/fs.rs @@ -63,7 +63,7 @@ pub trait MetadataExt { impl MetadataExt for Metadata { #[allow(deprecated)] fn as_raw_stat(&self) -> &raw::stat { - unsafe { &*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat) } + unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) } } fn st_dev(&self) -> u64 { self.as_inner().as_inner().st_dev as u64 diff --git a/std/src/os/emscripten/raw.rs b/std/src/os/emscripten/raw.rs index d23011c738141..7ae8c45a6f80a 100644 --- a/std/src/os/emscripten/raw.rs +++ b/std/src/os/emscripten/raw.rs @@ -1,6 +1,4 @@ //! Emscripten-specific raw type definitions -//! This is basically exactly the same as the linux definitions, -//! except using the musl-specific stat64 structure in liblibc. #![stable(feature = "raw_ext", since = "1.1.0")] #![deprecated( diff --git a/std/src/os/fd/net.rs b/std/src/os/fd/net.rs index 843f45f7f5f98..34479ca0e190e 100644 --- a/std/src/os/fd/net.rs +++ b/std/src/os/fd/net.rs @@ -1,6 +1,6 @@ use crate::os::fd::owned::OwnedFd; use crate::os::fd::raw::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; -use crate::sys_common::{self, AsInner, FromInner, IntoInner}; +use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::{net, sys}; macro_rules! impl_as_raw_fd { @@ -24,7 +24,7 @@ macro_rules! impl_from_raw_fd { unsafe fn from_raw_fd(fd: RawFd) -> net::$t { unsafe { let socket = sys::net::Socket::from_inner(FromInner::from_inner(OwnedFd::from_raw_fd(fd))); - net::$t::from_inner(sys_common::net::$t::from_inner(socket)) + net::$t::from_inner(sys::net::$t::from_inner(socket)) } } } diff --git a/std/src/os/fd/owned.rs b/std/src/os/fd/owned.rs index 388b8a88a1a48..5cec11ecccf1c 100644 --- a/std/src/os/fd/owned.rs +++ b/std/src/os/fd/owned.rs @@ -11,6 +11,8 @@ use crate::sys::cvt; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::{fmt, fs, io}; +type ValidRawFd = core::num::niche_types::NotAllOnes; + /// A borrowed file descriptor. /// /// This has a lifetime parameter to tie it to the lifetime of something that owns the file @@ -32,15 +34,10 @@ use crate::{fmt, fs, io}; /// instead, but this is not supported on all platforms. #[derive(Copy, Clone)] #[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(0)] -// libstd/os/raw/mod.rs assures me that every libstd-supported platform has a -// 32-bit c_int. Below is -2, in two's complement, but that only works out -// because c_int is 32 bits. -#[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)] #[rustc_nonnull_optimization_guaranteed] #[stable(feature = "io_safety", since = "1.63.0")] pub struct BorrowedFd<'fd> { - fd: RawFd, + fd: ValidRawFd, _phantom: PhantomData<&'fd OwnedFd>, } @@ -56,15 +53,10 @@ pub struct BorrowedFd<'fd> { /// /// You can use [`AsFd::as_fd`] to obtain a [`BorrowedFd`]. #[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(0)] -// libstd/os/raw/mod.rs assures me that every libstd-supported platform has a -// 32-bit c_int. Below is -2, in two's complement, but that only works out -// because c_int is 32 bits. -#[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)] #[rustc_nonnull_optimization_guaranteed] #[stable(feature = "io_safety", since = "1.63.0")] pub struct OwnedFd { - fd: RawFd, + fd: ValidRawFd, } impl BorrowedFd<'_> { @@ -75,12 +67,11 @@ impl BorrowedFd<'_> { /// The resource pointed to by `fd` must remain open for the duration of /// the returned `BorrowedFd`, and it must not have the value `-1`. #[inline] + #[track_caller] #[rustc_const_stable(feature = "io_safety", since = "1.63.0")] #[stable(feature = "io_safety", since = "1.63.0")] pub const unsafe fn borrow_raw(fd: RawFd) -> Self { - assert!(fd != u32::MAX as RawFd); - // SAFETY: we just asserted that the value is in the valid range and isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) - unsafe { Self { fd, _phantom: PhantomData } } + Self { fd: ValidRawFd::new(fd).expect("fd != -1"), _phantom: PhantomData } } } @@ -130,7 +121,7 @@ impl BorrowedFd<'_> { impl AsRawFd for BorrowedFd<'_> { #[inline] fn as_raw_fd(&self) -> RawFd { - self.fd + self.fd.as_inner() } } @@ -138,7 +129,7 @@ impl AsRawFd for BorrowedFd<'_> { impl AsRawFd for OwnedFd { #[inline] fn as_raw_fd(&self) -> RawFd { - self.fd + self.fd.as_inner() } } @@ -146,7 +137,7 @@ impl AsRawFd for OwnedFd { impl IntoRawFd for OwnedFd { #[inline] fn into_raw_fd(self) -> RawFd { - ManuallyDrop::new(self).fd + ManuallyDrop::new(self).fd.as_inner() } } @@ -161,10 +152,9 @@ impl FromRawFd for OwnedFd { /// /// [io-safety]: io#io-safety #[inline] + #[track_caller] unsafe fn from_raw_fd(fd: RawFd) -> Self { - assert_ne!(fd, u32::MAX as RawFd); - // SAFETY: we just asserted that the value is in the valid range and isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) - unsafe { Self { fd } } + Self { fd: ValidRawFd::new(fd).expect("fd != -1") } } } @@ -187,12 +177,12 @@ impl Drop for OwnedFd { #[cfg(not(target_os = "hermit"))] { #[cfg(unix)] - crate::sys::fs::debug_assert_fd_is_open(self.fd); + crate::sys::fs::debug_assert_fd_is_open(self.fd.as_inner()); - let _ = libc::close(self.fd); + let _ = libc::close(self.fd.as_inner()); } #[cfg(target_os = "hermit")] - let _ = hermit_abi::close(self.fd); + let _ = hermit_abi::close(self.fd.as_inner()); } } } @@ -428,6 +418,14 @@ impl AsFd for crate::rc::Rc { } } +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl AsFd for crate::rc::UniqueRc { + #[inline] + fn as_fd(&self) -> BorrowedFd<'_> { + (**self).as_fd() + } +} + #[stable(feature = "asfd_ptrs", since = "1.64.0")] impl AsFd for Box { #[inline] diff --git a/std/src/os/fd/raw.rs b/std/src/os/fd/raw.rs index 0d99d5492a268..03dff94350dad 100644 --- a/std/src/os/fd/raw.rs +++ b/std/src/os/fd/raw.rs @@ -19,11 +19,9 @@ use crate::sys_common::{AsInner, IntoInner}; use crate::{fs, io}; /// Raw file descriptors. -#[rustc_allowed_through_unstable_modules] #[stable(feature = "rust1", since = "1.0.0")] #[cfg(not(target_os = "hermit"))] pub type RawFd = raw::c_int; -#[rustc_allowed_through_unstable_modules] #[stable(feature = "rust1", since = "1.0.0")] #[cfg(target_os = "hermit")] pub type RawFd = i32; @@ -33,7 +31,6 @@ pub type RawFd = i32; /// This is only available on unix and WASI platforms and must be imported in /// order to call the method. Windows platforms have a corresponding /// `AsRawHandle` and `AsRawSocket` set of traits. -#[rustc_allowed_through_unstable_modules] #[stable(feature = "rust1", since = "1.0.0")] pub trait AsRawFd { /// Extracts the raw file descriptor. @@ -67,7 +64,6 @@ pub trait AsRawFd { /// A trait to express the ability to construct an object from a raw file /// descriptor. -#[rustc_allowed_through_unstable_modules] #[stable(feature = "from_raw_os", since = "1.1.0")] pub trait FromRawFd { /// Constructs a new instance of `Self` from the given raw file @@ -112,7 +108,6 @@ pub trait FromRawFd { /// A trait to express the ability to consume an object and acquire ownership of /// its raw file descriptor. -#[rustc_allowed_through_unstable_modules] #[stable(feature = "into_raw_os", since = "1.4.0")] pub trait IntoRawFd { /// Consumes this object, returning the raw underlying file descriptor. @@ -266,6 +261,14 @@ impl AsRawFd for crate::rc::Rc { } } +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl AsRawFd for crate::rc::UniqueRc { + #[inline] + fn as_raw_fd(&self) -> RawFd { + (**self).as_raw_fd() + } +} + #[stable(feature = "asrawfd_ptrs", since = "1.63.0")] impl AsRawFd for Box { #[inline] diff --git a/std/src/os/fd/tests.rs b/std/src/os/fd/tests.rs index b39863644f116..7e9cf038e9a75 100644 --- a/std/src/os/fd/tests.rs +++ b/std/src/os/fd/tests.rs @@ -36,7 +36,6 @@ fn test_fd() { #[cfg(any(unix, target_os = "wasi"))] #[test] fn test_niche_optimizations() { - use crate::mem::size_of; #[cfg(unix)] use crate::os::unix::io::{BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; #[cfg(target_os = "wasi")] diff --git a/std/src/os/hermit/io/net.rs b/std/src/os/hermit/io/net.rs index 7a774345b231a..233bc885fc733 100644 --- a/std/src/os/hermit/io/net.rs +++ b/std/src/os/hermit/io/net.rs @@ -23,7 +23,7 @@ macro_rules! impl_from_raw_fd { unsafe fn from_raw_fd(fd: RawFd) -> net::$t { unsafe { let socket = sys::net::Socket::from_inner(FromInner::from_inner(OwnedFd::from_raw_fd(fd))); - net::$t::from_inner(sys_common::net::$t::from_inner(socket)) + net::$t::from_inner(sys::net::$t::from_inner(socket)) } } } diff --git a/std/src/os/hurd/fs.rs b/std/src/os/hurd/fs.rs index 00ff1560f31d9..e3087fa8af1cc 100644 --- a/std/src/os/hurd/fs.rs +++ b/std/src/os/hurd/fs.rs @@ -298,7 +298,7 @@ pub trait MetadataExt { #[stable(feature = "metadata_ext", since = "1.1.0")] impl MetadataExt for Metadata { fn st_dev(&self) -> u64 { - self.as_inner().as_inner().st_fsid as u64 + self.as_inner().as_inner().st_dev as u64 } fn st_ino(&self) -> u64 { self.as_inner().as_inner().st_ino as u64 diff --git a/std/src/os/hurd/mod.rs b/std/src/os/hurd/mod.rs index aee86c7f61655..6cd50aeada1da 100644 --- a/std/src/os/hurd/mod.rs +++ b/std/src/os/hurd/mod.rs @@ -1,6 +1,7 @@ //! Hurd-specific definitions #![stable(feature = "raw_ext", since = "1.1.0")] +#![forbid(unsafe_op_in_unsafe_fn)] pub mod fs; pub mod raw; diff --git a/std/src/os/solid/io.rs b/std/src/os/solid/io.rs index 2d18f33961506..c23d842b238b8 100644 --- a/std/src/os/solid/io.rs +++ b/std/src/os/solid/io.rs @@ -48,12 +48,15 @@ use crate::marker::PhantomData; use crate::mem::ManuallyDrop; -use crate::sys_common::{self, AsInner, FromInner, IntoInner}; +use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::{fmt, net, sys}; /// Raw file descriptors. pub type RawFd = i32; +// The max of this is -2, in two's complement. -1 is `SOLID_NET_INVALID_FD`. +type ValidRawFd = core::num::niche_types::NotAllOnes; + /// A borrowed SOLID Sockets file descriptor. /// /// This has a lifetime parameter to tie it to the lifetime of something that @@ -69,12 +72,9 @@ pub type RawFd = i32; /// socket, which is then borrowed under the same lifetime. #[derive(Copy, Clone)] #[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(0)] -// This is -2, in two's complement. -1 is `SOLID_NET_INVALID_FD`. -#[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)] #[rustc_nonnull_optimization_guaranteed] pub struct BorrowedFd<'socket> { - fd: RawFd, + fd: ValidRawFd, _phantom: PhantomData<&'socket OwnedFd>, } @@ -87,12 +87,9 @@ pub struct BorrowedFd<'socket> { /// an argument, it is not captured or consumed, and it never has the value /// `SOLID_NET_INVALID_FD`. #[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(0)] -// This is -2, in two's complement. -1 is `SOLID_NET_INVALID_FD`. -#[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)] #[rustc_nonnull_optimization_guaranteed] pub struct OwnedFd { - fd: RawFd, + fd: ValidRawFd, } impl BorrowedFd<'_> { @@ -104,11 +101,9 @@ impl BorrowedFd<'_> { /// the returned `BorrowedFd`, and it must not have the value /// `SOLID_NET_INVALID_FD`. #[inline] + #[track_caller] pub const unsafe fn borrow_raw(fd: RawFd) -> Self { - assert!(fd != -1 as RawFd); - // SAFETY: we just asserted that the value is in the valid range and - // isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) - unsafe { Self { fd, _phantom: PhantomData } } + Self { fd: ValidRawFd::new(fd).expect("fd != -1"), _phantom: PhantomData } } } @@ -124,7 +119,7 @@ impl BorrowedFd<'_> { /// Creates a new `OwnedFd` instance that shares the same underlying file /// description as the existing `BorrowedFd` instance. pub fn try_clone_to_owned(&self) -> crate::io::Result { - let fd = sys::net::cvt(unsafe { sys::net::netc::dup(self.as_raw_fd()) })?; + let fd = sys::net::cvt(unsafe { crate::sys::abi::sockets::dup(self.as_raw_fd()) })?; Ok(unsafe { OwnedFd::from_raw_fd(fd) }) } } @@ -132,21 +127,21 @@ impl BorrowedFd<'_> { impl AsRawFd for BorrowedFd<'_> { #[inline] fn as_raw_fd(&self) -> RawFd { - self.fd + self.fd.as_inner() } } impl AsRawFd for OwnedFd { #[inline] fn as_raw_fd(&self) -> RawFd { - self.fd + self.fd.as_inner() } } impl IntoRawFd for OwnedFd { #[inline] fn into_raw_fd(self) -> RawFd { - ManuallyDrop::new(self).fd + ManuallyDrop::new(self).fd.as_inner() } } @@ -158,18 +153,16 @@ impl FromRawFd for OwnedFd { /// The resource pointed to by `fd` must be open and suitable for assuming /// ownership. The resource must not require any cleanup other than `close`. #[inline] + #[track_caller] unsafe fn from_raw_fd(fd: RawFd) -> Self { - assert_ne!(fd, -1 as RawFd); - // SAFETY: we just asserted that the value is in the valid range and - // isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) - unsafe { Self { fd } } + Self { fd: ValidRawFd::new(fd).expect("fd != -1") } } } impl Drop for OwnedFd { #[inline] fn drop(&mut self) { - unsafe { sys::net::netc::close(self.fd) }; + unsafe { crate::sys::abi::sockets::close(self.fd.as_inner()) }; } } @@ -388,7 +381,7 @@ macro_rules! impl_from_raw_fd { #[inline] unsafe fn from_raw_fd(fd: RawFd) -> net::$t { let socket = unsafe { sys::net::Socket::from_raw_fd(fd) }; - net::$t::from_inner(sys_common::net::$t::from_inner(socket)) + net::$t::from_inner(sys::net::$t::from_inner(socket)) } } )*}; diff --git a/std/src/os/unix/fs.rs b/std/src/os/unix/fs.rs index ba6481f052cdf..04a45fd035a55 100644 --- a/std/src/os/unix/fs.rs +++ b/std/src/os/unix/fs.rs @@ -987,6 +987,11 @@ impl DirBuilderExt for fs::DirBuilder { /// Changing the group typically requires either being the owner and a member of the group, or /// having privileges. /// +/// Be aware that changing owner clears the `suid` and `sgid` permission bits in most cases +/// according to POSIX, usually even if the user is root. The sgid is not cleared when +/// the file is non-group-executable. See: +/// This call may also clear file capabilities, if there was any. +/// /// If called on a symbolic link, this will change the owner and group of the link target. To /// change the owner and group of the link itself, see [`lchown`]. /// diff --git a/std/src/os/unix/fs/tests.rs b/std/src/os/unix/fs/tests.rs index 67f607bd46837..db9621c8c205c 100644 --- a/std/src/os/unix/fs/tests.rs +++ b/std/src/os/unix/fs/tests.rs @@ -3,7 +3,7 @@ use super::*; #[test] fn read_vectored_at() { let msg = b"preadv is working!"; - let dir = crate::sys_common::io::test::tmpdir(); + let dir = crate::test_helpers::tmpdir(); let filename = dir.join("preadv.txt"); { @@ -31,7 +31,7 @@ fn read_vectored_at() { #[test] fn write_vectored_at() { let msg = b"pwritev is not working!"; - let dir = crate::sys_common::io::test::tmpdir(); + let dir = crate::test_helpers::tmpdir(); let filename = dir.join("preadv.txt"); { diff --git a/std/src/os/unix/io/tests.rs b/std/src/os/unix/io/tests.rs index 84d2a7a1a91b4..fc147730578ac 100644 --- a/std/src/os/unix/io/tests.rs +++ b/std/src/os/unix/io/tests.rs @@ -1,4 +1,3 @@ -use crate::mem::size_of; use crate::os::unix::io::RawFd; #[test] diff --git a/std/src/os/unix/net/addr.rs b/std/src/os/unix/net/addr.rs index 253e1503cf7af..cb1246db3109e 100644 --- a/std/src/os/unix/net/addr.rs +++ b/std/src/os/unix/net/addr.rs @@ -30,14 +30,14 @@ pub(super) fn sockaddr_un(path: &Path) -> io::Result<(libc::sockaddr_un, libc::s let bytes = path.as_os_str().as_bytes(); if bytes.contains(&0) { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, "paths must not contain interior null bytes", )); } if bytes.len() >= addr.sun_path.len() { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, "path must be shorter than SUN_LEN", )); @@ -94,7 +94,7 @@ impl SocketAddr { { unsafe { let mut addr: libc::sockaddr_un = mem::zeroed(); - let mut len = mem::size_of::() as libc::socklen_t; + let mut len = size_of::() as libc::socklen_t; cvt(f((&raw mut addr) as *mut _, &mut len))?; SocketAddr::from_parts(addr, len) } @@ -119,7 +119,7 @@ impl SocketAddr { // linux returns zero bytes of address len = SUN_PATH_OFFSET as libc::socklen_t; // i.e., zero-length address } else if addr.sun_family != libc::AF_UNIX as libc::sa_family_t { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, "file descriptor did not correspond to a Unix socket", )); @@ -273,7 +273,7 @@ impl linux_ext::addr::SocketAddrExt for SocketAddr { addr.sun_family = libc::AF_UNIX as libc::sa_family_t; if name.len() + 1 > addr.sun_path.len() { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, "abstract socket name must be shorter than SUN_LEN", )); diff --git a/std/src/os/unix/net/listener.rs b/std/src/os/unix/net/listener.rs index be236317d047d..27428c9eb2855 100644 --- a/std/src/os/unix/net/listener.rs +++ b/std/src/os/unix/net/listener.rs @@ -177,7 +177,7 @@ impl UnixListener { #[stable(feature = "unix_socket", since = "1.10.0")] pub fn accept(&self) -> io::Result<(UnixStream, SocketAddr)> { let mut storage: libc::sockaddr_un = unsafe { mem::zeroed() }; - let mut len = mem::size_of_val(&storage) as libc::socklen_t; + let mut len = size_of_val(&storage) as libc::socklen_t; let sock = self.0.accept((&raw mut storage) as *mut _, &mut len)?; let addr = SocketAddr::from_parts(storage, len)?; Ok((UnixStream(sock), addr)) diff --git a/std/src/os/unix/net/tests.rs b/std/src/os/unix/net/tests.rs index 21e2176185d25..0398a535eb54a 100644 --- a/std/src/os/unix/net/tests.rs +++ b/std/src/os/unix/net/tests.rs @@ -7,7 +7,7 @@ use crate::os::android::net::{SocketAddrExt, UnixSocketExt}; use crate::os::linux::net::{SocketAddrExt, UnixSocketExt}; #[cfg(any(target_os = "android", target_os = "linux"))] use crate::os::unix::io::AsRawFd; -use crate::sys_common::io::test::tmpdir; +use crate::test_helpers::tmpdir; use crate::thread; use crate::time::Duration; diff --git a/std/src/os/unix/net/ucred.rs b/std/src/os/unix/net/ucred.rs index e1014a4f296dd..2dd7d409e48c2 100644 --- a/std/src/os/unix/net/ucred.rs +++ b/std/src/os/unix/net/ucred.rs @@ -41,15 +41,15 @@ mod impl_linux { use libc::{SO_PEERCRED, SOL_SOCKET, c_void, getsockopt, socklen_t, ucred}; use super::UCred; + use crate::io; use crate::os::unix::io::AsRawFd; use crate::os::unix::net::UnixStream; - use crate::{io, mem}; pub fn peer_cred(socket: &UnixStream) -> io::Result { - let ucred_size = mem::size_of::(); + let ucred_size = size_of::(); // Trivial sanity checks. - assert!(mem::size_of::() <= mem::size_of::()); + assert!(size_of::() <= size_of::()); assert!(ucred_size <= u32::MAX as usize); let mut ucred_size = ucred_size as socklen_t; @@ -64,7 +64,7 @@ mod impl_linux { &mut ucred_size, ); - if ret == 0 && ucred_size as usize == mem::size_of::() { + if ret == 0 && ucred_size as usize == size_of::() { Ok(UCred { uid: ucred.uid, gid: ucred.gid, pid: Some(ucred.pid) }) } else { Err(io::Error::last_os_error()) @@ -101,9 +101,9 @@ mod impl_apple { use libc::{LOCAL_PEERPID, SOL_LOCAL, c_void, getpeereid, getsockopt, pid_t, socklen_t}; use super::UCred; + use crate::io; use crate::os::unix::io::AsRawFd; use crate::os::unix::net::UnixStream; - use crate::{io, mem}; pub fn peer_cred(socket: &UnixStream) -> io::Result { let mut cred = UCred { uid: 1, gid: 1, pid: None }; @@ -115,7 +115,7 @@ mod impl_apple { } let mut pid: pid_t = 1; - let mut pid_size = mem::size_of::() as socklen_t; + let mut pid_size = size_of::() as socklen_t; let ret = getsockopt( socket.as_raw_fd(), @@ -125,7 +125,7 @@ mod impl_apple { &mut pid_size, ); - if ret == 0 && pid_size as usize == mem::size_of::() { + if ret == 0 && pid_size as usize == size_of::() { cred.pid = Some(pid); Ok(cred) } else { diff --git a/std/src/os/wasi/fs.rs b/std/src/os/wasi/fs.rs index 9ec3e387e2ba9..34f0e89f2f1ee 100644 --- a/std/src/os/wasi/fs.rs +++ b/std/src/os/wasi/fs.rs @@ -162,13 +162,6 @@ pub trait FileExt { Ok(()) } - /// Returns the current position within the file. - /// - /// This corresponds to the `fd_tell` syscall and is similar to - /// `seek` where you offset 0 bytes from the current position. - #[doc(alias = "fd_tell")] - fn tell(&self) -> io::Result; - /// Adjusts the flags associated with this file. /// /// This corresponds to the `fd_fdstat_set_flags` syscall. @@ -240,10 +233,6 @@ impl FileExt for fs::File { self.as_inner().as_inner().pwrite(bufs, offset) } - fn tell(&self) -> io::Result { - self.as_inner().as_inner().tell() - } - fn fdstat_set_flags(&self, flags: u16) -> io::Result<()> { self.as_inner().as_inner().set_flags(flags) } @@ -261,7 +250,7 @@ impl FileExt for fs::File { a if a == wasi::ADVICE_DONTNEED.raw() => wasi::ADVICE_DONTNEED, a if a == wasi::ADVICE_NOREUSE.raw() => wasi::ADVICE_NOREUSE, _ => { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, "invalid parameter 'advice'", )); @@ -560,6 +549,5 @@ pub fn symlink_path, U: AsRef>(old_path: P, new_path: U) -> } fn osstr2str(f: &OsStr) -> io::Result<&str> { - f.to_str() - .ok_or_else(|| io::const_io_error!(io::ErrorKind::Uncategorized, "input must be utf-8")) + f.to_str().ok_or_else(|| io::const_error!(io::ErrorKind::Uncategorized, "input must be utf-8")) } diff --git a/std/src/os/wasi/io/fd.rs b/std/src/os/wasi/io/fd.rs deleted file mode 100644 index 930aca887e3c4..0000000000000 --- a/std/src/os/wasi/io/fd.rs +++ /dev/null @@ -1,9 +0,0 @@ -//! Owned and borrowed file descriptors. - -#![unstable(feature = "wasi_ext", issue = "71213")] - -// Tests for this module -#[cfg(test)] -mod tests; - -pub use crate::os::fd::owned::*; diff --git a/std/src/os/wasi/io/mod.rs b/std/src/os/wasi/io/mod.rs index 4e123a1eec8ae..5f9a735db085e 100644 --- a/std/src/os/wasi/io/mod.rs +++ b/std/src/os/wasi/io/mod.rs @@ -4,3 +4,7 @@ #[stable(feature = "io_safety_wasi", since = "1.65.0")] pub use crate::os::fd::*; + +// Tests for this module +#[cfg(test)] +mod tests; diff --git a/std/src/os/wasi/io/raw.rs b/std/src/os/wasi/io/raw.rs deleted file mode 100644 index da3b36adad409..0000000000000 --- a/std/src/os/wasi/io/raw.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! WASI-specific extensions to general I/O primitives. - -#![unstable(feature = "wasi_ext", issue = "71213")] - -// NOTE: despite the fact that this module is unstable, -// stable Rust had the capability to access the stable -// re-exported items from os::fd::raw through this -// unstable module. -// In PR #95956 the stability checker was changed to check -// all path segments of an item rather than just the last, -// which caused the aforementioned stable usage to regress -// (see issue #99502). -// As a result, the items in os::fd::raw were given the -// rustc_allowed_through_unstable_modules attribute. -// No regression tests were added to ensure this property, -// as CI is not configured to test wasm32-wasi. -// If this module is stabilized, -// you may want to remove those attributes -// (assuming no other unstable modules need them). -pub use crate::os::fd::raw::*; diff --git a/std/src/os/wasi/io/fd/tests.rs b/std/src/os/wasi/io/tests.rs similarity index 93% rename from std/src/os/wasi/io/fd/tests.rs rename to std/src/os/wasi/io/tests.rs index 418274752b0ad..c5c6a19a6c885 100644 --- a/std/src/os/wasi/io/fd/tests.rs +++ b/std/src/os/wasi/io/tests.rs @@ -1,4 +1,3 @@ -use crate::mem::size_of; use crate::os::wasi::io::RawFd; #[test] diff --git a/std/src/os/windows/io/handle.rs b/std/src/os/windows/io/handle.rs index a4fa94e2b96a4..76f5f549dd244 100644 --- a/std/src/os/windows/io/handle.rs +++ b/std/src/os/windows/io/handle.rs @@ -485,6 +485,14 @@ impl AsHandle for crate::rc::Rc { } } +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl AsHandle for crate::rc::UniqueRc { + #[inline] + fn as_handle(&self) -> BorrowedHandle<'_> { + (**self).as_handle() + } +} + #[stable(feature = "as_windows_ptrs", since = "1.71.0")] impl AsHandle for Box { #[inline] diff --git a/std/src/os/windows/io/raw.rs b/std/src/os/windows/io/raw.rs index 6658248d574c9..c0517fab95068 100644 --- a/std/src/os/windows/io/raw.rs +++ b/std/src/os/windows/io/raw.rs @@ -6,7 +6,7 @@ use crate::os::windows::io::{AsHandle, AsSocket}; use crate::os::windows::io::{OwnedHandle, OwnedSocket}; use crate::os::windows::raw; -use crate::sys_common::{self, AsInner, FromInner, IntoInner}; +use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::{fs, io, net, ptr, sys}; /// Raw HANDLEs. @@ -262,7 +262,7 @@ impl FromRawSocket for net::TcpStream { unsafe fn from_raw_socket(sock: RawSocket) -> net::TcpStream { unsafe { let sock = sys::net::Socket::from_inner(OwnedSocket::from_raw_socket(sock)); - net::TcpStream::from_inner(sys_common::net::TcpStream::from_inner(sock)) + net::TcpStream::from_inner(sys::net::TcpStream::from_inner(sock)) } } } @@ -272,7 +272,7 @@ impl FromRawSocket for net::TcpListener { unsafe fn from_raw_socket(sock: RawSocket) -> net::TcpListener { unsafe { let sock = sys::net::Socket::from_inner(OwnedSocket::from_raw_socket(sock)); - net::TcpListener::from_inner(sys_common::net::TcpListener::from_inner(sock)) + net::TcpListener::from_inner(sys::net::TcpListener::from_inner(sock)) } } } @@ -282,7 +282,7 @@ impl FromRawSocket for net::UdpSocket { unsafe fn from_raw_socket(sock: RawSocket) -> net::UdpSocket { unsafe { let sock = sys::net::Socket::from_inner(OwnedSocket::from_raw_socket(sock)); - net::UdpSocket::from_inner(sys_common::net::UdpSocket::from_inner(sock)) + net::UdpSocket::from_inner(sys::net::UdpSocket::from_inner(sock)) } } } diff --git a/std/src/os/windows/io/socket.rs b/std/src/os/windows/io/socket.rs index 1fcfb6e73ad03..1c228914de93f 100644 --- a/std/src/os/windows/io/socket.rs +++ b/std/src/os/windows/io/socket.rs @@ -9,6 +9,9 @@ use crate::mem::{self, ManuallyDrop}; use crate::sys::cvt; use crate::{fmt, io, sys}; +// The max here is -2, in two's complement. -1 is `INVALID_SOCKET`. +type ValidRawSocket = core::num::niche_types::NotAllOnes; + /// A borrowed socket. /// /// This has a lifetime parameter to tie it to the lifetime of something that @@ -24,17 +27,10 @@ use crate::{fmt, io, sys}; /// socket, which is then borrowed under the same lifetime. #[derive(Copy, Clone)] #[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(0)] -// This is -2, in two's complement. -1 is `INVALID_SOCKET`. -#[cfg_attr(target_pointer_width = "32", rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE))] -#[cfg_attr( - target_pointer_width = "64", - rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FF_FF_FF_FF_FE) -)] #[rustc_nonnull_optimization_guaranteed] #[stable(feature = "io_safety", since = "1.63.0")] pub struct BorrowedSocket<'socket> { - socket: RawSocket, + socket: ValidRawSocket, _phantom: PhantomData<&'socket OwnedSocket>, } @@ -47,17 +43,10 @@ pub struct BorrowedSocket<'socket> { /// argument or returned as an owned value, and it never has the value /// `INVALID_SOCKET`. #[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(0)] -// This is -2, in two's complement. -1 is `INVALID_SOCKET`. -#[cfg_attr(target_pointer_width = "32", rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE))] -#[cfg_attr( - target_pointer_width = "64", - rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FF_FF_FF_FF_FE) -)] #[rustc_nonnull_optimization_guaranteed] #[stable(feature = "io_safety", since = "1.63.0")] pub struct OwnedSocket { - socket: RawSocket, + socket: ValidRawSocket, } impl BorrowedSocket<'_> { @@ -69,11 +58,11 @@ impl BorrowedSocket<'_> { /// the returned `BorrowedSocket`, and it must not have the value /// `INVALID_SOCKET`. #[inline] + #[track_caller] #[rustc_const_stable(feature = "io_safety", since = "1.63.0")] #[stable(feature = "io_safety", since = "1.63.0")] pub const unsafe fn borrow_raw(socket: RawSocket) -> Self { - assert!(socket != sys::c::INVALID_SOCKET as RawSocket); - unsafe { Self { socket, _phantom: PhantomData } } + Self { socket: ValidRawSocket::new(socket).expect("socket != -1"), _phantom: PhantomData } } } @@ -101,7 +90,7 @@ impl OwnedSocket { #[cfg(target_vendor = "uwp")] pub(crate) fn set_no_inherit(&self) -> io::Result<()> { - Err(io::const_io_error!(io::ErrorKind::Unsupported, "Unavailable on UWP")) + Err(io::const_error!(io::ErrorKind::Unsupported, "unavailable on UWP")) } } @@ -172,7 +161,7 @@ fn last_error() -> io::Error { impl AsRawSocket for BorrowedSocket<'_> { #[inline] fn as_raw_socket(&self) -> RawSocket { - self.socket + self.socket.as_inner() } } @@ -180,7 +169,7 @@ impl AsRawSocket for BorrowedSocket<'_> { impl AsRawSocket for OwnedSocket { #[inline] fn as_raw_socket(&self) -> RawSocket { - self.socket + self.socket.as_inner() } } @@ -188,18 +177,16 @@ impl AsRawSocket for OwnedSocket { impl IntoRawSocket for OwnedSocket { #[inline] fn into_raw_socket(self) -> RawSocket { - ManuallyDrop::new(self).socket + ManuallyDrop::new(self).socket.as_inner() } } #[stable(feature = "io_safety", since = "1.63.0")] impl FromRawSocket for OwnedSocket { #[inline] + #[track_caller] unsafe fn from_raw_socket(socket: RawSocket) -> Self { - unsafe { - debug_assert_ne!(socket, sys::c::INVALID_SOCKET as RawSocket); - Self { socket } - } + Self { socket: ValidRawSocket::new(socket).expect("socket != -1") } } } @@ -208,7 +195,7 @@ impl Drop for OwnedSocket { #[inline] fn drop(&mut self) { unsafe { - let _ = sys::c::closesocket(self.socket as sys::c::SOCKET); + let _ = sys::c::closesocket(self.socket.as_inner() as sys::c::SOCKET); } } } @@ -279,6 +266,14 @@ impl AsSocket for crate::rc::Rc { } } +#[unstable(feature = "unique_rc_arc", issue = "112566")] +impl AsSocket for crate::rc::UniqueRc { + #[inline] + fn as_socket(&self) -> BorrowedSocket<'_> { + (**self).as_socket() + } +} + #[stable(feature = "as_windows_ptrs", since = "1.71.0")] impl AsSocket for Box { #[inline] diff --git a/std/src/os/windows/io/tests.rs b/std/src/os/windows/io/tests.rs index 41734e52e8cce..029b6f5cd3d9e 100644 --- a/std/src/os/windows/io/tests.rs +++ b/std/src/os/windows/io/tests.rs @@ -1,6 +1,5 @@ #[test] fn test_niche_optimizations_socket() { - use crate::mem::size_of; use crate::os::windows::io::{ BorrowedSocket, FromRawSocket, IntoRawSocket, OwnedSocket, RawSocket, }; diff --git a/std/src/os/windows/process.rs b/std/src/os/windows/process.rs index c2830d2eb61d1..fa65a7c51bfa0 100644 --- a/std/src/os/windows/process.rs +++ b/std/src/os/windows/process.rs @@ -4,13 +4,14 @@ #![stable(feature = "process_extensions", since = "1.2.0")] -use crate::ffi::OsStr; +use crate::ffi::{OsStr, c_void}; +use crate::mem::MaybeUninit; use crate::os::windows::io::{ AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle, }; use crate::sealed::Sealed; use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; -use crate::{process, sys}; +use crate::{io, marker, process, ptr, sys}; #[stable(feature = "process_extensions", since = "1.2.0")] impl FromRawHandle for process::Stdio { @@ -295,41 +296,25 @@ pub trait CommandExt: Sealed { #[unstable(feature = "windows_process_extensions_async_pipes", issue = "98289")] fn async_pipes(&mut self, always_async: bool) -> &mut process::Command; - /// Set a raw attribute on the command, providing extended configuration options for Windows - /// processes. + /// Executes the command as a child process with the given + /// [`ProcThreadAttributeList`], returning a handle to it. /// - /// This method allows you to specify custom attributes for a child process on Windows systems - /// using raw attribute values. Raw attributes provide extended configurability for process - /// creation, but their usage can be complex and potentially unsafe. - /// - /// The `attribute` parameter specifies the raw attribute to be set, while the `value` - /// parameter holds the value associated with that attribute. Please refer to the - /// [`windows-rs` documentation] or the [Win32 API documentation] for detailed information - /// about available attributes and their meanings. - /// - /// [`windows-rs` documentation]: https://microsoft.github.io/windows-docs-rs/doc/windows/ - /// [Win32 API documentation]: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-updateprocthreadattribute + /// This method enables the customization of attributes for the spawned + /// child process on Windows systems. + /// Attributes offer extended configurability for process creation, + /// but their usage can be intricate and potentially unsafe. /// /// # Note /// - /// The maximum number of raw attributes is the value of [`u32::MAX`]. - /// If this limit is exceeded, the call to [`process::Command::spawn`] will return an `Error` - /// indicating that the maximum number of attributes has been exceeded. - /// - /// # Safety - /// - /// The usage of raw attributes is potentially unsafe and should be done with caution. - /// Incorrect attribute values or improper configuration can lead to unexpected behavior or - /// errors. + /// By default, stdin, stdout, and stderr are inherited from the parent + /// process. /// /// # Example /// - /// The following example demonstrates how to create a child process with a specific parent - /// process ID using a raw attribute. - /// - /// ```rust + /// ``` /// #![feature(windows_process_extensions_raw_attribute)] - /// use std::os::windows::{process::CommandExt, io::AsRawHandle}; + /// use std::os::windows::io::AsRawHandle; + /// use std::os::windows::process::{CommandExt, ProcThreadAttributeList}; /// use std::process::Command; /// /// # struct ProcessDropGuard(std::process::Child); @@ -338,36 +323,27 @@ pub trait CommandExt: Sealed { /// # let _ = self.0.kill(); /// # } /// # } - /// + /// # /// let parent = Command::new("cmd").spawn()?; - /// - /// let mut child_cmd = Command::new("cmd"); + /// let parent_process_handle = parent.as_raw_handle(); + /// # let parent = ProcessDropGuard(parent); /// /// const PROC_THREAD_ATTRIBUTE_PARENT_PROCESS: usize = 0x00020000; + /// let mut attribute_list = ProcThreadAttributeList::build() + /// .attribute(PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, &parent_process_handle) + /// .finish() + /// .unwrap(); /// - /// unsafe { - /// child_cmd.raw_attribute(PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, parent.as_raw_handle() as isize); - /// } + /// let mut child = Command::new("cmd").spawn_with_attributes(&attribute_list)?; /// # - /// # let parent = ProcessDropGuard(parent); - /// - /// let mut child = child_cmd.spawn()?; - /// /// # child.kill()?; /// # Ok::<(), std::io::Error>(()) /// ``` - /// - /// # Safety Note - /// - /// Remember that improper use of raw attributes can lead to undefined behavior or security - /// vulnerabilities. Always consult the documentation and ensure proper attribute values are - /// used. #[unstable(feature = "windows_process_extensions_raw_attribute", issue = "114854")] - unsafe fn raw_attribute( + fn spawn_with_attributes( &mut self, - attribute: usize, - value: T, - ) -> &mut process::Command; + attribute_list: &ProcThreadAttributeList<'_>, + ) -> io::Result; } #[stable(feature = "windows_process_extensions", since = "1.16.0")] @@ -401,13 +377,13 @@ impl CommandExt for process::Command { self } - unsafe fn raw_attribute( + fn spawn_with_attributes( &mut self, - attribute: usize, - value: T, - ) -> &mut process::Command { - unsafe { self.as_inner_mut().raw_attribute(attribute, value) }; - self + attribute_list: &ProcThreadAttributeList<'_>, + ) -> io::Result { + self.as_inner_mut() + .spawn_with_attributes(sys::process::Stdio::Inherit, true, Some(attribute_list)) + .map(process::Child::from_inner) } } @@ -447,3 +423,241 @@ impl ExitCodeExt for process::ExitCode { process::ExitCode::from_inner(From::from(raw)) } } + +/// A wrapper around windows [`ProcThreadAttributeList`][1]. +/// +/// [1]: +#[derive(Debug)] +#[unstable(feature = "windows_process_extensions_raw_attribute", issue = "114854")] +pub struct ProcThreadAttributeList<'a> { + attribute_list: Box<[MaybeUninit]>, + _lifetime_marker: marker::PhantomData<&'a ()>, +} + +#[unstable(feature = "windows_process_extensions_raw_attribute", issue = "114854")] +impl<'a> ProcThreadAttributeList<'a> { + /// Creates a new builder for constructing a [`ProcThreadAttributeList`]. + pub fn build() -> ProcThreadAttributeListBuilder<'a> { + ProcThreadAttributeListBuilder::new() + } + + /// Returns a pointer to the underling attribute list. + #[doc(hidden)] + pub fn as_ptr(&self) -> *const MaybeUninit { + self.attribute_list.as_ptr() + } +} + +#[unstable(feature = "windows_process_extensions_raw_attribute", issue = "114854")] +impl<'a> Drop for ProcThreadAttributeList<'a> { + /// Deletes the attribute list. + /// + /// This method calls [`DeleteProcThreadAttributeList`][1] to delete the + /// underlying attribute list. + /// + /// [1]: + fn drop(&mut self) { + let lp_attribute_list = self.attribute_list.as_mut_ptr().cast::(); + unsafe { sys::c::DeleteProcThreadAttributeList(lp_attribute_list) } + } +} + +/// Builder for constructing a [`ProcThreadAttributeList`]. +#[derive(Clone, Debug)] +#[unstable(feature = "windows_process_extensions_raw_attribute", issue = "114854")] +pub struct ProcThreadAttributeListBuilder<'a> { + attributes: alloc::collections::BTreeMap, + _lifetime_marker: marker::PhantomData<&'a ()>, +} + +#[unstable(feature = "windows_process_extensions_raw_attribute", issue = "114854")] +impl<'a> ProcThreadAttributeListBuilder<'a> { + fn new() -> Self { + ProcThreadAttributeListBuilder { + attributes: alloc::collections::BTreeMap::new(), + _lifetime_marker: marker::PhantomData, + } + } + + /// Sets an attribute on the attribute list. + /// + /// The `attribute` parameter specifies the raw attribute to be set, while + /// the `value` parameter holds the value associated with that attribute. + /// Please refer to the [Windows documentation][1] for a list of valid attributes. + /// + /// # Note + /// + /// The maximum number of attributes is the value of [`u32::MAX`]. If this + /// limit is exceeded, the call to [`Self::finish`] will return an `Error` + /// indicating that the maximum number of attributes has been exceeded. + /// + /// # Safety Note + /// + /// Remember that improper use of attributes can lead to undefined behavior + /// or security vulnerabilities. Always consult the documentation and ensure + /// proper attribute values are used. + /// + /// [1]: + pub fn attribute(self, attribute: usize, value: &'a T) -> Self { + unsafe { + self.raw_attribute(attribute, ptr::addr_of!(*value).cast::(), size_of::()) + } + } + + /// Sets a raw attribute on the attribute list. + /// + /// This function is useful for setting attributes with pointers or sizes + /// that cannot be derived directly from their values. + /// + /// # Safety + /// + /// This function is marked as `unsafe` because it deals with raw pointers + /// and sizes. It is the responsibility of the caller to ensure the value + /// lives longer than the resulting [`ProcThreadAttributeList`] as well as + /// the validity of the size parameter. + /// + /// # Example + /// + /// ``` + /// #![feature(windows_process_extensions_raw_attribute)] + /// use std::ffi::c_void; + /// use std::os::windows::process::{CommandExt, ProcThreadAttributeList}; + /// use std::os::windows::raw::HANDLE; + /// use std::process::Command; + /// + /// #[repr(C)] + /// pub struct COORD { + /// pub X: i16, + /// pub Y: i16, + /// } + /// + /// extern "system" { + /// fn CreatePipe( + /// hreadpipe: *mut HANDLE, + /// hwritepipe: *mut HANDLE, + /// lppipeattributes: *const c_void, + /// nsize: u32, + /// ) -> i32; + /// fn CreatePseudoConsole( + /// size: COORD, + /// hinput: HANDLE, + /// houtput: HANDLE, + /// dwflags: u32, + /// phpc: *mut isize, + /// ) -> i32; + /// fn CloseHandle(hobject: HANDLE) -> i32; + /// } + /// + /// let [mut input_read_side, mut output_write_side, mut output_read_side, mut input_write_side] = + /// [unsafe { std::mem::zeroed::() }; 4]; + /// + /// unsafe { + /// CreatePipe(&mut input_read_side, &mut input_write_side, std::ptr::null(), 0); + /// CreatePipe(&mut output_read_side, &mut output_write_side, std::ptr::null(), 0); + /// } + /// + /// let size = COORD { X: 60, Y: 40 }; + /// let mut h_pc = unsafe { std::mem::zeroed() }; + /// unsafe { CreatePseudoConsole(size, input_read_side, output_write_side, 0, &mut h_pc) }; + /// + /// unsafe { CloseHandle(input_read_side) }; + /// unsafe { CloseHandle(output_write_side) }; + /// + /// const PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE: usize = 131094; + /// + /// let attribute_list = unsafe { + /// ProcThreadAttributeList::build() + /// .raw_attribute( + /// PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, + /// h_pc as *const c_void, + /// size_of::(), + /// ) + /// .finish()? + /// }; + /// + /// let mut child = Command::new("cmd").spawn_with_attributes(&attribute_list)?; + /// # + /// # child.kill()?; + /// # Ok::<(), std::io::Error>(()) + /// ``` + pub unsafe fn raw_attribute( + mut self, + attribute: usize, + value_ptr: *const T, + value_size: usize, + ) -> Self { + self.attributes.insert( + attribute, + ProcThreadAttributeValue { ptr: value_ptr.cast::(), size: value_size }, + ); + self + } + + /// Finalizes the construction of the `ProcThreadAttributeList`. + /// + /// # Errors + /// + /// Returns an error if the maximum number of attributes is exceeded + /// or if there is an I/O error during initialization. + pub fn finish(&self) -> io::Result> { + // To initialize our ProcThreadAttributeList, we need to determine + // how many bytes to allocate for it. The Windows API simplifies this + // process by allowing us to call `InitializeProcThreadAttributeList` + // with a null pointer to retrieve the required size. + let mut required_size = 0; + let Ok(attribute_count) = self.attributes.len().try_into() else { + return Err(io::const_error!( + io::ErrorKind::InvalidInput, + "maximum number of ProcThreadAttributes exceeded", + )); + }; + unsafe { + sys::c::InitializeProcThreadAttributeList( + ptr::null_mut(), + attribute_count, + 0, + &mut required_size, + ) + }; + + let mut attribute_list = vec![MaybeUninit::uninit(); required_size].into_boxed_slice(); + + // Once we've allocated the necessary memory, it's safe to invoke + // `InitializeProcThreadAttributeList` to properly initialize the list. + sys::cvt(unsafe { + sys::c::InitializeProcThreadAttributeList( + attribute_list.as_mut_ptr().cast::(), + attribute_count, + 0, + &mut required_size, + ) + })?; + + // # Add our attributes to the buffer. + // It's theoretically possible for the attribute count to exceed a u32 + // value. Therefore, we ensure that we don't add more attributes than + // the buffer was initialized for. + for (&attribute, value) in self.attributes.iter().take(attribute_count as usize) { + sys::cvt(unsafe { + sys::c::UpdateProcThreadAttribute( + attribute_list.as_mut_ptr().cast::(), + 0, + attribute, + value.ptr, + value.size, + ptr::null_mut(), + ptr::null_mut(), + ) + })?; + } + + Ok(ProcThreadAttributeList { attribute_list, _lifetime_marker: marker::PhantomData }) + } +} + +/// Wrapper around the value data to be used as a Process Thread Attribute. +#[derive(Clone, Debug)] +struct ProcThreadAttributeValue { + ptr: *const c_void, + size: usize, +} diff --git a/std/src/os/xous/ffi.rs b/std/src/os/xous/ffi.rs index 1db314e9ddad7..9394f0a0496b2 100644 --- a/std/src/os/xous/ffi.rs +++ b/std/src/os/xous/ffi.rs @@ -368,7 +368,7 @@ pub(crate) unsafe fn map_memory( let mut a0 = Syscall::MapMemory as usize; let mut a1 = phys.map(|p| p.as_ptr() as usize).unwrap_or_default(); let mut a2 = virt.map(|p| p.as_ptr() as usize).unwrap_or_default(); - let a3 = count * core::mem::size_of::(); + let a3 = count * size_of::(); let a4 = flags.bits(); let a5 = 0; let a6 = 0; @@ -392,7 +392,7 @@ pub(crate) unsafe fn map_memory( if result == SyscallResult::MemoryRange as usize { let start = core::ptr::with_exposed_provenance_mut::(a1); - let len = a2 / core::mem::size_of::(); + let len = a2 / size_of::(); let end = unsafe { start.add(len) }; Ok(unsafe { core::slice::from_raw_parts_mut(start, len) }) } else if result == SyscallResult::Error as usize { @@ -409,7 +409,7 @@ pub(crate) unsafe fn map_memory( pub(crate) unsafe fn unmap_memory(range: *mut [T]) -> Result<(), Error> { let mut a0 = Syscall::UnmapMemory as usize; let mut a1 = range.as_mut_ptr() as usize; - let a2 = range.len() * core::mem::size_of::(); + let a2 = range.len() * size_of::(); let a3 = 0; let a4 = 0; let a5 = 0; @@ -455,7 +455,7 @@ pub(crate) unsafe fn update_memory_flags( ) -> Result<(), Error> { let mut a0 = Syscall::UpdateMemoryFlags as usize; let mut a1 = range.as_mut_ptr() as usize; - let a2 = range.len() * core::mem::size_of::(); + let a2 = range.len() * size_of::(); let a3 = new_flags.bits(); let a4 = 0; // Process ID is currently None let a5 = 0; diff --git a/std/src/os/xous/ffi/definitions.rs b/std/src/os/xous/ffi/definitions.rs index 1b16849af03b0..345005bcc78d7 100644 --- a/std/src/os/xous/ffi/definitions.rs +++ b/std/src/os/xous/ffi/definitions.rs @@ -126,36 +126,42 @@ impl From for Error { #[stable(feature = "rust1", since = "1.0.0")] impl core::fmt::Display for Error { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{}", match self { - Error::NoError => "no error occurred", - Error::BadAlignment => "memory was not properly aligned", - Error::BadAddress => "an invalid address was supplied", - Error::OutOfMemory => "the process or service has run out of memory", - Error::MemoryInUse => "the requested address is in use", - Error::InterruptNotFound => "the requested interrupt does not exist on this platform", - Error::InterruptInUse => "the requested interrupt is currently in use", - Error::InvalidString => "the specified string was not formatted correctly", - Error::ServerExists => "a server with that address already exists", - Error::ServerNotFound => "the requetsed server could not be found", - Error::ProcessNotFound => "the target process does not exist", - Error::ProcessNotChild => "the requested operation can only be done on child processes", - Error::ProcessTerminated => "the target process has crashed", - Error::Timeout => "the requested operation timed out", - Error::InternalError => "an internal error occurred", - Error::ServerQueueFull => "the server has too many pending messages", - Error::ThreadNotAvailable => "the specified thread does not exist", - Error::UnhandledSyscall => "the kernel did not recognize that syscall", - Error::InvalidSyscall => "the syscall had incorrect parameters", - Error::ShareViolation => "an attempt was made to share memory twice", - Error::InvalidThread => "tried to resume a thread that was not ready", - Error::InvalidPid => "kernel attempted to use a pid that was not valid", - Error::AccessDenied => "no permission to perform the requested operation", - Error::UseBeforeInit => "attempt to use a service before initialization finished", - Error::DoubleFree => "the requested resource was freed twice", - Error::DebugInProgress => "kernel attempted to activate a thread being debugged", - Error::InvalidLimit => "process attempted to adjust an invalid limit", - Error::UnknownError => "an unknown error occurred", - }) + write!( + f, + "{}", + match self { + Error::NoError => "no error occurred", + Error::BadAlignment => "memory was not properly aligned", + Error::BadAddress => "an invalid address was supplied", + Error::OutOfMemory => "the process or service has run out of memory", + Error::MemoryInUse => "the requested address is in use", + Error::InterruptNotFound => + "the requested interrupt does not exist on this platform", + Error::InterruptInUse => "the requested interrupt is currently in use", + Error::InvalidString => "the specified string was not formatted correctly", + Error::ServerExists => "a server with that address already exists", + Error::ServerNotFound => "the requetsed server could not be found", + Error::ProcessNotFound => "the target process does not exist", + Error::ProcessNotChild => + "the requested operation can only be done on child processes", + Error::ProcessTerminated => "the target process has crashed", + Error::Timeout => "the requested operation timed out", + Error::InternalError => "an internal error occurred", + Error::ServerQueueFull => "the server has too many pending messages", + Error::ThreadNotAvailable => "the specified thread does not exist", + Error::UnhandledSyscall => "the kernel did not recognize that syscall", + Error::InvalidSyscall => "the syscall had incorrect parameters", + Error::ShareViolation => "an attempt was made to share memory twice", + Error::InvalidThread => "tried to resume a thread that was not ready", + Error::InvalidPid => "kernel attempted to use a pid that was not valid", + Error::AccessDenied => "no permission to perform the requested operation", + Error::UseBeforeInit => "attempt to use a service before initialization finished", + Error::DoubleFree => "the requested resource was freed twice", + Error::DebugInProgress => "kernel attempted to activate a thread being debugged", + Error::InvalidLimit => "process attempted to adjust an invalid limit", + Error::UnknownError => "an unknown error occurred", + } + ) } } diff --git a/std/src/os/xous/services/log.rs b/std/src/os/xous/services/log.rs index 1661011ca64b1..095d4f4a3e7a8 100644 --- a/std/src/os/xous/services/log.rs +++ b/std/src/os/xous/services/log.rs @@ -7,8 +7,8 @@ use crate::os::xous::ffi::Connection; /// `group_or_null([1,2,3,4,5,6,7,8], 1)` on a 32-bit system will return a /// `usize` with 5678 packed into it. fn group_or_null(data: &[u8], offset: usize) -> usize { - let start = offset * core::mem::size_of::(); - let mut out_array = [0u8; core::mem::size_of::()]; + let start = offset * size_of::(); + let mut out_array = [0u8; size_of::()]; if start < data.len() { for (dest, src) in out_array.iter_mut().zip(&data[start..]) { *dest = *src; diff --git a/std/src/panic.rs b/std/src/panic.rs index d649357a56d71..22776ae2bc4a7 100644 --- a/std/src/panic.rs +++ b/std/src/panic.rs @@ -255,6 +255,7 @@ pub use crate::panicking::{set_hook, take_hook}; #[stable(feature = "panic_any", since = "1.51.0")] #[inline] #[track_caller] +#[cfg_attr(not(test), rustc_diagnostic_item = "panic_any")] pub fn panic_any(msg: M) -> ! { crate::panicking::begin_panic(msg); } @@ -376,7 +377,9 @@ pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { /// use std::panic; /// /// let result = panic::catch_unwind(|| { -/// panic!("oh no!"); +/// if 1 != 2 { +/// panic!("oh no!"); +/// } /// }); /// /// if let Err(err) = result { @@ -529,6 +532,3 @@ pub fn get_backtrace_style() -> Option { Err(new) => BacktraceStyle::from_u8(new), } } - -#[cfg(test)] -mod tests; diff --git a/std/src/panicking.rs b/std/src/panicking.rs index ac1f547c9143f..b47b41d4bc5b7 100644 --- a/std/src/panicking.rs +++ b/std/src/panicking.rs @@ -27,6 +27,22 @@ use crate::sys::backtrace; use crate::sys::stdio::panic_output; use crate::{fmt, intrinsics, process, thread}; +// This forces codegen of the function called by panic!() inside the std crate, rather than in +// downstream crates. Primarily this is useful for rustc's codegen tests, which rely on noticing +// complete removal of panic from generated IR. Since begin_panic is inline(never), it's only +// codegen'd once per crate-graph so this pushes that to std rather than our codegen test crates. +// +// (See https://github.com/rust-lang/rust/pull/123244 for more info on why). +// +// If this is causing problems we can also modify those codegen tests to use a crate type like +// cdylib which doesn't export "Rust" symbols to downstream linkage units. +#[unstable(feature = "libstd_sys_internals", reason = "used by the panic! macro", issue = "none")] +#[doc(hidden)] +#[allow(dead_code)] +#[used(compiler)] +pub static EMPTY_PANIC: fn(&'static str) -> ! = + begin_panic::<&'static str> as fn(&'static str) -> !; + // Binary interface to the panic runtime that the standard library depends on. // // The standard library is tagged with `#![needs_panic_runtime]` (introduced in @@ -38,11 +54,11 @@ use crate::{fmt, intrinsics, process, thread}; // One day this may look a little less ad-hoc with the compiler helping out to // hook up these functions, but it is not this day! #[allow(improper_ctypes)] -extern "C" { +unsafe extern "C" { fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static); } -extern "Rust" { +unsafe extern "Rust" { /// `PanicPayload` lazily performs allocation only when needed (this avoids /// allocations when using the "abort" panic runtime). fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32; @@ -65,7 +81,9 @@ extern "C" fn __rust_foreign_exception() -> ! { rtabort!("Rust cannot catch foreign exceptions"); } +#[derive(Default)] enum Hook { + #[default] Default, Custom(Box) + 'static + Sync + Send>), } @@ -80,13 +98,6 @@ impl Hook { } } -impl Default for Hook { - #[inline] - fn default() -> Hook { - Hook::Default - } -} - static HOOK: RwLock = RwLock::new(Hook::Default); /// Registers a custom panic hook, replacing the previously registered hook. @@ -247,15 +258,34 @@ fn default_hook(info: &PanicHookInfo<'_>) { let location = info.location().unwrap(); let msg = payload_as_str(info.payload()); - let thread = thread::try_current(); - let name = thread.as_ref().and_then(|t| t.name()).unwrap_or(""); let write = #[optimize(size)] |err: &mut dyn crate::io::Write| { // Use a lock to prevent mixed output in multithreading context. // Some platforms also require it when printing a backtrace, like `SymFromAddr` on Windows. let mut lock = backtrace::lock(); - let _ = writeln!(err, "thread '{name}' panicked at {location}:\n{msg}"); + + thread::with_current_name(|name| { + let name = name.unwrap_or(""); + + // Try to write the panic message to a buffer first to prevent other concurrent outputs + // interleaving with it. + let mut buffer = [0u8; 512]; + let mut cursor = crate::io::Cursor::new(&mut buffer[..]); + + let write_msg = |dst: &mut dyn crate::io::Write| { + // We add a newline to ensure the panic message appears at the start of a line. + writeln!(dst, "\nthread '{name}' panicked at {location}:\n{msg}") + }; + + if write_msg(&mut cursor).is_ok() { + let pos = cursor.position() as usize; + let _ = err.write_all(&buffer[0..pos]); + } else { + // The message did not fit into the buffer, write it directly instead. + let _ = write_msg(err); + }; + }); static FIRST_PANIC: AtomicBool = AtomicBool::new(true); @@ -607,7 +637,7 @@ pub fn begin_panic_handler(info: &core::panic::PanicInfo<'_>) -> ! { // Lazily, the first time this gets called, run the actual string formatting. self.string.get_or_insert_with(|| { let mut s = String::new(); - let mut fmt = fmt::Formatter::new(&mut s); + let mut fmt = fmt::Formatter::new(&mut s, fmt::FormattingOptions::new()); let _err = fmt::Display::fmt(&inner, &mut fmt); s }) diff --git a/std/src/path.rs b/std/src/path.rs index b0291e3aa196f..f9f3b488f0d03 100644 --- a/std/src/path.rs +++ b/std/src/path.rs @@ -67,9 +67,6 @@ #![stable(feature = "rust1", since = "1.0.0")] #![deny(unsafe_op_in_unsafe_fn)] -#[cfg(test)] -mod tests; - use core::clone::CloneToUninit; use crate::borrow::{Borrow, Cow}; @@ -298,7 +295,7 @@ where } // Detect scheme on Redox -fn has_redox_scheme(s: &[u8]) -> bool { +pub(crate) fn has_redox_scheme(s: &[u8]) -> bool { cfg!(target_os = "redox") && s.contains(&b':') } @@ -1158,6 +1155,7 @@ impl FusedIterator for Ancestors<'_> {} /// Note that `PathBuf` does not always sanitize arguments, for example /// [`push`] allows paths built from strings which include separators: /// +/// ``` /// use std::path::PathBuf; /// /// let mut path = PathBuf::new(); @@ -1166,6 +1164,7 @@ impl FusedIterator for Ancestors<'_> {} /// path.push("windows"); /// path.push(r"..\otherdir"); /// path.push("system32"); +/// ``` /// /// The behavior of `PathBuf` may be changed to a panic on such inputs /// in the future. [`Extend::extend`] should be used to add multi-part paths. @@ -1762,7 +1761,7 @@ impl From<&Path> for Box { } } -#[stable(feature = "box_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "box_from_mut_slice", since = "1.84.0")] impl From<&mut Path> for Box { /// Creates a boxed [`Path`] from a reference. /// @@ -2000,7 +1999,7 @@ impl From<&Path> for Arc { } } -#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "shared_from_mut_slice", since = "1.84.0")] impl From<&mut Path> for Arc { /// Converts a [`Path`] into an [`Arc`] by copying the [`Path`] data into a new [`Arc`] buffer. #[inline] @@ -2030,7 +2029,7 @@ impl From<&Path> for Rc { } } -#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "shared_from_mut_slice", since = "1.84.0")] impl From<&mut Path> for Rc { /// Converts a [`Path`] into an [`Rc`] by copying the [`Path`] data into a new [`Rc`] buffer. #[inline] @@ -2153,7 +2152,7 @@ impl Path { unsafe { Path::new(OsStr::from_encoded_bytes_unchecked(s)) } } // The following (private!) function reveals the byte encoding used for OsStr. - fn as_u8_slice(&self) -> &[u8] { + pub(crate) fn as_u8_slice(&self) -> &[u8] { self.inner.as_encoded_bytes() } @@ -2321,12 +2320,7 @@ impl Path { #[must_use] #[allow(deprecated)] pub fn is_absolute(&self) -> bool { - if cfg!(target_os = "redox") { - // FIXME: Allow Redox prefixes - self.has_root() || has_redox_scheme(self.as_u8_slice()) - } else { - self.has_root() && (cfg!(any(unix, target_os = "wasi")) || self.prefix().is_some()) - } + sys::path::is_absolute(self) } /// Returns `true` if the `Path` is relative, i.e., not absolute. @@ -2349,7 +2343,7 @@ impl Path { !self.is_absolute() } - fn prefix(&self) -> Option> { + pub(crate) fn prefix(&self) -> Option> { self.components().prefix } @@ -2504,6 +2498,7 @@ impl Path { /// assert_eq!(path.strip_prefix("/test/haha/foo.txt/"), Ok(Path::new(""))); /// /// assert!(path.strip_prefix("test").is_err()); + /// assert!(path.strip_prefix("/te").is_err()); /// assert!(path.strip_prefix("/haha").is_err()); /// /// let prefix = PathBuf::from("/test/"); @@ -3580,7 +3575,7 @@ impl Error for StripPrefixError { pub fn absolute>(path: P) -> io::Result { let path = path.as_ref(); if path.as_os_str().is_empty() { - Err(io::const_io_error!(io::ErrorKind::InvalidInput, "cannot make an empty path absolute",)) + Err(io::const_error!(io::ErrorKind::InvalidInput, "cannot make an empty path absolute")) } else { sys::path::absolute(path) } diff --git a/std/src/pipe.rs b/std/src/pipe.rs deleted file mode 100644 index 891032e94a669..0000000000000 --- a/std/src/pipe.rs +++ /dev/null @@ -1,128 +0,0 @@ -//! Module for anonymous pipe -//! -//! ``` -//! #![feature(anonymous_pipe)] -//! -//! # #[cfg(miri)] fn main() {} -//! # #[cfg(not(miri))] -//! # fn main() -> std::io::Result<()> { -//! let (reader, writer) = std::pipe::pipe()?; -//! # Ok(()) -//! # } -//! ``` - -use crate::io; -use crate::sys::anonymous_pipe::{AnonPipe, pipe as pipe_inner}; - -/// Create anonymous pipe that is close-on-exec and blocking. -#[unstable(feature = "anonymous_pipe", issue = "127154")] -#[inline] -pub fn pipe() -> io::Result<(PipeReader, PipeWriter)> { - pipe_inner().map(|(reader, writer)| (PipeReader(reader), PipeWriter(writer))) -} - -/// Read end of the anonymous pipe. -#[unstable(feature = "anonymous_pipe", issue = "127154")] -#[derive(Debug)] -pub struct PipeReader(pub(crate) AnonPipe); - -/// Write end of the anonymous pipe. -#[unstable(feature = "anonymous_pipe", issue = "127154")] -#[derive(Debug)] -pub struct PipeWriter(pub(crate) AnonPipe); - -impl PipeReader { - /// Create a new [`PipeReader`] instance that shares the same underlying file description. - #[unstable(feature = "anonymous_pipe", issue = "127154")] - pub fn try_clone(&self) -> io::Result { - self.0.try_clone().map(Self) - } -} - -impl PipeWriter { - /// Create a new [`PipeWriter`] instance that shares the same underlying file description. - #[unstable(feature = "anonymous_pipe", issue = "127154")] - pub fn try_clone(&self) -> io::Result { - self.0.try_clone().map(Self) - } -} - -#[unstable(feature = "anonymous_pipe", issue = "127154")] -impl io::Read for &PipeReader { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - self.0.read(buf) - } - fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut<'_>]) -> io::Result { - self.0.read_vectored(bufs) - } - #[inline] - fn is_read_vectored(&self) -> bool { - self.0.is_read_vectored() - } - fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { - self.0.read_to_end(buf) - } - fn read_buf(&mut self, buf: io::BorrowedCursor<'_>) -> io::Result<()> { - self.0.read_buf(buf) - } -} - -#[unstable(feature = "anonymous_pipe", issue = "127154")] -impl io::Read for PipeReader { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - self.0.read(buf) - } - fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut<'_>]) -> io::Result { - self.0.read_vectored(bufs) - } - #[inline] - fn is_read_vectored(&self) -> bool { - self.0.is_read_vectored() - } - fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { - self.0.read_to_end(buf) - } - fn read_buf(&mut self, buf: io::BorrowedCursor<'_>) -> io::Result<()> { - self.0.read_buf(buf) - } -} - -#[unstable(feature = "anonymous_pipe", issue = "127154")] -impl io::Write for &PipeWriter { - fn write(&mut self, buf: &[u8]) -> io::Result { - self.0.write(buf) - } - #[inline] - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } - - fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result { - self.0.write_vectored(bufs) - } - - #[inline] - fn is_write_vectored(&self) -> bool { - self.0.is_write_vectored() - } -} - -#[unstable(feature = "anonymous_pipe", issue = "127154")] -impl io::Write for PipeWriter { - fn write(&mut self, buf: &[u8]) -> io::Result { - self.0.write(buf) - } - #[inline] - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } - - fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result { - self.0.write_vectored(bufs) - } - - #[inline] - fn is_write_vectored(&self) -> bool { - self.0.is_write_vectored() - } -} diff --git a/std/src/prelude/mod.rs b/std/src/prelude/mod.rs index 0c610ba67e65c..5f7097c26e228 100644 --- a/std/src/prelude/mod.rs +++ b/std/src/prelude/mod.rs @@ -25,6 +25,7 @@ //! //! # Prelude contents //! +//! The items included in the prelude depend on the edition of the crate. //! The first version of the prelude is used in Rust 2015 and Rust 2018, //! and lives in [`std::prelude::v1`]. //! [`std::prelude::rust_2015`] and [`std::prelude::rust_2018`] re-export this prelude. @@ -32,8 +33,9 @@ //! //! * [std::marker]::{[Copy], [Send], [Sized], [Sync], [Unpin]}, //! marker traits that indicate fundamental properties of types. -//! * [std::ops]::{[Drop], [Fn], [FnMut], [FnOnce]}, various -//! operations for both destructors and overloading `()`. +//! * [std::ops]::{[Fn], [FnMut], [FnOnce]}, and their analogous +//! async traits, [std::ops]::{[AsyncFn], [AsyncFnMut], [AsyncFnOnce]}. +//! * [std::ops]::[Drop], for implementing destructors. //! * [std::mem]::[drop], a convenience function for explicitly //! dropping a value. //! * [std::mem]::{[size_of], [size_of_val]}, to get the size of @@ -67,15 +69,21 @@ //! The prelude used in Rust 2021, [`std::prelude::rust_2021`], includes all of the above, //! and in addition re-exports: //! -//! * [std::convert]::{[TryFrom], [TryInto]}, +//! * [std::convert]::{[TryFrom], [TryInto]}. //! * [std::iter]::[FromIterator]. //! +//! The prelude used in Rust 2024, [`std::prelude::rust_2024`], includes all of the above, +//! and in addition re-exports: +//! +//! * [std::future]::{[Future], [IntoFuture]}. +//! //! [std::borrow]: crate::borrow //! [std::boxed]: crate::boxed //! [std::clone]: crate::clone //! [std::cmp]: crate::cmp //! [std::convert]: crate::convert //! [std::default]: crate::default +//! [std::future]: crate::future //! [std::iter]: crate::iter //! [std::marker]: crate::marker //! [std::mem]: crate::mem @@ -85,6 +93,7 @@ //! [`std::prelude::rust_2015`]: rust_2015 //! [`std::prelude::rust_2018`]: rust_2018 //! [`std::prelude::rust_2021`]: rust_2021 +//! [`std::prelude::rust_2024`]: rust_2024 //! [std::result]: crate::result //! [std::slice]: crate::slice //! [std::string]: crate::string @@ -94,32 +103,15 @@ //! [book-dtor]: ../../book/ch15-03-drop.html //! [book-enums]: ../../book/ch06-01-defining-an-enum.html //! [book-iter]: ../../book/ch13-02-iterators.html +//! [Future]: crate::future::Future +//! [IntoFuture]: crate::future::IntoFuture // No formatting: this file is nothing but re-exports, and their order is worth preserving. #![cfg_attr(rustfmt, rustfmt::skip)] #![stable(feature = "rust1", since = "1.0.0")] -mod common; - -/// The first version of the prelude of The Rust Standard Library. -/// -/// See the [module-level documentation](self) for more. -#[stable(feature = "rust1", since = "1.0.0")] -pub mod v1 { - #[stable(feature = "rust1", since = "1.0.0")] - pub use super::common::*; - - // Do not `doc(inline)` these `doc(hidden)` items. - #[unstable( - feature = "rustc_encodable_decodable", - issue = "none", - soft, - reason = "derive macro for `rustc-serialize`; should not be used in new code" - )] - #[allow(deprecated)] - pub use core::prelude::v1::{RustcDecodable, RustcEncodable}; -} +pub mod v1; /// The 2015 version of the prelude of The Rust Standard Library. /// @@ -158,12 +150,28 @@ pub mod rust_2021 { /// The 2024 version of the prelude of The Rust Standard Library. /// /// See the [module-level documentation](self) for more. -#[unstable(feature = "prelude_2024", issue = "121042")] +#[stable(feature = "prelude_2024", since = "1.85.0")] pub mod rust_2024 { #[stable(feature = "rust1", since = "1.0.0")] - pub use super::common::*; + #[doc(no_inline)] + pub use super::v1::*; - #[unstable(feature = "prelude_2024", issue = "121042")] + #[stable(feature = "prelude_2024", since = "1.85.0")] #[doc(no_inline)] pub use core::prelude::rust_2024::*; } + +/// The Future version of the prelude of The Rust Standard Library. +/// +/// See the [module-level documentation](self) for more. +#[doc(hidden)] +#[unstable(feature = "prelude_future", issue = "none")] +pub mod rust_future { + #[stable(feature = "rust1", since = "1.0.0")] + #[doc(no_inline)] + pub use super::v1::*; + + #[unstable(feature = "prelude_next", issue = "none")] + #[doc(no_inline)] + pub use core::prelude::rust_future::*; +} diff --git a/std/src/prelude/common.rs b/std/src/prelude/v1.rs similarity index 90% rename from std/src/prelude/common.rs rename to std/src/prelude/v1.rs index e4731280ffe35..4217f65864072 100644 --- a/std/src/prelude/common.rs +++ b/std/src/prelude/v1.rs @@ -1,7 +1,9 @@ -//! Items common to the prelude of all editions. +//! The first version of the prelude of The Rust Standard Library. //! //! See the [module-level documentation](super) for more. +#![stable(feature = "rust1", since = "1.0.0")] + // No formatting: this file is nothing but re-exports, and their order is worth preserving. #![cfg_attr(rustfmt, rustfmt::skip)] @@ -12,7 +14,7 @@ pub use crate::marker::{Send, Sized, Sync, Unpin}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use crate::ops::{Drop, Fn, FnMut, FnOnce}; -#[unstable(feature = "async_closure", issue = "62290")] +#[stable(feature = "async_closure", since = "1.85.0")] #[doc(no_inline)] pub use crate::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce}; @@ -101,6 +103,15 @@ pub use core::prelude::v1::type_ascribe; )] pub use core::prelude::v1::deref; +// Do not `doc(no_inline)` either. +#[unstable( + feature = "type_alias_impl_trait", + issue = "63063", + reason = "`type_alias_impl_trait` has open design concerns" +)] +#[cfg(not(bootstrap))] +pub use core::prelude::v1::define_opaque; + // The file so far is equivalent to core/src/prelude/v1.rs. It is duplicated // rather than glob imported because we want docs to show these re-exports as // pointing to within `std`. diff --git a/std/src/process.rs b/std/src/process.rs index 6933528cdbd0a..bdd4844b6511a 100644 --- a/std/src/process.rs +++ b/std/src/process.rs @@ -217,6 +217,7 @@ use crate::{fmt, fs, str}; /// /// [`wait`]: Child::wait #[stable(feature = "process", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "Child")] pub struct Child { pub(crate) handle: imp::Process, @@ -224,7 +225,7 @@ pub struct Child { /// has been captured. You might find it helpful to do /// /// ```ignore (incomplete) - /// let stdin = child.stdin.take().unwrap(); + /// let stdin = child.stdin.take().expect("handle present"); /// ``` /// /// to avoid partially moving the `child` and thus blocking yourself from calling @@ -236,7 +237,7 @@ pub struct Child { /// has been captured. You might find it helpful to do /// /// ```ignore (incomplete) - /// let stdout = child.stdout.take().unwrap(); + /// let stdout = child.stdout.take().expect("handle present"); /// ``` /// /// to avoid partially moving the `child` and thus blocking yourself from calling @@ -248,7 +249,7 @@ pub struct Child { /// has been captured. You might find it helpful to do /// /// ```ignore (incomplete) - /// let stderr = child.stderr.take().unwrap(); + /// let stderr = child.stderr.take().expect("handle present"); /// ``` /// /// to avoid partially moving the `child` and thus blocking yourself from calling @@ -868,13 +869,17 @@ impl Command { /// /// # Examples /// + /// Prevent any inherited `GIT_DIR` variable from changing the target of the `git` command, + /// while allowing all other variables, like `GIT_AUTHOR_NAME`. + /// /// ```no_run /// use std::process::Command; /// - /// Command::new("ls") - /// .env_remove("PATH") - /// .spawn() - /// .expect("ls command failed to start"); + /// Command::new("git") + /// .arg("commit") + /// .env_remove("GIT_DIR") + /// .spawn()?; + /// # std::io::Result::Ok(()) /// ``` #[stable(feature = "process", since = "1.0.0")] pub fn env_remove>(&mut self, key: K) -> &mut Command { @@ -896,13 +901,17 @@ impl Command { /// /// # Examples /// + /// The behavior of `sort` is affected by `LANG` and `LC_*` environment variables. + /// Clearing the environment makes `sort`'s behavior independent of the parent processes' language. + /// /// ```no_run /// use std::process::Command; /// - /// Command::new("ls") + /// Command::new("sort") + /// .arg("file.txt") /// .env_clear() - /// .spawn() - /// .expect("ls command failed to start"); + /// .spawn()?; + /// # std::io::Result::Ok(()) /// ``` #[stable(feature = "process", since = "1.0.0")] pub fn env_clear(&mut self) -> &mut Command { @@ -1052,14 +1061,14 @@ impl Command { /// use std::io::{self, Write}; /// let output = Command::new("/bin/cat") /// .arg("file.txt") - /// .output() - /// .expect("failed to execute process"); + /// .output()?; /// /// println!("status: {}", output.status); - /// io::stdout().write_all(&output.stdout).unwrap(); - /// io::stderr().write_all(&output.stderr).unwrap(); + /// io::stdout().write_all(&output.stdout)?; + /// io::stderr().write_all(&output.stderr)?; /// /// assert!(output.status.success()); + /// # io::Result::Ok(()) /// ``` #[stable(feature = "process", since = "1.0.0")] pub fn output(&mut self) -> io::Result { @@ -1283,13 +1292,13 @@ impl fmt::Debug for Output { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let stdout_utf8 = str::from_utf8(&self.stdout); let stdout_debug: &dyn fmt::Debug = match stdout_utf8 { - Ok(ref str) => str, + Ok(ref s) => s, Err(_) => &self.stdout, }; let stderr_utf8 = str::from_utf8(&self.stderr); let stderr_debug: &dyn fmt::Debug = match stderr_utf8 { - Ok(ref str) => str, + Ok(ref s) => s, Err(_) => &self.stderr, }; @@ -1391,11 +1400,11 @@ impl Stdio { /// let output = Command::new("rev") /// .stdin(Stdio::inherit()) /// .stdout(Stdio::piped()) - /// .output() - /// .expect("Failed to execute command"); + /// .output()?; /// /// print!("You piped in the reverse of: "); - /// io::stdout().write_all(&output.stdout).unwrap(); + /// io::stdout().write_all(&output.stdout)?; + /// # io::Result::Ok(()) /// ``` #[must_use] #[stable(feature = "process", since = "1.0.0")] @@ -1575,14 +1584,14 @@ impl From for Stdio { /// use std::process::Command; /// /// // With the `foo.txt` file containing "Hello, world!" - /// let file = File::open("foo.txt").unwrap(); + /// let file = File::open("foo.txt")?; /// /// let reverse = Command::new("rev") /// .stdin(file) // Implicit File conversion into a Stdio - /// .output() - /// .expect("failed reverse command"); + /// .output()?; /// /// assert_eq!(reverse.stdout, b"!dlrow ,olleH"); + /// # std::io::Result::Ok(()) /// ``` fn from(file: fs::File) -> Stdio { Stdio::from_inner(file.into_inner().into()) @@ -2107,6 +2116,7 @@ impl Child { /// [`ErrorKind`]: io::ErrorKind /// [`InvalidInput`]: io::ErrorKind::InvalidInput #[stable(feature = "process", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "child_kill")] pub fn kill(&mut self) -> io::Result<()> { self.handle.kill() } @@ -2127,6 +2137,7 @@ impl Child { /// ``` #[must_use] #[stable(feature = "process_id", since = "1.3.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "child_id")] pub fn id(&self) -> u32 { self.handle.id() } @@ -2179,7 +2190,7 @@ impl Child { /// ```no_run /// use std::process::Command; /// - /// let mut child = Command::new("ls").spawn().unwrap(); + /// let mut child = Command::new("ls").spawn()?; /// /// match child.try_wait() { /// Ok(Some(status)) => println!("exited with: {status}"), @@ -2190,6 +2201,7 @@ impl Child { /// } /// Err(e) => println!("error attempting to wait: {e}"), /// } + /// # std::io::Result::Ok(()) /// ``` #[stable(feature = "process_try_wait", since = "1.18.0")] pub fn try_wait(&mut self) -> io::Result> { @@ -2309,14 +2321,10 @@ pub fn exit(code: i32) -> ! { /// Terminates the process in an abnormal fashion. /// /// The function will never return and will immediately terminate the current -/// process in a platform specific "abnormal" manner. -/// -/// Note that because this function never returns, and that it terminates the -/// process, no destructors on the current stack or any other thread's stack -/// will be run. -/// -/// Rust IO buffers (eg, from `BufWriter`) will not be flushed. -/// Likewise, C stdio buffers will (on most platforms) not be flushed. +/// process in a platform specific "abnormal" manner. As a consequence, +/// no destructors on the current stack or any other thread's stack +/// will be run, Rust IO buffers (eg, from `BufWriter`) will not be flushed, +/// and C stdio buffers will (on most platforms) not be flushed. /// /// This is in contrast to the default behavior of [`panic!`] which unwinds /// the current thread's stack and calls all destructors. @@ -2370,6 +2378,7 @@ pub fn exit(code: i32) -> ! { /// [panic hook]: crate::panic::set_hook #[stable(feature = "process_abort", since = "1.17.0")] #[cold] +#[cfg_attr(not(test), rustc_diagnostic_item = "process_abort")] pub fn abort() -> ! { crate::sys::abort_internal(); } diff --git a/std/src/process/tests.rs b/std/src/process/tests.rs index fb0b495961c36..5879914ca206a 100644 --- a/std/src/process/tests.rs +++ b/std/src/process/tests.rs @@ -323,9 +323,13 @@ fn test_capture_env_at_spawn() { // This variable will not be present if the environment has already // been captured above. - env::set_var("RUN_TEST_NEW_ENV2", "456"); + unsafe { + env::set_var("RUN_TEST_NEW_ENV2", "456"); + } let result = cmd.output().unwrap(); - env::remove_var("RUN_TEST_NEW_ENV2"); + unsafe { + env::remove_var("RUN_TEST_NEW_ENV2"); + } let output = String::from_utf8_lossy(&result.stdout).to_string(); @@ -391,143 +395,6 @@ fn test_interior_nul_in_env_value_is_error() { } } -/// Tests that process creation flags work by debugging a process. -/// Other creation flags make it hard or impossible to detect -/// behavioral changes in the process. -#[test] -#[cfg(windows)] -fn test_creation_flags() { - use crate::os::windows::process::CommandExt; - use crate::sys::c::{BOOL, INFINITE}; - #[repr(C)] - struct DEBUG_EVENT { - pub event_code: u32, - pub process_id: u32, - pub thread_id: u32, - // This is a union in the real struct, but we don't - // need this data for the purposes of this test. - pub _junk: [u8; 164], - } - - extern "system" { - fn WaitForDebugEvent(lpDebugEvent: *mut DEBUG_EVENT, dwMilliseconds: u32) -> BOOL; - fn ContinueDebugEvent(dwProcessId: u32, dwThreadId: u32, dwContinueStatus: u32) -> BOOL; - } - - const DEBUG_PROCESS: u32 = 1; - const EXIT_PROCESS_DEBUG_EVENT: u32 = 5; - const DBG_EXCEPTION_NOT_HANDLED: u32 = 0x80010001; - - let mut child = - Command::new("cmd").creation_flags(DEBUG_PROCESS).stdin(Stdio::piped()).spawn().unwrap(); - child.stdin.take().unwrap().write_all(b"exit\r\n").unwrap(); - let mut events = 0; - let mut event = DEBUG_EVENT { event_code: 0, process_id: 0, thread_id: 0, _junk: [0; 164] }; - loop { - if unsafe { WaitForDebugEvent(&mut event as *mut DEBUG_EVENT, INFINITE) } == 0 { - panic!("WaitForDebugEvent failed!"); - } - events += 1; - - if event.event_code == EXIT_PROCESS_DEBUG_EVENT { - break; - } - - if unsafe { - ContinueDebugEvent(event.process_id, event.thread_id, DBG_EXCEPTION_NOT_HANDLED) - } == 0 - { - panic!("ContinueDebugEvent failed!"); - } - } - assert!(events > 0); -} - -/// Tests proc thread attributes by spawning a process with a custom parent process, -/// then comparing the parent process ID with the expected parent process ID. -#[test] -#[cfg(windows)] -fn test_proc_thread_attributes() { - use crate::mem; - use crate::os::windows::io::AsRawHandle; - use crate::os::windows::process::CommandExt; - use crate::sys::c::{BOOL, CloseHandle, HANDLE}; - use crate::sys::cvt; - - #[repr(C)] - #[allow(non_snake_case)] - struct PROCESSENTRY32W { - dwSize: u32, - cntUsage: u32, - th32ProcessID: u32, - th32DefaultHeapID: usize, - th32ModuleID: u32, - cntThreads: u32, - th32ParentProcessID: u32, - pcPriClassBase: i32, - dwFlags: u32, - szExeFile: [u16; 260], - } - - extern "system" { - fn CreateToolhelp32Snapshot(dwflags: u32, th32processid: u32) -> HANDLE; - fn Process32First(hsnapshot: HANDLE, lppe: *mut PROCESSENTRY32W) -> BOOL; - fn Process32Next(hsnapshot: HANDLE, lppe: *mut PROCESSENTRY32W) -> BOOL; - } - - const PROC_THREAD_ATTRIBUTE_PARENT_PROCESS: usize = 0x00020000; - const TH32CS_SNAPPROCESS: u32 = 0x00000002; - - struct ProcessDropGuard(crate::process::Child); - - impl Drop for ProcessDropGuard { - fn drop(&mut self) { - let _ = self.0.kill(); - } - } - - let parent = ProcessDropGuard(Command::new("cmd").spawn().unwrap()); - - let mut child_cmd = Command::new("cmd"); - - unsafe { - child_cmd - .raw_attribute(PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, parent.0.as_raw_handle() as isize); - } - - let child = ProcessDropGuard(child_cmd.spawn().unwrap()); - - let h_snapshot = unsafe { CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) }; - - let mut process_entry = PROCESSENTRY32W { - dwSize: mem::size_of::() as u32, - cntUsage: 0, - th32ProcessID: 0, - th32DefaultHeapID: 0, - th32ModuleID: 0, - cntThreads: 0, - th32ParentProcessID: 0, - pcPriClassBase: 0, - dwFlags: 0, - szExeFile: [0; 260], - }; - - unsafe { cvt(Process32First(h_snapshot, &mut process_entry as *mut _)) }.unwrap(); - - loop { - if child.0.id() == process_entry.th32ProcessID { - break; - } - unsafe { cvt(Process32Next(h_snapshot, &mut process_entry as *mut _)) }.unwrap(); - } - - unsafe { cvt(CloseHandle(h_snapshot)) }.unwrap(); - - assert_eq!(parent.0.id(), process_entry.th32ParentProcessID); - - drop(child) -} - #[test] fn test_command_implements_send_sync() { fn take_send_sync_type(_: T) {} @@ -686,7 +553,7 @@ fn debug_print() { #[test] #[cfg(windows)] fn run_bat_script() { - let tempdir = crate::sys_common::io::test::tmpdir(); + let tempdir = crate::test_helpers::tmpdir(); let script_path = tempdir.join("hello.cmd"); crate::fs::write(&script_path, "@echo Hello, %~1!").unwrap(); @@ -705,7 +572,7 @@ fn run_bat_script() { #[test] #[cfg(windows)] fn run_canonical_bat_script() { - let tempdir = crate::sys_common::io::test::tmpdir(); + let tempdir = crate::test_helpers::tmpdir(); let script_path = tempdir.join("hello.cmd"); crate::fs::write(&script_path, "@echo Hello, %~1!").unwrap(); diff --git a/std/src/rt.rs b/std/src/rt.rs index b2492238bd37b..3a22a16cb165e 100644 --- a/std/src/rt.rs +++ b/std/src/rt.rs @@ -23,7 +23,7 @@ pub use core::panicking::{panic_display, panic_fmt}; #[rustfmt::skip] use crate::any::Any; use crate::sync::Once; -use crate::thread::{self, Thread}; +use crate::thread::{self, main_thread}; use crate::{mem, panic, sys}; // Prints to the "panic output", depending on the platform this may be: @@ -32,9 +32,14 @@ use crate::{mem, panic, sys}; // - nothing (so this macro is a no-op) macro_rules! rtprintpanic { ($($t:tt)*) => { + #[cfg(not(feature = "panic_immediate_abort"))] if let Some(mut out) = crate::sys::stdio::panic_output() { let _ = crate::io::Write::write_fmt(&mut out, format_args!($($t)*)); } + #[cfg(feature = "panic_immediate_abort")] + { + let _ = format_args!($($t)*); + } } } @@ -67,7 +72,7 @@ macro_rules! rtunwrap { }; } -fn handle_rt_panic(e: Box) { +fn handle_rt_panic(e: Box) -> T { mem::forget(e); rtabort!("initialization or cleanup bug"); } @@ -102,24 +107,9 @@ unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { sys::init(argc, argv, sigpipe) }; - // Set up the current thread handle to give it the right name. - // - // When code running before main uses `ReentrantLock` (for example by - // using `println!`), the thread ID can become initialized before we - // create this handle. Since `set_current` fails when the ID of the - // handle does not match the current ID, we should attempt to use the - // current thread ID here instead of unconditionally creating a new - // one. Also see #130210. - let thread = unsafe { Thread::new_main(thread::current_id()) }; - if let Err(_thread) = thread::set_current(thread) { - // `thread::current` will create a new handle if none has been set yet. - // Thus, if someone uses it before main, this call will fail. That's a - // bad idea though, as we then cannot set the main thread name here. - // - // FIXME: detect the main thread in `thread::current` and use the - // correct name there. - rtabort!("code running before main must not use thread::current"); - } + // Remember the main thread ID to give it the correct name. + // SAFETY: this is the only time and place where we call this function. + unsafe { main_thread::set(thread::current_id()) }; } /// Clean up the thread-local runtime state. This *should* be run after all other @@ -157,7 +147,7 @@ fn lang_start_internal( argc: isize, argv: *const *const u8, sigpipe: u8, -) -> Result { +) -> isize { // Guard against the code called by this function from unwinding outside of the Rust-controlled // code, which is UB. This is a requirement imposed by a combination of how the // `#[lang="start"]` attribute is implemented as well as by the implementation of the panicking @@ -168,19 +158,33 @@ fn lang_start_internal( // panic is a std implementation bug. A quite likely one too, as there isn't any way to // prevent std from accidentally introducing a panic to these functions. Another is from // user code from `main` or, more nefariously, as described in e.g. issue #86030. - // SAFETY: Only called once during runtime initialization. - panic::catch_unwind(move || unsafe { init(argc, argv, sigpipe) }) - .unwrap_or_else(handle_rt_panic); - let ret_code = panic::catch_unwind(move || panic::catch_unwind(main).unwrap_or(101) as isize) - .map_err(move |e| { - mem::forget(e); - rtabort!("drop of the panic payload panicked"); + // + // We use `catch_unwind` with `handle_rt_panic` instead of `abort_unwind` to make the error in + // case of a panic a bit nicer. + panic::catch_unwind(move || { + // SAFETY: Only called once during runtime initialization. + unsafe { init(argc, argv, sigpipe) }; + + let ret_code = panic::catch_unwind(main).unwrap_or_else(move |payload| { + // Carefully dispose of the panic payload. + let payload = panic::AssertUnwindSafe(payload); + panic::catch_unwind(move || drop({ payload }.0)).unwrap_or_else(move |e| { + mem::forget(e); // do *not* drop the 2nd payload + rtabort!("drop of the panic payload panicked"); + }); + // Return error code for panicking programs. + 101 }); - panic::catch_unwind(cleanup).unwrap_or_else(handle_rt_panic); - // Guard against multiple threads calling `libc::exit` concurrently. - // See the documentation for `unique_thread_exit` for more information. - panic::catch_unwind(crate::sys::exit_guard::unique_thread_exit).unwrap_or_else(handle_rt_panic); - ret_code + let ret_code = ret_code as isize; + + cleanup(); + // Guard against multiple threads calling `libc::exit` concurrently. + // See the documentation for `unique_thread_exit` for more information. + crate::sys::exit_guard::unique_thread_exit(); + + ret_code + }) + .unwrap_or_else(handle_rt_panic) } #[cfg(not(any(test, doctest)))] @@ -191,11 +195,10 @@ fn lang_start( argv: *const *const u8, sigpipe: u8, ) -> isize { - let Ok(v) = lang_start_internal( + lang_start_internal( &move || crate::sys::backtrace::__rust_begin_short_backtrace(main).report().to_i32(), argc, argv, sigpipe, - ); - v + ) } diff --git a/std/src/sync/barrier.rs b/std/src/sync/barrier.rs index 82cc13a74b7f1..067ff66d9af73 100644 --- a/std/src/sync/barrier.rs +++ b/std/src/sync/barrier.rs @@ -1,7 +1,5 @@ -#[cfg(test)] -mod tests; - use crate::fmt; +// FIXME(nonpoison_mutex,nonpoison_condvar): switch to nonpoison versions once they are available use crate::sync::{Condvar, Mutex}; /// A barrier enables multiple threads to synchronize the beginning @@ -10,26 +8,22 @@ use crate::sync::{Condvar, Mutex}; /// # Examples /// /// ``` -/// use std::sync::{Arc, Barrier}; +/// use std::sync::Barrier; /// use std::thread; /// /// let n = 10; -/// let mut handles = Vec::with_capacity(n); -/// let barrier = Arc::new(Barrier::new(n)); -/// for _ in 0..n { -/// let c = Arc::clone(&barrier); -/// // The same messages will be printed together. -/// // You will NOT see any interleaving. -/// handles.push(thread::spawn(move || { -/// println!("before wait"); -/// c.wait(); -/// println!("after wait"); -/// })); -/// } -/// // Wait for other threads to finish. -/// for handle in handles { -/// handle.join().unwrap(); -/// } +/// let barrier = Barrier::new(n); +/// thread::scope(|s| { +/// for _ in 0..n { +/// // The same messages will be printed together. +/// // You will NOT see any interleaving. +/// s.spawn(|| { +/// println!("before wait"); +/// barrier.wait(); +/// println!("after wait"); +/// }); +/// } +/// }); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub struct Barrier { @@ -105,26 +99,22 @@ impl Barrier { /// # Examples /// /// ``` - /// use std::sync::{Arc, Barrier}; + /// use std::sync::Barrier; /// use std::thread; /// /// let n = 10; - /// let mut handles = Vec::with_capacity(n); - /// let barrier = Arc::new(Barrier::new(n)); - /// for _ in 0..n { - /// let c = Arc::clone(&barrier); - /// // The same messages will be printed together. - /// // You will NOT see any interleaving. - /// handles.push(thread::spawn(move || { - /// println!("before wait"); - /// c.wait(); - /// println!("after wait"); - /// })); - /// } - /// // Wait for other threads to finish. - /// for handle in handles { - /// handle.join().unwrap(); - /// } + /// let barrier = Barrier::new(n); + /// thread::scope(|s| { + /// for _ in 0..n { + /// // The same messages will be printed together. + /// // You will NOT see any interleaving. + /// s.spawn(|| { + /// println!("before wait"); + /// barrier.wait(); + /// println!("after wait"); + /// }); + /// } + /// }); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn wait(&self) -> BarrierWaitResult { diff --git a/std/src/sync/lazy_lock.rs b/std/src/sync/lazy_lock.rs index 40510f5613450..78cf8841efefb 100644 --- a/std/src/sync/lazy_lock.rs +++ b/std/src/sync/lazy_lock.rs @@ -1,4 +1,4 @@ -use super::once::ExclusiveState; +use super::poison::once::ExclusiveState; use crate::cell::UnsafeCell; use crate::mem::ManuallyDrop; use crate::ops::Deref; @@ -31,7 +31,7 @@ union Data { /// ``` /// use std::sync::LazyLock; /// -/// // n.b. static items do not call [`Drop`] on program termination, so this won't be deallocated. +/// // Note: static items do not call [`Drop`] on program termination, so this won't be deallocated. /// // this is fine, as the OS can deallocate the terminated program faster than we can free memory /// // but tools like valgrind might report "memory leaks" as it isn't obvious this is intentional. /// static DEEP_THOUGHT: LazyLock = LazyLock::new(|| { @@ -63,6 +63,7 @@ union Data { /// ``` #[stable(feature = "lazy_cell", since = "1.80.0")] pub struct LazyLock T> { + // FIXME(nonpoison_once): if possible, switch to nonpoison version once it is available once: Once, data: UnsafeCell>, } @@ -349,6 +350,3 @@ unsafe impl Sync for LazyLock {} impl RefUnwindSafe for LazyLock {} #[stable(feature = "lazy_cell", since = "1.80.0")] impl UnwindSafe for LazyLock {} - -#[cfg(test)] -mod tests; diff --git a/std/src/sync/mod.rs b/std/src/sync/mod.rs index 0fb77331293fe..5b50a3c6ccf90 100644 --- a/std/src/sync/mod.rs +++ b/std/src/sync/mod.rs @@ -167,6 +167,10 @@ #![stable(feature = "rust1", since = "1.0.0")] +// No formatting: this file is just re-exports, and their order is worth preserving. +#![cfg_attr(rustfmt, rustfmt::skip)] + +// These come from `core` & `alloc` and only in one flavor: no poisoning. #[unstable(feature = "exclusive_wrapper", issue = "98407")] pub use core::sync::Exclusive; #[stable(feature = "rust1", since = "1.0.0")] @@ -175,40 +179,54 @@ pub use core::sync::atomic; #[stable(feature = "rust1", since = "1.0.0")] pub use alloc_crate::sync::{Arc, Weak}; +// FIXME(sync_nonpoison,sync_poison_mod): remove all `#[doc(inline)]` once the modules are stabilized. + +// These exist only in one flavor: no poisoning. #[stable(feature = "rust1", since = "1.0.0")] pub use self::barrier::{Barrier, BarrierWaitResult}; -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::condvar::{Condvar, WaitTimeoutResult}; #[stable(feature = "lazy_cell", since = "1.80.0")] pub use self::lazy_lock::LazyLock; -#[unstable(feature = "mapped_lock_guards", issue = "117108")] -pub use self::mutex::MappedMutexGuard; -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::mutex::{Mutex, MutexGuard}; -#[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated)] -pub use self::once::{ONCE_INIT, Once, OnceState}; #[stable(feature = "once_cell", since = "1.70.0")] pub use self::once_lock::OnceLock; -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult}; #[unstable(feature = "reentrant_lock", issue = "121440")] pub use self::reentrant_lock::{ReentrantLock, ReentrantLockGuard}; -#[unstable(feature = "mapped_lock_guards", issue = "117108")] -pub use self::rwlock::{MappedRwLockReadGuard, MappedRwLockWriteGuard}; + +// These make sense and exist only with poisoning. #[stable(feature = "rust1", since = "1.0.0")] -pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; +#[doc(inline)] +pub use self::poison::{LockResult, PoisonError}; + +// These (should) exist in both flavors: with and without poisoning. +// FIXME(sync_nonpoison): implement nonpoison versions: +// * Mutex (nonpoison_mutex) +// * Condvar (nonpoison_condvar) +// * Once (nonpoison_once) +// * RwLock (nonpoison_rwlock) +// The historical default is the version with poisoning. +#[stable(feature = "rust1", since = "1.0.0")] +#[doc(inline)] +pub use self::poison::{ + Mutex, MutexGuard, TryLockError, TryLockResult, + Condvar, WaitTimeoutResult, + Once, OnceState, + RwLock, RwLockReadGuard, RwLockWriteGuard, +}; +#[stable(feature = "rust1", since = "1.0.0")] +#[doc(inline)] +#[expect(deprecated)] +pub use self::poison::ONCE_INIT; +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +#[doc(inline)] +pub use self::poison::{MappedMutexGuard, MappedRwLockReadGuard, MappedRwLockWriteGuard}; #[unstable(feature = "mpmc_channel", issue = "126840")] pub mod mpmc; pub mod mpsc; +#[unstable(feature = "sync_poison_mod", issue = "134646")] +pub mod poison; + mod barrier; -mod condvar; mod lazy_lock; -mod mutex; -pub(crate) mod once; mod once_lock; -mod poison; mod reentrant_lock; -mod rwlock; diff --git a/std/src/sync/mpmc/mod.rs b/std/src/sync/mpmc/mod.rs index 0cf4902d6d59b..8712332dd2767 100644 --- a/std/src/sync/mpmc/mod.rs +++ b/std/src/sync/mpmc/mod.rs @@ -18,7 +18,7 @@ //! infinite buffer. //! //! 2. A synchronous, bounded channel. The [`sync_channel`] function will -//! return a `(SyncSender, Receiver)` tuple where the storage for pending +//! return a `(Sender, Receiver)` tuple where the storage for pending //! messages is a pre-allocated buffer of a fixed size. All sends will be //! **synchronous** by blocking until there is buffer space available. Note //! that a bound of 0 is allowed, causing the channel to become a "rendezvous" @@ -360,9 +360,17 @@ impl Sender { /// that a return value of [`Err`] means that the data will never be /// received, but a return value of [`Ok`] does *not* mean that the data /// will be received. It is possible for the corresponding receiver to - /// hang up immediately after this function returns [`Ok`]. + /// hang up immediately after this function returns [`Ok`]. However, if + /// the channel is zero-capacity, it acts as a rendezvous channel and a + /// return value of [`Ok`] means that the data has been received. /// - /// This method will never block the current thread. + /// If the channel is full and not disconnected, this call will block until + /// the send operation can proceed. If the channel becomes disconnected, + /// this call will wake up and return an error. The returned error contains + /// the original message. + /// + /// If called on a zero-capacity channel, this method will wait for a receive + /// operation to appear on the other side of the channel. /// /// # Examples /// @@ -608,9 +616,9 @@ impl Sender { #[unstable(feature = "mpmc_channel", issue = "126840")] pub fn same_channel(&self, other: &Sender) -> bool { match (&self.flavor, &other.flavor) { - (SenderFlavor::Array(ref a), SenderFlavor::Array(ref b)) => a == b, - (SenderFlavor::List(ref a), SenderFlavor::List(ref b)) => a == b, - (SenderFlavor::Zero(ref a), SenderFlavor::Zero(ref b)) => a == b, + (SenderFlavor::Array(a), SenderFlavor::Array(b)) => a == b, + (SenderFlavor::List(a), SenderFlavor::List(b)) => a == b, + (SenderFlavor::Zero(a), SenderFlavor::Zero(b)) => a == b, _ => false, } } @@ -650,7 +658,7 @@ impl fmt::Debug for Sender { } /// The receiving half of Rust's [`channel`] (or [`sync_channel`]) type. -/// Different threads can share this [`Sender`] by cloning it. +/// Different threads can share this [`Receiver`] by cloning it. /// /// Messages sent to the channel can be retrieved using [`recv`]. /// @@ -1374,3 +1382,6 @@ impl fmt::Debug for Receiver { f.pad("Receiver { .. }") } } + +#[cfg(test)] +mod tests; diff --git a/std/src/sync/mpmc/tests.rs b/std/src/sync/mpmc/tests.rs index ab14050df6c98..6deb4dc2fe0cc 100644 --- a/std/src/sync/mpmc/tests.rs +++ b/std/src/sync/mpmc/tests.rs @@ -1,728 +1,14 @@ -use super::*; -use crate::{env, thread}; - -pub fn stress_factor() -> usize { - match env::var("RUST_TEST_STRESS") { - Ok(val) => val.parse().unwrap(), - Err(..) => 1, - } -} - -#[test] -fn smoke() { - let (tx, rx) = channel::(); - tx.send(1).unwrap(); - assert_eq!(rx.recv().unwrap(), 1); -} - -#[test] -fn drop_full() { - let (tx, _rx) = channel::>(); - tx.send(Box::new(1)).unwrap(); -} - -#[test] -fn drop_full_shared() { - let (tx, _rx) = channel::>(); - drop(tx.clone()); - drop(tx.clone()); - tx.send(Box::new(1)).unwrap(); -} - -#[test] -fn smoke_shared() { - let (tx, rx) = channel::(); - tx.send(1).unwrap(); - assert_eq!(rx.recv().unwrap(), 1); - let tx = tx.clone(); - tx.send(1).unwrap(); - assert_eq!(rx.recv().unwrap(), 1); -} - -#[test] -fn smoke_threads() { - let (tx, rx) = channel::(); - let t1 = thread::spawn(move || { - for i in 0..2 { - tx.send(i).unwrap(); - } - }); - let t2 = thread::spawn(move || { - assert_eq!(rx.recv().unwrap(), 0); - assert_eq!(rx.recv().unwrap(), 1); - }); - t1.join().unwrap(); - t2.join().unwrap(); -} - -#[test] -fn smoke_port_gone() { - let (tx, rx) = channel::(); - drop(rx); - assert!(tx.send(1).is_err()); -} - -#[test] -fn smoke_shared_port_gone() { - let (tx, rx) = channel::(); - drop(rx); - assert!(tx.send(1).is_err()) -} - -#[test] -fn smoke_shared_port_gone2() { - let (tx, rx) = channel::(); - drop(rx); - let tx2 = tx.clone(); - drop(tx); - assert!(tx2.send(1).is_err()); -} - -#[test] -fn port_gone_concurrent() { - let (tx, rx) = channel::(); - let _t = thread::spawn(move || { - rx.recv().unwrap(); - }); - while tx.send(1).is_ok() {} -} - -#[test] -fn port_gone_concurrent_shared() { - let (tx, rx) = channel::(); - let tx2 = tx.clone(); - let _t = thread::spawn(move || { - rx.recv().unwrap(); - }); - while tx.send(1).is_ok() && tx2.send(1).is_ok() {} -} - -#[test] -fn smoke_chan_gone() { - let (tx, rx) = channel::(); - drop(tx); - assert!(rx.recv().is_err()); -} - -#[test] -fn smoke_chan_gone_shared() { - let (tx, rx) = channel::<()>(); - let tx2 = tx.clone(); - drop(tx); - drop(tx2); - assert!(rx.recv().is_err()); -} - -#[test] -fn chan_gone_concurrent() { - let (tx, rx) = channel::(); - let _t = thread::spawn(move || { - tx.send(1).unwrap(); - tx.send(1).unwrap(); - }); - while rx.recv().is_ok() {} -} - -#[test] -fn stress() { - let count = if cfg!(miri) { 100 } else { 10000 }; - let (tx, rx) = channel::(); - let t = thread::spawn(move || { - for _ in 0..count { - tx.send(1).unwrap(); - } - }); - for _ in 0..count { - assert_eq!(rx.recv().unwrap(), 1); - } - t.join().ok().expect("thread panicked"); -} - -#[test] -fn stress_shared() { - const AMT: u32 = if cfg!(miri) { 100 } else { 10000 }; - const NTHREADS: u32 = 8; - let (tx, rx) = channel::(); - - let t = thread::spawn(move || { - for _ in 0..AMT * NTHREADS { - assert_eq!(rx.recv().unwrap(), 1); - } - match rx.try_recv() { - Ok(..) => panic!(), - _ => {} - } - }); - - for _ in 0..NTHREADS { - let tx = tx.clone(); - thread::spawn(move || { - for _ in 0..AMT { - tx.send(1).unwrap(); - } - }); - } - drop(tx); - t.join().ok().expect("thread panicked"); -} - -#[test] -fn send_from_outside_runtime() { - let (tx1, rx1) = channel::<()>(); - let (tx2, rx2) = channel::(); - let t1 = thread::spawn(move || { - tx1.send(()).unwrap(); - for _ in 0..40 { - assert_eq!(rx2.recv().unwrap(), 1); - } - }); - rx1.recv().unwrap(); - let t2 = thread::spawn(move || { - for _ in 0..40 { - tx2.send(1).unwrap(); - } - }); - t1.join().ok().expect("thread panicked"); - t2.join().ok().expect("thread panicked"); -} - -#[test] -fn recv_from_outside_runtime() { - let (tx, rx) = channel::(); - let t = thread::spawn(move || { - for _ in 0..40 { - assert_eq!(rx.recv().unwrap(), 1); - } - }); - for _ in 0..40 { - tx.send(1).unwrap(); - } - t.join().ok().expect("thread panicked"); -} - -#[test] -fn no_runtime() { - let (tx1, rx1) = channel::(); - let (tx2, rx2) = channel::(); - let t1 = thread::spawn(move || { - assert_eq!(rx1.recv().unwrap(), 1); - tx2.send(2).unwrap(); - }); - let t2 = thread::spawn(move || { - tx1.send(1).unwrap(); - assert_eq!(rx2.recv().unwrap(), 2); - }); - t1.join().ok().expect("thread panicked"); - t2.join().ok().expect("thread panicked"); -} - -#[test] -fn oneshot_single_thread_close_port_first() { - // Simple test of closing without sending - let (_tx, rx) = channel::(); - drop(rx); -} - -#[test] -fn oneshot_single_thread_close_chan_first() { - // Simple test of closing without sending - let (tx, _rx) = channel::(); - drop(tx); -} - -#[test] -fn oneshot_single_thread_send_port_close() { - // Testing that the sender cleans up the payload if receiver is closed - let (tx, rx) = channel::>(); - drop(rx); - assert!(tx.send(Box::new(0)).is_err()); -} - -#[test] -fn oneshot_single_thread_recv_chan_close() { - // Receiving on a closed chan will panic - let res = thread::spawn(move || { - let (tx, rx) = channel::(); - drop(tx); - rx.recv().unwrap(); - }) - .join(); - // What is our res? - assert!(res.is_err()); -} - -#[test] -fn oneshot_single_thread_send_then_recv() { - let (tx, rx) = channel::>(); - tx.send(Box::new(10)).unwrap(); - assert!(*rx.recv().unwrap() == 10); -} - -#[test] -fn oneshot_single_thread_try_send_open() { - let (tx, rx) = channel::(); - assert!(tx.send(10).is_ok()); - assert!(rx.recv().unwrap() == 10); -} - -#[test] -fn oneshot_single_thread_try_send_closed() { - let (tx, rx) = channel::(); - drop(rx); - assert!(tx.send(10).is_err()); -} - -#[test] -fn oneshot_single_thread_try_recv_open() { - let (tx, rx) = channel::(); - tx.send(10).unwrap(); - assert!(rx.recv() == Ok(10)); -} - -#[test] -fn oneshot_single_thread_try_recv_closed() { - let (tx, rx) = channel::(); - drop(tx); - assert!(rx.recv().is_err()); -} - -#[test] -fn oneshot_single_thread_peek_data() { - let (tx, rx) = channel::(); - assert_eq!(rx.try_recv(), Err(TryRecvError::Empty)); - tx.send(10).unwrap(); - assert_eq!(rx.try_recv(), Ok(10)); -} - -#[test] -fn oneshot_single_thread_peek_close() { - let (tx, rx) = channel::(); - drop(tx); - assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected)); - assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected)); -} - -#[test] -fn oneshot_single_thread_peek_open() { - let (_tx, rx) = channel::(); - assert_eq!(rx.try_recv(), Err(TryRecvError::Empty)); -} - -#[test] -fn oneshot_multi_task_recv_then_send() { - let (tx, rx) = channel::>(); - let _t = thread::spawn(move || { - assert!(*rx.recv().unwrap() == 10); - }); - - tx.send(Box::new(10)).unwrap(); -} - -#[test] -fn oneshot_multi_task_recv_then_close() { - let (tx, rx) = channel::>(); - let _t = thread::spawn(move || { - drop(tx); - }); - let res = thread::spawn(move || { - assert!(*rx.recv().unwrap() == 10); - }) - .join(); - assert!(res.is_err()); -} - -#[test] -fn oneshot_multi_thread_close_stress() { - for _ in 0..stress_factor() { - let (tx, rx) = channel::(); - let _t = thread::spawn(move || { - drop(rx); - }); - drop(tx); - } -} - -#[test] -fn oneshot_multi_thread_send_close_stress() { - for _ in 0..stress_factor() { - let (tx, rx) = channel::(); - let _t = thread::spawn(move || { - drop(rx); - }); - let _ = thread::spawn(move || { - tx.send(1).unwrap(); - }) - .join(); - } -} - -#[test] -fn oneshot_multi_thread_recv_close_stress() { - for _ in 0..stress_factor() { - let (tx, rx) = channel::(); - thread::spawn(move || { - let res = thread::spawn(move || { - rx.recv().unwrap(); - }) - .join(); - assert!(res.is_err()); - }); - let _t = thread::spawn(move || { - thread::spawn(move || { - drop(tx); - }); - }); - } -} - -#[test] -fn oneshot_multi_thread_send_recv_stress() { - for _ in 0..stress_factor() { - let (tx, rx) = channel::>(); - let _t = thread::spawn(move || { - tx.send(Box::new(10)).unwrap(); - }); - assert!(*rx.recv().unwrap() == 10); - } -} - -#[test] -fn stream_send_recv_stress() { - for _ in 0..stress_factor() { - let (tx, rx) = channel(); - - send(tx, 0); - recv(rx, 0); - - fn send(tx: Sender>, i: i32) { - if i == 10 { - return; - } - - thread::spawn(move || { - tx.send(Box::new(i)).unwrap(); - send(tx, i + 1); - }); - } - - fn recv(rx: Receiver>, i: i32) { - if i == 10 { - return; - } - - thread::spawn(move || { - assert!(*rx.recv().unwrap() == i); - recv(rx, i + 1); - }); - } - } -} - -#[test] -fn oneshot_single_thread_recv_timeout() { - let (tx, rx) = channel(); - tx.send(()).unwrap(); - assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Ok(())); - assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Err(RecvTimeoutError::Timeout)); - tx.send(()).unwrap(); - assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Ok(())); -} - -#[test] -fn stress_recv_timeout_two_threads() { - let (tx, rx) = channel(); - let stress = stress_factor() + 100; - let timeout = Duration::from_millis(100); - - thread::spawn(move || { - for i in 0..stress { - if i % 2 == 0 { - thread::sleep(timeout * 2); - } - tx.send(1usize).unwrap(); - } - }); - - let mut recv_count = 0; - loop { - match rx.recv_timeout(timeout) { - Ok(n) => { - assert_eq!(n, 1usize); - recv_count += 1; - } - Err(RecvTimeoutError::Timeout) => continue, - Err(RecvTimeoutError::Disconnected) => break, - } - } - - assert_eq!(recv_count, stress); -} - -#[test] -fn recv_timeout_upgrade() { - let (tx, rx) = channel::<()>(); - let timeout = Duration::from_millis(1); - let _tx_clone = tx.clone(); - - let start = Instant::now(); - assert_eq!(rx.recv_timeout(timeout), Err(RecvTimeoutError::Timeout)); - assert!(Instant::now() >= start + timeout); -} - -#[test] -fn stress_recv_timeout_shared() { - let (tx, rx) = channel(); - let stress = stress_factor() + 100; - - for i in 0..stress { - let tx = tx.clone(); - thread::spawn(move || { - thread::sleep(Duration::from_millis(i as u64 * 10)); - tx.send(1usize).unwrap(); - }); - } - - drop(tx); - - let mut recv_count = 0; - loop { - match rx.recv_timeout(Duration::from_millis(10)) { - Ok(n) => { - assert_eq!(n, 1usize); - recv_count += 1; - } - Err(RecvTimeoutError::Timeout) => continue, - Err(RecvTimeoutError::Disconnected) => break, - } - } - - assert_eq!(recv_count, stress); -} - -#[test] -fn very_long_recv_timeout_wont_panic() { - let (tx, rx) = channel::<()>(); - let join_handle = thread::spawn(move || rx.recv_timeout(Duration::from_secs(u64::MAX))); - thread::sleep(Duration::from_secs(1)); - assert!(tx.send(()).is_ok()); - assert_eq!(join_handle.join().unwrap(), Ok(())); -} - -#[test] -fn recv_a_lot() { - let count = if cfg!(miri) { 1000 } else { 10000 }; - // Regression test that we don't run out of stack in scheduler context - let (tx, rx) = channel(); - for _ in 0..count { - tx.send(()).unwrap(); - } - for _ in 0..count { - rx.recv().unwrap(); - } -} - -#[test] -fn shared_recv_timeout() { - let (tx, rx) = channel(); - let total = 5; - for _ in 0..total { - let tx = tx.clone(); - thread::spawn(move || { - tx.send(()).unwrap(); - }); - } - - for _ in 0..total { - rx.recv().unwrap(); - } - - assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Err(RecvTimeoutError::Timeout)); - tx.send(()).unwrap(); - assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Ok(())); -} - -#[test] -fn shared_chan_stress() { - let (tx, rx) = channel(); - let total = stress_factor() + 100; - for _ in 0..total { - let tx = tx.clone(); - thread::spawn(move || { - tx.send(()).unwrap(); - }); - } - - for _ in 0..total { - rx.recv().unwrap(); - } -} - -#[test] -fn test_nested_recv_iter() { - let (tx, rx) = channel::(); - let (total_tx, total_rx) = channel::(); - - let _t = thread::spawn(move || { - let mut acc = 0; - for x in rx.iter() { - acc += x; - } - total_tx.send(acc).unwrap(); - }); - - tx.send(3).unwrap(); - tx.send(1).unwrap(); - tx.send(2).unwrap(); - drop(tx); - assert_eq!(total_rx.recv().unwrap(), 6); -} - -#[test] -fn test_recv_iter_break() { - let (tx, rx) = channel::(); - let (count_tx, count_rx) = channel(); - - let _t = thread::spawn(move || { - let mut count = 0; - for x in rx.iter() { - if count >= 3 { - break; - } else { - count += x; - } - } - count_tx.send(count).unwrap(); - }); - - tx.send(2).unwrap(); - tx.send(2).unwrap(); - tx.send(2).unwrap(); - let _ = tx.send(2); - drop(tx); - assert_eq!(count_rx.recv().unwrap(), 4); -} - -#[test] -fn test_recv_try_iter() { - let (request_tx, request_rx) = channel(); - let (response_tx, response_rx) = channel(); - - // Request `x`s until we have `6`. - let t = thread::spawn(move || { - let mut count = 0; - loop { - for x in response_rx.try_iter() { - count += x; - if count == 6 { - return count; - } - } - request_tx.send(()).unwrap(); - } - }); - - for _ in request_rx.iter() { - if response_tx.send(2).is_err() { - break; - } - } - - assert_eq!(t.join().unwrap(), 6); -} - -#[test] -fn test_recv_into_iter_owned() { - let mut iter = { - let (tx, rx) = channel::(); - tx.send(1).unwrap(); - tx.send(2).unwrap(); - - rx.into_iter() - }; - assert_eq!(iter.next().unwrap(), 1); - assert_eq!(iter.next().unwrap(), 2); - assert_eq!(iter.next().is_none(), true); -} - -#[test] -fn test_recv_into_iter_borrowed() { - let (tx, rx) = channel::(); - tx.send(1).unwrap(); - tx.send(2).unwrap(); - drop(tx); - let mut iter = (&rx).into_iter(); - assert_eq!(iter.next().unwrap(), 1); - assert_eq!(iter.next().unwrap(), 2); - assert_eq!(iter.next().is_none(), true); -} - -#[test] -fn try_recv_states() { - let (tx1, rx1) = channel::(); - let (tx2, rx2) = channel::<()>(); - let (tx3, rx3) = channel::<()>(); - let _t = thread::spawn(move || { - rx2.recv().unwrap(); - tx1.send(1).unwrap(); - tx3.send(()).unwrap(); - rx2.recv().unwrap(); - drop(tx1); - tx3.send(()).unwrap(); - }); - - assert_eq!(rx1.try_recv(), Err(TryRecvError::Empty)); - tx2.send(()).unwrap(); - rx3.recv().unwrap(); - assert_eq!(rx1.try_recv(), Ok(1)); - assert_eq!(rx1.try_recv(), Err(TryRecvError::Empty)); - tx2.send(()).unwrap(); - rx3.recv().unwrap(); - assert_eq!(rx1.try_recv(), Err(TryRecvError::Disconnected)); -} - -// This bug used to end up in a livelock inside of the Receiver destructor -// because the internal state of the Shared packet was corrupted -#[test] -fn destroy_upgraded_shared_port_when_sender_still_active() { - let (tx, rx) = channel(); - let (tx2, rx2) = channel(); - let _t = thread::spawn(move || { - rx.recv().unwrap(); // wait on a oneshot - drop(rx); // destroy a shared - tx2.send(()).unwrap(); - }); - // make sure the other thread has gone to sleep - for _ in 0..5000 { - thread::yield_now(); - } - - // upgrade to a shared chan and send a message - let t = tx.clone(); - drop(tx); - t.send(()).unwrap(); - - // wait for the child thread to exit before we exit - rx2.recv().unwrap(); -} - -#[test] -fn issue_32114() { - let (tx, _) = channel(); - let _ = tx.send(123); - assert_eq!(tx.send(123), Err(SendError(123))); -} - +// Ensure that thread_local init with `const { 0 }` still has unique address at run-time #[test] -fn issue_39364() { - let (tx, rx) = channel::<()>(); - let t = thread::spawn(move || { - thread::sleep(Duration::from_millis(300)); - let _ = tx.clone(); - // Don't drop; hand back to caller. - tx +fn waker_current_thread_id() { + let first = super::waker::current_thread_id(); + let t = crate::thread::spawn(move || { + let second = super::waker::current_thread_id(); + assert_ne!(first, second); + assert_eq!(second, super::waker::current_thread_id()); }); - let _ = rx.recv_timeout(Duration::from_millis(500)); - let _tx = t.join().unwrap(); // delay dropping until end of test - let _ = rx.recv_timeout(Duration::from_millis(500)); + assert_eq!(first, super::waker::current_thread_id()); + t.join().unwrap(); + assert_eq!(first, super::waker::current_thread_id()); } diff --git a/std/src/sync/mpmc/waker.rs b/std/src/sync/mpmc/waker.rs index 1895466f95d45..f5e764e69bd6e 100644 --- a/std/src/sync/mpmc/waker.rs +++ b/std/src/sync/mpmc/waker.rs @@ -204,6 +204,6 @@ impl Drop for SyncWaker { pub fn current_thread_id() -> usize { // `u8` is not drop so this variable will be available during thread destruction, // whereas `thread::current()` would not be - thread_local! { static DUMMY: u8 = 0 } + thread_local! { static DUMMY: u8 = const { 0 } } DUMMY.with(|x| (x as *const u8).addr()) } diff --git a/std/src/sync/mpsc/mod.rs b/std/src/sync/mpsc.rs similarity index 99% rename from std/src/sync/mpsc/mod.rs rename to std/src/sync/mpsc.rs index c86b546e01169..f942937c14d11 100644 --- a/std/src/sync/mpsc/mod.rs +++ b/std/src/sync/mpsc.rs @@ -137,12 +137,6 @@ #![stable(feature = "rust1", since = "1.0.0")] -#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] -mod tests; - -#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] -mod sync_tests; - // MPSC channels are built as a wrapper around MPMC channels, which // were ported from the `crossbeam-channel` crate. MPMC channels are // not exposed publicly, but if you are curious about the implementation, @@ -737,9 +731,10 @@ impl SyncSender { // Attempts to send for a value on this receiver, returning an error if the // corresponding channel has hung up, or if it waits more than `timeout`. // - // This method is currently private and only used for tests. - #[allow(unused)] - fn send_timeout(&self, t: T, timeout: Duration) -> Result<(), mpmc::SendTimeoutError> { + // This method is currently only used for tests. + #[unstable(issue = "none", feature = "std_internals")] + #[doc(hidden)] + pub fn send_timeout(&self, t: T, timeout: Duration) -> Result<(), mpmc::SendTimeoutError> { self.inner.send_timeout(t, timeout) } } diff --git a/std/src/sync/once_lock.rs b/std/src/sync/once_lock.rs index 0ae3cf4df3614..ffb90b1469584 100644 --- a/std/src/sync/once_lock.rs +++ b/std/src/sync/once_lock.rs @@ -13,6 +13,9 @@ use crate::sync::Once; /// Where OnceLock shines is when LazyLock is too simple to support a given case, as LazyLock /// doesn't allow additional inputs to its function after you call [`LazyLock::new(|| ...)`]. /// +/// A `OnceLock` can be thought of as a safe abstraction over uninitialized data that becomes +/// initialized once written. +/// /// [`OnceCell`]: crate::cell::OnceCell /// [`LazyLock`]: crate::sync::LazyLock /// [`LazyLock::new(|| ...)`]: crate::sync::LazyLock::new @@ -101,6 +104,7 @@ use crate::sync::Once; /// ``` #[stable(feature = "once_cell", since = "1.70.0")] pub struct OnceLock { + // FIXME(nonpoison_once): switch to nonpoison version once it is available once: Once, // Whether or not the value is initialized is tracked by `once.is_completed()`. value: UnsafeCell>, @@ -125,7 +129,7 @@ pub struct OnceLock { } impl OnceLock { - /// Creates a new empty cell. + /// Creates a new uninitialized cell. #[inline] #[must_use] #[stable(feature = "once_cell", since = "1.70.0")] @@ -140,8 +144,8 @@ impl OnceLock { /// Gets the reference to the underlying value. /// - /// Returns `None` if the cell is empty, or being initialized. This - /// method never blocks. + /// Returns `None` if the cell is uninitialized, or being initialized. + /// This method never blocks. #[inline] #[stable(feature = "once_cell", since = "1.70.0")] pub fn get(&self) -> Option<&T> { @@ -155,7 +159,8 @@ impl OnceLock { /// Gets the mutable reference to the underlying value. /// - /// Returns `None` if the cell is empty. This method never blocks. + /// Returns `None` if the cell is uninitialized, or being initialized. + /// This method never blocks. #[inline] #[stable(feature = "once_cell", since = "1.70.0")] pub fn get_mut(&mut self) -> Option<&mut T> { @@ -173,8 +178,6 @@ impl OnceLock { /// /// Waiting for a computation on another thread to finish: /// ```rust - /// #![feature(once_wait)] - /// /// use std::thread; /// use std::sync::OnceLock; /// @@ -188,19 +191,20 @@ impl OnceLock { /// }) /// ``` #[inline] - #[unstable(feature = "once_wait", issue = "127527")] + #[stable(feature = "once_wait", since = "1.86.0")] pub fn wait(&self) -> &T { self.once.wait_force(); unsafe { self.get_unchecked() } } - /// Sets the contents of this cell to `value`. + /// Initializes the contents of the cell to `value`. /// /// May block if another thread is currently attempting to initialize the cell. The cell is - /// guaranteed to contain a value when set returns, though not necessarily the one provided. + /// guaranteed to contain a value when `set` returns, though not necessarily the one provided. /// - /// Returns `Ok(())` if the cell's value was set by this call. + /// Returns `Ok(())` if the cell was uninitialized and + /// `Err(value)` if the cell was already initialized. /// /// # Examples /// @@ -229,13 +233,15 @@ impl OnceLock { } } - /// Sets the contents of this cell to `value` if the cell was empty, then - /// returns a reference to it. + /// Initializes the contents of the cell to `value` if the cell was uninitialized, + /// then returns a reference to it. /// /// May block if another thread is currently attempting to initialize the cell. The cell is - /// guaranteed to contain a value when set returns, though not necessarily the one provided. + /// guaranteed to contain a value when `try_insert` returns, though not necessarily the + /// one provided. /// - /// Returns `Ok(&value)` if the cell was empty and `Err(¤t_value, value)` if it was full. + /// Returns `Ok(&value)` if the cell was uninitialized and + /// `Err((¤t_value, value))` if it was already initialized. /// /// # Examples /// @@ -268,8 +274,8 @@ impl OnceLock { } } - /// Gets the contents of the cell, initializing it with `f` if the cell - /// was empty. + /// Gets the contents of the cell, initializing it to `f()` if the cell + /// was uninitialized. /// /// Many threads may call `get_or_init` concurrently with different /// initializing functions, but it is guaranteed that only one function @@ -277,7 +283,7 @@ impl OnceLock { /// /// # Panics /// - /// If `f` panics, the panic is propagated to the caller, and the cell + /// If `f()` panics, the panic is propagated to the caller, and the cell /// remains uninitialized. /// /// It is an error to reentrantly initialize the cell from `f`. The @@ -307,13 +313,13 @@ impl OnceLock { } /// Gets the mutable reference of the contents of the cell, initializing - /// it with `f` if the cell was empty. + /// it to `f()` if the cell was uninitialized. /// /// This method never blocks. /// /// # Panics /// - /// If `f` panics, the panic is propagated to the caller, and the cell + /// If `f()` panics, the panic is propagated to the caller, and the cell /// remains uninitialized. /// /// # Examples @@ -344,13 +350,13 @@ impl OnceLock { } } - /// Gets the contents of the cell, initializing it with `f` if - /// the cell was empty. If the cell was empty and `f` failed, an - /// error is returned. + /// Gets the contents of the cell, initializing it to `f()` if + /// the cell was uninitialized. If the cell was uninitialized + /// and `f()` failed, an error is returned. /// /// # Panics /// - /// If `f` panics, the panic is propagated to the caller, and + /// If `f()` panics, the panic is propagated to the caller, and /// the cell remains uninitialized. /// /// It is an error to reentrantly initialize the cell from `f`. @@ -396,14 +402,14 @@ impl OnceLock { } /// Gets the mutable reference of the contents of the cell, initializing - /// it with `f` if the cell was empty. If the cell was empty and `f` failed, - /// an error is returned. + /// it to `f()` if the cell was uninitialized. If the cell was uninitialized + /// and `f()` failed, an error is returned. /// /// This method never blocks. /// /// # Panics /// - /// If `f` panics, the panic is propagated to the caller, and + /// If `f()` panics, the panic is propagated to the caller, and /// the cell remains uninitialized. /// /// # Examples @@ -415,7 +421,7 @@ impl OnceLock { /// /// let mut cell: OnceLock = OnceLock::new(); /// - /// // Failed initializers do not change the value + /// // Failed attempts to initialize the cell do not change its contents /// assert!(cell.get_mut_or_try_init(|| "not a number!".parse()).is_err()); /// assert!(cell.get().is_none()); /// @@ -439,7 +445,7 @@ impl OnceLock { } /// Consumes the `OnceLock`, returning the wrapped value. Returns - /// `None` if the cell was empty. + /// `None` if the cell was uninitialized. /// /// # Examples /// @@ -461,7 +467,7 @@ impl OnceLock { /// Takes the value out of this `OnceLock`, moving it back to an uninitialized state. /// - /// Has no effect and returns `None` if the `OnceLock` hasn't been initialized. + /// Has no effect and returns `None` if the `OnceLock` was uninitialized. /// /// Safety is guaranteed by requiring a mutable reference. /// @@ -527,7 +533,7 @@ impl OnceLock { /// # Safety /// - /// The value must be initialized + /// The cell must be initialized #[inline] unsafe fn get_unchecked(&self) -> &T { debug_assert!(self.is_initialized()); @@ -536,7 +542,7 @@ impl OnceLock { /// # Safety /// - /// The value must be initialized + /// The cell must be initialized #[inline] unsafe fn get_unchecked_mut(&mut self) -> &mut T { debug_assert!(self.is_initialized()); @@ -561,7 +567,7 @@ impl UnwindSafe for OnceLock {} #[stable(feature = "once_cell", since = "1.70.0")] impl Default for OnceLock { - /// Creates a new empty cell. + /// Creates a new uninitialized cell. /// /// # Example /// @@ -675,6 +681,3 @@ unsafe impl<#[may_dangle] T> Drop for OnceLock { } } } - -#[cfg(test)] -mod tests; diff --git a/std/src/sync/poison.rs b/std/src/sync/poison.rs index da66a088e51b1..1b8809734b8a8 100644 --- a/std/src/sync/poison.rs +++ b/std/src/sync/poison.rs @@ -1,3 +1,78 @@ +//! Synchronization objects that employ poisoning. +//! +//! # Poisoning +//! +//! All synchronization objects in this module implement a strategy called "poisoning" +//! where if a thread panics while holding the exclusive access granted by the primitive, +//! the state of the primitive is set to "poisoned". +//! This information is then propagated to all other threads +//! to signify that the data protected by this primitive is likely tainted +//! (some invariant is not being upheld). +//! +//! The specifics of how this "poisoned" state affects other threads +//! depend on the primitive. See [#Overview] bellow. +//! +//! For the alternative implementations that do not employ poisoning, +//! see `std::sys::nonpoisoning`. +//! +//! # Overview +//! +//! Below is a list of synchronization objects provided by this module +//! with a high-level overview for each object and a description +//! of how it employs "poisoning". +//! +//! - [`Condvar`]: Condition Variable, providing the ability to block +//! a thread while waiting for an event to occur. +//! +//! Condition variables are typically associated with +//! a boolean predicate (a condition) and a mutex. +//! This implementation is associated with [`poison::Mutex`](Mutex), +//! which employs poisoning. +//! For this reason, [`Condvar::wait()`] will return a [`LockResult`], +//! just like [`poison::Mutex::lock()`](Mutex::lock) does. +//! +//! - [`Mutex`]: Mutual Exclusion mechanism, which ensures that at +//! most one thread at a time is able to access some data. +//! +//! [`Mutex::lock()`] returns a [`LockResult`], +//! providing a way to deal with the poisoned state. +//! See [`Mutex`'s documentation](Mutex#poisoning) for more. +//! +//! - [`Once`]: A thread-safe way to run a piece of code only once. +//! Mostly useful for implementing one-time global initialization. +//! +//! [`Once`] is poisoned if the piece of code passed to +//! [`Once::call_once()`] or [`Once::call_once_force()`] panics. +//! When in poisoned state, subsequent calls to [`Once::call_once()`] will panic too. +//! [`Once::call_once_force()`] can be used to clear the poisoned state. +//! +//! - [`RwLock`]: Provides a mutual exclusion mechanism which allows +//! multiple readers at the same time, while allowing only one +//! writer at a time. In some cases, this can be more efficient than +//! a mutex. +//! +//! This implementation, like [`Mutex`], will become poisoned on a panic. +//! Note, however, that an `RwLock` may only be poisoned if a panic occurs +//! while it is locked exclusively (write mode). If a panic occurs in any reader, +//! then the lock will not be poisoned. + +// FIXME(sync_nonpoison) add links to sync::nonpoison to the doc comment above. + +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::condvar::{Condvar, WaitTimeoutResult}; +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +pub use self::mutex::MappedMutexGuard; +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::mutex::{Mutex, MutexGuard}; +#[stable(feature = "rust1", since = "1.0.0")] +#[expect(deprecated)] +pub use self::once::ONCE_INIT; +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::once::{Once, OnceState}; +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +pub use self::rwlock::{MappedRwLockReadGuard, MappedRwLockWriteGuard}; +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; use crate::error::Error; use crate::fmt; #[cfg(panic = "unwind")] @@ -5,7 +80,13 @@ use crate::sync::atomic::{AtomicBool, Ordering}; #[cfg(panic = "unwind")] use crate::thread; -pub struct Flag { +mod condvar; +#[stable(feature = "rust1", since = "1.0.0")] +mod mutex; +pub(crate) mod once; +mod rwlock; + +pub(crate) struct Flag { #[cfg(panic = "unwind")] failed: AtomicBool, } @@ -78,7 +159,7 @@ impl Flag { } #[derive(Clone)] -pub struct Guard { +pub(crate) struct Guard { #[cfg(panic = "unwind")] panicking: bool, } @@ -87,8 +168,8 @@ pub struct Guard { /// /// Both [`Mutex`]es and [`RwLock`]s are poisoned whenever a thread fails while the lock /// is held. The precise semantics for when a lock is poisoned is documented on -/// each lock, but once a lock is poisoned then all future acquisitions will -/// return this error. +/// each lock. For a lock in the poisoned state, unless the state is cleared manually, +/// all future acquisitions will return this error. /// /// # Examples /// @@ -118,7 +199,7 @@ pub struct Guard { /// [`RwLock`]: crate::sync::RwLock #[stable(feature = "rust1", since = "1.0.0")] pub struct PoisonError { - guard: T, + data: T, #[cfg(not(panic = "unwind"))] _never: !, } @@ -147,14 +228,15 @@ pub enum TryLockError { /// A type alias for the result of a lock method which can be poisoned. /// /// The [`Ok`] variant of this result indicates that the primitive was not -/// poisoned, and the `Guard` is contained within. The [`Err`] variant indicates +/// poisoned, and the operation result is contained within. The [`Err`] variant indicates /// that the primitive was poisoned. Note that the [`Err`] variant *also* carries -/// the associated guard, and it can be acquired through the [`into_inner`] -/// method. +/// an associated value assigned by the lock method, and it can be acquired through the +/// [`into_inner`] method. The semantics of the associated value depends on the corresponding +/// lock method. /// /// [`into_inner`]: PoisonError::into_inner #[stable(feature = "rust1", since = "1.0.0")] -pub type LockResult = Result>; +pub type LockResult = Result>; /// A type alias for the result of a nonblocking locking method. /// @@ -195,8 +277,8 @@ impl PoisonError { /// This method may panic if std was built with `panic="abort"`. #[cfg(panic = "unwind")] #[stable(feature = "sync_poison", since = "1.2.0")] - pub fn new(guard: T) -> PoisonError { - PoisonError { guard } + pub fn new(data: T) -> PoisonError { + PoisonError { data } } /// Creates a `PoisonError`. @@ -208,12 +290,12 @@ impl PoisonError { #[cfg(not(panic = "unwind"))] #[stable(feature = "sync_poison", since = "1.2.0")] #[track_caller] - pub fn new(_guard: T) -> PoisonError { + pub fn new(_data: T) -> PoisonError { panic!("PoisonError created in a libstd built with panic=\"abort\"") } /// Consumes this error indicating that a lock is poisoned, returning the - /// underlying guard to allow access regardless. + /// associated data. /// /// # Examples /// @@ -238,21 +320,21 @@ impl PoisonError { /// ``` #[stable(feature = "sync_poison", since = "1.2.0")] pub fn into_inner(self) -> T { - self.guard + self.data } /// Reaches into this error indicating that a lock is poisoned, returning a - /// reference to the underlying guard to allow access regardless. + /// reference to the associated data. #[stable(feature = "sync_poison", since = "1.2.0")] pub fn get_ref(&self) -> &T { - &self.guard + &self.data } /// Reaches into this error indicating that a lock is poisoned, returning a - /// mutable reference to the underlying guard to allow access regardless. + /// mutable reference to the associated data. #[stable(feature = "sync_poison", since = "1.2.0")] pub fn get_mut(&mut self) -> &mut T { - &mut self.guard + &mut self.data } } @@ -315,13 +397,13 @@ impl Error for TryLockError { } } -pub fn map_result(result: LockResult, f: F) -> LockResult +pub(crate) fn map_result(result: LockResult, f: F) -> LockResult where F: FnOnce(T) -> U, { match result { Ok(t) => Ok(f(t)), #[cfg(panic = "unwind")] - Err(PoisonError { guard }) => Err(PoisonError::new(f(guard))), + Err(PoisonError { data }) => Err(PoisonError::new(f(data))), } } diff --git a/std/src/sync/condvar.rs b/std/src/sync/poison/condvar.rs similarity index 99% rename from std/src/sync/condvar.rs rename to std/src/sync/poison/condvar.rs index 44ffcb528d937..7f0f3f652bcb7 100644 --- a/std/src/sync/condvar.rs +++ b/std/src/sync/poison/condvar.rs @@ -1,8 +1,5 @@ -#[cfg(test)] -mod tests; - use crate::fmt; -use crate::sync::{LockResult, MutexGuard, PoisonError, mutex, poison}; +use crate::sync::poison::{self, LockResult, MutexGuard, PoisonError, mutex}; use crate::sys::sync as sys; use crate::time::{Duration, Instant}; @@ -16,6 +13,8 @@ use crate::time::{Duration, Instant}; #[stable(feature = "wait_timeout", since = "1.5.0")] pub struct WaitTimeoutResult(bool); +// FIXME(sync_nonpoison): `WaitTimeoutResult` is actually poisoning-agnostic, it seems. +// Should we take advantage of this fact? impl WaitTimeoutResult { /// Returns `true` if the wait was known to have timed out. /// diff --git a/std/src/sync/mutex.rs b/std/src/sync/poison/mutex.rs similarity index 84% rename from std/src/sync/mutex.rs rename to std/src/sync/poison/mutex.rs index fe2aca031a248..9362c764173a8 100644 --- a/std/src/sync/mutex.rs +++ b/std/src/sync/poison/mutex.rs @@ -1,13 +1,10 @@ -#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] -mod tests; - use crate::cell::UnsafeCell; use crate::fmt; use crate::marker::PhantomData; -use crate::mem::ManuallyDrop; +use crate::mem::{self, ManuallyDrop}; use crate::ops::{Deref, DerefMut}; use crate::ptr::NonNull; -use crate::sync::{LockResult, TryLockError, TryLockResult, poison}; +use crate::sync::{LockResult, PoisonError, TryLockError, TryLockResult, poison}; use crate::sys::sync as sys; /// A mutual exclusion primitive useful for protecting shared data @@ -181,10 +178,29 @@ pub struct Mutex { data: UnsafeCell, } -// these are the only places where `T: Send` matters; all other -// functionality works fine on a single thread. +/// `T` must be `Send` for a [`Mutex`] to be `Send` because it is possible to acquire +/// the owned `T` from the `Mutex` via [`into_inner`]. +/// +/// [`into_inner`]: Mutex::into_inner #[stable(feature = "rust1", since = "1.0.0")] unsafe impl Send for Mutex {} + +/// `T` must be `Send` for [`Mutex`] to be `Sync`. +/// This ensures that the protected data can be accessed safely from multiple threads +/// without causing data races or other unsafe behavior. +/// +/// [`Mutex`] provides mutable access to `T` to one thread at a time. However, it's essential +/// for `T` to be `Send` because it's not safe for non-`Send` structures to be accessed in +/// this manner. For instance, consider [`Rc`], a non-atomic reference counted smart pointer, +/// which is not `Send`. With `Rc`, we can have multiple copies pointing to the same heap +/// allocation with a non-atomic reference count. If we were to use `Mutex>`, it would +/// only protect one instance of `Rc` from shared access, leaving other copies vulnerable +/// to potential data races. +/// +/// Also note that it is not necessary for `T` to be `Sync` as `&T` is only made available +/// to one thread at a time if `T` is not `Sync`. +/// +/// [`Rc`]: crate::rc::Rc #[stable(feature = "rust1", since = "1.0.0")] unsafe impl Sync for Mutex {} @@ -211,8 +227,17 @@ pub struct MutexGuard<'a, T: ?Sized + 'a> { poison: poison::Guard, } +/// A [`MutexGuard`] is not `Send` to maximize platform portablity. +/// +/// On platforms that use POSIX threads (commonly referred to as pthreads) there is a requirement to +/// release mutex locks on the same thread they were acquired. +/// For this reason, [`MutexGuard`] must not implement `Send` to prevent it being dropped from +/// another thread. #[stable(feature = "rust1", since = "1.0.0")] impl !Send for MutexGuard<'_, T> {} + +/// `T` must be `Sync` for a [`MutexGuard`] to be `Sync` +/// because it is possible to get a `&T` from `&MutexGuard` (via `Deref`). #[stable(feature = "mutexguard", since = "1.19.0")] unsafe impl Sync for MutexGuard<'_, T> {} @@ -273,6 +298,100 @@ impl Mutex { pub const fn new(t: T) -> Mutex { Mutex { inner: sys::Mutex::new(), poison: poison::Flag::new(), data: UnsafeCell::new(t) } } + + /// Returns the contained value by cloning it. + /// + /// # Errors + /// + /// If another user of this mutex panicked while holding the mutex, then + /// this call will return an error instead. + /// + /// # Examples + /// + /// ``` + /// #![feature(lock_value_accessors)] + /// + /// use std::sync::Mutex; + /// + /// let mut mutex = Mutex::new(7); + /// + /// assert_eq!(mutex.get_cloned().unwrap(), 7); + /// ``` + #[unstable(feature = "lock_value_accessors", issue = "133407")] + pub fn get_cloned(&self) -> Result> + where + T: Clone, + { + match self.lock() { + Ok(guard) => Ok((*guard).clone()), + Err(_) => Err(PoisonError::new(())), + } + } + + /// Sets the contained value. + /// + /// # Errors + /// + /// If another user of this mutex panicked while holding the mutex, then + /// this call will return an error containing the provided `value` instead. + /// + /// # Examples + /// + /// ``` + /// #![feature(lock_value_accessors)] + /// + /// use std::sync::Mutex; + /// + /// let mut mutex = Mutex::new(7); + /// + /// assert_eq!(mutex.get_cloned().unwrap(), 7); + /// mutex.set(11).unwrap(); + /// assert_eq!(mutex.get_cloned().unwrap(), 11); + /// ``` + #[unstable(feature = "lock_value_accessors", issue = "133407")] + pub fn set(&self, value: T) -> Result<(), PoisonError> { + if mem::needs_drop::() { + // If the contained value has non-trivial destructor, we + // call that destructor after the lock being released. + self.replace(value).map(drop) + } else { + match self.lock() { + Ok(mut guard) => { + *guard = value; + + Ok(()) + } + Err(_) => Err(PoisonError::new(value)), + } + } + } + + /// Replaces the contained value with `value`, and returns the old contained value. + /// + /// # Errors + /// + /// If another user of this mutex panicked while holding the mutex, then + /// this call will return an error containing the provided `value` instead. + /// + /// # Examples + /// + /// ``` + /// #![feature(lock_value_accessors)] + /// + /// use std::sync::Mutex; + /// + /// let mut mutex = Mutex::new(7); + /// + /// assert_eq!(mutex.replace(11).unwrap(), 7); + /// assert_eq!(mutex.get_cloned().unwrap(), 11); + /// ``` + #[unstable(feature = "lock_value_accessors", issue = "133407")] + pub fn replace(&self, value: T) -> LockResult { + match self.lock() { + Ok(mut guard) => Ok(mem::replace(&mut *guard, value)), + Err(_) => Err(PoisonError::new(value)), + } + } } impl Mutex { @@ -290,7 +409,8 @@ impl Mutex { /// # Errors /// /// If another user of this mutex panicked while holding the mutex, then - /// this call will return an error once the mutex is acquired. + /// this call will return an error once the mutex is acquired. The acquired + /// mutex guard will be contained in the returned error. /// /// # Panics /// @@ -331,7 +451,8 @@ impl Mutex { /// /// If another user of this mutex panicked while holding the mutex, then /// this call will return the [`Poisoned`] error if the mutex would - /// otherwise be acquired. + /// otherwise be acquired. An acquired lock guard will be contained + /// in the returned error. /// /// If the mutex could not be acquired because it is already locked, then /// this call will return the [`WouldBlock`] error. @@ -438,7 +559,8 @@ impl Mutex { /// # Errors /// /// If another user of this mutex panicked while holding the mutex, then - /// this call will return an error instead. + /// this call will return an error containing the underlying data + /// instead. /// /// # Examples /// @@ -465,7 +587,8 @@ impl Mutex { /// # Errors /// /// If another user of this mutex panicked while holding the mutex, then - /// this call will return an error instead. + /// this call will return an error containing a mutable reference to the + /// underlying data instead. /// /// # Examples /// diff --git a/std/src/sync/once.rs b/std/src/sync/poison/once.rs similarity index 98% rename from std/src/sync/once.rs rename to std/src/sync/poison/once.rs index 27db4b634fb28..103e519540795 100644 --- a/std/src/sync/once.rs +++ b/std/src/sync/poison/once.rs @@ -3,9 +3,6 @@ //! This primitive is meant to be used to run one-time initialization. An //! example use case would be for initializing an FFI library. -#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] -mod tests; - use crate::fmt; use crate::panic::{RefUnwindSafe, UnwindSafe}; use crate::sys::sync as sys; @@ -269,8 +266,6 @@ impl Once { /// # Example /// /// ```rust - /// #![feature(once_wait)] - /// /// use std::sync::Once; /// use std::thread; /// @@ -289,7 +284,7 @@ impl Once { /// If this [`Once`] has been poisoned because an initialization closure has /// panicked, this method will also panic. Use [`wait_force`](Self::wait_force) /// if this behavior is not desired. - #[unstable(feature = "once_wait", issue = "127527")] + #[stable(feature = "once_wait", since = "1.86.0")] pub fn wait(&self) { if !self.inner.is_completed() { self.inner.wait(false); @@ -298,7 +293,7 @@ impl Once { /// Blocks the current thread until initialization has completed, ignoring /// poisoning. - #[unstable(feature = "once_wait", issue = "127527")] + #[stable(feature = "once_wait", since = "1.86.0")] pub fn wait_force(&self) { if !self.inner.is_completed() { self.inner.wait(true); diff --git a/std/src/sync/rwlock.rs b/std/src/sync/poison/rwlock.rs similarity index 91% rename from std/src/sync/rwlock.rs rename to std/src/sync/poison/rwlock.rs index d55d1c80dcae0..f9d9321f5f2d8 100644 --- a/std/src/sync/rwlock.rs +++ b/std/src/sync/poison/rwlock.rs @@ -1,10 +1,7 @@ -#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] -mod tests; - use crate::cell::UnsafeCell; use crate::fmt; use crate::marker::PhantomData; -use crate::mem::{ManuallyDrop, forget}; +use crate::mem::{self, ManuallyDrop, forget}; use crate::ops::{Deref, DerefMut}; use crate::ptr::NonNull; use crate::sync::{LockResult, PoisonError, TryLockError, TryLockResult, poison}; @@ -224,6 +221,103 @@ impl RwLock { pub const fn new(t: T) -> RwLock { RwLock { inner: sys::RwLock::new(), poison: poison::Flag::new(), data: UnsafeCell::new(t) } } + + /// Returns the contained value by cloning it. + /// + /// # Errors + /// + /// This function will return an error if the `RwLock` is poisoned. An + /// `RwLock` is poisoned whenever a writer panics while holding an exclusive + /// lock. + /// + /// # Examples + /// + /// ``` + /// #![feature(lock_value_accessors)] + /// + /// use std::sync::RwLock; + /// + /// let mut lock = RwLock::new(7); + /// + /// assert_eq!(lock.get_cloned().unwrap(), 7); + /// ``` + #[unstable(feature = "lock_value_accessors", issue = "133407")] + pub fn get_cloned(&self) -> Result> + where + T: Clone, + { + match self.read() { + Ok(guard) => Ok((*guard).clone()), + Err(_) => Err(PoisonError::new(())), + } + } + + /// Sets the contained value. + /// + /// # Errors + /// + /// This function will return an error containing the provided `value` if + /// the `RwLock` is poisoned. An `RwLock` is poisoned whenever a writer + /// panics while holding an exclusive lock. + /// + /// # Examples + /// + /// ``` + /// #![feature(lock_value_accessors)] + /// + /// use std::sync::RwLock; + /// + /// let mut lock = RwLock::new(7); + /// + /// assert_eq!(lock.get_cloned().unwrap(), 7); + /// lock.set(11).unwrap(); + /// assert_eq!(lock.get_cloned().unwrap(), 11); + /// ``` + #[unstable(feature = "lock_value_accessors", issue = "133407")] + pub fn set(&self, value: T) -> Result<(), PoisonError> { + if mem::needs_drop::() { + // If the contained value has non-trivial destructor, we + // call that destructor after the lock being released. + self.replace(value).map(drop) + } else { + match self.write() { + Ok(mut guard) => { + *guard = value; + + Ok(()) + } + Err(_) => Err(PoisonError::new(value)), + } + } + } + + /// Replaces the contained value with `value`, and returns the old contained value. + /// + /// # Errors + /// + /// This function will return an error containing the provided `value` if + /// the `RwLock` is poisoned. An `RwLock` is poisoned whenever a writer + /// panics while holding an exclusive lock. + /// + /// # Examples + /// + /// ``` + /// #![feature(lock_value_accessors)] + /// + /// use std::sync::RwLock; + /// + /// let mut lock = RwLock::new(7); + /// + /// assert_eq!(lock.replace(11).unwrap(), 7); + /// assert_eq!(lock.get_cloned().unwrap(), 11); + /// ``` + #[unstable(feature = "lock_value_accessors", issue = "133407")] + pub fn replace(&self, value: T) -> LockResult { + match self.write() { + Ok(mut guard) => Ok(mem::replace(&mut *guard, value)), + Err(_) => Err(PoisonError::new(value)), + } + } } impl RwLock { @@ -244,7 +338,8 @@ impl RwLock { /// This function will return an error if the `RwLock` is poisoned. An /// `RwLock` is poisoned whenever a writer panics while holding an exclusive /// lock. The failure will occur immediately after the lock has been - /// acquired. + /// acquired. The acquired lock guard will be contained in the returned + /// error. /// /// # Panics /// @@ -292,7 +387,8 @@ impl RwLock { /// This function will return the [`Poisoned`] error if the `RwLock` is /// poisoned. An `RwLock` is poisoned whenever a writer panics while holding /// an exclusive lock. `Poisoned` will only be returned if the lock would - /// have otherwise been acquired. + /// have otherwise been acquired. An acquired lock guard will be contained + /// in the returned error. /// /// This function will return the [`WouldBlock`] error if the `RwLock` could /// not be acquired because it was already locked exclusively. @@ -337,7 +433,8 @@ impl RwLock { /// /// This function will return an error if the `RwLock` is poisoned. An /// `RwLock` is poisoned whenever a writer panics while holding an exclusive - /// lock. An error will be returned when the lock is acquired. + /// lock. An error will be returned when the lock is acquired. The acquired + /// lock guard will be contained in the returned error. /// /// # Panics /// @@ -380,7 +477,8 @@ impl RwLock { /// This function will return the [`Poisoned`] error if the `RwLock` is /// poisoned. An `RwLock` is poisoned whenever a writer panics while holding /// an exclusive lock. `Poisoned` will only be returned if the lock would - /// have otherwise been acquired. + /// have otherwise been acquired. An acquired lock guard will be contained + /// in the returned error. /// /// This function will return the [`WouldBlock`] error if the `RwLock` could /// not be acquired because it was already locked exclusively. @@ -481,10 +579,10 @@ impl RwLock { /// /// # Errors /// - /// This function will return an error if the `RwLock` is poisoned. An - /// `RwLock` is poisoned whenever a writer panics while holding an exclusive - /// lock. An error will only be returned if the lock would have otherwise - /// been acquired. + /// This function will return an error containing the underlying data if + /// the `RwLock` is poisoned. An `RwLock` is poisoned whenever a writer + /// panics while holding an exclusive lock. An error will only be returned + /// if the lock would have otherwise been acquired. /// /// # Examples /// @@ -514,10 +612,11 @@ impl RwLock { /// /// # Errors /// - /// This function will return an error if the `RwLock` is poisoned. An - /// `RwLock` is poisoned whenever a writer panics while holding an exclusive - /// lock. An error will only be returned if the lock would have otherwise - /// been acquired. + /// This function will return an error containing a mutable reference to + /// the underlying data if the `RwLock` is poisoned. An `RwLock` is + /// poisoned whenever a writer panics while holding an exclusive lock. + /// An error will only be returned if the lock would have otherwise been + /// acquired. /// /// # Examples /// diff --git a/std/src/sync/reentrant_lock.rs b/std/src/sync/reentrant_lock.rs index 0140e0d21299f..e009eb410efc0 100644 --- a/std/src/sync/reentrant_lock.rs +++ b/std/src/sync/reentrant_lock.rs @@ -1,6 +1,3 @@ -#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] -mod tests; - use cfg_if::cfg_if; use crate::cell::UnsafeCell; @@ -324,7 +321,10 @@ impl ReentrantLock { /// Otherwise, an RAII guard is returned. /// /// This function does not block. - pub(crate) fn try_lock(&self) -> Option> { + // FIXME maybe make it a public part of the API? + #[unstable(issue = "none", feature = "std_internals")] + #[doc(hidden)] + pub fn try_lock(&self) -> Option> { let this_thread = current_id(); // Safety: We only touch lock_count when we own the inner mutex. // Additionally, we only call `self.owner.set()` while holding diff --git a/std/src/sys/alloc/sgx.rs b/std/src/sys/alloc/sgx.rs index fca9d087e5bfc..f5c27688fbc8f 100644 --- a/std/src/sys/alloc/sgx.rs +++ b/std/src/sys/alloc/sgx.rs @@ -11,7 +11,7 @@ use crate::sys::pal::waitqueue::SpinMutex; // in the rust-lang/rust repository as a submodule. The crate is a port of // dlmalloc.c from C to Rust. #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx5alloc8DLMALLOCE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx5alloc8DLMALLOCE")] static DLMALLOC: SpinMutex> = SpinMutex::new(dlmalloc::Dlmalloc::new_with_allocator(Sgx {})); @@ -85,13 +85,13 @@ unsafe impl GlobalAlloc for System { // The following functions are needed by libunwind. These symbols are named // in pre-link args for the target specification, so keep that in sync. #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __rust_c_alloc(size: usize, align: usize) -> *mut u8 { unsafe { crate::alloc::alloc(Layout::from_size_align_unchecked(size, align)) } } #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __rust_c_dealloc(ptr: *mut u8, size: usize, align: usize) { unsafe { crate::alloc::dealloc(ptr, Layout::from_size_align_unchecked(size, align)) } } diff --git a/std/src/sys/alloc/unix.rs b/std/src/sys/alloc/unix.rs index 1af9d76629014..a7ac4117ec902 100644 --- a/std/src/sys/alloc/unix.rs +++ b/std/src/sys/alloc/unix.rs @@ -81,7 +81,7 @@ cfg_if::cfg_if! { // while others require the alignment to be at least the pointer size (Illumos, macOS). // posix_memalign only has one, clear requirement: that the alignment be a multiple of // `sizeof(void*)`. Since these are all powers of 2, we can just use max. - let align = layout.align().max(crate::mem::size_of::()); + let align = layout.align().max(size_of::()); let ret = unsafe { libc::posix_memalign(&mut out, align, layout.size()) }; if ret != 0 { ptr::null_mut() } else { out as *mut u8 } } diff --git a/std/src/sys/alloc/wasm.rs b/std/src/sys/alloc/wasm.rs index a308fafc68b15..53fbc9529e590 100644 --- a/std/src/sys/alloc/wasm.rs +++ b/std/src/sys/alloc/wasm.rs @@ -1,6 +1,6 @@ //! This is an implementation of a global allocator on wasm targets when -//! emscripten is not in use. In that situation there's no actual runtime for us -//! to lean on for allocation, so instead we provide our own! +//! emscripten or wasi is not in use. In that situation there's no actual runtime +//! for us to lean on for allocation, so instead we provide our own! //! //! The wasm instruction set has two instructions for getting the current //! amount of memory and growing the amount of memory. These instructions are the diff --git a/std/src/sys/alloc/windows/tests.rs b/std/src/sys/alloc/windows/tests.rs index 674a3e1d92d17..1d5614528b12a 100644 --- a/std/src/sys/alloc/windows/tests.rs +++ b/std/src/sys/alloc/windows/tests.rs @@ -1,9 +1,8 @@ use super::{Header, MIN_ALIGN}; -use crate::mem; #[test] fn alloc_header() { // Header must fit in the padding before an aligned pointer - assert!(mem::size_of::
() <= MIN_ALIGN); - assert!(mem::align_of::
() <= MIN_ALIGN); + assert!(size_of::
() <= MIN_ALIGN); + assert!(align_of::
() <= MIN_ALIGN); } diff --git a/std/src/sys/alloc/xous.rs b/std/src/sys/alloc/xous.rs index 321d30e0b11b2..ccaa972c22de3 100644 --- a/std/src/sys/alloc/xous.rs +++ b/std/src/sys/alloc/xous.rs @@ -4,11 +4,11 @@ use crate::alloc::{GlobalAlloc, Layout, System}; #[cfg(not(test))] -#[export_name = "_ZN16__rust_internals3std3sys4xous5alloc8DLMALLOCE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys4xous5alloc8DLMALLOCE")] static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::Dlmalloc::new(); #[cfg(test)] -extern "Rust" { +unsafe extern "Rust" { #[link_name = "_ZN16__rust_internals3std3sys4xous5alloc8DLMALLOCE"] static mut DLMALLOC: dlmalloc::Dlmalloc; } diff --git a/std/src/sys/anonymous_pipe/unix.rs b/std/src/sys/anonymous_pipe/unix.rs index 9168024730e67..9e398765634b7 100644 --- a/std/src/sys/anonymous_pipe/unix.rs +++ b/std/src/sys/anonymous_pipe/unix.rs @@ -1,6 +1,5 @@ -use crate::io; +use crate::io::{self, PipeReader, PipeWriter}; use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -use crate::pipe::{PipeReader, PipeWriter}; use crate::process::Stdio; use crate::sys::fd::FileDesc; use crate::sys::pipe::anon_pipe; diff --git a/std/src/sys/anonymous_pipe/unsupported.rs b/std/src/sys/anonymous_pipe/unsupported.rs index dd51e70315e96..4e79ac9c21aad 100644 --- a/std/src/sys/anonymous_pipe/unsupported.rs +++ b/std/src/sys/anonymous_pipe/unsupported.rs @@ -1,5 +1,4 @@ -use crate::io; -use crate::pipe::{PipeReader, PipeWriter}; +use crate::io::{self, PipeReader, PipeWriter}; use crate::process::Stdio; pub use crate::sys::pipe::AnonPipe; diff --git a/std/src/sys/anonymous_pipe/windows.rs b/std/src/sys/anonymous_pipe/windows.rs index a48198f8a812b..eb7fa8ec1c9a1 100644 --- a/std/src/sys/anonymous_pipe/windows.rs +++ b/std/src/sys/anonymous_pipe/windows.rs @@ -1,12 +1,12 @@ +use crate::io::{self, PipeReader, PipeWriter}; use crate::os::windows::io::{ AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle, }; -use crate::pipe::{PipeReader, PipeWriter}; use crate::process::Stdio; +use crate::ptr; use crate::sys::c; use crate::sys::handle::Handle; use crate::sys_common::{FromInner, IntoInner}; -use crate::{io, ptr}; pub type AnonPipe = Handle; diff --git a/std/src/sys/backtrace.rs b/std/src/sys/backtrace.rs index 4d939e175cf2e..efa6a896dad8f 100644 --- a/std/src/sys/backtrace.rs +++ b/std/src/sys/backtrace.rs @@ -58,8 +58,8 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: let mut res = Ok(()); let mut omitted_count: usize = 0; let mut first_omit = true; - // Start immediately if we're not using a short backtrace. - let mut start = print_fmt != PrintFmt::Short; + // If we're using a short backtrace, ignore all frames until we're told to start printing. + let mut print = print_fmt != PrintFmt::Short; set_image_base(); // SAFETY: we roll our own locking in this town unsafe { @@ -72,27 +72,25 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| { hit = true; - // Any frames between `__rust_begin_short_backtrace` and `__rust_end_short_backtrace` - // are omitted from the backtrace in short mode, `__rust_end_short_backtrace` will be - // called before the panic hook, so we won't ignore any frames if there is no - // invoke of `__rust_begin_short_backtrace`. + // `__rust_end_short_backtrace` means we are done hiding symbols + // for now. Print until we see `__rust_begin_short_backtrace`. if print_fmt == PrintFmt::Short { if let Some(sym) = symbol.name().and_then(|s| s.as_str()) { - if start && sym.contains("__rust_begin_short_backtrace") { - start = false; + if sym.contains("__rust_end_short_backtrace") { + print = true; return; } - if sym.contains("__rust_end_short_backtrace") { - start = true; + if print && sym.contains("__rust_begin_short_backtrace") { + print = false; return; } - if !start { + if !print { omitted_count += 1; } } } - if start { + if print { if omitted_count > 0 { debug_assert!(print_fmt == PrintFmt::Short); // only print the message between the middle of frames @@ -112,7 +110,7 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: }); #[cfg(target_os = "nto")] if libc::__my_thread_exit as *mut libc::c_void == frame.ip() { - if !hit && start { + if !hit && print { use crate::backtrace_rs::SymbolName; res = bt_fmt.frame().print_raw( frame.ip(), @@ -123,7 +121,7 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: } return false; } - if !hit && start { + if !hit && print { res = bt_fmt.frame().print_raw(frame.ip(), None, None, None); } diff --git a/std/src/sys/cmath.rs b/std/src/sys/cmath.rs index 2997e908fa1b2..c9969b4e376ea 100644 --- a/std/src/sys/cmath.rs +++ b/std/src/sys/cmath.rs @@ -2,7 +2,7 @@ // These symbols are all defined by `libm`, // or by `compiler-builtins` on unsupported platforms. -extern "C" { +unsafe extern "C" { pub fn acos(n: f64) -> f64; pub fn asin(n: f64) -> f64; pub fn atan(n: f64) -> f64; @@ -26,7 +26,12 @@ extern "C" { pub fn tgamma(n: f64) -> f64; pub fn tgammaf(n: f32) -> f32; pub fn lgamma_r(n: f64, s: &mut i32) -> f64; + #[cfg(not(target_os = "aix"))] pub fn lgammaf_r(n: f32, s: &mut i32) -> f32; + pub fn erf(n: f64) -> f64; + pub fn erff(n: f32) -> f32; + pub fn erfc(n: f64) -> f64; + pub fn erfcf(n: f32) -> f32; pub fn acosf128(n: f128) -> f128; pub fn asinf128(n: f128) -> f128; @@ -42,6 +47,8 @@ extern "C" { pub fn tanhf128(n: f128) -> f128; pub fn tgammaf128(n: f128) -> f128; pub fn lgammaf128_r(n: f128, s: &mut i32) -> f128; + pub fn erff128(n: f128) -> f128; + pub fn erfcf128(n: f128) -> f128; cfg_if::cfg_if! { if #[cfg(not(all(target_os = "windows", target_env = "msvc", target_arch = "x86")))] { @@ -56,6 +63,13 @@ extern "C" { }} } +// On AIX, we don't have lgammaf_r only the f64 version, so we can +// use the f64 version lgamma_r +#[cfg(target_os = "aix")] +pub unsafe fn lgammaf_r(n: f32, s: &mut i32) -> f32 { + lgamma_r(n.into(), s) as f32 +} + // On 32-bit x86 MSVC these functions aren't defined, so we just define shims // which promote everything to f64, perform the calculation, and then demote // back to f32. While not precisely correct should be "correct enough" for now. diff --git a/std/src/sys_common/fs.rs b/std/src/sys/fs/common.rs similarity index 96% rename from std/src/sys_common/fs.rs rename to std/src/sys/fs/common.rs index a25a7244660bb..bfd684d295b89 100644 --- a/std/src/sys_common/fs.rs +++ b/std/src/sys/fs/common.rs @@ -5,7 +5,7 @@ use crate::io::{self, Error, ErrorKind}; use crate::path::Path; use crate::sys_common::ignore_notfound; -pub(crate) const NOT_FILE_ERROR: Error = io::const_io_error!( +pub(crate) const NOT_FILE_ERROR: Error = io::const_error!( ErrorKind::InvalidInput, "the source path is neither a regular file nor a symlink to a regular file", ); diff --git a/std/src/sys/pal/hermit/fs.rs b/std/src/sys/fs/hermit.rs similarity index 94% rename from std/src/sys/pal/hermit/fs.rs rename to std/src/sys/fs/hermit.rs index 17d15ed2e5045..1191e335daadd 100644 --- a/std/src/sys/pal/hermit/fs.rs +++ b/std/src/sys/fs/hermit.rs @@ -1,18 +1,18 @@ -use super::fd::FileDesc; -use super::hermit_abi::{ +use crate::ffi::{CStr, OsStr, OsString, c_char}; +use crate::io::{self, BorrowedCursor, Error, ErrorKind, IoSlice, IoSliceMut, SeekFrom}; +use crate::os::hermit::ffi::OsStringExt; +use crate::os::hermit::hermit_abi::{ self, DT_DIR, DT_LNK, DT_REG, DT_UNKNOWN, O_APPEND, O_CREAT, O_DIRECTORY, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, dirent64, stat as stat_struct, }; -use crate::ffi::{CStr, OsStr, OsString}; -use crate::io::{self, BorrowedCursor, Error, ErrorKind, IoSlice, IoSliceMut, SeekFrom}; -use crate::os::hermit::ffi::OsStringExt; use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use crate::path::{Path, PathBuf}; use crate::sync::Arc; use crate::sys::common::small_c_string::run_path_with_cstr; +pub use crate::sys::fs::common::{copy, exists}; +use crate::sys::pal::fd::FileDesc; use crate::sys::time::SystemTime; use crate::sys::{cvt, unsupported}; -pub use crate::sys_common::fs::{copy, exists}; use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; use crate::{fmt, mem}; @@ -135,7 +135,7 @@ impl FileAttr { S_IFREG => DT_REG, _ => DT_UNKNOWN, }; - FileType { mode: mode } + FileType { mode } } } @@ -204,7 +204,7 @@ impl Iterator for ReadDir { // the size of dirent64. The file name is always a C string and terminated by `\0`. // Consequently, we are able to ignore the last byte. let name_bytes = - unsafe { CStr::from_ptr(&dir.d_name as *const _ as *const i8).to_bytes() }; + unsafe { CStr::from_ptr(&dir.d_name as *const _ as *const c_char).to_bytes() }; let entry = DirEntry { root: self.inner.root.clone(), ino: dir.d_ino, @@ -294,7 +294,7 @@ impl OpenOptions { (false, _, true) => Ok(O_WRONLY | O_APPEND), (true, _, true) => Ok(O_RDWR | O_APPEND), (false, false, false) => { - Err(io::const_io_error!(ErrorKind::InvalidInput, "invalid access mode")) + Err(io::const_error!(ErrorKind::InvalidInput, "invalid access mode")) } } } @@ -304,18 +304,12 @@ impl OpenOptions { (true, false) => {} (false, false) => { if self.truncate || self.create || self.create_new { - return Err(io::const_io_error!( - ErrorKind::InvalidInput, - "invalid creation mode", - )); + return Err(io::const_error!(ErrorKind::InvalidInput, "invalid creation mode")); } } (_, true) => { if self.truncate && !self.create_new { - return Err(io::const_io_error!( - ErrorKind::InvalidInput, - "invalid creation mode", - )); + return Err(io::const_error!(ErrorKind::InvalidInput, "invalid creation mode")); } } } @@ -423,8 +417,12 @@ impl File { Ok(()) } - pub fn seek(&self, _pos: SeekFrom) -> io::Result { - Err(Error::from_raw_os_error(22)) + pub fn seek(&self, pos: SeekFrom) -> io::Result { + self.0.seek(pos) + } + + pub fn tell(&self) -> io::Result { + self.0.tell() } pub fn duplicate(&self) -> io::Result { @@ -447,7 +445,7 @@ impl DirBuilder { pub fn mkdir(&self, path: &Path) -> io::Result<()> { run_path_with_cstr(path, &|path| { - cvt(unsafe { hermit_abi::mkdir(path.as_ptr(), self.mode.into()) }).map(|_| ()) + cvt(unsafe { hermit_abi::mkdir(path.as_ptr().cast(), self.mode.into()) }).map(|_| ()) }) } diff --git a/std/src/sys/fs/mod.rs b/std/src/sys/fs/mod.rs new file mode 100644 index 0000000000000..c2e19eb393a16 --- /dev/null +++ b/std/src/sys/fs/mod.rs @@ -0,0 +1,28 @@ +#![deny(unsafe_op_in_unsafe_fn)] + +pub mod common; + +cfg_if::cfg_if! { + if #[cfg(target_family = "unix")] { + mod unix; + pub use unix::*; + } else if #[cfg(target_os = "windows")] { + mod windows; + pub use windows::*; + } else if #[cfg(target_os = "hermit")] { + mod hermit; + pub use hermit::*; + } else if #[cfg(target_os = "solid_asp3")] { + mod solid; + pub use solid::*; + } else if #[cfg(target_os = "uefi")] { + mod uefi; + pub use uefi::*; + } else if #[cfg(target_os = "wasi")] { + mod wasi; + pub use wasi::*; + } else { + mod unsupported; + pub use unsupported::*; + } +} diff --git a/std/src/sys/pal/solid/fs.rs b/std/src/sys/fs/solid.rs similarity index 94% rename from std/src/sys/pal/solid/fs.rs rename to std/src/sys/fs/solid.rs index 776a96ff3b7ba..39de933b7248b 100644 --- a/std/src/sys/pal/solid/fs.rs +++ b/std/src/sys/fs/solid.rs @@ -1,4 +1,5 @@ -use super::{abi, error}; +#![allow(dead_code)] + use crate::ffi::{CStr, CString, OsStr, OsString}; use crate::fmt; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}; @@ -7,34 +8,30 @@ use crate::os::raw::{c_int, c_short}; use crate::os::solid::ffi::OsStrExt; use crate::path::{Path, PathBuf}; use crate::sync::Arc; +pub use crate::sys::fs::common::exists; +use crate::sys::pal::{abi, error}; use crate::sys::time::SystemTime; use crate::sys::unsupported; -pub use crate::sys_common::fs::exists; use crate::sys_common::ignore_notfound; +type CIntNotMinusOne = core::num::niche_types::NotAllOnes; + /// A file descriptor. #[derive(Clone, Copy)] -#[rustc_layout_scalar_valid_range_start(0)] -// libstd/os/raw/mod.rs assures me that every libstd-supported platform has a -// 32-bit c_int. Below is -2, in two's complement, but that only works out -// because c_int is 32 bits. -#[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)] struct FileDesc { - fd: c_int, + fd: CIntNotMinusOne, } impl FileDesc { #[inline] + #[track_caller] fn new(fd: c_int) -> FileDesc { - assert_ne!(fd, -1i32); - // Safety: we just asserted that the value is in the valid range and - // isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) - unsafe { FileDesc { fd } } + FileDesc { fd: CIntNotMinusOne::new(fd).expect("fd != -1") } } #[inline] fn raw(&self) -> c_int { - self.fd + self.fd.as_inner() } } @@ -303,7 +300,7 @@ fn cstr(path: &Path) -> io::Result { if !path.starts_with(br"\") { // Relative paths aren't supported - return Err(crate::io::const_io_error!( + return Err(crate::io::const_error!( crate::io::ErrorKind::Unsupported, "relative path is not supported on this platform", )); @@ -314,10 +311,7 @@ fn cstr(path: &Path) -> io::Result { let wrapped_path = [SAFE_PREFIX, &path, &[0]].concat(); CString::from_vec_with_nul(wrapped_path).map_err(|_| { - crate::io::const_io_error!( - io::ErrorKind::InvalidInput, - "path provided contains a nul byte", - ) + crate::io::const_error!(io::ErrorKind::InvalidInput, "path provided contains a nul byte") }) } @@ -460,8 +454,11 @@ impl File { abi::SOLID_FS_Lseek(self.fd.raw(), pos, whence) }) .map_err(|e| e.as_io_error())?; - // Get the new offset + self.tell() + } + + pub fn tell(&self) -> io::Result { unsafe { let mut out_offset = MaybeUninit::uninit(); error::SolidError::err_if_negative(abi::SOLID_FS_Ftell( @@ -512,7 +509,7 @@ impl fmt::Debug for File { pub fn unlink(p: &Path) -> io::Result<()> { if stat(p)?.file_type().is_dir() { - Err(io::const_io_error!(io::ErrorKind::IsADirectory, "is a directory")) + Err(io::const_error!(io::ErrorKind::IsADirectory, "is a directory")) } else { error::SolidError::err_if_negative(unsafe { abi::SOLID_FS_Unlink(cstr(p)?.as_ptr()) }) .map_err(|e| e.as_io_error())?; @@ -542,7 +539,7 @@ pub fn rmdir(p: &Path) -> io::Result<()> { .map_err(|e| e.as_io_error())?; Ok(()) } else { - Err(io::const_io_error!(io::ErrorKind::NotADirectory, "not a directory")) + Err(io::const_error!(io::ErrorKind::NotADirectory, "not a directory")) } } @@ -570,7 +567,7 @@ pub fn remove_dir_all(path: &Path) -> io::Result<()> { pub fn readlink(p: &Path) -> io::Result { // This target doesn't support symlinks stat(p)?; - Err(io::const_io_error!(io::ErrorKind::InvalidInput, "not a symbolic link")) + Err(io::const_error!(io::ErrorKind::InvalidInput, "not a symbolic link")) } pub fn symlink(_original: &Path, _link: &Path) -> io::Result<()> { diff --git a/std/src/sys/fs/uefi.rs b/std/src/sys/fs/uefi.rs new file mode 100644 index 0000000000000..56aed7dfd8e82 --- /dev/null +++ b/std/src/sys/fs/uefi.rs @@ -0,0 +1,319 @@ +use crate::ffi::OsString; +use crate::fmt; +use crate::hash::Hash; +use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}; +use crate::path::{Path, PathBuf}; +use crate::sys::time::SystemTime; +use crate::sys::unsupported; + +#[expect(dead_code)] +const FILE_PERMISSIONS_MASK: u64 = r_efi::protocols::file::READ_ONLY; + +pub struct File(!); + +#[derive(Clone)] +pub struct FileAttr { + attr: u64, + size: u64, +} + +pub struct ReadDir(!); + +pub struct DirEntry(!); + +#[derive(Clone, Debug)] +pub struct OpenOptions {} + +#[derive(Copy, Clone, Debug, Default)] +pub struct FileTimes {} + +#[derive(Clone, PartialEq, Eq, Debug)] +// Bool indicates if file is readonly +pub struct FilePermissions(bool); + +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +// Bool indicates if directory +pub struct FileType(bool); + +#[derive(Debug)] +pub struct DirBuilder {} + +impl FileAttr { + pub fn size(&self) -> u64 { + self.size + } + + pub fn perm(&self) -> FilePermissions { + FilePermissions::from_attr(self.attr) + } + + pub fn file_type(&self) -> FileType { + FileType::from_attr(self.attr) + } + + pub fn modified(&self) -> io::Result { + unsupported() + } + + pub fn accessed(&self) -> io::Result { + unsupported() + } + + pub fn created(&self) -> io::Result { + unsupported() + } +} + +impl FilePermissions { + pub fn readonly(&self) -> bool { + self.0 + } + + pub fn set_readonly(&mut self, readonly: bool) { + self.0 = readonly + } + + const fn from_attr(attr: u64) -> Self { + Self(attr & r_efi::protocols::file::READ_ONLY != 0) + } + + #[expect(dead_code)] + const fn to_attr(&self) -> u64 { + if self.0 { r_efi::protocols::file::READ_ONLY } else { 0 } + } +} + +impl FileTimes { + pub fn set_accessed(&mut self, _t: SystemTime) {} + pub fn set_modified(&mut self, _t: SystemTime) {} +} + +impl FileType { + pub fn is_dir(&self) -> bool { + self.0 + } + + pub fn is_file(&self) -> bool { + !self.is_dir() + } + + // Symlinks are not supported in UEFI + pub fn is_symlink(&self) -> bool { + false + } + + const fn from_attr(attr: u64) -> Self { + Self(attr & r_efi::protocols::file::DIRECTORY != 0) + } +} + +impl fmt::Debug for ReadDir { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0 + } +} + +impl Iterator for ReadDir { + type Item = io::Result; + + fn next(&mut self) -> Option> { + self.0 + } +} + +impl DirEntry { + pub fn path(&self) -> PathBuf { + self.0 + } + + pub fn file_name(&self) -> OsString { + self.0 + } + + pub fn metadata(&self) -> io::Result { + self.0 + } + + pub fn file_type(&self) -> io::Result { + self.0 + } +} + +impl OpenOptions { + pub fn new() -> OpenOptions { + OpenOptions {} + } + + pub fn read(&mut self, _read: bool) {} + pub fn write(&mut self, _write: bool) {} + pub fn append(&mut self, _append: bool) {} + pub fn truncate(&mut self, _truncate: bool) {} + pub fn create(&mut self, _create: bool) {} + pub fn create_new(&mut self, _create_new: bool) {} +} + +impl File { + pub fn open(_path: &Path, _opts: &OpenOptions) -> io::Result { + unsupported() + } + + pub fn file_attr(&self) -> io::Result { + self.0 + } + + pub fn fsync(&self) -> io::Result<()> { + self.0 + } + + pub fn datasync(&self) -> io::Result<()> { + self.0 + } + + pub fn lock(&self) -> io::Result<()> { + self.0 + } + + pub fn lock_shared(&self) -> io::Result<()> { + self.0 + } + + pub fn try_lock(&self) -> io::Result { + self.0 + } + + pub fn try_lock_shared(&self) -> io::Result { + self.0 + } + + pub fn unlock(&self) -> io::Result<()> { + self.0 + } + + pub fn truncate(&self, _size: u64) -> io::Result<()> { + self.0 + } + + pub fn read(&self, _buf: &mut [u8]) -> io::Result { + self.0 + } + + pub fn read_vectored(&self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result { + self.0 + } + + pub fn is_read_vectored(&self) -> bool { + self.0 + } + + pub fn read_buf(&self, _cursor: BorrowedCursor<'_>) -> io::Result<()> { + self.0 + } + + pub fn write(&self, _buf: &[u8]) -> io::Result { + self.0 + } + + pub fn write_vectored(&self, _bufs: &[IoSlice<'_>]) -> io::Result { + self.0 + } + + pub fn is_write_vectored(&self) -> bool { + self.0 + } + + pub fn flush(&self) -> io::Result<()> { + self.0 + } + + pub fn seek(&self, _pos: SeekFrom) -> io::Result { + self.0 + } + + pub fn tell(&self) -> io::Result { + self.0 + } + + pub fn duplicate(&self) -> io::Result { + self.0 + } + + pub fn set_permissions(&self, _perm: FilePermissions) -> io::Result<()> { + self.0 + } + + pub fn set_times(&self, _times: FileTimes) -> io::Result<()> { + self.0 + } +} + +impl DirBuilder { + pub fn new() -> DirBuilder { + DirBuilder {} + } + + pub fn mkdir(&self, _p: &Path) -> io::Result<()> { + unsupported() + } +} + +impl fmt::Debug for File { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0 + } +} + +pub fn readdir(_p: &Path) -> io::Result { + unsupported() +} + +pub fn unlink(_p: &Path) -> io::Result<()> { + unsupported() +} + +pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> { + unsupported() +} + +pub fn set_perm(_p: &Path, _perm: FilePermissions) -> io::Result<()> { + unsupported() +} + +pub fn rmdir(_p: &Path) -> io::Result<()> { + unsupported() +} + +pub fn remove_dir_all(_path: &Path) -> io::Result<()> { + unsupported() +} + +pub fn exists(_path: &Path) -> io::Result { + unsupported() +} + +pub fn readlink(_p: &Path) -> io::Result { + unsupported() +} + +pub fn symlink(_original: &Path, _link: &Path) -> io::Result<()> { + unsupported() +} + +pub fn link(_src: &Path, _dst: &Path) -> io::Result<()> { + unsupported() +} + +pub fn stat(_p: &Path) -> io::Result { + unsupported() +} + +pub fn lstat(_p: &Path) -> io::Result { + unsupported() +} + +pub fn canonicalize(_p: &Path) -> io::Result { + unsupported() +} + +pub fn copy(_from: &Path, _to: &Path) -> io::Result { + unsupported() +} diff --git a/std/src/sys/pal/unix/fs.rs b/std/src/sys/fs/unix.rs similarity index 92% rename from std/src/sys/pal/unix/fs.rs rename to std/src/sys/fs/unix.rs index 96f99efb21e84..d944bc9c9a2a0 100644 --- a/std/src/sys/pal/unix/fs.rs +++ b/std/src/sys/fs/unix.rs @@ -1,3 +1,5 @@ +#![allow(nonstandard_style)] +#![allow(unsafe_op_in_unsafe_fn)] // miri has some special hacks here that make things unused. #![cfg_attr(miri, allow(unused))] @@ -8,16 +10,14 @@ mod tests; use libc::c_char; #[cfg(any( all(target_os = "linux", not(target_env = "musl")), - target_os = "emscripten", target_os = "android", + target_os = "fuchsia", target_os = "hurd" ))] use libc::dirfd; -#[cfg(any( - all(target_os = "linux", not(target_env = "musl")), - target_os = "emscripten", - target_os = "hurd" -))] +#[cfg(target_os = "fuchsia")] +use libc::fstatat as fstatat64; +#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "hurd"))] use libc::fstatat64; #[cfg(any( target_os = "android", @@ -34,7 +34,6 @@ use libc::readdir as readdir64; #[cfg(not(any( target_os = "android", target_os = "linux", - target_os = "emscripten", target_os = "solaris", target_os = "illumos", target_os = "l4re", @@ -48,7 +47,7 @@ use libc::readdir as readdir64; use libc::readdir_r as readdir64_r; #[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "hurd"))] use libc::readdir64; -#[cfg(any(target_os = "emscripten", target_os = "l4re"))] +#[cfg(target_os = "l4re")] use libc::readdir64_r; use libc::{c_int, mode_t}; #[cfg(target_os = "android")] @@ -58,7 +57,6 @@ use libc::{ }; #[cfg(not(any( all(target_os = "linux", not(target_env = "musl")), - target_os = "emscripten", target_os = "l4re", target_os = "android", target_os = "hurd", @@ -69,7 +67,6 @@ use libc::{ }; #[cfg(any( all(target_os = "linux", not(target_env = "musl")), - target_os = "emscripten", target_os = "l4re", target_os = "hurd" ))] @@ -84,13 +81,13 @@ use crate::path::{Path, PathBuf}; use crate::sync::Arc; use crate::sys::common::small_c_string::run_path_with_cstr; use crate::sys::fd::FileDesc; +pub use crate::sys::fs::common::exists; use crate::sys::time::SystemTime; #[cfg(all(target_os = "linux", target_env = "gnu"))] use crate::sys::weak::syscall; #[cfg(target_os = "android")] use crate::sys::weak::weak; use crate::sys::{cvt, cvt_r}; -pub use crate::sys_common::fs::exists; use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; use crate::{mem, ptr}; @@ -168,7 +165,8 @@ cfg_has_statx! {{ ) -> c_int } - if STATX_SAVED_STATE.load(Ordering::Relaxed) == STATX_STATE::Unavailable as u8 { + let statx_availability = STATX_SAVED_STATE.load(Ordering::Relaxed); + if statx_availability == STATX_STATE::Unavailable as u8 { return None; } @@ -200,6 +198,9 @@ cfg_has_statx! {{ return None; } } + if statx_availability == STATX_STATE::Unknown as u8 { + STATX_SAVED_STATE.store(STATX_STATE::Present as u8, Ordering::Relaxed); + } // We cannot fill `stat64` exhaustively because of private padding fields. let mut stat: stat64 = mem::zeroed(); @@ -559,7 +560,7 @@ impl FileAttr { return if (ext.stx_mask & libc::STATX_BTIME) != 0 { SystemTime::new(ext.stx_btime.tv_sec, ext.stx_btime.tv_nsec as i64) } else { - Err(io::const_io_error!( + Err(io::const_error!( io::ErrorKind::Unsupported, "creation time is not available for the filesystem", )) @@ -567,10 +568,9 @@ impl FileAttr { } } - Err(io::const_io_error!( + Err(io::const_error!( io::ErrorKind::Unsupported, - "creation time is not available on this platform \ - currently", + "creation time is not available on this platform currently", )) } @@ -701,6 +701,8 @@ impl Iterator for ReadDir { target_os = "hurd", ))] fn next(&mut self) -> Option> { + use crate::sys::os::{errno, set_errno}; + if self.end_of_stream { return None; } @@ -712,8 +714,8 @@ impl Iterator for ReadDir { // with unlimited or variable NAME_MAX. Many modern platforms guarantee // thread safety for readdir() as long an individual DIR* is not accessed // concurrently, which is sufficient for Rust. - super::os::set_errno(0); - let entry_ptr = readdir64(self.inner.dirp.0); + set_errno(0); + let entry_ptr: *const dirent64 = readdir64(self.inner.dirp.0); if entry_ptr.is_null() { // We either encountered an error, or reached the end. Either way, // the next call to next() should return None. @@ -721,7 +723,7 @@ impl Iterator for ReadDir { // To distinguish between errors and end-of-directory, we had to clear // errno beforehand to check for an error now. - return match super::os::errno() { + return match errno() { 0 => None, e => Some(Err(Error::from_raw_os_error(e))), }; @@ -739,44 +741,32 @@ impl Iterator for ReadDir { // contents were "simply" partially initialized data. // // Like for uninitialized contents, converting entry_ptr to `&dirent64` - // would not be legal. However, unique to dirent64 is that we don't even - // get to use `&raw const (*entry_ptr).d_name` because that operation - // requires the full extent of *entry_ptr to be in bounds of the same - // allocation, which is not necessarily the case here. - // - // Instead we must access fields individually through their offsets. - macro_rules! offset_ptr { - ($entry_ptr:expr, $field:ident) => {{ - const OFFSET: isize = mem::offset_of!(dirent64, $field) as isize; - if true { - // Cast to the same type determined by the else branch. - $entry_ptr.byte_offset(OFFSET).cast::<_>() - } else { - #[allow(deref_nullptr)] - { - &raw const (*ptr::null::()).$field - } - } - }}; - } + // would not be legal. However, we can use `&raw const (*entry_ptr).d_name` + // to refer the fields individually, because that operation is equivalent + // to `byte_offset` and thus does not require the full extent of `*entry_ptr` + // to be in bounds of the same allocation, only the offset of the field + // being referenced. // d_name is guaranteed to be null-terminated. - let name = CStr::from_ptr(offset_ptr!(entry_ptr, d_name).cast()); + let name = CStr::from_ptr((&raw const (*entry_ptr).d_name).cast()); let name_bytes = name.to_bytes(); if name_bytes == b"." || name_bytes == b".." { continue; } + // When loading from a field, we can skip the `&raw const`; `(*entry_ptr).d_ino` as + // a value expression will do the right thing: `byte_offset` to the field and then + // only access those bytes. #[cfg(not(target_os = "vita"))] let entry = dirent64_min { - d_ino: *offset_ptr!(entry_ptr, d_ino) as u64, + d_ino: (*entry_ptr).d_ino as u64, #[cfg(not(any( target_os = "solaris", target_os = "illumos", target_os = "aix", target_os = "nto", )))] - d_type: *offset_ptr!(entry_ptr, d_type) as u8, + d_type: (*entry_ptr).d_type as u8, }; #[cfg(target_os = "vita")] @@ -864,7 +854,6 @@ impl Drop for Dir { target_os = "vita", target_os = "hurd", target_os = "espidf", - target_os = "fuchsia", target_os = "horizon", target_os = "vxworks", target_os = "rtems", @@ -895,8 +884,8 @@ impl DirEntry { #[cfg(all( any( all(target_os = "linux", not(target_env = "musl")), - target_os = "emscripten", target_os = "android", + target_os = "fuchsia", target_os = "hurd" ), not(miri) // no dirfd on Miri @@ -924,8 +913,8 @@ impl DirEntry { #[cfg(any( not(any( all(target_os = "linux", not(target_env = "musl")), - target_os = "emscripten", target_os = "android", + target_os = "fuchsia", target_os = "hurd", )), miri @@ -1229,6 +1218,7 @@ impl File { } #[cfg(any( target_os = "freebsd", + target_os = "fuchsia", target_os = "linux", target_os = "android", target_os = "netbsd", @@ -1241,6 +1231,7 @@ impl File { } #[cfg(not(any( target_os = "android", + target_os = "fuchsia", target_os = "freebsd", target_os = "linux", target_os = "netbsd", @@ -1256,6 +1247,7 @@ impl File { #[cfg(any( target_os = "freebsd", + target_os = "fuchsia", target_os = "linux", target_os = "netbsd", target_vendor = "apple", @@ -1267,16 +1259,18 @@ impl File { #[cfg(not(any( target_os = "freebsd", + target_os = "fuchsia", target_os = "linux", target_os = "netbsd", target_vendor = "apple", )))] pub fn lock(&self) -> io::Result<()> { - Err(io::const_io_error!(io::ErrorKind::Unsupported, "lock() not supported")) + Err(io::const_error!(io::ErrorKind::Unsupported, "lock() not supported")) } #[cfg(any( target_os = "freebsd", + target_os = "fuchsia", target_os = "linux", target_os = "netbsd", target_vendor = "apple", @@ -1288,16 +1282,18 @@ impl File { #[cfg(not(any( target_os = "freebsd", + target_os = "fuchsia", target_os = "linux", target_os = "netbsd", target_vendor = "apple", )))] pub fn lock_shared(&self) -> io::Result<()> { - Err(io::const_io_error!(io::ErrorKind::Unsupported, "lock_shared() not supported")) + Err(io::const_error!(io::ErrorKind::Unsupported, "lock_shared() not supported")) } #[cfg(any( target_os = "freebsd", + target_os = "fuchsia", target_os = "linux", target_os = "netbsd", target_vendor = "apple", @@ -1315,16 +1311,18 @@ impl File { #[cfg(not(any( target_os = "freebsd", + target_os = "fuchsia", target_os = "linux", target_os = "netbsd", target_vendor = "apple", )))] pub fn try_lock(&self) -> io::Result { - Err(io::const_io_error!(io::ErrorKind::Unsupported, "try_lock() not supported")) + Err(io::const_error!(io::ErrorKind::Unsupported, "try_lock() not supported")) } #[cfg(any( target_os = "freebsd", + target_os = "fuchsia", target_os = "linux", target_os = "netbsd", target_vendor = "apple", @@ -1342,16 +1340,18 @@ impl File { #[cfg(not(any( target_os = "freebsd", + target_os = "fuchsia", target_os = "linux", target_os = "netbsd", target_vendor = "apple", )))] pub fn try_lock_shared(&self) -> io::Result { - Err(io::const_io_error!(io::ErrorKind::Unsupported, "try_lock_shared() not supported")) + Err(io::const_error!(io::ErrorKind::Unsupported, "try_lock_shared() not supported")) } #[cfg(any( target_os = "freebsd", + target_os = "fuchsia", target_os = "linux", target_os = "netbsd", target_vendor = "apple", @@ -1363,12 +1363,13 @@ impl File { #[cfg(not(any( target_os = "freebsd", + target_os = "fuchsia", target_os = "linux", target_os = "netbsd", target_vendor = "apple", )))] pub fn unlock(&self) -> io::Result<()> { - Err(io::const_io_error!(io::ErrorKind::Unsupported, "unlock() not supported")) + Err(io::const_error!(io::ErrorKind::Unsupported, "unlock() not supported")) } pub fn truncate(&self, size: u64) -> io::Result<()> { @@ -1440,6 +1441,10 @@ impl File { Ok(n as u64) } + pub fn tell(&self) -> io::Result { + self.seek(SeekFrom::Current(0)) + } + pub fn duplicate(&self) -> io::Result { self.0.duplicate().map(File) } @@ -1449,6 +1454,20 @@ impl File { Ok(()) } + // FIXME(#115199): Rust currently omits weak function definitions + // and its metadata from LLVM IR. + #[cfg_attr( + any( + target_os = "android", + all( + target_os = "linux", + target_env = "gnu", + target_pointer_width = "32", + not(target_arch = "riscv32") + ) + ), + no_sanitize(cfi) + )] pub fn set_times(&self, times: FileTimes) -> io::Result<()> { #[cfg(not(any( target_os = "redox", @@ -1459,13 +1478,13 @@ impl File { )))] let to_timespec = |time: Option| match time { Some(time) if let Some(ts) = time.t.to_timespec() => Ok(ts), - Some(time) if time > crate::sys::time::UNIX_EPOCH => Err(io::const_io_error!( + Some(time) if time > crate::sys::time::UNIX_EPOCH => Err(io::const_error!( io::ErrorKind::InvalidInput, - "timestamp is too large to set as a file time" + "timestamp is too large to set as a file time", )), - Some(_) => Err(io::const_io_error!( + Some(_) => Err(io::const_error!( io::ErrorKind::InvalidInput, - "timestamp is too small to set as a file time" + "timestamp is too small to set as a file time", )), None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }), }; @@ -1476,7 +1495,7 @@ impl File { // the same as for Redox. // `futimens` and `UTIME_OMIT` are a work in progress for vxworks. let _ = times; - Err(io::const_io_error!( + Err(io::const_error!( io::ErrorKind::Unsupported, "setting file times not supported", )) @@ -1504,7 +1523,7 @@ impl File { self.as_raw_fd(), (&raw const attrlist).cast::().cast_mut(), buf.as_ptr().cast::().cast_mut(), - num_times * mem::size_of::(), + num_times * size_of::(), 0 ) })?; Ok(()) @@ -1515,7 +1534,7 @@ impl File { weak!(fn futimens(c_int, *const libc::timespec) -> c_int); match futimens.get() { Some(futimens) => futimens(self.as_raw_fd(), times.as_ptr()), - None => return Err(io::const_io_error!( + None => return Err(io::const_error!( io::ErrorKind::Unsupported, "setting file times requires Android API level >= 19", )), @@ -1659,7 +1678,7 @@ impl fmt::Debug for File { fn get_path(fd: c_int) -> Option { let info = Box::::new_zeroed(); let mut info = unsafe { info.assume_init() }; - info.kf_structsize = mem::size_of::() as libc::c_int; + info.kf_structsize = size_of::() as libc::c_int; let n = unsafe { libc::fcntl(fd, libc::F_KINFO, &mut *info) }; if n == -1 { return None; @@ -1931,7 +1950,7 @@ pub fn canonicalize(p: &Path) -> io::Result { fn open_from(from: &Path) -> io::Result<(crate::fs::File, crate::fs::Metadata)> { use crate::fs::File; - use crate::sys_common::fs::NOT_FILE_ERROR; + use crate::sys::fs::common::NOT_FILE_ERROR; let reader = File::open(from)?; let metadata = reader.metadata()?; @@ -1944,7 +1963,7 @@ fn open_from(from: &Path) -> io::Result<(crate::fs::File, crate::fs::Metadata)> #[cfg(target_os = "espidf")] fn open_to_and_set_permissions( to: &Path, - _reader_metadata: crate::fs::Metadata, + _reader_metadata: &crate::fs::Metadata, ) -> io::Result<(crate::fs::File, crate::fs::Metadata)> { use crate::fs::OpenOptions; let writer = OpenOptions::new().open(to)?; @@ -1955,7 +1974,7 @@ fn open_to_and_set_permissions( #[cfg(not(target_os = "espidf"))] fn open_to_and_set_permissions( to: &Path, - reader_metadata: crate::fs::Metadata, + reader_metadata: &crate::fs::Metadata, ) -> io::Result<(crate::fs::File, crate::fs::Metadata)> { use crate::fs::OpenOptions; use crate::os::unix::fs::{OpenOptionsExt, PermissionsExt}; @@ -1980,30 +1999,63 @@ fn open_to_and_set_permissions( Ok((writer, writer_metadata)) } -#[cfg(not(any(target_os = "linux", target_os = "android", target_vendor = "apple")))] -pub fn copy(from: &Path, to: &Path) -> io::Result { - let (mut reader, reader_metadata) = open_from(from)?; - let (mut writer, _) = open_to_and_set_permissions(to, reader_metadata)?; +mod cfm { + use crate::fs::{File, Metadata}; + use crate::io::{BorrowedCursor, IoSlice, IoSliceMut, Read, Result, Write}; - io::copy(&mut reader, &mut writer) -} + #[allow(dead_code)] + pub struct CachedFileMetadata(pub File, pub Metadata); + impl Read for CachedFileMetadata { + fn read(&mut self, buf: &mut [u8]) -> Result { + self.0.read(buf) + } + fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result { + self.0.read_vectored(bufs) + } + fn read_buf(&mut self, cursor: BorrowedCursor<'_>) -> Result<()> { + self.0.read_buf(cursor) + } + #[inline] + fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() + } + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + self.0.read_to_end(buf) + } + fn read_to_string(&mut self, buf: &mut String) -> Result { + self.0.read_to_string(buf) + } + } + impl Write for CachedFileMetadata { + fn write(&mut self, buf: &[u8]) -> Result { + self.0.write(buf) + } + fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result { + self.0.write_vectored(bufs) + } + #[inline] + fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() + } + #[inline] + fn flush(&mut self) -> Result<()> { + self.0.flush() + } + } +} #[cfg(any(target_os = "linux", target_os = "android"))] +pub(crate) use cfm::CachedFileMetadata; + +#[cfg(not(target_vendor = "apple"))] pub fn copy(from: &Path, to: &Path) -> io::Result { - let (mut reader, reader_metadata) = open_from(from)?; - let max_len = u64::MAX; - let (mut writer, _) = open_to_and_set_permissions(to, reader_metadata)?; - - use super::kernel_copy::{CopyResult, copy_regular_files}; - - match copy_regular_files(reader.as_raw_fd(), writer.as_raw_fd(), max_len) { - CopyResult::Ended(bytes) => Ok(bytes), - CopyResult::Error(e, _) => Err(e), - CopyResult::Fallback(written) => match io::copy::generic_copy(&mut reader, &mut writer) { - Ok(bytes) => Ok(bytes + written), - Err(e) => Err(e), - }, - } + let (reader, reader_metadata) = open_from(from)?; + let (writer, writer_metadata) = open_to_and_set_permissions(to, &reader_metadata)?; + + io::copy( + &mut cfm::CachedFileMetadata(reader, reader_metadata), + &mut cfm::CachedFileMetadata(writer, writer_metadata), + ) } #[cfg(target_vendor = "apple")] @@ -2040,7 +2092,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { } // Fall back to using `fcopyfile` if `fclonefileat` does not succeed. - let (writer, writer_metadata) = open_to_and_set_permissions(to, reader_metadata)?; + let (writer, writer_metadata) = open_to_and_set_permissions(to, &reader_metadata)?; // We ensure that `FreeOnDrop` never contains a null pointer so it is // always safe to call `copyfile_state_free` @@ -2090,7 +2142,7 @@ pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> { #[cfg(target_os = "vxworks")] pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> { let (_, _, _) = (path, uid, gid); - Err(io::const_io_error!(io::ErrorKind::Unsupported, "lchown not supported by vxworks")) + Err(io::const_error!(io::ErrorKind::Unsupported, "lchown not supported by vxworks")) } #[cfg(not(any(target_os = "fuchsia", target_os = "vxworks")))] @@ -2101,7 +2153,7 @@ pub fn chroot(dir: &Path) -> io::Result<()> { #[cfg(target_os = "vxworks")] pub fn chroot(dir: &Path) -> io::Result<()> { let _ = dir; - Err(io::const_io_error!(io::ErrorKind::Unsupported, "chroot not supported by vxworks")) + Err(io::const_error!(io::ErrorKind::Unsupported, "chroot not supported by vxworks")) } pub use remove_dir_impl::remove_dir_all; @@ -2117,7 +2169,7 @@ pub use remove_dir_impl::remove_dir_all; miri ))] mod remove_dir_impl { - pub use crate::sys_common::fs::remove_dir_all; + pub use crate::sys::fs::common::remove_dir_all; } // Modern implementation using openat(), unlinkat() and fdopendir() diff --git a/std/src/sys/pal/unix/fs/tests.rs b/std/src/sys/fs/unix/tests.rs similarity index 98% rename from std/src/sys/pal/unix/fs/tests.rs rename to std/src/sys/fs/unix/tests.rs index 71be3472148b0..8875a318db7d2 100644 --- a/std/src/sys/pal/unix/fs/tests.rs +++ b/std/src/sys/fs/unix/tests.rs @@ -1,4 +1,4 @@ -use crate::sys::pal::unix::fs::FilePermissions; +use crate::sys::fs::FilePermissions; #[test] fn test_debug_permissions() { diff --git a/std/src/sys/pal/unsupported/fs.rs b/std/src/sys/fs/unsupported.rs similarity index 98% rename from std/src/sys/pal/unsupported/fs.rs rename to std/src/sys/fs/unsupported.rs index 9585ec24f687d..45e93deffa3a4 100644 --- a/std/src/sys/pal/unsupported/fs.rs +++ b/std/src/sys/fs/unsupported.rs @@ -258,6 +258,10 @@ impl File { self.0 } + pub fn tell(&self) -> io::Result { + self.0 + } + pub fn duplicate(&self) -> io::Result { self.0 } diff --git a/std/src/sys/pal/wasi/fs.rs b/std/src/sys/fs/wasi.rs similarity index 81% rename from std/src/sys/pal/wasi/fs.rs rename to std/src/sys/fs/wasi.rs index 3296c762cca2b..773040571bc97 100644 --- a/std/src/sys/pal/wasi/fs.rs +++ b/std/src/sys/fs/wasi.rs @@ -1,6 +1,3 @@ -#![forbid(unsafe_op_in_unsafe_fn)] - -use super::fd::WasiFd; use crate::ffi::{CStr, OsStr, OsString}; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}; use crate::mem::{self, ManuallyDrop}; @@ -10,9 +7,10 @@ use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd use crate::path::{Path, PathBuf}; use crate::sync::Arc; use crate::sys::common::small_c_string::run_path_with_cstr; +use crate::sys::fd::WasiFd; +pub use crate::sys::fs::common::exists; use crate::sys::time::SystemTime; use crate::sys::unsupported; -pub use crate::sys_common::fs::exists; use crate::sys_common::{AsInner, FromInner, IntoInner, ignore_notfound}; use crate::{fmt, iter, ptr}; @@ -27,10 +25,27 @@ pub struct FileAttr { pub struct ReadDir { inner: Arc, - cookie: Option, - buf: Vec, - offset: usize, - cap: usize, + state: ReadDirState, +} + +enum ReadDirState { + /// Fill `buf` with `buf.len()` bytes starting from `next_read_offset`. + FillBuffer { + next_read_offset: wasi::Dircookie, + buf: Vec, + }, + ProcessEntry { + buf: Vec, + next_read_offset: Option, + offset: usize, + }, + /// There is no more data to get in [`Self::FillBuffer`]; keep returning + /// entries via ProcessEntry until `buf` is exhausted. + RunUntilExhaustion { + buf: Vec, + offset: usize, + }, + Done, } struct ReadDirInner { @@ -147,11 +162,8 @@ impl FileType { impl ReadDir { fn new(dir: File, root: PathBuf) -> ReadDir { ReadDir { - cookie: Some(0), - buf: vec![0; 128], - offset: 0, - cap: 0, inner: Arc::new(ReadDirInner { dir, root }), + state: ReadDirState::FillBuffer { next_read_offset: 0, buf: vec![0; 128] }, } } } @@ -162,78 +174,99 @@ impl fmt::Debug for ReadDir { } } +impl core::iter::FusedIterator for ReadDir {} + impl Iterator for ReadDir { type Item = io::Result; fn next(&mut self) -> Option> { - loop { - // If we've reached the capacity of our buffer then we need to read - // some more from the OS, otherwise we pick up at our old offset. - let offset = if self.offset == self.cap { - let cookie = self.cookie.take()?; - match self.inner.dir.fd.readdir(&mut self.buf, cookie) { - Ok(bytes) => self.cap = bytes, - Err(e) => return Some(Err(e)), - } - self.offset = 0; - self.cookie = Some(cookie); - - // If we didn't actually read anything, this is in theory the - // end of the directory. - if self.cap == 0 { - self.cookie = None; - return None; - } - - 0 - } else { - self.offset - }; - let data = &self.buf[offset..self.cap]; - - // If we're not able to read a directory entry then that means it - // must have been truncated at the end of the buffer, so reset our - // offset so we can go back and reread into the buffer, picking up - // where we last left off. - let dirent_size = mem::size_of::(); - if data.len() < dirent_size { - assert!(self.cookie.is_some()); - assert!(self.buf.len() >= dirent_size); - self.offset = self.cap; - continue; - } - let (dirent, data) = data.split_at(dirent_size); - let dirent = unsafe { ptr::read_unaligned(dirent.as_ptr() as *const wasi::Dirent) }; - - // If the file name was truncated, then we need to reinvoke - // `readdir` so we truncate our buffer to start over and reread this - // descriptor. Note that if our offset is 0 that means the file name - // is massive and we need a bigger buffer. - if data.len() < dirent.d_namlen as usize { - if offset == 0 { - let amt_to_add = self.buf.capacity(); - self.buf.extend(iter::repeat(0).take(amt_to_add)); + match &mut self.state { + ReadDirState::FillBuffer { next_read_offset, buf } => { + let result = self.inner.dir.fd.readdir(buf, *next_read_offset); + match result { + Ok(read_bytes) => { + if read_bytes < buf.len() { + buf.truncate(read_bytes); + self.state = + ReadDirState::RunUntilExhaustion { buf: mem::take(buf), offset: 0 }; + } else { + debug_assert_eq!(read_bytes, buf.len()); + self.state = ReadDirState::ProcessEntry { + buf: mem::take(buf), + offset: 0, + next_read_offset: Some(*next_read_offset), + }; + } + self.next() + } + Err(e) => { + self.state = ReadDirState::Done; + return Some(Err(e)); + } } - assert!(self.cookie.is_some()); - self.offset = self.cap; - continue; } - self.cookie = Some(dirent.d_next); - self.offset = offset + dirent_size + dirent.d_namlen as usize; + ReadDirState::ProcessEntry { buf, next_read_offset, offset } => { + let contents = &buf[*offset..]; + const DIRENT_SIZE: usize = size_of::(); + if contents.len() >= DIRENT_SIZE { + let (dirent, data) = contents.split_at(DIRENT_SIZE); + let dirent = + unsafe { ptr::read_unaligned(dirent.as_ptr() as *const wasi::Dirent) }; + // If the file name was truncated, then we need to reinvoke + // `readdir` so we truncate our buffer to start over and reread this + // descriptor. + if data.len() < dirent.d_namlen as usize { + if buf.len() < dirent.d_namlen as usize + DIRENT_SIZE { + buf.resize(dirent.d_namlen as usize + DIRENT_SIZE, 0); + } + if let Some(next_read_offset) = *next_read_offset { + self.state = + ReadDirState::FillBuffer { next_read_offset, buf: mem::take(buf) }; + } else { + self.state = ReadDirState::Done; + } + + return self.next(); + } + next_read_offset.as_mut().map(|cookie| { + *cookie = dirent.d_next; + }); + *offset = *offset + DIRENT_SIZE + dirent.d_namlen as usize; - let name = &data[..(dirent.d_namlen as usize)]; + let name = &data[..(dirent.d_namlen as usize)]; - // These names are skipped on all other platforms, so let's skip - // them here too - if name == b"." || name == b".." { - continue; + // These names are skipped on all other platforms, so let's skip + // them here too + if name == b"." || name == b".." { + return self.next(); + } + + return Some(Ok(DirEntry { + meta: dirent, + name: name.to_vec(), + inner: self.inner.clone(), + })); + } else if let Some(next_read_offset) = *next_read_offset { + self.state = ReadDirState::FillBuffer { next_read_offset, buf: mem::take(buf) }; + } else { + self.state = ReadDirState::Done; + } + self.next() } + ReadDirState::RunUntilExhaustion { buf, offset } => { + if *offset >= buf.len() { + self.state = ReadDirState::Done; + } else { + self.state = ReadDirState::ProcessEntry { + buf: mem::take(buf), + offset: *offset, + next_read_offset: None, + }; + } - return Some(Ok(DirEntry { - meta: dirent, - name: name.to_vec(), - inner: self.inner.clone(), - })); + self.next() + } + ReadDirState::Done => None, } } } @@ -482,6 +515,10 @@ impl File { self.fd.seek(pos) } + pub fn tell(&self) -> io::Result { + self.fd.tell() + } + pub fn duplicate(&self) -> io::Result { // https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-rationale.md#why-no-dup unsupported() @@ -496,9 +533,9 @@ impl File { pub fn set_times(&self, times: FileTimes) -> io::Result<()> { let to_timestamp = |time: Option| match time { Some(time) if let Some(ts) = time.to_wasi_timestamp() => Ok(ts), - Some(_) => Err(io::const_io_error!( + Some(_) => Err(io::const_error!( io::ErrorKind::InvalidInput, - "timestamp is too large to set as a file time" + "timestamp is too large to set as a file time", )), None => Ok(0), }; @@ -738,8 +775,7 @@ fn open_parent(p: &Path) -> io::Result<(ManuallyDrop, PathBuf)> { } let msg = format!( "failed to find a pre-opened file descriptor \ - through which {:?} could be opened", - p + through which {p:?} could be opened", ); return Err(io::Error::new(io::ErrorKind::Uncategorized, msg)); } @@ -752,7 +788,7 @@ fn open_parent(p: &Path) -> io::Result<(ManuallyDrop, PathBuf)> { } } - extern "C" { + unsafe extern "C" { pub fn __wasilibc_find_relpath( path: *const libc::c_char, abs_prefix: *mut *const libc::c_char, @@ -764,8 +800,7 @@ fn open_parent(p: &Path) -> io::Result<(ManuallyDrop, PathBuf)> { } pub fn osstr2str(f: &OsStr) -> io::Result<&str> { - f.to_str() - .ok_or_else(|| io::const_io_error!(io::ErrorKind::Uncategorized, "input must be utf-8")) + f.to_str().ok_or_else(|| io::const_error!(io::ErrorKind::Uncategorized, "input must be utf-8")) } pub fn copy(from: &Path, to: &Path) -> io::Result { @@ -811,7 +846,7 @@ fn remove_dir_all_recursive(parent: &WasiFd, path: &Path) -> io::Result<()> { for entry in ReadDir::new(fd, dummy_root) { let entry = entry?; let path = crate::str::from_utf8(&entry.name).map_err(|_| { - io::const_io_error!(io::ErrorKind::Uncategorized, "invalid utf-8 file name found") + io::const_error!(io::ErrorKind::Uncategorized, "invalid utf-8 file name found") })?; let result: io::Result<()> = try { diff --git a/std/src/sys/pal/windows/fs.rs b/std/src/sys/fs/windows.rs similarity index 89% rename from std/src/sys/pal/windows/fs.rs rename to std/src/sys/fs/windows.rs index 07e4f93a37956..362e64abf1ac3 100644 --- a/std/src/sys/pal/windows/fs.rs +++ b/std/src/sys/fs/windows.rs @@ -1,14 +1,17 @@ -use super::api::{self, WinError}; -use super::{IoResult, to_u16s}; +#![allow(nonstandard_style)] + +use crate::alloc::{Layout, alloc, dealloc}; use crate::borrow::Cow; use crate::ffi::{OsStr, OsString, c_void}; use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom}; -use crate::mem::{self, MaybeUninit}; +use crate::mem::{self, MaybeUninit, offset_of}; use crate::os::windows::io::{AsHandle, BorrowedHandle}; use crate::os::windows::prelude::*; use crate::path::{Path, PathBuf}; use crate::sync::Arc; use crate::sys::handle::Handle; +use crate::sys::pal::api::{self, WinError, set_file_information_by_handle}; +use crate::sys::pal::{IoResult, fill_utf16_buf, to_u16s, truncate_utf16_at_nul}; use crate::sys::path::maybe_verbatim; use crate::sys::time::SystemTime; use crate::sys::{Align8, c, cvt}; @@ -43,7 +46,7 @@ pub struct FileType { } pub struct ReadDir { - handle: FindNextFileHandle, + handle: Option, root: Arc, first: Option, } @@ -112,13 +115,13 @@ impl fmt::Debug for ReadDir { impl Iterator for ReadDir { type Item = io::Result; fn next(&mut self) -> Option> { - if self.handle.0 == c::INVALID_HANDLE_VALUE { + let Some(handle) = self.handle.as_ref() else { // This iterator was initialized with an `INVALID_HANDLE_VALUE` as its handle. // Simply return `None` because this is only the case when `FindFirstFileExW` in // the construction of this iterator returns `ERROR_FILE_NOT_FOUND` which means // no matchhing files can be found. return None; - } + }; if let Some(first) = self.first.take() { if let Some(e) = DirEntry::new(&self.root, &first) { return Some(Ok(e)); @@ -127,7 +130,7 @@ impl Iterator for ReadDir { unsafe { let mut wfd = mem::zeroed(); loop { - if c::FindNextFileW(self.handle.0, &mut wfd) == 0 { + if c::FindNextFileW(handle.0, &mut wfd) == 0 { match api::get_last_error() { WinError::NO_MORE_FILES => return None, WinError { code } => { @@ -166,7 +169,7 @@ impl DirEntry { } pub fn file_name(&self) -> OsString { - let filename = super::truncate_utf16_at_nul(&self.data.cFileName); + let filename = truncate_utf16_at_nul(&self.data.cFileName); OsString::from_wide(filename) } @@ -295,6 +298,10 @@ impl OpenOptions { impl File { pub fn open(path: &Path, opts: &OpenOptions) -> io::Result { let path = maybe_verbatim(path)?; + Self::open_native(&path, opts) + } + + fn open_native(path: &[u16], opts: &OpenOptions) -> io::Result { let creation = opts.get_creation_mode()?; let handle = unsafe { c::CreateFileW( @@ -314,22 +321,17 @@ impl File { && creation == c::OPEN_ALWAYS && api::get_last_error() == WinError::ALREADY_EXISTS { - unsafe { - // This originally used `FileAllocationInfo` instead of - // `FileEndOfFileInfo` but that wasn't supported by WINE. - // It's arguable which fits the semantics of `OpenOptions` - // better so let's just use the more widely supported method. - let eof = c::FILE_END_OF_FILE_INFO { EndOfFile: 0 }; - let result = c::SetFileInformationByHandle( - handle.as_raw_handle(), - c::FileEndOfFileInfo, - (&raw const eof).cast::(), - mem::size_of::() as u32, - ); - if result == 0 { - return Err(io::Error::last_os_error()); - } - } + // This first tries `FileAllocationInfo` but falls back to + // `FileEndOfFileInfo` in order to support WINE. + // If WINE gains support for FileAllocationInfo, we should + // remove the fallback. + let alloc = c::FILE_ALLOCATION_INFO { AllocationSize: 0 }; + set_file_information_by_handle(handle.as_raw_handle(), &alloc) + .or_else(|_| { + let eof = c::FILE_END_OF_FILE_INFO { EndOfFile: 0 }; + set_file_information_by_handle(handle.as_raw_handle(), &eof) + }) + .io_result()?; } Ok(File { handle: Handle::from_inner(handle) }) } else { @@ -477,7 +479,7 @@ impl File { self.handle.as_raw_handle(), c::FileAttributeTagInfo, (&raw mut attr_tag).cast(), - mem::size_of::().try_into().unwrap(), + size_of::().try_into().unwrap(), ))?; if attr_tag.FileAttributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0 { reparse_tag = attr_tag.ReparseTag; @@ -504,7 +506,7 @@ impl File { pub fn file_attr(&self) -> io::Result { unsafe { let mut info: c::FILE_BASIC_INFO = mem::zeroed(); - let size = mem::size_of_val(&info); + let size = size_of_val(&info); cvt(c::GetFileInformationByHandleEx( self.handle.as_raw_handle(), c::FileBasicInfo, @@ -536,7 +538,7 @@ impl File { file_index: None, }; let mut info: c::FILE_STANDARD_INFO = mem::zeroed(); - let size = mem::size_of_val(&info); + let size = size_of_val(&info); cvt(c::GetFileInformationByHandleEx( self.handle.as_raw_handle(), c::FileStandardInfo, @@ -551,7 +553,7 @@ impl File { self.handle.as_raw_handle(), c::FileAttributeTagInfo, (&raw mut attr_tag).cast(), - mem::size_of::().try_into().unwrap(), + size_of::().try_into().unwrap(), ))?; if attr_tag.FileAttributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0 { attr.reparse_tag = attr_tag.ReparseTag; @@ -617,6 +619,10 @@ impl File { Ok(newpos as u64) } + pub fn tell(&self) -> io::Result { + self.seek(SeekFrom::Current(0)) + } + pub fn duplicate(&self) -> io::Result { Ok(Self { handle: self.handle.try_clone()? }) } @@ -645,7 +651,7 @@ impl File { ptr::null_mut(), ) })?; - const _: () = assert!(core::mem::align_of::() <= 8); + const _: () = assert!(align_of::() <= 8); Ok((bytes, space.0.as_mut_ptr().cast::())) } } @@ -677,7 +683,7 @@ impl File { ) } _ => { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::Uncategorized, "Unsupported reparse point type", )); @@ -691,7 +697,7 @@ impl File { // Turn `\??\` into `\\?\` (a verbatim path). subst[1] = b'\\' as u16; // Attempt to convert to a more user-friendly path. - let user = super::args::from_wide_to_user_path( + let user = crate::sys::args::from_wide_to_user_path( subst.iter().copied().chain([0]).collect(), )?; Ok(PathBuf::from(OsString::from_wide(user.strip_suffix(&[0]).unwrap_or(&user)))) @@ -718,9 +724,9 @@ impl File { || times.modified.map_or(false, is_zero) || times.created.map_or(false, is_zero) { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, - "Cannot set file timestamp to 0", + "cannot set file timestamp to 0", )); } let is_max = |t: c::FILETIME| t.dwLowDateTime == u32::MAX && t.dwHighDateTime == u32::MAX; @@ -728,9 +734,9 @@ impl File { || times.modified.map_or(false, is_max) || times.created.map_or(false, is_max) { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, - "Cannot set file timestamp to 0xFFFF_FFFF_FFFF_FFFF", + "cannot set file timestamp to 0xFFFF_FFFF_FFFF_FFFF", )); } cvt(unsafe { @@ -749,7 +755,7 @@ impl File { fn basic_info(&self) -> io::Result { unsafe { let mut info: c::FILE_BASIC_INFO = mem::zeroed(); - let size = mem::size_of_val(&info); + let size = size_of_val(&info); cvt(c::GetFileInformationByHandleEx( self.handle.as_raw_handle(), c::FileBasicInfo, @@ -798,7 +804,7 @@ impl File { /// will prevent anyone from opening a new handle to the file. #[allow(unused)] fn win32_delete(&self) -> Result<(), WinError> { - let info = c::FILE_DISPOSITION_INFO { DeleteFile: c::TRUE as _ }; + let info = c::FILE_DISPOSITION_INFO { DeleteFile: true }; api::set_file_information_by_handle(self.handle.as_raw_handle(), &info) } @@ -882,7 +888,6 @@ impl<'a> DirBuffIter<'a> { impl<'a> Iterator for DirBuffIter<'a> { type Item = (Cow<'a, [u16]>, bool); fn next(&mut self) -> Option { - use crate::mem::size_of; let buffer = &self.buffer?[self.cursor..]; // Get the name and next entry from the buffer. @@ -1180,7 +1185,7 @@ pub fn readdir(p: &Path) -> io::Result { if find_handle != c::INVALID_HANDLE_VALUE { Ok(ReadDir { - handle: FindNextFileHandle(find_handle), + handle: Some(FindNextFileHandle(find_handle)), root: Arc::new(root), first: Some(wfd), }) @@ -1198,11 +1203,7 @@ pub fn readdir(p: &Path) -> io::Result { // See issue #120040: https://github.com/rust-lang/rust/issues/120040. let last_error = api::get_last_error(); if last_error == WinError::FILE_NOT_FOUND { - return Ok(ReadDir { - handle: FindNextFileHandle(find_handle), - root: Arc::new(root), - first: None, - }); + return Ok(ReadDir { handle: None, root: Arc::new(root), first: None }); } // Just return the error constructed from the raw OS error if the above is not the case. @@ -1216,14 +1217,98 @@ pub fn readdir(p: &Path) -> io::Result { pub fn unlink(p: &Path) -> io::Result<()> { let p_u16s = maybe_verbatim(p)?; - cvt(unsafe { c::DeleteFileW(p_u16s.as_ptr()) })?; - Ok(()) + if unsafe { c::DeleteFileW(p_u16s.as_ptr()) } == 0 { + let err = api::get_last_error(); + // if `DeleteFileW` fails with ERROR_ACCESS_DENIED then try to remove + // the file while ignoring the readonly attribute. + // This is accomplished by calling the `posix_delete` function on an open file handle. + if err == WinError::ACCESS_DENIED { + let mut opts = OpenOptions::new(); + opts.access_mode(c::DELETE); + opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT); + if let Ok(f) = File::open_native(&p_u16s, &opts) { + if f.posix_delete().is_ok() { + return Ok(()); + } + } + } + // return the original error if any of the above fails. + Err(io::Error::from_raw_os_error(err.code as i32)) + } else { + Ok(()) + } } pub fn rename(old: &Path, new: &Path) -> io::Result<()> { let old = maybe_verbatim(old)?; let new = maybe_verbatim(new)?; - cvt(unsafe { c::MoveFileExW(old.as_ptr(), new.as_ptr(), c::MOVEFILE_REPLACE_EXISTING) })?; + + if unsafe { c::MoveFileExW(old.as_ptr(), new.as_ptr(), c::MOVEFILE_REPLACE_EXISTING) } == 0 { + let err = api::get_last_error(); + // if `MoveFileExW` fails with ERROR_ACCESS_DENIED then try to move + // the file while ignoring the readonly attribute. + // This is accomplished by calling `SetFileInformationByHandle` with `FileRenameInfoEx`. + if err == WinError::ACCESS_DENIED { + let mut opts = OpenOptions::new(); + opts.access_mode(c::DELETE); + opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT | c::FILE_FLAG_BACKUP_SEMANTICS); + let Ok(f) = File::open_native(&old, &opts) else { return Err(err).io_result() }; + + // Calculate the layout of the `FILE_RENAME_INFO` we pass to `SetFileInformation` + // This is a dynamically sized struct so we need to get the position of the last field to calculate the actual size. + let Ok(new_len_without_nul_in_bytes): Result = ((new.len() - 1) * 2).try_into() + else { + return Err(err).io_result(); + }; + let offset: u32 = offset_of!(c::FILE_RENAME_INFO, FileName).try_into().unwrap(); + let struct_size = offset + new_len_without_nul_in_bytes + 2; + let layout = + Layout::from_size_align(struct_size as usize, align_of::()) + .unwrap(); + + // SAFETY: We allocate enough memory for a full FILE_RENAME_INFO struct and a filename. + let file_rename_info; + unsafe { + file_rename_info = alloc(layout).cast::(); + if file_rename_info.is_null() { + return Err(io::ErrorKind::OutOfMemory.into()); + } + + (&raw mut (*file_rename_info).Anonymous).write(c::FILE_RENAME_INFO_0 { + Flags: c::FILE_RENAME_FLAG_REPLACE_IF_EXISTS + | c::FILE_RENAME_FLAG_POSIX_SEMANTICS, + }); + + (&raw mut (*file_rename_info).RootDirectory).write(ptr::null_mut()); + // Don't include the NULL in the size + (&raw mut (*file_rename_info).FileNameLength).write(new_len_without_nul_in_bytes); + + new.as_ptr().copy_to_nonoverlapping( + (&raw mut (*file_rename_info).FileName).cast::(), + new.len(), + ); + } + + let result = unsafe { + c::SetFileInformationByHandle( + f.as_raw_handle(), + c::FileRenameInfoEx, + file_rename_info.cast::(), + struct_size, + ) + }; + unsafe { dealloc(file_rename_info.cast::(), layout) }; + if result == 0 { + if api::get_last_error() == WinError::DIR_NOT_EMPTY { + return Err(WinError::DIR_NOT_EMPTY).io_result(); + } else { + return Err(err).io_result(); + } + } + } else { + return Err(err).io_result(); + } + } Ok(()) } @@ -1305,10 +1390,7 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> { #[cfg(target_vendor = "uwp")] pub fn link(_original: &Path, _link: &Path) -> io::Result<()> { - return Err(io::const_io_error!( - io::ErrorKind::Unsupported, - "hard link are not supported on UWP", - )); + return Err(io::const_error!(io::ErrorKind::Unsupported, "hard link are not supported on UWP")); } pub fn stat(path: &Path) -> io::Result { @@ -1412,7 +1494,7 @@ pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> { } fn get_path(f: &File) -> io::Result { - super::fill_utf16_buf( + fill_utf16_buf( |buf, sz| unsafe { c::GetFinalPathNameByHandleW(f.handle.as_raw_handle(), buf, sz, c::VOLUME_NAME_DOS) }, @@ -1495,7 +1577,7 @@ pub fn junction_point(original: &Path, link: &Path) -> io::Result<()> { let bytes = unsafe { OsStr::from_encoded_bytes_unchecked(&abs_path[2..]) }; r"\??\UNC\".encode_utf16().chain(bytes.encode_wide()).collect() } else { - return Err(io::const_io_error!(io::ErrorKind::InvalidInput, "path is not valid")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "path is not valid")); } }; // Defined inline so we don't have to mess about with variable length buffer. @@ -1512,10 +1594,7 @@ pub fn junction_point(original: &Path, link: &Path) -> io::Result<()> { } let data_len = 12 + (abs_path.len() * 2); if data_len > u16::MAX as usize { - return Err(io::const_io_error!( - io::ErrorKind::InvalidInput, - "`original` path is too long" - )); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "`original` path is too long")); } let data_len = data_len as u16; let mut header = MountPointBuffer { diff --git a/std/src/sys/pal/windows/fs/remove_dir_all.rs b/std/src/sys/fs/windows/remove_dir_all.rs similarity index 99% rename from std/src/sys/pal/windows/fs/remove_dir_all.rs rename to std/src/sys/fs/windows/remove_dir_all.rs index 9416049da78f8..f51eced84164f 100644 --- a/std/src/sys/pal/windows/fs/remove_dir_all.rs +++ b/std/src/sys/fs/windows/remove_dir_all.rs @@ -33,7 +33,7 @@ use core::sync::atomic::{AtomicU32, Ordering}; use super::{AsRawHandle, DirBuff, File, FromRawHandle}; use crate::sys::c; -use crate::sys::pal::windows::api::WinError; +use crate::sys::pal::api::WinError; use crate::thread; // The maximum number of times to spin when waiting for deletes to complete. diff --git a/std/src/sys/pal/solid/io.rs b/std/src/sys/io/io_slice/iovec.rs similarity index 90% rename from std/src/sys/pal/solid/io.rs rename to std/src/sys/io/io_slice/iovec.rs index 9ef4b7049b690..072191315f7c5 100644 --- a/std/src/sys/pal/solid/io.rs +++ b/std/src/sys/io/io_slice/iovec.rs @@ -1,8 +1,13 @@ -use libc::c_void; +#[cfg(target_os = "hermit")] +use hermit_abi::iovec; +#[cfg(target_family = "unix")] +use libc::iovec; -use super::abi::sockets::iovec; +use crate::ffi::c_void; use crate::marker::PhantomData; use crate::slice; +#[cfg(target_os = "solid_asp3")] +use crate::sys::pal::abi::sockets::iovec; #[derive(Copy, Clone)] #[repr(transparent)] @@ -80,7 +85,3 @@ impl<'a> IoSliceMut<'a> { unsafe { slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len) } } } - -pub fn is_terminal(_: &T) -> bool { - false -} diff --git a/std/src/sys/pal/unsupported/io.rs b/std/src/sys/io/io_slice/unsupported.rs similarity index 94% rename from std/src/sys/pal/unsupported/io.rs rename to std/src/sys/io/io_slice/unsupported.rs index 604735d32d51a..1572cac6cd771 100644 --- a/std/src/sys/pal/unsupported/io.rs +++ b/std/src/sys/io/io_slice/unsupported.rs @@ -50,7 +50,3 @@ impl<'a> IoSliceMut<'a> { self.0 } } - -pub fn is_terminal(_: &T) -> bool { - false -} diff --git a/std/src/sys/pal/wasi/io.rs b/std/src/sys/io/io_slice/wasi.rs similarity index 90% rename from std/src/sys/pal/wasi/io.rs rename to std/src/sys/io/io_slice/wasi.rs index 57f81bc6257cd..87acbbd924e56 100644 --- a/std/src/sys/pal/wasi/io.rs +++ b/std/src/sys/io/io_slice/wasi.rs @@ -1,7 +1,4 @@ -#![forbid(unsafe_op_in_unsafe_fn)] - use crate::marker::PhantomData; -use crate::os::fd::{AsFd, AsRawFd}; use crate::slice; #[derive(Copy, Clone)] @@ -77,8 +74,3 @@ impl<'a> IoSliceMut<'a> { unsafe { slice::from_raw_parts_mut(self.vec.buf as *mut u8, self.vec.buf_len) } } } - -pub fn is_terminal(fd: &impl AsFd) -> bool { - let fd = fd.as_fd(); - unsafe { libc::isatty(fd.as_raw_fd()) != 0 } -} diff --git a/std/src/sys/pal/unix/io.rs b/std/src/sys/io/io_slice/windows.rs similarity index 52% rename from std/src/sys/pal/unix/io.rs rename to std/src/sys/io/io_slice/windows.rs index 0d5a152dc0dc6..c3d8ec87c19e3 100644 --- a/std/src/sys/pal/unix/io.rs +++ b/std/src/sys/io/io_slice/windows.rs @@ -1,87 +1,82 @@ -use libc::{c_void, iovec}; - use crate::marker::PhantomData; -use crate::os::fd::{AsFd, AsRawFd}; use crate::slice; +use crate::sys::c; #[derive(Copy, Clone)] #[repr(transparent)] pub struct IoSlice<'a> { - vec: iovec, + vec: c::WSABUF, _p: PhantomData<&'a [u8]>, } impl<'a> IoSlice<'a> { #[inline] pub fn new(buf: &'a [u8]) -> IoSlice<'a> { + assert!(buf.len() <= u32::MAX as usize); IoSlice { - vec: iovec { iov_base: buf.as_ptr() as *mut u8 as *mut c_void, iov_len: buf.len() }, + vec: c::WSABUF { len: buf.len() as u32, buf: buf.as_ptr() as *mut u8 }, _p: PhantomData, } } #[inline] pub fn advance(&mut self, n: usize) { - if self.vec.iov_len < n { + if (self.vec.len as usize) < n { panic!("advancing IoSlice beyond its length"); } unsafe { - self.vec.iov_len -= n; - self.vec.iov_base = self.vec.iov_base.add(n); + self.vec.len -= n as u32; + self.vec.buf = self.vec.buf.add(n); } } #[inline] pub const fn as_slice(&self) -> &'a [u8] { - unsafe { slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len) } + unsafe { slice::from_raw_parts(self.vec.buf, self.vec.len as usize) } } } #[repr(transparent)] pub struct IoSliceMut<'a> { - vec: iovec, + vec: c::WSABUF, _p: PhantomData<&'a mut [u8]>, } impl<'a> IoSliceMut<'a> { #[inline] pub fn new(buf: &'a mut [u8]) -> IoSliceMut<'a> { + assert!(buf.len() <= u32::MAX as usize); IoSliceMut { - vec: iovec { iov_base: buf.as_mut_ptr() as *mut c_void, iov_len: buf.len() }, + vec: c::WSABUF { len: buf.len() as u32, buf: buf.as_mut_ptr() }, _p: PhantomData, } } #[inline] pub fn advance(&mut self, n: usize) { - if self.vec.iov_len < n { + if (self.vec.len as usize) < n { panic!("advancing IoSliceMut beyond its length"); } unsafe { - self.vec.iov_len -= n; - self.vec.iov_base = self.vec.iov_base.add(n); + self.vec.len -= n as u32; + self.vec.buf = self.vec.buf.add(n); } } #[inline] pub fn as_slice(&self) -> &[u8] { - unsafe { slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len) } + unsafe { slice::from_raw_parts(self.vec.buf, self.vec.len as usize) } } #[inline] pub const fn into_slice(self) -> &'a mut [u8] { - unsafe { slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len) } + unsafe { slice::from_raw_parts_mut(self.vec.buf, self.vec.len as usize) } } #[inline] pub fn as_mut_slice(&mut self) -> &mut [u8] { - unsafe { slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len) } + unsafe { slice::from_raw_parts_mut(self.vec.buf, self.vec.len as usize) } } } - -pub fn is_terminal(fd: &impl AsFd) -> bool { - let fd = fd.as_fd(); - unsafe { libc::isatty(fd.as_raw_fd()) != 0 } -} diff --git a/std/src/sys/io/is_terminal/hermit.rs b/std/src/sys/io/is_terminal/hermit.rs new file mode 100644 index 0000000000000..61bdb6f0a5440 --- /dev/null +++ b/std/src/sys/io/is_terminal/hermit.rs @@ -0,0 +1,6 @@ +use crate::os::fd::{AsFd, AsRawFd}; + +pub fn is_terminal(fd: &impl AsFd) -> bool { + let fd = fd.as_fd(); + hermit_abi::isatty(fd.as_raw_fd()) +} diff --git a/std/src/sys/io/is_terminal/isatty.rs b/std/src/sys/io/is_terminal/isatty.rs new file mode 100644 index 0000000000000..6e0b46211b907 --- /dev/null +++ b/std/src/sys/io/is_terminal/isatty.rs @@ -0,0 +1,6 @@ +use crate::os::fd::{AsFd, AsRawFd}; + +pub fn is_terminal(fd: &impl AsFd) -> bool { + let fd = fd.as_fd(); + unsafe { libc::isatty(fd.as_raw_fd()) != 0 } +} diff --git a/std/src/sys/io/is_terminal/unsupported.rs b/std/src/sys/io/is_terminal/unsupported.rs new file mode 100644 index 0000000000000..cee4add32fbfc --- /dev/null +++ b/std/src/sys/io/is_terminal/unsupported.rs @@ -0,0 +1,3 @@ +pub fn is_terminal(_: &T) -> bool { + false +} diff --git a/std/src/sys/pal/windows/io.rs b/std/src/sys/io/is_terminal/windows.rs similarity index 54% rename from std/src/sys/pal/windows/io.rs rename to std/src/sys/io/is_terminal/windows.rs index f2865d2ffc168..b0c718d71f9f3 100644 --- a/std/src/sys/pal/windows/io.rs +++ b/std/src/sys/io/is_terminal/windows.rs @@ -1,90 +1,7 @@ -use core::ffi::c_void; - -use crate::marker::PhantomData; -use crate::mem::size_of; +use crate::ffi::c_void; use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle}; -use crate::slice; use crate::sys::c; -#[derive(Copy, Clone)] -#[repr(transparent)] -pub struct IoSlice<'a> { - vec: c::WSABUF, - _p: PhantomData<&'a [u8]>, -} - -impl<'a> IoSlice<'a> { - #[inline] - pub fn new(buf: &'a [u8]) -> IoSlice<'a> { - assert!(buf.len() <= u32::MAX as usize); - IoSlice { - vec: c::WSABUF { len: buf.len() as u32, buf: buf.as_ptr() as *mut u8 }, - _p: PhantomData, - } - } - - #[inline] - pub fn advance(&mut self, n: usize) { - if (self.vec.len as usize) < n { - panic!("advancing IoSlice beyond its length"); - } - - unsafe { - self.vec.len -= n as u32; - self.vec.buf = self.vec.buf.add(n); - } - } - - #[inline] - pub const fn as_slice(&self) -> &'a [u8] { - unsafe { slice::from_raw_parts(self.vec.buf, self.vec.len as usize) } - } -} - -#[repr(transparent)] -pub struct IoSliceMut<'a> { - vec: c::WSABUF, - _p: PhantomData<&'a mut [u8]>, -} - -impl<'a> IoSliceMut<'a> { - #[inline] - pub fn new(buf: &'a mut [u8]) -> IoSliceMut<'a> { - assert!(buf.len() <= u32::MAX as usize); - IoSliceMut { - vec: c::WSABUF { len: buf.len() as u32, buf: buf.as_mut_ptr() }, - _p: PhantomData, - } - } - - #[inline] - pub fn advance(&mut self, n: usize) { - if (self.vec.len as usize) < n { - panic!("advancing IoSliceMut beyond its length"); - } - - unsafe { - self.vec.len -= n as u32; - self.vec.buf = self.vec.buf.add(n); - } - } - - #[inline] - pub fn as_slice(&self) -> &[u8] { - unsafe { slice::from_raw_parts(self.vec.buf, self.vec.len as usize) } - } - - #[inline] - pub const fn into_slice(self) -> &'a mut [u8] { - unsafe { slice::from_raw_parts_mut(self.vec.buf, self.vec.len as usize) } - } - - #[inline] - pub fn as_mut_slice(&mut self) -> &mut [u8] { - unsafe { slice::from_raw_parts_mut(self.vec.buf, self.vec.len as usize) } - } -} - pub fn is_terminal(h: &impl AsHandle) -> bool { handle_is_console(h.as_handle()) } diff --git a/std/src/sys/io/mod.rs b/std/src/sys/io/mod.rs new file mode 100644 index 0000000000000..e00b479109f39 --- /dev/null +++ b/std/src/sys/io/mod.rs @@ -0,0 +1,44 @@ +#![forbid(unsafe_op_in_unsafe_fn)] + +mod io_slice { + cfg_if::cfg_if! { + if #[cfg(any(target_family = "unix", target_os = "hermit", target_os = "solid_asp3"))] { + mod iovec; + pub use iovec::*; + } else if #[cfg(target_os = "windows")] { + mod windows; + pub use windows::*; + } else if #[cfg(target_os = "wasi")] { + mod wasi; + pub use wasi::*; + } else { + mod unsupported; + pub use unsupported::*; + } + } +} + +mod is_terminal { + cfg_if::cfg_if! { + if #[cfg(any(target_family = "unix", target_os = "wasi"))] { + mod isatty; + pub use isatty::*; + } else if #[cfg(target_os = "windows")] { + mod windows; + pub use windows::*; + } else if #[cfg(target_os = "hermit")] { + mod hermit; + pub use hermit::*; + } else { + mod unsupported; + pub use unsupported::*; + } + } +} + +pub use io_slice::{IoSlice, IoSliceMut}; +pub use is_terminal::is_terminal; + +// Bare metal platforms usually have very small amounts of RAM +// (in the order of hundreds of KB) +pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { 8 * 1024 }; diff --git a/std/src/sys/mod.rs b/std/src/sys/mod.rs index f17dd47decedc..09677b9d64282 100644 --- a/std/src/sys/mod.rs +++ b/std/src/sys/mod.rs @@ -12,9 +12,13 @@ pub mod anonymous_pipe; pub mod backtrace; pub mod cmath; pub mod exit_guard; +pub mod fs; +pub mod io; +pub mod net; pub mod os_str; pub mod path; pub mod random; +pub mod stdio; pub mod sync; pub mod thread_local; diff --git a/std/src/sys/pal/sgx/net.rs b/std/src/sys/net/connection/sgx.rs similarity index 94% rename from std/src/sys/pal/sgx/net.rs rename to std/src/sys/net/connection/sgx.rs index c966886d16344..242df10bc3270 100644 --- a/std/src/sys/pal/sgx/net.rs +++ b/std/src/sys/net/connection/sgx.rs @@ -1,7 +1,7 @@ -use super::abi::usercalls; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, ToSocketAddrs}; use crate::sync::Arc; +use crate::sys::abi::usercalls; use crate::sys::fd::FileDesc; use crate::sys::{AsInner, FromInner, IntoInner, TryIntoInner, sgx_ineffective, unsupported}; use crate::time::Duration; @@ -499,38 +499,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { LookupHost::new(format!("{host}:{port}")) } } - -#[allow(bad_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/std/src/sys_common/net.rs b/std/src/sys/net/connection/socket.rs similarity index 81% rename from std/src/sys_common/net.rs rename to std/src/sys/net/connection/socket.rs index 5a0ad90758101..e154cf039cad1 100644 --- a/std/src/sys_common/net.rs +++ b/std/src/sys/net/connection/socket.rs @@ -3,13 +3,33 @@ mod tests; use crate::ffi::{c_int, c_void}; use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}; -use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; +use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, SocketAddrV4, SocketAddrV6}; use crate::sys::common::small_c_string::run_with_cstr; -use crate::sys::net::{Socket, cvt, cvt_gai, cvt_r, init, netc as c, wrlen_t}; -use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::sys_common::{AsInner, FromInner}; use crate::time::Duration; use crate::{cmp, fmt, mem, ptr}; +cfg_if::cfg_if! { + if #[cfg(target_os = "hermit")] { + mod hermit; + pub use hermit::*; + } else if #[cfg(target_os = "solid_asp3")] { + mod solid; + pub use solid::*; + } else if #[cfg(target_family = "unix")] { + mod unix; + pub use unix::*; + } else if #[cfg(all(target_os = "wasi", target_env = "p2"))] { + mod wasip2; + pub use wasip2::*; + } else if #[cfg(target_os = "windows")] { + mod windows; + pub use windows::*; + } +} + +use netc as c; + cfg_if::cfg_if! { if #[cfg(any( target_os = "dragonfly", @@ -24,11 +44,11 @@ cfg_if::cfg_if! { target_os = "nuttx", target_vendor = "apple", ))] { - use crate::sys::net::netc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP; - use crate::sys::net::netc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP; + use c::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP; + use c::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP; } else { - use crate::sys::net::netc::IPV6_ADD_MEMBERSHIP; - use crate::sys::net::netc::IPV6_DROP_MEMBERSHIP; + use c::IPV6_ADD_MEMBERSHIP; + use c::IPV6_DROP_MEMBERSHIP; } } @@ -59,6 +79,111 @@ cfg_if::cfg_if! { } } +//////////////////////////////////////////////////////////////////////////////// +// address conversions +//////////////////////////////////////////////////////////////////////////////// + +fn ip_v4_addr_to_c(addr: &Ipv4Addr) -> c::in_addr { + // `s_addr` is stored as BE on all machines and the array is in BE order. + // So the native endian conversion method is used so that it's never swapped. + c::in_addr { s_addr: u32::from_ne_bytes(addr.octets()) } +} + +fn ip_v6_addr_to_c(addr: &Ipv6Addr) -> c::in6_addr { + c::in6_addr { s6_addr: addr.octets() } +} + +fn ip_v4_addr_from_c(addr: c::in_addr) -> Ipv4Addr { + Ipv4Addr::from(addr.s_addr.to_ne_bytes()) +} + +fn ip_v6_addr_from_c(addr: c::in6_addr) -> Ipv6Addr { + Ipv6Addr::from(addr.s6_addr) +} + +fn socket_addr_v4_to_c(addr: &SocketAddrV4) -> c::sockaddr_in { + c::sockaddr_in { + sin_family: c::AF_INET as c::sa_family_t, + sin_port: addr.port().to_be(), + sin_addr: ip_v4_addr_to_c(addr.ip()), + ..unsafe { mem::zeroed() } + } +} + +fn socket_addr_v6_to_c(addr: &SocketAddrV6) -> c::sockaddr_in6 { + c::sockaddr_in6 { + sin6_family: c::AF_INET6 as c::sa_family_t, + sin6_port: addr.port().to_be(), + sin6_addr: ip_v6_addr_to_c(addr.ip()), + sin6_flowinfo: addr.flowinfo(), + sin6_scope_id: addr.scope_id(), + ..unsafe { mem::zeroed() } + } +} + +fn socket_addr_v4_from_c(addr: c::sockaddr_in) -> SocketAddrV4 { + SocketAddrV4::new(ip_v4_addr_from_c(addr.sin_addr), u16::from_be(addr.sin_port)) +} + +fn socket_addr_v6_from_c(addr: c::sockaddr_in6) -> SocketAddrV6 { + SocketAddrV6::new( + ip_v6_addr_from_c(addr.sin6_addr), + u16::from_be(addr.sin6_port), + addr.sin6_flowinfo, + addr.sin6_scope_id, + ) +} + +/// A type with the same memory layout as `c::sockaddr`. Used in converting Rust level +/// SocketAddr* types into their system representation. The benefit of this specific +/// type over using `c::sockaddr_storage` is that this type is exactly as large as it +/// needs to be and not a lot larger. And it can be initialized more cleanly from Rust. +#[repr(C)] +union SocketAddrCRepr { + v4: c::sockaddr_in, + v6: c::sockaddr_in6, +} + +impl SocketAddrCRepr { + fn as_ptr(&self) -> *const c::sockaddr { + self as *const _ as *const c::sockaddr + } +} + +fn socket_addr_to_c(addr: &SocketAddr) -> (SocketAddrCRepr, c::socklen_t) { + match addr { + SocketAddr::V4(a) => { + let sockaddr = SocketAddrCRepr { v4: socket_addr_v4_to_c(a) }; + (sockaddr, size_of::() as c::socklen_t) + } + SocketAddr::V6(a) => { + let sockaddr = SocketAddrCRepr { v6: socket_addr_v6_to_c(a) }; + (sockaddr, size_of::() as c::socklen_t) + } + } +} + +unsafe fn socket_addr_from_c( + storage: *const c::sockaddr_storage, + len: usize, +) -> io::Result { + match (*storage).ss_family as c_int { + c::AF_INET => { + assert!(len >= size_of::()); + Ok(SocketAddr::V4(socket_addr_v4_from_c(unsafe { + *(storage as *const _ as *const c::sockaddr_in) + }))) + } + c::AF_INET6 => { + assert!(len >= size_of::()); + Ok(SocketAddr::V6(socket_addr_v6_from_c(unsafe { + *(storage as *const _ as *const c::sockaddr_in6) + }))) + } + _ => Err(io::const_error!(ErrorKind::InvalidInput, "invalid argument")), + } +} + //////////////////////////////////////////////////////////////////////////////// // sockaddr and misc bindings //////////////////////////////////////////////////////////////////////////////// @@ -75,7 +200,7 @@ pub fn setsockopt( level, option_name, (&raw const option_value) as *const _, - mem::size_of::() as c::socklen_t, + size_of::() as c::socklen_t, ))?; Ok(()) } @@ -84,7 +209,7 @@ pub fn setsockopt( pub fn getsockopt(sock: &Socket, level: c_int, option_name: c_int) -> io::Result { unsafe { let mut option_value: T = mem::zeroed(); - let mut option_len = mem::size_of::() as c::socklen_t; + let mut option_len = size_of::() as c::socklen_t; cvt(c::getsockopt( sock.as_raw(), level, @@ -102,27 +227,9 @@ where { unsafe { let mut storage: c::sockaddr_storage = mem::zeroed(); - let mut len = mem::size_of_val(&storage) as c::socklen_t; + let mut len = size_of_val(&storage) as c::socklen_t; cvt(f((&raw mut storage) as *mut _, &mut len))?; - sockaddr_to_addr(&storage, len as usize) - } -} - -pub fn sockaddr_to_addr(storage: &c::sockaddr_storage, len: usize) -> io::Result { - match storage.ss_family as c_int { - c::AF_INET => { - assert!(len >= mem::size_of::()); - Ok(SocketAddr::V4(FromInner::from_inner(unsafe { - *(storage as *const _ as *const c::sockaddr_in) - }))) - } - c::AF_INET6 => { - assert!(len >= mem::size_of::()); - Ok(SocketAddr::V6(FromInner::from_inner(unsafe { - *(storage as *const _ as *const c::sockaddr_in6) - }))) - } - _ => Err(io::const_io_error!(ErrorKind::InvalidInput, "invalid argument")), + socket_addr_from_c(&storage, len as usize) } } @@ -159,7 +266,7 @@ impl Iterator for LookupHost { unsafe { let cur = self.cur.as_ref()?; self.cur = cur.ai_next; - match sockaddr_to_addr(mem::transmute(cur.ai_addr), cur.ai_addrlen as usize) { + match socket_addr_from_c(cur.ai_addr.cast(), cur.ai_addrlen as usize) { Ok(addr) => return Some(addr), Err(_) => continue, } @@ -185,7 +292,7 @@ impl TryFrom<&str> for LookupHost { ($e:expr, $msg:expr) => { match $e { Some(r) => r, - None => return Err(io::const_io_error!(io::ErrorKind::InvalidInput, $msg)), + None => return Err(io::const_error!(io::ErrorKind::InvalidInput, $msg)), } }; } @@ -412,7 +519,7 @@ impl TcpListener { setsockopt(&sock, c::SOL_SOCKET, c::SO_REUSEADDR, 1 as c_int)?; // Bind our new socket - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(unsafe { c::bind(sock.as_raw(), addr.as_ptr(), len as _) })?; cfg_if::cfg_if! { @@ -450,10 +557,13 @@ impl TcpListener { } pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> { - let mut storage: c::sockaddr_storage = unsafe { mem::zeroed() }; - let mut len = mem::size_of_val(&storage) as c::socklen_t; - let sock = self.inner.accept((&raw mut storage) as *mut _, &mut len)?; - let addr = sockaddr_to_addr(&storage, len as usize)?; + // The `accept` function will fill in the storage with the address, + // so we don't need to zero it here. + // reference: https://linux.die.net/man/2/accept4 + let mut storage: mem::MaybeUninit = mem::MaybeUninit::uninit(); + let mut len = size_of_val(&storage) as c::socklen_t; + let sock = self.inner.accept(storage.as_mut_ptr() as *mut _, &mut len)?; + let addr = unsafe { socket_addr_from_c(storage.as_ptr(), len as usize)? }; Ok((TcpStream { inner: sock }, addr)) } @@ -522,7 +632,7 @@ impl UdpSocket { init(); let sock = Socket::new(addr, c::SOCK_DGRAM)?; - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(unsafe { c::bind(sock.as_raw(), addr.as_ptr(), len as _) })?; Ok(UdpSocket { inner: sock }) } @@ -554,7 +664,7 @@ impl UdpSocket { pub fn send_to(&self, buf: &[u8], dst: &SocketAddr) -> io::Result { let len = cmp::min(buf.len(), ::MAX as usize) as wrlen_t; - let (dst, dstlen) = dst.into_inner(); + let (dst, dstlen) = socket_addr_to_c(dst); let ret = cvt(unsafe { c::sendto( self.inner.as_raw(), @@ -636,15 +746,15 @@ impl UdpSocket { pub fn join_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> { let mreq = c::ip_mreq { - imr_multiaddr: multiaddr.into_inner(), - imr_interface: interface.into_inner(), + imr_multiaddr: ip_v4_addr_to_c(multiaddr), + imr_interface: ip_v4_addr_to_c(interface), }; setsockopt(&self.inner, c::IPPROTO_IP, c::IP_ADD_MEMBERSHIP, mreq) } pub fn join_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> { let mreq = c::ipv6_mreq { - ipv6mr_multiaddr: multiaddr.into_inner(), + ipv6mr_multiaddr: ip_v6_addr_to_c(multiaddr), ipv6mr_interface: to_ipv6mr_interface(interface), }; setsockopt(&self.inner, c::IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, mreq) @@ -652,15 +762,15 @@ impl UdpSocket { pub fn leave_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> { let mreq = c::ip_mreq { - imr_multiaddr: multiaddr.into_inner(), - imr_interface: interface.into_inner(), + imr_multiaddr: ip_v4_addr_to_c(multiaddr), + imr_interface: ip_v4_addr_to_c(interface), }; setsockopt(&self.inner, c::IPPROTO_IP, c::IP_DROP_MEMBERSHIP, mreq) } pub fn leave_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> { let mreq = c::ipv6_mreq { - ipv6mr_multiaddr: multiaddr.into_inner(), + ipv6mr_multiaddr: ip_v6_addr_to_c(multiaddr), ipv6mr_interface: to_ipv6mr_interface(interface), }; setsockopt(&self.inner, c::IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, mreq) @@ -700,7 +810,7 @@ impl UdpSocket { } pub fn connect(&self, addr: io::Result<&SocketAddr>) -> io::Result<()> { - let (addr, len) = addr?.into_inner(); + let (addr, len) = socket_addr_to_c(addr?); cvt_r(|| unsafe { c::connect(self.inner.as_raw(), addr.as_ptr(), len) }).map(drop) } } @@ -723,38 +833,3 @@ impl fmt::Debug for UdpSocket { res.field(name, &self.inner.as_raw()).finish() } } - -//////////////////////////////////////////////////////////////////////////////// -// Converting SocketAddr to libc representation -//////////////////////////////////////////////////////////////////////////////// - -/// A type with the same memory layout as `c::sockaddr`. Used in converting Rust level -/// SocketAddr* types into their system representation. The benefit of this specific -/// type over using `c::sockaddr_storage` is that this type is exactly as large as it -/// needs to be and not a lot larger. And it can be initialized more cleanly from Rust. -#[repr(C)] -pub(crate) union SocketAddrCRepr { - v4: c::sockaddr_in, - v6: c::sockaddr_in6, -} - -impl SocketAddrCRepr { - pub fn as_ptr(&self) -> *const c::sockaddr { - self as *const _ as *const c::sockaddr - } -} - -impl<'a> IntoInner<(SocketAddrCRepr, c::socklen_t)> for &'a SocketAddr { - fn into_inner(self) -> (SocketAddrCRepr, c::socklen_t) { - match *self { - SocketAddr::V4(ref a) => { - let sockaddr = SocketAddrCRepr { v4: a.into_inner() }; - (sockaddr, mem::size_of::() as c::socklen_t) - } - SocketAddr::V6(ref a) => { - let sockaddr = SocketAddrCRepr { v6: a.into_inner() }; - (sockaddr, mem::size_of::() as c::socklen_t) - } - } - } -} diff --git a/std/src/sys/pal/hermit/net.rs b/std/src/sys/net/connection/socket/hermit.rs similarity index 94% rename from std/src/sys/pal/hermit/net.rs rename to std/src/sys/net/connection/socket/hermit.rs index d9baa091a2321..f49821657d940 100644 --- a/std/src/sys/pal/hermit/net.rs +++ b/std/src/sys/net/connection/socket/hermit.rs @@ -2,21 +2,20 @@ use core::ffi::c_int; -use super::fd::FileDesc; +pub(super) use hermit_abi as netc; + +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd}; +use crate::sys::fd::FileDesc; use crate::sys::time::Instant; -use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; +pub use crate::sys::{cvt, cvt_r}; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::Duration; use crate::{cmp, mem}; -#[allow(unused_extern_crates)] -pub extern crate hermit_abi as netc; - -pub use crate::sys::{cvt, cvt_r}; - +#[expect(non_camel_case_types)] pub type wrlen_t = usize; pub fn cvt_gai(err: i32) -> io::Result<()> { @@ -56,7 +55,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt_r(|| unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?; Ok(()) } @@ -64,7 +63,7 @@ impl Socket { pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Result<()> { self.set_nonblocking(true)?; let r = unsafe { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(netc::connect(self.as_raw_fd(), addr.as_ptr(), len)) }; self.set_nonblocking(false)?; @@ -87,7 +86,7 @@ impl Socket { loop { let elapsed = start.elapsed(); if elapsed >= timeout { - return Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out")); + return Err(io::const_error!(io::ErrorKind::TimedOut, "connection timed out")); } let timeout = timeout - elapsed; @@ -114,7 +113,7 @@ impl Socket { // for POLLHUP rather than read readiness if pollfd.revents & netc::POLLHUP != 0 { let e = self.take_error()?.unwrap_or_else(|| { - io::const_io_error!( + io::const_error!( io::ErrorKind::Uncategorized, "no error set after POLLHUP", ) @@ -184,7 +183,7 @@ impl Socket { fn recv_from_with_flags(&self, buf: &mut [u8], flags: i32) -> io::Result<(usize, SocketAddr)> { let mut storage: netc::sockaddr_storage = unsafe { mem::zeroed() }; - let mut addrlen = mem::size_of_val(&storage) as netc::socklen_t; + let mut addrlen = size_of_val(&storage) as netc::socklen_t; let n = cvt(unsafe { netc::recvfrom( @@ -196,7 +195,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { diff --git a/std/src/sys/pal/solid/net.rs b/std/src/sys/net/connection/socket/solid.rs similarity index 92% rename from std/src/sys/pal/solid/net.rs rename to std/src/sys/net/connection/socket/solid.rs index c0818ecd856d2..94bb605c1007c 100644 --- a/std/src/sys/pal/solid/net.rs +++ b/std/src/sys/net/connection/socket/solid.rs @@ -1,24 +1,23 @@ use libc::{c_int, c_void, size_t}; use self::netc::{MSG_PEEK, sockaddr, socklen_t}; -use super::abi; +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::ffi::CStr; use crate::io::{self, BorrowedBuf, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::solid::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd}; -use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; +use crate::sys::abi; use crate::sys_common::{FromInner, IntoInner}; use crate::time::Duration; use crate::{cmp, mem, ptr, str}; -pub mod netc { - pub use super::super::abi::sockets::*; +pub(super) mod netc { + pub use crate::sys::abi::sockets::*; } +#[expect(non_camel_case_types)] pub type wrlen_t = size_t; -const READ_LIMIT: usize = libc::ssize_t::MAX as usize; - const fn max_iov() -> usize { // Judging by the source code, it's unlimited, but specify a lower // value just in case. @@ -78,7 +77,7 @@ fn last_error() -> io::Error { io::Error::from_raw_os_error(unsafe { netc::SOLID_NET_GetLastError() }) } -pub(super) fn error_name(er: abi::ER) -> Option<&'static str> { +pub fn error_name(er: abi::ER) -> Option<&'static str> { unsafe { CStr::from_ptr(netc::strerror(er)) }.to_str().ok() } @@ -87,7 +86,7 @@ pub fn is_interrupted(er: abi::ER) -> bool { er == netc::SOLID_NET_ERR_BASE - libc::EINTR } -pub(super) fn decode_error_kind(er: abi::ER) -> ErrorKind { +pub fn decode_error_kind(er: abi::ER) -> ErrorKind { let errno = netc::SOLID_NET_ERR_BASE - er; match errno as libc::c_int { libc::ECONNREFUSED => ErrorKind::ConnectionRefused, @@ -132,7 +131,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?; Ok(()) } @@ -175,7 +174,7 @@ impl Socket { }; match n { - 0 => Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out")), + 0 => Err(io::const_error!(io::ErrorKind::TimedOut, "connection timed out")), _ => { let can_write = writefds.num_fds != 0; if !can_write { @@ -245,7 +244,7 @@ impl Socket { flags: c_int, ) -> io::Result<(usize, SocketAddr)> { let mut storage: netc::sockaddr_storage = unsafe { mem::zeroed() }; - let mut addrlen = mem::size_of_val(&storage) as netc::socklen_t; + let mut addrlen = size_of_val(&storage) as netc::socklen_t; let n = cvt(unsafe { netc::recvfrom( @@ -257,7 +256,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { @@ -268,17 +267,6 @@ impl Socket { self.recv_from_with_flags(buf, MSG_PEEK) } - pub fn write(&self, buf: &[u8]) -> io::Result { - let ret = cvt(unsafe { - netc::write( - self.as_raw_fd(), - buf.as_ptr() as *const c_void, - cmp::min(buf.len(), READ_LIMIT), - ) - })?; - Ok(ret as usize) - } - pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result { let ret = cvt(unsafe { netc::writev( diff --git a/std/src/sys_common/net/tests.rs b/std/src/sys/net/connection/socket/tests.rs similarity index 100% rename from std/src/sys_common/net/tests.rs rename to std/src/sys/net/connection/socket/tests.rs diff --git a/std/src/sys/pal/unix/net.rs b/std/src/sys/net/connection/socket/unix.rs similarity index 96% rename from std/src/sys/pal/unix/net.rs rename to std/src/sys/net/connection/socket/unix.rs index 6a67bb0a101e9..e633cf772c528 100644 --- a/std/src/sys/pal/unix/net.rs +++ b/std/src/sys/net/connection/socket/unix.rs @@ -5,8 +5,8 @@ use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use crate::sys::fd::FileDesc; -use crate::sys::pal::unix::IsMinusOne; -use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; +use crate::sys::net::{getsockopt, setsockopt}; +use crate::sys::pal::IsMinusOne; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::{Duration, Instant}; use crate::{cmp, mem}; @@ -19,11 +19,12 @@ cfg_if::cfg_if! { } } -pub use crate::sys::{cvt, cvt_r}; +pub(super) use libc as netc; -#[allow(unused_extern_crates)] -pub extern crate libc as netc; +use super::{socket_addr_from_c, socket_addr_to_c}; +pub use crate::sys::{cvt, cvt_r}; +#[expect(non_camel_case_types)] pub type wrlen_t = size_t; pub struct Socket(FileDesc); @@ -81,6 +82,7 @@ impl Socket { target_os = "netbsd", target_os = "openbsd", target_os = "nto", + target_os = "solaris", ))] { // On platforms that support it we pass the SOCK_CLOEXEC // flag to atomically create the socket and set it as @@ -149,7 +151,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); loop { let result = unsafe { libc::connect(self.as_raw_fd(), addr.as_ptr(), len) }; if result.is_minus_one() { @@ -167,7 +169,7 @@ impl Socket { pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Result<()> { self.set_nonblocking(true)?; let r = unsafe { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(libc::connect(self.as_raw_fd(), addr.as_ptr(), len)) }; self.set_nonblocking(false)?; @@ -190,7 +192,7 @@ impl Socket { loop { let elapsed = start.elapsed(); if elapsed >= timeout { - return Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out")); + return Err(io::const_error!(io::ErrorKind::TimedOut, "connection timed out")); } let timeout = timeout - elapsed; @@ -225,7 +227,7 @@ impl Socket { // for POLLHUP or POLLERR rather than read readiness if pollfd.revents & (libc::POLLHUP | libc::POLLERR) != 0 { let e = self.take_error()?.unwrap_or_else(|| { - io::const_io_error!( + io::const_error!( io::ErrorKind::Uncategorized, "no error set after POLLHUP", ) @@ -320,8 +322,11 @@ impl Socket { buf: &mut [u8], flags: c_int, ) -> io::Result<(usize, SocketAddr)> { - let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() }; - let mut addrlen = mem::size_of_val(&storage) as libc::socklen_t; + // The `recvfrom` function will fill in the storage with the address, + // so we don't need to zero it here. + // reference: https://linux.die.net/man/2/recvfrom + let mut storage: mem::MaybeUninit = mem::MaybeUninit::uninit(); + let mut addrlen = size_of_val(&storage) as libc::socklen_t; let n = cvt(unsafe { libc::recvfrom( @@ -333,7 +338,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(storage.as_ptr(), addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { diff --git a/std/src/sys/pal/wasip2/net.rs b/std/src/sys/net/connection/socket/wasip2.rs similarity index 96% rename from std/src/sys/pal/wasip2/net.rs rename to std/src/sys/net/connection/socket/wasip2.rs index 06e623df8438e..73c2583187207 100644 --- a/std/src/sys/pal/wasip2/net.rs +++ b/std/src/sys/net/connection/socket/wasip2.rs @@ -1,19 +1,18 @@ #![deny(unsafe_op_in_unsafe_fn)] +pub(super) use libc as netc; use libc::{c_int, c_void, size_t}; +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::ffi::CStr; use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; use crate::sys::unsupported; -use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::{Duration, Instant}; use crate::{cmp, mem, str}; -pub extern crate libc as netc; - #[allow(non_camel_case_types)] pub type wrlen_t = size_t; @@ -89,7 +88,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt_r(|| unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?; Ok(()) } @@ -117,7 +116,7 @@ impl Socket { loop { let elapsed = start.elapsed(); if elapsed >= timeout { - return Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out")); + return Err(io::const_error!(io::ErrorKind::TimedOut, "connection timed out")); } let timeout = timeout - elapsed; @@ -212,7 +211,7 @@ impl Socket { flags: c_int, ) -> io::Result<(usize, SocketAddr)> { let mut storage: netc::sockaddr_storage = unsafe { mem::zeroed() }; - let mut addrlen = mem::size_of_val(&storage) as netc::socklen_t; + let mut addrlen = size_of_val(&storage) as netc::socklen_t; let n = cvt(unsafe { netc::recvfrom( @@ -224,7 +223,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { diff --git a/std/src/sys/pal/windows/net.rs b/std/src/sys/net/connection/socket/windows.rs similarity index 92% rename from std/src/sys/pal/windows/net.rs rename to std/src/sys/net/connection/socket/windows.rs index fd62d1f407c27..ce975bb2289c2 100644 --- a/std/src/sys/pal/windows/net.rs +++ b/std/src/sys/net/connection/socket/windows.rs @@ -2,6 +2,7 @@ use core::ffi::{c_int, c_long, c_ulong, c_ushort}; +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut, Read}; use crate::net::{Shutdown, SocketAddr}; use crate::os::windows::io::{ @@ -9,14 +10,14 @@ use crate::os::windows::io::{ }; use crate::sync::OnceLock; use crate::sys::c; -use crate::sys_common::{AsInner, FromInner, IntoInner, net}; +use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::Duration; use crate::{cmp, mem, ptr, sys}; #[allow(non_camel_case_types)] pub type wrlen_t = i32; -pub mod netc { +pub(super) mod netc { //! BSD socket compatibility shim //! //! Some Windows API types are not quite what's expected by our cross-platform @@ -110,6 +111,7 @@ pub mod netc { } } +#[expect(missing_debug_implementations)] pub struct Socket(OwnedSocket); static WSA_CLEANUP: OnceLock i32> = OnceLock::new(); @@ -224,7 +226,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); let result = unsafe { c::connect(self.as_raw(), addr.as_ptr(), len) }; cvt(result).map(drop) } @@ -267,7 +269,7 @@ impl Socket { }; match count { - 0 => Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out")), + 0 => Err(io::const_error!(io::ErrorKind::TimedOut, "connection timed out")), _ => { if writefds.fd_count != 1 { if let Some(e) = self.take_error()? { @@ -379,7 +381,7 @@ impl Socket { flags: c_int, ) -> io::Result<(usize, SocketAddr)> { let mut storage = unsafe { mem::zeroed::() }; - let mut addrlen = mem::size_of_val(&storage) as netc::socklen_t; + let mut addrlen = size_of_val(&storage) as netc::socklen_t; let length = cmp::min(buf.len(), ::MAX as usize) as wrlen_t; // On unix when a socket is shut down all further reads return 0, so we @@ -400,12 +402,12 @@ impl Socket { let error = unsafe { c::WSAGetLastError() }; if error == c::WSAESHUTDOWN { - Ok((0, net::sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((0, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } else { Err(io::Error::from_raw_os_error(error)) } } - _ => Ok((result as usize, net::sockaddr_to_addr(&storage, addrlen as usize)?)), + _ => Ok((result as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })), } } @@ -450,11 +452,11 @@ impl Socket { } None => 0, }; - net::setsockopt(self, c::SOL_SOCKET, kind, timeout) + setsockopt(self, c::SOL_SOCKET, kind, timeout) } pub fn timeout(&self, kind: c_int) -> io::Result> { - let raw: u32 = net::getsockopt(self, c::SOL_SOCKET, kind)?; + let raw: u32 = getsockopt(self, c::SOL_SOCKET, kind)?; if raw == 0 { Ok(None) } else { @@ -487,38 +489,38 @@ impl Socket { l_linger: linger.unwrap_or_default().as_secs() as c_ushort, }; - net::setsockopt(self, c::SOL_SOCKET, c::SO_LINGER, linger) + setsockopt(self, c::SOL_SOCKET, c::SO_LINGER, linger) } pub fn linger(&self) -> io::Result> { - let val: c::LINGER = net::getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?; + let val: c::LINGER = getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?; Ok((val.l_onoff != 0).then(|| Duration::from_secs(val.l_linger as u64))) } pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> { - net::setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BOOL) + setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BOOL) } pub fn nodelay(&self) -> io::Result { - let raw: c::BOOL = net::getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)?; + let raw: c::BOOL = getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)?; Ok(raw != 0) } pub fn take_error(&self) -> io::Result> { - let raw: c_int = net::getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)?; + let raw: c_int = getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)?; if raw == 0 { Ok(None) } else { Ok(Some(io::Error::from_raw_os_error(raw as i32))) } } // This is used by sys_common code to abstract over Windows and Unix. pub fn as_raw(&self) -> c::SOCKET { - debug_assert_eq!(mem::size_of::(), mem::size_of::()); - debug_assert_eq!(mem::align_of::(), mem::align_of::()); + debug_assert_eq!(size_of::(), size_of::()); + debug_assert_eq!(align_of::(), align_of::()); self.as_inner().as_raw_socket() as c::SOCKET } pub unsafe fn from_raw(raw: c::SOCKET) -> Self { - debug_assert_eq!(mem::size_of::(), mem::size_of::()); - debug_assert_eq!(mem::align_of::(), mem::align_of::()); + debug_assert_eq!(size_of::(), size_of::()); + debug_assert_eq!(align_of::(), align_of::()); unsafe { Self::from_raw_socket(raw as RawSocket) } } } diff --git a/std/src/sys/pal/teeos/net.rs b/std/src/sys/net/connection/uefi/mod.rs similarity index 90% rename from std/src/sys/pal/teeos/net.rs rename to std/src/sys/net/connection/uefi/mod.rs index fed95205027a7..da2174396266f 100644 --- a/std/src/sys/pal/teeos/net.rs +++ b/std/src/sys/net/connection/uefi/mod.rs @@ -332,38 +332,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { unsupported() } } - -#[allow(nonstandard_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} - -pub type Socket = UdpSocket; diff --git a/std/src/sys/pal/unsupported/net.rs b/std/src/sys/net/connection/unsupported.rs similarity index 90% rename from std/src/sys/pal/unsupported/net.rs rename to std/src/sys/net/connection/unsupported.rs index 87e6106468fdb..da2174396266f 100644 --- a/std/src/sys/pal/unsupported/net.rs +++ b/std/src/sys/net/connection/unsupported.rs @@ -332,38 +332,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { unsupported() } } - -#[allow(nonstandard_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/std/src/sys/pal/wasi/net.rs b/std/src/sys/net/connection/wasip1.rs similarity index 93% rename from std/src/sys/pal/wasi/net.rs rename to std/src/sys/net/connection/wasip1.rs index a648679982812..951dc65e5b47d 100644 --- a/std/src/sys/pal/wasi/net.rs +++ b/std/src/sys/net/connection/wasip1.rs @@ -1,12 +1,11 @@ #![forbid(unsafe_op_in_unsafe_fn)] -use super::err2io; -use super::fd::WasiFd; use crate::fmt; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; -use crate::sys::unsupported; +use crate::sys::fd::WasiFd; +use crate::sys::{err2io, unsupported}; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::Duration; @@ -506,38 +505,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { unsupported() } } - -#[allow(nonstandard_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/std/src/sys/pal/xous/net/dns.rs b/std/src/sys/net/connection/xous/dns.rs similarity index 94% rename from std/src/sys/pal/xous/net/dns.rs rename to std/src/sys/net/connection/xous/dns.rs index 1a2b56b4da5d3..bb29d211fad56 100644 --- a/std/src/sys/pal/xous/net/dns.rs +++ b/std/src/sys/net/connection/xous/dns.rs @@ -107,7 +107,7 @@ impl TryFrom<&str> for LookupHost { ($e:expr, $msg:expr) => { match $e { Some(r) => r, - None => return Err(io::const_io_error!(io::ErrorKind::InvalidInput, &$msg)), + None => return Err(io::const_error!(io::ErrorKind::InvalidInput, &$msg)), } }; } @@ -123,7 +123,6 @@ impl TryFrom<(&str, u16)> for LookupHost { type Error = io::Error; fn try_from(v: (&str, u16)) -> io::Result { - lookup(v.0, v.1) - .map_err(|_e| io::const_io_error!(io::ErrorKind::InvalidInput, &"DNS failure")) + lookup(v.0, v.1).map_err(|_e| io::const_error!(io::ErrorKind::InvalidInput, "DNS failure")) } } diff --git a/std/src/sys/net/connection/xous/mod.rs b/std/src/sys/net/connection/xous/mod.rs new file mode 100644 index 0000000000000..e44a375b9e3c5 --- /dev/null +++ b/std/src/sys/net/connection/xous/mod.rs @@ -0,0 +1,48 @@ +mod dns; + +mod tcpstream; +pub use tcpstream::*; + +mod tcplistener; +pub use tcplistener::*; + +mod udp; +pub use udp::*; + +// this structure needs to be synchronized with what's in net/src/api.rs +#[repr(C)] +#[derive(Debug)] +enum NetError { + // Ok = 0, + Unaddressable = 1, + SocketInUse = 2, + // AccessDenied = 3, + Invalid = 4, + // Finished = 5, + LibraryError = 6, + // AlreadyUsed = 7, + TimedOut = 8, + WouldBlock = 9, +} + +#[repr(C, align(4096))] +struct ConnectRequest { + raw: [u8; 4096], +} + +#[repr(C, align(4096))] +struct SendData { + raw: [u8; 4096], +} + +#[repr(C, align(4096))] +pub struct ReceiveData { + raw: [u8; 4096], +} + +#[repr(C, align(4096))] +pub struct GetAddress { + raw: [u8; 4096], +} + +pub use dns::LookupHost; diff --git a/std/src/sys/pal/xous/net/tcplistener.rs b/std/src/sys/net/connection/xous/tcplistener.rs similarity index 83% rename from std/src/sys/pal/xous/net/tcplistener.rs rename to std/src/sys/net/connection/xous/tcplistener.rs index ddfb289162b69..7f13ca5592040 100644 --- a/std/src/sys/pal/xous/net/tcplistener.rs +++ b/std/src/sys/net/connection/xous/tcplistener.rs @@ -9,9 +9,9 @@ use crate::{fmt, io}; macro_rules! unimpl { () => { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::Unsupported, - &"This function is not yet implemented", + "this function is not yet implemented", )); }; } @@ -71,7 +71,7 @@ impl TcpListener { 0, 4096, ) else { - return Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Invalid response")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response")); }; // The first four bytes should be zero upon success, and will be nonzero @@ -80,18 +80,15 @@ impl TcpListener { if response[0] != 0 || valid == 0 { let errcode = response[1]; if errcode == NetError::SocketInUse as u8 { - return Err(io::const_io_error!(io::ErrorKind::ResourceBusy, &"Socket in use")); + return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use")); } else if errcode == NetError::Invalid as u8 { - return Err(io::const_io_error!( - io::ErrorKind::AddrNotAvailable, - &"Invalid address" - )); + return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "invalid address")); } else if errcode == NetError::LibraryError as u8 { - return Err(io::const_io_error!(io::ErrorKind::Other, &"Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } else { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::Other, - &"Unable to connect or internal error" + "unable to connect or internal error", )); } } @@ -130,16 +127,13 @@ impl TcpListener { if receive_request.raw[0] != 0 { // error case if receive_request.raw[1] == NetError::TimedOut as u8 { - return Err(io::const_io_error!(io::ErrorKind::TimedOut, &"accept timed out",)); + return Err(io::const_error!(io::ErrorKind::TimedOut, "accept timed out")); } else if receive_request.raw[1] == NetError::WouldBlock as u8 { - return Err(io::const_io_error!( - io::ErrorKind::WouldBlock, - &"accept would block", - )); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "accept would block")); } else if receive_request.raw[1] == NetError::LibraryError as u8 { - return Err(io::const_io_error!(io::ErrorKind::Other, &"Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } else { - return Err(io::const_io_error!(io::ErrorKind::Other, &"library error",)); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } } else { // accept successful @@ -163,7 +157,7 @@ impl TcpListener { port, ) } else { - return Err(io::const_io_error!(io::ErrorKind::Other, &"library error",)); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); }; // replenish the listener @@ -175,7 +169,7 @@ impl TcpListener { Ok((TcpStream::from_listener(stream_fd, self.local.port(), port, addr), addr)) } } else { - Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unable to accept")) + Err(io::const_error!(io::ErrorKind::InvalidInput, "unable to accept")) } } @@ -186,13 +180,13 @@ impl TcpListener { pub fn set_ttl(&self, ttl: u32) -> io::Result<()> { if ttl > 255 { - return Err(io::Error::new(io::ErrorKind::InvalidInput, "TTL must be less than 256")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "TTL must be less than 256")); } crate::os::xous::ffi::blocking_scalar( services::net_server(), services::NetBlockingScalar::StdSetTtlTcp(self.fd.load(Ordering::Relaxed), ttl).into(), ) - .or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|_| ()) } @@ -201,7 +195,7 @@ impl TcpListener { services::net_server(), services::NetBlockingScalar::StdGetTtlTcp(self.fd.load(Ordering::Relaxed)).into(), ) - .or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|res| res[0] as _)?) } diff --git a/std/src/sys/pal/xous/net/tcpstream.rs b/std/src/sys/net/connection/xous/tcpstream.rs similarity index 85% rename from std/src/sys/pal/xous/net/tcpstream.rs rename to std/src/sys/net/connection/xous/tcpstream.rs index 03442cf2fcdfd..283b1fe9a33b9 100644 --- a/std/src/sys/pal/xous/net/tcpstream.rs +++ b/std/src/sys/net/connection/xous/tcpstream.rs @@ -10,9 +10,9 @@ use crate::time::Duration; macro_rules! unimpl { () => { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::Unsupported, - &"This function is not yet implemented", + "this function is not yet implemented", )); }; } @@ -96,7 +96,7 @@ impl TcpStream { 0, 4096, ) else { - return Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Invalid response")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response")); }; // The first four bytes should be zero upon success, and will be nonzero @@ -106,16 +106,13 @@ impl TcpStream { // errcode is a u8 but stuck in a u16 where the upper byte is invalid. Mask & decode accordingly. let errcode = response[0]; if errcode == NetError::SocketInUse as u8 { - return Err(io::const_io_error!(io::ErrorKind::ResourceBusy, &"Socket in use",)); + return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use")); } else if errcode == NetError::Unaddressable as u8 { - return Err(io::const_io_error!( - io::ErrorKind::AddrNotAvailable, - &"Invalid address", - )); + return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "invalid address")); } else { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, - &"Unable to connect or internal error", + "unable to connect or internal error", )); } } @@ -199,9 +196,9 @@ impl TcpStream { self.read_timeout.load(Ordering::Relaxed) as usize, data_to_read, ) else { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, - &"Library failure: wrong message type or messaging error" + "library failure: wrong message type or messaging error", )); }; @@ -215,14 +212,14 @@ impl TcpStream { if result[0] != 0 { if result[1] == 8 { // timed out - return Err(io::const_io_error!(io::ErrorKind::TimedOut, &"Timeout",)); + return Err(io::const_error!(io::ErrorKind::TimedOut, "timeout")); } if result[1] == 9 { // would block - return Err(io::const_io_error!(io::ErrorKind::WouldBlock, &"Would block",)); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "would block")); } } - Err(io::const_io_error!(io::ErrorKind::Other, &"recv_slice failure")) + Err(io::const_error!(io::ErrorKind::Other, "recv_slice failure")) } } @@ -261,23 +258,20 @@ impl TcpStream { self.write_timeout.load(Ordering::Relaxed) as usize, buf_len, ) - .or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Internal error")))?; + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "internal error")))?; if send_request.raw[0] != 0 { if send_request.raw[4] == 8 { // timed out - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::BrokenPipe, - &"Timeout or connection closed", + "timeout or connection closed", )); } else if send_request.raw[4] == 9 { // would block - return Err(io::const_io_error!(io::ErrorKind::WouldBlock, &"Would block",)); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "would block")); } else { - return Err(io::const_io_error!( - io::ErrorKind::InvalidInput, - &"Error when sending", - )); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "error when sending")); } } Ok(u32::from_le_bytes([ @@ -310,7 +304,7 @@ impl TcpStream { 0, 0, ) else { - return Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Internal error")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "internal error")); }; let mut i = get_addr.raw.iter(); match *i.next().unwrap() { @@ -330,7 +324,7 @@ impl TcpStream { } Ok(SocketAddr::V6(SocketAddrV6::new(new_addr.into(), self.local_port, 0, 0))) } - _ => Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Internal error")), + _ => Err(io::const_error!(io::ErrorKind::InvalidInput, "tnternal error")), } } @@ -339,7 +333,7 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdTcpStreamShutdown(self.fd, how).into(), ) - .or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|_| ()) } @@ -361,7 +355,7 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdSetNodelay(self.fd, enabled).into(), ) - .or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|_| ()) } @@ -370,19 +364,19 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdGetNodelay(self.fd).into(), ) - .or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|res| res[0] != 0)?) } pub fn set_ttl(&self, ttl: u32) -> io::Result<()> { if ttl > 255 { - return Err(io::Error::new(io::ErrorKind::InvalidInput, "TTL must be less than 256")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "TTL must be less than 256")); } crate::os::xous::ffi::blocking_scalar( services::net_server(), services::NetBlockingScalar::StdSetTtlTcp(self.fd, ttl).into(), ) - .or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|_| ()) } @@ -391,7 +385,7 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdGetTtlTcp(self.fd).into(), ) - .or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|res| res[0] as _)?) } diff --git a/std/src/sys/pal/xous/net/udp.rs b/std/src/sys/net/connection/xous/udp.rs similarity index 84% rename from std/src/sys/pal/xous/net/udp.rs rename to std/src/sys/net/connection/xous/udp.rs index de5133280ba9d..c112c04ce94bc 100644 --- a/std/src/sys/pal/xous/net/udp.rs +++ b/std/src/sys/net/connection/xous/udp.rs @@ -11,9 +11,9 @@ use crate::{fmt, io}; macro_rules! unimpl { () => { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::Unsupported, - &"This function is not yet implemented", + "this function is not yet implemented", )); }; } @@ -72,18 +72,18 @@ impl UdpSocket { if response[0] != 0 || valid == 0 { let errcode = response[1]; if errcode == NetError::SocketInUse as u8 { - return Err(io::const_io_error!(io::ErrorKind::ResourceBusy, &"Socket in use")); + return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use")); } else if errcode == NetError::Invalid as u8 { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, - &"Port can't be 0 or invalid address" + "port can't be 0 or invalid address", )); } else if errcode == NetError::LibraryError as u8 { - return Err(io::const_io_error!(io::ErrorKind::Other, &"Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } else { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::Other, - &"Unable to connect or internal error" + "unable to connect or internal error", )); } } @@ -98,13 +98,13 @@ impl UdpSocket { nonblocking: Cell::new(false), }); } - Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Invalid response")) + Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response")) } pub fn peer_addr(&self) -> io::Result { match self.remote.get() { Some(dest) => Ok(dest), - None => Err(io::const_io_error!(io::ErrorKind::NotConnected, &"No peer specified")), + None => Err(io::const_error!(io::ErrorKind::NotConnected, "no peer specified")), } } @@ -141,16 +141,13 @@ impl UdpSocket { if receive_request.raw[0] != 0 { // error case if receive_request.raw[1] == NetError::TimedOut as u8 { - return Err(io::const_io_error!(io::ErrorKind::TimedOut, &"recv timed out",)); + return Err(io::const_error!(io::ErrorKind::TimedOut, "recv timed out")); } else if receive_request.raw[1] == NetError::WouldBlock as u8 { - return Err(io::const_io_error!( - io::ErrorKind::WouldBlock, - &"recv would block", - )); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "recv would block")); } else if receive_request.raw[1] == NetError::LibraryError as u8 { - return Err(io::const_io_error!(io::ErrorKind::Other, &"Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } else { - return Err(io::const_io_error!(io::ErrorKind::Other, &"library error",)); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } } else { let rr = &receive_request.raw; @@ -173,7 +170,7 @@ impl UdpSocket { port, ) } else { - return Err(io::const_io_error!(io::ErrorKind::Other, &"library error",)); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); }; for (&s, d) in rr[22..22 + rxlen as usize].iter().zip(buf.iter_mut()) { *d = s; @@ -181,7 +178,7 @@ impl UdpSocket { Ok((rxlen as usize, addr)) } } else { - Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unable to recv")) + Err(io::const_error!(io::ErrorKind::InvalidInput, "unable to recv")) } } @@ -211,7 +208,7 @@ impl UdpSocket { if let Some(addr) = self.remote.get() { self.send_to(buf, &addr) } else { - Err(io::const_io_error!(io::ErrorKind::NotConnected, &"No remote specified")) + Err(io::const_error!(io::ErrorKind::NotConnected, "No remote specified")) } } @@ -247,7 +244,7 @@ impl UdpSocket { // let buf = unsafe { // xous::MemoryRange::new( // &mut tx_req as *mut SendData as usize, - // core::mem::size_of::(), + // size_of::(), // ) // .unwrap() // }; @@ -282,24 +279,21 @@ impl UdpSocket { if response[0] != 0 || valid == 0 { let errcode = response[1]; if errcode == NetError::SocketInUse as u8 { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::ResourceBusy, - &"Socket in use" + "socket in use", )); } else if errcode == NetError::Invalid as u8 { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, - &"Socket not valid" + "socket not valid", )); } else if errcode == NetError::LibraryError as u8 { - return Err(io::const_io_error!( - io::ErrorKind::Other, - &"Library error" - )); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } else { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::Other, - &"Unable to connect" + "unable to connect", )); } } else { @@ -309,16 +303,13 @@ impl UdpSocket { } Err(crate::os::xous::ffi::Error::ServerQueueFull) => { if now.elapsed() >= write_timeout { - return Err(io::const_io_error!( - io::ErrorKind::WouldBlock, - &"Write timed out" - )); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "write timed out")); } else { // question: do we want to do something a bit more gentle than immediately retrying? crate::thread::yield_now(); } } - _ => return Err(io::const_io_error!(io::ErrorKind::Other, &"Library error")), + _ => return Err(io::const_error!(io::ErrorKind::Other, "library error")), } } } @@ -366,13 +357,13 @@ impl UdpSocket { pub fn set_ttl(&self, ttl: u32) -> io::Result<()> { if ttl > 255 { - return Err(io::Error::new(io::ErrorKind::InvalidInput, "TTL must be less than 256")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "TTL must be less than 256")); } crate::os::xous::ffi::blocking_scalar( services::net_server(), services::NetBlockingScalar::StdSetTtlUdp(self.fd, ttl).into(), ) - .or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|_| ()) } @@ -381,7 +372,7 @@ impl UdpSocket { services::net_server(), services::NetBlockingScalar::StdGetTtlUdp(self.fd).into(), ) - .or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|res| res[0] as _)?) } @@ -447,7 +438,7 @@ impl UdpSocket { impl fmt::Debug for UdpSocket { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "UDP listening on {:?} to {:?}", self.local, self.remote.get(),) + write!(f, "UDP listening on {:?} to {:?}", self.local, self.remote.get()) } } diff --git a/std/src/sys/net/mod.rs b/std/src/sys/net/mod.rs new file mode 100644 index 0000000000000..646679a1cc8b9 --- /dev/null +++ b/std/src/sys/net/mod.rs @@ -0,0 +1,41 @@ +cfg_if::cfg_if! { + if #[cfg(any( + all(target_family = "unix", not(target_os = "l4re")), + target_os = "windows", + target_os = "hermit", + all(target_os = "wasi", target_env = "p2"), + target_os = "solid_asp3", + ))] { + mod connection { + mod socket; + pub use socket::*; + } + } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { + mod connection { + mod sgx; + pub use sgx::*; + } + } else if #[cfg(all(target_os = "wasi", target_env = "p1"))] { + mod connection { + mod wasip1; + pub use wasip1::*; + } + } else if #[cfg(target_os = "xous")] { + mod connection { + mod xous; + pub use xous::*; + } + } else if #[cfg(target_os = "uefi")] { + mod connection { + mod uefi; + pub use uefi::*; + } + } else { + mod connection { + mod unsupported; + pub use unsupported::*; + } + } +} + +pub use connection::*; diff --git a/std/src/sys/os_str/bytes.rs b/std/src/sys/os_str/bytes.rs index 5b65d862be102..dfff2d3e5d31d 100644 --- a/std/src/sys/os_str/bytes.rs +++ b/std/src/sys/os_str/bytes.rs @@ -8,7 +8,7 @@ use crate::collections::TryReserveError; use crate::fmt::Write; use crate::rc::Rc; use crate::sync::Arc; -use crate::sys_common::{AsInner, IntoInner}; +use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::{fmt, mem, str}; #[cfg(test)] @@ -25,6 +25,37 @@ pub struct Slice { pub inner: [u8], } +impl IntoInner> for Buf { + fn into_inner(self) -> Vec { + self.inner + } +} + +impl FromInner> for Buf { + fn from_inner(inner: Vec) -> Self { + Buf { inner } + } +} + +impl AsInner<[u8]> for Buf { + #[inline] + fn as_inner(&self) -> &[u8] { + &self.inner + } +} + +impl fmt::Debug for Buf { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(self.as_slice(), f) + } +} + +impl fmt::Display for Buf { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(self.as_slice(), f) + } +} + impl fmt::Debug for Slice { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.inner.utf8_chunks().debug(), f) @@ -55,18 +86,6 @@ impl fmt::Display for Slice { } } -impl fmt::Debug for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(self.as_slice(), formatter) - } -} - -impl fmt::Display for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(self.as_slice(), formatter) - } -} - impl Clone for Buf { #[inline] fn clone(&self) -> Self { @@ -79,19 +98,6 @@ impl Clone for Buf { } } -impl IntoInner> for Buf { - fn into_inner(self) -> Vec { - self.inner - } -} - -impl AsInner<[u8]> for Buf { - #[inline] - fn as_inner(&self) -> &[u8] { - &self.inner - } -} - impl Buf { #[inline] pub fn into_encoded_bytes(self) -> Vec { @@ -103,6 +109,12 @@ impl Buf { Self { inner: s } } + #[inline] + pub fn into_string(self) -> Result { + String::from_utf8(self.inner).map_err(|p| Buf { inner: p.into_bytes() }) + } + + #[inline] pub fn from_string(s: String) -> Buf { Buf { inner: s.into_bytes() } } @@ -122,6 +134,16 @@ impl Buf { self.inner.capacity() } + #[inline] + pub fn push_slice(&mut self, s: &Slice) { + self.inner.extend_from_slice(&s.inner) + } + + #[inline] + pub fn push_str(&mut self, s: &str) { + self.inner.extend_from_slice(s.as_bytes()); + } + #[inline] pub fn reserve(&mut self, additional: usize) { self.inner.reserve(additional) @@ -157,7 +179,7 @@ impl Buf { // SAFETY: Slice just wraps [u8], // and &*self.inner is &[u8], therefore // transmuting &[u8] to &Slice is safe. - unsafe { mem::transmute(&*self.inner) } + unsafe { mem::transmute(self.inner.as_slice()) } } #[inline] @@ -165,15 +187,7 @@ impl Buf { // SAFETY: Slice just wraps [u8], // and &mut *self.inner is &mut [u8], therefore // transmuting &mut [u8] to &mut Slice is safe. - unsafe { mem::transmute(&mut *self.inner) } - } - - pub fn into_string(self) -> Result { - String::from_utf8(self.inner).map_err(|p| Buf { inner: p.into_bytes() }) - } - - pub fn push_slice(&mut self, s: &Slice) { - self.inner.extend_from_slice(&s.inner) + unsafe { mem::transmute(self.inner.as_mut_slice()) } } #[inline] @@ -278,18 +292,22 @@ impl Slice { unsafe { Slice::from_encoded_bytes_unchecked(s.as_bytes()) } } + #[inline] pub fn to_str(&self) -> Result<&str, crate::str::Utf8Error> { str::from_utf8(&self.inner) } + #[inline] pub fn to_string_lossy(&self) -> Cow<'_, str> { String::from_utf8_lossy(&self.inner) } + #[inline] pub fn to_owned(&self) -> Buf { Buf { inner: self.inner.to_vec() } } + #[inline] pub fn clone_into(&self, buf: &mut Buf) { self.inner.clone_into(&mut buf.inner) } @@ -300,6 +318,7 @@ impl Slice { unsafe { mem::transmute(boxed) } } + #[inline] pub fn empty_box() -> Box { let boxed: Box<[u8]> = Default::default(); unsafe { mem::transmute(boxed) } diff --git a/std/src/sys/os_str/wtf8.rs b/std/src/sys/os_str/wtf8.rs index a4ad5966afe57..a32f5d40f6a9c 100644 --- a/std/src/sys/os_str/wtf8.rs +++ b/std/src/sys/os_str/wtf8.rs @@ -10,11 +10,16 @@ use crate::sys_common::wtf8::{Wtf8, Wtf8Buf, check_utf8_boundary}; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::{fmt, mem}; -#[derive(Clone, Hash)] +#[derive(Hash)] pub struct Buf { pub inner: Wtf8Buf, } +#[repr(transparent)] +pub struct Slice { + pub inner: Wtf8, +} + impl IntoInner for Buf { fn into_inner(self) -> Wtf8Buf { self.inner @@ -35,31 +40,38 @@ impl AsInner for Buf { } impl fmt::Debug for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(self.as_slice(), formatter) + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&self.inner, f) } } impl fmt::Display for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(self.as_slice(), formatter) + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(&self.inner, f) } } -#[repr(transparent)] -pub struct Slice { - pub inner: Wtf8, -} - impl fmt::Debug for Slice { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(&self.inner, formatter) + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&self.inner, f) } } impl fmt::Display for Slice { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(&self.inner, formatter) + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(&self.inner, f) + } +} + +impl Clone for Buf { + #[inline] + fn clone(&self) -> Self { + Buf { inner: self.inner.clone() } + } + + #[inline] + fn clone_from(&mut self, source: &Self) { + self.inner.clone_from(&source.inner) } } @@ -74,62 +86,62 @@ impl Buf { unsafe { Self { inner: Wtf8Buf::from_bytes_unchecked(s) } } } - pub fn with_capacity(capacity: usize) -> Buf { - Buf { inner: Wtf8Buf::with_capacity(capacity) } - } - - pub fn clear(&mut self) { - self.inner.clear() - } - - pub fn capacity(&self) -> usize { - self.inner.capacity() + #[inline] + pub fn into_string(self) -> Result { + self.inner.into_string().map_err(|buf| Buf { inner: buf }) } + #[inline] pub fn from_string(s: String) -> Buf { Buf { inner: Wtf8Buf::from_string(s) } } - pub fn as_slice(&self) -> &Slice { - // SAFETY: Slice is just a wrapper for Wtf8, - // and self.inner.as_slice() returns &Wtf8. - // Therefore, transmuting &Wtf8 to &Slice is safe. - unsafe { mem::transmute(self.inner.as_slice()) } + #[inline] + pub fn with_capacity(capacity: usize) -> Buf { + Buf { inner: Wtf8Buf::with_capacity(capacity) } } - pub fn as_mut_slice(&mut self) -> &mut Slice { - // SAFETY: Slice is just a wrapper for Wtf8, - // and self.inner.as_mut_slice() returns &mut Wtf8. - // Therefore, transmuting &mut Wtf8 to &mut Slice is safe. - // Additionally, care should be taken to ensure the slice - // is always valid Wtf8. - unsafe { mem::transmute(self.inner.as_mut_slice()) } + #[inline] + pub fn clear(&mut self) { + self.inner.clear() } - pub fn into_string(self) -> Result { - self.inner.into_string().map_err(|buf| Buf { inner: buf }) + #[inline] + pub fn capacity(&self) -> usize { + self.inner.capacity() } + #[inline] pub fn push_slice(&mut self, s: &Slice) { self.inner.push_wtf8(&s.inner) } + #[inline] + pub fn push_str(&mut self, s: &str) { + self.inner.push_str(s); + } + + #[inline] pub fn reserve(&mut self, additional: usize) { self.inner.reserve(additional) } + #[inline] pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { self.inner.try_reserve(additional) } + #[inline] pub fn reserve_exact(&mut self, additional: usize) { self.inner.reserve_exact(additional) } + #[inline] pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> { self.inner.try_reserve_exact(additional) } + #[inline] pub fn shrink_to_fit(&mut self) { self.inner.shrink_to_fit() } @@ -139,6 +151,24 @@ impl Buf { self.inner.shrink_to(min_capacity) } + #[inline] + pub fn as_slice(&self) -> &Slice { + // SAFETY: Slice is just a wrapper for Wtf8, + // and self.inner.as_slice() returns &Wtf8. + // Therefore, transmuting &Wtf8 to &Slice is safe. + unsafe { mem::transmute(self.inner.as_slice()) } + } + + #[inline] + pub fn as_mut_slice(&mut self) -> &mut Slice { + // SAFETY: Slice is just a wrapper for Wtf8, + // and self.inner.as_mut_slice() returns &mut Wtf8. + // Therefore, transmuting &mut Wtf8 to &mut Slice is safe. + // Additionally, care should be taken to ensure the slice + // is always valid Wtf8. + unsafe { mem::transmute(self.inner.as_mut_slice()) } + } + #[inline] pub fn leak<'a>(self) -> &'a mut Slice { unsafe { mem::transmute(self.inner.leak()) } @@ -194,6 +224,7 @@ impl Slice { } #[track_caller] + #[inline] pub fn check_public_boundary(&self, index: usize) { check_utf8_boundary(&self.inner, index); } @@ -203,18 +234,22 @@ impl Slice { unsafe { mem::transmute(Wtf8::from_str(s)) } } + #[inline] pub fn to_str(&self) -> Result<&str, crate::str::Utf8Error> { self.inner.as_str() } + #[inline] pub fn to_string_lossy(&self) -> Cow<'_, str> { self.inner.to_string_lossy() } + #[inline] pub fn to_owned(&self) -> Buf { Buf { inner: self.inner.to_owned() } } + #[inline] pub fn clone_into(&self, buf: &mut Buf) { self.inner.clone_into(&mut buf.inner) } @@ -224,6 +259,7 @@ impl Slice { unsafe { mem::transmute(self.inner.into_box()) } } + #[inline] pub fn empty_box() -> Box { unsafe { mem::transmute(Wtf8::empty_box()) } } diff --git a/std/src/sys/pal/common/small_c_string.rs b/std/src/sys/pal/common/small_c_string.rs index 3c96714b5c58c..f54505a856e05 100644 --- a/std/src/sys/pal/common/small_c_string.rs +++ b/std/src/sys/pal/common/small_c_string.rs @@ -11,7 +11,7 @@ const MAX_STACK_ALLOCATION: usize = 384; const MAX_STACK_ALLOCATION: usize = 32; const NUL_ERR: io::Error = - io::const_io_error!(io::ErrorKind::InvalidInput, "file name contained an unexpected NUL byte"); + io::const_error!(io::ErrorKind::InvalidInput, "file name contained an unexpected NUL byte"); #[inline] pub fn run_path_with_cstr(path: &Path, f: &dyn Fn(&CStr) -> io::Result) -> io::Result { diff --git a/std/src/sys/pal/hermit/fd.rs b/std/src/sys/pal/hermit/fd.rs index 79fc13bd4a87f..3d6b99cd77b54 100644 --- a/std/src/sys/pal/hermit/fd.rs +++ b/std/src/sys/pal/hermit/fd.rs @@ -2,8 +2,8 @@ use super::hermit_abi; use crate::cmp; -use crate::io::{self, IoSlice, IoSliceMut, Read}; -use crate::os::hermit::io::{FromRawFd, OwnedFd, RawFd, *}; +use crate::io::{self, IoSlice, IoSliceMut, Read, SeekFrom}; +use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; use crate::sys::{cvt, unsupported}; use crate::sys_common::{AsInner, FromInner, IntoInner}; @@ -66,9 +66,26 @@ impl FileDesc { true } + pub fn seek(&self, pos: SeekFrom) -> io::Result { + let (whence, pos) = match pos { + // Casting to `i64` is fine, too large values will end up as + // negative which will cause an error in `lseek`. + SeekFrom::Start(off) => (hermit_abi::SEEK_SET, off as i64), + SeekFrom::End(off) => (hermit_abi::SEEK_END, off), + SeekFrom::Current(off) => (hermit_abi::SEEK_CUR, off), + }; + let n = cvt(unsafe { hermit_abi::lseek(self.as_raw_fd(), pos as isize, whence) })?; + Ok(n as u64) + } + + pub fn tell(&self) -> io::Result { + self.seek(SeekFrom::Current(0)) + } + pub fn duplicate(&self) -> io::Result { self.duplicate_path(&[]) } + pub fn duplicate_path(&self, _path: &[u8]) -> io::Result { unsupported() } diff --git a/std/src/sys/pal/hermit/io.rs b/std/src/sys/pal/hermit/io.rs deleted file mode 100644 index 0424a1ac55a29..0000000000000 --- a/std/src/sys/pal/hermit/io.rs +++ /dev/null @@ -1,87 +0,0 @@ -use hermit_abi::{c_void, iovec}; - -use crate::marker::PhantomData; -use crate::os::hermit::io::{AsFd, AsRawFd}; -use crate::slice; - -#[derive(Copy, Clone)] -#[repr(transparent)] -pub struct IoSlice<'a> { - vec: iovec, - _p: PhantomData<&'a [u8]>, -} - -impl<'a> IoSlice<'a> { - #[inline] - pub fn new(buf: &'a [u8]) -> IoSlice<'a> { - IoSlice { - vec: iovec { iov_base: buf.as_ptr() as *mut u8 as *mut c_void, iov_len: buf.len() }, - _p: PhantomData, - } - } - - #[inline] - pub fn advance(&mut self, n: usize) { - if self.vec.iov_len < n { - panic!("advancing IoSlice beyond its length"); - } - - unsafe { - self.vec.iov_len -= n; - self.vec.iov_base = self.vec.iov_base.add(n); - } - } - - #[inline] - pub const fn as_slice(&self) -> &'a [u8] { - unsafe { slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len) } - } -} - -#[repr(transparent)] -pub struct IoSliceMut<'a> { - vec: iovec, - _p: PhantomData<&'a mut [u8]>, -} - -impl<'a> IoSliceMut<'a> { - #[inline] - pub fn new(buf: &'a mut [u8]) -> IoSliceMut<'a> { - IoSliceMut { - vec: iovec { iov_base: buf.as_mut_ptr() as *mut c_void, iov_len: buf.len() }, - _p: PhantomData, - } - } - - #[inline] - pub fn advance(&mut self, n: usize) { - if self.vec.iov_len < n { - panic!("advancing IoSliceMut beyond its length"); - } - - unsafe { - self.vec.iov_len -= n; - self.vec.iov_base = self.vec.iov_base.add(n); - } - } - - #[inline] - pub fn as_slice(&self) -> &[u8] { - unsafe { slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len) } - } - - #[inline] - pub const fn into_slice(self) -> &'a mut [u8] { - unsafe { slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len) } - } - - #[inline] - pub fn as_mut_slice(&mut self) -> &mut [u8] { - unsafe { slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len) } - } -} - -pub fn is_terminal(fd: &impl AsFd) -> bool { - let fd = fd.as_fd(); - hermit_abi::isatty(fd.as_raw_fd()) -} diff --git a/std/src/sys/pal/hermit/mod.rs b/std/src/sys/pal/hermit/mod.rs index b62afb40a615f..608245bd430bc 100644 --- a/std/src/sys/pal/hermit/mod.rs +++ b/std/src/sys/pal/hermit/mod.rs @@ -21,16 +21,12 @@ use crate::os::raw::c_char; pub mod args; pub mod env; pub mod fd; -pub mod fs; pub mod futex; -pub mod io; -pub mod net; pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; #[path = "../unsupported/process.rs"] pub mod process; -pub mod stdio; pub mod thread; pub mod time; @@ -42,7 +38,7 @@ pub fn unsupported() -> crate::io::Result { } pub fn unsupported_err() -> crate::io::Error { - crate::io::const_io_error!( + crate::io::const_error!( crate::io::ErrorKind::Unsupported, "operation not supported on HermitCore yet", ) @@ -55,7 +51,7 @@ pub fn abort_internal() -> ! { // This function is needed by the panic runtime. The symbol is named in // pre-link args for the target specification, so keep that in sync. #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] // NB. used by both libunwind and libpanic_abort pub extern "C" fn __rust_abort() { abort_internal(); @@ -74,18 +70,18 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, _sigpipe: u8) { pub unsafe fn cleanup() {} #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn runtime_entry( argc: i32, argv: *const *const c_char, env: *const *const c_char, ) -> ! { - extern "C" { + unsafe extern "C" { fn main(argc: isize, argv: *const *const c_char) -> i32; } // initialize environment - os::init_environment(env as *const *const i8); + os::init_environment(env); let result = unsafe { main(argc as isize, argv) }; diff --git a/std/src/sys/pal/hermit/os.rs b/std/src/sys/pal/hermit/os.rs index f8ea80afa43f1..791cdb1e57e7d 100644 --- a/std/src/sys/pal/hermit/os.rs +++ b/std/src/sys/pal/hermit/os.rs @@ -3,7 +3,7 @@ use core::slice::memchr; use super::hermit_abi; use crate::collections::HashMap; use crate::error::Error as StdError; -use crate::ffi::{CStr, OsStr, OsString}; +use crate::ffi::{CStr, OsStr, OsString, c_char}; use crate::marker::PhantomData; use crate::os::hermit::ffi::OsStringExt; use crate::path::{self, PathBuf}; @@ -70,7 +70,7 @@ pub fn current_exe() -> io::Result { static ENV: Mutex>> = Mutex::new(None); -pub fn init_environment(env: *const *const i8) { +pub fn init_environment(env: *const *const c_char) { let mut guard = ENV.lock().unwrap(); let map = guard.insert(HashMap::new()); diff --git a/std/src/sys/pal/hermit/stdio.rs b/std/src/sys/pal/hermit/stdio.rs deleted file mode 100644 index 3ea00f5cc5ec9..0000000000000 --- a/std/src/sys/pal/hermit/stdio.rs +++ /dev/null @@ -1,97 +0,0 @@ -use super::hermit_abi; -use crate::io; -use crate::io::{IoSlice, IoSliceMut}; -use crate::mem::ManuallyDrop; -use crate::os::hermit::io::FromRawFd; -use crate::sys::fd::FileDesc; - -pub struct Stdin; -pub struct Stdout; -pub struct Stderr; - -impl Stdin { - pub const fn new() -> Stdin { - Stdin - } -} - -impl io::Read for Stdin { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(hermit_abi::STDIN_FILENO)).read(buf) } - } - - fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { - unsafe { - ManuallyDrop::new(FileDesc::from_raw_fd(hermit_abi::STDIN_FILENO)).read_vectored(bufs) - } - } - - #[inline] - fn is_read_vectored(&self) -> bool { - true - } -} - -impl Stdout { - pub const fn new() -> Stdout { - Stdout - } -} - -impl io::Write for Stdout { - fn write(&mut self, buf: &[u8]) -> io::Result { - unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(hermit_abi::STDOUT_FILENO)).write(buf) } - } - - fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { - unsafe { - ManuallyDrop::new(FileDesc::from_raw_fd(hermit_abi::STDOUT_FILENO)).write_vectored(bufs) - } - } - - #[inline] - fn is_write_vectored(&self) -> bool { - true - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl Stderr { - pub const fn new() -> Stderr { - Stderr - } -} - -impl io::Write for Stderr { - fn write(&mut self, buf: &[u8]) -> io::Result { - unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(hermit_abi::STDERR_FILENO)).write(buf) } - } - - fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { - unsafe { - ManuallyDrop::new(FileDesc::from_raw_fd(hermit_abi::STDERR_FILENO)).write_vectored(bufs) - } - } - - #[inline] - fn is_write_vectored(&self) -> bool { - true - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -pub const STDIN_BUF_SIZE: usize = 128; - -pub fn is_ebadf(err: &io::Error) -> bool { - err.raw_os_error() == Some(hermit_abi::EBADF) -} - -pub fn panic_output() -> Option { - Some(Stderr::new()) -} diff --git a/std/src/sys/pal/hermit/thread.rs b/std/src/sys/pal/hermit/thread.rs index 41f2c3e212355..bb68a824fc313 100644 --- a/std/src/sys/pal/hermit/thread.rs +++ b/std/src/sys/pal/hermit/thread.rs @@ -41,9 +41,9 @@ impl Thread { unsafe { drop(Box::from_raw(p)); } - Err(io::const_io_error!(io::ErrorKind::Uncategorized, "Unable to create thread!")) + Err(io::const_error!(io::ErrorKind::Uncategorized, "unable to create thread!")) } else { - Ok(Thread { tid: tid }) + Ok(Thread { tid }) }; extern "C" fn thread_start(main: usize) { diff --git a/std/src/sys/pal/hermit/time.rs b/std/src/sys/pal/hermit/time.rs index e0b6eb76b03af..f76a5f96c8750 100644 --- a/std/src/sys/pal/hermit/time.rs +++ b/std/src/sys/pal/hermit/time.rs @@ -22,7 +22,7 @@ impl Timespec { const fn new(tv_sec: i64, tv_nsec: i32) -> Timespec { assert!(tv_nsec >= 0 && tv_nsec < NSEC_PER_SEC); // SAFETY: The assert above checks tv_nsec is within the valid range - Timespec { t: timespec { tv_sec: tv_sec, tv_nsec: tv_nsec } } + Timespec { t: timespec { tv_sec, tv_nsec } } } fn sub_timespec(&self, other: &Timespec) -> Result { diff --git a/std/src/sys/pal/itron/abi.rs b/std/src/sys/pal/itron/abi.rs index 5eb14bb7e534b..49b5251fc0eb6 100644 --- a/std/src/sys/pal/itron/abi.rs +++ b/std/src/sys/pal/itron/abi.rs @@ -132,7 +132,7 @@ pub struct T_CTSK { pub stk: *mut u8, } -extern "C" { +unsafe extern "C" { #[link_name = "__asp3_acre_tsk"] pub fn acre_tsk(pk_ctsk: *const T_CTSK) -> ER_ID; #[link_name = "__asp3_get_tid"] diff --git a/std/src/sys/pal/itron/thread.rs b/std/src/sys/pal/itron/thread.rs index 04095e1a7cf99..d1481f827e1e1 100644 --- a/std/src/sys/pal/itron/thread.rs +++ b/std/src/sys/pal/itron/thread.rs @@ -80,7 +80,7 @@ const LIFECYCLE_EXITED_OR_FINISHED_OR_JOIN_FINALIZE: usize = usize::MAX; // there's no single value for `JOINING` // 64KiB for 32-bit ISAs, 128KiB for 64-bit ISAs. -pub const DEFAULT_MIN_STACK_SIZE: usize = 0x4000 * crate::mem::size_of::(); +pub const DEFAULT_MIN_STACK_SIZE: usize = 0x4000 * size_of::(); impl Thread { /// # Safety diff --git a/std/src/sys/pal/itron/time/tests.rs b/std/src/sys/pal/itron/time/tests.rs index 28db4f8b6799f..d14035d9da49f 100644 --- a/std/src/sys/pal/itron/time/tests.rs +++ b/std/src/sys/pal/itron/time/tests.rs @@ -8,24 +8,26 @@ fn reltim2dur(t: u64) -> Duration { fn test_dur2reltims() { assert_eq!(dur2reltims(reltim2dur(0)).collect::>(), vec![]); assert_eq!(dur2reltims(reltim2dur(42)).collect::>(), vec![42]); - assert_eq!(dur2reltims(reltim2dur(abi::TMAX_RELTIM as u64)).collect::>(), vec![ - abi::TMAX_RELTIM - ]); - assert_eq!(dur2reltims(reltim2dur(abi::TMAX_RELTIM as u64 + 10000)).collect::>(), vec![ - abi::TMAX_RELTIM, - 10000 - ]); + assert_eq!( + dur2reltims(reltim2dur(abi::TMAX_RELTIM as u64)).collect::>(), + vec![abi::TMAX_RELTIM] + ); + assert_eq!( + dur2reltims(reltim2dur(abi::TMAX_RELTIM as u64 + 10000)).collect::>(), + vec![abi::TMAX_RELTIM, 10000] + ); } #[test] fn test_dur2tmos() { assert_eq!(dur2tmos(reltim2dur(0)).collect::>(), vec![0]); assert_eq!(dur2tmos(reltim2dur(42)).collect::>(), vec![42]); - assert_eq!(dur2tmos(reltim2dur(abi::TMAX_RELTIM as u64)).collect::>(), vec![ - abi::TMAX_RELTIM - ]); - assert_eq!(dur2tmos(reltim2dur(abi::TMAX_RELTIM as u64 + 10000)).collect::>(), vec![ - abi::TMAX_RELTIM, - 10000 - ]); + assert_eq!( + dur2tmos(reltim2dur(abi::TMAX_RELTIM as u64)).collect::>(), + vec![abi::TMAX_RELTIM] + ); + assert_eq!( + dur2tmos(reltim2dur(abi::TMAX_RELTIM as u64 + 10000)).collect::>(), + vec![abi::TMAX_RELTIM, 10000] + ); } diff --git a/std/src/sys/pal/sgx/abi/mem.rs b/std/src/sys/pal/sgx/abi/mem.rs index 18e6d5b3fa24d..e6ce15bed3cfd 100644 --- a/std/src/sys/pal/sgx/abi/mem.rs +++ b/std/src/sys/pal/sgx/abi/mem.rs @@ -12,7 +12,7 @@ pub(crate) unsafe fn rel_ptr_mut(offset: u64) -> *mut T { (image_base() + offset) as *mut T } -extern "C" { +unsafe extern "C" { static ENCLAVE_SIZE: usize; static HEAP_BASE: u64; static HEAP_SIZE: usize; diff --git a/std/src/sys/pal/sgx/abi/mod.rs b/std/src/sys/pal/sgx/abi/mod.rs index d8836452e7555..2c805a4d0af01 100644 --- a/std/src/sys/pal/sgx/abi/mod.rs +++ b/std/src/sys/pal/sgx/abi/mod.rs @@ -6,7 +6,7 @@ use core::sync::atomic::{AtomicUsize, Ordering}; use crate::io::Write; // runtime features -pub(super) mod panic; +pub mod panic; mod reloc; // library features @@ -23,7 +23,7 @@ global_asm!(include_str!("entry.S"), options(att_syntax)); struct EntryReturn(u64, u64); #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] unsafe extern "C" fn tcs_init(secondary: bool) { // Be very careful when changing this code: it runs before the binary has been // relocated. Any indirect accesses to symbols will likely fail. @@ -60,7 +60,7 @@ unsafe extern "C" fn tcs_init(secondary: bool) { // (main function exists). If this is a library, the crate author should be // able to specify this #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn entry(p1: u64, p2: u64, p3: u64, secondary: bool, p4: u64, p5: u64) -> EntryReturn { // FIXME: how to support TLS in library mode? let tls = Box::new(tls::Tls::new()); @@ -73,7 +73,7 @@ extern "C" fn entry(p1: u64, p2: u64, p3: u64, secondary: bool, p4: u64, p5: u64 EntryReturn(0, 0) } else { - extern "C" { + unsafe extern "C" { fn main(argc: isize, argv: *const *const u8) -> isize; } @@ -103,7 +103,7 @@ pub(super) fn exit_with_code(code: isize) -> ! { } #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn abort_reentry() -> ! { usercalls::exit(false) } diff --git a/std/src/sys/pal/sgx/abi/panic.rs b/std/src/sys/pal/sgx/abi/panic.rs index c06b97ee3674a..67af062b0fffe 100644 --- a/std/src/sys/pal/sgx/abi/panic.rs +++ b/std/src/sys/pal/sgx/abi/panic.rs @@ -2,7 +2,7 @@ use super::usercalls::alloc::UserRef; use crate::io::{self, Write}; use crate::{cmp, mem}; -extern "C" { +unsafe extern "C" { fn take_debug_panic_buf_ptr() -> *mut u8; static DEBUG: u8; } diff --git a/std/src/sys/pal/sgx/abi/reloc.rs b/std/src/sys/pal/sgx/abi/reloc.rs index 02dff0ad29fc3..a4f5e4a0936f4 100644 --- a/std/src/sys/pal/sgx/abi/reloc.rs +++ b/std/src/sys/pal/sgx/abi/reloc.rs @@ -11,7 +11,7 @@ struct Rela { } pub fn relocate_elf_rela() { - extern "C" { + unsafe extern "C" { static RELA: u64; static RELACOUNT: usize; } diff --git a/std/src/sys/pal/sgx/abi/thread.rs b/std/src/sys/pal/sgx/abi/thread.rs index 2b23e368cc31a..9b37e2baf3642 100644 --- a/std/src/sys/pal/sgx/abi/thread.rs +++ b/std/src/sys/pal/sgx/abi/thread.rs @@ -6,7 +6,7 @@ use fortanix_sgx_abi::Tcs; /// is a one-to-one correspondence of the ID to the address of the TCS. #[unstable(feature = "sgx_platform", issue = "56975")] pub fn current() -> Tcs { - extern "C" { + unsafe extern "C" { fn get_tcs_addr() -> *mut u8; } let addr = unsafe { get_tcs_addr() }; diff --git a/std/src/sys/pal/sgx/abi/tls/mod.rs b/std/src/sys/pal/sgx/abi/tls/mod.rs index 34fc2f20d2214..8e2b271f1c970 100644 --- a/std/src/sys/pal/sgx/abi/tls/mod.rs +++ b/std/src/sys/pal/sgx/abi/tls/mod.rs @@ -12,17 +12,17 @@ const TLS_KEYS: usize = 128; // Same as POSIX minimum const TLS_KEYS_BITSET_SIZE: usize = (TLS_KEYS + (USIZE_BITS - 1)) / USIZE_BITS; #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_KEY_IN_USEE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_KEY_IN_USEE")] static TLS_KEY_IN_USE: SyncBitset = SYNC_BITSET_INIT; macro_rules! dup { ((* $($exp:tt)*) $($val:tt)*) => (dup!( ($($exp)*) $($val)* $($val)* )); (() $($val:tt)*) => ([$($val),*]) } #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_DESTRUCTORE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_DESTRUCTORE")] static TLS_DESTRUCTOR: [AtomicUsize; TLS_KEYS] = dup!((* * * * * * *) (AtomicUsize::new(0))); -extern "C" { +unsafe extern "C" { fn get_tls_ptr() -> *const u8; fn set_tls_ptr(tls: *const u8); } diff --git a/std/src/sys/pal/sgx/abi/usercalls/alloc.rs b/std/src/sys/pal/sgx/abi/usercalls/alloc.rs index 5069ab82ccc90..301e3299c0572 100644 --- a/std/src/sys/pal/sgx/abi/usercalls/alloc.rs +++ b/std/src/sys/pal/sgx/abi/usercalls/alloc.rs @@ -63,7 +63,7 @@ unsafe impl UserSafeSized for [T; 2] {} /// A type that can be represented in memory as one or more `UserSafeSized`s. #[unstable(feature = "sgx_platform", issue = "56975")] pub unsafe trait UserSafe { - /// Equivalent to `mem::align_of::`. + /// Equivalent to `align_of::`. fn align_of() -> usize; /// Constructs a pointer to `Self` given a memory range in user space. @@ -120,7 +120,7 @@ pub unsafe trait UserSafe { let is_aligned = |p: *const u8| -> bool { p.is_aligned_to(Self::align_of()) }; assert!(is_aligned(ptr as *const u8)); - assert!(is_user_range(ptr as _, mem::size_of_val(unsafe { &*ptr }))); + assert!(is_user_range(ptr as _, size_of_val(unsafe { &*ptr }))); assert!(!ptr.is_null()); } } @@ -128,11 +128,11 @@ pub unsafe trait UserSafe { #[unstable(feature = "sgx_platform", issue = "56975")] unsafe impl UserSafe for T { fn align_of() -> usize { - mem::align_of::() + align_of::() } unsafe fn from_raw_sized_unchecked(ptr: *mut u8, size: usize) -> *mut Self { - assert_eq!(size, mem::size_of::()); + assert_eq!(size, size_of::()); ptr as _ } } @@ -140,7 +140,7 @@ unsafe impl UserSafe for T { #[unstable(feature = "sgx_platform", issue = "56975")] unsafe impl UserSafe for [T] { fn align_of() -> usize { - mem::align_of::() + align_of::() } /// # Safety @@ -155,7 +155,7 @@ unsafe impl UserSafe for [T] { /// /// * the element size is not a factor of the size unsafe fn from_raw_sized_unchecked(ptr: *mut u8, size: usize) -> *mut Self { - let elem_size = mem::size_of::(); + let elem_size = size_of::(); assert_eq!(size % elem_size, 0); let len = size / elem_size; // SAFETY: The caller must uphold the safety contract for `from_raw_sized_unchecked` @@ -239,7 +239,7 @@ where /// Copies `val` into freshly allocated space in user memory. pub fn new_from_enclave(val: &T) -> Self { unsafe { - let mut user = Self::new_uninit_bytes(mem::size_of_val(val)); + let mut user = Self::new_uninit_bytes(size_of_val(val)); user.copy_from_enclave(val); user } @@ -277,7 +277,7 @@ where { /// Allocates space for `T` in user memory. pub fn uninitialized() -> Self { - Self::new_uninit_bytes(mem::size_of::()) + Self::new_uninit_bytes(size_of::()) } } @@ -288,7 +288,7 @@ where { /// Allocates space for a `[T]` of `n` elements in user memory. pub fn uninitialized(n: usize) -> Self { - Self::new_uninit_bytes(n * mem::size_of::()) + Self::new_uninit_bytes(n * size_of::()) } /// Creates an owned `User<[T]>` from a raw thin pointer and a slice length. @@ -306,9 +306,7 @@ where /// * The pointed-to range does not fit in the address space /// * The pointed-to range is not in user memory pub unsafe fn from_raw_parts(ptr: *mut T, len: usize) -> Self { - User(unsafe { - NonNull::new_userref(<[T]>::from_raw_sized(ptr as _, len * mem::size_of::())) - }) + User(unsafe { NonNull::new_userref(<[T]>::from_raw_sized(ptr as _, len * size_of::())) }) } } @@ -326,7 +324,7 @@ where // `<*const u8>::align_offset` aren't _guaranteed_ to compute the largest // possible middle region, and as such can't be used. fn u64_align_to_guaranteed(ptr: *const u8, mut len: usize) -> (usize, usize, usize) { - const QWORD_SIZE: usize = mem::size_of::(); + const QWORD_SIZE: usize = size_of::(); let offset = ptr as usize % QWORD_SIZE; @@ -532,11 +530,11 @@ where /// the source. This can happen for dynamically-sized types such as slices. pub fn copy_from_enclave(&mut self, val: &T) { unsafe { - assert_eq!(mem::size_of_val(val), mem::size_of_val(&*self.0.get())); + assert_eq!(size_of_val(val), size_of_val(&*self.0.get())); copy_to_userspace( val as *const T as *const u8, self.0.get() as *mut T as *mut u8, - mem::size_of_val(val), + size_of_val(val), ); } } @@ -548,11 +546,11 @@ where /// the source. This can happen for dynamically-sized types such as slices. pub fn copy_to_enclave(&self, dest: &mut T) { unsafe { - assert_eq!(mem::size_of_val(dest), mem::size_of_val(&*self.0.get())); + assert_eq!(size_of_val(dest), size_of_val(&*self.0.get())); copy_from_userspace( self.0.get() as *const T as *const u8, dest as *mut T as *mut u8, - mem::size_of_val(dest), + size_of_val(dest), ); } } @@ -577,7 +575,7 @@ where pub fn to_enclave(&self) -> T { unsafe { let mut data = mem::MaybeUninit::uninit(); - copy_from_userspace(self.0.get() as _, data.as_mut_ptr() as _, mem::size_of::()); + copy_from_userspace(self.0.get() as _, data.as_mut_ptr() as _, size_of::()); data.assume_init() } } @@ -602,9 +600,7 @@ where /// * The pointed-to range is not in user memory pub unsafe fn from_raw_parts<'a>(ptr: *const T, len: usize) -> &'a Self { // SAFETY: The caller must uphold the safety contract for `from_raw_parts`. - unsafe { - &*(<[T]>::from_raw_sized(ptr as _, len * mem::size_of::()).as_ptr() as *const Self) - } + unsafe { &*(<[T]>::from_raw_sized(ptr as _, len * size_of::()).as_ptr() as *const Self) } } /// Creates a `&mut UserRef<[T]>` from a raw thin pointer and a slice length. @@ -624,7 +620,7 @@ where pub unsafe fn from_raw_parts_mut<'a>(ptr: *mut T, len: usize) -> &'a mut Self { // SAFETY: The caller must uphold the safety contract for `from_raw_parts_mut`. unsafe { - &mut *(<[T]>::from_raw_sized(ptr as _, len * mem::size_of::()).as_ptr() as *mut Self) + &mut *(<[T]>::from_raw_sized(ptr as _, len * size_of::()).as_ptr() as *mut Self) } } @@ -744,7 +740,7 @@ where fn drop(&mut self) { unsafe { let ptr = (*self.0.as_ptr()).0.get(); - super::free(ptr as _, mem::size_of_val(&mut *ptr), T::align_of()); + super::free(ptr as _, size_of_val(&mut *ptr), T::align_of()); } } } diff --git a/std/src/sys/pal/sgx/abi/usercalls/raw.rs b/std/src/sys/pal/sgx/abi/usercalls/raw.rs index 943b771498f8f..28fbbc3c51816 100644 --- a/std/src/sys/pal/sgx/abi/usercalls/raw.rs +++ b/std/src/sys/pal/sgx/abi/usercalls/raw.rs @@ -9,7 +9,7 @@ use crate::ptr::NonNull; #[repr(C)] struct UsercallReturn(u64, u64); -extern "C" { +unsafe extern "C" { fn usercall(nr: NonZero, p1: u64, p2: u64, abort: u64, p3: u64, p4: u64) -> UsercallReturn; } diff --git a/std/src/sys/pal/sgx/args.rs b/std/src/sys/pal/sgx/args.rs index a72a041da6cc9..e62bf383954eb 100644 --- a/std/src/sys/pal/sgx/args.rs +++ b/std/src/sys/pal/sgx/args.rs @@ -7,7 +7,7 @@ use crate::sys_common::FromInner; use crate::{fmt, slice}; #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE")] static ARGS: AtomicUsize = AtomicUsize::new(0); type ArgsStore = Vec; diff --git a/std/src/sys/pal/sgx/fd.rs b/std/src/sys/pal/sgx/fd.rs index c41b527cff798..3bb3189a1d127 100644 --- a/std/src/sys/pal/sgx/fd.rs +++ b/std/src/sys/pal/sgx/fd.rs @@ -12,7 +12,7 @@ pub struct FileDesc { impl FileDesc { pub fn new(fd: Fd) -> FileDesc { - FileDesc { fd: fd } + FileDesc { fd } } pub fn raw(&self) -> Fd { diff --git a/std/src/sys/pal/sgx/libunwind_integration.rs b/std/src/sys/pal/sgx/libunwind_integration.rs index debfd324c864e..b5419ad05decd 100644 --- a/std/src/sys/pal/sgx/libunwind_integration.rs +++ b/std/src/sys/pal/sgx/libunwind_integration.rs @@ -4,6 +4,7 @@ #![cfg(not(test))] use crate::sys::sync::RwLock; +use crate::{slice, str}; // Verify that the byte pattern libunwind uses to initialize an RwLock is // equivalent to the value of RwLock::new(). If the value changes, @@ -15,7 +16,7 @@ const _: () = unsafe { const EINVAL: i32 = 22; -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __rust_rwlock_rdlock(p: *mut RwLock) -> i32 { if p.is_null() { return EINVAL; @@ -27,7 +28,7 @@ pub unsafe extern "C" fn __rust_rwlock_rdlock(p: *mut RwLock) -> i32 { return 0; } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __rust_rwlock_wrlock(p: *mut RwLock) -> i32 { if p.is_null() { return EINVAL; @@ -36,7 +37,7 @@ pub unsafe extern "C" fn __rust_rwlock_wrlock(p: *mut RwLock) -> i32 { return 0; } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __rust_rwlock_unlock(p: *mut RwLock) -> i32 { if p.is_null() { return EINVAL; @@ -44,3 +45,14 @@ pub unsafe extern "C" fn __rust_rwlock_unlock(p: *mut RwLock) -> i32 { unsafe { (*p).write_unlock() }; return 0; } + +#[unsafe(no_mangle)] +pub unsafe extern "C" fn __rust_print_err(m: *mut u8, s: i32) { + if s < 0 { + return; + } + let buf = unsafe { slice::from_raw_parts(m as *const u8, s as _) }; + if let Ok(s) = str::from_utf8(&buf[..buf.iter().position(|&b| b == 0).unwrap_or(buf.len())]) { + eprint!("{s}"); + } +} diff --git a/std/src/sys/pal/sgx/mod.rs b/std/src/sys/pal/sgx/mod.rs index 586ccd18c2f57..bb419c2530ec1 100644 --- a/std/src/sys/pal/sgx/mod.rs +++ b/std/src/sys/pal/sgx/mod.rs @@ -12,18 +12,12 @@ pub mod abi; pub mod args; pub mod env; pub mod fd; -#[path = "../unsupported/fs.rs"] -pub mod fs; -#[path = "../unsupported/io.rs"] -pub mod io; mod libunwind_integration; -pub mod net; pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; #[path = "../unsupported/process.rs"] pub mod process; -pub mod stdio; pub mod thread; pub mod thread_parking; pub mod time; @@ -48,7 +42,7 @@ pub fn unsupported() -> crate::io::Result { } pub fn unsupported_err() -> crate::io::Error { - crate::io::const_io_error!(ErrorKind::Unsupported, "operation not supported on SGX yet") + crate::io::const_error!(ErrorKind::Unsupported, "operation not supported on SGX yet") } /// This function is used to implement various functions that doesn't exist, @@ -59,7 +53,7 @@ pub fn unsupported_err() -> crate::io::Error { pub fn sgx_ineffective(v: T) -> crate::io::Result { static SGX_INEFFECTIVE_ERROR: AtomicBool = AtomicBool::new(false); if SGX_INEFFECTIVE_ERROR.load(Ordering::Relaxed) { - Err(crate::io::const_io_error!( + Err(crate::io::const_error!( ErrorKind::Uncategorized, "operation can't be trusted to have any effect on SGX", )) @@ -126,7 +120,7 @@ pub fn abort_internal() -> ! { // This function is needed by the panic runtime. The symbol is named in // pre-link args for the target specification, so keep that in sync. #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] // NB. used by both libunwind and libpanic_abort pub extern "C" fn __rust_abort() { abort_internal(); diff --git a/std/src/sys/pal/sgx/os.rs b/std/src/sys/pal/sgx/os.rs index 46af710aa396c..b1ec2afd764e6 100644 --- a/std/src/sys/pal/sgx/os.rs +++ b/std/src/sys/pal/sgx/os.rs @@ -74,10 +74,10 @@ pub fn current_exe() -> io::Result { } #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx2os3ENVE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os3ENVE")] static ENV: AtomicUsize = AtomicUsize::new(0); #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx2os8ENV_INITE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os8ENV_INITE")] static ENV_INIT: Once = Once::new(); type EnvStore = Mutex>; diff --git a/std/src/sys/pal/sgx/thread.rs b/std/src/sys/pal/sgx/thread.rs index cecd53c352c5a..b6932df431f42 100644 --- a/std/src/sys/pal/sgx/thread.rs +++ b/std/src/sys/pal/sgx/thread.rs @@ -46,7 +46,7 @@ mod task_queue { } #[cfg_attr(test, linkage = "available_externally")] - #[export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE"] + #[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE")] static TASK_QUEUE: Mutex> = Mutex::new(Vec::new()); pub(super) fn lock() -> MutexGuard<'static, Vec> { diff --git a/std/src/sys/pal/solid/abi/fs.rs b/std/src/sys/pal/solid/abi/fs.rs index 6864a3e7745b9..7f2b1f83e8561 100644 --- a/std/src/sys/pal/solid/abi/fs.rs +++ b/std/src/sys/pal/solid/abi/fs.rs @@ -31,7 +31,7 @@ pub const DT_WHT: c_uchar = 14; pub type S_DIR = c_int; -extern "C" { +unsafe extern "C" { pub fn SOLID_FS_Open(fd: *mut c_int, path: *const c_char, mode: c_int) -> c_int; pub fn SOLID_FS_Close(fd: c_int) -> c_int; pub fn SOLID_FS_Read(fd: c_int, buf: *mut u8, size: usize, result: *mut usize) -> c_int; diff --git a/std/src/sys/pal/solid/abi/mod.rs b/std/src/sys/pal/solid/abi/mod.rs index 4d09705721748..819f93f407423 100644 --- a/std/src/sys/pal/solid/abi/mod.rs +++ b/std/src/sys/pal/solid/abi/mod.rs @@ -33,27 +33,27 @@ pub struct SOLID_RTC_TIME { pub tm_wday: c_int, } -extern "C" { +unsafe extern "C" { pub fn SOLID_RTC_ReadTime(time: *mut SOLID_RTC_TIME) -> c_int; } // `solid_log.h` -extern "C" { +unsafe extern "C" { pub fn SOLID_LOG_write(s: *const u8, l: usize); } // `solid_mem.h` -extern "C" { +unsafe extern "C" { pub fn SOLID_TLS_AddDestructor(id: i32, dtor: unsafe extern "C" fn(*mut u8)); } // `solid_rng.h` -extern "C" { +unsafe extern "C" { pub fn SOLID_RNG_SampleRandomBytes(buffer: *mut u8, length: usize) -> c_int; } // `rwlock.h` -extern "C" { +unsafe extern "C" { pub fn rwl_loc_rdl(id: ID) -> ER; pub fn rwl_loc_wrl(id: ID) -> ER; pub fn rwl_ploc_rdl(id: ID) -> ER; diff --git a/std/src/sys/pal/solid/abi/sockets.rs b/std/src/sys/pal/solid/abi/sockets.rs index 3c9e3f9ffb95d..80802dd42e248 100644 --- a/std/src/sys/pal/solid/abi/sockets.rs +++ b/std/src/sys/pal/solid/abi/sockets.rs @@ -158,7 +158,7 @@ pub struct fd_set { pub fds: [c_int; SOLID_NET_FD_SETSIZE], } -extern "C" { +unsafe extern "C" { #[link_name = "SOLID_NET_StrError"] pub fn strerror(errnum: c_int) -> *const c_char; diff --git a/std/src/sys/pal/solid/error.rs b/std/src/sys/pal/solid/error.rs index e092497856d43..b399463c0c280 100644 --- a/std/src/sys/pal/solid/error.rs +++ b/std/src/sys/pal/solid/error.rs @@ -1,6 +1,7 @@ pub use self::itron::error::{ItronError as SolidError, expect_success}; -use super::{abi, itron, net}; +use super::{abi, itron}; use crate::io::ErrorKind; +use crate::sys::net; /// Describe the specified SOLID error code. Returns `None` if it's an /// undefined error code. diff --git a/std/src/sys/pal/solid/mod.rs b/std/src/sys/pal/solid/mod.rs index d41042be51844..e4a61fdcfe3e7 100644 --- a/std/src/sys/pal/solid/mod.rs +++ b/std/src/sys/pal/solid/mod.rs @@ -22,15 +22,11 @@ pub mod env; // `error` is `pub(crate)` so that it can be accessed by `itron/error.rs` as // `crate::sys::error` pub(crate) mod error; -pub mod fs; -pub mod io; -pub mod net; pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; #[path = "../unsupported/process.rs"] pub mod process; -pub mod stdio; pub use self::itron::{thread, thread_parking}; pub mod time; @@ -51,7 +47,7 @@ pub fn unsupported_err() -> crate::io::Error { #[inline] pub fn is_interrupted(code: i32) -> bool { - net::is_interrupted(code) + crate::sys::net::is_interrupted(code) } pub fn decode_error_kind(code: i32) -> crate::io::ErrorKind { diff --git a/std/src/sys/pal/solid/os.rs b/std/src/sys/pal/solid/os.rs index d8afcb91f67f2..e3b2e0aa50f4a 100644 --- a/std/src/sys/pal/solid/os.rs +++ b/std/src/sys/pal/solid/os.rs @@ -129,7 +129,7 @@ impl Iterator for Env { /// Returns a vector of (variable, value) byte-vector pairs for all the /// environment variables of the current process. pub fn env() -> Env { - extern "C" { + unsafe extern "C" { static mut environ: *const *const c_char; } @@ -204,7 +204,7 @@ pub unsafe fn unsetenv(n: &OsStr) -> io::Result<()> { /// In kmclib, `setenv` and `unsetenv` don't always set `errno`, so this /// function just returns a generic error. fn cvt_env(t: c_int) -> io::Result { - if t == -1 { Err(io::const_io_error!(io::ErrorKind::Uncategorized, "failure")) } else { Ok(t) } + if t == -1 { Err(io::const_error!(io::ErrorKind::Uncategorized, "failure")) } else { Ok(t) } } pub fn temp_dir() -> PathBuf { diff --git a/std/src/sys/pal/solid/time.rs b/std/src/sys/pal/solid/time.rs index 3f9bbb0b63cdb..c39d715c6a6f6 100644 --- a/std/src/sys/pal/solid/time.rs +++ b/std/src/sys/pal/solid/time.rs @@ -35,7 +35,7 @@ impl SystemTime { SystemTime(t) } - pub(super) fn from_time_t(t: abi::time_t) -> Self { + pub fn from_time_t(t: abi::time_t) -> Self { Self(t) } diff --git a/std/src/sys/pal/teeos/mod.rs b/std/src/sys/pal/teeos/mod.rs index 60a227afb84e3..41b2512159289 100644 --- a/std/src/sys/pal/teeos/mod.rs +++ b/std/src/sys/pal/teeos/mod.rs @@ -11,22 +11,24 @@ pub mod args; #[path = "../unsupported/env.rs"] pub mod env; //pub mod fd; -#[path = "../unsupported/fs.rs"] -pub mod fs; -#[path = "../unsupported/io.rs"] -pub mod io; -pub mod net; pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; #[path = "../unsupported/process.rs"] pub mod process; -pub mod stdio; pub mod thread; #[allow(non_upper_case_globals)] #[path = "../unix/time.rs"] pub mod time; +#[path = "../unix/sync"] +pub mod sync { + mod condvar; + mod mutex; + pub use condvar::Condvar; + pub use mutex::Mutex; +} + use crate::io::ErrorKind; pub fn abort_internal() -> ! { @@ -63,7 +65,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { libc::ECONNREFUSED => ConnectionRefused, libc::ECONNRESET => ConnectionReset, libc::EDEADLK => Deadlock, - libc::EDQUOT => FilesystemQuotaExceeded, + libc::EDQUOT => QuotaExceeded, libc::EEXIST => AlreadyExists, libc::EFBIG => FileTooLarge, libc::EHOSTUNREACH => HostUnreachable, @@ -143,5 +145,5 @@ pub fn unsupported() -> std_io::Result { } pub fn unsupported_err() -> std_io::Error { - std_io::Error::new(std_io::ErrorKind::Unsupported, "operation not supported on this platform") + std_io::Error::UNSUPPORTED_PLATFORM } diff --git a/std/src/sys/pal/teeos/os.rs b/std/src/sys/pal/teeos/os.rs index 82cade771b513..bf6945811ab0e 100644 --- a/std/src/sys/pal/teeos/os.rs +++ b/std/src/sys/pal/teeos/os.rs @@ -107,11 +107,11 @@ pub fn getenv(_: &OsStr) -> Option { } pub unsafe fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> { - Err(io::Error::new(io::ErrorKind::Unsupported, "cannot set env vars on this platform")) + Err(io::const_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform")) } pub unsafe fn unsetenv(_: &OsStr) -> io::Result<()> { - Err(io::Error::new(io::ErrorKind::Unsupported, "cannot unset env vars on this platform")) + Err(io::const_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform")) } pub fn temp_dir() -> PathBuf { diff --git a/std/src/sys/pal/teeos/thread.rs b/std/src/sys/pal/teeos/thread.rs index 15c65240ddd2a..e3b4908f85863 100644 --- a/std/src/sys/pal/teeos/thread.rs +++ b/std/src/sys/pal/teeos/thread.rs @@ -16,7 +16,7 @@ pub struct Thread { unsafe impl Send for Thread {} unsafe impl Sync for Thread {} -extern "C" { +unsafe extern "C" { pub fn TEE_Wait(timeout: u32) -> u32; } @@ -56,7 +56,7 @@ impl Thread { } }; - let ret = libc::pthread_create(&mut native, &attr, thread_start, p as *mut _); + let ret = unsafe { libc::pthread_create(&mut native, &attr, thread_start, p as *mut _) }; // Note: if the thread creation fails and this assert fails, then p will // be leaked. However, an alternative design could cause double-free // which is clearly worse. diff --git a/std/src/sys/pal/uefi/args.rs b/std/src/sys/pal/uefi/args.rs index bdf6f5a0c1c34..0c29caf2db676 100644 --- a/std/src/sys/pal/uefi/args.rs +++ b/std/src/sys/pal/uefi/args.rs @@ -4,7 +4,6 @@ use super::helpers; use crate::env::current_exe; use crate::ffi::OsString; use crate::iter::Iterator; -use crate::mem::size_of; use crate::{fmt, vec}; pub struct Args { diff --git a/std/src/sys/pal/uefi/helpers.rs b/std/src/sys/pal/uefi/helpers.rs index abc8e69a285f3..0a2a8f5ef67be 100644 --- a/std/src/sys/pal/uefi/helpers.rs +++ b/std/src/sys/pal/uefi/helpers.rs @@ -10,14 +10,16 @@ //! - More information about protocols can be found [here](https://edk2-docs.gitbook.io/edk-ii-uefi-driver-writer-s-guide/3_foundation/36_protocols_and_handles) use r_efi::efi::{self, Guid}; -use r_efi::protocols::{device_path, device_path_to_text, shell}; +use r_efi::protocols::{device_path, device_path_to_text, service_binding, shell}; use crate::ffi::{OsStr, OsString}; -use crate::io::{self, const_io_error}; -use crate::mem::{MaybeUninit, size_of}; +use crate::io::{self, const_error}; +use crate::marker::PhantomData; +use crate::mem::MaybeUninit; use crate::os::uefi::env::boot_services; use crate::os::uefi::ffi::{OsStrExt, OsStringExt}; use crate::os::uefi::{self}; +use crate::path::Path; use crate::ptr::NonNull; use crate::slice; use crate::sync::atomic::{AtomicPtr, Ordering}; @@ -30,7 +32,7 @@ type BootUninstallMultipleProtocolInterfaces = unsafe extern "efiapi" fn(_: r_efi::efi::Handle, _: ...) -> r_efi::efi::Status; const BOOT_SERVICES_UNAVAILABLE: io::Error = - const_io_error!(io::ErrorKind::Other, "Boot Services are no longer available"); + const_error!(io::ErrorKind::Other, "Boot Services are no longer available"); /// Locates Handles with a particular Protocol GUID. /// @@ -114,7 +116,7 @@ pub(crate) fn open_protocol( Err(crate::io::Error::from_raw_os_error(r.as_usize())) } else { NonNull::new(unsafe { protocol.assume_init() }) - .ok_or(const_io_error!(io::ErrorKind::Other, "null protocol")) + .ok_or(const_error!(io::ErrorKind::Other, "null protocol")) } } @@ -134,7 +136,7 @@ pub(crate) fn create_event( if r.is_error() { Err(crate::io::Error::from_raw_os_error(r.as_usize())) } else { - NonNull::new(event).ok_or(const_io_error!(io::ErrorKind::Other, "null protocol")) + NonNull::new(event).ok_or(const_error!(io::ErrorKind::Other, "null protocol")) } } @@ -155,10 +157,8 @@ pub(crate) unsafe fn close_event(evt: NonNull) -> io::Result /// /// Note: Some protocols need to be manually freed. It is the caller's responsibility to do so. pub(crate) fn image_handle_protocol(protocol_guid: Guid) -> io::Result> { - let system_handle = uefi::env::try_image_handle().ok_or(io::const_io_error!( - io::ErrorKind::NotFound, - "Protocol not found in Image handle" - ))?; + let system_handle = uefi::env::try_image_handle() + .ok_or(io::const_error!(io::ErrorKind::NotFound, "protocol not found in Image handle"))?; open_protocol(system_handle, protocol_guid) } @@ -178,7 +178,7 @@ pub(crate) fn device_path_to_text(path: NonNull) -> io::R }; let path = os_string_from_raw(path_ptr) - .ok_or(io::const_io_error!(io::ErrorKind::InvalidData, "Invalid path"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidData, "invalid path"))?; if let Some(boot_services) = crate::os::uefi::env::boot_services() { let boot_services: NonNull = boot_services.cast(); @@ -213,7 +213,7 @@ pub(crate) fn device_path_to_text(path: NonNull) -> io::R } } - Err(io::const_io_error!(io::ErrorKind::NotFound, "No device path to text protocol found")) + Err(io::const_error!(io::ErrorKind::NotFound, "no device path to text protocol found")) } /// Gets RuntimeServices. @@ -224,17 +224,17 @@ pub(crate) fn runtime_services() -> Option> NonNull::new(runtime_services) } -pub(crate) struct DevicePath(NonNull); +pub(crate) struct OwnedDevicePath(NonNull); -impl DevicePath { +impl OwnedDevicePath { pub(crate) fn from_text(p: &OsStr) -> io::Result { fn inner( p: &OsStr, protocol: NonNull, - ) -> io::Result { + ) -> io::Result { let path_vec = p.encode_wide().chain(Some(0)).collect::>(); if path_vec[..path_vec.len() - 1].contains(&0) { - return Err(const_io_error!( + return Err(const_error!( io::ErrorKind::InvalidInput, "strings passed to UEFI cannot contain NULs", )); @@ -243,9 +243,9 @@ impl DevicePath { let path = unsafe { ((*protocol.as_ptr()).convert_text_to_device_path)(path_vec.as_ptr()) }; - NonNull::new(path).map(DevicePath).ok_or_else(|| { - const_io_error!(io::ErrorKind::InvalidFilename, "Invalid Device Path") - }) + NonNull::new(path) + .map(OwnedDevicePath) + .ok_or_else(|| const_error!(io::ErrorKind::InvalidFilename, "invalid Device Path")) } static LAST_VALID_HANDLE: AtomicPtr = @@ -271,18 +271,22 @@ impl DevicePath { } } - io::Result::Err(const_io_error!( + io::Result::Err(const_error!( io::ErrorKind::NotFound, - "DevicePathFromText Protocol not found" + "DevicePathFromText Protocol not found", )) } - pub(crate) fn as_ptr(&self) -> *mut r_efi::protocols::device_path::Protocol { + pub(crate) const fn as_ptr(&self) -> *mut r_efi::protocols::device_path::Protocol { self.0.as_ptr() } + + pub(crate) const fn borrow<'a>(&'a self) -> BorrowedDevicePath<'a> { + BorrowedDevicePath::new(self.0) + } } -impl Drop for DevicePath { +impl Drop for OwnedDevicePath { fn drop(&mut self) { if let Some(bt) = boot_services() { let bt: NonNull = bt.cast(); @@ -293,6 +297,39 @@ impl Drop for DevicePath { } } +impl crate::fmt::Debug for OwnedDevicePath { + fn fmt(&self, f: &mut crate::fmt::Formatter<'_>) -> crate::fmt::Result { + match self.borrow().to_text() { + Ok(p) => p.fmt(f), + Err(_) => f.debug_struct("OwnedDevicePath").finish_non_exhaustive(), + } + } +} + +pub(crate) struct BorrowedDevicePath<'a> { + protocol: NonNull, + phantom: PhantomData<&'a r_efi::protocols::device_path::Protocol>, +} + +impl<'a> BorrowedDevicePath<'a> { + pub(crate) const fn new(protocol: NonNull) -> Self { + Self { protocol, phantom: PhantomData } + } + + pub(crate) fn to_text(&self) -> io::Result { + device_path_to_text(self.protocol) + } +} + +impl<'a> crate::fmt::Debug for BorrowedDevicePath<'a> { + fn fmt(&self, f: &mut crate::fmt::Formatter<'_>) -> crate::fmt::Result { + match self.to_text() { + Ok(p) => p.fmt(f), + Err(_) => f.debug_struct("BorrowedDevicePath").finish_non_exhaustive(), + } + } +} + pub(crate) struct OwnedProtocol { guid: r_efi::efi::Guid, handle: NonNull, @@ -326,7 +363,7 @@ impl OwnedProtocol { }; let handle = NonNull::new(handle) - .ok_or(io::const_io_error!(io::ErrorKind::Uncategorized, "found null handle"))?; + .ok_or(io::const_error!(io::ErrorKind::Uncategorized, "found null handle"))?; Ok(Self { guid, handle, protocol }) } @@ -445,3 +482,80 @@ pub(crate) fn open_shell() -> Option> { None } + +/// Get device path protocol associated with shell mapping. +/// +/// returns None in case no such mapping is exists +pub(crate) fn get_device_path_from_map(map: &Path) -> io::Result> { + let shell = + open_shell().ok_or(io::const_error!(io::ErrorKind::NotFound, "UEFI Shell not found"))?; + let mut path = os_string_to_raw(map.as_os_str()) + .ok_or(io::const_error!(io::ErrorKind::InvalidFilename, "invalid UEFI shell mapping"))?; + + // The Device Path Protocol pointer returned by UEFI shell is owned by the shell and is not + // freed throughout it's lifetime. So it has a 'static lifetime. + let protocol = unsafe { ((*shell.as_ptr()).get_device_path_from_map)(path.as_mut_ptr()) }; + let protocol = NonNull::new(protocol) + .ok_or(io::const_error!(io::ErrorKind::NotFound, "UEFI Shell mapping not found"))?; + + Ok(BorrowedDevicePath::new(protocol)) +} + +/// Helper for UEFI Protocols which are created and destroyed using +/// [EFI_SERVICE_BINDING_PROTCOL](https://uefi.org/specs/UEFI/2.11/11_Protocols_UEFI_Driver_Model.html#efi-service-binding-protocol) +pub(crate) struct ServiceProtocol { + service_guid: r_efi::efi::Guid, + handle: NonNull, + child_handle: NonNull, +} + +impl ServiceProtocol { + #[expect(dead_code)] + pub(crate) fn open(service_guid: r_efi::efi::Guid) -> io::Result { + let handles = locate_handles(service_guid)?; + + for handle in handles { + if let Ok(protocol) = open_protocol::(handle, service_guid) { + let Ok(child_handle) = Self::create_child(protocol) else { + continue; + }; + + return Ok(Self { service_guid, handle, child_handle }); + } + } + + Err(io::const_error!(io::ErrorKind::NotFound, "no service binding protocol found")) + } + + #[expect(dead_code)] + pub(crate) fn child_handle(&self) -> NonNull { + self.child_handle + } + + fn create_child( + sbp: NonNull, + ) -> io::Result> { + let mut child_handle: r_efi::efi::Handle = crate::ptr::null_mut(); + // SAFETY: A new handle is allocated if a pointer to NULL is passed. + let r = unsafe { ((*sbp.as_ptr()).create_child)(sbp.as_ptr(), &mut child_handle) }; + + if r.is_error() { + Err(crate::io::Error::from_raw_os_error(r.as_usize())) + } else { + NonNull::new(child_handle) + .ok_or(const_error!(io::ErrorKind::Other, "null child handle")) + } + } +} + +impl Drop for ServiceProtocol { + fn drop(&mut self) { + if let Ok(sbp) = open_protocol::(self.handle, self.service_guid) + { + // SAFETY: Child handle must be allocated by the current service binding protocol. + let _ = unsafe { + ((*sbp.as_ptr()).destroy_child)(sbp.as_ptr(), self.child_handle.as_ptr()) + }; + } + } +} diff --git a/std/src/sys/pal/uefi/mod.rs b/std/src/sys/pal/uefi/mod.rs index c0ab52f650aa5..714dc392688fb 100644 --- a/std/src/sys/pal/uefi/mod.rs +++ b/std/src/sys/pal/uefi/mod.rs @@ -15,18 +15,11 @@ pub mod args; pub mod env; -#[path = "../unsupported/fs.rs"] -pub mod fs; pub mod helpers; -#[path = "../unsupported/io.rs"] -pub mod io; -#[path = "../unsupported/net.rs"] -pub mod net; pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; pub mod process; -pub mod stdio; pub mod thread; pub mod time; @@ -95,7 +88,7 @@ pub const fn unsupported() -> std_io::Result { #[inline] pub const fn unsupported_err() -> std_io::Error { - std_io::const_io_error!(std_io::ErrorKind::Unsupported, "operation not supported on UEFI",) + std_io::const_error!(std_io::ErrorKind::Unsupported, "operation not supported on UEFI") } pub fn decode_error_kind(code: RawOsError) -> crate::io::ErrorKind { @@ -174,7 +167,7 @@ pub fn abort_internal() -> ! { // This function is needed by the panic runtime. The symbol is named in // pre-link args for the target specification, so keep that in sync. #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn __rust_abort() { abort_internal(); } diff --git a/std/src/sys/pal/uefi/os.rs b/std/src/sys/pal/uefi/os.rs index 27395f7c3c0b3..d26d61890c19e 100644 --- a/std/src/sys/pal/uefi/os.rs +++ b/std/src/sys/pal/uefi/os.rs @@ -17,111 +17,50 @@ pub fn errno() -> RawOsError { pub fn error_string(errno: RawOsError) -> String { // Keep the List in Alphabetical Order // The Messages are taken from UEFI Specification Appendix D - Status Codes - match r_efi::efi::Status::from_usize(errno) { - Status::ABORTED => "The operation was aborted.".to_owned(), - Status::ACCESS_DENIED => "Access was denied.".to_owned(), - Status::ALREADY_STARTED => "The protocol has already been started.".to_owned(), - Status::BAD_BUFFER_SIZE => "The buffer was not the proper size for the request.".to_owned(), - Status::BUFFER_TOO_SMALL => { - "The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs.".to_owned() - } - Status::COMPROMISED_DATA => { - "The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.".to_owned() - } - Status::CONNECTION_FIN => { - "The receiving operation fails because the communication peer has closed the connection and there is no more data in the receive buffer of the instance.".to_owned() - } - Status::CONNECTION_REFUSED => { - "The receiving or transmission operation fails because this connection is refused.".to_owned() - } - Status::CONNECTION_RESET => { - "The connect fails because the connection is reset either by instance itself or the communication peer.".to_owned() - } - Status::CRC_ERROR => "A CRC error was detected.".to_owned(), - Status::DEVICE_ERROR => "The physical device reported an error while attempting the operation.".to_owned() - , - Status::END_OF_FILE => { - "The end of the file was reached.".to_owned() - } - Status::END_OF_MEDIA => { - "Beginning or end of media was reached".to_owned() - } - Status::HOST_UNREACHABLE => { - "The remote host is not reachable.".to_owned() - } - Status::HTTP_ERROR => { - "A HTTP error occurred during the network operation.".to_owned() - } - Status::ICMP_ERROR => { - "An ICMP error occurred during the network operation.".to_owned() - } - Status::INCOMPATIBLE_VERSION => { - "The function encountered an internal version that was incompatible with a version requested by the caller.".to_owned() - } - Status::INVALID_LANGUAGE => { - "The language specified was invalid.".to_owned() - } - Status::INVALID_PARAMETER => { - "A parameter was incorrect.".to_owned() - } - Status::IP_ADDRESS_CONFLICT => { - "There is an address conflict address allocation".to_owned() - } - Status::LOAD_ERROR => { - "The image failed to load.".to_owned() - } - Status::MEDIA_CHANGED => { - "The medium in the device has changed since the last access.".to_owned() - } - Status::NETWORK_UNREACHABLE => { - "The network containing the remote host is not reachable.".to_owned() - } - Status::NO_MAPPING => { - "A mapping to a device does not exist.".to_owned() - } - Status::NO_MEDIA => { - "The device does not contain any medium to perform the operation.".to_owned() - } - Status::NO_RESPONSE => { - "The server was not found or did not respond to the request.".to_owned() - } - Status::NOT_FOUND => "The item was not found.".to_owned(), - Status::NOT_READY => { - "There is no data pending upon return.".to_owned() - } - Status::NOT_STARTED => { - "The protocol has not been started.".to_owned() - } - Status::OUT_OF_RESOURCES => { - "A resource has run out.".to_owned() - } - Status::PROTOCOL_ERROR => { - "A protocol error occurred during the network operation.".to_owned() - } - Status::PROTOCOL_UNREACHABLE => { - "An ICMP protocol unreachable error is received.".to_owned() - } - Status::SECURITY_VIOLATION => { - "The function was not performed due to a security violation.".to_owned() - } - Status::TFTP_ERROR => { - "A TFTP error occurred during the network operation.".to_owned() - } - Status::TIMEOUT => "The timeout time expired.".to_owned(), - Status::UNSUPPORTED => { - "The operation is not supported.".to_owned() - } - Status::VOLUME_FULL => { - "There is no more space on the file system.".to_owned() - } - Status::VOLUME_CORRUPTED => { - "An inconstancy was detected on the file system causing the operating to fail.".to_owned() - } - Status::WRITE_PROTECTED => { - "The device cannot be written to.".to_owned() - } - _ => format!("Status: {}", errno), - } + #[rustfmt::skip] + let msg = match r_efi::efi::Status::from_usize(errno) { + Status::ABORTED => "The operation was aborted.", + Status::ACCESS_DENIED => "Access was denied.", + Status::ALREADY_STARTED => "The protocol has already been started.", + Status::BAD_BUFFER_SIZE => "The buffer was not the proper size for the request.", + Status::BUFFER_TOO_SMALL => "The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs.", + Status::COMPROMISED_DATA => "The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.", + Status::CONNECTION_FIN => "The receiving operation fails because the communication peer has closed the connection and there is no more data in the receive buffer of the instance.", + Status::CONNECTION_REFUSED => "The receiving or transmission operation fails because this connection is refused.", + Status::CONNECTION_RESET => "The connect fails because the connection is reset either by instance itself or the communication peer.", + Status::CRC_ERROR => "A CRC error was detected.", + Status::DEVICE_ERROR => "The physical device reported an error while attempting the operation.", + Status::END_OF_FILE => "The end of the file was reached.", + Status::END_OF_MEDIA => "Beginning or end of media was reached", + Status::HOST_UNREACHABLE => "The remote host is not reachable.", + Status::HTTP_ERROR => "A HTTP error occurred during the network operation.", + Status::ICMP_ERROR => "An ICMP error occurred during the network operation.", + Status::INCOMPATIBLE_VERSION => "The function encountered an internal version that was incompatible with a version requested by the caller.", + Status::INVALID_LANGUAGE => "The language specified was invalid.", + Status::INVALID_PARAMETER => "A parameter was incorrect.", + Status::IP_ADDRESS_CONFLICT => "There is an address conflict address allocation", + Status::LOAD_ERROR => "The image failed to load.", + Status::MEDIA_CHANGED => "The medium in the device has changed since the last access.", + Status::NETWORK_UNREACHABLE => "The network containing the remote host is not reachable.", + Status::NO_MAPPING => "A mapping to a device does not exist.", + Status::NO_MEDIA => "The device does not contain any medium to perform the operation.", + Status::NO_RESPONSE => "The server was not found or did not respond to the request.", + Status::NOT_FOUND => "The item was not found.", + Status::NOT_READY => "There is no data pending upon return.", + Status::NOT_STARTED => "The protocol has not been started.", + Status::OUT_OF_RESOURCES => "A resource has run out.", + Status::PROTOCOL_ERROR => "A protocol error occurred during the network operation.", + Status::PROTOCOL_UNREACHABLE => "An ICMP protocol unreachable error is received.", + Status::SECURITY_VIOLATION => "The function was not performed due to a security violation.", + Status::TFTP_ERROR => "A TFTP error occurred during the network operation.", + Status::TIMEOUT => "The timeout time expired.", + Status::UNSUPPORTED => "The operation is not supported.", + Status::VOLUME_FULL => "There is no more space on the file system.", + Status::VOLUME_CORRUPTED => "An inconstancy was detected on the file system causing the operating to fail.", + Status::WRITE_PROTECTED => "The device cannot be written to.", + _ => return format!("Status: {errno}"), + }; + msg.to_owned() } pub fn getcwd() -> io::Result { @@ -131,7 +70,7 @@ pub fn getcwd() -> io::Result { let path_ptr = unsafe { ((*shell.as_ptr()).get_cur_dir)(crate::ptr::null_mut()) }; helpers::os_string_from_raw(path_ptr) .map(PathBuf::from) - .ok_or(io::const_io_error!(io::ErrorKind::InvalidData, "Invalid path")) + .ok_or(io::const_error!(io::ErrorKind::InvalidData, "invalid path")) } None => { let mut t = current_exe()?; @@ -147,7 +86,7 @@ pub fn chdir(p: &path::Path) -> io::Result<()> { let shell = helpers::open_shell().ok_or(unsupported_err())?; let mut p = helpers::os_string_to_raw(p.as_os_str()) - .ok_or(io::const_io_error!(io::ErrorKind::InvalidData, "Invalid path"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidData, "invalid path"))?; let r = unsafe { ((*shell.as_ptr()).set_cur_dir)(crate::ptr::null_mut(), p.as_mut_ptr()) }; if r.is_error() { Err(io::Error::from_raw_os_error(r.as_usize())) } else { Ok(()) } @@ -290,15 +229,15 @@ mod uefi_env { pub(crate) fn set(key: &OsStr, val: &OsStr) -> io::Result<()> { let mut key_ptr = helpers::os_string_to_raw(key) - .ok_or(io::const_io_error!(io::ErrorKind::InvalidInput, "Invalid Key"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "invalid key"))?; let mut val_ptr = helpers::os_string_to_raw(val) - .ok_or(io::const_io_error!(io::ErrorKind::InvalidInput, "Invalid Value"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "invalid value"))?; unsafe { set_raw(key_ptr.as_mut_ptr(), val_ptr.as_mut_ptr()) } } pub(crate) fn unset(key: &OsStr) -> io::Result<()> { let mut key_ptr = helpers::os_string_to_raw(key) - .ok_or(io::const_io_error!(io::ErrorKind::InvalidInput, "Invalid Key"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "invalid key"))?; unsafe { set_raw(key_ptr.as_mut_ptr(), crate::ptr::null_mut()) } } @@ -314,7 +253,7 @@ mod uefi_env { let mut start = 0; - // UEFI Shell returns all keys seperated by NULL. + // UEFI Shell returns all keys separated by NULL. // End of string is denoted by two NULLs for i in 0.. { if unsafe { *val.add(i) } == 0 { @@ -328,7 +267,7 @@ mod uefi_env { }); // SAFETY: val.add(start) is always NULL terminated let val = unsafe { get_raw(shell, val.add(start)) } - .ok_or(io::const_io_error!(io::ErrorKind::InvalidInput, "Invalid Value"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "invalid value"))?; vars.push((key, val)); start = i + 1; diff --git a/std/src/sys/pal/uefi/process.rs b/std/src/sys/pal/uefi/process.rs index 1b83f4b0aee88..1203d51e5312a 100644 --- a/std/src/sys/pal/uefi/process.rs +++ b/std/src/sys/pal/uefi/process.rs @@ -1,6 +1,7 @@ use r_efi::protocols::simple_text_output; use super::helpers; +use crate::collections::BTreeMap; pub use crate::ffi::OsString as EnvKey; use crate::ffi::{OsStr, OsString}; use crate::num::{NonZero, NonZeroI32}; @@ -21,6 +22,7 @@ pub struct Command { args: Vec, stdout: Option, stderr: Option, + env: CommandEnv, } // passed back to std::process with the pipes connected to the child, if any @@ -40,7 +42,13 @@ pub enum Stdio { impl Command { pub fn new(program: &OsStr) -> Command { - Command { prog: program.to_os_string(), args: Vec::new(), stdout: None, stderr: None } + Command { + prog: program.to_os_string(), + args: Vec::new(), + stdout: None, + stderr: None, + env: Default::default(), + } } pub fn arg(&mut self, arg: &OsStr) { @@ -48,7 +56,7 @@ impl Command { } pub fn env_mut(&mut self) -> &mut CommandEnv { - panic!("unsupported") + &mut self.env } pub fn cwd(&mut self, _dir: &OsStr) { @@ -76,7 +84,7 @@ impl Command { } pub fn get_envs(&self) -> CommandEnvs<'_> { - panic!("unsupported") + self.env.iter() } pub fn get_current_dir(&self) -> Option<&Path> { @@ -140,8 +148,30 @@ impl Command { cmd.stderr_inherit() }; + let env = env_changes(&self.env); + + // Set any new vars + if let Some(e) = &env { + for (k, (_, v)) in e { + match v { + Some(v) => unsafe { crate::env::set_var(k, v) }, + None => unsafe { crate::env::remove_var(k) }, + } + } + } + let stat = cmd.start_image()?; + // Rollback any env changes + if let Some(e) = env { + for (k, (v, _)) in e { + match v { + Some(v) => unsafe { crate::env::set_var(k, v) }, + None => unsafe { crate::env::remove_var(k) }, + } + } + } + let stdout = cmd.stdout()?; let stderr = cmd.stderr()?; @@ -307,7 +337,7 @@ mod uefi_command_internal { use super::super::helpers; use crate::ffi::{OsStr, OsString}; - use crate::io::{self, const_io_error}; + use crate::io::{self, const_error}; use crate::mem::MaybeUninit; use crate::os::uefi::env::{boot_services, image_handle, system_table}; use crate::os::uefi::ffi::{OsStrExt, OsStringExt}; @@ -326,9 +356,9 @@ mod uefi_command_internal { impl Image { pub fn load_image(p: &OsStr) -> io::Result { - let path = helpers::DevicePath::from_text(p)?; + let path = helpers::OwnedDevicePath::from_text(p)?; let boot_services: NonNull = boot_services() - .ok_or_else(|| const_io_error!(io::ErrorKind::NotFound, "Boot Services not found"))? + .ok_or_else(|| const_error!(io::ErrorKind::NotFound, "Boot Services not found"))? .cast(); let mut child_handle: MaybeUninit = MaybeUninit::uninit(); let image_handle = image_handle(); @@ -358,7 +388,7 @@ mod uefi_command_internal { } } - pub fn start_image(&mut self) -> io::Result { + pub(crate) fn start_image(&mut self) -> io::Result { self.update_st_crc32()?; // Use our system table instead of the default one @@ -369,7 +399,7 @@ mod uefi_command_internal { } let boot_services: NonNull = boot_services() - .ok_or_else(|| const_io_error!(io::ErrorKind::NotFound, "Boot Services not found"))? + .ok_or_else(|| const_error!(io::ErrorKind::NotFound, "Boot Services not found"))? .cast(); let mut exit_data_size: usize = 0; let mut exit_data: MaybeUninit<*mut u16> = MaybeUninit::uninit(); @@ -460,7 +490,7 @@ mod uefi_command_internal { helpers::open_protocol(self.handle, loaded_image::PROTOCOL_GUID).unwrap(); let len = args.len(); - let args_size: u32 = crate::mem::size_of_val(&args).try_into().unwrap(); + let args_size: u32 = (len * size_of::()).try_into().unwrap(); let ptr = Box::into_raw(args).as_mut_ptr(); unsafe { @@ -583,7 +613,7 @@ mod uefi_command_internal { OsString::from_wide(&self._buffer) .into_string() .map(Into::into) - .map_err(|_| const_io_error!(io::ErrorKind::Other, "utf8 conversion failed")) + .map_err(|_| const_error!(io::ErrorKind::Other, "UTF-8 conversion failed")) } extern "efiapi" fn reset( @@ -706,9 +736,10 @@ mod uefi_command_internal { res.push(QUOTE); res.extend(prog.encode_wide()); res.push(QUOTE); - res.push(SPACE); for arg in args { + res.push(SPACE); + // Wrap the argument in quotes to be treat as single arg res.push(QUOTE); for c in arg.encode_wide() { @@ -719,10 +750,37 @@ mod uefi_command_internal { res.push(c); } res.push(QUOTE); - - res.push(SPACE); } res.into_boxed_slice() } } + +/// Create a map of environment variable changes. Allows efficient setting and rolling back of +/// environment variable changes. +/// +/// Entry: (Old Value, New Value) +fn env_changes(env: &CommandEnv) -> Option, Option)>> { + if env.is_unchanged() { + return None; + } + + let mut result = BTreeMap::, Option)>::new(); + + // Check if we want to clear all prior variables + if env.does_clear() { + for (k, v) in crate::env::vars_os() { + result.insert(k.into(), (Some(v), None)); + } + } + + for (k, v) in env.iter() { + let v: Option = v.map(Into::into); + result + .entry(k.into()) + .and_modify(|cur| *cur = (cur.0.clone(), v.clone())) + .or_insert((crate::env::var_os(k), v)); + } + + Some(result) +} diff --git a/std/src/sys/pal/uefi/tests.rs b/std/src/sys/pal/uefi/tests.rs index 5eb36da922b54..38658cc4e9ac4 100644 --- a/std/src/sys/pal/uefi/tests.rs +++ b/std/src/sys/pal/uefi/tests.rs @@ -16,7 +16,7 @@ fn align() { if *j <= 8 { assert_eq!(align_size(i, *j), i); } else { - assert!(align_size(i, *j) > i + std::mem::size_of::<*mut ()>()); + assert!(align_size(i, *j) > i + size_of::<*mut ()>()); } } } diff --git a/std/src/sys/pal/uefi/time.rs b/std/src/sys/pal/uefi/time.rs index 495ff2dc930ed..c4ff3015ac60d 100644 --- a/std/src/sys/pal/uefi/time.rs +++ b/std/src/sys/pal/uefi/time.rs @@ -84,7 +84,7 @@ pub(crate) mod system_time_internal { // This algorithm is based on the one described in the post // https://blog.reverberate.org/2020/05/12/optimizing-date-algorithms.html - pub const fn uefi_time_to_duration(t: r_efi::system::Time) -> Duration { + pub(crate) const fn uefi_time_to_duration(t: r_efi::system::Time) -> Duration { assert!(t.month <= 12); assert!(t.month != 0); diff --git a/std/src/sys/pal/unix/args.rs b/std/src/sys/pal/unix/args.rs index 8438a61e90feb..1c87a79803c0d 100644 --- a/std/src/sys/pal/unix/args.rs +++ b/std/src/sys/pal/unix/args.rs @@ -147,7 +147,7 @@ mod imp { /// This allows `std::env::args` to work even in a `cdylib`, as it does on macOS and Windows. #[cfg(all(target_os = "linux", target_env = "gnu"))] #[used] - #[link_section = ".init_array.00099"] + #[unsafe(link_section = ".init_array.00099")] static ARGV_INIT_ARRAY: extern "C" fn( crate::os::raw::c_int, *const *const u8, @@ -204,7 +204,7 @@ mod imp { } pub fn argc_argv() -> (isize, *const *const c_char) { - extern "C" { + unsafe extern "C" { // These functions are in crt_externs.h. fn _NSGetArgc() -> *mut c_int; fn _NSGetArgv() -> *mut *mut *mut c_char; diff --git a/std/src/sys/pal/unix/fd.rs b/std/src/sys/pal/unix/fd.rs index 6a28799ca55eb..a08c7ccec2da3 100644 --- a/std/src/sys/pal/unix/fd.rs +++ b/std/src/sys/pal/unix/fd.rs @@ -5,7 +5,6 @@ mod tests; #[cfg(not(any( target_os = "linux", - target_os = "emscripten", target_os = "l4re", target_os = "android", target_os = "hurd", @@ -14,7 +13,6 @@ use libc::off_t as off64_t; #[cfg(any( target_os = "android", target_os = "linux", - target_os = "emscripten", target_os = "l4re", target_os = "hurd", ))] @@ -253,6 +251,9 @@ impl FileDesc { } #[cfg(all(target_os = "android", target_pointer_width = "32"))] + // FIXME(#115199): Rust currently omits weak function definitions + // and its metadata from LLVM IR. + #[no_sanitize(cfi)] pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result { super::weak::weak!(fn preadv64(libc::c_int, *const libc::iovec, libc::c_int, off64_t) -> isize); diff --git a/std/src/sys/pal/unix/futex.rs b/std/src/sys/pal/unix/futex.rs index 0fc765dc87a5d..87ba13ca9321d 100644 --- a/std/src/sys/pal/unix/futex.rs +++ b/std/src/sys/pal/unix/futex.rs @@ -58,7 +58,7 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option) - _clockid: libc::CLOCK_MONOTONIC as u32, }); let umtx_timeout_ptr = umtx_timeout.as_ref().map_or(null(), |t| t as *const _); - let umtx_timeout_size = umtx_timeout.as_ref().map_or(0, |t| crate::mem::size_of_val(t)); + let umtx_timeout_size = umtx_timeout.as_ref().map_or(0, |t| size_of_val(t)); libc::_umtx_op( futex as *const AtomicU32 as *mut _, libc::UMTX_OP_WAIT_UINT_PRIVATE, @@ -219,7 +219,7 @@ pub fn futex_wake_all(futex: &AtomicU32) { } #[cfg(target_os = "emscripten")] -extern "C" { +unsafe extern "C" { fn emscripten_futex_wake(addr: *const AtomicU32, count: libc::c_int) -> libc::c_int; fn emscripten_futex_wait( addr: *const AtomicU32, @@ -267,7 +267,7 @@ pub mod zircon { pub const ZX_ERR_BAD_STATE: zx_status_t = -20; pub const ZX_ERR_TIMED_OUT: zx_status_t = -21; - extern "C" { + unsafe extern "C" { pub fn zx_clock_get_monotonic() -> zx_time_t; pub fn zx_futex_wait( value_ptr: *const zx_futex_t, diff --git a/std/src/sys/pal/unix/kernel_copy.rs b/std/src/sys/pal/unix/kernel_copy.rs index a671383cb7957..bbf29f3252341 100644 --- a/std/src/sys/pal/unix/kernel_copy.rs +++ b/std/src/sys/pal/unix/kernel_copy.rs @@ -52,19 +52,19 @@ use crate::cmp::min; use crate::fs::{File, Metadata}; use crate::io::copy::generic_copy; use crate::io::{ - BufRead, BufReader, BufWriter, Error, Read, Result, StderrLock, StdinLock, StdoutLock, Take, - Write, + BufRead, BufReader, BufWriter, Error, PipeReader, PipeWriter, Read, Result, StderrLock, + StdinLock, StdoutLock, Take, Write, }; use crate::mem::ManuallyDrop; use crate::net::TcpStream; use crate::os::unix::fs::FileTypeExt; use crate::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use crate::os::unix::net::UnixStream; -use crate::pipe::{PipeReader, PipeWriter}; use crate::process::{ChildStderr, ChildStdin, ChildStdout}; use crate::ptr; use crate::sync::atomic::{AtomicBool, AtomicU8, Ordering}; use crate::sys::cvt; +use crate::sys::fs::CachedFileMetadata; use crate::sys::weak::syscall; #[cfg(test)] @@ -192,7 +192,7 @@ impl SpecCopy for Copier<'_, '_, R, W> { let w_cfg = writer.properties(); // before direct operations on file descriptors ensure that all source and sink buffers are empty - let mut flush = || -> crate::io::Result { + let mut flush = || -> Result { let bytes = reader.drain_to(writer, u64::MAX)?; // BufWriter buffered bytes have already been accounted for in earlier write() calls writer.flush()?; @@ -537,6 +537,18 @@ impl CopyWrite for BufWriter { } } +impl CopyRead for CachedFileMetadata { + fn properties(&self) -> CopyParams { + CopyParams(FdMeta::Metadata(self.1.clone()), Some(self.0.as_raw_fd())) + } +} + +impl CopyWrite for CachedFileMetadata { + fn properties(&self) -> CopyParams { + CopyParams(FdMeta::Metadata(self.1.clone()), Some(self.0.as_raw_fd())) + } +} + fn fd_to_meta(fd: &T) -> FdMeta { let fd = fd.as_raw_fd(); let file: ManuallyDrop = ManuallyDrop::new(unsafe { File::from_raw_fd(fd) }); diff --git a/std/src/sys/pal/unix/kernel_copy/tests.rs b/std/src/sys/pal/unix/kernel_copy/tests.rs index 1350d743ff6f3..54d8f8ed2edd4 100644 --- a/std/src/sys/pal/unix/kernel_copy/tests.rs +++ b/std/src/sys/pal/unix/kernel_copy/tests.rs @@ -2,7 +2,7 @@ use crate::fs::OpenOptions; use crate::io; use crate::io::{BufRead, Read, Result, Seek, SeekFrom, Write}; use crate::os::unix::io::AsRawFd; -use crate::sys_common::io::test::tmpdir; +use crate::test_helpers::tmpdir; #[test] fn copy_specialization() -> Result<()> { diff --git a/std/src/sys/pal/unix/l4re.rs b/std/src/sys/pal/unix/l4re.rs deleted file mode 100644 index 52d39dcfb16fb..0000000000000 --- a/std/src/sys/pal/unix/l4re.rs +++ /dev/null @@ -1,564 +0,0 @@ -macro_rules! unimpl { - () => { - return Err(io::const_io_error!( - io::ErrorKind::Unsupported, - "No networking available on L4Re.", - )); - }; -} - -pub mod net { - #![allow(warnings)] - use crate::fmt; - use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; - use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; - use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; - use crate::sys::fd::FileDesc; - use crate::sys_common::{AsInner, FromInner, IntoInner}; - use crate::time::Duration; - - #[allow(unused_extern_crates)] - pub extern crate libc as netc; - - pub struct Socket(FileDesc); - impl Socket { - pub fn new(_: &SocketAddr, _: libc::c_int) -> io::Result { - unimpl!(); - } - - pub fn new_raw(_: libc::c_int, _: libc::c_int) -> io::Result { - unimpl!(); - } - - pub fn new_pair(_: libc::c_int, _: libc::c_int) -> io::Result<(Socket, Socket)> { - unimpl!(); - } - - pub fn connect_timeout(&self, _: &SocketAddr, _: Duration) -> io::Result<()> { - unimpl!(); - } - - pub fn accept( - &self, - _: *mut libc::sockaddr, - _: *mut libc::socklen_t, - ) -> io::Result { - unimpl!(); - } - - pub fn duplicate(&self) -> io::Result { - unimpl!(); - } - - pub fn read(&self, _: &mut [u8]) -> io::Result { - unimpl!(); - } - - pub fn read_buf(&self, _: BorrowedCursor<'_>) -> io::Result<()> { - unimpl!(); - } - - pub fn read_vectored(&self, _: &mut [IoSliceMut<'_>]) -> io::Result { - unimpl!(); - } - - pub fn is_read_vectored(&self) -> bool { - false - } - - pub fn peek(&self, _: &mut [u8]) -> io::Result { - unimpl!(); - } - - pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - unimpl!(); - } - - pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - unimpl!(); - } - - pub fn write(&self, _: &[u8]) -> io::Result { - unimpl!(); - } - - pub fn write_vectored(&self, _: &[IoSlice<'_>]) -> io::Result { - unimpl!(); - } - - pub fn is_write_vectored(&self) -> bool { - false - } - - pub fn set_timeout(&self, _: Option, _: libc::c_int) -> io::Result<()> { - unimpl!(); - } - - pub fn timeout(&self, _: libc::c_int) -> io::Result> { - unimpl!(); - } - - pub fn shutdown(&self, _: Shutdown) -> io::Result<()> { - unimpl!(); - } - - pub fn set_linger(&self, _: Option) -> io::Result<()> { - unimpl!(); - } - - pub fn linger(&self) -> io::Result> { - unimpl!(); - } - - pub fn set_nodelay(&self, _: bool) -> io::Result<()> { - unimpl!(); - } - - pub fn nodelay(&self) -> io::Result { - unimpl!(); - } - - pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - unimpl!(); - } - - pub fn take_error(&self) -> io::Result> { - unimpl!(); - } - - // This is used by sys_common code to abstract over Windows and Unix. - pub fn as_raw(&self) -> RawFd { - self.as_raw_fd() - } - } - - impl AsInner for Socket { - #[inline] - fn as_inner(&self) -> &FileDesc { - &self.0 - } - } - - impl FromInner for Socket { - fn from_inner(file_desc: FileDesc) -> Socket { - Socket(file_desc) - } - } - - impl IntoInner for Socket { - fn into_inner(self) -> FileDesc { - self.0 - } - } - - impl AsFd for Socket { - fn as_fd(&self) -> BorrowedFd<'_> { - self.0.as_fd() - } - } - - impl AsRawFd for Socket { - #[inline] - fn as_raw_fd(&self) -> RawFd { - self.0.as_raw_fd() - } - } - - impl IntoRawFd for Socket { - fn into_raw_fd(self) -> RawFd { - self.0.into_raw_fd() - } - } - - impl FromRawFd for Socket { - unsafe fn from_raw_fd(raw_fd: RawFd) -> Self { - Self(FromRawFd::from_raw_fd(raw_fd)) - } - } - - pub struct TcpStream { - inner: Socket, - } - - impl TcpStream { - pub fn connect(_: io::Result<&SocketAddr>) -> io::Result { - unimpl!(); - } - - pub fn connect_timeout(_: &SocketAddr, _: Duration) -> io::Result { - unimpl!(); - } - - #[inline] - pub fn socket(&self) -> &Socket { - &self.inner - } - - pub fn into_socket(self) -> Socket { - self.inner - } - - pub fn set_read_timeout(&self, _: Option) -> io::Result<()> { - unimpl!(); - } - - pub fn set_write_timeout(&self, _: Option) -> io::Result<()> { - unimpl!(); - } - - pub fn read_timeout(&self) -> io::Result> { - unimpl!(); - } - - pub fn write_timeout(&self) -> io::Result> { - unimpl!(); - } - - pub fn peek(&self, _: &mut [u8]) -> io::Result { - unimpl!(); - } - - pub fn read(&self, _: &mut [u8]) -> io::Result { - unimpl!(); - } - - pub fn read_buf(&self, _: BorrowedCursor<'_>) -> io::Result<()> { - unimpl!(); - } - - pub fn read_vectored(&self, _: &mut [IoSliceMut<'_>]) -> io::Result { - unimpl!(); - } - - pub fn is_read_vectored(&self) -> bool { - false - } - - pub fn write(&self, _: &[u8]) -> io::Result { - unimpl!(); - } - - pub fn write_vectored(&self, _: &[IoSlice<'_>]) -> io::Result { - unimpl!(); - } - - pub fn is_write_vectored(&self) -> bool { - false - } - - pub fn peer_addr(&self) -> io::Result { - unimpl!(); - } - - pub fn socket_addr(&self) -> io::Result { - unimpl!(); - } - - pub fn shutdown(&self, _: Shutdown) -> io::Result<()> { - unimpl!(); - } - - pub fn duplicate(&self) -> io::Result { - unimpl!(); - } - - pub fn set_linger(&self, _: Option) -> io::Result<()> { - unimpl!(); - } - - pub fn linger(&self) -> io::Result> { - unimpl!(); - } - - pub fn set_nodelay(&self, _: bool) -> io::Result<()> { - unimpl!(); - } - - pub fn nodelay(&self) -> io::Result { - unimpl!(); - } - - pub fn set_ttl(&self, _: u32) -> io::Result<()> { - unimpl!(); - } - - pub fn ttl(&self) -> io::Result { - unimpl!(); - } - - pub fn take_error(&self) -> io::Result> { - unimpl!(); - } - - pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - unimpl!(); - } - } - - impl FromInner for TcpStream { - fn from_inner(socket: Socket) -> TcpStream { - TcpStream { inner: socket } - } - } - - impl fmt::Debug for TcpStream { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "No networking support available on L4Re") - } - } - - pub struct TcpListener { - inner: Socket, - } - - impl TcpListener { - pub fn bind(_: io::Result<&SocketAddr>) -> io::Result { - unimpl!(); - } - - #[inline] - pub fn socket(&self) -> &Socket { - &self.inner - } - - pub fn into_socket(self) -> Socket { - self.inner - } - - pub fn socket_addr(&self) -> io::Result { - unimpl!(); - } - - pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> { - unimpl!(); - } - - pub fn duplicate(&self) -> io::Result { - unimpl!(); - } - - pub fn set_ttl(&self, _: u32) -> io::Result<()> { - unimpl!(); - } - - pub fn ttl(&self) -> io::Result { - unimpl!(); - } - - pub fn set_only_v6(&self, _: bool) -> io::Result<()> { - unimpl!(); - } - - pub fn only_v6(&self) -> io::Result { - unimpl!(); - } - - pub fn take_error(&self) -> io::Result> { - unimpl!(); - } - - pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - unimpl!(); - } - } - - impl FromInner for TcpListener { - fn from_inner(socket: Socket) -> TcpListener { - TcpListener { inner: socket } - } - } - - impl fmt::Debug for TcpListener { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "No networking support available on L4Re.") - } - } - - pub struct UdpSocket { - inner: Socket, - } - - impl UdpSocket { - pub fn bind(_: io::Result<&SocketAddr>) -> io::Result { - unimpl!(); - } - - #[inline] - pub fn socket(&self) -> &Socket { - &self.inner - } - - pub fn into_socket(self) -> Socket { - self.inner - } - - pub fn peer_addr(&self) -> io::Result { - unimpl!(); - } - - pub fn socket_addr(&self) -> io::Result { - unimpl!(); - } - - pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - unimpl!(); - } - - pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - unimpl!(); - } - - pub fn send_to(&self, _: &[u8], _: &SocketAddr) -> io::Result { - unimpl!(); - } - - pub fn duplicate(&self) -> io::Result { - unimpl!(); - } - - pub fn set_read_timeout(&self, _: Option) -> io::Result<()> { - unimpl!(); - } - - pub fn set_write_timeout(&self, _: Option) -> io::Result<()> { - unimpl!(); - } - - pub fn read_timeout(&self) -> io::Result> { - unimpl!(); - } - - pub fn write_timeout(&self) -> io::Result> { - unimpl!(); - } - - pub fn set_broadcast(&self, _: bool) -> io::Result<()> { - unimpl!(); - } - - pub fn broadcast(&self) -> io::Result { - unimpl!(); - } - - pub fn set_multicast_loop_v4(&self, _: bool) -> io::Result<()> { - unimpl!(); - } - - pub fn multicast_loop_v4(&self) -> io::Result { - unimpl!(); - } - - pub fn set_multicast_ttl_v4(&self, _: u32) -> io::Result<()> { - unimpl!(); - } - - pub fn multicast_ttl_v4(&self) -> io::Result { - unimpl!(); - } - - pub fn set_multicast_loop_v6(&self, _: bool) -> io::Result<()> { - unimpl!(); - } - - pub fn multicast_loop_v6(&self) -> io::Result { - unimpl!(); - } - - pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { - unimpl!(); - } - - pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { - unimpl!(); - } - - pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { - unimpl!(); - } - - pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { - unimpl!(); - } - - pub fn set_ttl(&self, _: u32) -> io::Result<()> { - unimpl!(); - } - - pub fn ttl(&self) -> io::Result { - unimpl!(); - } - - pub fn take_error(&self) -> io::Result> { - unimpl!(); - } - - pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - unimpl!(); - } - - pub fn recv(&self, _: &mut [u8]) -> io::Result { - unimpl!(); - } - - pub fn peek(&self, _: &mut [u8]) -> io::Result { - unimpl!(); - } - - pub fn send(&self, _: &[u8]) -> io::Result { - unimpl!(); - } - - pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> { - unimpl!(); - } - } - - impl FromInner for UdpSocket { - fn from_inner(socket: Socket) -> UdpSocket { - UdpSocket { inner: socket } - } - } - - impl fmt::Debug for UdpSocket { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "No networking support on L4Re available.") - } - } - - pub struct LookupHost { - original: *mut libc::addrinfo, - cur: *mut libc::addrinfo, - } - - impl Iterator for LookupHost { - type Item = SocketAddr; - fn next(&mut self) -> Option { - None - } - } - - impl LookupHost { - pub fn port(&self) -> u16 { - 0 // unimplemented - } - } - - unsafe impl Sync for LookupHost {} - unsafe impl Send for LookupHost {} - - impl TryFrom<&str> for LookupHost { - type Error = io::Error; - - fn try_from(_v: &str) -> io::Result { - unimpl!(); - } - } - - impl<'a> TryFrom<(&'a str, u16)> for LookupHost { - type Error = io::Error; - - fn try_from(_v: (&'a str, u16)) -> io::Result { - unimpl!(); - } - } -} diff --git a/std/src/sys/pal/unix/linux/pidfd/tests.rs b/std/src/sys/pal/unix/linux/pidfd/tests.rs index fb928c76fbd04..17b06bea91278 100644 --- a/std/src/sys/pal/unix/linux/pidfd/tests.rs +++ b/std/src/sys/pal/unix/linux/pidfd/tests.rs @@ -45,8 +45,8 @@ fn test_command_pidfd() { .expect_err("pidfd should not have been created"); // exercise the fork/exec path since the earlier attempts may have used pidfd_spawnp() - let mut child = - unsafe { Command::new("false").pre_exec(|| Ok(())) }.create_pidfd(true).spawn().unwrap(); + let mut cmd = Command::new("false"); + let mut child = unsafe { cmd.pre_exec(|| Ok(())) }.create_pidfd(true).spawn().unwrap(); assert!(child.id() > 0 && child.id() < -1i32 as u32); diff --git a/std/src/sys/pal/unix/mod.rs b/std/src/sys/pal/unix/mod.rs index 4fe18daa2040f..419abe732ac3f 100644 --- a/std/src/sys/pal/unix/mod.rs +++ b/std/src/sys/pal/unix/mod.rs @@ -9,24 +9,16 @@ pub mod weak; pub mod args; pub mod env; pub mod fd; -pub mod fs; pub mod futex; -pub mod io; #[cfg(any(target_os = "linux", target_os = "android"))] pub mod kernel_copy; -#[cfg(target_os = "l4re")] -mod l4re; #[cfg(target_os = "linux")] pub mod linux; -#[cfg(not(target_os = "l4re"))] -pub mod net; -#[cfg(target_os = "l4re")] -pub use self::l4re::net; pub mod os; pub mod pipe; pub mod process; pub mod stack_overflow; -pub mod stdio; +pub mod sync; pub mod thread; pub mod thread_parking; pub mod time; @@ -253,7 +245,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { libc::ECONNREFUSED => ConnectionRefused, libc::ECONNRESET => ConnectionReset, libc::EDEADLK => Deadlock, - libc::EDQUOT => FilesystemQuotaExceeded, + libc::EDQUOT => QuotaExceeded, libc::EEXIST => AlreadyExists, libc::EFBIG => FileTooLarge, libc::EHOSTUNREACH => HostUnreachable, @@ -379,24 +371,24 @@ cfg_if::cfg_if! { cfg(target_feature = "crt-static"))] #[link(name = "dl", cfg(not(target_feature = "crt-static")))] #[link(name = "log", cfg(not(target_feature = "crt-static")))] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "freebsd")] { #[link(name = "execinfo")] #[link(name = "pthread")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "netbsd")] { #[link(name = "pthread")] #[link(name = "rt")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(any(target_os = "dragonfly", target_os = "openbsd"))] { #[link(name = "pthread")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "solaris")] { #[link(name = "socket")] #[link(name = "posix4")] #[link(name = "pthread")] #[link(name = "resolv")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "illumos")] { #[link(name = "socket")] #[link(name = "posix4")] @@ -405,24 +397,24 @@ cfg_if::cfg_if! { #[link(name = "nsl")] // Use libumem for the (malloc-compatible) allocator #[link(name = "umem")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_vendor = "apple")] { // Link to `libSystem.dylib`. // // Don't get confused by the presence of `System.framework`, // it is a deprecated wrapper over the dynamic library. #[link(name = "System")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "fuchsia")] { #[link(name = "zircon")] #[link(name = "fdio")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(all(target_os = "linux", target_env = "uclibc"))] { #[link(name = "dl")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "vita")] { #[link(name = "pthread", kind = "static", modifiers = "-bundle")] - extern "C" {} + unsafe extern "C" {} } } diff --git a/std/src/sys/pal/unix/os.rs b/std/src/sys/pal/unix/os.rs index f207131ddf332..3a238d160cb57 100644 --- a/std/src/sys/pal/unix/os.rs +++ b/std/src/sys/pal/unix/os.rs @@ -30,7 +30,7 @@ cfg_if::cfg_if! { } } -extern "C" { +unsafe extern "C" { #[cfg(not(any(target_os = "dragonfly", target_os = "vxworks", target_os = "rtems")))] #[cfg_attr( any( @@ -82,7 +82,7 @@ pub fn errno() -> i32 { #[cfg(target_os = "rtems")] pub fn errno() -> i32 { - extern "C" { + unsafe extern "C" { #[thread_local] static _tls_errno: c_int; } @@ -92,7 +92,7 @@ pub fn errno() -> i32 { #[cfg(target_os = "dragonfly")] pub fn errno() -> i32 { - extern "C" { + unsafe extern "C" { #[thread_local] static errno: c_int; } @@ -103,7 +103,7 @@ pub fn errno() -> i32 { #[cfg(target_os = "dragonfly")] #[allow(dead_code)] pub fn set_errno(e: i32) { - extern "C" { + unsafe extern "C" { #[thread_local] static mut errno: c_int; } @@ -115,7 +115,7 @@ pub fn set_errno(e: i32) { /// Gets a detailed string description for the given error number. pub fn error_string(errno: i32) -> String { - extern "C" { + unsafe extern "C" { #[cfg_attr( all( any(target_os = "linux", target_os = "hurd", target_env = "newlib"), @@ -258,9 +258,9 @@ pub fn current_exe() -> io::Result { use crate::env; use crate::io::ErrorKind; - let exe_path = env::args().next().ok_or(io::const_io_error!( + let exe_path = env::args().next().ok_or(io::const_error!( ErrorKind::NotFound, - "an executable path was not found because no arguments were provided through argv" + "an executable path was not found because no arguments were provided through argv", ))?; let path = PathBuf::from(exe_path); if path.is_absolute() { @@ -284,7 +284,7 @@ pub fn current_exe() -> io::Result { } } } - Err(io::const_io_error!(ErrorKind::NotFound, "an executable path was not found")) + Err(io::const_error!(ErrorKind::NotFound, "an executable path was not found")) } #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] @@ -340,7 +340,7 @@ pub fn current_exe() -> io::Result { 0, ))?; if path_len <= 1 { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::Uncategorized, "KERN_PROC_PATHNAME sysctl returned zero-length string", )); @@ -363,7 +363,7 @@ pub fn current_exe() -> io::Result { if curproc_exe.is_file() { return crate::fs::read_link(curproc_exe); } - Err(io::const_io_error!( + Err(io::const_error!( io::ErrorKind::Uncategorized, "/proc/curproc/exe doesn't point to regular file.", )) @@ -382,10 +382,7 @@ pub fn current_exe() -> io::Result { cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _, &mut argv_len, ptr::null_mut(), 0))?; argv.set_len(argv_len as usize); if argv[0].is_null() { - return Err(io::const_io_error!( - io::ErrorKind::Uncategorized, - "no current exe available", - )); + return Err(io::const_error!(io::ErrorKind::Uncategorized, "no current exe available")); } let argv0 = CStr::from_ptr(argv[0]).to_bytes(); if argv0[0] == b'.' || argv0.iter().any(|b| *b == b'/') { @@ -405,7 +402,7 @@ pub fn current_exe() -> io::Result { ))] pub fn current_exe() -> io::Result { match crate::fs::read_link("/proc/self/exe") { - Err(ref e) if e.kind() == io::ErrorKind::NotFound => Err(io::const_io_error!( + Err(ref e) if e.kind() == io::ErrorKind::NotFound => Err(io::const_error!( io::ErrorKind::Uncategorized, "no /proc/self/exe available. Is /proc mounted?", )), @@ -428,11 +425,13 @@ pub fn current_exe() -> io::Result { pub fn current_exe() -> io::Result { unsafe { let mut sz: u32 = 0; + #[expect(deprecated)] libc::_NSGetExecutablePath(ptr::null_mut(), &mut sz); if sz == 0 { return Err(io::Error::last_os_error()); } let mut v: Vec = Vec::with_capacity(sz as usize); + #[expect(deprecated)] let err = libc::_NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz); if err != 0 { return Err(io::Error::last_os_error()); @@ -476,7 +475,7 @@ pub fn current_exe() -> io::Result { ); if result != libc::B_OK { use crate::io::ErrorKind; - Err(io::const_io_error!(ErrorKind::Uncategorized, "Error getting executable path")) + Err(io::const_error!(ErrorKind::Uncategorized, "error getting executable path")) } else { // find_path adds the null terminator. let name = CStr::from_ptr(name.as_ptr()).to_bytes(); @@ -493,7 +492,7 @@ pub fn current_exe() -> io::Result { #[cfg(target_os = "l4re")] pub fn current_exe() -> io::Result { use crate::io::ErrorKind; - Err(io::const_io_error!(ErrorKind::Unsupported, "Not yet implemented!")) + Err(io::const_error!(ErrorKind::Unsupported, "not yet implemented!")) } #[cfg(target_os = "vxworks")] @@ -523,9 +522,9 @@ pub fn current_exe() -> io::Result { use crate::env; use crate::io::ErrorKind; - let exe_path = env::args().next().ok_or(io::const_io_error!( + let exe_path = env::args().next().ok_or(io::const_error!( ErrorKind::Uncategorized, - "an executable path was not found because no arguments were provided through argv" + "an executable path was not found because no arguments were provided through argv", ))?; let path = PathBuf::from(exe_path); @@ -609,7 +608,7 @@ pub unsafe fn environ() -> *mut *const *const c_char { // Use the `environ` static which is part of POSIX. #[cfg(not(target_vendor = "apple"))] pub unsafe fn environ() -> *mut *const *const c_char { - extern "C" { + unsafe extern "C" { static mut environ: *const *const c_char; } &raw mut environ @@ -846,7 +845,7 @@ pub fn getppid() -> u32 { #[cfg(all(target_os = "linux", target_env = "gnu"))] pub fn glibc_version() -> Option<(usize, usize)> { - extern "C" { + unsafe extern "C" { fn gnu_get_libc_version() -> *const libc::c_char; } let version_cstr = unsafe { CStr::from_ptr(gnu_get_libc_version()) }; diff --git a/std/src/sys/pal/unix/process/process_common.rs b/std/src/sys/pal/unix/process/process_common.rs index 13290fed762ae..0ea9db211b311 100644 --- a/std/src/sys/pal/unix/process/process_common.rs +++ b/std/src/sys/pal/unix/process/process_common.rs @@ -43,10 +43,7 @@ cfg_if::cfg_if! { #[allow(dead_code)] pub unsafe fn sigaddset(set: *mut libc::sigset_t, signum: libc::c_int) -> libc::c_int { - use crate::{ - mem::{align_of, size_of}, - slice, - }; + use crate::slice; use libc::{c_ulong, sigset_t}; // The implementations from bionic (android libc) type pun `sigset_t` as an @@ -393,7 +390,7 @@ impl Command { fn os2c(s: &OsStr, saw_nul: &mut bool) -> CString { CString::new(s.as_bytes()).unwrap_or_else(|_e| { *saw_nul = true; - CString::new("").unwrap() + c"".to_owned() }) } diff --git a/std/src/sys/pal/unix/process/process_fuchsia.rs b/std/src/sys/pal/unix/process/process_fuchsia.rs index 8f7d786e32fcd..05c9ace470e3e 100644 --- a/std/src/sys/pal/unix/process/process_fuchsia.rs +++ b/std/src/sys/pal/unix/process/process_fuchsia.rs @@ -18,7 +18,7 @@ impl Command { let envp = self.capture_env(); if self.saw_nul() { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, "nul byte found in provided data", )); @@ -38,7 +38,7 @@ impl Command { pub fn exec(&mut self, default: Stdio) -> io::Error { if self.saw_nul() { - return io::const_io_error!( + return io::const_error!( io::ErrorKind::InvalidInput, "nul byte found in provided data", ); @@ -179,15 +179,15 @@ impl Process { self.handle.raw(), ZX_INFO_PROCESS, (&raw mut proc_info) as *mut libc::c_void, - mem::size_of::(), + size_of::(), &mut actual, &mut avail, ))?; } if actual != 1 { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidData, - "Failed to get exit status of process", + "failed to get exit status of process", )); } Ok(ExitStatus(proc_info.return_code)) @@ -216,15 +216,15 @@ impl Process { self.handle.raw(), ZX_INFO_PROCESS, (&raw mut proc_info) as *mut libc::c_void, - mem::size_of::(), + size_of::(), &mut actual, &mut avail, ))?; } if actual != 1 { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidData, - "Failed to get exit status of process", + "failed to get exit status of process", )); } Ok(Some(ExitStatus(proc_info.return_code))) diff --git a/std/src/sys/pal/unix/process/process_unix.rs b/std/src/sys/pal/unix/process/process_unix.rs index 8faf1fda5464d..be9a7e919905f 100644 --- a/std/src/sys/pal/unix/process/process_unix.rs +++ b/std/src/sys/pal/unix/process/process_unix.rs @@ -19,8 +19,7 @@ use crate::sys::process::process_common::*; use crate::{fmt, mem, sys}; cfg_if::cfg_if! { - // This workaround is only needed for QNX 7.0 and 7.1. The bug should have been fixed in 8.0 - if #[cfg(any(target_env = "nto70", target_env = "nto71"))] { + if #[cfg(target_os = "nto")] { use crate::thread; use libc::{c_char, posix_spawn_file_actions_t, posix_spawnattr_t}; use crate::time::Duration; @@ -61,7 +60,7 @@ impl Command { let envp = self.capture_env(); if self.saw_nul() { - return Err(io::const_io_error!( + return Err(io::const_error!( ErrorKind::InvalidInput, "nul byte found in provided data", )); @@ -175,7 +174,7 @@ impl Command { // allowed to exist in dead code), but it sounds bad, so we go out of our // way to avoid that all-together. #[cfg(any(target_os = "tvos", target_os = "watchos"))] - const ERR_APPLE_TV_WATCH_NO_FORK_EXEC: Error = io::const_io_error!( + const ERR_APPLE_TV_WATCH_NO_FORK_EXEC: Error = io::const_error!( ErrorKind::Unsupported, "`fork`+`exec`-based process spawning is not supported on this target", ); @@ -187,12 +186,7 @@ impl Command { // Attempts to fork the process. If successful, returns Ok((0, -1)) // in the child, and Ok((child_pid, -1)) in the parent. - #[cfg(not(any( - target_os = "watchos", - target_os = "tvos", - target_env = "nto70", - target_env = "nto71" - )))] + #[cfg(not(any(target_os = "watchos", target_os = "tvos", target_os = "nto")))] unsafe fn do_fork(&mut self) -> Result { cvt(libc::fork()) } @@ -201,8 +195,7 @@ impl Command { // or closed a file descriptor while the fork() was occurring". // Documentation says "... or try calling fork() again". This is what we do here. // See also https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/f/fork.html - // This workaround is only needed for QNX 7.0 and 7.1. The bug should have been fixed in 8.0 - #[cfg(any(target_env = "nto70", target_env = "nto71"))] + #[cfg(target_os = "nto")] unsafe fn do_fork(&mut self) -> Result { use crate::sys::os::errno; @@ -218,7 +211,7 @@ impl Command { } else if delay < MAX_FORKSPAWN_SLEEP { thread::sleep(delay); } else { - return Err(io::const_io_error!( + return Err(io::const_error!( ErrorKind::WouldBlock, "forking returned EBADF too often", )); @@ -235,7 +228,7 @@ impl Command { let envp = self.capture_env(); if self.saw_nul() { - return io::const_io_error!(ErrorKind::InvalidInput, "nul byte found in provided data",); + return io::const_error!(ErrorKind::InvalidInput, "nul byte found in provided data"); } match self.setup_io(default, true) { @@ -417,6 +410,7 @@ impl Command { #[cfg(not(any( target_os = "freebsd", + target_os = "illumos", all(target_os = "linux", target_env = "gnu"), all(target_os = "linux", target_env = "musl"), target_os = "nto", @@ -434,11 +428,15 @@ impl Command { // directly. #[cfg(any( target_os = "freebsd", + target_os = "illumos", all(target_os = "linux", target_env = "gnu"), all(target_os = "linux", target_env = "musl"), target_os = "nto", target_vendor = "apple", ))] + // FIXME(#115199): Rust currently omits weak function definitions + // and its metadata from LLVM IR. + #[cfg_attr(target_os = "linux", no_sanitize(cfi))] fn posix_spawn( &mut self, stdio: &ChildPipes, @@ -561,7 +559,7 @@ impl Command { } else if delay < MAX_FORKSPAWN_SLEEP { thread::sleep(delay); } else { - return Err(io::const_io_error!( + return Err(io::const_error!( ErrorKind::WouldBlock, "posix_spawnp returned EBADF too often", )); @@ -591,6 +589,10 @@ impl Command { fn get_posix_spawn_addchdir() -> Option { use crate::sys::weak::weak; + // POSIX.1-2024 standardizes this function: + // https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_addchdir.html. + // The _np version is more widely available, though, so try that first. + weak! { fn posix_spawn_file_actions_addchdir_np( *mut libc::posix_spawn_file_actions_t, @@ -598,7 +600,16 @@ impl Command { ) -> libc::c_int } - posix_spawn_file_actions_addchdir_np.get() + weak! { + fn posix_spawn_file_actions_addchdir( + *mut libc::posix_spawn_file_actions_t, + *const libc::c_char + ) -> libc::c_int + } + + posix_spawn_file_actions_addchdir_np + .get() + .or_else(|| posix_spawn_file_actions_addchdir.get()) } /// Get the function pointer for adding a chdir action to a @@ -806,7 +817,7 @@ impl Command { let fds: [c_int; 1] = [pidfd as RawFd]; - const SCM_MSG_LEN: usize = mem::size_of::<[c_int; 1]>(); + const SCM_MSG_LEN: usize = size_of::<[c_int; 1]>(); #[repr(C)] union Cmsg { @@ -825,7 +836,7 @@ impl Command { // only attach cmsg if we successfully acquired the pidfd if pidfd >= 0 { - msg.msg_controllen = mem::size_of_val(&cmsg.buf) as _; + msg.msg_controllen = size_of_val(&cmsg.buf) as _; msg.msg_control = (&raw mut cmsg.buf) as *mut _; let hdr = CMSG_FIRSTHDR((&raw mut msg) as *mut _); @@ -857,7 +868,7 @@ impl Command { use crate::sys::cvt_r; unsafe { - const SCM_MSG_LEN: usize = mem::size_of::<[c_int; 1]>(); + const SCM_MSG_LEN: usize = size_of::<[c_int; 1]>(); #[repr(C)] union Cmsg { @@ -872,7 +883,7 @@ impl Command { msg.msg_iov = (&raw mut iov) as *mut _; msg.msg_iovlen = 1; - msg.msg_controllen = mem::size_of::() as _; + msg.msg_controllen = size_of::() as _; msg.msg_control = (&raw mut cmsg) as *mut _; match cvt_r(|| libc::recvmsg(sock.as_raw(), &mut msg, libc::MSG_CMSG_CLOEXEC)) { @@ -1235,7 +1246,7 @@ mod linux_child_ext { .as_ref() // SAFETY: The os type is a transparent wrapper, therefore we can transmute references .map(|fd| unsafe { mem::transmute::<&imp::PidFd, &os::PidFd>(fd) }) - .ok_or_else(|| io::Error::new(ErrorKind::Uncategorized, "No pidfd was created.")) + .ok_or_else(|| io::const_error!(ErrorKind::Uncategorized, "no pidfd was created.")) } fn into_pidfd(mut self) -> Result { diff --git a/std/src/sys/pal/unix/process/process_vxworks.rs b/std/src/sys/pal/unix/process/process_vxworks.rs index 38daf6af91808..e2c1b6a032624 100644 --- a/std/src/sys/pal/unix/process/process_vxworks.rs +++ b/std/src/sys/pal/unix/process/process_vxworks.rs @@ -22,7 +22,7 @@ impl Command { let envp = self.capture_env(); if self.saw_nul() { - return Err(io::const_io_error!( + return Err(io::const_error!( ErrorKind::InvalidInput, "nul byte found in provided data", )); diff --git a/std/src/sys/pal/unix/process/zircon.rs b/std/src/sys/pal/unix/process/zircon.rs index 4035e2370a3c6..7932bd26d76c3 100644 --- a/std/src/sys/pal/unix/process/zircon.rs +++ b/std/src/sys/pal/unix/process/zircon.rs @@ -75,7 +75,7 @@ pub struct zx_info_process_t { pub reserved1: u32, } -extern "C" { +unsafe extern "C" { pub fn zx_job_default() -> zx_handle_t; pub fn zx_task_kill(handle: zx_handle_t) -> zx_status_t; @@ -115,7 +115,7 @@ pub struct fdio_spawn_action_t { pub reserved1: u64, } -extern "C" { +unsafe extern "C" { pub fn fdio_spawn_etc( job: zx_handle_t, flags: u32, diff --git a/std/src/sys/pal/unix/stack_overflow.rs b/std/src/sys/pal/unix/stack_overflow.rs index 69b31da427fcb..0ecccdc8812dd 100644 --- a/std/src/sys/pal/unix/stack_overflow.rs +++ b/std/src/sys/pal/unix/stack_overflow.rs @@ -100,10 +100,11 @@ mod imp { // If the faulting address is within the guard page, then we print a // message saying so and abort. if start <= addr && addr < end { - rtprintpanic!( - "\nthread '{}' has overflowed its stack\n", - thread::current().name().unwrap_or("") - ); + thread::with_current_name(|name| { + let name = name.unwrap_or(""); + rtprintpanic!("\nthread '{name}' has overflowed its stack\n"); + }); + rtabort!("stack overflow"); } else { // Unregister ourselves by reverting back to the default behavior. @@ -318,21 +319,27 @@ mod imp { ))] unsafe fn get_stack_start() -> Option<*mut libc::c_void> { let mut ret = None; - let mut attr: libc::pthread_attr_t = crate::mem::zeroed(); + let mut attr: mem::MaybeUninit = mem::MaybeUninit::uninit(); + if !cfg!(target_os = "freebsd") { + attr = mem::MaybeUninit::zeroed(); + } #[cfg(target_os = "freebsd")] - assert_eq!(libc::pthread_attr_init(&mut attr), 0); + assert_eq!(libc::pthread_attr_init(attr.as_mut_ptr()), 0); #[cfg(target_os = "freebsd")] - let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr); + let e = libc::pthread_attr_get_np(libc::pthread_self(), attr.as_mut_ptr()); #[cfg(not(target_os = "freebsd"))] - let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr); + let e = libc::pthread_getattr_np(libc::pthread_self(), attr.as_mut_ptr()); if e == 0 { let mut stackaddr = crate::ptr::null_mut(); let mut stacksize = 0; - assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut stacksize), 0); + assert_eq!( + libc::pthread_attr_getstack(attr.as_ptr(), &mut stackaddr, &mut stacksize), + 0 + ); ret = Some(stackaddr); } if e == 0 || cfg!(target_os = "freebsd") { - assert_eq!(libc::pthread_attr_destroy(&mut attr), 0); + assert_eq!(libc::pthread_attr_destroy(attr.as_mut_ptr()), 0); } ret } @@ -419,7 +426,7 @@ mod imp { use crate::sys::weak::dlsym; dlsym!(fn sysctlbyname(*const libc::c_char, *mut libc::c_void, *mut libc::size_t, *const libc::c_void, libc::size_t) -> libc::c_int); let mut guard: usize = 0; - let mut size = mem::size_of_val(&guard); + let mut size = size_of_val(&guard); let oid = c"security.bsd.stack_guard_page"; match sysctlbyname.get() { Some(fcn) if unsafe { @@ -508,16 +515,20 @@ mod imp { // FIXME: I am probably not unsafe. unsafe fn current_guard() -> Option> { let mut ret = None; - let mut attr: libc::pthread_attr_t = crate::mem::zeroed(); + + let mut attr: mem::MaybeUninit = mem::MaybeUninit::uninit(); + if !cfg!(target_os = "freebsd") { + attr = mem::MaybeUninit::zeroed(); + } #[cfg(target_os = "freebsd")] - assert_eq!(libc::pthread_attr_init(&mut attr), 0); + assert_eq!(libc::pthread_attr_init(attr.as_mut_ptr()), 0); #[cfg(target_os = "freebsd")] - let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr); + let e = libc::pthread_attr_get_np(libc::pthread_self(), attr.as_mut_ptr()); #[cfg(not(target_os = "freebsd"))] - let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr); + let e = libc::pthread_getattr_np(libc::pthread_self(), attr.as_mut_ptr()); if e == 0 { let mut guardsize = 0; - assert_eq!(libc::pthread_attr_getguardsize(&attr, &mut guardsize), 0); + assert_eq!(libc::pthread_attr_getguardsize(attr.as_ptr(), &mut guardsize), 0); if guardsize == 0 { if cfg!(all(target_os = "linux", target_env = "musl")) { // musl versions before 1.1.19 always reported guard @@ -530,7 +541,7 @@ mod imp { } let mut stackptr = crate::ptr::null_mut::(); let mut size = 0; - assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackptr, &mut size), 0); + assert_eq!(libc::pthread_attr_getstack(attr.as_ptr(), &mut stackptr, &mut size), 0); let stackaddr = stackptr.addr(); ret = if cfg!(any(target_os = "freebsd", target_os = "netbsd", target_os = "hurd")) { @@ -551,7 +562,7 @@ mod imp { }; } if e == 0 || cfg!(target_os = "freebsd") { - assert_eq!(libc::pthread_attr_destroy(&mut attr), 0); + assert_eq!(libc::pthread_attr_destroy(attr.as_mut_ptr()), 0); } ret } diff --git a/std/src/sys/pal/unix/sync/condvar.rs b/std/src/sys/pal/unix/sync/condvar.rs new file mode 100644 index 0000000000000..73631053e9f47 --- /dev/null +++ b/std/src/sys/pal/unix/sync/condvar.rs @@ -0,0 +1,172 @@ +use super::Mutex; +use crate::cell::UnsafeCell; +use crate::pin::Pin; +#[cfg(not(target_os = "nto"))] +use crate::sys::pal::time::TIMESPEC_MAX; +#[cfg(target_os = "nto")] +use crate::sys::pal::time::TIMESPEC_MAX_CAPPED; +use crate::sys::pal::time::Timespec; +use crate::time::Duration; + +pub struct Condvar { + inner: UnsafeCell, +} + +impl Condvar { + pub fn new() -> Condvar { + Condvar { inner: UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER) } + } + + #[inline] + fn raw(&self) -> *mut libc::pthread_cond_t { + self.inner.get() + } + + /// # Safety + /// `init` must have been called on this instance. + #[inline] + pub unsafe fn notify_one(self: Pin<&Self>) { + let r = unsafe { libc::pthread_cond_signal(self.raw()) }; + debug_assert_eq!(r, 0); + } + + /// # Safety + /// `init` must have been called on this instance. + #[inline] + pub unsafe fn notify_all(self: Pin<&Self>) { + let r = unsafe { libc::pthread_cond_broadcast(self.raw()) }; + debug_assert_eq!(r, 0); + } + + /// # Safety + /// * `init` must have been called on this instance. + /// * `mutex` must be locked by the current thread. + /// * This condition variable may only be used with the same mutex. + #[inline] + pub unsafe fn wait(self: Pin<&Self>, mutex: Pin<&Mutex>) { + let r = unsafe { libc::pthread_cond_wait(self.raw(), mutex.raw()) }; + debug_assert_eq!(r, 0); + } + + /// # Safety + /// * `init` must have been called on this instance. + /// * `mutex` must be locked by the current thread. + /// * This condition variable may only be used with the same mutex. + pub unsafe fn wait_timeout(&self, mutex: Pin<&Mutex>, dur: Duration) -> bool { + let mutex = mutex.raw(); + + // OSX implementation of `pthread_cond_timedwait` is buggy + // with super long durations. When duration is greater than + // 0x100_0000_0000_0000 seconds, `pthread_cond_timedwait` + // in macOS Sierra returns error 316. + // + // This program demonstrates the issue: + // https://gist.github.com/stepancheg/198db4623a20aad2ad7cddb8fda4a63c + // + // To work around this issue, the timeout is clamped to 1000 years. + #[cfg(target_vendor = "apple")] + let dur = Duration::min(dur, Duration::from_secs(1000 * 365 * 86400)); + + let timeout = Timespec::now(Self::CLOCK).checked_add_duration(&dur); + + #[cfg(not(target_os = "nto"))] + let timeout = timeout.and_then(|t| t.to_timespec()).unwrap_or(TIMESPEC_MAX); + + #[cfg(target_os = "nto")] + let timeout = timeout.and_then(|t| t.to_timespec_capped()).unwrap_or(TIMESPEC_MAX_CAPPED); + + let r = unsafe { libc::pthread_cond_timedwait(self.raw(), mutex, &timeout) }; + assert!(r == libc::ETIMEDOUT || r == 0); + r == 0 + } +} + +#[cfg(not(any( + target_os = "android", + target_vendor = "apple", + target_os = "espidf", + target_os = "horizon", + target_os = "l4re", + target_os = "redox", + target_os = "teeos", +)))] +impl Condvar { + pub const PRECISE_TIMEOUT: bool = true; + const CLOCK: libc::clockid_t = libc::CLOCK_MONOTONIC; + + /// # Safety + /// May only be called once per instance of `Self`. + pub unsafe fn init(self: Pin<&mut Self>) { + use crate::mem::MaybeUninit; + + struct AttrGuard<'a>(pub &'a mut MaybeUninit); + impl Drop for AttrGuard<'_> { + fn drop(&mut self) { + unsafe { + let result = libc::pthread_condattr_destroy(self.0.as_mut_ptr()); + assert_eq!(result, 0); + } + } + } + + unsafe { + let mut attr = MaybeUninit::::uninit(); + let r = libc::pthread_condattr_init(attr.as_mut_ptr()); + assert_eq!(r, 0); + let attr = AttrGuard(&mut attr); + let r = libc::pthread_condattr_setclock(attr.0.as_mut_ptr(), Self::CLOCK); + assert_eq!(r, 0); + let r = libc::pthread_cond_init(self.raw(), attr.0.as_ptr()); + assert_eq!(r, 0); + } + } +} + +// `pthread_condattr_setclock` is unfortunately not supported on these platforms. +#[cfg(any( + target_os = "android", + target_vendor = "apple", + target_os = "espidf", + target_os = "horizon", + target_os = "l4re", + target_os = "redox", + target_os = "teeos", +))] +impl Condvar { + pub const PRECISE_TIMEOUT: bool = false; + const CLOCK: libc::clockid_t = libc::CLOCK_REALTIME; + + /// # Safety + /// May only be called once per instance of `Self`. + pub unsafe fn init(self: Pin<&mut Self>) { + if cfg!(any(target_os = "espidf", target_os = "horizon", target_os = "teeos")) { + // NOTE: ESP-IDF's PTHREAD_COND_INITIALIZER support is not released yet + // So on that platform, init() should always be called. + // + // Similar story for the 3DS (horizon) and for TEEOS. + let r = unsafe { libc::pthread_cond_init(self.raw(), crate::ptr::null()) }; + assert_eq!(r, 0); + } + } +} + +impl !Unpin for Condvar {} + +unsafe impl Sync for Condvar {} +unsafe impl Send for Condvar {} + +impl Drop for Condvar { + #[inline] + fn drop(&mut self) { + let r = unsafe { libc::pthread_cond_destroy(self.raw()) }; + if cfg!(target_os = "dragonfly") { + // On DragonFly pthread_cond_destroy() returns EINVAL if called on + // a condvar that was just initialized with + // libc::PTHREAD_COND_INITIALIZER. Once it is used or + // pthread_cond_init() is called, this behaviour no longer occurs. + debug_assert!(r == 0 || r == libc::EINVAL); + } else { + debug_assert_eq!(r, 0); + } + } +} diff --git a/std/src/sys/pal/unix/sync/mod.rs b/std/src/sys/pal/unix/sync/mod.rs new file mode 100644 index 0000000000000..b430ff5d8ef5f --- /dev/null +++ b/std/src/sys/pal/unix/sync/mod.rs @@ -0,0 +1,16 @@ +#![cfg(not(any( + target_os = "linux", + target_os = "android", + all(target_os = "emscripten", target_feature = "atomics"), + target_os = "freebsd", + target_os = "openbsd", + target_os = "dragonfly", + target_os = "fuchsia", +)))] +#![forbid(unsafe_op_in_unsafe_fn)] + +mod condvar; +mod mutex; + +pub use condvar::Condvar; +pub use mutex::Mutex; diff --git a/std/src/sys/pal/unix/sync/mutex.rs b/std/src/sys/pal/unix/sync/mutex.rs new file mode 100644 index 0000000000000..557e70af94ba7 --- /dev/null +++ b/std/src/sys/pal/unix/sync/mutex.rs @@ -0,0 +1,135 @@ +use super::super::cvt_nz; +use crate::cell::UnsafeCell; +use crate::io::Error; +use crate::mem::MaybeUninit; +use crate::pin::Pin; + +pub struct Mutex { + inner: UnsafeCell, +} + +impl Mutex { + pub fn new() -> Mutex { + Mutex { inner: UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER) } + } + + pub(super) fn raw(&self) -> *mut libc::pthread_mutex_t { + self.inner.get() + } + + /// # Safety + /// May only be called once per instance of `Self`. + pub unsafe fn init(self: Pin<&mut Self>) { + // Issue #33770 + // + // A pthread mutex initialized with PTHREAD_MUTEX_INITIALIZER will have + // a type of PTHREAD_MUTEX_DEFAULT, which has undefined behavior if you + // try to re-lock it from the same thread when you already hold a lock + // (https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_init.html). + // This is the case even if PTHREAD_MUTEX_DEFAULT == PTHREAD_MUTEX_NORMAL + // (https://github.com/rust-lang/rust/issues/33770#issuecomment-220847521) -- in that + // case, `pthread_mutexattr_settype(PTHREAD_MUTEX_DEFAULT)` will of course be the same + // as setting it to `PTHREAD_MUTEX_NORMAL`, but not setting any mode will result in + // a Mutex where re-locking is UB. + // + // In practice, glibc takes advantage of this undefined behavior to + // implement hardware lock elision, which uses hardware transactional + // memory to avoid acquiring the lock. While a transaction is in + // progress, the lock appears to be unlocked. This isn't a problem for + // other threads since the transactional memory will abort if a conflict + // is detected, however no abort is generated when re-locking from the + // same thread. + // + // Since locking the same mutex twice will result in two aliasing &mut + // references, we instead create the mutex with type + // PTHREAD_MUTEX_NORMAL which is guaranteed to deadlock if we try to + // re-lock it from the same thread, thus avoiding undefined behavior. + unsafe { + let mut attr = MaybeUninit::::uninit(); + cvt_nz(libc::pthread_mutexattr_init(attr.as_mut_ptr())).unwrap(); + let attr = AttrGuard(&mut attr); + cvt_nz(libc::pthread_mutexattr_settype( + attr.0.as_mut_ptr(), + libc::PTHREAD_MUTEX_NORMAL, + )) + .unwrap(); + cvt_nz(libc::pthread_mutex_init(self.raw(), attr.0.as_ptr())).unwrap(); + } + } + + /// # Safety + /// * If `init` was not called on this instance, reentrant locking causes + /// undefined behaviour. + /// * Destroying a locked mutex causes undefined behaviour. + pub unsafe fn lock(self: Pin<&Self>) { + #[cold] + #[inline(never)] + fn fail(r: i32) -> ! { + let error = Error::from_raw_os_error(r); + panic!("failed to lock mutex: {error}"); + } + + let r = unsafe { libc::pthread_mutex_lock(self.raw()) }; + // As we set the mutex type to `PTHREAD_MUTEX_NORMAL` above, we expect + // the lock call to never fail. Unfortunately however, some platforms + // (Solaris) do not conform to the standard, and instead always provide + // deadlock detection. How kind of them! Unfortunately that means that + // we need to check the error code here. To save us from UB on other + // less well-behaved platforms in the future, we do it even on "good" + // platforms like macOS. See #120147 for more context. + if r != 0 { + fail(r) + } + } + + /// # Safety + /// * If `init` was not called on this instance, reentrant locking causes + /// undefined behaviour. + /// * Destroying a locked mutex causes undefined behaviour. + pub unsafe fn try_lock(self: Pin<&Self>) -> bool { + unsafe { libc::pthread_mutex_trylock(self.raw()) == 0 } + } + + /// # Safety + /// The mutex must be locked by the current thread. + pub unsafe fn unlock(self: Pin<&Self>) { + let r = unsafe { libc::pthread_mutex_unlock(self.raw()) }; + debug_assert_eq!(r, 0); + } +} + +impl !Unpin for Mutex {} + +unsafe impl Send for Mutex {} +unsafe impl Sync for Mutex {} + +impl Drop for Mutex { + fn drop(&mut self) { + // SAFETY: + // If `lock` or `init` was called, the mutex must have been pinned, so + // it is still at the same location. Otherwise, `inner` must contain + // `PTHREAD_MUTEX_INITIALIZER`, which is valid at all locations. Thus, + // this call always destroys a valid mutex. + let r = unsafe { libc::pthread_mutex_destroy(self.raw()) }; + if cfg!(any(target_os = "aix", target_os = "dragonfly")) { + // On AIX and DragonFly pthread_mutex_destroy() returns EINVAL if called + // on a mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER. + // Once it is used (locked/unlocked) or pthread_mutex_init() is called, + // this behaviour no longer occurs. + debug_assert!(r == 0 || r == libc::EINVAL); + } else { + debug_assert_eq!(r, 0); + } + } +} + +struct AttrGuard<'a>(pub &'a mut MaybeUninit); + +impl Drop for AttrGuard<'_> { + fn drop(&mut self) { + unsafe { + let result = libc::pthread_mutexattr_destroy(self.0.as_mut_ptr()); + assert_eq!(result, 0); + } + } +} diff --git a/std/src/sys/pal/unix/thread.rs b/std/src/sys/pal/unix/thread.rs index 040246618360f..abe8d3fbf681e 100644 --- a/std/src/sys/pal/unix/thread.rs +++ b/std/src/sys/pal/unix/thread.rs @@ -23,7 +23,7 @@ mod zircon { type zx_status_t = i32; pub const ZX_PROP_NAME: u32 = 3; - extern "C" { + unsafe extern "C" { pub fn zx_object_set_property( handle: zx_handle_t, property: u32, @@ -45,27 +45,31 @@ unsafe impl Sync for Thread {} impl Thread { // unsafe: see thread::Builder::spawn_unchecked for safety requirements + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub unsafe fn new(stack: usize, p: Box) -> io::Result { let p = Box::into_raw(Box::new(p)); let mut native: libc::pthread_t = mem::zeroed(); - let mut attr: libc::pthread_attr_t = mem::zeroed(); - assert_eq!(libc::pthread_attr_init(&mut attr), 0); + let mut attr: mem::MaybeUninit = mem::MaybeUninit::uninit(); + assert_eq!(libc::pthread_attr_init(attr.as_mut_ptr()), 0); #[cfg(target_os = "espidf")] if stack > 0 { // Only set the stack if a non-zero value is passed // 0 is used as an indication that the default stack size configured in the ESP-IDF menuconfig system should be used assert_eq!( - libc::pthread_attr_setstacksize(&mut attr, cmp::max(stack, min_stack_size(&attr))), + libc::pthread_attr_setstacksize( + attr.as_mut_ptr(), + cmp::max(stack, min_stack_size(attr.as_ptr())) + ), 0 ); } #[cfg(not(target_os = "espidf"))] { - let stack_size = cmp::max(stack, min_stack_size(&attr)); + let stack_size = cmp::max(stack, min_stack_size(attr.as_ptr())); - match libc::pthread_attr_setstacksize(&mut attr, stack_size) { + match libc::pthread_attr_setstacksize(attr.as_mut_ptr(), stack_size) { 0 => {} n => { assert_eq!(n, libc::EINVAL); @@ -76,16 +80,16 @@ impl Thread { let page_size = os::page_size(); let stack_size = (stack_size + page_size - 1) & (-(page_size as isize - 1) as usize - 1); - assert_eq!(libc::pthread_attr_setstacksize(&mut attr, stack_size), 0); + assert_eq!(libc::pthread_attr_setstacksize(attr.as_mut_ptr(), stack_size), 0); } }; } - let ret = libc::pthread_create(&mut native, &attr, thread_start, p as *mut _); + let ret = libc::pthread_create(&mut native, attr.as_ptr(), thread_start, p as *mut _); // Note: if the thread creation fails and this assert fails, then p will // be leaked. However, an alternative design could cause double-free // which is clearly worse. - assert_eq!(libc::pthread_attr_destroy(&mut attr), 0); + assert_eq!(libc::pthread_attr_destroy(attr.as_mut_ptr()), 0); return if ret != 0 { // The thread failed to start and as a result p was not consumed. Therefore, it is @@ -129,25 +133,32 @@ impl Thread { } } - #[cfg(target_os = "linux")] + #[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "nuttx" + ))] pub fn set_name(name: &CStr) { - const TASK_COMM_LEN: usize = 16; - unsafe { - // Available since glibc 2.12, musl 1.1.16, and uClibc 1.0.20. - let name = truncate_cstr::<{ TASK_COMM_LEN }>(name); + cfg_if::cfg_if! { + if #[cfg(target_os = "linux")] { + // Linux limits the allowed length of the name. + const TASK_COMM_LEN: usize = 16; + let name = truncate_cstr::<{ TASK_COMM_LEN }>(name); + } else { + // FreeBSD, DragonFly BSD and NuttX do not enforce length limits. + } + }; + // Available since glibc 2.12, musl 1.1.16, and uClibc 1.0.20 for Linux, + // FreeBSD 12.2 and 13.0, and DragonFly BSD 6.0. let res = libc::pthread_setname_np(libc::pthread_self(), name.as_ptr()); // We have no good way of propagating errors here, but in debug-builds let's check that this actually worked. debug_assert_eq!(res, 0); } } - #[cfg(any( - target_os = "freebsd", - target_os = "dragonfly", - target_os = "openbsd", - target_os = "nuttx" - ))] + #[cfg(target_os = "openbsd")] pub fn set_name(name: &CStr) { unsafe { libc::pthread_set_name_np(libc::pthread_self(), name.as_ptr()); @@ -177,6 +188,9 @@ impl Thread { } #[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto"))] + // FIXME(#115199): Rust currently omits weak function definitions + // and its metadata from LLVM IR. + #[no_sanitize(cfi)] pub fn set_name(name: &CStr) { weak! { fn pthread_setname_np( @@ -222,7 +236,7 @@ impl Thread { #[cfg(target_os = "vxworks")] pub fn set_name(name: &CStr) { // FIXME(libc): adding real STATUS, ERROR type eventually. - extern "C" { + unsafe extern "C" { fn taskNameSet(task_id: libc::TASK_ID, task_name: *mut libc::c_char) -> libc::c_int; } @@ -361,7 +375,7 @@ pub fn available_parallelism() -> io::Result> { quota = cgroups::quota().max(1); let mut set: libc::cpu_set_t = unsafe { mem::zeroed() }; unsafe { - if libc::sched_getaffinity(0, mem::size_of::(), &mut set) == 0 { + if libc::sched_getaffinity(0, size_of::(), &mut set) == 0 { let count = libc::CPU_COUNT(&set) as usize; let count = count.min(quota); @@ -401,7 +415,7 @@ pub fn available_parallelism() -> io::Result> { libc::CPU_LEVEL_WHICH, libc::CPU_WHICH_PID, -1, - mem::size_of::(), + size_of::(), &mut set, ) == 0 { let count = libc::CPU_COUNT(&set) as usize; @@ -436,7 +450,7 @@ pub fn available_parallelism() -> io::Result> { } let mut cpus: libc::c_uint = 0; - let mut cpus_size = crate::mem::size_of_val(&cpus); + let mut cpus_size = size_of_val(&cpus); unsafe { cpus = libc::sysconf(libc::_SC_NPROCESSORS_ONLN) as libc::c_uint; @@ -469,7 +483,7 @@ pub fn available_parallelism() -> io::Result> { unsafe { use libc::_syspage_ptr; if _syspage_ptr.is_null() { - Err(io::const_io_error!(io::ErrorKind::NotFound, "No syspage available")) + Err(io::const_error!(io::ErrorKind::NotFound, "no syspage available")) } else { let cpus = (*_syspage_ptr).num_cpu; NonZero::new(cpus as usize) @@ -498,7 +512,7 @@ pub fn available_parallelism() -> io::Result> { } else if #[cfg(target_os = "vxworks")] { // Note: there is also `vxCpuConfiguredGet`, closer to _SC_NPROCESSORS_CONF // expectations than the actual cores availability. - extern "C" { + unsafe extern "C" { fn vxCpuEnabledGet() -> libc::cpuset_t; } @@ -509,7 +523,7 @@ pub fn available_parallelism() -> io::Result> { } } else { // FIXME: implement on Redox, l4re - Err(io::const_io_error!(io::ErrorKind::Unsupported, "Getting the number of hardware threads is not supported on the target platform")) + Err(io::const_error!(io::ErrorKind::Unsupported, "getting the number of hardware threads is not supported on the target platform")) } } } diff --git a/std/src/sys/pal/unix/thread_parking.rs b/std/src/sys/pal/unix/thread_parking.rs index 72dd2031479ee..bef8b4fb36391 100644 --- a/std/src/sys/pal/unix/thread_parking.rs +++ b/std/src/sys/pal/unix/thread_parking.rs @@ -8,7 +8,7 @@ use crate::ffi::{c_int, c_void}; use crate::ptr; use crate::time::Duration; -extern "C" { +unsafe extern "C" { fn ___lwp_park60( clock_id: clockid_t, flags: c_int, diff --git a/std/src/sys/pal/unix/time.rs b/std/src/sys/pal/unix/time.rs index 535fe6b27d91e..c0a3044660b7e 100644 --- a/std/src/sys/pal/unix/time.rs +++ b/std/src/sys/pal/unix/time.rs @@ -1,3 +1,5 @@ +use core::num::niche_types::Nanoseconds; + use crate::time::Duration; use crate::{fmt, io}; @@ -15,12 +17,6 @@ pub(in crate::sys) const TIMESPEC_MAX_CAPPED: libc::timespec = libc::timespec { tv_nsec: (u64::MAX % NSEC_PER_SEC) as i64, }; -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(0)] -#[rustc_layout_scalar_valid_range_end(999_999_999)] -struct Nanoseconds(u32); - #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SystemTime { pub(crate) t: Timespec, @@ -59,14 +55,14 @@ impl fmt::Debug for SystemTime { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SystemTime") .field("tv_sec", &self.t.tv_sec) - .field("tv_nsec", &self.t.tv_nsec.0) + .field("tv_nsec", &self.t.tv_nsec) .finish() } } impl Timespec { const unsafe fn new_unchecked(tv_sec: i64, tv_nsec: i64) -> Timespec { - Timespec { tv_sec, tv_nsec: unsafe { Nanoseconds(tv_nsec as u32) } } + Timespec { tv_sec, tv_nsec: unsafe { Nanoseconds::new_unchecked(tv_nsec as u32) } } } pub const fn zero() -> Timespec { @@ -96,10 +92,21 @@ impl Timespec { if tv_nsec >= 0 && tv_nsec < NSEC_PER_SEC as i64 { Ok(unsafe { Self::new_unchecked(tv_sec, tv_nsec) }) } else { - Err(io::const_io_error!(io::ErrorKind::InvalidData, "Invalid timestamp")) + Err(io::const_error!(io::ErrorKind::InvalidData, "invalid timestamp")) } } + // FIXME(#115199): Rust currently omits weak function definitions + // and its metadata from LLVM IR. + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_pointer_width = "32", + not(target_arch = "riscv32") + ), + no_sanitize(cfi) + )] pub fn now(clock: libc::clockid_t) -> Timespec { use crate::mem::MaybeUninit; use crate::sys::cvt; @@ -147,12 +154,15 @@ impl Timespec { // // Ideally this code could be rearranged such that it more // directly expresses the lower-cost behavior we want from it. - let (secs, nsec) = if self.tv_nsec.0 >= other.tv_nsec.0 { - ((self.tv_sec - other.tv_sec) as u64, self.tv_nsec.0 - other.tv_nsec.0) + let (secs, nsec) = if self.tv_nsec.as_inner() >= other.tv_nsec.as_inner() { + ( + (self.tv_sec - other.tv_sec) as u64, + self.tv_nsec.as_inner() - other.tv_nsec.as_inner(), + ) } else { ( (self.tv_sec - other.tv_sec - 1) as u64, - self.tv_nsec.0 + (NSEC_PER_SEC as u32) - other.tv_nsec.0, + self.tv_nsec.as_inner() + (NSEC_PER_SEC as u32) - other.tv_nsec.as_inner(), ) }; @@ -170,7 +180,7 @@ impl Timespec { // Nano calculations can't overflow because nanos are <1B which fit // in a u32. - let mut nsec = other.subsec_nanos() + self.tv_nsec.0; + let mut nsec = other.subsec_nanos() + self.tv_nsec.as_inner(); if nsec >= NSEC_PER_SEC as u32 { nsec -= NSEC_PER_SEC as u32; secs = secs.checked_add(1)?; @@ -182,7 +192,7 @@ impl Timespec { let mut secs = self.tv_sec.checked_sub_unsigned(other.as_secs())?; // Similar to above, nanos can't overflow. - let mut nsec = self.tv_nsec.0 as i32 - other.subsec_nanos() as i32; + let mut nsec = self.tv_nsec.as_inner() as i32 - other.subsec_nanos() as i32; if nsec < 0 { nsec += NSEC_PER_SEC as i32; secs = secs.checked_sub(1)?; @@ -194,7 +204,7 @@ impl Timespec { pub fn to_timespec(&self) -> Option { Some(libc::timespec { tv_sec: self.tv_sec.try_into().ok()?, - tv_nsec: self.tv_nsec.0.try_into().ok()?, + tv_nsec: self.tv_nsec.as_inner().try_into().ok()?, }) } @@ -203,7 +213,7 @@ impl Timespec { #[cfg(target_os = "nto")] pub(in crate::sys) fn to_timespec_capped(&self) -> Option { // Check if timeout in nanoseconds would fit into an u64 - if (self.tv_nsec.0 as u64) + if (self.tv_nsec.as_inner() as u64) .checked_add((self.tv_sec as u64).checked_mul(NSEC_PER_SEC)?) .is_none() { @@ -219,7 +229,7 @@ impl Timespec { not(target_arch = "riscv32") ))] pub fn to_timespec64(&self) -> __timespec64 { - __timespec64::new(self.tv_sec, self.tv_nsec.0 as _) + __timespec64::new(self.tv_sec, self.tv_nsec.as_inner() as _) } } @@ -293,7 +303,7 @@ impl fmt::Debug for Instant { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Instant") .field("tv_sec", &self.t.tv_sec) - .field("tv_nsec", &self.t.tv_nsec.0) + .field("tv_nsec", &self.t.tv_nsec) .finish() } } diff --git a/std/src/sys/pal/unix/weak.rs b/std/src/sys/pal/unix/weak.rs index 35762f5a53b5b..ce3f66a83748b 100644 --- a/std/src/sys/pal/unix/weak.rs +++ b/std/src/sys/pal/unix/weak.rs @@ -31,7 +31,7 @@ use crate::{mem, ptr}; pub(crate) macro weak { (fn $name:ident($($t:ty),*) -> $ret:ty) => ( let ref $name: ExternWeak $ret> = { - extern "C" { + unsafe extern "C" { #[linkage = "extern_weak"] static $name: Option $ret>; } @@ -123,7 +123,7 @@ impl DlsymWeak { // Cold because it should only happen during first-time initialization. #[cold] unsafe fn initialize(&self) -> Option { - assert_eq!(mem::size_of::(), mem::size_of::<*mut libc::c_void>()); + assert_eq!(size_of::(), size_of::<*mut libc::c_void>()); let val = fetch(self.name); // This synchronizes with the acquire fence in `get`. @@ -144,6 +144,9 @@ unsafe fn fetch(name: &str) -> *mut libc::c_void { #[cfg(not(any(target_os = "linux", target_os = "android")))] pub(crate) macro syscall { (fn $name:ident($($arg_name:ident: $t:ty),*) -> $ret:ty) => ( + // FIXME(#115199): Rust currently omits weak function definitions + // and its metadata from LLVM IR. + #[no_sanitize(cfi)] unsafe fn $name($($arg_name: $t),*) -> $ret { weak! { fn $name($($t),*) -> $ret } diff --git a/std/src/sys/pal/unsupported/mod.rs b/std/src/sys/pal/unsupported/mod.rs index 01d516f7568bf..bcea699f3b2ad 100644 --- a/std/src/sys/pal/unsupported/mod.rs +++ b/std/src/sys/pal/unsupported/mod.rs @@ -2,13 +2,9 @@ pub mod args; pub mod env; -pub mod fs; -pub mod io; -pub mod net; pub mod os; pub mod pipe; pub mod process; -pub mod stdio; pub mod thread; pub mod time; diff --git a/std/src/sys/pal/unsupported/os.rs b/std/src/sys/pal/unsupported/os.rs index 481fd62c04fe8..48de4312885fe 100644 --- a/std/src/sys/pal/unsupported/os.rs +++ b/std/src/sys/pal/unsupported/os.rs @@ -96,11 +96,11 @@ pub fn getenv(_: &OsStr) -> Option { } pub unsafe fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> { - Err(io::const_io_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform")) + Err(io::const_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform")) } pub unsafe fn unsetenv(_: &OsStr) -> io::Result<()> { - Err(io::const_io_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform")) + Err(io::const_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform")) } pub fn temp_dir() -> PathBuf { diff --git a/std/src/sys/pal/wasi/fd.rs b/std/src/sys/pal/wasi/fd.rs index 19b60157e2e00..4b3dd1ce49ef6 100644 --- a/std/src/sys/pal/wasi/fd.rs +++ b/std/src/sys/pal/wasi/fd.rs @@ -14,8 +14,8 @@ pub struct WasiFd { } fn iovec<'a>(a: &'a mut [IoSliceMut<'_>]) -> &'a [wasi::Iovec] { - assert_eq!(mem::size_of::>(), mem::size_of::()); - assert_eq!(mem::align_of::>(), mem::align_of::()); + assert_eq!(size_of::>(), size_of::()); + assert_eq!(align_of::>(), align_of::()); // SAFETY: `IoSliceMut` and `IoVec` have exactly the same memory layout. // We decorate our `IoSliceMut` with `repr(transparent)` (see `io.rs`), and // `crate::io::IoSliceMut` is a `repr(transparent)` wrapper around our type, so this is @@ -24,8 +24,8 @@ fn iovec<'a>(a: &'a mut [IoSliceMut<'_>]) -> &'a [wasi::Iovec] { } fn ciovec<'a>(a: &'a [IoSlice<'_>]) -> &'a [wasi::Ciovec] { - assert_eq!(mem::size_of::>(), mem::size_of::()); - assert_eq!(mem::align_of::>(), mem::align_of::()); + assert_eq!(size_of::>(), size_of::()); + assert_eq!(align_of::>(), align_of::()); // SAFETY: `IoSlice` and `CIoVec` have exactly the same memory layout. // We decorate our `IoSlice` with `repr(transparent)` (see `io.rs`), and // `crate::io::IoSlice` is a `repr(transparent)` wrapper around our type, so this is diff --git a/std/src/sys/pal/wasi/mod.rs b/std/src/sys/pal/wasi/mod.rs index 5d54c7903065c..c89832857dd72 100644 --- a/std/src/sys/pal/wasi/mod.rs +++ b/std/src/sys/pal/wasi/mod.rs @@ -1,8 +1,7 @@ //! System bindings for the wasm/web platform //! //! This module contains the facade (aka platform-specific) implementations of -//! OS level functionality for wasm. Note that this wasm is *not* the emscripten -//! wasm, so we have no runtime here. +//! OS level functionality for wasm. //! //! This is all super highly experimental and not actually intended for //! wide/production use yet, it's still all in the experimental category. This @@ -17,19 +16,15 @@ pub mod args; pub mod env; pub mod fd; -pub mod fs; #[allow(unused)] #[path = "../wasm/atomics/futex.rs"] pub mod futex; -pub mod io; -pub mod net; pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; #[path = "../unsupported/process.rs"] pub mod process; -pub mod stdio; pub mod thread; pub mod time; @@ -46,5 +41,4 @@ mod helpers; // import conflict rules. If we glob export `helpers` and `common` together, // then the compiler complains about conflicts. -use helpers::err2io; -pub use helpers::{abort_internal, decode_error_kind, is_interrupted}; +pub(crate) use helpers::{abort_internal, decode_error_kind, err2io, is_interrupted}; diff --git a/std/src/sys/pal/wasi/os.rs b/std/src/sys/pal/wasi/os.rs index f7701360f5a9c..ba2b65a1f40dc 100644 --- a/std/src/sys/pal/wasi/os.rs +++ b/std/src/sys/pal/wasi/os.rs @@ -16,7 +16,7 @@ use crate::{fmt, io, str, vec}; mod libc { pub use libc::*; - extern "C" { + unsafe extern "C" { pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; pub fn chdir(dir: *const c_char) -> c_int; pub fn __wasilibc_get_environ() -> *mut *mut c_char; @@ -46,7 +46,7 @@ cfg_if::cfg_if! { } pub fn errno() -> i32 { - extern "C" { + unsafe extern "C" { #[thread_local] static errno: libc::c_int; } diff --git a/std/src/sys/pal/wasi/thread.rs b/std/src/sys/pal/wasi/thread.rs index 4b83870fdea6c..c85b03d4a8918 100644 --- a/std/src/sys/pal/wasi/thread.rs +++ b/std/src/sys/pal/wasi/thread.rs @@ -2,7 +2,6 @@ use crate::ffi::CStr; use crate::num::NonZero; -use crate::sys::unsupported; use crate::time::Duration; use crate::{io, mem}; @@ -14,16 +13,15 @@ cfg_if::cfg_if! { // Add a few symbols not in upstream `libc` just yet. mod libc { pub use crate::ffi; - pub use crate::mem; pub use libc::*; // defined in wasi-libc // https://github.com/WebAssembly/wasi-libc/blob/a6f871343313220b76009827ed0153586361c0d5/libc-top-half/musl/include/alltypes.h.in#L108 #[repr(C)] union pthread_attr_union { - __i: [ffi::c_int; if mem::size_of::() == 8 { 14 } else { 9 }], - __vi: [ffi::c_int; if mem::size_of::() == 8 { 14 } else { 9 }], - __s: [ffi::c_ulong; if mem::size_of::() == 8 { 7 } else { 9 }], + __i: [ffi::c_int; if size_of::() == 8 { 14 } else { 9 }], + __vi: [ffi::c_int; if size_of::() == 8 { 14 } else { 9 }], + __s: [ffi::c_ulong; if size_of::() == 8 { 7 } else { 9 }], } #[repr(C)] @@ -34,7 +32,9 @@ cfg_if::cfg_if! { #[allow(non_camel_case_types)] pub type pthread_t = *mut ffi::c_void; - extern "C" { + pub const _SC_NPROCESSORS_ONLN: ffi::c_int = 84; + + unsafe extern "C" { pub fn pthread_create( native: *mut pthread_t, attr: *const pthread_attr_t, @@ -121,7 +121,7 @@ impl Thread { } } else { pub unsafe fn new(_stack: usize, _p: Box) -> io::Result { - unsupported() + crate::sys::unsupported() } } } @@ -187,5 +187,14 @@ impl Thread { } pub fn available_parallelism() -> io::Result> { - unsupported() + cfg_if::cfg_if! { + if #[cfg(target_feature = "atomics")] { + match unsafe { libc::sysconf(libc::_SC_NPROCESSORS_ONLN) } { + -1 => Err(io::Error::last_os_error()), + cpus => NonZero::new(cpus as usize).ok_or(io::Error::UNKNOWN_THREAD_COUNT), + } + } else { + crate::sys::unsupported() + } + } } diff --git a/std/src/sys/pal/wasip2/cabi_realloc.rs b/std/src/sys/pal/wasip2/cabi_realloc.rs index 820063173d657..78adf9002fd7e 100644 --- a/std/src/sys/pal/wasip2/cabi_realloc.rs +++ b/std/src/sys/pal/wasip2/cabi_realloc.rs @@ -32,7 +32,7 @@ static FORCE_CODEGEN_OF_CABI_REALLOC: unsafe extern "C" fn( ) -> *mut u8 = cabi_realloc; #[linkage = "weak"] -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn cabi_realloc( old_ptr: *mut u8, old_len: usize, diff --git a/std/src/sys/pal/wasip2/mod.rs b/std/src/sys/pal/wasip2/mod.rs index 320712fdcc9fe..3008ba887535c 100644 --- a/std/src/sys/pal/wasip2/mod.rs +++ b/std/src/sys/pal/wasip2/mod.rs @@ -12,23 +12,16 @@ pub mod args; pub mod env; #[path = "../wasi/fd.rs"] pub mod fd; -#[path = "../wasi/fs.rs"] -pub mod fs; #[allow(unused)] #[path = "../wasm/atomics/futex.rs"] pub mod futex; -#[path = "../wasi/io.rs"] -pub mod io; -pub mod net; #[path = "../wasi/os.rs"] pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; #[path = "../unsupported/process.rs"] pub mod process; -#[path = "../wasi/stdio.rs"] -pub mod stdio; #[path = "../wasi/thread.rs"] pub mod thread; #[path = "../wasi/time.rs"] diff --git a/std/src/sys/pal/wasm/mod.rs b/std/src/sys/pal/wasm/mod.rs index 8141bfac49aad..175fe75357fb5 100644 --- a/std/src/sys/pal/wasm/mod.rs +++ b/std/src/sys/pal/wasm/mod.rs @@ -2,7 +2,7 @@ //! //! This module contains the facade (aka platform-specific) implementations of //! OS level functionality for wasm. Note that this wasm is *not* the emscripten -//! wasm, so we have no runtime here. +//! or wasi wasm, so we have no runtime here. //! //! This is all super highly experimental and not actually intended for //! wide/production use yet, it's still all in the experimental category. This @@ -19,20 +19,12 @@ #[path = "../unsupported/args.rs"] pub mod args; pub mod env; -#[path = "../unsupported/fs.rs"] -pub mod fs; -#[path = "../unsupported/io.rs"] -pub mod io; -#[path = "../unsupported/net.rs"] -pub mod net; #[path = "../unsupported/os.rs"] pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; #[path = "../unsupported/process.rs"] pub mod process; -#[path = "../unsupported/stdio.rs"] -pub mod stdio; #[path = "../unsupported/time.rs"] pub mod time; diff --git a/std/src/sys/pal/windows/api.rs b/std/src/sys/pal/windows/api.rs index ebe207fde935c..6b5f9aeace28a 100644 --- a/std/src/sys/pal/windows/api.rs +++ b/std/src/sys/pal/windows/api.rs @@ -137,7 +137,7 @@ pub const fn to_utf16(s: &str) -> [u16; UTF16_LEN] { /// use frequent `as` casts. This is risky because they are too powerful. /// For example, the following will compile today: /// -/// `std::mem::size_of:: as u32` +/// `size_of:: as u32` /// /// Note that `size_of` is never actually called, instead a function pointer is /// converted to a `u32`. Clippy would warn about this but, alas, it's not run @@ -147,7 +147,7 @@ const fn win32_size_of() -> u32 { // Uses a trait to workaround restriction on using generic types in inner items. trait Win32SizeOf: Sized { const WIN32_SIZE_OF: u32 = { - let size = core::mem::size_of::(); + let size = size_of::(); assert!(size <= u32::MAX as usize); size as u32 }; diff --git a/std/src/sys/pal/windows/args.rs b/std/src/sys/pal/windows/args.rs index e9fc19bcb99c1..3447a0157e4c5 100644 --- a/std/src/sys/pal/windows/args.rs +++ b/std/src/sys/pal/windows/args.rs @@ -327,7 +327,7 @@ pub(crate) fn make_bat_command_line( force_quotes: bool, ) -> io::Result> { const INVALID_ARGUMENT_ERROR: io::Error = - io::const_io_error!(io::ErrorKind::InvalidInput, r#"batch file arguments are invalid"#); + io::const_error!(io::ErrorKind::InvalidInput, r#"batch file arguments are invalid"#); // Set the start of the command line to `cmd.exe /c "` // It is necessary to surround the command in an extra pair of quotes, // hence the trailing quote here. It will be closed after all arguments @@ -340,7 +340,7 @@ pub(crate) fn make_bat_command_line( // Windows file names cannot contain a `"` character or end with `\\`. // If the script name does then return an error. if script.contains(&(b'"' as u16)) || script.last() == Some(&(b'\\' as u16)) { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, "Windows file names may not contain `\"` or end with `\\`" )); diff --git a/std/src/sys/pal/windows/args/tests.rs b/std/src/sys/pal/windows/args/tests.rs index 6d5c953cbd5c6..484a90ab056df 100644 --- a/std/src/sys/pal/windows/args/tests.rs +++ b/std/src/sys/pal/windows/args/tests.rs @@ -47,10 +47,10 @@ fn whitespace_behavior() { fn genius_quotes() { chk(r#"EXE "" """#, &["EXE", "", ""]); chk(r#"EXE "" """"#, &["EXE", "", r#"""#]); - chk(r#"EXE "this is """all""" in the same argument""#, &[ - "EXE", - r#"this is "all" in the same argument"#, - ]); + chk( + r#"EXE "this is """all""" in the same argument""#, + &["EXE", r#"this is "all" in the same argument"#], + ); chk(r#"EXE "a"""#, &["EXE", r#"a""#]); chk(r#"EXE "a"" a"#, &["EXE", r#"a" a"#]); // quotes cannot be escaped in command names diff --git a/std/src/sys/pal/windows/c.rs b/std/src/sys/pal/windows/c.rs index 9ce3e912caf1b..004cbee52f62a 100644 --- a/std/src/sys/pal/windows/c.rs +++ b/std/src/sys/pal/windows/c.rs @@ -6,7 +6,7 @@ #![allow(clippy::style)] use core::ffi::{CStr, c_uint, c_ulong, c_ushort, c_void}; -use core::{mem, ptr}; +use core::ptr; mod windows_sys; pub use windows_sys::*; @@ -39,7 +39,7 @@ pub fn nt_success(status: NTSTATUS) -> bool { impl UNICODE_STRING { pub fn from_ref(slice: &[u16]) -> Self { - let len = mem::size_of_val(slice); + let len = size_of_val(slice); Self { Length: len as _, MaximumLength: len as _, Buffer: slice.as_ptr() as _ } } } @@ -47,7 +47,7 @@ impl UNICODE_STRING { impl Default for OBJECT_ATTRIBUTES { fn default() -> Self { Self { - Length: mem::size_of::() as _, + Length: size_of::() as _, RootDirectory: ptr::null_mut(), ObjectName: ptr::null_mut(), Attributes: 0, @@ -115,7 +115,7 @@ if #[cfg(not(target_vendor = "uwp"))] { link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated") )] #[cfg_attr(not(target_arch = "x86"), link(name = "bcryptprimitives", kind = "raw-dylib"))] -extern "system" { +unsafe extern "system" { pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL; } @@ -164,7 +164,7 @@ compat_fn_with_fallback! { not(target_arch = "x86"), link(name = "api-ms-win-core-synch-l1-2-0", kind = "raw-dylib") )] -extern "system" { +unsafe extern "system" { pub fn WaitOnAddress( address: *const c_void, compareaddress: *const c_void, @@ -204,7 +204,7 @@ compat_fn_with_fallback! { pub fn NtReleaseKeyedEvent( EventHandle: HANDLE, Key: *const c_void, - Alertable: BOOLEAN, + Alertable: bool, Timeout: *mut i64 ) -> NTSTATUS { panic!("keyed events not available") @@ -213,7 +213,7 @@ compat_fn_with_fallback! { pub fn NtWaitForKeyedEvent( EventHandle: HANDLE, Key: *const c_void, - Alertable: BOOLEAN, + Alertable: bool, Timeout: *mut i64 ) -> NTSTATUS { panic!("keyed events not available") @@ -237,6 +237,17 @@ compat_fn_with_fallback! { STATUS_NOT_IMPLEMENTED } #[cfg(target_vendor = "uwp")] + pub fn NtOpenFile( + filehandle: *mut HANDLE, + desiredaccess: u32, + objectattributes: *const OBJECT_ATTRIBUTES, + iostatusblock: *mut IO_STATUS_BLOCK, + shareaccess: u32, + openoptions: u32 + ) -> NTSTATUS { + STATUS_NOT_IMPLEMENTED + } + #[cfg(target_vendor = "uwp")] pub fn NtReadFile( filehandle: HANDLE, event: HANDLE, diff --git a/std/src/sys/pal/windows/c/bindings.txt b/std/src/sys/pal/windows/c/bindings.txt index 248ce3c9ff624..e2c2163327968 100644 --- a/std/src/sys/pal/windows/c/bindings.txt +++ b/std/src/sys/pal/windows/c/bindings.txt @@ -1,2607 +1,2612 @@ --out windows_sys.rs ---config flatten sys +--flat +--sys +--no-core --filter -!Windows.Win32.Foundation.INVALID_HANDLE_VALUE -Windows.Wdk.Storage.FileSystem.FILE_COMPLETE_IF_OPLOCKED -Windows.Wdk.Storage.FileSystem.FILE_CONTAINS_EXTENDED_CREATE_INFORMATION -Windows.Wdk.Storage.FileSystem.FILE_CREATE -Windows.Wdk.Storage.FileSystem.FILE_CREATE_TREE_CONNECTION -Windows.Wdk.Storage.FileSystem.FILE_DELETE_ON_CLOSE -Windows.Wdk.Storage.FileSystem.FILE_DIRECTORY_FILE -Windows.Wdk.Storage.FileSystem.FILE_DISALLOW_EXCLUSIVE +!INVALID_HANDLE_VALUE +ABOVE_NORMAL_PRIORITY_CLASS +accept +AcquireSRWLockExclusive +AcquireSRWLockShared +ADDRESS_FAMILY +ADDRINFOA +AddVectoredExceptionHandler +AF_INET +AF_INET6 +AF_UNIX +AF_UNSPEC +ALL_PROCESSOR_GROUPS +ARM64_NT_NEON128 +BELOW_NORMAL_PRIORITY_CLASS +bind +BOOL +BY_HANDLE_FILE_INFORMATION +CALLBACK_CHUNK_FINISHED +CALLBACK_STREAM_SWITCH +CancelIo +CloseHandle +closesocket +COMPARESTRING_RESULT +CompareStringOrdinal +connect +CONSOLE_MODE +CONSOLE_READCONSOLE_CONTROL +CONTEXT +CopyFileExW +CP_UTF8 +CREATE_ALWAYS +CREATE_BREAKAWAY_FROM_JOB +CREATE_DEFAULT_ERROR_MODE +CREATE_FORCEDOS +CREATE_IGNORE_SYSTEM_DEFAULT +CREATE_NEW +CREATE_NEW_CONSOLE +CREATE_NEW_PROCESS_GROUP +CREATE_NO_WINDOW +CREATE_PRESERVE_CODE_AUTHZ_LEVEL +CREATE_PROTECTED_PROCESS +CREATE_SECURE_PROCESS +CREATE_SEPARATE_WOW_VDM +CREATE_SHARED_WOW_VDM +CREATE_SUSPENDED +CREATE_UNICODE_ENVIRONMENT +CREATE_WAITABLE_TIMER_HIGH_RESOLUTION +CREATE_WAITABLE_TIMER_MANUAL_RESET +CreateDirectoryW +CreateEventW +CreateFileW +CreateHardLinkW +CreateNamedPipeW +CreatePipe +CreateProcessW +CreateSymbolicLinkW +CreateThread +CreateWaitableTimerExW +CSTR_EQUAL +CSTR_GREATER_THAN +CSTR_LESS_THAN +DEBUG_ONLY_THIS_PROCESS +DEBUG_PROCESS +DELETE +DeleteFileW +DeleteProcThreadAttributeList +DETACHED_PROCESS +DeviceIoControl +DISABLE_NEWLINE_AUTO_RETURN +DLL_PROCESS_DETACH +DLL_THREAD_DETACH +DNS_ERROR_ADDRESS_REQUIRED +DNS_ERROR_ALIAS_LOOP +DNS_ERROR_AUTOZONE_ALREADY_EXISTS +DNS_ERROR_AXFR +DNS_ERROR_BACKGROUND_LOADING +DNS_ERROR_BAD_KEYMASTER +DNS_ERROR_BAD_PACKET +DNS_ERROR_CANNOT_FIND_ROOT_HINTS +DNS_ERROR_CLIENT_SUBNET_ALREADY_EXISTS +DNS_ERROR_CLIENT_SUBNET_DOES_NOT_EXIST +DNS_ERROR_CLIENT_SUBNET_IS_ACCESSED +DNS_ERROR_CNAME_COLLISION +DNS_ERROR_CNAME_LOOP +DNS_ERROR_DATAFILE_OPEN_FAILURE +DNS_ERROR_DATAFILE_PARSING +DNS_ERROR_DEFAULT_SCOPE +DNS_ERROR_DEFAULT_VIRTUALIZATION_INSTANCE +DNS_ERROR_DEFAULT_ZONESCOPE +DNS_ERROR_DELEGATION_REQUIRED +DNS_ERROR_DNAME_COLLISION +DNS_ERROR_DNSSEC_IS_DISABLED +DNS_ERROR_DP_ALREADY_ENLISTED +DNS_ERROR_DP_ALREADY_EXISTS +DNS_ERROR_DP_DOES_NOT_EXIST +DNS_ERROR_DP_FSMO_ERROR +DNS_ERROR_DP_NOT_AVAILABLE +DNS_ERROR_DP_NOT_ENLISTED +DNS_ERROR_DS_UNAVAILABLE +DNS_ERROR_DS_ZONE_ALREADY_EXISTS +DNS_ERROR_DWORD_VALUE_TOO_LARGE +DNS_ERROR_DWORD_VALUE_TOO_SMALL +DNS_ERROR_FILE_WRITEBACK_FAILED +DNS_ERROR_FORWARDER_ALREADY_EXISTS +DNS_ERROR_INCONSISTENT_ROOT_HINTS +DNS_ERROR_INVAILD_VIRTUALIZATION_INSTANCE_NAME +DNS_ERROR_INVALID_CLIENT_SUBNET_NAME +DNS_ERROR_INVALID_DATA +DNS_ERROR_INVALID_DATAFILE_NAME +DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET +DNS_ERROR_INVALID_IP_ADDRESS +DNS_ERROR_INVALID_KEY_SIZE +DNS_ERROR_INVALID_NAME +DNS_ERROR_INVALID_NAME_CHAR +DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT +DNS_ERROR_INVALID_POLICY_TABLE +DNS_ERROR_INVALID_PROPERTY +DNS_ERROR_INVALID_ROLLOVER_PERIOD +DNS_ERROR_INVALID_SCOPE_NAME +DNS_ERROR_INVALID_SCOPE_OPERATION +DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD +DNS_ERROR_INVALID_TYPE +DNS_ERROR_INVALID_XML +DNS_ERROR_INVALID_ZONE_OPERATION +DNS_ERROR_INVALID_ZONE_TYPE +DNS_ERROR_INVALID_ZONESCOPE_NAME +DNS_ERROR_KEYMASTER_REQUIRED +DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION +DNS_ERROR_KSP_NOT_ACCESSIBLE +DNS_ERROR_LOAD_ZONESCOPE_FAILED +DNS_ERROR_NAME_DOES_NOT_EXIST +DNS_ERROR_NAME_NOT_IN_ZONE +DNS_ERROR_NBSTAT_INIT_FAILED +DNS_ERROR_NEED_SECONDARY_ADDRESSES +DNS_ERROR_NEED_WINS_SERVERS +DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE +DNS_ERROR_NO_CREATE_CACHE_DATA +DNS_ERROR_NO_DNS_SERVERS +DNS_ERROR_NO_MEMORY +DNS_ERROR_NO_PACKET +DNS_ERROR_NO_TCPIP +DNS_ERROR_NO_VALID_TRUST_ANCHORS +DNS_ERROR_NO_ZONE_INFO +DNS_ERROR_NODE_CREATION_FAILED +DNS_ERROR_NODE_IS_CNAME +DNS_ERROR_NODE_IS_DNAME +DNS_ERROR_NON_RFC_NAME +DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD +DNS_ERROR_NOT_ALLOWED_ON_RODC +DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER +DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE +DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE +DNS_ERROR_NOT_ALLOWED_ON_ZSK +DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION +DNS_ERROR_NOT_ALLOWED_UNDER_DNAME +DNS_ERROR_NOT_ALLOWED_WITH_ZONESCOPES +DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS +DNS_ERROR_NOT_UNIQUE +DNS_ERROR_NSEC3_INCOMPATIBLE_WITH_RSA_SHA1 +DNS_ERROR_NSEC3_NAME_COLLISION +DNS_ERROR_NSEC_INCOMPATIBLE_WITH_NSEC3_RSA_SHA1 +DNS_ERROR_NUMERIC_NAME +DNS_ERROR_POLICY_ALREADY_EXISTS +DNS_ERROR_POLICY_DOES_NOT_EXIST +DNS_ERROR_POLICY_INVALID_CRITERIA +DNS_ERROR_POLICY_INVALID_CRITERIA_CLIENT_SUBNET +DNS_ERROR_POLICY_INVALID_CRITERIA_FQDN +DNS_ERROR_POLICY_INVALID_CRITERIA_INTERFACE +DNS_ERROR_POLICY_INVALID_CRITERIA_NETWORK_PROTOCOL +DNS_ERROR_POLICY_INVALID_CRITERIA_QUERY_TYPE +DNS_ERROR_POLICY_INVALID_CRITERIA_TIME_OF_DAY +DNS_ERROR_POLICY_INVALID_CRITERIA_TRANSPORT_PROTOCOL +DNS_ERROR_POLICY_INVALID_NAME +DNS_ERROR_POLICY_INVALID_SETTINGS +DNS_ERROR_POLICY_INVALID_WEIGHT +DNS_ERROR_POLICY_LOCKED +DNS_ERROR_POLICY_MISSING_CRITERIA +DNS_ERROR_POLICY_PROCESSING_ORDER_INVALID +DNS_ERROR_POLICY_SCOPE_MISSING +DNS_ERROR_POLICY_SCOPE_NOT_ALLOWED +DNS_ERROR_PRIMARY_REQUIRES_DATAFILE +DNS_ERROR_RCODE +DNS_ERROR_RCODE_BADKEY +DNS_ERROR_RCODE_BADSIG +DNS_ERROR_RCODE_BADTIME +DNS_ERROR_RCODE_FORMAT_ERROR +DNS_ERROR_RCODE_NAME_ERROR +DNS_ERROR_RCODE_NOT_IMPLEMENTED +DNS_ERROR_RCODE_NOTAUTH +DNS_ERROR_RCODE_NOTZONE +DNS_ERROR_RCODE_NXRRSET +DNS_ERROR_RCODE_REFUSED +DNS_ERROR_RCODE_SERVER_FAILURE +DNS_ERROR_RCODE_YXDOMAIN +DNS_ERROR_RCODE_YXRRSET +DNS_ERROR_RECORD_ALREADY_EXISTS +DNS_ERROR_RECORD_DOES_NOT_EXIST +DNS_ERROR_RECORD_FORMAT +DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT +DNS_ERROR_RECORD_TIMED_OUT +DNS_ERROR_ROLLOVER_ALREADY_QUEUED +DNS_ERROR_ROLLOVER_IN_PROGRESS +DNS_ERROR_ROLLOVER_NOT_POKEABLE +DNS_ERROR_RRL_INVALID_IPV4_PREFIX +DNS_ERROR_RRL_INVALID_IPV6_PREFIX +DNS_ERROR_RRL_INVALID_LEAK_RATE +DNS_ERROR_RRL_INVALID_TC_RATE +DNS_ERROR_RRL_INVALID_WINDOW_SIZE +DNS_ERROR_RRL_LEAK_RATE_LESSTHAN_TC_RATE +DNS_ERROR_RRL_NOT_ENABLED +DNS_ERROR_SCOPE_ALREADY_EXISTS +DNS_ERROR_SCOPE_DOES_NOT_EXIST +DNS_ERROR_SCOPE_LOCKED +DNS_ERROR_SECONDARY_DATA +DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP +DNS_ERROR_SERVERSCOPE_IS_REFERENCED +DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE +DNS_ERROR_SOA_DELETE_INVALID +DNS_ERROR_STANDBY_KEY_NOT_PRESENT +DNS_ERROR_SUBNET_ALREADY_EXISTS +DNS_ERROR_SUBNET_DOES_NOT_EXIST +DNS_ERROR_TOO_MANY_SKDS +DNS_ERROR_TRY_AGAIN_LATER +DNS_ERROR_UNEXPECTED_CNG_ERROR +DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR +DNS_ERROR_UNKNOWN_RECORD_TYPE +DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION +DNS_ERROR_UNSECURE_PACKET +DNS_ERROR_UNSUPPORTED_ALGORITHM +DNS_ERROR_VIRTUALIZATION_INSTANCE_ALREADY_EXISTS +DNS_ERROR_VIRTUALIZATION_INSTANCE_DOES_NOT_EXIST +DNS_ERROR_VIRTUALIZATION_TREE_LOCKED +DNS_ERROR_WINS_INIT_FAILED +DNS_ERROR_ZONE_ALREADY_EXISTS +DNS_ERROR_ZONE_CONFIGURATION_ERROR +DNS_ERROR_ZONE_CREATION_FAILED +DNS_ERROR_ZONE_DOES_NOT_EXIST +DNS_ERROR_ZONE_HAS_NO_NS_RECORDS +DNS_ERROR_ZONE_HAS_NO_SOA_RECORD +DNS_ERROR_ZONE_IS_SHUTDOWN +DNS_ERROR_ZONE_LOCKED +DNS_ERROR_ZONE_LOCKED_FOR_SIGNING +DNS_ERROR_ZONE_NOT_SECONDARY +DNS_ERROR_ZONE_REQUIRES_MASTER_IP +DNS_ERROR_ZONESCOPE_ALREADY_EXISTS +DNS_ERROR_ZONESCOPE_DOES_NOT_EXIST +DNS_ERROR_ZONESCOPE_FILE_WRITEBACK_FAILED +DNS_ERROR_ZONESCOPE_IS_REFERENCED +DUPLICATE_CLOSE_SOURCE +DUPLICATE_HANDLE_OPTIONS +DUPLICATE_SAME_ACCESS +DuplicateHandle +E_NOTIMPL +ENABLE_AUTO_POSITION +ENABLE_ECHO_INPUT +ENABLE_EXTENDED_FLAGS +ENABLE_INSERT_MODE +ENABLE_LINE_INPUT +ENABLE_LVB_GRID_WORLDWIDE +ENABLE_MOUSE_INPUT +ENABLE_PROCESSED_INPUT +ENABLE_PROCESSED_OUTPUT +ENABLE_QUICK_EDIT_MODE +ENABLE_VIRTUAL_TERMINAL_INPUT +ENABLE_VIRTUAL_TERMINAL_PROCESSING +ENABLE_WINDOW_INPUT +ENABLE_WRAP_AT_EOL_OUTPUT +ERROR_ABANDON_HIBERFILE +ERROR_ABANDONED_WAIT_0 +ERROR_ABANDONED_WAIT_63 +ERROR_ABIOS_ERROR +ERROR_ACCESS_AUDIT_BY_POLICY +ERROR_ACCESS_DENIED +ERROR_ACCESS_DENIED_APPDATA +ERROR_ACCESS_DISABLED_BY_POLICY +ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY +ERROR_ACCESS_DISABLED_WEBBLADE +ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER +ERROR_ACCOUNT_DISABLED +ERROR_ACCOUNT_EXPIRED +ERROR_ACCOUNT_LOCKED_OUT +ERROR_ACCOUNT_RESTRICTION +ERROR_ACPI_ERROR +ERROR_ACTIVE_CONNECTIONS +ERROR_ADAP_HDW_ERR +ERROR_ADDRESS_ALREADY_ASSOCIATED +ERROR_ADDRESS_NOT_ASSOCIATED +ERROR_ALERTED +ERROR_ALIAS_EXISTS +ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED +ERROR_ALLOCATE_BUCKET +ERROR_ALLOTTED_SPACE_EXCEEDED +ERROR_ALREADY_ASSIGNED +ERROR_ALREADY_EXISTS +ERROR_ALREADY_FIBER +ERROR_ALREADY_HAS_STREAM_ID +ERROR_ALREADY_INITIALIZED +ERROR_ALREADY_REGISTERED +ERROR_ALREADY_RUNNING_LKG +ERROR_ALREADY_THREAD +ERROR_ALREADY_WAITING +ERROR_ALREADY_WIN32 +ERROR_API_UNAVAILABLE +ERROR_APP_HANG +ERROR_APP_INIT_FAILURE +ERROR_APP_WRONG_OS +ERROR_APPCONTAINER_REQUIRED +ERROR_APPEXEC_APP_COMPAT_BLOCK +ERROR_APPEXEC_CALLER_WAIT_TIMEOUT +ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_LICENSING +ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_RESOURCES +ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_TERMINATION +ERROR_APPEXEC_CONDITION_NOT_SATISFIED +ERROR_APPEXEC_HANDLE_INVALIDATED +ERROR_APPEXEC_HOST_ID_MISMATCH +ERROR_APPEXEC_INVALID_HOST_GENERATION +ERROR_APPEXEC_INVALID_HOST_STATE +ERROR_APPEXEC_NO_DONOR +ERROR_APPEXEC_UNEXPECTED_PROCESS_REGISTRATION +ERROR_APPEXEC_UNKNOWN_USER +ERROR_APPHELP_BLOCK +ERROR_APPX_FILE_NOT_ENCRYPTED +ERROR_ARBITRATION_UNHANDLED +ERROR_ARENA_TRASHED +ERROR_ARITHMETIC_OVERFLOW +ERROR_ASSERTION_FAILURE +ERROR_ATOMIC_LOCKS_NOT_SUPPORTED +ERROR_AUDIT_FAILED +ERROR_AUTHENTICATION_FIREWALL_FAILED +ERROR_AUTHIP_FAILURE +ERROR_AUTODATASEG_EXCEEDS_64k +ERROR_BACKUP_CONTROLLER +ERROR_BAD_ACCESSOR_FLAGS +ERROR_BAD_ARGUMENTS +ERROR_BAD_COMMAND +ERROR_BAD_COMPRESSION_BUFFER +ERROR_BAD_CONFIGURATION +ERROR_BAD_CURRENT_DIRECTORY +ERROR_BAD_DESCRIPTOR_FORMAT +ERROR_BAD_DEV_TYPE +ERROR_BAD_DEVICE +ERROR_BAD_DEVICE_PATH +ERROR_BAD_DLL_ENTRYPOINT +ERROR_BAD_DRIVER_LEVEL +ERROR_BAD_ENVIRONMENT +ERROR_BAD_EXE_FORMAT +ERROR_BAD_FILE_TYPE +ERROR_BAD_FORMAT +ERROR_BAD_FUNCTION_TABLE +ERROR_BAD_IMPERSONATION_LEVEL +ERROR_BAD_INHERITANCE_ACL +ERROR_BAD_LENGTH +ERROR_BAD_LOGON_SESSION_STATE +ERROR_BAD_MCFG_TABLE +ERROR_BAD_NET_NAME +ERROR_BAD_NET_RESP +ERROR_BAD_NETPATH +ERROR_BAD_PATHNAME +ERROR_BAD_PIPE +ERROR_BAD_PROFILE +ERROR_BAD_PROVIDER +ERROR_BAD_QUERY_SYNTAX +ERROR_BAD_RECOVERY_POLICY +ERROR_BAD_REM_ADAP +ERROR_BAD_SERVICE_ENTRYPOINT +ERROR_BAD_STACK +ERROR_BAD_THREADID_ADDR +ERROR_BAD_TOKEN_TYPE +ERROR_BAD_UNIT +ERROR_BAD_USER_PROFILE +ERROR_BAD_USERNAME +ERROR_BAD_VALIDATION_CLASS +ERROR_BADDB +ERROR_BADKEY +ERROR_BADSTARTPOSITION +ERROR_BEGINNING_OF_MEDIA +ERROR_BEYOND_VDL +ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT +ERROR_BLOCK_SHARED +ERROR_BLOCK_SOURCE_WEAK_REFERENCE_INVALID +ERROR_BLOCK_TARGET_WEAK_REFERENCE_INVALID +ERROR_BLOCK_TOO_MANY_REFERENCES +ERROR_BLOCK_WEAK_REFERENCE_INVALID +ERROR_BLOCKED_BY_PARENTAL_CONTROLS +ERROR_BOOT_ALREADY_ACCEPTED +ERROR_BROKEN_PIPE +ERROR_BUFFER_ALL_ZEROS +ERROR_BUFFER_OVERFLOW +ERROR_BUS_RESET +ERROR_BUSY +ERROR_BUSY_DRIVE +ERROR_BYPASSIO_FLT_NOT_SUPPORTED +ERROR_CACHE_PAGE_LOCKED +ERROR_CALL_NOT_IMPLEMENTED +ERROR_CALLBACK_INVOKE_INLINE +ERROR_CALLBACK_POP_STACK +ERROR_CALLBACK_SUPPLIED_INVALID_DATA +ERROR_CAN_NOT_COMPLETE +ERROR_CANCEL_VIOLATION +ERROR_CANCELLED +ERROR_CANNOT_BREAK_OPLOCK +ERROR_CANNOT_COPY +ERROR_CANNOT_DETECT_DRIVER_FAILURE +ERROR_CANNOT_DETECT_PROCESS_ABORT +ERROR_CANNOT_FIND_WND_CLASS +ERROR_CANNOT_GRANT_REQUESTED_OPLOCK +ERROR_CANNOT_IMPERSONATE +ERROR_CANNOT_LOAD_REGISTRY_FILE +ERROR_CANNOT_MAKE +ERROR_CANNOT_OPEN_PROFILE +ERROR_CANT_ACCESS_DOMAIN_INFO +ERROR_CANT_ACCESS_FILE +ERROR_CANT_CLEAR_ENCRYPTION_FLAG +ERROR_CANT_DISABLE_MANDATORY +ERROR_CANT_ENABLE_DENY_ONLY +ERROR_CANT_OPEN_ANONYMOUS +ERROR_CANT_RESOLVE_FILENAME +ERROR_CANT_TERMINATE_SELF +ERROR_CANT_WAIT +ERROR_CANTFETCHBACKWARDS +ERROR_CANTOPEN +ERROR_CANTREAD +ERROR_CANTSCROLLBACKWARDS +ERROR_CANTWRITE +ERROR_CAPAUTHZ_CHANGE_TYPE +ERROR_CAPAUTHZ_DB_CORRUPTED +ERROR_CAPAUTHZ_NO_POLICY +ERROR_CAPAUTHZ_NOT_AUTHORIZED +ERROR_CAPAUTHZ_NOT_DEVUNLOCKED +ERROR_CAPAUTHZ_NOT_PROVISIONED +ERROR_CAPAUTHZ_SCCD_DEV_MODE_REQUIRED +ERROR_CAPAUTHZ_SCCD_INVALID_CATALOG +ERROR_CAPAUTHZ_SCCD_NO_AUTH_ENTITY +ERROR_CAPAUTHZ_SCCD_NO_CAPABILITY_MATCH +ERROR_CAPAUTHZ_SCCD_PARSE_ERROR +ERROR_CARDBUS_NOT_SUPPORTED +ERROR_CASE_DIFFERING_NAMES_IN_DIR +ERROR_CASE_SENSITIVE_PATH +ERROR_CERTIFICATE_VALIDATION_PREFERENCE_CONFLICT +ERROR_CHECKING_FILE_SYSTEM +ERROR_CHECKOUT_REQUIRED +ERROR_CHILD_MUST_BE_VOLATILE +ERROR_CHILD_NOT_COMPLETE +ERROR_CHILD_PROCESS_BLOCKED +ERROR_CHILD_WINDOW_MENU +ERROR_CIMFS_IMAGE_CORRUPT +ERROR_CIMFS_IMAGE_VERSION_NOT_SUPPORTED +ERROR_CIRCULAR_DEPENDENCY +ERROR_CLASS_ALREADY_EXISTS +ERROR_CLASS_DOES_NOT_EXIST +ERROR_CLASS_HAS_WINDOWS +ERROR_CLIENT_SERVER_PARAMETERS_INVALID +ERROR_CLIPBOARD_NOT_OPEN +ERROR_CLOUD_FILE_ACCESS_DENIED +ERROR_CLOUD_FILE_ALREADY_CONNECTED +ERROR_CLOUD_FILE_AUTHENTICATION_FAILED +ERROR_CLOUD_FILE_CONNECTED_PROVIDER_ONLY +ERROR_CLOUD_FILE_DEHYDRATION_DISALLOWED +ERROR_CLOUD_FILE_IN_USE +ERROR_CLOUD_FILE_INCOMPATIBLE_HARDLINKS +ERROR_CLOUD_FILE_INSUFFICIENT_RESOURCES +ERROR_CLOUD_FILE_INVALID_REQUEST +ERROR_CLOUD_FILE_METADATA_CORRUPT +ERROR_CLOUD_FILE_METADATA_TOO_LARGE +ERROR_CLOUD_FILE_NETWORK_UNAVAILABLE +ERROR_CLOUD_FILE_NOT_IN_SYNC +ERROR_CLOUD_FILE_NOT_SUPPORTED +ERROR_CLOUD_FILE_NOT_UNDER_SYNC_ROOT +ERROR_CLOUD_FILE_PINNED +ERROR_CLOUD_FILE_PROPERTY_BLOB_CHECKSUM_MISMATCH +ERROR_CLOUD_FILE_PROPERTY_BLOB_TOO_LARGE +ERROR_CLOUD_FILE_PROPERTY_CORRUPT +ERROR_CLOUD_FILE_PROPERTY_LOCK_CONFLICT +ERROR_CLOUD_FILE_PROPERTY_VERSION_NOT_SUPPORTED +ERROR_CLOUD_FILE_PROVIDER_NOT_RUNNING +ERROR_CLOUD_FILE_PROVIDER_TERMINATED +ERROR_CLOUD_FILE_READ_ONLY_VOLUME +ERROR_CLOUD_FILE_REQUEST_ABORTED +ERROR_CLOUD_FILE_REQUEST_CANCELED +ERROR_CLOUD_FILE_REQUEST_TIMEOUT +ERROR_CLOUD_FILE_SYNC_ROOT_METADATA_CORRUPT +ERROR_CLOUD_FILE_TOO_MANY_PROPERTY_BLOBS +ERROR_CLOUD_FILE_UNSUCCESSFUL +ERROR_CLOUD_FILE_US_MESSAGE_TIMEOUT +ERROR_CLOUD_FILE_VALIDATION_FAILED +ERROR_COMMITMENT_LIMIT +ERROR_COMMITMENT_MINIMUM +ERROR_COMPRESSED_FILE_NOT_SUPPORTED +ERROR_COMPRESSION_DISABLED +ERROR_COMPRESSION_NOT_BENEFICIAL +ERROR_CONNECTED_OTHER_PASSWORD +ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT +ERROR_CONNECTION_ABORTED +ERROR_CONNECTION_ACTIVE +ERROR_CONNECTION_COUNT_LIMIT +ERROR_CONNECTION_INVALID +ERROR_CONNECTION_REFUSED +ERROR_CONNECTION_UNAVAIL +ERROR_CONTAINER_ASSIGNED +ERROR_CONTENT_BLOCKED +ERROR_CONTEXT_EXPIRED +ERROR_CONTINUE +ERROR_CONTROL_C_EXIT +ERROR_CONTROL_ID_NOT_FOUND +ERROR_CONVERT_TO_LARGE +ERROR_CORRUPT_LOG_CLEARED +ERROR_CORRUPT_LOG_CORRUPTED +ERROR_CORRUPT_LOG_DELETED_FULL +ERROR_CORRUPT_LOG_OVERFULL +ERROR_CORRUPT_LOG_UNAVAILABLE +ERROR_CORRUPT_SYSTEM_FILE +ERROR_COULD_NOT_INTERPRET +ERROR_COUNTER_TIMEOUT +ERROR_CPU_SET_INVALID +ERROR_CRASH_DUMP +ERROR_CRC +ERROR_CREATE_FAILED +ERROR_CROSS_PARTITION_VIOLATION +ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE +ERROR_CS_ENCRYPTION_FILE_NOT_CSE +ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE +ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE +ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER +ERROR_CSCSHARE_OFFLINE +ERROR_CTX_CLIENT_QUERY_TIMEOUT +ERROR_CTX_MODEM_RESPONSE_TIMEOUT +ERROR_CURRENT_DIRECTORY +ERROR_CURRENT_DOMAIN_NOT_ALLOWED +ERROR_DATA_CHECKSUM_ERROR +ERROR_DATA_NOT_ACCEPTED +ERROR_DATABASE_DOES_NOT_EXIST +ERROR_DATATYPE_MISMATCH +ERROR_DAX_MAPPING_EXISTS +ERROR_DBG_COMMAND_EXCEPTION +ERROR_DBG_CONTINUE +ERROR_DBG_CONTROL_BREAK +ERROR_DBG_CONTROL_C +ERROR_DBG_EXCEPTION_HANDLED +ERROR_DBG_EXCEPTION_NOT_HANDLED +ERROR_DBG_PRINTEXCEPTION_C +ERROR_DBG_REPLY_LATER +ERROR_DBG_RIPEXCEPTION +ERROR_DBG_TERMINATE_PROCESS +ERROR_DBG_TERMINATE_THREAD +ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE +ERROR_DC_NOT_FOUND +ERROR_DDE_FAIL +ERROR_DEBUG_ATTACH_FAILED +ERROR_DEBUGGER_INACTIVE +ERROR_DECRYPTION_FAILED +ERROR_DELAY_LOAD_FAILED +ERROR_DELETE_PENDING +ERROR_DEPENDENT_SERVICES_RUNNING +ERROR_DESTINATION_ELEMENT_FULL +ERROR_DESTROY_OBJECT_OF_OTHER_THREAD +ERROR_DEV_NOT_EXIST +ERROR_DEVICE_ALREADY_ATTACHED +ERROR_DEVICE_ALREADY_REMEMBERED +ERROR_DEVICE_DOOR_OPEN +ERROR_DEVICE_ENUMERATION_ERROR +ERROR_DEVICE_FEATURE_NOT_SUPPORTED +ERROR_DEVICE_HARDWARE_ERROR +ERROR_DEVICE_HINT_NAME_BUFFER_TOO_SMALL +ERROR_DEVICE_IN_MAINTENANCE +ERROR_DEVICE_IN_USE +ERROR_DEVICE_NO_RESOURCES +ERROR_DEVICE_NOT_CONNECTED +ERROR_DEVICE_NOT_PARTITIONED +ERROR_DEVICE_REINITIALIZATION_NEEDED +ERROR_DEVICE_REMOVED +ERROR_DEVICE_REQUIRES_CLEANING +ERROR_DEVICE_RESET_REQUIRED +ERROR_DEVICE_SUPPORT_IN_PROGRESS +ERROR_DEVICE_UNREACHABLE +ERROR_DHCP_ADDRESS_CONFLICT +ERROR_DIFFERENT_SERVICE_ACCOUNT +ERROR_DIR_EFS_DISALLOWED +ERROR_DIR_NOT_EMPTY +ERROR_DIR_NOT_ROOT +ERROR_DIRECT_ACCESS_HANDLE +ERROR_DIRECTORY +ERROR_DIRECTORY_NOT_SUPPORTED +ERROR_DISCARDED +ERROR_DISK_CHANGE +ERROR_DISK_CORRUPT +ERROR_DISK_FULL +ERROR_DISK_OPERATION_FAILED +ERROR_DISK_QUOTA_EXCEEDED +ERROR_DISK_RECALIBRATE_FAILED +ERROR_DISK_REPAIR_DISABLED +ERROR_DISK_REPAIR_REDIRECTED +ERROR_DISK_REPAIR_UNSUCCESSFUL +ERROR_DISK_RESET_FAILED +ERROR_DISK_RESOURCES_EXHAUSTED +ERROR_DISK_TOO_FRAGMENTED +ERROR_DLL_INIT_FAILED +ERROR_DLL_INIT_FAILED_LOGOFF +ERROR_DLL_MIGHT_BE_INCOMPATIBLE +ERROR_DLL_MIGHT_BE_INSECURE +ERROR_DLL_NOT_FOUND +ERROR_DLP_POLICY_DENIES_OPERATION +ERROR_DLP_POLICY_SILENTLY_FAIL +ERROR_DLP_POLICY_WARNS_AGAINST_OPERATION +ERROR_DOMAIN_CONTROLLER_EXISTS +ERROR_DOMAIN_CONTROLLER_NOT_FOUND +ERROR_DOMAIN_CTRLR_CONFIG_ERROR +ERROR_DOMAIN_EXISTS +ERROR_DOMAIN_LIMIT_EXCEEDED +ERROR_DOMAIN_SID_SAME_AS_LOCAL_WORKSTATION +ERROR_DOMAIN_TRUST_INCONSISTENT +ERROR_DOWNGRADE_DETECTED +ERROR_DPL_NOT_SUPPORTED_FOR_USER +ERROR_DRIVE_LOCKED +ERROR_DRIVER_BLOCKED +ERROR_DRIVER_CANCEL_TIMEOUT +ERROR_DRIVER_DATABASE_ERROR +ERROR_DRIVER_FAILED_PRIOR_UNLOAD +ERROR_DRIVER_FAILED_SLEEP +ERROR_DRIVER_PROCESS_TERMINATED +ERROR_DRIVERS_LEAKING_LOCKED_PAGES +ERROR_DS_ADD_REPLICA_INHIBITED +ERROR_DS_ADMIN_LIMIT_EXCEEDED +ERROR_DS_AFFECTS_MULTIPLE_DSAS +ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER +ERROR_DS_ALIAS_DEREF_PROBLEM +ERROR_DS_ALIAS_POINTS_TO_ALIAS +ERROR_DS_ALIAS_PROBLEM +ERROR_DS_ALIASED_OBJ_MISSING +ERROR_DS_ATT_ALREADY_EXISTS +ERROR_DS_ATT_IS_NOT_ON_OBJ +ERROR_DS_ATT_NOT_DEF_FOR_CLASS +ERROR_DS_ATT_NOT_DEF_IN_SCHEMA +ERROR_DS_ATT_SCHEMA_REQ_ID +ERROR_DS_ATT_SCHEMA_REQ_SYNTAX +ERROR_DS_ATT_VAL_ALREADY_EXISTS +ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS +ERROR_DS_ATTRIBUTE_OWNED_BY_SAM +ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED +ERROR_DS_AUDIT_FAILURE +ERROR_DS_AUTH_METHOD_NOT_SUPPORTED +ERROR_DS_AUTH_UNKNOWN +ERROR_DS_AUTHORIZATION_FAILED +ERROR_DS_AUX_CLS_TEST_FAIL +ERROR_DS_BACKLINK_WITHOUT_LINK +ERROR_DS_BAD_ATT_SCHEMA_SYNTAX +ERROR_DS_BAD_HIERARCHY_FILE +ERROR_DS_BAD_INSTANCE_TYPE +ERROR_DS_BAD_NAME_SYNTAX +ERROR_DS_BAD_RDN_ATT_ID_SYNTAX +ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED +ERROR_DS_BUSY +ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD +ERROR_DS_CANT_ADD_ATT_VALUES +ERROR_DS_CANT_ADD_SYSTEM_ONLY +ERROR_DS_CANT_ADD_TO_GC +ERROR_DS_CANT_CACHE_ATT +ERROR_DS_CANT_CACHE_CLASS +ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC +ERROR_DS_CANT_CREATE_UNDER_SCHEMA +ERROR_DS_CANT_DEL_MASTER_CROSSREF +ERROR_DS_CANT_DELETE +ERROR_DS_CANT_DELETE_DSA_OBJ +ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC +ERROR_DS_CANT_DEREF_ALIAS +ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN +ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF +ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN +ERROR_DS_CANT_FIND_DSA_OBJ +ERROR_DS_CANT_FIND_EXPECTED_NC +ERROR_DS_CANT_FIND_NC_IN_CACHE +ERROR_DS_CANT_MIX_MASTER_AND_REPS +ERROR_DS_CANT_MOD_OBJ_CLASS +ERROR_DS_CANT_MOD_PRIMARYGROUPID +ERROR_DS_CANT_MOD_SYSTEM_ONLY +ERROR_DS_CANT_MOVE_ACCOUNT_GROUP +ERROR_DS_CANT_MOVE_APP_BASIC_GROUP +ERROR_DS_CANT_MOVE_APP_QUERY_GROUP +ERROR_DS_CANT_MOVE_DELETED_OBJECT +ERROR_DS_CANT_MOVE_RESOURCE_GROUP +ERROR_DS_CANT_ON_NON_LEAF +ERROR_DS_CANT_ON_RDN +ERROR_DS_CANT_REM_MISSING_ATT +ERROR_DS_CANT_REM_MISSING_ATT_VAL +ERROR_DS_CANT_REMOVE_ATT_CACHE +ERROR_DS_CANT_REMOVE_CLASS_CACHE +ERROR_DS_CANT_REPLACE_HIDDEN_REC +ERROR_DS_CANT_RETRIEVE_ATTS +ERROR_DS_CANT_RETRIEVE_CHILD +ERROR_DS_CANT_RETRIEVE_DN +ERROR_DS_CANT_RETRIEVE_INSTANCE +ERROR_DS_CANT_RETRIEVE_SD +ERROR_DS_CANT_START +ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ +ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS +ERROR_DS_CHILDREN_EXIST +ERROR_DS_CLASS_MUST_BE_CONCRETE +ERROR_DS_CLASS_NOT_DSA +ERROR_DS_CLIENT_LOOP +ERROR_DS_CODE_INCONSISTENCY +ERROR_DS_COMPARE_FALSE +ERROR_DS_COMPARE_TRUE +ERROR_DS_CONFIDENTIALITY_REQUIRED +ERROR_DS_CONFIG_PARAM_MISSING +ERROR_DS_CONSTRAINT_VIOLATION +ERROR_DS_CONSTRUCTED_ATT_MOD +ERROR_DS_CONTROL_NOT_FOUND +ERROR_DS_COULDNT_CONTACT_FSMO +ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE +ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE +ERROR_DS_COULDNT_UPDATE_SPNS +ERROR_DS_COUNTING_AB_INDICES_FAILED +ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE +ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2 +ERROR_DS_CROSS_DOM_MOVE_ERROR +ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD +ERROR_DS_CROSS_NC_DN_RENAME +ERROR_DS_CROSS_REF_BUSY +ERROR_DS_CROSS_REF_EXISTS +ERROR_DS_DATABASE_ERROR +ERROR_DS_DECODING_ERROR +ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED +ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST +ERROR_DS_DIFFERENT_REPL_EPOCHS +ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER +ERROR_DS_DISALLOWED_NC_REDIRECT +ERROR_DS_DNS_LOOKUP_FAILURE +ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST +ERROR_DS_DOMAIN_RENAME_IN_PROGRESS +ERROR_DS_DOMAIN_VERSION_TOO_HIGH +ERROR_DS_DOMAIN_VERSION_TOO_LOW +ERROR_DS_DRA_ABANDON_SYNC +ERROR_DS_DRA_ACCESS_DENIED +ERROR_DS_DRA_BAD_DN +ERROR_DS_DRA_BAD_INSTANCE_TYPE +ERROR_DS_DRA_BAD_NC +ERROR_DS_DRA_BUSY +ERROR_DS_DRA_CONNECTION_FAILED +ERROR_DS_DRA_CORRUPT_UTD_VECTOR +ERROR_DS_DRA_DB_ERROR +ERROR_DS_DRA_DN_EXISTS +ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT +ERROR_DS_DRA_EXTN_CONNECTION_FAILED +ERROR_DS_DRA_GENERIC +ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET +ERROR_DS_DRA_INCONSISTENT_DIT +ERROR_DS_DRA_INTERNAL_ERROR +ERROR_DS_DRA_INVALID_PARAMETER +ERROR_DS_DRA_MAIL_PROBLEM +ERROR_DS_DRA_MISSING_KRBTGT_SECRET +ERROR_DS_DRA_MISSING_PARENT +ERROR_DS_DRA_NAME_COLLISION +ERROR_DS_DRA_NO_REPLICA +ERROR_DS_DRA_NOT_SUPPORTED +ERROR_DS_DRA_OBJ_IS_REP_SOURCE +ERROR_DS_DRA_OBJ_NC_MISMATCH +ERROR_DS_DRA_OUT_OF_MEM +ERROR_DS_DRA_OUT_SCHEDULE_WINDOW +ERROR_DS_DRA_PREEMPTED +ERROR_DS_DRA_RECYCLED_TARGET +ERROR_DS_DRA_REF_ALREADY_EXISTS +ERROR_DS_DRA_REF_NOT_FOUND +ERROR_DS_DRA_REPL_PENDING +ERROR_DS_DRA_RPC_CANCELLED +ERROR_DS_DRA_SCHEMA_CONFLICT +ERROR_DS_DRA_SCHEMA_INFO_SHIP +ERROR_DS_DRA_SCHEMA_MISMATCH +ERROR_DS_DRA_SECRETS_DENIED +ERROR_DS_DRA_SHUTDOWN +ERROR_DS_DRA_SINK_DISABLED +ERROR_DS_DRA_SOURCE_DISABLED +ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA +ERROR_DS_DRA_SOURCE_REINSTALLED +ERROR_DS_DRS_EXTENSIONS_CHANGED +ERROR_DS_DS_REQUIRED +ERROR_DS_DSA_MUST_BE_INT_MASTER +ERROR_DS_DST_DOMAIN_NOT_NATIVE +ERROR_DS_DST_NC_MISMATCH +ERROR_DS_DUP_LDAP_DISPLAY_NAME +ERROR_DS_DUP_LINK_ID +ERROR_DS_DUP_MAPI_ID +ERROR_DS_DUP_MSDS_INTID +ERROR_DS_DUP_OID +ERROR_DS_DUP_RDN +ERROR_DS_DUP_SCHEMA_ID_GUID +ERROR_DS_DUPLICATE_ID_FOUND +ERROR_DS_ENCODING_ERROR +ERROR_DS_EPOCH_MISMATCH +ERROR_DS_EXISTING_AD_CHILD_NC +ERROR_DS_EXISTS_IN_AUX_CLS +ERROR_DS_EXISTS_IN_MAY_HAVE +ERROR_DS_EXISTS_IN_MUST_HAVE +ERROR_DS_EXISTS_IN_POSS_SUP +ERROR_DS_EXISTS_IN_RDNATTID +ERROR_DS_EXISTS_IN_SUB_CLS +ERROR_DS_FILTER_UNKNOWN +ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS +ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST +ERROR_DS_FOREST_VERSION_TOO_HIGH +ERROR_DS_FOREST_VERSION_TOO_LOW +ERROR_DS_GC_NOT_AVAILABLE +ERROR_DS_GC_REQUIRED +ERROR_DS_GCVERIFY_ERROR +ERROR_DS_GENERIC_ERROR +ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER +ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER +ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER +ERROR_DS_GOVERNSID_MISSING +ERROR_DS_GROUP_CONVERSION_ERROR +ERROR_DS_HAVE_PRIMARY_MEMBERS +ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED +ERROR_DS_HIERARCHY_TABLE_TOO_DEEP +ERROR_DS_HIGH_ADLDS_FFL +ERROR_DS_HIGH_DSA_VERSION +ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD +ERROR_DS_ILLEGAL_MOD_OPERATION +ERROR_DS_ILLEGAL_SUPERIOR +ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION +ERROR_DS_INAPPROPRIATE_AUTH +ERROR_DS_INAPPROPRIATE_MATCHING +ERROR_DS_INCOMPATIBLE_CONTROLS_USED +ERROR_DS_INCOMPATIBLE_VERSION +ERROR_DS_INCORRECT_ROLE_OWNER +ERROR_DS_INIT_FAILURE +ERROR_DS_INIT_FAILURE_CONSOLE +ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE +ERROR_DS_INSTALL_NO_SRC_SCH_VERSION +ERROR_DS_INSTALL_SCHEMA_MISMATCH +ERROR_DS_INSUFF_ACCESS_RIGHTS +ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT +ERROR_DS_INTERNAL_FAILURE +ERROR_DS_INVALID_ATTRIBUTE_SYNTAX +ERROR_DS_INVALID_DMD +ERROR_DS_INVALID_DN_SYNTAX +ERROR_DS_INVALID_GROUP_TYPE +ERROR_DS_INVALID_LDAP_DISPLAY_NAME +ERROR_DS_INVALID_NAME_FOR_SPN +ERROR_DS_INVALID_ROLE_OWNER +ERROR_DS_INVALID_SCRIPT +ERROR_DS_INVALID_SEARCH_FLAG +ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE +ERROR_DS_INVALID_SEARCH_FLAG_TUPLE +ERROR_DS_IS_LEAF +ERROR_DS_KEY_NOT_UNIQUE +ERROR_DS_LDAP_SEND_QUEUE_FULL +ERROR_DS_LINK_ID_NOT_AVAILABLE +ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER +ERROR_DS_LOCAL_ERROR +ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY +ERROR_DS_LOOP_DETECT +ERROR_DS_LOW_ADLDS_FFL +ERROR_DS_LOW_DSA_VERSION +ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4 +ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED +ERROR_DS_MAPI_ID_NOT_AVAILABLE +ERROR_DS_MASTERDSA_REQUIRED +ERROR_DS_MAX_OBJ_SIZE_EXCEEDED +ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY +ERROR_DS_MISSING_EXPECTED_ATT +ERROR_DS_MISSING_FOREST_TRUST +ERROR_DS_MISSING_FSMO_SETTINGS +ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER +ERROR_DS_MISSING_REQUIRED_ATT +ERROR_DS_MISSING_SUPREF +ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG +ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE +ERROR_DS_MODIFYDN_WRONG_GRANDPARENT +ERROR_DS_MUST_BE_RUN_ON_DST_DC +ERROR_DS_NAME_ERROR_DOMAIN_ONLY +ERROR_DS_NAME_ERROR_NO_MAPPING +ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING +ERROR_DS_NAME_ERROR_NOT_FOUND +ERROR_DS_NAME_ERROR_NOT_UNIQUE +ERROR_DS_NAME_ERROR_RESOLVING +ERROR_DS_NAME_ERROR_TRUST_REFERRAL +ERROR_DS_NAME_NOT_UNIQUE +ERROR_DS_NAME_REFERENCE_INVALID +ERROR_DS_NAME_TOO_LONG +ERROR_DS_NAME_TOO_MANY_PARTS +ERROR_DS_NAME_TYPE_UNKNOWN +ERROR_DS_NAME_UNPARSEABLE +ERROR_DS_NAME_VALUE_TOO_LONG +ERROR_DS_NAMING_MASTER_GC +ERROR_DS_NAMING_VIOLATION +ERROR_DS_NC_MUST_HAVE_NC_PARENT +ERROR_DS_NC_STILL_HAS_DSAS +ERROR_DS_NCNAME_MISSING_CR_REF +ERROR_DS_NCNAME_MUST_BE_NC +ERROR_DS_NO_ATTRIBUTE_OR_VALUE +ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN +ERROR_DS_NO_CHAINED_EVAL +ERROR_DS_NO_CHAINING +ERROR_DS_NO_CHECKPOINT_WITH_PDC +ERROR_DS_NO_CROSSREF_FOR_NC +ERROR_DS_NO_DELETED_NAME +ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS +ERROR_DS_NO_MORE_RIDS +ERROR_DS_NO_MSDS_INTID +ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN +ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN +ERROR_DS_NO_NTDSA_OBJECT +ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC +ERROR_DS_NO_PARENT_OBJECT +ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION +ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA +ERROR_DS_NO_REF_DOMAIN +ERROR_DS_NO_REQUESTED_ATTS_FOUND +ERROR_DS_NO_RESULTS_RETURNED +ERROR_DS_NO_RIDS_ALLOCATED +ERROR_DS_NO_SERVER_OBJECT +ERROR_DS_NO_SUCH_OBJECT +ERROR_DS_NO_TREE_DELETE_ABOVE_NC +ERROR_DS_NON_ASQ_SEARCH +ERROR_DS_NON_BASE_SEARCH +ERROR_DS_NONEXISTENT_MAY_HAVE +ERROR_DS_NONEXISTENT_MUST_HAVE +ERROR_DS_NONEXISTENT_POSS_SUP +ERROR_DS_NONSAFE_SCHEMA_CHANGE +ERROR_DS_NOT_AN_OBJECT +ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC +ERROR_DS_NOT_CLOSEST +ERROR_DS_NOT_INSTALLED +ERROR_DS_NOT_ON_BACKLINK +ERROR_DS_NOT_SUPPORTED +ERROR_DS_NOT_SUPPORTED_SORT_ORDER +ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX +ERROR_DS_NTDSCRIPT_PROCESS_ERROR +ERROR_DS_NTDSCRIPT_SYNTAX_ERROR +ERROR_DS_OBJ_CLASS_NOT_DEFINED +ERROR_DS_OBJ_CLASS_NOT_SUBCLASS +ERROR_DS_OBJ_CLASS_VIOLATION +ERROR_DS_OBJ_GUID_EXISTS +ERROR_DS_OBJ_NOT_FOUND +ERROR_DS_OBJ_STRING_NAME_EXISTS +ERROR_DS_OBJ_TOO_LARGE +ERROR_DS_OBJECT_BEING_REMOVED +ERROR_DS_OBJECT_CLASS_REQUIRED +ERROR_DS_OBJECT_RESULTS_TOO_LARGE +ERROR_DS_OFFSET_RANGE_ERROR +ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS +ERROR_DS_OID_NOT_FOUND +ERROR_DS_OPERATIONS_ERROR +ERROR_DS_OUT_OF_SCOPE +ERROR_DS_OUT_OF_VERSION_STORE +ERROR_DS_PARAM_ERROR +ERROR_DS_PARENT_IS_AN_ALIAS +ERROR_DS_PDC_OPERATION_IN_PROGRESS +ERROR_DS_PER_ATTRIBUTE_AUTHZ_FAILED_DURING_ADD +ERROR_DS_POLICY_NOT_KNOWN +ERROR_DS_PROTOCOL_ERROR +ERROR_DS_RANGE_CONSTRAINT +ERROR_DS_RDN_DOESNT_MATCH_SCHEMA +ERROR_DS_RECALCSCHEMA_FAILED +ERROR_DS_REFERRAL +ERROR_DS_REFERRAL_LIMIT_EXCEEDED +ERROR_DS_REFUSING_FSMO_ROLES +ERROR_DS_REMOTE_CROSSREF_OP_FAILED +ERROR_DS_REPL_LIFETIME_EXCEEDED +ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR +ERROR_DS_REPLICATOR_ONLY +ERROR_DS_RESERVED_LINK_ID +ERROR_DS_RESERVED_MAPI_ID +ERROR_DS_RIDMGR_DISABLED +ERROR_DS_RIDMGR_INIT_ERROR +ERROR_DS_ROLE_NOT_VERIFIED +ERROR_DS_ROOT_CANT_BE_SUBREF +ERROR_DS_ROOT_MUST_BE_NC +ERROR_DS_ROOT_REQUIRES_CLASS_TOP +ERROR_DS_SAM_INIT_FAILURE +ERROR_DS_SAM_INIT_FAILURE_CONSOLE +ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY +ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD +ERROR_DS_SCHEMA_ALLOC_FAILED +ERROR_DS_SCHEMA_NOT_LOADED +ERROR_DS_SCHEMA_UPDATE_DISALLOWED +ERROR_DS_SEC_DESC_INVALID +ERROR_DS_SEC_DESC_TOO_SHORT +ERROR_DS_SECURITY_CHECKING_ERROR +ERROR_DS_SECURITY_ILLEGAL_MODIFY +ERROR_DS_SEMANTIC_ATT_TEST +ERROR_DS_SENSITIVE_GROUP_VIOLATION +ERROR_DS_SERVER_DOWN +ERROR_DS_SHUTTING_DOWN +ERROR_DS_SINGLE_USER_MODE_FAILED +ERROR_DS_SINGLE_VALUE_CONSTRAINT +ERROR_DS_SIZELIMIT_EXCEEDED +ERROR_DS_SORT_CONTROL_MISSING +ERROR_DS_SOURCE_AUDITING_NOT_ENABLED +ERROR_DS_SOURCE_DOMAIN_IN_FOREST +ERROR_DS_SPN_VALUE_NOT_UNIQUE_IN_FOREST +ERROR_DS_SRC_AND_DST_NC_IDENTICAL +ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH +ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER +ERROR_DS_SRC_GUID_MISMATCH +ERROR_DS_SRC_NAME_MISMATCH +ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER +ERROR_DS_SRC_SID_EXISTS_IN_FOREST +ERROR_DS_STRING_SD_CONVERSION_FAILED +ERROR_DS_STRONG_AUTH_REQUIRED +ERROR_DS_SUB_CLS_TEST_FAIL +ERROR_DS_SUBREF_MUST_HAVE_PARENT +ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD +ERROR_DS_SYNTAX_MISMATCH +ERROR_DS_THREAD_LIMIT_EXCEEDED +ERROR_DS_TIMELIMIT_EXCEEDED +ERROR_DS_TREE_DELETE_NOT_FINISHED +ERROR_DS_UNABLE_TO_SURRENDER_ROLES +ERROR_DS_UNAVAILABLE +ERROR_DS_UNAVAILABLE_CRIT_EXTENSION +ERROR_DS_UNDELETE_SAM_VALIDATION_FAILED +ERROR_DS_UNICODEPWD_NOT_IN_QUOTES +ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER +ERROR_DS_UNKNOWN_ERROR +ERROR_DS_UNKNOWN_OPERATION +ERROR_DS_UNWILLING_TO_PERFORM +ERROR_DS_UPN_VALUE_NOT_UNIQUE_IN_FOREST +ERROR_DS_USER_BUFFER_TO_SMALL +ERROR_DS_VALUE_KEY_NOT_UNIQUE +ERROR_DS_VERSION_CHECK_FAILURE +ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL +ERROR_DS_WRONG_LINKED_ATT_SYNTAX +ERROR_DS_WRONG_OM_OBJ_CLASS +ERROR_DUP_DOMAINNAME +ERROR_DUP_NAME +ERROR_DUPLICATE_PRIVILEGES +ERROR_DUPLICATE_SERVICE_NAME +ERROR_DYNAMIC_CODE_BLOCKED +ERROR_DYNLINK_FROM_INVALID_RING +ERROR_EA_ACCESS_DENIED +ERROR_EA_FILE_CORRUPT +ERROR_EA_LIST_INCONSISTENT +ERROR_EA_TABLE_FULL +ERROR_EAS_DIDNT_FIT +ERROR_EAS_NOT_SUPPORTED +ERROR_EDP_DPL_POLICY_CANT_BE_SATISFIED +ERROR_EDP_POLICY_DENIES_OPERATION +ERROR_EFS_ALG_BLOB_TOO_BIG +ERROR_EFS_DISABLED +ERROR_EFS_SERVER_NOT_TRUSTED +ERROR_EFS_VERSION_NOT_SUPPORT +ERROR_ELEVATION_REQUIRED +ERROR_ENCLAVE_FAILURE +ERROR_ENCLAVE_NOT_TERMINATED +ERROR_ENCLAVE_VIOLATION +ERROR_ENCRYPTED_FILE_NOT_SUPPORTED +ERROR_ENCRYPTED_IO_NOT_POSSIBLE +ERROR_ENCRYPTING_METADATA_DISALLOWED +ERROR_ENCRYPTION_DISABLED +ERROR_ENCRYPTION_FAILED +ERROR_ENCRYPTION_POLICY_DENIES_OPERATION +ERROR_END_OF_MEDIA +ERROR_ENVVAR_NOT_FOUND +ERROR_EOM_OVERFLOW +ERROR_ERRORS_ENCOUNTERED +ERROR_EVALUATION_EXPIRATION +ERROR_EVENT_DONE +ERROR_EVENT_PENDING +ERROR_EVENTLOG_CANT_START +ERROR_EVENTLOG_FILE_CHANGED +ERROR_EVENTLOG_FILE_CORRUPT +ERROR_EXCEPTION_IN_SERVICE +ERROR_EXCL_SEM_ALREADY_OWNED +ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY +ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY +ERROR_EXE_MACHINE_TYPE_MISMATCH +ERROR_EXE_MARKED_INVALID +ERROR_EXTENDED_ERROR +ERROR_EXTERNAL_BACKING_PROVIDER_UNKNOWN +ERROR_EXTERNAL_SYSKEY_NOT_SUPPORTED +ERROR_EXTRANEOUS_INFORMATION +ERROR_FAIL_FAST_EXCEPTION +ERROR_FAIL_I24 +ERROR_FAIL_NOACTION_REBOOT +ERROR_FAIL_RESTART +ERROR_FAIL_SHUTDOWN +ERROR_FAILED_DRIVER_ENTRY +ERROR_FAILED_SERVICE_CONTROLLER_CONNECT +ERROR_FATAL_APP_EXIT +ERROR_FILE_CHECKED_OUT +ERROR_FILE_CORRUPT +ERROR_FILE_ENCRYPTED +ERROR_FILE_EXISTS +ERROR_FILE_HANDLE_REVOKED +ERROR_FILE_INVALID +ERROR_FILE_LEVEL_TRIM_NOT_SUPPORTED +ERROR_FILE_METADATA_OPTIMIZATION_IN_PROGRESS +ERROR_FILE_NOT_ENCRYPTED +ERROR_FILE_NOT_FOUND +ERROR_FILE_NOT_SUPPORTED +ERROR_FILE_OFFLINE +ERROR_FILE_PROTECTED_UNDER_DPL +ERROR_FILE_READ_ONLY +ERROR_FILE_SNAP_IN_PROGRESS +ERROR_FILE_SNAP_INVALID_PARAMETER +ERROR_FILE_SNAP_IO_NOT_COORDINATED +ERROR_FILE_SNAP_MODIFY_NOT_SUPPORTED +ERROR_FILE_SNAP_UNEXPECTED_ERROR +ERROR_FILE_SNAP_USER_SECTION_NOT_SUPPORTED +ERROR_FILE_SYSTEM_LIMITATION +ERROR_FILE_SYSTEM_VIRTUALIZATION_BUSY +ERROR_FILE_SYSTEM_VIRTUALIZATION_INVALID_OPERATION +ERROR_FILE_SYSTEM_VIRTUALIZATION_METADATA_CORRUPT +ERROR_FILE_SYSTEM_VIRTUALIZATION_PROVIDER_UNKNOWN +ERROR_FILE_SYSTEM_VIRTUALIZATION_UNAVAILABLE +ERROR_FILE_TOO_LARGE +ERROR_FILEMARK_DETECTED +ERROR_FILENAME_EXCED_RANGE +ERROR_FIRMWARE_UPDATED +ERROR_FLOAT_MULTIPLE_FAULTS +ERROR_FLOAT_MULTIPLE_TRAPS +ERROR_FLOPPY_BAD_REGISTERS +ERROR_FLOPPY_ID_MARK_NOT_FOUND +ERROR_FLOPPY_UNKNOWN_ERROR +ERROR_FLOPPY_VOLUME +ERROR_FLOPPY_WRONG_CYLINDER +ERROR_FORMS_AUTH_REQUIRED +ERROR_FOUND_OUT_OF_SCOPE +ERROR_FS_DRIVER_REQUIRED +ERROR_FS_METADATA_INCONSISTENT +ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY +ERROR_FT_DI_SCAN_REQUIRED +ERROR_FT_READ_FAILURE +ERROR_FT_READ_FROM_COPY_FAILURE +ERROR_FT_READ_RECOVERY_FROM_BACKUP +ERROR_FT_WRITE_FAILURE +ERROR_FT_WRITE_RECOVERY +ERROR_FULLSCREEN_MODE +ERROR_FUNCTION_FAILED +ERROR_FUNCTION_NOT_CALLED +ERROR_GDI_HANDLE_LEAK +ERROR_GEN_FAILURE +ERROR_GENERIC_NOT_MAPPED +ERROR_GLOBAL_ONLY_HOOK +ERROR_GRACEFUL_DISCONNECT +ERROR_GROUP_EXISTS +ERROR_GUID_SUBSTITUTION_MADE +ERROR_HANDLE_DISK_FULL +ERROR_HANDLE_EOF +ERROR_HANDLE_REVOKED +ERROR_HANDLES_CLOSED +ERROR_HAS_SYSTEM_CRITICAL_FILES +ERROR_HIBERNATED +ERROR_HIBERNATION_FAILURE +ERROR_HOOK_NEEDS_HMOD +ERROR_HOOK_NOT_INSTALLED +ERROR_HOOK_TYPE_NOT_ALLOWED +ERROR_HOST_DOWN +ERROR_HOST_UNREACHABLE +ERROR_HOTKEY_ALREADY_REGISTERED +ERROR_HOTKEY_NOT_REGISTERED +ERROR_HWNDS_HAVE_DIFF_PARENT +ERROR_ILL_FORMED_PASSWORD +ERROR_ILLEGAL_CHARACTER +ERROR_ILLEGAL_DLL_RELOCATION +ERROR_ILLEGAL_ELEMENT_ADDRESS +ERROR_ILLEGAL_FLOAT_CONTEXT +ERROR_IMAGE_AT_DIFFERENT_BASE +ERROR_IMAGE_MACHINE_TYPE_MISMATCH +ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE +ERROR_IMAGE_NOT_AT_BASE +ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT +ERROR_IMPLEMENTATION_LIMIT +ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE +ERROR_INCOMPATIBLE_SERVICE_SID_TYPE +ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING +ERROR_INCORRECT_ACCOUNT_TYPE +ERROR_INCORRECT_ADDRESS +ERROR_INCORRECT_SIZE +ERROR_INDEX_ABSENT +ERROR_INDEX_OUT_OF_BOUNDS +ERROR_INFLOOP_IN_RELOC_CHAIN +ERROR_INSTALL_ALREADY_RUNNING +ERROR_INSTALL_FAILURE +ERROR_INSTALL_LANGUAGE_UNSUPPORTED +ERROR_INSTALL_LOG_FAILURE +ERROR_INSTALL_NOTUSED +ERROR_INSTALL_PACKAGE_INVALID +ERROR_INSTALL_PACKAGE_OPEN_FAILED +ERROR_INSTALL_PACKAGE_REJECTED +ERROR_INSTALL_PACKAGE_VERSION +ERROR_INSTALL_PLATFORM_UNSUPPORTED +ERROR_INSTALL_REJECTED +ERROR_INSTALL_REMOTE_DISALLOWED +ERROR_INSTALL_REMOTE_PROHIBITED +ERROR_INSTALL_SERVICE_FAILURE +ERROR_INSTALL_SERVICE_SAFEBOOT +ERROR_INSTALL_SOURCE_ABSENT +ERROR_INSTALL_SUSPEND +ERROR_INSTALL_TEMP_UNWRITABLE +ERROR_INSTALL_TRANSFORM_FAILURE +ERROR_INSTALL_TRANSFORM_REJECTED +ERROR_INSTALL_UI_FAILURE +ERROR_INSTALL_USEREXIT +ERROR_INSTRUCTION_MISALIGNMENT +ERROR_INSUFFICIENT_BUFFER +ERROR_INSUFFICIENT_LOGON_INFO +ERROR_INSUFFICIENT_POWER +ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE +ERROR_INSUFFICIENT_VIRTUAL_ADDR_RESOURCES +ERROR_INTERMIXED_KERNEL_EA_OPERATION +ERROR_INTERNAL_DB_CORRUPTION +ERROR_INTERNAL_DB_ERROR +ERROR_INTERNAL_ERROR +ERROR_INTERRUPT_STILL_CONNECTED +ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED +ERROR_INVALID_ACCEL_HANDLE +ERROR_INVALID_ACCESS +ERROR_INVALID_ACCOUNT_NAME +ERROR_INVALID_ACE_CONDITION +ERROR_INVALID_ACL +ERROR_INVALID_ADDRESS +ERROR_INVALID_AT_INTERRUPT_TIME +ERROR_INVALID_BLOCK +ERROR_INVALID_BLOCK_LENGTH +ERROR_INVALID_CAP +ERROR_INVALID_CATEGORY +ERROR_INVALID_COMBOBOX_MESSAGE +ERROR_INVALID_COMMAND_LINE +ERROR_INVALID_COMPUTERNAME +ERROR_INVALID_CRUNTIME_PARAMETER +ERROR_INVALID_CURSOR_HANDLE +ERROR_INVALID_DATA +ERROR_INVALID_DATATYPE +ERROR_INVALID_DEVICE_OBJECT_PARAMETER +ERROR_INVALID_DLL +ERROR_INVALID_DOMAIN_ROLE +ERROR_INVALID_DOMAIN_STATE +ERROR_INVALID_DOMAINNAME +ERROR_INVALID_DRIVE +ERROR_INVALID_DWP_HANDLE +ERROR_INVALID_EA_HANDLE +ERROR_INVALID_EA_NAME +ERROR_INVALID_EDIT_HEIGHT +ERROR_INVALID_ENVIRONMENT +ERROR_INVALID_EVENT_COUNT +ERROR_INVALID_EVENTNAME +ERROR_INVALID_EXCEPTION_HANDLER +ERROR_INVALID_EXE_SIGNATURE +ERROR_INVALID_FIELD +ERROR_INVALID_FIELD_IN_PARAMETER_LIST +ERROR_INVALID_FILTER_PROC +ERROR_INVALID_FLAG_NUMBER +ERROR_INVALID_FLAGS +ERROR_INVALID_FORM_NAME +ERROR_INVALID_FORM_SIZE +ERROR_INVALID_FUNCTION +ERROR_INVALID_GROUP_ATTRIBUTES +ERROR_INVALID_GROUPNAME +ERROR_INVALID_GW_COMMAND +ERROR_INVALID_HANDLE +ERROR_INVALID_HANDLE_STATE +ERROR_INVALID_HOOK_FILTER +ERROR_INVALID_HOOK_HANDLE +ERROR_INVALID_HW_PROFILE +ERROR_INVALID_ICON_HANDLE +ERROR_INVALID_ID_AUTHORITY +ERROR_INVALID_IMAGE_HASH +ERROR_INVALID_IMPORT_OF_NON_DLL +ERROR_INVALID_INDEX +ERROR_INVALID_KERNEL_INFO_VERSION +ERROR_INVALID_KEYBOARD_HANDLE +ERROR_INVALID_LABEL +ERROR_INVALID_LB_MESSAGE +ERROR_INVALID_LDT_DESCRIPTOR +ERROR_INVALID_LDT_OFFSET +ERROR_INVALID_LDT_SIZE +ERROR_INVALID_LEVEL +ERROR_INVALID_LIST_FORMAT +ERROR_INVALID_LOCK_RANGE +ERROR_INVALID_LOGON_HOURS +ERROR_INVALID_LOGON_TYPE +ERROR_INVALID_MEMBER +ERROR_INVALID_MENU_HANDLE +ERROR_INVALID_MESSAGE +ERROR_INVALID_MESSAGEDEST +ERROR_INVALID_MESSAGENAME +ERROR_INVALID_MINALLOCSIZE +ERROR_INVALID_MODULETYPE +ERROR_INVALID_MONITOR_HANDLE +ERROR_INVALID_MSGBOX_STYLE +ERROR_INVALID_NAME +ERROR_INVALID_NETNAME +ERROR_INVALID_OPLOCK_PROTOCOL +ERROR_INVALID_ORDINAL +ERROR_INVALID_OWNER +ERROR_INVALID_PACKAGE_SID_LENGTH +ERROR_INVALID_PARAMETER +ERROR_INVALID_PASSWORD +ERROR_INVALID_PASSWORDNAME +ERROR_INVALID_PATCH_XML +ERROR_INVALID_PEP_INFO_VERSION +ERROR_INVALID_PLUGPLAY_DEVICE_PATH +ERROR_INVALID_PORT_ATTRIBUTES +ERROR_INVALID_PRIMARY_GROUP +ERROR_INVALID_PRINTER_COMMAND +ERROR_INVALID_PRINTER_NAME +ERROR_INVALID_PRINTER_STATE +ERROR_INVALID_PRIORITY +ERROR_INVALID_QUOTA_LOWER +ERROR_INVALID_REPARSE_DATA +ERROR_INVALID_SCROLLBAR_RANGE +ERROR_INVALID_SECURITY_DESCR +ERROR_INVALID_SEGDPL +ERROR_INVALID_SEGMENT_NUMBER +ERROR_INVALID_SEPARATOR_FILE +ERROR_INVALID_SERVER_STATE +ERROR_INVALID_SERVICE_ACCOUNT +ERROR_INVALID_SERVICE_CONTROL +ERROR_INVALID_SERVICE_LOCK +ERROR_INVALID_SERVICENAME +ERROR_INVALID_SHARENAME +ERROR_INVALID_SHOWWIN_COMMAND +ERROR_INVALID_SID +ERROR_INVALID_SIGNAL_NUMBER +ERROR_INVALID_SPI_VALUE +ERROR_INVALID_STACKSEG +ERROR_INVALID_STARTING_CODESEG +ERROR_INVALID_SUB_AUTHORITY +ERROR_INVALID_TABLE +ERROR_INVALID_TARGET_HANDLE +ERROR_INVALID_TASK_INDEX +ERROR_INVALID_TASK_NAME +ERROR_INVALID_THREAD_ID +ERROR_INVALID_TIME +ERROR_INVALID_TOKEN +ERROR_INVALID_UNWIND_TARGET +ERROR_INVALID_USER_BUFFER +ERROR_INVALID_USER_PRINCIPAL_NAME +ERROR_INVALID_VARIANT +ERROR_INVALID_VERIFY_SWITCH +ERROR_INVALID_WINDOW_HANDLE +ERROR_INVALID_WORKSTATION +ERROR_IO_DEVICE +ERROR_IO_INCOMPLETE +ERROR_IO_PENDING +ERROR_IO_PRIVILEGE_FAILED +ERROR_IO_REISSUE_AS_CACHED +ERROR_IOPL_NOT_ENABLED +ERROR_IP_ADDRESS_CONFLICT1 +ERROR_IP_ADDRESS_CONFLICT2 +ERROR_IPSEC_IKE_TIMED_OUT +ERROR_IRQ_BUSY +ERROR_IS_JOIN_PATH +ERROR_IS_JOIN_TARGET +ERROR_IS_JOINED +ERROR_IS_SUBST_PATH +ERROR_IS_SUBST_TARGET +ERROR_IS_SUBSTED +ERROR_ITERATED_DATA_EXCEEDS_64k +ERROR_JOB_NO_CONTAINER +ERROR_JOIN_TO_JOIN +ERROR_JOIN_TO_SUBST +ERROR_JOURNAL_DELETE_IN_PROGRESS +ERROR_JOURNAL_ENTRY_DELETED +ERROR_JOURNAL_HOOK_SET +ERROR_JOURNAL_NOT_ACTIVE +ERROR_KERNEL_APC +ERROR_KEY_DELETED +ERROR_KEY_HAS_CHILDREN +ERROR_KM_DRIVER_BLOCKED +ERROR_LABEL_TOO_LONG +ERROR_LAST_ADMIN +ERROR_LB_WITHOUT_TABSTOPS +ERROR_LICENSE_QUOTA_EXCEEDED +ERROR_LINUX_SUBSYSTEM_NOT_PRESENT +ERROR_LINUX_SUBSYSTEM_UPDATE_REQUIRED +ERROR_LISTBOX_ID_NOT_FOUND +ERROR_LM_CROSS_ENCRYPTION_REQUIRED +ERROR_LOCAL_POLICY_MODIFICATION_NOT_SUPPORTED +ERROR_LOCAL_USER_SESSION_KEY +ERROR_LOCK_FAILED +ERROR_LOCK_VIOLATION +ERROR_LOCKED +ERROR_LOG_FILE_FULL +ERROR_LOG_HARD_ERROR +ERROR_LOGIN_TIME_RESTRICTION +ERROR_LOGIN_WKSTA_RESTRICTION +ERROR_LOGON_FAILURE +ERROR_LOGON_NOT_GRANTED +ERROR_LOGON_SERVER_CONFLICT +ERROR_LOGON_SESSION_COLLISION +ERROR_LOGON_SESSION_EXISTS +ERROR_LOGON_TYPE_NOT_GRANTED +ERROR_LONGJUMP +ERROR_LOST_MODE_LOGON_RESTRICTION +ERROR_LOST_WRITEBEHIND_DATA +ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR +ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED +ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR +ERROR_LUIDS_EXHAUSTED +ERROR_MACHINE_LOCKED +ERROR_MAGAZINE_NOT_PRESENT +ERROR_MAPPED_ALIGNMENT +ERROR_MARKED_TO_DISALLOW_WRITES +ERROR_MARSHALL_OVERFLOW +ERROR_MAX_SESSIONS_REACHED +ERROR_MAX_THRDS_REACHED +ERROR_MCA_EXCEPTION +ERROR_MCA_OCCURED +ERROR_MEDIA_CHANGED +ERROR_MEDIA_CHECK +ERROR_MEMBER_IN_ALIAS +ERROR_MEMBER_IN_GROUP +ERROR_MEMBER_NOT_IN_ALIAS +ERROR_MEMBER_NOT_IN_GROUP +ERROR_MEMBERS_PRIMARY_GROUP +ERROR_MEMORY_HARDWARE +ERROR_MENU_ITEM_NOT_FOUND +ERROR_MESSAGE_SYNC_ONLY +ERROR_META_EXPANSION_TOO_LONG +ERROR_MISSING_SYSTEMFILE +ERROR_MOD_NOT_FOUND +ERROR_MORE_DATA +ERROR_MORE_WRITES +ERROR_MOUNT_POINT_NOT_RESOLVED +ERROR_MP_PROCESSOR_MISMATCH +ERROR_MR_MID_NOT_FOUND +ERROR_MULTIPLE_FAULT_VIOLATION +ERROR_MUTANT_LIMIT_EXCEEDED +ERROR_MUTUAL_AUTH_FAILED +ERROR_NEGATIVE_SEEK +ERROR_NESTING_NOT_ALLOWED +ERROR_NET_OPEN_FAILED +ERROR_NET_WRITE_FAULT +ERROR_NETLOGON_NOT_STARTED +ERROR_NETNAME_DELETED +ERROR_NETWORK_ACCESS_DENIED +ERROR_NETWORK_ACCESS_DENIED_EDP +ERROR_NETWORK_BUSY +ERROR_NETWORK_UNREACHABLE +ERROR_NO_ACE_CONDITION +ERROR_NO_ASSOCIATION +ERROR_NO_BYPASSIO_DRIVER_SUPPORT +ERROR_NO_CALLBACK_ACTIVE +ERROR_NO_DATA +ERROR_NO_DATA_DETECTED +ERROR_NO_EFS +ERROR_NO_EVENT_PAIR +ERROR_NO_GUID_TRANSLATION +ERROR_NO_IMPERSONATION_TOKEN +ERROR_NO_INHERITANCE +ERROR_NO_LOG_SPACE +ERROR_NO_LOGON_SERVERS +ERROR_NO_MATCH +ERROR_NO_MEDIA_IN_DRIVE +ERROR_NO_MORE_DEVICES +ERROR_NO_MORE_FILES +ERROR_NO_MORE_ITEMS +ERROR_NO_MORE_MATCHES +ERROR_NO_MORE_SEARCH_HANDLES +ERROR_NO_MORE_USER_HANDLES +ERROR_NO_NET_OR_BAD_PATH +ERROR_NO_NETWORK +ERROR_NO_NVRAM_RESOURCES +ERROR_NO_PAGEFILE +ERROR_NO_PHYSICALLY_ALIGNED_FREE_SPACE_FOUND +ERROR_NO_PROC_SLOTS +ERROR_NO_PROMOTION_ACTIVE +ERROR_NO_QUOTAS_FOR_ACCOUNT +ERROR_NO_RANGES_PROCESSED +ERROR_NO_RECOVERY_POLICY +ERROR_NO_RECOVERY_PROGRAM +ERROR_NO_SCROLLBARS +ERROR_NO_SECRETS +ERROR_NO_SECURITY_ON_OBJECT +ERROR_NO_SHUTDOWN_IN_PROGRESS +ERROR_NO_SIGNAL_SENT +ERROR_NO_SITE_SETTINGS_OBJECT +ERROR_NO_SITENAME +ERROR_NO_SPOOL_SPACE +ERROR_NO_SUCH_ALIAS +ERROR_NO_SUCH_DEVICE +ERROR_NO_SUCH_DOMAIN +ERROR_NO_SUCH_GROUP +ERROR_NO_SUCH_LOGON_SESSION +ERROR_NO_SUCH_MEMBER +ERROR_NO_SUCH_PACKAGE +ERROR_NO_SUCH_PRIVILEGE +ERROR_NO_SUCH_SITE +ERROR_NO_SUCH_USER +ERROR_NO_SYSTEM_MENU +ERROR_NO_SYSTEM_RESOURCES +ERROR_NO_TASK_QUEUE +ERROR_NO_TOKEN +ERROR_NO_TRACKING_SERVICE +ERROR_NO_TRUST_LSA_SECRET +ERROR_NO_TRUST_SAM_ACCOUNT +ERROR_NO_UNICODE_TRANSLATION +ERROR_NO_USER_KEYS +ERROR_NO_USER_SESSION_KEY +ERROR_NO_VOLUME_ID +ERROR_NO_VOLUME_LABEL +ERROR_NO_WILDCARD_CHARACTERS +ERROR_NO_WORK_DONE +ERROR_NO_WRITABLE_DC_FOUND +ERROR_NO_YIELD_PERFORMED +ERROR_NOACCESS +ERROR_NOINTERFACE +ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT +ERROR_NOLOGON_SERVER_TRUST_ACCOUNT +ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT +ERROR_NON_ACCOUNT_SID +ERROR_NON_DOMAIN_SID +ERROR_NON_MDICHILD_WINDOW +ERROR_NONE_MAPPED +ERROR_NONPAGED_SYSTEM_RESOURCES +ERROR_NOT_A_CLOUD_FILE +ERROR_NOT_A_CLOUD_SYNC_ROOT +ERROR_NOT_A_DAX_VOLUME +ERROR_NOT_A_REPARSE_POINT +ERROR_NOT_ALL_ASSIGNED +ERROR_NOT_ALLOWED_ON_SYSTEM_FILE +ERROR_NOT_APPCONTAINER +ERROR_NOT_AUTHENTICATED +ERROR_NOT_CAPABLE +ERROR_NOT_CHILD_WINDOW +ERROR_NOT_CONNECTED +ERROR_NOT_CONTAINER +ERROR_NOT_DAX_MAPPABLE +ERROR_NOT_DOS_DISK +ERROR_NOT_ENOUGH_MEMORY +ERROR_NOT_ENOUGH_QUOTA +ERROR_NOT_ENOUGH_SERVER_MEMORY +ERROR_NOT_EXPORT_FORMAT +ERROR_NOT_FOUND +ERROR_NOT_GUI_PROCESS +ERROR_NOT_JOINED +ERROR_NOT_LOCKED +ERROR_NOT_LOGGED_ON +ERROR_NOT_LOGON_PROCESS +ERROR_NOT_OWNER +ERROR_NOT_READ_FROM_COPY +ERROR_NOT_READY +ERROR_NOT_REDUNDANT_STORAGE +ERROR_NOT_REGISTRY_FILE +ERROR_NOT_SAFE_MODE_DRIVER +ERROR_NOT_SAFEBOOT_SERVICE +ERROR_NOT_SAME_DEVICE +ERROR_NOT_SAME_OBJECT +ERROR_NOT_SUBSTED +ERROR_NOT_SUPPORTED +ERROR_NOT_SUPPORTED_IN_APPCONTAINER +ERROR_NOT_SUPPORTED_ON_DAX +ERROR_NOT_SUPPORTED_ON_SBS +ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER +ERROR_NOT_SUPPORTED_WITH_AUDITING +ERROR_NOT_SUPPORTED_WITH_BTT +ERROR_NOT_SUPPORTED_WITH_BYPASSIO +ERROR_NOT_SUPPORTED_WITH_CACHED_HANDLE +ERROR_NOT_SUPPORTED_WITH_COMPRESSION +ERROR_NOT_SUPPORTED_WITH_DEDUPLICATION +ERROR_NOT_SUPPORTED_WITH_ENCRYPTION +ERROR_NOT_SUPPORTED_WITH_MONITORING +ERROR_NOT_SUPPORTED_WITH_REPLICATION +ERROR_NOT_SUPPORTED_WITH_SNAPSHOT +ERROR_NOT_SUPPORTED_WITH_VIRTUALIZATION +ERROR_NOT_TINY_STREAM +ERROR_NOTHING_TO_TERMINATE +ERROR_NOTIFICATION_GUID_ALREADY_DEFINED +ERROR_NOTIFY_CLEANUP +ERROR_NOTIFY_ENUM_DIR +ERROR_NT_CROSS_ENCRYPTION_REQUIRED +ERROR_NTLM_BLOCKED +ERROR_NULL_LM_PASSWORD +ERROR_OBJECT_IS_IMMUTABLE +ERROR_OBJECT_NAME_EXISTS +ERROR_OBJECT_NOT_EXTERNALLY_BACKED +ERROR_OFFLOAD_READ_FILE_NOT_SUPPORTED +ERROR_OFFLOAD_READ_FLT_NOT_SUPPORTED +ERROR_OFFLOAD_WRITE_FILE_NOT_SUPPORTED +ERROR_OFFLOAD_WRITE_FLT_NOT_SUPPORTED +ERROR_OFFSET_ALIGNMENT_VIOLATION +ERROR_OLD_WIN_VERSION +ERROR_ONLY_IF_CONNECTED +ERROR_OPEN_FAILED +ERROR_OPEN_FILES +ERROR_OPERATION_ABORTED +ERROR_OPERATION_IN_PROGRESS +ERROR_OPLOCK_BREAK_IN_PROGRESS +ERROR_OPLOCK_HANDLE_CLOSED +ERROR_OPLOCK_NOT_GRANTED +ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE +ERROR_ORPHAN_NAME_EXHAUSTED +ERROR_OUT_OF_PAPER +ERROR_OUT_OF_STRUCTURES +ERROR_OUTOFMEMORY +ERROR_OVERRIDE_NOCHANGES +ERROR_PAGE_FAULT_COPY_ON_WRITE +ERROR_PAGE_FAULT_DEMAND_ZERO +ERROR_PAGE_FAULT_GUARD_PAGE +ERROR_PAGE_FAULT_PAGING_FILE +ERROR_PAGE_FAULT_TRANSITION +ERROR_PAGED_SYSTEM_RESOURCES +ERROR_PAGEFILE_CREATE_FAILED +ERROR_PAGEFILE_NOT_SUPPORTED +ERROR_PAGEFILE_QUOTA +ERROR_PAGEFILE_QUOTA_EXCEEDED +ERROR_PARAMETER_QUOTA_EXCEEDED +ERROR_PARTIAL_COPY +ERROR_PARTITION_FAILURE +ERROR_PARTITION_TERMINATING +ERROR_PASSWORD_CHANGE_REQUIRED +ERROR_PASSWORD_EXPIRED +ERROR_PASSWORD_MUST_CHANGE +ERROR_PASSWORD_RESTRICTION +ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT +ERROR_PATCH_NO_SEQUENCE +ERROR_PATCH_PACKAGE_INVALID +ERROR_PATCH_PACKAGE_OPEN_FAILED +ERROR_PATCH_PACKAGE_REJECTED +ERROR_PATCH_PACKAGE_UNSUPPORTED +ERROR_PATCH_REMOVAL_DISALLOWED +ERROR_PATCH_REMOVAL_UNSUPPORTED +ERROR_PATCH_TARGET_NOT_FOUND +ERROR_PATH_BUSY +ERROR_PATH_NOT_FOUND +ERROR_PER_USER_TRUST_QUOTA_EXCEEDED +ERROR_PIPE_BUSY +ERROR_PIPE_CONNECTED +ERROR_PIPE_LISTENING +ERROR_PIPE_LOCAL +ERROR_PIPE_NOT_CONNECTED +ERROR_PKINIT_FAILURE +ERROR_PLUGPLAY_QUERY_VETOED +ERROR_PNP_BAD_MPS_TABLE +ERROR_PNP_INVALID_ID +ERROR_PNP_IRQ_TRANSLATION_FAILED +ERROR_PNP_QUERY_REMOVE_DEVICE_TIMEOUT +ERROR_PNP_QUERY_REMOVE_RELATED_DEVICE_TIMEOUT +ERROR_PNP_QUERY_REMOVE_UNRELATED_DEVICE_TIMEOUT +ERROR_PNP_REBOOT_REQUIRED +ERROR_PNP_RESTART_ENUMERATION +ERROR_PNP_TRANSLATION_FAILED +ERROR_POINT_NOT_FOUND +ERROR_POLICY_OBJECT_NOT_FOUND +ERROR_POLICY_ONLY_IN_DS +ERROR_POPUP_ALREADY_ACTIVE +ERROR_PORT_MESSAGE_TOO_LONG +ERROR_PORT_NOT_SET +ERROR_PORT_UNREACHABLE +ERROR_POSSIBLE_DEADLOCK +ERROR_POTENTIAL_FILE_FOUND +ERROR_PREDEFINED_HANDLE +ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED +ERROR_PRINT_CANCELLED +ERROR_PRINTER_ALREADY_EXISTS +ERROR_PRINTER_DELETED +ERROR_PRINTER_DRIVER_ALREADY_INSTALLED +ERROR_PRINTQ_FULL +ERROR_PRIVATE_DIALOG_INDEX +ERROR_PRIVILEGE_NOT_HELD +ERROR_PROC_NOT_FOUND +ERROR_PROCESS_ABORTED +ERROR_PROCESS_IN_JOB +ERROR_PROCESS_IS_PROTECTED +ERROR_PROCESS_MODE_ALREADY_BACKGROUND +ERROR_PROCESS_MODE_NOT_BACKGROUND +ERROR_PROCESS_NOT_IN_JOB +ERROR_PRODUCT_UNINSTALLED +ERROR_PRODUCT_VERSION +ERROR_PROFILING_AT_LIMIT +ERROR_PROFILING_NOT_STARTED +ERROR_PROFILING_NOT_STOPPED +ERROR_PROMOTION_ACTIVE +ERROR_PROTOCOL_UNREACHABLE +ERROR_PWD_HISTORY_CONFLICT +ERROR_PWD_TOO_LONG +ERROR_PWD_TOO_RECENT +ERROR_PWD_TOO_SHORT +ERROR_QUOTA_ACTIVITY +ERROR_QUOTA_LIST_INCONSISTENT +ERROR_RANGE_LIST_CONFLICT +ERROR_RANGE_NOT_FOUND +ERROR_READ_FAULT +ERROR_RECEIVE_EXPEDITED +ERROR_RECEIVE_PARTIAL +ERROR_RECEIVE_PARTIAL_EXPEDITED +ERROR_RECOVERY_FAILURE +ERROR_REDIR_PAUSED +ERROR_REDIRECTOR_HAS_OPEN_HANDLES +ERROR_REG_NAT_CONSUMPTION +ERROR_REGISTRY_CORRUPT +ERROR_REGISTRY_HIVE_RECOVERED +ERROR_REGISTRY_IO_FAILED +ERROR_REGISTRY_QUOTA_LIMIT +ERROR_REGISTRY_RECOVERED +ERROR_RELOC_CHAIN_XEEDS_SEGLIM +ERROR_REM_NOT_LIST +ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED +ERROR_REMOTE_SESSION_LIMIT_EXCEEDED +ERROR_REMOTE_STORAGE_MEDIA_ERROR +ERROR_REMOTE_STORAGE_NOT_ACTIVE +ERROR_REPARSE +ERROR_REPARSE_ATTRIBUTE_CONFLICT +ERROR_REPARSE_OBJECT +ERROR_REPARSE_POINT_ENCOUNTERED +ERROR_REPARSE_TAG_INVALID +ERROR_REPARSE_TAG_MISMATCH +ERROR_REPLY_MESSAGE_MISMATCH +ERROR_REQ_NOT_ACCEP +ERROR_REQUEST_ABORTED +ERROR_REQUEST_OUT_OF_SEQUENCE +ERROR_REQUEST_PAUSED +ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION +ERROR_RESIDENT_FILE_NOT_SUPPORTED +ERROR_RESOURCE_CALL_TIMED_OUT +ERROR_RESOURCE_DATA_NOT_FOUND +ERROR_RESOURCE_LANG_NOT_FOUND +ERROR_RESOURCE_NAME_NOT_FOUND +ERROR_RESOURCE_REQUIREMENTS_CHANGED +ERROR_RESOURCE_TYPE_NOT_FOUND +ERROR_RESTART_APPLICATION +ERROR_RESUME_HIBERNATION +ERROR_RETRY +ERROR_RETURN_ADDRESS_HIJACK_ATTEMPT +ERROR_REVISION_MISMATCH +ERROR_RING2_STACK_IN_USE +ERROR_RING2SEG_MUST_BE_MOVABLE +ERROR_RMODE_APP +ERROR_ROWSNOTRELEASED +ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT +ERROR_RUNLEVEL_SWITCH_TIMEOUT +ERROR_RWRAW_ENCRYPTED_FILE_NOT_ENCRYPTED +ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILEOFFSET +ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILERANGE +ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_PARAMETER +ERROR_RXACT_COMMIT_FAILURE +ERROR_RXACT_COMMIT_NECESSARY +ERROR_RXACT_COMMITTED +ERROR_RXACT_INVALID_STATE +ERROR_RXACT_STATE_CREATED +ERROR_SAM_INIT_FAILURE +ERROR_SAME_DRIVE +ERROR_SCOPE_NOT_FOUND +ERROR_SCREEN_ALREADY_LOCKED +ERROR_SCRUB_DATA_DISABLED +ERROR_SECRET_TOO_LONG +ERROR_SECTION_DIRECT_MAP_ONLY +ERROR_SECTOR_NOT_FOUND +ERROR_SECURITY_DENIES_OPERATION +ERROR_SECURITY_STREAM_IS_INCONSISTENT +ERROR_SEEK +ERROR_SEEK_ON_DEVICE +ERROR_SEGMENT_NOTIFICATION +ERROR_SEM_IS_SET +ERROR_SEM_NOT_FOUND +ERROR_SEM_OWNER_DIED +ERROR_SEM_TIMEOUT +ERROR_SEM_USER_LIMIT +ERROR_SERIAL_NO_DEVICE +ERROR_SERVER_DISABLED +ERROR_SERVER_HAS_OPEN_HANDLES +ERROR_SERVER_NOT_DISABLED +ERROR_SERVER_SHUTDOWN_IN_PROGRESS +ERROR_SERVER_SID_MISMATCH +ERROR_SERVER_TRANSPORT_CONFLICT +ERROR_SERVICE_ALREADY_RUNNING +ERROR_SERVICE_CANNOT_ACCEPT_CTRL +ERROR_SERVICE_DATABASE_LOCKED +ERROR_SERVICE_DEPENDENCY_DELETED +ERROR_SERVICE_DEPENDENCY_FAIL +ERROR_SERVICE_DISABLED +ERROR_SERVICE_DOES_NOT_EXIST +ERROR_SERVICE_EXISTS +ERROR_SERVICE_LOGON_FAILED +ERROR_SERVICE_MARKED_FOR_DELETE +ERROR_SERVICE_NEVER_STARTED +ERROR_SERVICE_NO_THREAD +ERROR_SERVICE_NOT_ACTIVE +ERROR_SERVICE_NOT_FOUND +ERROR_SERVICE_NOT_IN_EXE +ERROR_SERVICE_NOTIFICATION +ERROR_SERVICE_NOTIFY_CLIENT_LAGGING +ERROR_SERVICE_REQUEST_TIMEOUT +ERROR_SERVICE_SPECIFIC_ERROR +ERROR_SERVICE_START_HANG +ERROR_SESSION_CREDENTIAL_CONFLICT +ERROR_SESSION_KEY_TOO_SHORT +ERROR_SET_CONTEXT_DENIED +ERROR_SET_NOT_FOUND +ERROR_SET_POWER_STATE_FAILED +ERROR_SET_POWER_STATE_VETOED +ERROR_SETCOUNT_ON_BAD_LB +ERROR_SETMARK_DETECTED +ERROR_SHARED_POLICY +ERROR_SHARING_BUFFER_EXCEEDED +ERROR_SHARING_PAUSED +ERROR_SHARING_VIOLATION +ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME +ERROR_SHUTDOWN_DISKS_NOT_IN_MAINTENANCE_MODE +ERROR_SHUTDOWN_IN_PROGRESS +ERROR_SHUTDOWN_IS_SCHEDULED +ERROR_SHUTDOWN_USERS_LOGGED_ON +ERROR_SIGNAL_PENDING +ERROR_SIGNAL_REFUSED +ERROR_SINGLE_INSTANCE_APP +ERROR_SMARTCARD_SUBSYSTEM_FAILURE +ERROR_SMB1_NOT_AVAILABLE +ERROR_SMB_GUEST_LOGON_BLOCKED +ERROR_SMR_GARBAGE_COLLECTION_REQUIRED +ERROR_SOME_NOT_MAPPED +ERROR_SOURCE_ELEMENT_EMPTY +ERROR_SPARSE_FILE_NOT_SUPPORTED +ERROR_SPECIAL_ACCOUNT +ERROR_SPECIAL_GROUP +ERROR_SPECIAL_USER +ERROR_SRC_SRV_DLL_LOAD_FAILED +ERROR_STACK_BUFFER_OVERRUN +ERROR_STACK_OVERFLOW +ERROR_STACK_OVERFLOW_READ +ERROR_STOPPED_ON_SYMLINK +ERROR_STORAGE_LOST_DATA_PERSISTENCE +ERROR_STORAGE_RESERVE_ALREADY_EXISTS +ERROR_STORAGE_RESERVE_DOES_NOT_EXIST +ERROR_STORAGE_RESERVE_ID_INVALID +ERROR_STORAGE_RESERVE_NOT_EMPTY +ERROR_STORAGE_STACK_ACCESS_DENIED +ERROR_STORAGE_TOPOLOGY_ID_MISMATCH +ERROR_STRICT_CFG_VIOLATION +ERROR_SUBST_TO_JOIN +ERROR_SUBST_TO_SUBST +ERROR_SUCCESS +ERROR_SUCCESS_REBOOT_INITIATED +ERROR_SWAPERROR +ERROR_SYMLINK_CLASS_DISABLED +ERROR_SYMLINK_NOT_SUPPORTED +ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED +ERROR_SYNCHRONIZATION_REQUIRED +ERROR_SYSTEM_HIVE_TOO_LARGE +ERROR_SYSTEM_IMAGE_BAD_SIGNATURE +ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION +ERROR_SYSTEM_POWERSTATE_TRANSITION +ERROR_SYSTEM_PROCESS_TERMINATED +ERROR_SYSTEM_SHUTDOWN +ERROR_SYSTEM_TRACE +ERROR_THREAD_1_INACTIVE +ERROR_THREAD_ALREADY_IN_TASK +ERROR_THREAD_MODE_ALREADY_BACKGROUND +ERROR_THREAD_MODE_NOT_BACKGROUND +ERROR_THREAD_NOT_IN_PROCESS +ERROR_THREAD_WAS_SUSPENDED +ERROR_TIME_SENSITIVE_THREAD +ERROR_TIME_SKEW +ERROR_TIMEOUT +ERROR_TIMER_NOT_CANCELED +ERROR_TIMER_RESOLUTION_NOT_SET +ERROR_TIMER_RESUME_IGNORED +ERROR_TLW_WITH_WSCHILD +ERROR_TOKEN_ALREADY_IN_USE +ERROR_TOO_MANY_CMDS +ERROR_TOO_MANY_CONTEXT_IDS +ERROR_TOO_MANY_DESCRIPTORS +ERROR_TOO_MANY_LINKS +ERROR_TOO_MANY_LUIDS_REQUESTED +ERROR_TOO_MANY_MODULES +ERROR_TOO_MANY_MUXWAITERS +ERROR_TOO_MANY_NAMES +ERROR_TOO_MANY_OPEN_FILES +ERROR_TOO_MANY_POSTS +ERROR_TOO_MANY_SECRETS +ERROR_TOO_MANY_SEM_REQUESTS +ERROR_TOO_MANY_SEMAPHORES +ERROR_TOO_MANY_SESS +ERROR_TOO_MANY_SIDS +ERROR_TOO_MANY_TCBS +ERROR_TOO_MANY_THREADS +ERROR_TRANSLATION_COMPLETE +ERROR_TRUST_FAILURE +ERROR_TRUSTED_DOMAIN_FAILURE +ERROR_TRUSTED_RELATIONSHIP_FAILURE +ERROR_UNABLE_TO_LOCK_MEDIA +ERROR_UNABLE_TO_MOVE_REPLACEMENT +ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 +ERROR_UNABLE_TO_REMOVE_REPLACED +ERROR_UNABLE_TO_UNLOAD_MEDIA +ERROR_UNDEFINED_CHARACTER +ERROR_UNDEFINED_SCOPE +ERROR_UNEXP_NET_ERR +ERROR_UNEXPECTED_MM_CREATE_ERR +ERROR_UNEXPECTED_MM_EXTEND_ERR +ERROR_UNEXPECTED_MM_MAP_ERROR +ERROR_UNEXPECTED_NTCACHEMANAGER_ERROR +ERROR_UNHANDLED_EXCEPTION +ERROR_UNIDENTIFIED_ERROR +ERROR_UNKNOWN_COMPONENT +ERROR_UNKNOWN_FEATURE +ERROR_UNKNOWN_PATCH +ERROR_UNKNOWN_PORT +ERROR_UNKNOWN_PRINTER_DRIVER +ERROR_UNKNOWN_PRINTPROCESSOR +ERROR_UNKNOWN_PRODUCT +ERROR_UNKNOWN_PROPERTY +ERROR_UNKNOWN_REVISION +ERROR_UNRECOGNIZED_MEDIA +ERROR_UNRECOGNIZED_VOLUME +ERROR_UNSATISFIED_DEPENDENCIES +ERROR_UNSUPPORTED_COMPRESSION +ERROR_UNSUPPORTED_TYPE +ERROR_UNTRUSTED_MOUNT_POINT +ERROR_UNWIND +ERROR_UNWIND_CONSOLIDATE +ERROR_USER_APC +ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED +ERROR_USER_EXISTS +ERROR_USER_MAPPED_FILE +ERROR_USER_PROFILE_LOAD +ERROR_VALIDATE_CONTINUE +ERROR_VC_DISCONNECTED +ERROR_VDM_DISALLOWED +ERROR_VDM_HARD_ERROR +ERROR_VERIFIER_STOP +ERROR_VERSION_PARSE_ERROR +ERROR_VIRUS_DELETED +ERROR_VIRUS_INFECTED +ERROR_VOLSNAP_HIBERNATE_READY +ERROR_VOLSNAP_PREPARE_HIBERNATE +ERROR_VOLUME_MOUNTED +ERROR_VOLUME_NOT_CLUSTER_ALIGNED +ERROR_VOLUME_NOT_SIS_ENABLED +ERROR_VOLUME_NOT_SUPPORT_EFS +ERROR_VOLUME_NOT_SUPPORTED +ERROR_VOLUME_WRITE_ACCESS_DENIED +ERROR_WAIT_1 +ERROR_WAIT_2 +ERROR_WAIT_3 +ERROR_WAIT_63 +ERROR_WAIT_FOR_OPLOCK +ERROR_WAIT_NO_CHILDREN +ERROR_WAKE_SYSTEM +ERROR_WAKE_SYSTEM_DEBUGGER +ERROR_WAS_LOCKED +ERROR_WAS_UNLOCKED +ERROR_WEAK_WHFBKEY_BLOCKED +ERROR_WINDOW_NOT_COMBOBOX +ERROR_WINDOW_NOT_DIALOG +ERROR_WINDOW_OF_OTHER_THREAD +ERROR_WIP_ENCRYPTION_FAILED +ERROR_WOF_FILE_RESOURCE_TABLE_CORRUPT +ERROR_WOF_WIM_HEADER_CORRUPT +ERROR_WOF_WIM_RESOURCE_TABLE_CORRUPT +ERROR_WORKING_SET_QUOTA +ERROR_WOW_ASSERTION +ERROR_WRITE_FAULT +ERROR_WRITE_PROTECT +ERROR_WRONG_COMPARTMENT +ERROR_WRONG_DISK +ERROR_WRONG_EFS +ERROR_WRONG_PASSWORD +ERROR_WRONG_TARGET_NAME +ERROR_WX86_ERROR +ERROR_WX86_WARNING +ERROR_XML_PARSE_ERROR +ERROR_XMLDSIG_ERROR +EXCEPTION_DISPOSITION +EXCEPTION_MAXIMUM_PARAMETERS +EXCEPTION_RECORD +EXCEPTION_STACK_OVERFLOW +ExceptionCollidedUnwind +ExceptionContinueExecution +ExceptionContinueSearch +ExceptionNestedException +ExitProcess +EXTENDED_STARTUPINFO_PRESENT +FACILITY_CODE +FACILITY_NT_BIT +FALSE +FARPROC +FAST_FAIL_FATAL_APP_EXIT +FD_SET +FILE_ACCESS_RIGHTS +FILE_ADD_FILE +FILE_ADD_SUBDIRECTORY +FILE_ALL_ACCESS +FILE_ALLOCATION_INFO +FILE_APPEND_DATA +FILE_ATTRIBUTE_ARCHIVE +FILE_ATTRIBUTE_COMPRESSED +FILE_ATTRIBUTE_DEVICE +FILE_ATTRIBUTE_DIRECTORY +FILE_ATTRIBUTE_EA +FILE_ATTRIBUTE_ENCRYPTED +FILE_ATTRIBUTE_HIDDEN +FILE_ATTRIBUTE_INTEGRITY_STREAM +FILE_ATTRIBUTE_NO_SCRUB_DATA +FILE_ATTRIBUTE_NORMAL +FILE_ATTRIBUTE_NOT_CONTENT_INDEXED +FILE_ATTRIBUTE_OFFLINE +FILE_ATTRIBUTE_PINNED +FILE_ATTRIBUTE_READONLY +FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS +FILE_ATTRIBUTE_RECALL_ON_OPEN +FILE_ATTRIBUTE_REPARSE_POINT +FILE_ATTRIBUTE_SPARSE_FILE +FILE_ATTRIBUTE_SYSTEM +FILE_ATTRIBUTE_TAG_INFO +FILE_ATTRIBUTE_TEMPORARY +FILE_ATTRIBUTE_UNPINNED +FILE_ATTRIBUTE_VIRTUAL +FILE_BASIC_INFO +FILE_BEGIN +FILE_COMPLETE_IF_OPLOCKED +FILE_CONTAINS_EXTENDED_CREATE_INFORMATION +FILE_CREATE +FILE_CREATE_PIPE_INSTANCE +FILE_CREATE_TREE_CONNECTION +FILE_CREATION_DISPOSITION +FILE_CURRENT +FILE_DELETE_CHILD +FILE_DELETE_ON_CLOSE +FILE_DIRECTORY_FILE +FILE_DISALLOW_EXCLUSIVE +FILE_DISPOSITION_FLAG_DELETE +FILE_DISPOSITION_FLAG_DO_NOT_DELETE +FILE_DISPOSITION_FLAG_FORCE_IMAGE_SECTION_CHECK +FILE_DISPOSITION_FLAG_IGNORE_READONLY_ATTRIBUTE +FILE_DISPOSITION_FLAG_ON_CLOSE +FILE_DISPOSITION_FLAG_POSIX_SEMANTICS +FILE_DISPOSITION_INFO +FILE_DISPOSITION_INFO_EX +FILE_DISPOSITION_INFO_EX_FLAGS +FILE_END +FILE_END_OF_FILE_INFO +FILE_EXECUTE +FILE_FLAG_BACKUP_SEMANTICS +FILE_FLAG_DELETE_ON_CLOSE +FILE_FLAG_FIRST_PIPE_INSTANCE +FILE_FLAG_NO_BUFFERING +FILE_FLAG_OPEN_NO_RECALL +FILE_FLAG_OPEN_REPARSE_POINT +FILE_FLAG_OVERLAPPED +FILE_FLAG_POSIX_SEMANTICS +FILE_FLAG_RANDOM_ACCESS +FILE_FLAG_SEQUENTIAL_SCAN +FILE_FLAG_SESSION_AWARE +FILE_FLAG_WRITE_THROUGH +FILE_FLAGS_AND_ATTRIBUTES +FILE_GENERIC_EXECUTE +FILE_GENERIC_READ +FILE_GENERIC_WRITE +FILE_ID_BOTH_DIR_INFO +FILE_INFO_BY_HANDLE_CLASS +FILE_IO_PRIORITY_HINT_INFO +FILE_LIST_DIRECTORY +FILE_NAME_NORMALIZED +FILE_NAME_OPENED +FILE_NO_EA_KNOWLEDGE +FILE_NO_INTERMEDIATE_BUFFERING +FILE_NON_DIRECTORY_FILE +FILE_OPEN +FILE_OPEN_BY_FILE_ID +FILE_OPEN_FOR_BACKUP_INTENT +FILE_OPEN_FOR_FREE_SPACE_QUERY +FILE_OPEN_IF +FILE_OPEN_REPARSE_POINT +FILE_OPEN_REQUIRING_OPLOCK +FILE_OVERWRITE +FILE_OVERWRITE_IF +FILE_RANDOM_ACCESS +FILE_READ_ATTRIBUTES +FILE_READ_DATA +FILE_READ_EA +FILE_RENAME_FLAG_POSIX_SEMANTICS +FILE_RENAME_FLAG_REPLACE_IF_EXISTS +FILE_RENAME_INFO +FILE_RESERVE_OPFILTER +FILE_SEQUENTIAL_ONLY +FILE_SESSION_AWARE +FILE_SHARE_DELETE +FILE_SHARE_MODE +FILE_SHARE_NONE +FILE_SHARE_READ +FILE_SHARE_WRITE +FILE_STANDARD_INFO +FILE_SUPERSEDE +FILE_SYNCHRONOUS_IO_ALERT +FILE_SYNCHRONOUS_IO_NONALERT +FILE_TRAVERSE +FILE_TYPE +FILE_TYPE_CHAR +FILE_TYPE_DISK +FILE_TYPE_PIPE +FILE_TYPE_REMOTE +FILE_TYPE_UNKNOWN +FILE_WRITE_ATTRIBUTES +FILE_WRITE_DATA +FILE_WRITE_EA +FILE_WRITE_THROUGH +FileAlignmentInfo +FileAllocationInfo +FileAttributeTagInfo +FileBasicInfo +FileCaseSensitiveInfo +FileCompressionInfo +FileDispositionInfo +FileDispositionInfoEx +FileEndOfFileInfo +FileFullDirectoryInfo +FileFullDirectoryRestartInfo +FileIdBothDirectoryInfo +FileIdBothDirectoryRestartInfo +FileIdExtdDirectoryInfo +FileIdExtdDirectoryRestartInfo +FileIdInfo +FileIoPriorityHintInfo +FileNameInfo +FileNormalizedNameInfo +FileRemoteProtocolInfo +FileRenameInfo +FileRenameInfoEx +FileStandardInfo +FileStorageInfo +FileStreamInfo +FILETIME +FindClose +FindExInfoBasic +FindExSearchNameMatch +FindFirstFileExW +FindNextFileW +FIONBIO +FlushFileBuffers +FORMAT_MESSAGE_ALLOCATE_BUFFER +FORMAT_MESSAGE_ARGUMENT_ARRAY +FORMAT_MESSAGE_FROM_HMODULE +FORMAT_MESSAGE_FROM_STRING +FORMAT_MESSAGE_FROM_SYSTEM +FORMAT_MESSAGE_IGNORE_INSERTS +FORMAT_MESSAGE_OPTIONS +FormatMessageW +freeaddrinfo +FreeEnvironmentStringsW +FRS_ERR_SYSVOL_POPULATE_TIMEOUT +FSCTL_GET_REPARSE_POINT +FSCTL_SET_REPARSE_POINT +GENERIC_ACCESS_RIGHTS +GENERIC_ALL +GENERIC_EXECUTE +GENERIC_READ +GENERIC_WRITE +GetActiveProcessorCount +getaddrinfo +GetCommandLineW +GetConsoleMode +GetConsoleOutputCP +GetCurrentDirectoryW +GetCurrentProcess +GetCurrentProcessId +GetCurrentThread +GetEnvironmentStringsW +GetEnvironmentVariableW +GetExitCodeProcess +GetFileAttributesW +GetFileInformationByHandle +GetFileInformationByHandleEx +GetFileType +GETFINALPATHNAMEBYHANDLE_FLAGS +GetFinalPathNameByHandleW +GetFullPathNameW +GetLastError +GetModuleFileNameW +GetModuleHandleA +GetModuleHandleW +GetOverlappedResult +getpeername +GetProcAddress +GetProcessId +getsockname +getsockopt +GetStdHandle +GetSystemDirectoryW +GetSystemInfo +GetSystemTimeAsFileTime +GetSystemTimePreciseAsFileTime +GetTempPathW +GetUserProfileDirectoryW +GetWindowsDirectoryW +HANDLE +HANDLE_FLAG_INHERIT +HANDLE_FLAG_PROTECT_FROM_CLOSE +HANDLE_FLAGS +HIGH_PRIORITY_CLASS +HMODULE +IDLE_PRIORITY_CLASS +IN6_ADDR +IN_ADDR +INFINITE +INHERIT_CALLER_PRIORITY +INHERIT_PARENT_AFFINITY +INIT_ONCE_INIT_FAILED +InitializeProcThreadAttributeList +InitOnceBeginInitialize +InitOnceComplete +INVALID_FILE_ATTRIBUTES +INVALID_SOCKET +IO_REPARSE_TAG_MOUNT_POINT +IO_REPARSE_TAG_SYMLINK +ioctlsocket +IP_ADD_MEMBERSHIP +IP_DROP_MEMBERSHIP +IP_MREQ +IP_MULTICAST_LOOP +IP_MULTICAST_TTL +IP_TTL +IPPROTO +IPPROTO_AH +IPPROTO_CBT +IPPROTO_DSTOPTS +IPPROTO_EGP +IPPROTO_ESP +IPPROTO_FRAGMENT +IPPROTO_GGP +IPPROTO_HOPOPTS +IPPROTO_ICLFXBM +IPPROTO_ICMP +IPPROTO_ICMPV6 +IPPROTO_IDP +IPPROTO_IGMP +IPPROTO_IGP +IPPROTO_IP +IPPROTO_IPV4 +IPPROTO_IPV6 +IPPROTO_L2TP +IPPROTO_MAX +IPPROTO_ND +IPPROTO_NONE +IPPROTO_PGM +IPPROTO_PIM +IPPROTO_PUP +IPPROTO_RAW +IPPROTO_RDP +IPPROTO_RESERVED_IPSEC +IPPROTO_RESERVED_IPSECOFFLOAD +IPPROTO_RESERVED_MAX +IPPROTO_RESERVED_RAW +IPPROTO_RESERVED_WNV +IPPROTO_RM +IPPROTO_ROUTING +IPPROTO_SCTP +IPPROTO_ST +IPPROTO_TCP +IPPROTO_UDP +IPV6_ADD_MEMBERSHIP +IPV6_DROP_MEMBERSHIP +IPV6_MREQ +IPV6_MULTICAST_LOOP +IPV6_V6ONLY +LINGER +listen +LocalFree +LOCKFILE_EXCLUSIVE_LOCK +LOCKFILE_FAIL_IMMEDIATELY +LockFileEx +LPOVERLAPPED_COMPLETION_ROUTINE +LPPROC_THREAD_ATTRIBUTE_LIST +LPPROGRESS_ROUTINE +LPPROGRESS_ROUTINE_CALLBACK_REASON +LPTHREAD_START_ROUTINE +LPWSAOVERLAPPED_COMPLETION_ROUTINE +M128A +MAX_PATH +MAXIMUM_REPARSE_DATA_BUFFER_SIZE +MaximumFileInfoByHandleClass +MB_COMPOSITE +MB_ERR_INVALID_CHARS +MB_PRECOMPOSED +MB_USEGLYPHCHARS +MOVE_FILE_FLAGS +MOVEFILE_COPY_ALLOWED +MOVEFILE_CREATE_HARDLINK +MOVEFILE_DELAY_UNTIL_REBOOT +MOVEFILE_FAIL_IF_NOT_TRACKABLE +MOVEFILE_REPLACE_EXISTING +MOVEFILE_WRITE_THROUGH +MoveFileExW +MSG_DONTROUTE +MSG_OOB +MSG_PEEK +MSG_PUSH_IMMEDIATE +MSG_WAITALL +MULTI_BYTE_TO_WIDE_CHAR_FLAGS +MultiByteToWideChar +NAMED_PIPE_MODE +NO_ERROR +NORMAL_PRIORITY_CLASS +NtCreateFile +NTCREATEFILE_CREATE_DISPOSITION +NTCREATEFILE_CREATE_OPTIONS +NtOpenFile +NtReadFile +NTSTATUS +NtWriteFile +OBJ_DONT_REPARSE +OPEN_ALWAYS +OPEN_EXISTING +OpenProcessToken +OVERLAPPED +PIPE_ACCEPT_REMOTE_CLIENTS +PIPE_ACCESS_DUPLEX +PIPE_ACCESS_INBOUND +PIPE_ACCESS_OUTBOUND +PIPE_CLIENT_END +PIPE_NOWAIT +PIPE_READMODE_BYTE +PIPE_READMODE_MESSAGE +PIPE_REJECT_REMOTE_CLIENTS +PIPE_SERVER_END +PIPE_TYPE_BYTE +PIPE_TYPE_MESSAGE +PIPE_WAIT +PROCESS_CREATION_FLAGS +PROCESS_INFORMATION +PROCESS_MODE_BACKGROUND_BEGIN +PROCESS_MODE_BACKGROUND_END +PROCESSOR_ARCHITECTURE +PROFILE_KERNEL +PROFILE_SERVER +PROFILE_USER +PROGRESS_CONTINUE +QueryPerformanceCounter +QueryPerformanceFrequency +READ_CONTROL +ReadConsoleW +ReadFile +ReadFileEx +REALTIME_PRIORITY_CLASS +recv +recvfrom +ReleaseSRWLockExclusive +ReleaseSRWLockShared +RemoveDirectoryW +RtlGenRandom +RtlNtStatusToDosError +SD_BOTH +SD_RECEIVE +SD_SEND +SECURITY_ANONYMOUS +SECURITY_ATTRIBUTES +SECURITY_CONTEXT_TRACKING +SECURITY_DELEGATION +SECURITY_EFFECTIVE_ONLY +SECURITY_IDENTIFICATION +SECURITY_IMPERSONATION +SECURITY_SQOS_PRESENT +SECURITY_VALID_SQOS_FLAGS +select +send +SEND_RECV_FLAGS +sendto +SET_FILE_POINTER_MOVE_METHOD +SetCurrentDirectoryW +SetEnvironmentVariableW +SetFileAttributesW +SetFileInformationByHandle +SetFilePointerEx +SetFileTime +SetHandleInformation +SetLastError +setsockopt +SetThreadStackGuarantee +SetWaitableTimer +shutdown +Sleep +SleepConditionVariableSRW +SleepEx +SO_BROADCAST +SO_ERROR +SO_LINGER +SO_RCVTIMEO +SO_SNDTIMEO +SOCK_DGRAM +SOCK_RAW +SOCK_RDM +SOCK_SEQPACKET +SOCK_STREAM +SOCKADDR +SOCKADDR_STORAGE +SOCKADDR_UN +SOCKET +SOCKET_ERROR +SOL_SOCKET +SPECIFIC_RIGHTS_ALL +STACK_SIZE_PARAM_IS_A_RESERVATION +STANDARD_RIGHTS_ALL +STANDARD_RIGHTS_EXECUTE +STANDARD_RIGHTS_READ +STANDARD_RIGHTS_REQUIRED +STANDARD_RIGHTS_WRITE +STARTF_FORCEOFFFEEDBACK +STARTF_FORCEONFEEDBACK +STARTF_PREVENTPINNING +STARTF_RUNFULLSCREEN +STARTF_TITLEISAPPID +STARTF_TITLEISLINKNAME +STARTF_UNTRUSTEDSOURCE +STARTF_USECOUNTCHARS +STARTF_USEFILLATTRIBUTE +STARTF_USEHOTKEY +STARTF_USEPOSITION +STARTF_USESHOWWINDOW +STARTF_USESIZE +STARTF_USESTDHANDLES +STARTUPINFOEXW +STARTUPINFOW +STARTUPINFOW_FLAGS +STATUS_DELETE_PENDING +STATUS_DIRECTORY_NOT_EMPTY +STATUS_END_OF_FILE +STATUS_FILE_DELETED +STATUS_INVALID_HANDLE +STATUS_INVALID_PARAMETER +STATUS_NOT_IMPLEMENTED +STATUS_PENDING +STATUS_SHARING_VIOLATION +STATUS_SUCCESS +STD_ERROR_HANDLE +STD_HANDLE +STD_INPUT_HANDLE +STD_OUTPUT_HANDLE +SwitchToThread +SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE +SYMBOLIC_LINK_FLAG_DIRECTORY +SYMBOLIC_LINK_FLAGS +SYMLINK_FLAG_RELATIVE +SYNCHRONIZE +SYSTEM_INFO +TCP_NODELAY +TerminateProcess +THREAD_CREATE_RUN_IMMEDIATELY +THREAD_CREATE_SUSPENDED +THREAD_CREATION_FLAGS +TIMER_ALL_ACCESS +TIMER_MODIFY_STATE +TIMEVAL +TLS_OUT_OF_INDEXES +TlsAlloc +TlsFree +TlsGetValue +TlsSetValue +TOKEN_ACCESS_MASK +TOKEN_ACCESS_PSEUDO_HANDLE +TOKEN_ACCESS_PSEUDO_HANDLE_WIN8 +TOKEN_ACCESS_SYSTEM_SECURITY +TOKEN_ADJUST_DEFAULT +TOKEN_ADJUST_GROUPS +TOKEN_ADJUST_PRIVILEGES +TOKEN_ADJUST_SESSIONID +TOKEN_ALL_ACCESS +TOKEN_ASSIGN_PRIMARY +TOKEN_DELETE +TOKEN_DUPLICATE +TOKEN_EXECUTE +TOKEN_IMPERSONATE +TOKEN_QUERY +TOKEN_QUERY_SOURCE +TOKEN_READ +TOKEN_READ_CONTROL +TOKEN_TRUST_CONSTRAINT_MASK +TOKEN_WRITE +TOKEN_WRITE_DAC +TOKEN_WRITE_OWNER +TRUE +TRUNCATE_EXISTING +TryAcquireSRWLockExclusive +TryAcquireSRWLockShared +UNICODE_STRING +UnlockFile +UpdateProcThreadAttribute +VOLUME_NAME_DOS +VOLUME_NAME_GUID +VOLUME_NAME_NONE +WAIT_ABANDONED +WAIT_ABANDONED_0 +WAIT_FAILED +WAIT_IO_COMPLETION +WAIT_OBJECT_0 +WAIT_TIMEOUT +WaitForMultipleObjects +WaitForSingleObject +WakeAllConditionVariable +WakeConditionVariable +WC_ERR_INVALID_CHARS +WideCharToMultiByte +WIN32_ERROR +WIN32_FIND_DATAW Windows.Wdk.Storage.FileSystem.FILE_NO_COMPRESSION -Windows.Wdk.Storage.FileSystem.FILE_NO_EA_KNOWLEDGE -Windows.Wdk.Storage.FileSystem.FILE_NO_INTERMEDIATE_BUFFERING -Windows.Wdk.Storage.FileSystem.FILE_NON_DIRECTORY_FILE -Windows.Wdk.Storage.FileSystem.FILE_OPEN -Windows.Wdk.Storage.FileSystem.FILE_OPEN_BY_FILE_ID -Windows.Wdk.Storage.FileSystem.FILE_OPEN_FOR_BACKUP_INTENT -Windows.Wdk.Storage.FileSystem.FILE_OPEN_FOR_FREE_SPACE_QUERY -Windows.Wdk.Storage.FileSystem.FILE_OPEN_IF Windows.Wdk.Storage.FileSystem.FILE_OPEN_NO_RECALL -Windows.Wdk.Storage.FileSystem.FILE_OPEN_REPARSE_POINT -Windows.Wdk.Storage.FileSystem.FILE_OPEN_REQUIRING_OPLOCK -Windows.Wdk.Storage.FileSystem.FILE_OVERWRITE -Windows.Wdk.Storage.FileSystem.FILE_OVERWRITE_IF -Windows.Wdk.Storage.FileSystem.FILE_RANDOM_ACCESS -Windows.Wdk.Storage.FileSystem.FILE_RESERVE_OPFILTER -Windows.Wdk.Storage.FileSystem.FILE_SEQUENTIAL_ONLY -Windows.Wdk.Storage.FileSystem.FILE_SESSION_AWARE -Windows.Wdk.Storage.FileSystem.FILE_SUPERSEDE -Windows.Wdk.Storage.FileSystem.FILE_SYNCHRONOUS_IO_ALERT -Windows.Wdk.Storage.FileSystem.FILE_SYNCHRONOUS_IO_NONALERT -Windows.Wdk.Storage.FileSystem.FILE_WRITE_THROUGH -Windows.Wdk.Storage.FileSystem.NtCreateFile -Windows.Wdk.Storage.FileSystem.NTCREATEFILE_CREATE_DISPOSITION -Windows.Wdk.Storage.FileSystem.NTCREATEFILE_CREATE_OPTIONS -Windows.Wdk.Storage.FileSystem.NtOpenFile -Windows.Wdk.Storage.FileSystem.NtReadFile -Windows.Wdk.Storage.FileSystem.NtWriteFile -Windows.Wdk.Storage.FileSystem.SYMLINK_FLAG_RELATIVE -Windows.Win32.Foundation.BOOL -Windows.Win32.Foundation.BOOLEAN -Windows.Win32.Foundation.CloseHandle -Windows.Win32.Foundation.DNS_ERROR_ADDRESS_REQUIRED -Windows.Win32.Foundation.DNS_ERROR_ALIAS_LOOP -Windows.Win32.Foundation.DNS_ERROR_AUTOZONE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_AXFR -Windows.Win32.Foundation.DNS_ERROR_BACKGROUND_LOADING -Windows.Win32.Foundation.DNS_ERROR_BAD_KEYMASTER -Windows.Win32.Foundation.DNS_ERROR_BAD_PACKET -Windows.Win32.Foundation.DNS_ERROR_CANNOT_FIND_ROOT_HINTS -Windows.Win32.Foundation.DNS_ERROR_CLIENT_SUBNET_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_CLIENT_SUBNET_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_CLIENT_SUBNET_IS_ACCESSED -Windows.Win32.Foundation.DNS_ERROR_CNAME_COLLISION -Windows.Win32.Foundation.DNS_ERROR_CNAME_LOOP -Windows.Win32.Foundation.DNS_ERROR_DATAFILE_OPEN_FAILURE -Windows.Win32.Foundation.DNS_ERROR_DATAFILE_PARSING -Windows.Win32.Foundation.DNS_ERROR_DEFAULT_SCOPE -Windows.Win32.Foundation.DNS_ERROR_DEFAULT_VIRTUALIZATION_INSTANCE -Windows.Win32.Foundation.DNS_ERROR_DEFAULT_ZONESCOPE -Windows.Win32.Foundation.DNS_ERROR_DELEGATION_REQUIRED -Windows.Win32.Foundation.DNS_ERROR_DNAME_COLLISION -Windows.Win32.Foundation.DNS_ERROR_DNSSEC_IS_DISABLED -Windows.Win32.Foundation.DNS_ERROR_DP_ALREADY_ENLISTED -Windows.Win32.Foundation.DNS_ERROR_DP_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_DP_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_DP_FSMO_ERROR -Windows.Win32.Foundation.DNS_ERROR_DP_NOT_AVAILABLE -Windows.Win32.Foundation.DNS_ERROR_DP_NOT_ENLISTED -Windows.Win32.Foundation.DNS_ERROR_DS_UNAVAILABLE -Windows.Win32.Foundation.DNS_ERROR_DS_ZONE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_DWORD_VALUE_TOO_LARGE -Windows.Win32.Foundation.DNS_ERROR_DWORD_VALUE_TOO_SMALL -Windows.Win32.Foundation.DNS_ERROR_FILE_WRITEBACK_FAILED -Windows.Win32.Foundation.DNS_ERROR_FORWARDER_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_INCONSISTENT_ROOT_HINTS -Windows.Win32.Foundation.DNS_ERROR_INVAILD_VIRTUALIZATION_INSTANCE_NAME -Windows.Win32.Foundation.DNS_ERROR_INVALID_CLIENT_SUBNET_NAME -Windows.Win32.Foundation.DNS_ERROR_INVALID_DATA -Windows.Win32.Foundation.DNS_ERROR_INVALID_DATAFILE_NAME -Windows.Win32.Foundation.DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET -Windows.Win32.Foundation.DNS_ERROR_INVALID_IP_ADDRESS -Windows.Win32.Foundation.DNS_ERROR_INVALID_KEY_SIZE -Windows.Win32.Foundation.DNS_ERROR_INVALID_NAME -Windows.Win32.Foundation.DNS_ERROR_INVALID_NAME_CHAR -Windows.Win32.Foundation.DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT -Windows.Win32.Foundation.DNS_ERROR_INVALID_POLICY_TABLE -Windows.Win32.Foundation.DNS_ERROR_INVALID_PROPERTY -Windows.Win32.Foundation.DNS_ERROR_INVALID_ROLLOVER_PERIOD -Windows.Win32.Foundation.DNS_ERROR_INVALID_SCOPE_NAME -Windows.Win32.Foundation.DNS_ERROR_INVALID_SCOPE_OPERATION -Windows.Win32.Foundation.DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD -Windows.Win32.Foundation.DNS_ERROR_INVALID_TYPE -Windows.Win32.Foundation.DNS_ERROR_INVALID_XML -Windows.Win32.Foundation.DNS_ERROR_INVALID_ZONE_OPERATION -Windows.Win32.Foundation.DNS_ERROR_INVALID_ZONE_TYPE -Windows.Win32.Foundation.DNS_ERROR_INVALID_ZONESCOPE_NAME -Windows.Win32.Foundation.DNS_ERROR_KEYMASTER_REQUIRED -Windows.Win32.Foundation.DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION -Windows.Win32.Foundation.DNS_ERROR_KSP_NOT_ACCESSIBLE -Windows.Win32.Foundation.DNS_ERROR_LOAD_ZONESCOPE_FAILED -Windows.Win32.Foundation.DNS_ERROR_NAME_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_NAME_NOT_IN_ZONE -Windows.Win32.Foundation.DNS_ERROR_NBSTAT_INIT_FAILED -Windows.Win32.Foundation.DNS_ERROR_NEED_SECONDARY_ADDRESSES -Windows.Win32.Foundation.DNS_ERROR_NEED_WINS_SERVERS -Windows.Win32.Foundation.DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE -Windows.Win32.Foundation.DNS_ERROR_NO_CREATE_CACHE_DATA -Windows.Win32.Foundation.DNS_ERROR_NO_DNS_SERVERS -Windows.Win32.Foundation.DNS_ERROR_NO_MEMORY -Windows.Win32.Foundation.DNS_ERROR_NO_PACKET -Windows.Win32.Foundation.DNS_ERROR_NO_TCPIP -Windows.Win32.Foundation.DNS_ERROR_NO_VALID_TRUST_ANCHORS -Windows.Win32.Foundation.DNS_ERROR_NO_ZONE_INFO -Windows.Win32.Foundation.DNS_ERROR_NODE_CREATION_FAILED -Windows.Win32.Foundation.DNS_ERROR_NODE_IS_CNAME -Windows.Win32.Foundation.DNS_ERROR_NODE_IS_DNAME -Windows.Win32.Foundation.DNS_ERROR_NON_RFC_NAME -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_RODC -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_ZSK -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_UNDER_DNAME -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_WITH_ZONESCOPES -Windows.Win32.Foundation.DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS -Windows.Win32.Foundation.DNS_ERROR_NOT_UNIQUE -Windows.Win32.Foundation.DNS_ERROR_NSEC3_INCOMPATIBLE_WITH_RSA_SHA1 -Windows.Win32.Foundation.DNS_ERROR_NSEC3_NAME_COLLISION -Windows.Win32.Foundation.DNS_ERROR_NSEC_INCOMPATIBLE_WITH_NSEC3_RSA_SHA1 -Windows.Win32.Foundation.DNS_ERROR_NUMERIC_NAME -Windows.Win32.Foundation.DNS_ERROR_POLICY_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_POLICY_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_CLIENT_SUBNET -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_FQDN -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_INTERFACE -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_NETWORK_PROTOCOL -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_QUERY_TYPE -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_TIME_OF_DAY -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_TRANSPORT_PROTOCOL -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_NAME -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_SETTINGS -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_WEIGHT -Windows.Win32.Foundation.DNS_ERROR_POLICY_LOCKED -Windows.Win32.Foundation.DNS_ERROR_POLICY_MISSING_CRITERIA -Windows.Win32.Foundation.DNS_ERROR_POLICY_PROCESSING_ORDER_INVALID -Windows.Win32.Foundation.DNS_ERROR_POLICY_SCOPE_MISSING -Windows.Win32.Foundation.DNS_ERROR_POLICY_SCOPE_NOT_ALLOWED -Windows.Win32.Foundation.DNS_ERROR_PRIMARY_REQUIRES_DATAFILE -Windows.Win32.Foundation.DNS_ERROR_RCODE -Windows.Win32.Foundation.DNS_ERROR_RCODE_BADKEY -Windows.Win32.Foundation.DNS_ERROR_RCODE_BADSIG -Windows.Win32.Foundation.DNS_ERROR_RCODE_BADTIME -Windows.Win32.Foundation.DNS_ERROR_RCODE_FORMAT_ERROR -Windows.Win32.Foundation.DNS_ERROR_RCODE_NAME_ERROR -Windows.Win32.Foundation.DNS_ERROR_RCODE_NOT_IMPLEMENTED -Windows.Win32.Foundation.DNS_ERROR_RCODE_NOTAUTH -Windows.Win32.Foundation.DNS_ERROR_RCODE_NOTZONE -Windows.Win32.Foundation.DNS_ERROR_RCODE_NXRRSET -Windows.Win32.Foundation.DNS_ERROR_RCODE_REFUSED -Windows.Win32.Foundation.DNS_ERROR_RCODE_SERVER_FAILURE -Windows.Win32.Foundation.DNS_ERROR_RCODE_YXDOMAIN -Windows.Win32.Foundation.DNS_ERROR_RCODE_YXRRSET -Windows.Win32.Foundation.DNS_ERROR_RECORD_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_RECORD_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_RECORD_FORMAT -Windows.Win32.Foundation.DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT -Windows.Win32.Foundation.DNS_ERROR_RECORD_TIMED_OUT -Windows.Win32.Foundation.DNS_ERROR_ROLLOVER_ALREADY_QUEUED -Windows.Win32.Foundation.DNS_ERROR_ROLLOVER_IN_PROGRESS -Windows.Win32.Foundation.DNS_ERROR_ROLLOVER_NOT_POKEABLE -Windows.Win32.Foundation.DNS_ERROR_RRL_INVALID_IPV4_PREFIX -Windows.Win32.Foundation.DNS_ERROR_RRL_INVALID_IPV6_PREFIX -Windows.Win32.Foundation.DNS_ERROR_RRL_INVALID_LEAK_RATE -Windows.Win32.Foundation.DNS_ERROR_RRL_INVALID_TC_RATE -Windows.Win32.Foundation.DNS_ERROR_RRL_INVALID_WINDOW_SIZE -Windows.Win32.Foundation.DNS_ERROR_RRL_LEAK_RATE_LESSTHAN_TC_RATE -Windows.Win32.Foundation.DNS_ERROR_RRL_NOT_ENABLED -Windows.Win32.Foundation.DNS_ERROR_SCOPE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_SCOPE_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_SCOPE_LOCKED -Windows.Win32.Foundation.DNS_ERROR_SECONDARY_DATA -Windows.Win32.Foundation.DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP -Windows.Win32.Foundation.DNS_ERROR_SERVERSCOPE_IS_REFERENCED -Windows.Win32.Foundation.DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE -Windows.Win32.Foundation.DNS_ERROR_SOA_DELETE_INVALID -Windows.Win32.Foundation.DNS_ERROR_STANDBY_KEY_NOT_PRESENT -Windows.Win32.Foundation.DNS_ERROR_SUBNET_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_SUBNET_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_TOO_MANY_SKDS -Windows.Win32.Foundation.DNS_ERROR_TRY_AGAIN_LATER -Windows.Win32.Foundation.DNS_ERROR_UNEXPECTED_CNG_ERROR -Windows.Win32.Foundation.DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR -Windows.Win32.Foundation.DNS_ERROR_UNKNOWN_RECORD_TYPE -Windows.Win32.Foundation.DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION -Windows.Win32.Foundation.DNS_ERROR_UNSECURE_PACKET -Windows.Win32.Foundation.DNS_ERROR_UNSUPPORTED_ALGORITHM -Windows.Win32.Foundation.DNS_ERROR_VIRTUALIZATION_INSTANCE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_VIRTUALIZATION_INSTANCE_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_VIRTUALIZATION_TREE_LOCKED -Windows.Win32.Foundation.DNS_ERROR_WINS_INIT_FAILED -Windows.Win32.Foundation.DNS_ERROR_ZONE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_ZONE_CONFIGURATION_ERROR -Windows.Win32.Foundation.DNS_ERROR_ZONE_CREATION_FAILED -Windows.Win32.Foundation.DNS_ERROR_ZONE_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_ZONE_HAS_NO_NS_RECORDS -Windows.Win32.Foundation.DNS_ERROR_ZONE_HAS_NO_SOA_RECORD -Windows.Win32.Foundation.DNS_ERROR_ZONE_IS_SHUTDOWN -Windows.Win32.Foundation.DNS_ERROR_ZONE_LOCKED -Windows.Win32.Foundation.DNS_ERROR_ZONE_LOCKED_FOR_SIGNING -Windows.Win32.Foundation.DNS_ERROR_ZONE_NOT_SECONDARY -Windows.Win32.Foundation.DNS_ERROR_ZONE_REQUIRES_MASTER_IP -Windows.Win32.Foundation.DNS_ERROR_ZONESCOPE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_ZONESCOPE_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_ZONESCOPE_FILE_WRITEBACK_FAILED -Windows.Win32.Foundation.DNS_ERROR_ZONESCOPE_IS_REFERENCED -Windows.Win32.Foundation.DUPLICATE_CLOSE_SOURCE -Windows.Win32.Foundation.DUPLICATE_HANDLE_OPTIONS -Windows.Win32.Foundation.DUPLICATE_SAME_ACCESS -Windows.Win32.Foundation.DuplicateHandle -Windows.Win32.Foundation.E_NOTIMPL -Windows.Win32.Foundation.ERROR_ABANDON_HIBERFILE -Windows.Win32.Foundation.ERROR_ABANDONED_WAIT_0 -Windows.Win32.Foundation.ERROR_ABANDONED_WAIT_63 -Windows.Win32.Foundation.ERROR_ABIOS_ERROR -Windows.Win32.Foundation.ERROR_ACCESS_AUDIT_BY_POLICY -Windows.Win32.Foundation.ERROR_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_ACCESS_DENIED_APPDATA -Windows.Win32.Foundation.ERROR_ACCESS_DISABLED_BY_POLICY -Windows.Win32.Foundation.ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY -Windows.Win32.Foundation.ERROR_ACCESS_DISABLED_WEBBLADE -Windows.Win32.Foundation.ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER -Windows.Win32.Foundation.ERROR_ACCOUNT_DISABLED -Windows.Win32.Foundation.ERROR_ACCOUNT_EXPIRED -Windows.Win32.Foundation.ERROR_ACCOUNT_LOCKED_OUT -Windows.Win32.Foundation.ERROR_ACCOUNT_RESTRICTION -Windows.Win32.Foundation.ERROR_ACPI_ERROR -Windows.Win32.Foundation.ERROR_ACTIVE_CONNECTIONS -Windows.Win32.Foundation.ERROR_ADAP_HDW_ERR -Windows.Win32.Foundation.ERROR_ADDRESS_ALREADY_ASSOCIATED -Windows.Win32.Foundation.ERROR_ADDRESS_NOT_ASSOCIATED -Windows.Win32.Foundation.ERROR_ALERTED -Windows.Win32.Foundation.ERROR_ALIAS_EXISTS -Windows.Win32.Foundation.ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_ALLOCATE_BUCKET -Windows.Win32.Foundation.ERROR_ALLOTTED_SPACE_EXCEEDED -Windows.Win32.Foundation.ERROR_ALREADY_ASSIGNED -Windows.Win32.Foundation.ERROR_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_ALREADY_FIBER -Windows.Win32.Foundation.ERROR_ALREADY_HAS_STREAM_ID -Windows.Win32.Foundation.ERROR_ALREADY_INITIALIZED -Windows.Win32.Foundation.ERROR_ALREADY_REGISTERED -Windows.Win32.Foundation.ERROR_ALREADY_RUNNING_LKG -Windows.Win32.Foundation.ERROR_ALREADY_THREAD -Windows.Win32.Foundation.ERROR_ALREADY_WAITING -Windows.Win32.Foundation.ERROR_ALREADY_WIN32 -Windows.Win32.Foundation.ERROR_API_UNAVAILABLE -Windows.Win32.Foundation.ERROR_APP_HANG -Windows.Win32.Foundation.ERROR_APP_INIT_FAILURE -Windows.Win32.Foundation.ERROR_APP_WRONG_OS -Windows.Win32.Foundation.ERROR_APPCONTAINER_REQUIRED -Windows.Win32.Foundation.ERROR_APPEXEC_APP_COMPAT_BLOCK -Windows.Win32.Foundation.ERROR_APPEXEC_CALLER_WAIT_TIMEOUT -Windows.Win32.Foundation.ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_LICENSING -Windows.Win32.Foundation.ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_RESOURCES -Windows.Win32.Foundation.ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_TERMINATION -Windows.Win32.Foundation.ERROR_APPEXEC_CONDITION_NOT_SATISFIED -Windows.Win32.Foundation.ERROR_APPEXEC_HANDLE_INVALIDATED -Windows.Win32.Foundation.ERROR_APPEXEC_HOST_ID_MISMATCH -Windows.Win32.Foundation.ERROR_APPEXEC_INVALID_HOST_GENERATION -Windows.Win32.Foundation.ERROR_APPEXEC_INVALID_HOST_STATE -Windows.Win32.Foundation.ERROR_APPEXEC_NO_DONOR -Windows.Win32.Foundation.ERROR_APPEXEC_UNEXPECTED_PROCESS_REGISTRATION -Windows.Win32.Foundation.ERROR_APPEXEC_UNKNOWN_USER -Windows.Win32.Foundation.ERROR_APPHELP_BLOCK -Windows.Win32.Foundation.ERROR_APPX_FILE_NOT_ENCRYPTED -Windows.Win32.Foundation.ERROR_ARBITRATION_UNHANDLED -Windows.Win32.Foundation.ERROR_ARENA_TRASHED -Windows.Win32.Foundation.ERROR_ARITHMETIC_OVERFLOW -Windows.Win32.Foundation.ERROR_ASSERTION_FAILURE -Windows.Win32.Foundation.ERROR_ATOMIC_LOCKS_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_AUDIT_FAILED -Windows.Win32.Foundation.ERROR_AUTHENTICATION_FIREWALL_FAILED -Windows.Win32.Foundation.ERROR_AUTHIP_FAILURE -Windows.Win32.Foundation.ERROR_AUTODATASEG_EXCEEDS_64k -Windows.Win32.Foundation.ERROR_BACKUP_CONTROLLER -Windows.Win32.Foundation.ERROR_BAD_ACCESSOR_FLAGS -Windows.Win32.Foundation.ERROR_BAD_ARGUMENTS -Windows.Win32.Foundation.ERROR_BAD_COMMAND -Windows.Win32.Foundation.ERROR_BAD_COMPRESSION_BUFFER -Windows.Win32.Foundation.ERROR_BAD_CONFIGURATION -Windows.Win32.Foundation.ERROR_BAD_CURRENT_DIRECTORY -Windows.Win32.Foundation.ERROR_BAD_DESCRIPTOR_FORMAT -Windows.Win32.Foundation.ERROR_BAD_DEV_TYPE -Windows.Win32.Foundation.ERROR_BAD_DEVICE -Windows.Win32.Foundation.ERROR_BAD_DEVICE_PATH -Windows.Win32.Foundation.ERROR_BAD_DLL_ENTRYPOINT -Windows.Win32.Foundation.ERROR_BAD_DRIVER_LEVEL -Windows.Win32.Foundation.ERROR_BAD_ENVIRONMENT -Windows.Win32.Foundation.ERROR_BAD_EXE_FORMAT -Windows.Win32.Foundation.ERROR_BAD_FILE_TYPE -Windows.Win32.Foundation.ERROR_BAD_FORMAT -Windows.Win32.Foundation.ERROR_BAD_FUNCTION_TABLE -Windows.Win32.Foundation.ERROR_BAD_IMPERSONATION_LEVEL -Windows.Win32.Foundation.ERROR_BAD_INHERITANCE_ACL -Windows.Win32.Foundation.ERROR_BAD_LENGTH -Windows.Win32.Foundation.ERROR_BAD_LOGON_SESSION_STATE -Windows.Win32.Foundation.ERROR_BAD_MCFG_TABLE -Windows.Win32.Foundation.ERROR_BAD_NET_NAME -Windows.Win32.Foundation.ERROR_BAD_NET_RESP -Windows.Win32.Foundation.ERROR_BAD_NETPATH -Windows.Win32.Foundation.ERROR_BAD_PATHNAME -Windows.Win32.Foundation.ERROR_BAD_PIPE -Windows.Win32.Foundation.ERROR_BAD_PROFILE -Windows.Win32.Foundation.ERROR_BAD_PROVIDER -Windows.Win32.Foundation.ERROR_BAD_QUERY_SYNTAX -Windows.Win32.Foundation.ERROR_BAD_RECOVERY_POLICY -Windows.Win32.Foundation.ERROR_BAD_REM_ADAP -Windows.Win32.Foundation.ERROR_BAD_SERVICE_ENTRYPOINT -Windows.Win32.Foundation.ERROR_BAD_STACK -Windows.Win32.Foundation.ERROR_BAD_THREADID_ADDR -Windows.Win32.Foundation.ERROR_BAD_TOKEN_TYPE -Windows.Win32.Foundation.ERROR_BAD_UNIT -Windows.Win32.Foundation.ERROR_BAD_USER_PROFILE -Windows.Win32.Foundation.ERROR_BAD_USERNAME -Windows.Win32.Foundation.ERROR_BAD_VALIDATION_CLASS -Windows.Win32.Foundation.ERROR_BADDB -Windows.Win32.Foundation.ERROR_BADKEY -Windows.Win32.Foundation.ERROR_BADSTARTPOSITION -Windows.Win32.Foundation.ERROR_BEGINNING_OF_MEDIA -Windows.Win32.Foundation.ERROR_BEYOND_VDL -Windows.Win32.Foundation.ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT -Windows.Win32.Foundation.ERROR_BLOCK_SHARED -Windows.Win32.Foundation.ERROR_BLOCK_SOURCE_WEAK_REFERENCE_INVALID -Windows.Win32.Foundation.ERROR_BLOCK_TARGET_WEAK_REFERENCE_INVALID -Windows.Win32.Foundation.ERROR_BLOCK_TOO_MANY_REFERENCES -Windows.Win32.Foundation.ERROR_BLOCK_WEAK_REFERENCE_INVALID -Windows.Win32.Foundation.ERROR_BLOCKED_BY_PARENTAL_CONTROLS -Windows.Win32.Foundation.ERROR_BOOT_ALREADY_ACCEPTED -Windows.Win32.Foundation.ERROR_BROKEN_PIPE -Windows.Win32.Foundation.ERROR_BUFFER_ALL_ZEROS -Windows.Win32.Foundation.ERROR_BUFFER_OVERFLOW -Windows.Win32.Foundation.ERROR_BUS_RESET -Windows.Win32.Foundation.ERROR_BUSY -Windows.Win32.Foundation.ERROR_BUSY_DRIVE -Windows.Win32.Foundation.ERROR_BYPASSIO_FLT_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_CACHE_PAGE_LOCKED -Windows.Win32.Foundation.ERROR_CALL_NOT_IMPLEMENTED -Windows.Win32.Foundation.ERROR_CALLBACK_INVOKE_INLINE -Windows.Win32.Foundation.ERROR_CALLBACK_POP_STACK -Windows.Win32.Foundation.ERROR_CALLBACK_SUPPLIED_INVALID_DATA -Windows.Win32.Foundation.ERROR_CAN_NOT_COMPLETE -Windows.Win32.Foundation.ERROR_CANCEL_VIOLATION -Windows.Win32.Foundation.ERROR_CANCELLED -Windows.Win32.Foundation.ERROR_CANNOT_BREAK_OPLOCK -Windows.Win32.Foundation.ERROR_CANNOT_COPY -Windows.Win32.Foundation.ERROR_CANNOT_DETECT_DRIVER_FAILURE -Windows.Win32.Foundation.ERROR_CANNOT_DETECT_PROCESS_ABORT -Windows.Win32.Foundation.ERROR_CANNOT_FIND_WND_CLASS -Windows.Win32.Foundation.ERROR_CANNOT_GRANT_REQUESTED_OPLOCK -Windows.Win32.Foundation.ERROR_CANNOT_IMPERSONATE -Windows.Win32.Foundation.ERROR_CANNOT_LOAD_REGISTRY_FILE -Windows.Win32.Foundation.ERROR_CANNOT_MAKE -Windows.Win32.Foundation.ERROR_CANNOT_OPEN_PROFILE -Windows.Win32.Foundation.ERROR_CANT_ACCESS_DOMAIN_INFO -Windows.Win32.Foundation.ERROR_CANT_ACCESS_FILE -Windows.Win32.Foundation.ERROR_CANT_CLEAR_ENCRYPTION_FLAG -Windows.Win32.Foundation.ERROR_CANT_DISABLE_MANDATORY -Windows.Win32.Foundation.ERROR_CANT_ENABLE_DENY_ONLY -Windows.Win32.Foundation.ERROR_CANT_OPEN_ANONYMOUS -Windows.Win32.Foundation.ERROR_CANT_RESOLVE_FILENAME -Windows.Win32.Foundation.ERROR_CANT_TERMINATE_SELF -Windows.Win32.Foundation.ERROR_CANT_WAIT -Windows.Win32.Foundation.ERROR_CANTFETCHBACKWARDS -Windows.Win32.Foundation.ERROR_CANTOPEN -Windows.Win32.Foundation.ERROR_CANTREAD -Windows.Win32.Foundation.ERROR_CANTSCROLLBACKWARDS -Windows.Win32.Foundation.ERROR_CANTWRITE -Windows.Win32.Foundation.ERROR_CAPAUTHZ_CHANGE_TYPE -Windows.Win32.Foundation.ERROR_CAPAUTHZ_DB_CORRUPTED -Windows.Win32.Foundation.ERROR_CAPAUTHZ_NO_POLICY -Windows.Win32.Foundation.ERROR_CAPAUTHZ_NOT_AUTHORIZED -Windows.Win32.Foundation.ERROR_CAPAUTHZ_NOT_DEVUNLOCKED -Windows.Win32.Foundation.ERROR_CAPAUTHZ_NOT_PROVISIONED -Windows.Win32.Foundation.ERROR_CAPAUTHZ_SCCD_DEV_MODE_REQUIRED -Windows.Win32.Foundation.ERROR_CAPAUTHZ_SCCD_INVALID_CATALOG -Windows.Win32.Foundation.ERROR_CAPAUTHZ_SCCD_NO_AUTH_ENTITY -Windows.Win32.Foundation.ERROR_CAPAUTHZ_SCCD_NO_CAPABILITY_MATCH -Windows.Win32.Foundation.ERROR_CAPAUTHZ_SCCD_PARSE_ERROR -Windows.Win32.Foundation.ERROR_CARDBUS_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_CASE_DIFFERING_NAMES_IN_DIR -Windows.Win32.Foundation.ERROR_CASE_SENSITIVE_PATH -Windows.Win32.Foundation.ERROR_CERTIFICATE_VALIDATION_PREFERENCE_CONFLICT -Windows.Win32.Foundation.ERROR_CHECKING_FILE_SYSTEM -Windows.Win32.Foundation.ERROR_CHECKOUT_REQUIRED -Windows.Win32.Foundation.ERROR_CHILD_MUST_BE_VOLATILE -Windows.Win32.Foundation.ERROR_CHILD_NOT_COMPLETE -Windows.Win32.Foundation.ERROR_CHILD_PROCESS_BLOCKED -Windows.Win32.Foundation.ERROR_CHILD_WINDOW_MENU -Windows.Win32.Foundation.ERROR_CIMFS_IMAGE_CORRUPT -Windows.Win32.Foundation.ERROR_CIMFS_IMAGE_VERSION_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_CIRCULAR_DEPENDENCY -Windows.Win32.Foundation.ERROR_CLASS_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_CLASS_DOES_NOT_EXIST -Windows.Win32.Foundation.ERROR_CLASS_HAS_WINDOWS -Windows.Win32.Foundation.ERROR_CLIENT_SERVER_PARAMETERS_INVALID -Windows.Win32.Foundation.ERROR_CLIPBOARD_NOT_OPEN -Windows.Win32.Foundation.ERROR_CLOUD_FILE_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_ALREADY_CONNECTED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_AUTHENTICATION_FAILED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_CONNECTED_PROVIDER_ONLY -Windows.Win32.Foundation.ERROR_CLOUD_FILE_DEHYDRATION_DISALLOWED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_IN_USE -Windows.Win32.Foundation.ERROR_CLOUD_FILE_INCOMPATIBLE_HARDLINKS -Windows.Win32.Foundation.ERROR_CLOUD_FILE_INSUFFICIENT_RESOURCES -Windows.Win32.Foundation.ERROR_CLOUD_FILE_INVALID_REQUEST -Windows.Win32.Foundation.ERROR_CLOUD_FILE_METADATA_CORRUPT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_METADATA_TOO_LARGE -Windows.Win32.Foundation.ERROR_CLOUD_FILE_NETWORK_UNAVAILABLE -Windows.Win32.Foundation.ERROR_CLOUD_FILE_NOT_IN_SYNC -Windows.Win32.Foundation.ERROR_CLOUD_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_NOT_UNDER_SYNC_ROOT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PINNED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROPERTY_BLOB_CHECKSUM_MISMATCH -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROPERTY_BLOB_TOO_LARGE -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROPERTY_CORRUPT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROPERTY_LOCK_CONFLICT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROPERTY_VERSION_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROVIDER_NOT_RUNNING -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROVIDER_TERMINATED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_READ_ONLY_VOLUME -Windows.Win32.Foundation.ERROR_CLOUD_FILE_REQUEST_ABORTED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_REQUEST_CANCELED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_REQUEST_TIMEOUT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_SYNC_ROOT_METADATA_CORRUPT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_TOO_MANY_PROPERTY_BLOBS -Windows.Win32.Foundation.ERROR_CLOUD_FILE_UNSUCCESSFUL -Windows.Win32.Foundation.ERROR_CLOUD_FILE_US_MESSAGE_TIMEOUT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_VALIDATION_FAILED -Windows.Win32.Foundation.ERROR_COMMITMENT_LIMIT -Windows.Win32.Foundation.ERROR_COMMITMENT_MINIMUM -Windows.Win32.Foundation.ERROR_COMPRESSED_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_COMPRESSION_DISABLED -Windows.Win32.Foundation.ERROR_COMPRESSION_NOT_BENEFICIAL -Windows.Win32.Foundation.ERROR_CONNECTED_OTHER_PASSWORD -Windows.Win32.Foundation.ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT -Windows.Win32.Foundation.ERROR_CONNECTION_ABORTED -Windows.Win32.Foundation.ERROR_CONNECTION_ACTIVE -Windows.Win32.Foundation.ERROR_CONNECTION_COUNT_LIMIT -Windows.Win32.Foundation.ERROR_CONNECTION_INVALID -Windows.Win32.Foundation.ERROR_CONNECTION_REFUSED -Windows.Win32.Foundation.ERROR_CONNECTION_UNAVAIL -Windows.Win32.Foundation.ERROR_CONTAINER_ASSIGNED -Windows.Win32.Foundation.ERROR_CONTENT_BLOCKED -Windows.Win32.Foundation.ERROR_CONTEXT_EXPIRED -Windows.Win32.Foundation.ERROR_CONTINUE -Windows.Win32.Foundation.ERROR_CONTROL_C_EXIT -Windows.Win32.Foundation.ERROR_CONTROL_ID_NOT_FOUND -Windows.Win32.Foundation.ERROR_CONVERT_TO_LARGE -Windows.Win32.Foundation.ERROR_CORRUPT_LOG_CLEARED -Windows.Win32.Foundation.ERROR_CORRUPT_LOG_CORRUPTED -Windows.Win32.Foundation.ERROR_CORRUPT_LOG_DELETED_FULL -Windows.Win32.Foundation.ERROR_CORRUPT_LOG_OVERFULL -Windows.Win32.Foundation.ERROR_CORRUPT_LOG_UNAVAILABLE -Windows.Win32.Foundation.ERROR_CORRUPT_SYSTEM_FILE -Windows.Win32.Foundation.ERROR_COULD_NOT_INTERPRET -Windows.Win32.Foundation.ERROR_COUNTER_TIMEOUT -Windows.Win32.Foundation.ERROR_CPU_SET_INVALID -Windows.Win32.Foundation.ERROR_CRASH_DUMP -Windows.Win32.Foundation.ERROR_CRC -Windows.Win32.Foundation.ERROR_CREATE_FAILED -Windows.Win32.Foundation.ERROR_CROSS_PARTITION_VIOLATION -Windows.Win32.Foundation.ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE -Windows.Win32.Foundation.ERROR_CS_ENCRYPTION_FILE_NOT_CSE -Windows.Win32.Foundation.ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE -Windows.Win32.Foundation.ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE -Windows.Win32.Foundation.ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER -Windows.Win32.Foundation.ERROR_CSCSHARE_OFFLINE -Windows.Win32.Foundation.ERROR_CTX_CLIENT_QUERY_TIMEOUT -Windows.Win32.Foundation.ERROR_CTX_MODEM_RESPONSE_TIMEOUT -Windows.Win32.Foundation.ERROR_CURRENT_DIRECTORY -Windows.Win32.Foundation.ERROR_CURRENT_DOMAIN_NOT_ALLOWED -Windows.Win32.Foundation.ERROR_DATA_CHECKSUM_ERROR -Windows.Win32.Foundation.ERROR_DATA_NOT_ACCEPTED -Windows.Win32.Foundation.ERROR_DATABASE_DOES_NOT_EXIST -Windows.Win32.Foundation.ERROR_DATATYPE_MISMATCH -Windows.Win32.Foundation.ERROR_DAX_MAPPING_EXISTS -Windows.Win32.Foundation.ERROR_DBG_COMMAND_EXCEPTION -Windows.Win32.Foundation.ERROR_DBG_CONTINUE -Windows.Win32.Foundation.ERROR_DBG_CONTROL_BREAK -Windows.Win32.Foundation.ERROR_DBG_CONTROL_C -Windows.Win32.Foundation.ERROR_DBG_EXCEPTION_HANDLED -Windows.Win32.Foundation.ERROR_DBG_EXCEPTION_NOT_HANDLED -Windows.Win32.Foundation.ERROR_DBG_PRINTEXCEPTION_C -Windows.Win32.Foundation.ERROR_DBG_REPLY_LATER -Windows.Win32.Foundation.ERROR_DBG_RIPEXCEPTION -Windows.Win32.Foundation.ERROR_DBG_TERMINATE_PROCESS -Windows.Win32.Foundation.ERROR_DBG_TERMINATE_THREAD -Windows.Win32.Foundation.ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE -Windows.Win32.Foundation.ERROR_DC_NOT_FOUND -Windows.Win32.Foundation.ERROR_DDE_FAIL -Windows.Win32.Foundation.ERROR_DEBUG_ATTACH_FAILED -Windows.Win32.Foundation.ERROR_DEBUGGER_INACTIVE -Windows.Win32.Foundation.ERROR_DECRYPTION_FAILED -Windows.Win32.Foundation.ERROR_DELAY_LOAD_FAILED -Windows.Win32.Foundation.ERROR_DELETE_PENDING -Windows.Win32.Foundation.ERROR_DEPENDENT_SERVICES_RUNNING -Windows.Win32.Foundation.ERROR_DESTINATION_ELEMENT_FULL -Windows.Win32.Foundation.ERROR_DESTROY_OBJECT_OF_OTHER_THREAD -Windows.Win32.Foundation.ERROR_DEV_NOT_EXIST -Windows.Win32.Foundation.ERROR_DEVICE_ALREADY_ATTACHED -Windows.Win32.Foundation.ERROR_DEVICE_ALREADY_REMEMBERED -Windows.Win32.Foundation.ERROR_DEVICE_DOOR_OPEN -Windows.Win32.Foundation.ERROR_DEVICE_ENUMERATION_ERROR -Windows.Win32.Foundation.ERROR_DEVICE_FEATURE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_DEVICE_HARDWARE_ERROR -Windows.Win32.Foundation.ERROR_DEVICE_HINT_NAME_BUFFER_TOO_SMALL -Windows.Win32.Foundation.ERROR_DEVICE_IN_MAINTENANCE -Windows.Win32.Foundation.ERROR_DEVICE_IN_USE -Windows.Win32.Foundation.ERROR_DEVICE_NO_RESOURCES -Windows.Win32.Foundation.ERROR_DEVICE_NOT_CONNECTED -Windows.Win32.Foundation.ERROR_DEVICE_NOT_PARTITIONED -Windows.Win32.Foundation.ERROR_DEVICE_REINITIALIZATION_NEEDED -Windows.Win32.Foundation.ERROR_DEVICE_REMOVED -Windows.Win32.Foundation.ERROR_DEVICE_REQUIRES_CLEANING -Windows.Win32.Foundation.ERROR_DEVICE_RESET_REQUIRED -Windows.Win32.Foundation.ERROR_DEVICE_SUPPORT_IN_PROGRESS -Windows.Win32.Foundation.ERROR_DEVICE_UNREACHABLE -Windows.Win32.Foundation.ERROR_DHCP_ADDRESS_CONFLICT -Windows.Win32.Foundation.ERROR_DIFFERENT_SERVICE_ACCOUNT -Windows.Win32.Foundation.ERROR_DIR_EFS_DISALLOWED -Windows.Win32.Foundation.ERROR_DIR_NOT_EMPTY -Windows.Win32.Foundation.ERROR_DIR_NOT_ROOT -Windows.Win32.Foundation.ERROR_DIRECT_ACCESS_HANDLE -Windows.Win32.Foundation.ERROR_DIRECTORY -Windows.Win32.Foundation.ERROR_DIRECTORY_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_DISCARDED -Windows.Win32.Foundation.ERROR_DISK_CHANGE -Windows.Win32.Foundation.ERROR_DISK_CORRUPT -Windows.Win32.Foundation.ERROR_DISK_FULL -Windows.Win32.Foundation.ERROR_DISK_OPERATION_FAILED -Windows.Win32.Foundation.ERROR_DISK_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_DISK_RECALIBRATE_FAILED -Windows.Win32.Foundation.ERROR_DISK_REPAIR_DISABLED -Windows.Win32.Foundation.ERROR_DISK_REPAIR_REDIRECTED -Windows.Win32.Foundation.ERROR_DISK_REPAIR_UNSUCCESSFUL -Windows.Win32.Foundation.ERROR_DISK_RESET_FAILED -Windows.Win32.Foundation.ERROR_DISK_RESOURCES_EXHAUSTED -Windows.Win32.Foundation.ERROR_DISK_TOO_FRAGMENTED -Windows.Win32.Foundation.ERROR_DLL_INIT_FAILED -Windows.Win32.Foundation.ERROR_DLL_INIT_FAILED_LOGOFF -Windows.Win32.Foundation.ERROR_DLL_MIGHT_BE_INCOMPATIBLE -Windows.Win32.Foundation.ERROR_DLL_MIGHT_BE_INSECURE -Windows.Win32.Foundation.ERROR_DLL_NOT_FOUND -Windows.Win32.Foundation.ERROR_DLP_POLICY_DENIES_OPERATION -Windows.Win32.Foundation.ERROR_DLP_POLICY_SILENTLY_FAIL -Windows.Win32.Foundation.ERROR_DLP_POLICY_WARNS_AGAINST_OPERATION -Windows.Win32.Foundation.ERROR_DOMAIN_CONTROLLER_EXISTS -Windows.Win32.Foundation.ERROR_DOMAIN_CONTROLLER_NOT_FOUND -Windows.Win32.Foundation.ERROR_DOMAIN_CTRLR_CONFIG_ERROR -Windows.Win32.Foundation.ERROR_DOMAIN_EXISTS -Windows.Win32.Foundation.ERROR_DOMAIN_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DOMAIN_SID_SAME_AS_LOCAL_WORKSTATION -Windows.Win32.Foundation.ERROR_DOMAIN_TRUST_INCONSISTENT -Windows.Win32.Foundation.ERROR_DOWNGRADE_DETECTED -Windows.Win32.Foundation.ERROR_DPL_NOT_SUPPORTED_FOR_USER -Windows.Win32.Foundation.ERROR_DRIVE_LOCKED -Windows.Win32.Foundation.ERROR_DRIVER_BLOCKED -Windows.Win32.Foundation.ERROR_DRIVER_CANCEL_TIMEOUT -Windows.Win32.Foundation.ERROR_DRIVER_DATABASE_ERROR -Windows.Win32.Foundation.ERROR_DRIVER_FAILED_PRIOR_UNLOAD -Windows.Win32.Foundation.ERROR_DRIVER_FAILED_SLEEP -Windows.Win32.Foundation.ERROR_DRIVER_PROCESS_TERMINATED -Windows.Win32.Foundation.ERROR_DRIVERS_LEAKING_LOCKED_PAGES -Windows.Win32.Foundation.ERROR_DS_ADD_REPLICA_INHIBITED -Windows.Win32.Foundation.ERROR_DS_ADMIN_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_AFFECTS_MULTIPLE_DSAS -Windows.Win32.Foundation.ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER -Windows.Win32.Foundation.ERROR_DS_ALIAS_DEREF_PROBLEM -Windows.Win32.Foundation.ERROR_DS_ALIAS_POINTS_TO_ALIAS -Windows.Win32.Foundation.ERROR_DS_ALIAS_PROBLEM -Windows.Win32.Foundation.ERROR_DS_ALIASED_OBJ_MISSING -Windows.Win32.Foundation.ERROR_DS_ATT_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_DS_ATT_IS_NOT_ON_OBJ -Windows.Win32.Foundation.ERROR_DS_ATT_NOT_DEF_FOR_CLASS -Windows.Win32.Foundation.ERROR_DS_ATT_NOT_DEF_IN_SCHEMA -Windows.Win32.Foundation.ERROR_DS_ATT_SCHEMA_REQ_ID -Windows.Win32.Foundation.ERROR_DS_ATT_SCHEMA_REQ_SYNTAX -Windows.Win32.Foundation.ERROR_DS_ATT_VAL_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS -Windows.Win32.Foundation.ERROR_DS_ATTRIBUTE_OWNED_BY_SAM -Windows.Win32.Foundation.ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED -Windows.Win32.Foundation.ERROR_DS_AUDIT_FAILURE -Windows.Win32.Foundation.ERROR_DS_AUTH_METHOD_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_DS_AUTH_UNKNOWN -Windows.Win32.Foundation.ERROR_DS_AUTHORIZATION_FAILED -Windows.Win32.Foundation.ERROR_DS_AUX_CLS_TEST_FAIL -Windows.Win32.Foundation.ERROR_DS_BACKLINK_WITHOUT_LINK -Windows.Win32.Foundation.ERROR_DS_BAD_ATT_SCHEMA_SYNTAX -Windows.Win32.Foundation.ERROR_DS_BAD_HIERARCHY_FILE -Windows.Win32.Foundation.ERROR_DS_BAD_INSTANCE_TYPE -Windows.Win32.Foundation.ERROR_DS_BAD_NAME_SYNTAX -Windows.Win32.Foundation.ERROR_DS_BAD_RDN_ATT_ID_SYNTAX -Windows.Win32.Foundation.ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED -Windows.Win32.Foundation.ERROR_DS_BUSY -Windows.Win32.Foundation.ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD -Windows.Win32.Foundation.ERROR_DS_CANT_ADD_ATT_VALUES -Windows.Win32.Foundation.ERROR_DS_CANT_ADD_SYSTEM_ONLY -Windows.Win32.Foundation.ERROR_DS_CANT_ADD_TO_GC -Windows.Win32.Foundation.ERROR_DS_CANT_CACHE_ATT -Windows.Win32.Foundation.ERROR_DS_CANT_CACHE_CLASS -Windows.Win32.Foundation.ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC -Windows.Win32.Foundation.ERROR_DS_CANT_CREATE_UNDER_SCHEMA -Windows.Win32.Foundation.ERROR_DS_CANT_DEL_MASTER_CROSSREF -Windows.Win32.Foundation.ERROR_DS_CANT_DELETE -Windows.Win32.Foundation.ERROR_DS_CANT_DELETE_DSA_OBJ -Windows.Win32.Foundation.ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC -Windows.Win32.Foundation.ERROR_DS_CANT_DEREF_ALIAS -Windows.Win32.Foundation.ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN -Windows.Win32.Foundation.ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF -Windows.Win32.Foundation.ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN -Windows.Win32.Foundation.ERROR_DS_CANT_FIND_DSA_OBJ -Windows.Win32.Foundation.ERROR_DS_CANT_FIND_EXPECTED_NC -Windows.Win32.Foundation.ERROR_DS_CANT_FIND_NC_IN_CACHE -Windows.Win32.Foundation.ERROR_DS_CANT_MIX_MASTER_AND_REPS -Windows.Win32.Foundation.ERROR_DS_CANT_MOD_OBJ_CLASS -Windows.Win32.Foundation.ERROR_DS_CANT_MOD_PRIMARYGROUPID -Windows.Win32.Foundation.ERROR_DS_CANT_MOD_SYSTEM_ONLY -Windows.Win32.Foundation.ERROR_DS_CANT_MOVE_ACCOUNT_GROUP -Windows.Win32.Foundation.ERROR_DS_CANT_MOVE_APP_BASIC_GROUP -Windows.Win32.Foundation.ERROR_DS_CANT_MOVE_APP_QUERY_GROUP -Windows.Win32.Foundation.ERROR_DS_CANT_MOVE_DELETED_OBJECT -Windows.Win32.Foundation.ERROR_DS_CANT_MOVE_RESOURCE_GROUP -Windows.Win32.Foundation.ERROR_DS_CANT_ON_NON_LEAF -Windows.Win32.Foundation.ERROR_DS_CANT_ON_RDN -Windows.Win32.Foundation.ERROR_DS_CANT_REM_MISSING_ATT -Windows.Win32.Foundation.ERROR_DS_CANT_REM_MISSING_ATT_VAL -Windows.Win32.Foundation.ERROR_DS_CANT_REMOVE_ATT_CACHE -Windows.Win32.Foundation.ERROR_DS_CANT_REMOVE_CLASS_CACHE -Windows.Win32.Foundation.ERROR_DS_CANT_REPLACE_HIDDEN_REC -Windows.Win32.Foundation.ERROR_DS_CANT_RETRIEVE_ATTS -Windows.Win32.Foundation.ERROR_DS_CANT_RETRIEVE_CHILD -Windows.Win32.Foundation.ERROR_DS_CANT_RETRIEVE_DN -Windows.Win32.Foundation.ERROR_DS_CANT_RETRIEVE_INSTANCE -Windows.Win32.Foundation.ERROR_DS_CANT_RETRIEVE_SD -Windows.Win32.Foundation.ERROR_DS_CANT_START -Windows.Win32.Foundation.ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ -Windows.Win32.Foundation.ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS -Windows.Win32.Foundation.ERROR_DS_CHILDREN_EXIST -Windows.Win32.Foundation.ERROR_DS_CLASS_MUST_BE_CONCRETE -Windows.Win32.Foundation.ERROR_DS_CLASS_NOT_DSA -Windows.Win32.Foundation.ERROR_DS_CLIENT_LOOP -Windows.Win32.Foundation.ERROR_DS_CODE_INCONSISTENCY -Windows.Win32.Foundation.ERROR_DS_COMPARE_FALSE -Windows.Win32.Foundation.ERROR_DS_COMPARE_TRUE -Windows.Win32.Foundation.ERROR_DS_CONFIDENTIALITY_REQUIRED -Windows.Win32.Foundation.ERROR_DS_CONFIG_PARAM_MISSING -Windows.Win32.Foundation.ERROR_DS_CONSTRAINT_VIOLATION -Windows.Win32.Foundation.ERROR_DS_CONSTRUCTED_ATT_MOD -Windows.Win32.Foundation.ERROR_DS_CONTROL_NOT_FOUND -Windows.Win32.Foundation.ERROR_DS_COULDNT_CONTACT_FSMO -Windows.Win32.Foundation.ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE -Windows.Win32.Foundation.ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE -Windows.Win32.Foundation.ERROR_DS_COULDNT_UPDATE_SPNS -Windows.Win32.Foundation.ERROR_DS_COUNTING_AB_INDICES_FAILED -Windows.Win32.Foundation.ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE -Windows.Win32.Foundation.ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2 -Windows.Win32.Foundation.ERROR_DS_CROSS_DOM_MOVE_ERROR -Windows.Win32.Foundation.ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD -Windows.Win32.Foundation.ERROR_DS_CROSS_NC_DN_RENAME -Windows.Win32.Foundation.ERROR_DS_CROSS_REF_BUSY -Windows.Win32.Foundation.ERROR_DS_CROSS_REF_EXISTS -Windows.Win32.Foundation.ERROR_DS_DATABASE_ERROR -Windows.Win32.Foundation.ERROR_DS_DECODING_ERROR -Windows.Win32.Foundation.ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED -Windows.Win32.Foundation.ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_DIFFERENT_REPL_EPOCHS -Windows.Win32.Foundation.ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER -Windows.Win32.Foundation.ERROR_DS_DISALLOWED_NC_REDIRECT -Windows.Win32.Foundation.ERROR_DS_DNS_LOOKUP_FAILURE -Windows.Win32.Foundation.ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_DOMAIN_RENAME_IN_PROGRESS -Windows.Win32.Foundation.ERROR_DS_DOMAIN_VERSION_TOO_HIGH -Windows.Win32.Foundation.ERROR_DS_DOMAIN_VERSION_TOO_LOW -Windows.Win32.Foundation.ERROR_DS_DRA_ABANDON_SYNC -Windows.Win32.Foundation.ERROR_DS_DRA_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_DS_DRA_BAD_DN -Windows.Win32.Foundation.ERROR_DS_DRA_BAD_INSTANCE_TYPE -Windows.Win32.Foundation.ERROR_DS_DRA_BAD_NC -Windows.Win32.Foundation.ERROR_DS_DRA_BUSY -Windows.Win32.Foundation.ERROR_DS_DRA_CONNECTION_FAILED -Windows.Win32.Foundation.ERROR_DS_DRA_CORRUPT_UTD_VECTOR -Windows.Win32.Foundation.ERROR_DS_DRA_DB_ERROR -Windows.Win32.Foundation.ERROR_DS_DRA_DN_EXISTS -Windows.Win32.Foundation.ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT -Windows.Win32.Foundation.ERROR_DS_DRA_EXTN_CONNECTION_FAILED -Windows.Win32.Foundation.ERROR_DS_DRA_GENERIC -Windows.Win32.Foundation.ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET -Windows.Win32.Foundation.ERROR_DS_DRA_INCONSISTENT_DIT -Windows.Win32.Foundation.ERROR_DS_DRA_INTERNAL_ERROR -Windows.Win32.Foundation.ERROR_DS_DRA_INVALID_PARAMETER -Windows.Win32.Foundation.ERROR_DS_DRA_MAIL_PROBLEM -Windows.Win32.Foundation.ERROR_DS_DRA_MISSING_KRBTGT_SECRET -Windows.Win32.Foundation.ERROR_DS_DRA_MISSING_PARENT -Windows.Win32.Foundation.ERROR_DS_DRA_NAME_COLLISION -Windows.Win32.Foundation.ERROR_DS_DRA_NO_REPLICA -Windows.Win32.Foundation.ERROR_DS_DRA_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_DS_DRA_OBJ_IS_REP_SOURCE -Windows.Win32.Foundation.ERROR_DS_DRA_OBJ_NC_MISMATCH -Windows.Win32.Foundation.ERROR_DS_DRA_OUT_OF_MEM -Windows.Win32.Foundation.ERROR_DS_DRA_OUT_SCHEDULE_WINDOW -Windows.Win32.Foundation.ERROR_DS_DRA_PREEMPTED -Windows.Win32.Foundation.ERROR_DS_DRA_RECYCLED_TARGET -Windows.Win32.Foundation.ERROR_DS_DRA_REF_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_DS_DRA_REF_NOT_FOUND -Windows.Win32.Foundation.ERROR_DS_DRA_REPL_PENDING -Windows.Win32.Foundation.ERROR_DS_DRA_RPC_CANCELLED -Windows.Win32.Foundation.ERROR_DS_DRA_SCHEMA_CONFLICT -Windows.Win32.Foundation.ERROR_DS_DRA_SCHEMA_INFO_SHIP -Windows.Win32.Foundation.ERROR_DS_DRA_SCHEMA_MISMATCH -Windows.Win32.Foundation.ERROR_DS_DRA_SECRETS_DENIED -Windows.Win32.Foundation.ERROR_DS_DRA_SHUTDOWN -Windows.Win32.Foundation.ERROR_DS_DRA_SINK_DISABLED -Windows.Win32.Foundation.ERROR_DS_DRA_SOURCE_DISABLED -Windows.Win32.Foundation.ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA -Windows.Win32.Foundation.ERROR_DS_DRA_SOURCE_REINSTALLED -Windows.Win32.Foundation.ERROR_DS_DRS_EXTENSIONS_CHANGED -Windows.Win32.Foundation.ERROR_DS_DS_REQUIRED -Windows.Win32.Foundation.ERROR_DS_DSA_MUST_BE_INT_MASTER -Windows.Win32.Foundation.ERROR_DS_DST_DOMAIN_NOT_NATIVE -Windows.Win32.Foundation.ERROR_DS_DST_NC_MISMATCH -Windows.Win32.Foundation.ERROR_DS_DUP_LDAP_DISPLAY_NAME -Windows.Win32.Foundation.ERROR_DS_DUP_LINK_ID -Windows.Win32.Foundation.ERROR_DS_DUP_MAPI_ID -Windows.Win32.Foundation.ERROR_DS_DUP_MSDS_INTID -Windows.Win32.Foundation.ERROR_DS_DUP_OID -Windows.Win32.Foundation.ERROR_DS_DUP_RDN -Windows.Win32.Foundation.ERROR_DS_DUP_SCHEMA_ID_GUID -Windows.Win32.Foundation.ERROR_DS_DUPLICATE_ID_FOUND -Windows.Win32.Foundation.ERROR_DS_ENCODING_ERROR -Windows.Win32.Foundation.ERROR_DS_EPOCH_MISMATCH -Windows.Win32.Foundation.ERROR_DS_EXISTING_AD_CHILD_NC -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_AUX_CLS -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_MAY_HAVE -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_MUST_HAVE -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_POSS_SUP -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_RDNATTID -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_SUB_CLS -Windows.Win32.Foundation.ERROR_DS_FILTER_UNKNOWN -Windows.Win32.Foundation.ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS -Windows.Win32.Foundation.ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_FOREST_VERSION_TOO_HIGH -Windows.Win32.Foundation.ERROR_DS_FOREST_VERSION_TOO_LOW -Windows.Win32.Foundation.ERROR_DS_GC_NOT_AVAILABLE -Windows.Win32.Foundation.ERROR_DS_GC_REQUIRED -Windows.Win32.Foundation.ERROR_DS_GCVERIFY_ERROR -Windows.Win32.Foundation.ERROR_DS_GENERIC_ERROR -Windows.Win32.Foundation.ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER -Windows.Win32.Foundation.ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER -Windows.Win32.Foundation.ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER -Windows.Win32.Foundation.ERROR_DS_GOVERNSID_MISSING -Windows.Win32.Foundation.ERROR_DS_GROUP_CONVERSION_ERROR -Windows.Win32.Foundation.ERROR_DS_HAVE_PRIMARY_MEMBERS -Windows.Win32.Foundation.ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED -Windows.Win32.Foundation.ERROR_DS_HIERARCHY_TABLE_TOO_DEEP -Windows.Win32.Foundation.ERROR_DS_HIGH_ADLDS_FFL -Windows.Win32.Foundation.ERROR_DS_HIGH_DSA_VERSION -Windows.Win32.Foundation.ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD -Windows.Win32.Foundation.ERROR_DS_ILLEGAL_MOD_OPERATION -Windows.Win32.Foundation.ERROR_DS_ILLEGAL_SUPERIOR -Windows.Win32.Foundation.ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION -Windows.Win32.Foundation.ERROR_DS_INAPPROPRIATE_AUTH -Windows.Win32.Foundation.ERROR_DS_INAPPROPRIATE_MATCHING -Windows.Win32.Foundation.ERROR_DS_INCOMPATIBLE_CONTROLS_USED -Windows.Win32.Foundation.ERROR_DS_INCOMPATIBLE_VERSION -Windows.Win32.Foundation.ERROR_DS_INCORRECT_ROLE_OWNER -Windows.Win32.Foundation.ERROR_DS_INIT_FAILURE -Windows.Win32.Foundation.ERROR_DS_INIT_FAILURE_CONSOLE -Windows.Win32.Foundation.ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE -Windows.Win32.Foundation.ERROR_DS_INSTALL_NO_SRC_SCH_VERSION -Windows.Win32.Foundation.ERROR_DS_INSTALL_SCHEMA_MISMATCH -Windows.Win32.Foundation.ERROR_DS_INSUFF_ACCESS_RIGHTS -Windows.Win32.Foundation.ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT -Windows.Win32.Foundation.ERROR_DS_INTERNAL_FAILURE -Windows.Win32.Foundation.ERROR_DS_INVALID_ATTRIBUTE_SYNTAX -Windows.Win32.Foundation.ERROR_DS_INVALID_DMD -Windows.Win32.Foundation.ERROR_DS_INVALID_DN_SYNTAX -Windows.Win32.Foundation.ERROR_DS_INVALID_GROUP_TYPE -Windows.Win32.Foundation.ERROR_DS_INVALID_LDAP_DISPLAY_NAME -Windows.Win32.Foundation.ERROR_DS_INVALID_NAME_FOR_SPN -Windows.Win32.Foundation.ERROR_DS_INVALID_ROLE_OWNER -Windows.Win32.Foundation.ERROR_DS_INVALID_SCRIPT -Windows.Win32.Foundation.ERROR_DS_INVALID_SEARCH_FLAG -Windows.Win32.Foundation.ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE -Windows.Win32.Foundation.ERROR_DS_INVALID_SEARCH_FLAG_TUPLE -Windows.Win32.Foundation.ERROR_DS_IS_LEAF -Windows.Win32.Foundation.ERROR_DS_KEY_NOT_UNIQUE -Windows.Win32.Foundation.ERROR_DS_LDAP_SEND_QUEUE_FULL -Windows.Win32.Foundation.ERROR_DS_LINK_ID_NOT_AVAILABLE -Windows.Win32.Foundation.ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER -Windows.Win32.Foundation.ERROR_DS_LOCAL_ERROR -Windows.Win32.Foundation.ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY -Windows.Win32.Foundation.ERROR_DS_LOOP_DETECT -Windows.Win32.Foundation.ERROR_DS_LOW_ADLDS_FFL -Windows.Win32.Foundation.ERROR_DS_LOW_DSA_VERSION -Windows.Win32.Foundation.ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4 -Windows.Win32.Foundation.ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_MAPI_ID_NOT_AVAILABLE -Windows.Win32.Foundation.ERROR_DS_MASTERDSA_REQUIRED -Windows.Win32.Foundation.ERROR_DS_MAX_OBJ_SIZE_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY -Windows.Win32.Foundation.ERROR_DS_MISSING_EXPECTED_ATT -Windows.Win32.Foundation.ERROR_DS_MISSING_FOREST_TRUST -Windows.Win32.Foundation.ERROR_DS_MISSING_FSMO_SETTINGS -Windows.Win32.Foundation.ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER -Windows.Win32.Foundation.ERROR_DS_MISSING_REQUIRED_ATT -Windows.Win32.Foundation.ERROR_DS_MISSING_SUPREF -Windows.Win32.Foundation.ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG -Windows.Win32.Foundation.ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE -Windows.Win32.Foundation.ERROR_DS_MODIFYDN_WRONG_GRANDPARENT -Windows.Win32.Foundation.ERROR_DS_MUST_BE_RUN_ON_DST_DC -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_DOMAIN_ONLY -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_NO_MAPPING -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_NOT_FOUND -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_NOT_UNIQUE -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_RESOLVING -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_TRUST_REFERRAL -Windows.Win32.Foundation.ERROR_DS_NAME_NOT_UNIQUE -Windows.Win32.Foundation.ERROR_DS_NAME_REFERENCE_INVALID -Windows.Win32.Foundation.ERROR_DS_NAME_TOO_LONG -Windows.Win32.Foundation.ERROR_DS_NAME_TOO_MANY_PARTS -Windows.Win32.Foundation.ERROR_DS_NAME_TYPE_UNKNOWN -Windows.Win32.Foundation.ERROR_DS_NAME_UNPARSEABLE -Windows.Win32.Foundation.ERROR_DS_NAME_VALUE_TOO_LONG -Windows.Win32.Foundation.ERROR_DS_NAMING_MASTER_GC -Windows.Win32.Foundation.ERROR_DS_NAMING_VIOLATION -Windows.Win32.Foundation.ERROR_DS_NC_MUST_HAVE_NC_PARENT -Windows.Win32.Foundation.ERROR_DS_NC_STILL_HAS_DSAS -Windows.Win32.Foundation.ERROR_DS_NCNAME_MISSING_CR_REF -Windows.Win32.Foundation.ERROR_DS_NCNAME_MUST_BE_NC -Windows.Win32.Foundation.ERROR_DS_NO_ATTRIBUTE_OR_VALUE -Windows.Win32.Foundation.ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN -Windows.Win32.Foundation.ERROR_DS_NO_CHAINED_EVAL -Windows.Win32.Foundation.ERROR_DS_NO_CHAINING -Windows.Win32.Foundation.ERROR_DS_NO_CHECKPOINT_WITH_PDC -Windows.Win32.Foundation.ERROR_DS_NO_CROSSREF_FOR_NC -Windows.Win32.Foundation.ERROR_DS_NO_DELETED_NAME -Windows.Win32.Foundation.ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS -Windows.Win32.Foundation.ERROR_DS_NO_MORE_RIDS -Windows.Win32.Foundation.ERROR_DS_NO_MSDS_INTID -Windows.Win32.Foundation.ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN -Windows.Win32.Foundation.ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN -Windows.Win32.Foundation.ERROR_DS_NO_NTDSA_OBJECT -Windows.Win32.Foundation.ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC -Windows.Win32.Foundation.ERROR_DS_NO_PARENT_OBJECT -Windows.Win32.Foundation.ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION -Windows.Win32.Foundation.ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA -Windows.Win32.Foundation.ERROR_DS_NO_REF_DOMAIN -Windows.Win32.Foundation.ERROR_DS_NO_REQUESTED_ATTS_FOUND -Windows.Win32.Foundation.ERROR_DS_NO_RESULTS_RETURNED -Windows.Win32.Foundation.ERROR_DS_NO_RIDS_ALLOCATED -Windows.Win32.Foundation.ERROR_DS_NO_SERVER_OBJECT -Windows.Win32.Foundation.ERROR_DS_NO_SUCH_OBJECT -Windows.Win32.Foundation.ERROR_DS_NO_TREE_DELETE_ABOVE_NC -Windows.Win32.Foundation.ERROR_DS_NON_ASQ_SEARCH -Windows.Win32.Foundation.ERROR_DS_NON_BASE_SEARCH -Windows.Win32.Foundation.ERROR_DS_NONEXISTENT_MAY_HAVE -Windows.Win32.Foundation.ERROR_DS_NONEXISTENT_MUST_HAVE -Windows.Win32.Foundation.ERROR_DS_NONEXISTENT_POSS_SUP -Windows.Win32.Foundation.ERROR_DS_NONSAFE_SCHEMA_CHANGE -Windows.Win32.Foundation.ERROR_DS_NOT_AN_OBJECT -Windows.Win32.Foundation.ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC -Windows.Win32.Foundation.ERROR_DS_NOT_CLOSEST -Windows.Win32.Foundation.ERROR_DS_NOT_INSTALLED -Windows.Win32.Foundation.ERROR_DS_NOT_ON_BACKLINK -Windows.Win32.Foundation.ERROR_DS_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_DS_NOT_SUPPORTED_SORT_ORDER -Windows.Win32.Foundation.ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX -Windows.Win32.Foundation.ERROR_DS_NTDSCRIPT_PROCESS_ERROR -Windows.Win32.Foundation.ERROR_DS_NTDSCRIPT_SYNTAX_ERROR -Windows.Win32.Foundation.ERROR_DS_OBJ_CLASS_NOT_DEFINED -Windows.Win32.Foundation.ERROR_DS_OBJ_CLASS_NOT_SUBCLASS -Windows.Win32.Foundation.ERROR_DS_OBJ_CLASS_VIOLATION -Windows.Win32.Foundation.ERROR_DS_OBJ_GUID_EXISTS -Windows.Win32.Foundation.ERROR_DS_OBJ_NOT_FOUND -Windows.Win32.Foundation.ERROR_DS_OBJ_STRING_NAME_EXISTS -Windows.Win32.Foundation.ERROR_DS_OBJ_TOO_LARGE -Windows.Win32.Foundation.ERROR_DS_OBJECT_BEING_REMOVED -Windows.Win32.Foundation.ERROR_DS_OBJECT_CLASS_REQUIRED -Windows.Win32.Foundation.ERROR_DS_OBJECT_RESULTS_TOO_LARGE -Windows.Win32.Foundation.ERROR_DS_OFFSET_RANGE_ERROR -Windows.Win32.Foundation.ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS -Windows.Win32.Foundation.ERROR_DS_OID_NOT_FOUND -Windows.Win32.Foundation.ERROR_DS_OPERATIONS_ERROR -Windows.Win32.Foundation.ERROR_DS_OUT_OF_SCOPE -Windows.Win32.Foundation.ERROR_DS_OUT_OF_VERSION_STORE -Windows.Win32.Foundation.ERROR_DS_PARAM_ERROR -Windows.Win32.Foundation.ERROR_DS_PARENT_IS_AN_ALIAS -Windows.Win32.Foundation.ERROR_DS_PDC_OPERATION_IN_PROGRESS -Windows.Win32.Foundation.ERROR_DS_PER_ATTRIBUTE_AUTHZ_FAILED_DURING_ADD -Windows.Win32.Foundation.ERROR_DS_POLICY_NOT_KNOWN -Windows.Win32.Foundation.ERROR_DS_PROTOCOL_ERROR -Windows.Win32.Foundation.ERROR_DS_RANGE_CONSTRAINT -Windows.Win32.Foundation.ERROR_DS_RDN_DOESNT_MATCH_SCHEMA -Windows.Win32.Foundation.ERROR_DS_RECALCSCHEMA_FAILED -Windows.Win32.Foundation.ERROR_DS_REFERRAL -Windows.Win32.Foundation.ERROR_DS_REFERRAL_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_REFUSING_FSMO_ROLES -Windows.Win32.Foundation.ERROR_DS_REMOTE_CROSSREF_OP_FAILED -Windows.Win32.Foundation.ERROR_DS_REPL_LIFETIME_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR -Windows.Win32.Foundation.ERROR_DS_REPLICATOR_ONLY -Windows.Win32.Foundation.ERROR_DS_RESERVED_LINK_ID -Windows.Win32.Foundation.ERROR_DS_RESERVED_MAPI_ID -Windows.Win32.Foundation.ERROR_DS_RIDMGR_DISABLED -Windows.Win32.Foundation.ERROR_DS_RIDMGR_INIT_ERROR -Windows.Win32.Foundation.ERROR_DS_ROLE_NOT_VERIFIED -Windows.Win32.Foundation.ERROR_DS_ROOT_CANT_BE_SUBREF -Windows.Win32.Foundation.ERROR_DS_ROOT_MUST_BE_NC -Windows.Win32.Foundation.ERROR_DS_ROOT_REQUIRES_CLASS_TOP -Windows.Win32.Foundation.ERROR_DS_SAM_INIT_FAILURE -Windows.Win32.Foundation.ERROR_DS_SAM_INIT_FAILURE_CONSOLE -Windows.Win32.Foundation.ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY -Windows.Win32.Foundation.ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD -Windows.Win32.Foundation.ERROR_DS_SCHEMA_ALLOC_FAILED -Windows.Win32.Foundation.ERROR_DS_SCHEMA_NOT_LOADED -Windows.Win32.Foundation.ERROR_DS_SCHEMA_UPDATE_DISALLOWED -Windows.Win32.Foundation.ERROR_DS_SEC_DESC_INVALID -Windows.Win32.Foundation.ERROR_DS_SEC_DESC_TOO_SHORT -Windows.Win32.Foundation.ERROR_DS_SECURITY_CHECKING_ERROR -Windows.Win32.Foundation.ERROR_DS_SECURITY_ILLEGAL_MODIFY -Windows.Win32.Foundation.ERROR_DS_SEMANTIC_ATT_TEST -Windows.Win32.Foundation.ERROR_DS_SENSITIVE_GROUP_VIOLATION -Windows.Win32.Foundation.ERROR_DS_SERVER_DOWN -Windows.Win32.Foundation.ERROR_DS_SHUTTING_DOWN -Windows.Win32.Foundation.ERROR_DS_SINGLE_USER_MODE_FAILED -Windows.Win32.Foundation.ERROR_DS_SINGLE_VALUE_CONSTRAINT -Windows.Win32.Foundation.ERROR_DS_SIZELIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_SORT_CONTROL_MISSING -Windows.Win32.Foundation.ERROR_DS_SOURCE_AUDITING_NOT_ENABLED -Windows.Win32.Foundation.ERROR_DS_SOURCE_DOMAIN_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_SPN_VALUE_NOT_UNIQUE_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_SRC_AND_DST_NC_IDENTICAL -Windows.Win32.Foundation.ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH -Windows.Win32.Foundation.ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER -Windows.Win32.Foundation.ERROR_DS_SRC_GUID_MISMATCH -Windows.Win32.Foundation.ERROR_DS_SRC_NAME_MISMATCH -Windows.Win32.Foundation.ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER -Windows.Win32.Foundation.ERROR_DS_SRC_SID_EXISTS_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_STRING_SD_CONVERSION_FAILED -Windows.Win32.Foundation.ERROR_DS_STRONG_AUTH_REQUIRED -Windows.Win32.Foundation.ERROR_DS_SUB_CLS_TEST_FAIL -Windows.Win32.Foundation.ERROR_DS_SUBREF_MUST_HAVE_PARENT -Windows.Win32.Foundation.ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD -Windows.Win32.Foundation.ERROR_DS_SYNTAX_MISMATCH -Windows.Win32.Foundation.ERROR_DS_THREAD_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_TIMELIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_TREE_DELETE_NOT_FINISHED -Windows.Win32.Foundation.ERROR_DS_UNABLE_TO_SURRENDER_ROLES -Windows.Win32.Foundation.ERROR_DS_UNAVAILABLE -Windows.Win32.Foundation.ERROR_DS_UNAVAILABLE_CRIT_EXTENSION -Windows.Win32.Foundation.ERROR_DS_UNDELETE_SAM_VALIDATION_FAILED -Windows.Win32.Foundation.ERROR_DS_UNICODEPWD_NOT_IN_QUOTES -Windows.Win32.Foundation.ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER -Windows.Win32.Foundation.ERROR_DS_UNKNOWN_ERROR -Windows.Win32.Foundation.ERROR_DS_UNKNOWN_OPERATION -Windows.Win32.Foundation.ERROR_DS_UNWILLING_TO_PERFORM -Windows.Win32.Foundation.ERROR_DS_UPN_VALUE_NOT_UNIQUE_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_USER_BUFFER_TO_SMALL -Windows.Win32.Foundation.ERROR_DS_VALUE_KEY_NOT_UNIQUE -Windows.Win32.Foundation.ERROR_DS_VERSION_CHECK_FAILURE -Windows.Win32.Foundation.ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL -Windows.Win32.Foundation.ERROR_DS_WRONG_LINKED_ATT_SYNTAX -Windows.Win32.Foundation.ERROR_DS_WRONG_OM_OBJ_CLASS -Windows.Win32.Foundation.ERROR_DUP_DOMAINNAME -Windows.Win32.Foundation.ERROR_DUP_NAME -Windows.Win32.Foundation.ERROR_DUPLICATE_PRIVILEGES -Windows.Win32.Foundation.ERROR_DUPLICATE_SERVICE_NAME -Windows.Win32.Foundation.ERROR_DYNAMIC_CODE_BLOCKED -Windows.Win32.Foundation.ERROR_DYNLINK_FROM_INVALID_RING -Windows.Win32.Foundation.ERROR_EA_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_EA_FILE_CORRUPT -Windows.Win32.Foundation.ERROR_EA_LIST_INCONSISTENT -Windows.Win32.Foundation.ERROR_EA_TABLE_FULL -Windows.Win32.Foundation.ERROR_EAS_DIDNT_FIT -Windows.Win32.Foundation.ERROR_EAS_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_EDP_DPL_POLICY_CANT_BE_SATISFIED -Windows.Win32.Foundation.ERROR_EDP_POLICY_DENIES_OPERATION -Windows.Win32.Foundation.ERROR_EFS_ALG_BLOB_TOO_BIG -Windows.Win32.Foundation.ERROR_EFS_DISABLED -Windows.Win32.Foundation.ERROR_EFS_SERVER_NOT_TRUSTED -Windows.Win32.Foundation.ERROR_EFS_VERSION_NOT_SUPPORT -Windows.Win32.Foundation.ERROR_ELEVATION_REQUIRED -Windows.Win32.Foundation.ERROR_ENCLAVE_FAILURE -Windows.Win32.Foundation.ERROR_ENCLAVE_NOT_TERMINATED -Windows.Win32.Foundation.ERROR_ENCLAVE_VIOLATION -Windows.Win32.Foundation.ERROR_ENCRYPTED_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_ENCRYPTED_IO_NOT_POSSIBLE -Windows.Win32.Foundation.ERROR_ENCRYPTING_METADATA_DISALLOWED -Windows.Win32.Foundation.ERROR_ENCRYPTION_DISABLED -Windows.Win32.Foundation.ERROR_ENCRYPTION_FAILED -Windows.Win32.Foundation.ERROR_ENCRYPTION_POLICY_DENIES_OPERATION -Windows.Win32.Foundation.ERROR_END_OF_MEDIA -Windows.Win32.Foundation.ERROR_ENVVAR_NOT_FOUND -Windows.Win32.Foundation.ERROR_EOM_OVERFLOW -Windows.Win32.Foundation.ERROR_ERRORS_ENCOUNTERED -Windows.Win32.Foundation.ERROR_EVALUATION_EXPIRATION -Windows.Win32.Foundation.ERROR_EVENT_DONE -Windows.Win32.Foundation.ERROR_EVENT_PENDING -Windows.Win32.Foundation.ERROR_EVENTLOG_CANT_START -Windows.Win32.Foundation.ERROR_EVENTLOG_FILE_CHANGED -Windows.Win32.Foundation.ERROR_EVENTLOG_FILE_CORRUPT -Windows.Win32.Foundation.ERROR_EXCEPTION_IN_SERVICE -Windows.Win32.Foundation.ERROR_EXCL_SEM_ALREADY_OWNED -Windows.Win32.Foundation.ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY -Windows.Win32.Foundation.ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY -Windows.Win32.Foundation.ERROR_EXE_MACHINE_TYPE_MISMATCH -Windows.Win32.Foundation.ERROR_EXE_MARKED_INVALID -Windows.Win32.Foundation.ERROR_EXTENDED_ERROR -Windows.Win32.Foundation.ERROR_EXTERNAL_BACKING_PROVIDER_UNKNOWN -Windows.Win32.Foundation.ERROR_EXTERNAL_SYSKEY_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_EXTRANEOUS_INFORMATION -Windows.Win32.Foundation.ERROR_FAIL_FAST_EXCEPTION -Windows.Win32.Foundation.ERROR_FAIL_I24 -Windows.Win32.Foundation.ERROR_FAIL_NOACTION_REBOOT -Windows.Win32.Foundation.ERROR_FAIL_RESTART -Windows.Win32.Foundation.ERROR_FAIL_SHUTDOWN -Windows.Win32.Foundation.ERROR_FAILED_DRIVER_ENTRY -Windows.Win32.Foundation.ERROR_FAILED_SERVICE_CONTROLLER_CONNECT -Windows.Win32.Foundation.ERROR_FATAL_APP_EXIT -Windows.Win32.Foundation.ERROR_FILE_CHECKED_OUT -Windows.Win32.Foundation.ERROR_FILE_CORRUPT -Windows.Win32.Foundation.ERROR_FILE_ENCRYPTED -Windows.Win32.Foundation.ERROR_FILE_EXISTS -Windows.Win32.Foundation.ERROR_FILE_HANDLE_REVOKED -Windows.Win32.Foundation.ERROR_FILE_INVALID -Windows.Win32.Foundation.ERROR_FILE_LEVEL_TRIM_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_FILE_METADATA_OPTIMIZATION_IN_PROGRESS -Windows.Win32.Foundation.ERROR_FILE_NOT_ENCRYPTED -Windows.Win32.Foundation.ERROR_FILE_NOT_FOUND -Windows.Win32.Foundation.ERROR_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_FILE_OFFLINE -Windows.Win32.Foundation.ERROR_FILE_PROTECTED_UNDER_DPL -Windows.Win32.Foundation.ERROR_FILE_READ_ONLY -Windows.Win32.Foundation.ERROR_FILE_SNAP_IN_PROGRESS -Windows.Win32.Foundation.ERROR_FILE_SNAP_INVALID_PARAMETER -Windows.Win32.Foundation.ERROR_FILE_SNAP_IO_NOT_COORDINATED -Windows.Win32.Foundation.ERROR_FILE_SNAP_MODIFY_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_FILE_SNAP_UNEXPECTED_ERROR -Windows.Win32.Foundation.ERROR_FILE_SNAP_USER_SECTION_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_LIMITATION -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_VIRTUALIZATION_BUSY -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_VIRTUALIZATION_INVALID_OPERATION -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_VIRTUALIZATION_METADATA_CORRUPT -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_VIRTUALIZATION_PROVIDER_UNKNOWN -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_VIRTUALIZATION_UNAVAILABLE -Windows.Win32.Foundation.ERROR_FILE_TOO_LARGE -Windows.Win32.Foundation.ERROR_FILEMARK_DETECTED -Windows.Win32.Foundation.ERROR_FILENAME_EXCED_RANGE -Windows.Win32.Foundation.ERROR_FIRMWARE_UPDATED -Windows.Win32.Foundation.ERROR_FLOAT_MULTIPLE_FAULTS -Windows.Win32.Foundation.ERROR_FLOAT_MULTIPLE_TRAPS -Windows.Win32.Foundation.ERROR_FLOPPY_BAD_REGISTERS -Windows.Win32.Foundation.ERROR_FLOPPY_ID_MARK_NOT_FOUND -Windows.Win32.Foundation.ERROR_FLOPPY_UNKNOWN_ERROR -Windows.Win32.Foundation.ERROR_FLOPPY_VOLUME -Windows.Win32.Foundation.ERROR_FLOPPY_WRONG_CYLINDER -Windows.Win32.Foundation.ERROR_FORMS_AUTH_REQUIRED -Windows.Win32.Foundation.ERROR_FOUND_OUT_OF_SCOPE -Windows.Win32.Foundation.ERROR_FS_DRIVER_REQUIRED -Windows.Win32.Foundation.ERROR_FS_METADATA_INCONSISTENT -Windows.Win32.Foundation.ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY -Windows.Win32.Foundation.ERROR_FT_DI_SCAN_REQUIRED -Windows.Win32.Foundation.ERROR_FT_READ_FAILURE -Windows.Win32.Foundation.ERROR_FT_READ_FROM_COPY_FAILURE -Windows.Win32.Foundation.ERROR_FT_READ_RECOVERY_FROM_BACKUP -Windows.Win32.Foundation.ERROR_FT_WRITE_FAILURE -Windows.Win32.Foundation.ERROR_FT_WRITE_RECOVERY -Windows.Win32.Foundation.ERROR_FULLSCREEN_MODE -Windows.Win32.Foundation.ERROR_FUNCTION_FAILED -Windows.Win32.Foundation.ERROR_FUNCTION_NOT_CALLED -Windows.Win32.Foundation.ERROR_GDI_HANDLE_LEAK -Windows.Win32.Foundation.ERROR_GEN_FAILURE -Windows.Win32.Foundation.ERROR_GENERIC_NOT_MAPPED -Windows.Win32.Foundation.ERROR_GLOBAL_ONLY_HOOK -Windows.Win32.Foundation.ERROR_GRACEFUL_DISCONNECT -Windows.Win32.Foundation.ERROR_GROUP_EXISTS -Windows.Win32.Foundation.ERROR_GUID_SUBSTITUTION_MADE -Windows.Win32.Foundation.ERROR_HANDLE_DISK_FULL -Windows.Win32.Foundation.ERROR_HANDLE_EOF -Windows.Win32.Foundation.ERROR_HANDLE_REVOKED -Windows.Win32.Foundation.ERROR_HANDLES_CLOSED -Windows.Win32.Foundation.ERROR_HAS_SYSTEM_CRITICAL_FILES -Windows.Win32.Foundation.ERROR_HIBERNATED -Windows.Win32.Foundation.ERROR_HIBERNATION_FAILURE -Windows.Win32.Foundation.ERROR_HOOK_NEEDS_HMOD -Windows.Win32.Foundation.ERROR_HOOK_NOT_INSTALLED -Windows.Win32.Foundation.ERROR_HOOK_TYPE_NOT_ALLOWED -Windows.Win32.Foundation.ERROR_HOST_DOWN -Windows.Win32.Foundation.ERROR_HOST_UNREACHABLE -Windows.Win32.Foundation.ERROR_HOTKEY_ALREADY_REGISTERED -Windows.Win32.Foundation.ERROR_HOTKEY_NOT_REGISTERED -Windows.Win32.Foundation.ERROR_HWNDS_HAVE_DIFF_PARENT -Windows.Win32.Foundation.ERROR_ILL_FORMED_PASSWORD -Windows.Win32.Foundation.ERROR_ILLEGAL_CHARACTER -Windows.Win32.Foundation.ERROR_ILLEGAL_DLL_RELOCATION -Windows.Win32.Foundation.ERROR_ILLEGAL_ELEMENT_ADDRESS -Windows.Win32.Foundation.ERROR_ILLEGAL_FLOAT_CONTEXT -Windows.Win32.Foundation.ERROR_IMAGE_AT_DIFFERENT_BASE -Windows.Win32.Foundation.ERROR_IMAGE_MACHINE_TYPE_MISMATCH -Windows.Win32.Foundation.ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE -Windows.Win32.Foundation.ERROR_IMAGE_NOT_AT_BASE -Windows.Win32.Foundation.ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT -Windows.Win32.Foundation.ERROR_IMPLEMENTATION_LIMIT -Windows.Win32.Foundation.ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE -Windows.Win32.Foundation.ERROR_INCOMPATIBLE_SERVICE_SID_TYPE -Windows.Win32.Foundation.ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING -Windows.Win32.Foundation.ERROR_INCORRECT_ACCOUNT_TYPE -Windows.Win32.Foundation.ERROR_INCORRECT_ADDRESS -Windows.Win32.Foundation.ERROR_INCORRECT_SIZE -Windows.Win32.Foundation.ERROR_INDEX_ABSENT -Windows.Win32.Foundation.ERROR_INDEX_OUT_OF_BOUNDS -Windows.Win32.Foundation.ERROR_INFLOOP_IN_RELOC_CHAIN -Windows.Win32.Foundation.ERROR_INSTALL_ALREADY_RUNNING -Windows.Win32.Foundation.ERROR_INSTALL_FAILURE -Windows.Win32.Foundation.ERROR_INSTALL_LANGUAGE_UNSUPPORTED -Windows.Win32.Foundation.ERROR_INSTALL_LOG_FAILURE -Windows.Win32.Foundation.ERROR_INSTALL_NOTUSED -Windows.Win32.Foundation.ERROR_INSTALL_PACKAGE_INVALID -Windows.Win32.Foundation.ERROR_INSTALL_PACKAGE_OPEN_FAILED -Windows.Win32.Foundation.ERROR_INSTALL_PACKAGE_REJECTED -Windows.Win32.Foundation.ERROR_INSTALL_PACKAGE_VERSION -Windows.Win32.Foundation.ERROR_INSTALL_PLATFORM_UNSUPPORTED -Windows.Win32.Foundation.ERROR_INSTALL_REJECTED -Windows.Win32.Foundation.ERROR_INSTALL_REMOTE_DISALLOWED -Windows.Win32.Foundation.ERROR_INSTALL_REMOTE_PROHIBITED -Windows.Win32.Foundation.ERROR_INSTALL_SERVICE_FAILURE -Windows.Win32.Foundation.ERROR_INSTALL_SERVICE_SAFEBOOT -Windows.Win32.Foundation.ERROR_INSTALL_SOURCE_ABSENT -Windows.Win32.Foundation.ERROR_INSTALL_SUSPEND -Windows.Win32.Foundation.ERROR_INSTALL_TEMP_UNWRITABLE -Windows.Win32.Foundation.ERROR_INSTALL_TRANSFORM_FAILURE -Windows.Win32.Foundation.ERROR_INSTALL_TRANSFORM_REJECTED -Windows.Win32.Foundation.ERROR_INSTALL_UI_FAILURE -Windows.Win32.Foundation.ERROR_INSTALL_USEREXIT -Windows.Win32.Foundation.ERROR_INSTRUCTION_MISALIGNMENT -Windows.Win32.Foundation.ERROR_INSUFFICIENT_BUFFER -Windows.Win32.Foundation.ERROR_INSUFFICIENT_LOGON_INFO -Windows.Win32.Foundation.ERROR_INSUFFICIENT_POWER -Windows.Win32.Foundation.ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE -Windows.Win32.Foundation.ERROR_INSUFFICIENT_VIRTUAL_ADDR_RESOURCES -Windows.Win32.Foundation.ERROR_INTERMIXED_KERNEL_EA_OPERATION -Windows.Win32.Foundation.ERROR_INTERNAL_DB_CORRUPTION -Windows.Win32.Foundation.ERROR_INTERNAL_DB_ERROR -Windows.Win32.Foundation.ERROR_INTERNAL_ERROR -Windows.Win32.Foundation.ERROR_INTERRUPT_STILL_CONNECTED -Windows.Win32.Foundation.ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED -Windows.Win32.Foundation.ERROR_INVALID_ACCEL_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_ACCESS -Windows.Win32.Foundation.ERROR_INVALID_ACCOUNT_NAME -Windows.Win32.Foundation.ERROR_INVALID_ACE_CONDITION -Windows.Win32.Foundation.ERROR_INVALID_ACL -Windows.Win32.Foundation.ERROR_INVALID_ADDRESS -Windows.Win32.Foundation.ERROR_INVALID_AT_INTERRUPT_TIME -Windows.Win32.Foundation.ERROR_INVALID_BLOCK -Windows.Win32.Foundation.ERROR_INVALID_BLOCK_LENGTH -Windows.Win32.Foundation.ERROR_INVALID_CAP -Windows.Win32.Foundation.ERROR_INVALID_CATEGORY -Windows.Win32.Foundation.ERROR_INVALID_COMBOBOX_MESSAGE -Windows.Win32.Foundation.ERROR_INVALID_COMMAND_LINE -Windows.Win32.Foundation.ERROR_INVALID_COMPUTERNAME -Windows.Win32.Foundation.ERROR_INVALID_CRUNTIME_PARAMETER -Windows.Win32.Foundation.ERROR_INVALID_CURSOR_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_DATA -Windows.Win32.Foundation.ERROR_INVALID_DATATYPE -Windows.Win32.Foundation.ERROR_INVALID_DEVICE_OBJECT_PARAMETER -Windows.Win32.Foundation.ERROR_INVALID_DLL -Windows.Win32.Foundation.ERROR_INVALID_DOMAIN_ROLE -Windows.Win32.Foundation.ERROR_INVALID_DOMAIN_STATE -Windows.Win32.Foundation.ERROR_INVALID_DOMAINNAME -Windows.Win32.Foundation.ERROR_INVALID_DRIVE -Windows.Win32.Foundation.ERROR_INVALID_DWP_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_EA_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_EA_NAME -Windows.Win32.Foundation.ERROR_INVALID_EDIT_HEIGHT -Windows.Win32.Foundation.ERROR_INVALID_ENVIRONMENT -Windows.Win32.Foundation.ERROR_INVALID_EVENT_COUNT -Windows.Win32.Foundation.ERROR_INVALID_EVENTNAME -Windows.Win32.Foundation.ERROR_INVALID_EXCEPTION_HANDLER -Windows.Win32.Foundation.ERROR_INVALID_EXE_SIGNATURE -Windows.Win32.Foundation.ERROR_INVALID_FIELD -Windows.Win32.Foundation.ERROR_INVALID_FIELD_IN_PARAMETER_LIST -Windows.Win32.Foundation.ERROR_INVALID_FILTER_PROC -Windows.Win32.Foundation.ERROR_INVALID_FLAG_NUMBER -Windows.Win32.Foundation.ERROR_INVALID_FLAGS -Windows.Win32.Foundation.ERROR_INVALID_FORM_NAME -Windows.Win32.Foundation.ERROR_INVALID_FORM_SIZE -Windows.Win32.Foundation.ERROR_INVALID_FUNCTION -Windows.Win32.Foundation.ERROR_INVALID_GROUP_ATTRIBUTES -Windows.Win32.Foundation.ERROR_INVALID_GROUPNAME -Windows.Win32.Foundation.ERROR_INVALID_GW_COMMAND -Windows.Win32.Foundation.ERROR_INVALID_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_HANDLE_STATE -Windows.Win32.Foundation.ERROR_INVALID_HOOK_FILTER -Windows.Win32.Foundation.ERROR_INVALID_HOOK_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_HW_PROFILE -Windows.Win32.Foundation.ERROR_INVALID_ICON_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_ID_AUTHORITY -Windows.Win32.Foundation.ERROR_INVALID_IMAGE_HASH -Windows.Win32.Foundation.ERROR_INVALID_IMPORT_OF_NON_DLL -Windows.Win32.Foundation.ERROR_INVALID_INDEX -Windows.Win32.Foundation.ERROR_INVALID_KERNEL_INFO_VERSION -Windows.Win32.Foundation.ERROR_INVALID_KEYBOARD_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_LABEL -Windows.Win32.Foundation.ERROR_INVALID_LB_MESSAGE -Windows.Win32.Foundation.ERROR_INVALID_LDT_DESCRIPTOR -Windows.Win32.Foundation.ERROR_INVALID_LDT_OFFSET -Windows.Win32.Foundation.ERROR_INVALID_LDT_SIZE -Windows.Win32.Foundation.ERROR_INVALID_LEVEL -Windows.Win32.Foundation.ERROR_INVALID_LIST_FORMAT -Windows.Win32.Foundation.ERROR_INVALID_LOCK_RANGE -Windows.Win32.Foundation.ERROR_INVALID_LOGON_HOURS -Windows.Win32.Foundation.ERROR_INVALID_LOGON_TYPE -Windows.Win32.Foundation.ERROR_INVALID_MEMBER -Windows.Win32.Foundation.ERROR_INVALID_MENU_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_MESSAGE -Windows.Win32.Foundation.ERROR_INVALID_MESSAGEDEST -Windows.Win32.Foundation.ERROR_INVALID_MESSAGENAME -Windows.Win32.Foundation.ERROR_INVALID_MINALLOCSIZE -Windows.Win32.Foundation.ERROR_INVALID_MODULETYPE -Windows.Win32.Foundation.ERROR_INVALID_MONITOR_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_MSGBOX_STYLE -Windows.Win32.Foundation.ERROR_INVALID_NAME -Windows.Win32.Foundation.ERROR_INVALID_NETNAME -Windows.Win32.Foundation.ERROR_INVALID_OPLOCK_PROTOCOL -Windows.Win32.Foundation.ERROR_INVALID_ORDINAL -Windows.Win32.Foundation.ERROR_INVALID_OWNER -Windows.Win32.Foundation.ERROR_INVALID_PACKAGE_SID_LENGTH -Windows.Win32.Foundation.ERROR_INVALID_PARAMETER -Windows.Win32.Foundation.ERROR_INVALID_PASSWORD -Windows.Win32.Foundation.ERROR_INVALID_PASSWORDNAME -Windows.Win32.Foundation.ERROR_INVALID_PATCH_XML -Windows.Win32.Foundation.ERROR_INVALID_PEP_INFO_VERSION -Windows.Win32.Foundation.ERROR_INVALID_PLUGPLAY_DEVICE_PATH -Windows.Win32.Foundation.ERROR_INVALID_PORT_ATTRIBUTES -Windows.Win32.Foundation.ERROR_INVALID_PRIMARY_GROUP -Windows.Win32.Foundation.ERROR_INVALID_PRINTER_COMMAND -Windows.Win32.Foundation.ERROR_INVALID_PRINTER_NAME -Windows.Win32.Foundation.ERROR_INVALID_PRINTER_STATE -Windows.Win32.Foundation.ERROR_INVALID_PRIORITY -Windows.Win32.Foundation.ERROR_INVALID_QUOTA_LOWER -Windows.Win32.Foundation.ERROR_INVALID_REPARSE_DATA -Windows.Win32.Foundation.ERROR_INVALID_SCROLLBAR_RANGE -Windows.Win32.Foundation.ERROR_INVALID_SECURITY_DESCR -Windows.Win32.Foundation.ERROR_INVALID_SEGDPL -Windows.Win32.Foundation.ERROR_INVALID_SEGMENT_NUMBER -Windows.Win32.Foundation.ERROR_INVALID_SEPARATOR_FILE -Windows.Win32.Foundation.ERROR_INVALID_SERVER_STATE -Windows.Win32.Foundation.ERROR_INVALID_SERVICE_ACCOUNT -Windows.Win32.Foundation.ERROR_INVALID_SERVICE_CONTROL -Windows.Win32.Foundation.ERROR_INVALID_SERVICE_LOCK -Windows.Win32.Foundation.ERROR_INVALID_SERVICENAME -Windows.Win32.Foundation.ERROR_INVALID_SHARENAME -Windows.Win32.Foundation.ERROR_INVALID_SHOWWIN_COMMAND -Windows.Win32.Foundation.ERROR_INVALID_SID -Windows.Win32.Foundation.ERROR_INVALID_SIGNAL_NUMBER -Windows.Win32.Foundation.ERROR_INVALID_SPI_VALUE -Windows.Win32.Foundation.ERROR_INVALID_STACKSEG -Windows.Win32.Foundation.ERROR_INVALID_STARTING_CODESEG -Windows.Win32.Foundation.ERROR_INVALID_SUB_AUTHORITY -Windows.Win32.Foundation.ERROR_INVALID_TABLE -Windows.Win32.Foundation.ERROR_INVALID_TARGET_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_TASK_INDEX -Windows.Win32.Foundation.ERROR_INVALID_TASK_NAME -Windows.Win32.Foundation.ERROR_INVALID_THREAD_ID -Windows.Win32.Foundation.ERROR_INVALID_TIME -Windows.Win32.Foundation.ERROR_INVALID_TOKEN -Windows.Win32.Foundation.ERROR_INVALID_UNWIND_TARGET -Windows.Win32.Foundation.ERROR_INVALID_USER_BUFFER -Windows.Win32.Foundation.ERROR_INVALID_USER_PRINCIPAL_NAME -Windows.Win32.Foundation.ERROR_INVALID_VARIANT -Windows.Win32.Foundation.ERROR_INVALID_VERIFY_SWITCH -Windows.Win32.Foundation.ERROR_INVALID_WINDOW_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_WORKSTATION -Windows.Win32.Foundation.ERROR_IO_DEVICE -Windows.Win32.Foundation.ERROR_IO_INCOMPLETE -Windows.Win32.Foundation.ERROR_IO_PENDING -Windows.Win32.Foundation.ERROR_IO_PRIVILEGE_FAILED -Windows.Win32.Foundation.ERROR_IO_REISSUE_AS_CACHED -Windows.Win32.Foundation.ERROR_IOPL_NOT_ENABLED -Windows.Win32.Foundation.ERROR_IP_ADDRESS_CONFLICT1 -Windows.Win32.Foundation.ERROR_IP_ADDRESS_CONFLICT2 -Windows.Win32.Foundation.ERROR_IPSEC_IKE_TIMED_OUT -Windows.Win32.Foundation.ERROR_IRQ_BUSY -Windows.Win32.Foundation.ERROR_IS_JOIN_PATH -Windows.Win32.Foundation.ERROR_IS_JOIN_TARGET -Windows.Win32.Foundation.ERROR_IS_JOINED -Windows.Win32.Foundation.ERROR_IS_SUBST_PATH -Windows.Win32.Foundation.ERROR_IS_SUBST_TARGET -Windows.Win32.Foundation.ERROR_IS_SUBSTED -Windows.Win32.Foundation.ERROR_ITERATED_DATA_EXCEEDS_64k -Windows.Win32.Foundation.ERROR_JOB_NO_CONTAINER -Windows.Win32.Foundation.ERROR_JOIN_TO_JOIN -Windows.Win32.Foundation.ERROR_JOIN_TO_SUBST -Windows.Win32.Foundation.ERROR_JOURNAL_DELETE_IN_PROGRESS -Windows.Win32.Foundation.ERROR_JOURNAL_ENTRY_DELETED -Windows.Win32.Foundation.ERROR_JOURNAL_HOOK_SET -Windows.Win32.Foundation.ERROR_JOURNAL_NOT_ACTIVE -Windows.Win32.Foundation.ERROR_KERNEL_APC -Windows.Win32.Foundation.ERROR_KEY_DELETED -Windows.Win32.Foundation.ERROR_KEY_HAS_CHILDREN -Windows.Win32.Foundation.ERROR_KM_DRIVER_BLOCKED -Windows.Win32.Foundation.ERROR_LABEL_TOO_LONG -Windows.Win32.Foundation.ERROR_LAST_ADMIN -Windows.Win32.Foundation.ERROR_LB_WITHOUT_TABSTOPS -Windows.Win32.Foundation.ERROR_LICENSE_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_LINUX_SUBSYSTEM_NOT_PRESENT -Windows.Win32.Foundation.ERROR_LINUX_SUBSYSTEM_UPDATE_REQUIRED -Windows.Win32.Foundation.ERROR_LISTBOX_ID_NOT_FOUND -Windows.Win32.Foundation.ERROR_LM_CROSS_ENCRYPTION_REQUIRED -Windows.Win32.Foundation.ERROR_LOCAL_POLICY_MODIFICATION_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_LOCAL_USER_SESSION_KEY -Windows.Win32.Foundation.ERROR_LOCK_FAILED -Windows.Win32.Foundation.ERROR_LOCK_VIOLATION -Windows.Win32.Foundation.ERROR_LOCKED -Windows.Win32.Foundation.ERROR_LOG_FILE_FULL -Windows.Win32.Foundation.ERROR_LOG_HARD_ERROR -Windows.Win32.Foundation.ERROR_LOGIN_TIME_RESTRICTION -Windows.Win32.Foundation.ERROR_LOGIN_WKSTA_RESTRICTION -Windows.Win32.Foundation.ERROR_LOGON_FAILURE -Windows.Win32.Foundation.ERROR_LOGON_NOT_GRANTED -Windows.Win32.Foundation.ERROR_LOGON_SERVER_CONFLICT -Windows.Win32.Foundation.ERROR_LOGON_SESSION_COLLISION -Windows.Win32.Foundation.ERROR_LOGON_SESSION_EXISTS -Windows.Win32.Foundation.ERROR_LOGON_TYPE_NOT_GRANTED -Windows.Win32.Foundation.ERROR_LONGJUMP -Windows.Win32.Foundation.ERROR_LOST_MODE_LOGON_RESTRICTION -Windows.Win32.Foundation.ERROR_LOST_WRITEBEHIND_DATA -Windows.Win32.Foundation.ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR -Windows.Win32.Foundation.ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED -Windows.Win32.Foundation.ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR -Windows.Win32.Foundation.ERROR_LUIDS_EXHAUSTED -Windows.Win32.Foundation.ERROR_MACHINE_LOCKED -Windows.Win32.Foundation.ERROR_MAGAZINE_NOT_PRESENT -Windows.Win32.Foundation.ERROR_MAPPED_ALIGNMENT -Windows.Win32.Foundation.ERROR_MARKED_TO_DISALLOW_WRITES -Windows.Win32.Foundation.ERROR_MARSHALL_OVERFLOW -Windows.Win32.Foundation.ERROR_MAX_SESSIONS_REACHED -Windows.Win32.Foundation.ERROR_MAX_THRDS_REACHED -Windows.Win32.Foundation.ERROR_MCA_EXCEPTION -Windows.Win32.Foundation.ERROR_MCA_OCCURED -Windows.Win32.Foundation.ERROR_MEDIA_CHANGED -Windows.Win32.Foundation.ERROR_MEDIA_CHECK -Windows.Win32.Foundation.ERROR_MEMBER_IN_ALIAS -Windows.Win32.Foundation.ERROR_MEMBER_IN_GROUP -Windows.Win32.Foundation.ERROR_MEMBER_NOT_IN_ALIAS -Windows.Win32.Foundation.ERROR_MEMBER_NOT_IN_GROUP -Windows.Win32.Foundation.ERROR_MEMBERS_PRIMARY_GROUP -Windows.Win32.Foundation.ERROR_MEMORY_HARDWARE -Windows.Win32.Foundation.ERROR_MENU_ITEM_NOT_FOUND -Windows.Win32.Foundation.ERROR_MESSAGE_SYNC_ONLY -Windows.Win32.Foundation.ERROR_META_EXPANSION_TOO_LONG -Windows.Win32.Foundation.ERROR_MISSING_SYSTEMFILE -Windows.Win32.Foundation.ERROR_MOD_NOT_FOUND -Windows.Win32.Foundation.ERROR_MORE_DATA -Windows.Win32.Foundation.ERROR_MORE_WRITES -Windows.Win32.Foundation.ERROR_MOUNT_POINT_NOT_RESOLVED -Windows.Win32.Foundation.ERROR_MP_PROCESSOR_MISMATCH -Windows.Win32.Foundation.ERROR_MR_MID_NOT_FOUND -Windows.Win32.Foundation.ERROR_MULTIPLE_FAULT_VIOLATION -Windows.Win32.Foundation.ERROR_MUTANT_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_MUTUAL_AUTH_FAILED -Windows.Win32.Foundation.ERROR_NEGATIVE_SEEK -Windows.Win32.Foundation.ERROR_NESTING_NOT_ALLOWED -Windows.Win32.Foundation.ERROR_NET_OPEN_FAILED -Windows.Win32.Foundation.ERROR_NET_WRITE_FAULT -Windows.Win32.Foundation.ERROR_NETLOGON_NOT_STARTED -Windows.Win32.Foundation.ERROR_NETNAME_DELETED -Windows.Win32.Foundation.ERROR_NETWORK_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_NETWORK_ACCESS_DENIED_EDP -Windows.Win32.Foundation.ERROR_NETWORK_BUSY -Windows.Win32.Foundation.ERROR_NETWORK_UNREACHABLE -Windows.Win32.Foundation.ERROR_NO_ACE_CONDITION -Windows.Win32.Foundation.ERROR_NO_ASSOCIATION -Windows.Win32.Foundation.ERROR_NO_BYPASSIO_DRIVER_SUPPORT -Windows.Win32.Foundation.ERROR_NO_CALLBACK_ACTIVE -Windows.Win32.Foundation.ERROR_NO_DATA -Windows.Win32.Foundation.ERROR_NO_DATA_DETECTED -Windows.Win32.Foundation.ERROR_NO_EFS -Windows.Win32.Foundation.ERROR_NO_EVENT_PAIR -Windows.Win32.Foundation.ERROR_NO_GUID_TRANSLATION -Windows.Win32.Foundation.ERROR_NO_IMPERSONATION_TOKEN -Windows.Win32.Foundation.ERROR_NO_INHERITANCE -Windows.Win32.Foundation.ERROR_NO_LOG_SPACE -Windows.Win32.Foundation.ERROR_NO_LOGON_SERVERS -Windows.Win32.Foundation.ERROR_NO_MATCH -Windows.Win32.Foundation.ERROR_NO_MEDIA_IN_DRIVE -Windows.Win32.Foundation.ERROR_NO_MORE_DEVICES -Windows.Win32.Foundation.ERROR_NO_MORE_FILES -Windows.Win32.Foundation.ERROR_NO_MORE_ITEMS -Windows.Win32.Foundation.ERROR_NO_MORE_MATCHES -Windows.Win32.Foundation.ERROR_NO_MORE_SEARCH_HANDLES -Windows.Win32.Foundation.ERROR_NO_MORE_USER_HANDLES -Windows.Win32.Foundation.ERROR_NO_NET_OR_BAD_PATH -Windows.Win32.Foundation.ERROR_NO_NETWORK -Windows.Win32.Foundation.ERROR_NO_NVRAM_RESOURCES -Windows.Win32.Foundation.ERROR_NO_PAGEFILE -Windows.Win32.Foundation.ERROR_NO_PHYSICALLY_ALIGNED_FREE_SPACE_FOUND -Windows.Win32.Foundation.ERROR_NO_PROC_SLOTS -Windows.Win32.Foundation.ERROR_NO_PROMOTION_ACTIVE -Windows.Win32.Foundation.ERROR_NO_QUOTAS_FOR_ACCOUNT -Windows.Win32.Foundation.ERROR_NO_RANGES_PROCESSED -Windows.Win32.Foundation.ERROR_NO_RECOVERY_POLICY -Windows.Win32.Foundation.ERROR_NO_RECOVERY_PROGRAM -Windows.Win32.Foundation.ERROR_NO_SCROLLBARS -Windows.Win32.Foundation.ERROR_NO_SECRETS -Windows.Win32.Foundation.ERROR_NO_SECURITY_ON_OBJECT -Windows.Win32.Foundation.ERROR_NO_SHUTDOWN_IN_PROGRESS -Windows.Win32.Foundation.ERROR_NO_SIGNAL_SENT -Windows.Win32.Foundation.ERROR_NO_SITE_SETTINGS_OBJECT -Windows.Win32.Foundation.ERROR_NO_SITENAME -Windows.Win32.Foundation.ERROR_NO_SPOOL_SPACE -Windows.Win32.Foundation.ERROR_NO_SUCH_ALIAS -Windows.Win32.Foundation.ERROR_NO_SUCH_DEVICE -Windows.Win32.Foundation.ERROR_NO_SUCH_DOMAIN -Windows.Win32.Foundation.ERROR_NO_SUCH_GROUP -Windows.Win32.Foundation.ERROR_NO_SUCH_LOGON_SESSION -Windows.Win32.Foundation.ERROR_NO_SUCH_MEMBER -Windows.Win32.Foundation.ERROR_NO_SUCH_PACKAGE -Windows.Win32.Foundation.ERROR_NO_SUCH_PRIVILEGE -Windows.Win32.Foundation.ERROR_NO_SUCH_SITE -Windows.Win32.Foundation.ERROR_NO_SUCH_USER -Windows.Win32.Foundation.ERROR_NO_SYSTEM_MENU -Windows.Win32.Foundation.ERROR_NO_SYSTEM_RESOURCES -Windows.Win32.Foundation.ERROR_NO_TASK_QUEUE -Windows.Win32.Foundation.ERROR_NO_TOKEN -Windows.Win32.Foundation.ERROR_NO_TRACKING_SERVICE -Windows.Win32.Foundation.ERROR_NO_TRUST_LSA_SECRET -Windows.Win32.Foundation.ERROR_NO_TRUST_SAM_ACCOUNT -Windows.Win32.Foundation.ERROR_NO_UNICODE_TRANSLATION -Windows.Win32.Foundation.ERROR_NO_USER_KEYS -Windows.Win32.Foundation.ERROR_NO_USER_SESSION_KEY -Windows.Win32.Foundation.ERROR_NO_VOLUME_ID -Windows.Win32.Foundation.ERROR_NO_VOLUME_LABEL -Windows.Win32.Foundation.ERROR_NO_WILDCARD_CHARACTERS -Windows.Win32.Foundation.ERROR_NO_WORK_DONE -Windows.Win32.Foundation.ERROR_NO_WRITABLE_DC_FOUND -Windows.Win32.Foundation.ERROR_NO_YIELD_PERFORMED -Windows.Win32.Foundation.ERROR_NOACCESS -Windows.Win32.Foundation.ERROR_NOINTERFACE -Windows.Win32.Foundation.ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT -Windows.Win32.Foundation.ERROR_NOLOGON_SERVER_TRUST_ACCOUNT -Windows.Win32.Foundation.ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT -Windows.Win32.Foundation.ERROR_NON_ACCOUNT_SID -Windows.Win32.Foundation.ERROR_NON_DOMAIN_SID -Windows.Win32.Foundation.ERROR_NON_MDICHILD_WINDOW -Windows.Win32.Foundation.ERROR_NONE_MAPPED -Windows.Win32.Foundation.ERROR_NONPAGED_SYSTEM_RESOURCES -Windows.Win32.Foundation.ERROR_NOT_A_CLOUD_FILE -Windows.Win32.Foundation.ERROR_NOT_A_CLOUD_SYNC_ROOT -Windows.Win32.Foundation.ERROR_NOT_A_DAX_VOLUME -Windows.Win32.Foundation.ERROR_NOT_A_REPARSE_POINT -Windows.Win32.Foundation.ERROR_NOT_ALL_ASSIGNED -Windows.Win32.Foundation.ERROR_NOT_ALLOWED_ON_SYSTEM_FILE -Windows.Win32.Foundation.ERROR_NOT_APPCONTAINER -Windows.Win32.Foundation.ERROR_NOT_AUTHENTICATED -Windows.Win32.Foundation.ERROR_NOT_CAPABLE -Windows.Win32.Foundation.ERROR_NOT_CHILD_WINDOW -Windows.Win32.Foundation.ERROR_NOT_CONNECTED -Windows.Win32.Foundation.ERROR_NOT_CONTAINER -Windows.Win32.Foundation.ERROR_NOT_DAX_MAPPABLE -Windows.Win32.Foundation.ERROR_NOT_DOS_DISK -Windows.Win32.Foundation.ERROR_NOT_ENOUGH_MEMORY -Windows.Win32.Foundation.ERROR_NOT_ENOUGH_QUOTA -Windows.Win32.Foundation.ERROR_NOT_ENOUGH_SERVER_MEMORY -Windows.Win32.Foundation.ERROR_NOT_EXPORT_FORMAT -Windows.Win32.Foundation.ERROR_NOT_FOUND -Windows.Win32.Foundation.ERROR_NOT_GUI_PROCESS -Windows.Win32.Foundation.ERROR_NOT_JOINED -Windows.Win32.Foundation.ERROR_NOT_LOCKED -Windows.Win32.Foundation.ERROR_NOT_LOGGED_ON -Windows.Win32.Foundation.ERROR_NOT_LOGON_PROCESS -Windows.Win32.Foundation.ERROR_NOT_OWNER -Windows.Win32.Foundation.ERROR_NOT_READ_FROM_COPY -Windows.Win32.Foundation.ERROR_NOT_READY -Windows.Win32.Foundation.ERROR_NOT_REDUNDANT_STORAGE -Windows.Win32.Foundation.ERROR_NOT_REGISTRY_FILE -Windows.Win32.Foundation.ERROR_NOT_SAFE_MODE_DRIVER -Windows.Win32.Foundation.ERROR_NOT_SAFEBOOT_SERVICE -Windows.Win32.Foundation.ERROR_NOT_SAME_DEVICE -Windows.Win32.Foundation.ERROR_NOT_SAME_OBJECT -Windows.Win32.Foundation.ERROR_NOT_SUBSTED -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_IN_APPCONTAINER -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_ON_DAX -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_ON_SBS -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_AUDITING -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_BTT -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_BYPASSIO -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_CACHED_HANDLE -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_COMPRESSION -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_DEDUPLICATION -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_ENCRYPTION -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_MONITORING -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_REPLICATION -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_SNAPSHOT -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_VIRTUALIZATION -Windows.Win32.Foundation.ERROR_NOT_TINY_STREAM -Windows.Win32.Foundation.ERROR_NOTHING_TO_TERMINATE -Windows.Win32.Foundation.ERROR_NOTIFICATION_GUID_ALREADY_DEFINED -Windows.Win32.Foundation.ERROR_NOTIFY_CLEANUP -Windows.Win32.Foundation.ERROR_NOTIFY_ENUM_DIR -Windows.Win32.Foundation.ERROR_NT_CROSS_ENCRYPTION_REQUIRED -Windows.Win32.Foundation.ERROR_NTLM_BLOCKED -Windows.Win32.Foundation.ERROR_NULL_LM_PASSWORD -Windows.Win32.Foundation.ERROR_OBJECT_IS_IMMUTABLE -Windows.Win32.Foundation.ERROR_OBJECT_NAME_EXISTS -Windows.Win32.Foundation.ERROR_OBJECT_NOT_EXTERNALLY_BACKED -Windows.Win32.Foundation.ERROR_OFFLOAD_READ_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_OFFLOAD_READ_FLT_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_OFFLOAD_WRITE_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_OFFLOAD_WRITE_FLT_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_OFFSET_ALIGNMENT_VIOLATION -Windows.Win32.Foundation.ERROR_OLD_WIN_VERSION -Windows.Win32.Foundation.ERROR_ONLY_IF_CONNECTED -Windows.Win32.Foundation.ERROR_OPEN_FAILED -Windows.Win32.Foundation.ERROR_OPEN_FILES -Windows.Win32.Foundation.ERROR_OPERATION_ABORTED -Windows.Win32.Foundation.ERROR_OPERATION_IN_PROGRESS -Windows.Win32.Foundation.ERROR_OPLOCK_BREAK_IN_PROGRESS -Windows.Win32.Foundation.ERROR_OPLOCK_HANDLE_CLOSED -Windows.Win32.Foundation.ERROR_OPLOCK_NOT_GRANTED -Windows.Win32.Foundation.ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE -Windows.Win32.Foundation.ERROR_ORPHAN_NAME_EXHAUSTED -Windows.Win32.Foundation.ERROR_OUT_OF_PAPER -Windows.Win32.Foundation.ERROR_OUT_OF_STRUCTURES -Windows.Win32.Foundation.ERROR_OUTOFMEMORY -Windows.Win32.Foundation.ERROR_OVERRIDE_NOCHANGES -Windows.Win32.Foundation.ERROR_PAGE_FAULT_COPY_ON_WRITE -Windows.Win32.Foundation.ERROR_PAGE_FAULT_DEMAND_ZERO -Windows.Win32.Foundation.ERROR_PAGE_FAULT_GUARD_PAGE -Windows.Win32.Foundation.ERROR_PAGE_FAULT_PAGING_FILE -Windows.Win32.Foundation.ERROR_PAGE_FAULT_TRANSITION -Windows.Win32.Foundation.ERROR_PAGED_SYSTEM_RESOURCES -Windows.Win32.Foundation.ERROR_PAGEFILE_CREATE_FAILED -Windows.Win32.Foundation.ERROR_PAGEFILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_PAGEFILE_QUOTA -Windows.Win32.Foundation.ERROR_PAGEFILE_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_PARAMETER_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_PARTIAL_COPY -Windows.Win32.Foundation.ERROR_PARTITION_FAILURE -Windows.Win32.Foundation.ERROR_PARTITION_TERMINATING -Windows.Win32.Foundation.ERROR_PASSWORD_CHANGE_REQUIRED -Windows.Win32.Foundation.ERROR_PASSWORD_EXPIRED -Windows.Win32.Foundation.ERROR_PASSWORD_MUST_CHANGE -Windows.Win32.Foundation.ERROR_PASSWORD_RESTRICTION -Windows.Win32.Foundation.ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT -Windows.Win32.Foundation.ERROR_PATCH_NO_SEQUENCE -Windows.Win32.Foundation.ERROR_PATCH_PACKAGE_INVALID -Windows.Win32.Foundation.ERROR_PATCH_PACKAGE_OPEN_FAILED -Windows.Win32.Foundation.ERROR_PATCH_PACKAGE_REJECTED -Windows.Win32.Foundation.ERROR_PATCH_PACKAGE_UNSUPPORTED -Windows.Win32.Foundation.ERROR_PATCH_REMOVAL_DISALLOWED -Windows.Win32.Foundation.ERROR_PATCH_REMOVAL_UNSUPPORTED -Windows.Win32.Foundation.ERROR_PATCH_TARGET_NOT_FOUND -Windows.Win32.Foundation.ERROR_PATH_BUSY -Windows.Win32.Foundation.ERROR_PATH_NOT_FOUND -Windows.Win32.Foundation.ERROR_PER_USER_TRUST_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_PIPE_BUSY -Windows.Win32.Foundation.ERROR_PIPE_CONNECTED -Windows.Win32.Foundation.ERROR_PIPE_LISTENING -Windows.Win32.Foundation.ERROR_PIPE_LOCAL -Windows.Win32.Foundation.ERROR_PIPE_NOT_CONNECTED -Windows.Win32.Foundation.ERROR_PKINIT_FAILURE -Windows.Win32.Foundation.ERROR_PLUGPLAY_QUERY_VETOED -Windows.Win32.Foundation.ERROR_PNP_BAD_MPS_TABLE -Windows.Win32.Foundation.ERROR_PNP_INVALID_ID -Windows.Win32.Foundation.ERROR_PNP_IRQ_TRANSLATION_FAILED -Windows.Win32.Foundation.ERROR_PNP_QUERY_REMOVE_DEVICE_TIMEOUT -Windows.Win32.Foundation.ERROR_PNP_QUERY_REMOVE_RELATED_DEVICE_TIMEOUT -Windows.Win32.Foundation.ERROR_PNP_QUERY_REMOVE_UNRELATED_DEVICE_TIMEOUT -Windows.Win32.Foundation.ERROR_PNP_REBOOT_REQUIRED -Windows.Win32.Foundation.ERROR_PNP_RESTART_ENUMERATION -Windows.Win32.Foundation.ERROR_PNP_TRANSLATION_FAILED -Windows.Win32.Foundation.ERROR_POINT_NOT_FOUND -Windows.Win32.Foundation.ERROR_POLICY_OBJECT_NOT_FOUND -Windows.Win32.Foundation.ERROR_POLICY_ONLY_IN_DS -Windows.Win32.Foundation.ERROR_POPUP_ALREADY_ACTIVE -Windows.Win32.Foundation.ERROR_PORT_MESSAGE_TOO_LONG -Windows.Win32.Foundation.ERROR_PORT_NOT_SET -Windows.Win32.Foundation.ERROR_PORT_UNREACHABLE -Windows.Win32.Foundation.ERROR_POSSIBLE_DEADLOCK -Windows.Win32.Foundation.ERROR_POTENTIAL_FILE_FOUND -Windows.Win32.Foundation.ERROR_PREDEFINED_HANDLE -Windows.Win32.Foundation.ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED -Windows.Win32.Foundation.ERROR_PRINT_CANCELLED -Windows.Win32.Foundation.ERROR_PRINTER_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_PRINTER_DELETED -Windows.Win32.Foundation.ERROR_PRINTER_DRIVER_ALREADY_INSTALLED -Windows.Win32.Foundation.ERROR_PRINTQ_FULL -Windows.Win32.Foundation.ERROR_PRIVATE_DIALOG_INDEX -Windows.Win32.Foundation.ERROR_PRIVILEGE_NOT_HELD -Windows.Win32.Foundation.ERROR_PROC_NOT_FOUND -Windows.Win32.Foundation.ERROR_PROCESS_ABORTED -Windows.Win32.Foundation.ERROR_PROCESS_IN_JOB -Windows.Win32.Foundation.ERROR_PROCESS_IS_PROTECTED -Windows.Win32.Foundation.ERROR_PROCESS_MODE_ALREADY_BACKGROUND -Windows.Win32.Foundation.ERROR_PROCESS_MODE_NOT_BACKGROUND -Windows.Win32.Foundation.ERROR_PROCESS_NOT_IN_JOB -Windows.Win32.Foundation.ERROR_PRODUCT_UNINSTALLED -Windows.Win32.Foundation.ERROR_PRODUCT_VERSION -Windows.Win32.Foundation.ERROR_PROFILING_AT_LIMIT -Windows.Win32.Foundation.ERROR_PROFILING_NOT_STARTED -Windows.Win32.Foundation.ERROR_PROFILING_NOT_STOPPED -Windows.Win32.Foundation.ERROR_PROMOTION_ACTIVE -Windows.Win32.Foundation.ERROR_PROTOCOL_UNREACHABLE -Windows.Win32.Foundation.ERROR_PWD_HISTORY_CONFLICT -Windows.Win32.Foundation.ERROR_PWD_TOO_LONG -Windows.Win32.Foundation.ERROR_PWD_TOO_RECENT -Windows.Win32.Foundation.ERROR_PWD_TOO_SHORT -Windows.Win32.Foundation.ERROR_QUOTA_ACTIVITY -Windows.Win32.Foundation.ERROR_QUOTA_LIST_INCONSISTENT -Windows.Win32.Foundation.ERROR_RANGE_LIST_CONFLICT -Windows.Win32.Foundation.ERROR_RANGE_NOT_FOUND -Windows.Win32.Foundation.ERROR_READ_FAULT -Windows.Win32.Foundation.ERROR_RECEIVE_EXPEDITED -Windows.Win32.Foundation.ERROR_RECEIVE_PARTIAL -Windows.Win32.Foundation.ERROR_RECEIVE_PARTIAL_EXPEDITED -Windows.Win32.Foundation.ERROR_RECOVERY_FAILURE -Windows.Win32.Foundation.ERROR_REDIR_PAUSED -Windows.Win32.Foundation.ERROR_REDIRECTOR_HAS_OPEN_HANDLES -Windows.Win32.Foundation.ERROR_REG_NAT_CONSUMPTION -Windows.Win32.Foundation.ERROR_REGISTRY_CORRUPT -Windows.Win32.Foundation.ERROR_REGISTRY_HIVE_RECOVERED -Windows.Win32.Foundation.ERROR_REGISTRY_IO_FAILED -Windows.Win32.Foundation.ERROR_REGISTRY_QUOTA_LIMIT -Windows.Win32.Foundation.ERROR_REGISTRY_RECOVERED -Windows.Win32.Foundation.ERROR_RELOC_CHAIN_XEEDS_SEGLIM -Windows.Win32.Foundation.ERROR_REM_NOT_LIST -Windows.Win32.Foundation.ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED -Windows.Win32.Foundation.ERROR_REMOTE_SESSION_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_REMOTE_STORAGE_MEDIA_ERROR -Windows.Win32.Foundation.ERROR_REMOTE_STORAGE_NOT_ACTIVE -Windows.Win32.Foundation.ERROR_REPARSE -Windows.Win32.Foundation.ERROR_REPARSE_ATTRIBUTE_CONFLICT -Windows.Win32.Foundation.ERROR_REPARSE_OBJECT -Windows.Win32.Foundation.ERROR_REPARSE_POINT_ENCOUNTERED -Windows.Win32.Foundation.ERROR_REPARSE_TAG_INVALID -Windows.Win32.Foundation.ERROR_REPARSE_TAG_MISMATCH -Windows.Win32.Foundation.ERROR_REPLY_MESSAGE_MISMATCH -Windows.Win32.Foundation.ERROR_REQ_NOT_ACCEP -Windows.Win32.Foundation.ERROR_REQUEST_ABORTED -Windows.Win32.Foundation.ERROR_REQUEST_OUT_OF_SEQUENCE -Windows.Win32.Foundation.ERROR_REQUEST_PAUSED -Windows.Win32.Foundation.ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION -Windows.Win32.Foundation.ERROR_RESIDENT_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_RESOURCE_CALL_TIMED_OUT -Windows.Win32.Foundation.ERROR_RESOURCE_DATA_NOT_FOUND -Windows.Win32.Foundation.ERROR_RESOURCE_LANG_NOT_FOUND -Windows.Win32.Foundation.ERROR_RESOURCE_NAME_NOT_FOUND -Windows.Win32.Foundation.ERROR_RESOURCE_REQUIREMENTS_CHANGED -Windows.Win32.Foundation.ERROR_RESOURCE_TYPE_NOT_FOUND -Windows.Win32.Foundation.ERROR_RESTART_APPLICATION -Windows.Win32.Foundation.ERROR_RESUME_HIBERNATION -Windows.Win32.Foundation.ERROR_RETRY -Windows.Win32.Foundation.ERROR_RETURN_ADDRESS_HIJACK_ATTEMPT -Windows.Win32.Foundation.ERROR_REVISION_MISMATCH -Windows.Win32.Foundation.ERROR_RING2_STACK_IN_USE -Windows.Win32.Foundation.ERROR_RING2SEG_MUST_BE_MOVABLE -Windows.Win32.Foundation.ERROR_RMODE_APP -Windows.Win32.Foundation.ERROR_ROWSNOTRELEASED -Windows.Win32.Foundation.ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT -Windows.Win32.Foundation.ERROR_RUNLEVEL_SWITCH_TIMEOUT -Windows.Win32.Foundation.ERROR_RWRAW_ENCRYPTED_FILE_NOT_ENCRYPTED -Windows.Win32.Foundation.ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILEOFFSET -Windows.Win32.Foundation.ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILERANGE -Windows.Win32.Foundation.ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_PARAMETER -Windows.Win32.Foundation.ERROR_RXACT_COMMIT_FAILURE -Windows.Win32.Foundation.ERROR_RXACT_COMMIT_NECESSARY -Windows.Win32.Foundation.ERROR_RXACT_COMMITTED -Windows.Win32.Foundation.ERROR_RXACT_INVALID_STATE -Windows.Win32.Foundation.ERROR_RXACT_STATE_CREATED -Windows.Win32.Foundation.ERROR_SAM_INIT_FAILURE -Windows.Win32.Foundation.ERROR_SAME_DRIVE -Windows.Win32.Foundation.ERROR_SCOPE_NOT_FOUND -Windows.Win32.Foundation.ERROR_SCREEN_ALREADY_LOCKED -Windows.Win32.Foundation.ERROR_SCRUB_DATA_DISABLED -Windows.Win32.Foundation.ERROR_SECRET_TOO_LONG -Windows.Win32.Foundation.ERROR_SECTION_DIRECT_MAP_ONLY -Windows.Win32.Foundation.ERROR_SECTOR_NOT_FOUND -Windows.Win32.Foundation.ERROR_SECURITY_DENIES_OPERATION -Windows.Win32.Foundation.ERROR_SECURITY_STREAM_IS_INCONSISTENT -Windows.Win32.Foundation.ERROR_SEEK -Windows.Win32.Foundation.ERROR_SEEK_ON_DEVICE -Windows.Win32.Foundation.ERROR_SEGMENT_NOTIFICATION -Windows.Win32.Foundation.ERROR_SEM_IS_SET -Windows.Win32.Foundation.ERROR_SEM_NOT_FOUND -Windows.Win32.Foundation.ERROR_SEM_OWNER_DIED -Windows.Win32.Foundation.ERROR_SEM_TIMEOUT -Windows.Win32.Foundation.ERROR_SEM_USER_LIMIT -Windows.Win32.Foundation.ERROR_SERIAL_NO_DEVICE -Windows.Win32.Foundation.ERROR_SERVER_DISABLED -Windows.Win32.Foundation.ERROR_SERVER_HAS_OPEN_HANDLES -Windows.Win32.Foundation.ERROR_SERVER_NOT_DISABLED -Windows.Win32.Foundation.ERROR_SERVER_SHUTDOWN_IN_PROGRESS -Windows.Win32.Foundation.ERROR_SERVER_SID_MISMATCH -Windows.Win32.Foundation.ERROR_SERVER_TRANSPORT_CONFLICT -Windows.Win32.Foundation.ERROR_SERVICE_ALREADY_RUNNING -Windows.Win32.Foundation.ERROR_SERVICE_CANNOT_ACCEPT_CTRL -Windows.Win32.Foundation.ERROR_SERVICE_DATABASE_LOCKED -Windows.Win32.Foundation.ERROR_SERVICE_DEPENDENCY_DELETED -Windows.Win32.Foundation.ERROR_SERVICE_DEPENDENCY_FAIL -Windows.Win32.Foundation.ERROR_SERVICE_DISABLED -Windows.Win32.Foundation.ERROR_SERVICE_DOES_NOT_EXIST -Windows.Win32.Foundation.ERROR_SERVICE_EXISTS -Windows.Win32.Foundation.ERROR_SERVICE_LOGON_FAILED -Windows.Win32.Foundation.ERROR_SERVICE_MARKED_FOR_DELETE -Windows.Win32.Foundation.ERROR_SERVICE_NEVER_STARTED -Windows.Win32.Foundation.ERROR_SERVICE_NO_THREAD -Windows.Win32.Foundation.ERROR_SERVICE_NOT_ACTIVE -Windows.Win32.Foundation.ERROR_SERVICE_NOT_FOUND -Windows.Win32.Foundation.ERROR_SERVICE_NOT_IN_EXE -Windows.Win32.Foundation.ERROR_SERVICE_NOTIFICATION -Windows.Win32.Foundation.ERROR_SERVICE_NOTIFY_CLIENT_LAGGING -Windows.Win32.Foundation.ERROR_SERVICE_REQUEST_TIMEOUT -Windows.Win32.Foundation.ERROR_SERVICE_SPECIFIC_ERROR -Windows.Win32.Foundation.ERROR_SERVICE_START_HANG -Windows.Win32.Foundation.ERROR_SESSION_CREDENTIAL_CONFLICT -Windows.Win32.Foundation.ERROR_SESSION_KEY_TOO_SHORT -Windows.Win32.Foundation.ERROR_SET_CONTEXT_DENIED -Windows.Win32.Foundation.ERROR_SET_NOT_FOUND -Windows.Win32.Foundation.ERROR_SET_POWER_STATE_FAILED -Windows.Win32.Foundation.ERROR_SET_POWER_STATE_VETOED -Windows.Win32.Foundation.ERROR_SETCOUNT_ON_BAD_LB -Windows.Win32.Foundation.ERROR_SETMARK_DETECTED -Windows.Win32.Foundation.ERROR_SHARED_POLICY -Windows.Win32.Foundation.ERROR_SHARING_BUFFER_EXCEEDED -Windows.Win32.Foundation.ERROR_SHARING_PAUSED -Windows.Win32.Foundation.ERROR_SHARING_VIOLATION -Windows.Win32.Foundation.ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME -Windows.Win32.Foundation.ERROR_SHUTDOWN_DISKS_NOT_IN_MAINTENANCE_MODE -Windows.Win32.Foundation.ERROR_SHUTDOWN_IN_PROGRESS -Windows.Win32.Foundation.ERROR_SHUTDOWN_IS_SCHEDULED -Windows.Win32.Foundation.ERROR_SHUTDOWN_USERS_LOGGED_ON -Windows.Win32.Foundation.ERROR_SIGNAL_PENDING -Windows.Win32.Foundation.ERROR_SIGNAL_REFUSED -Windows.Win32.Foundation.ERROR_SINGLE_INSTANCE_APP -Windows.Win32.Foundation.ERROR_SMARTCARD_SUBSYSTEM_FAILURE -Windows.Win32.Foundation.ERROR_SMB1_NOT_AVAILABLE -Windows.Win32.Foundation.ERROR_SMB_GUEST_LOGON_BLOCKED -Windows.Win32.Foundation.ERROR_SMR_GARBAGE_COLLECTION_REQUIRED -Windows.Win32.Foundation.ERROR_SOME_NOT_MAPPED -Windows.Win32.Foundation.ERROR_SOURCE_ELEMENT_EMPTY -Windows.Win32.Foundation.ERROR_SPARSE_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_SPECIAL_ACCOUNT -Windows.Win32.Foundation.ERROR_SPECIAL_GROUP -Windows.Win32.Foundation.ERROR_SPECIAL_USER -Windows.Win32.Foundation.ERROR_SRC_SRV_DLL_LOAD_FAILED -Windows.Win32.Foundation.ERROR_STACK_BUFFER_OVERRUN -Windows.Win32.Foundation.ERROR_STACK_OVERFLOW -Windows.Win32.Foundation.ERROR_STACK_OVERFLOW_READ -Windows.Win32.Foundation.ERROR_STOPPED_ON_SYMLINK -Windows.Win32.Foundation.ERROR_STORAGE_LOST_DATA_PERSISTENCE -Windows.Win32.Foundation.ERROR_STORAGE_RESERVE_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_STORAGE_RESERVE_DOES_NOT_EXIST -Windows.Win32.Foundation.ERROR_STORAGE_RESERVE_ID_INVALID -Windows.Win32.Foundation.ERROR_STORAGE_RESERVE_NOT_EMPTY -Windows.Win32.Foundation.ERROR_STORAGE_STACK_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_STORAGE_TOPOLOGY_ID_MISMATCH -Windows.Win32.Foundation.ERROR_STRICT_CFG_VIOLATION -Windows.Win32.Foundation.ERROR_SUBST_TO_JOIN -Windows.Win32.Foundation.ERROR_SUBST_TO_SUBST -Windows.Win32.Foundation.ERROR_SUCCESS -Windows.Win32.Foundation.ERROR_SUCCESS_REBOOT_INITIATED -Windows.Win32.Foundation.ERROR_SWAPERROR -Windows.Win32.Foundation.ERROR_SYMLINK_CLASS_DISABLED -Windows.Win32.Foundation.ERROR_SYMLINK_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED -Windows.Win32.Foundation.ERROR_SYNCHRONIZATION_REQUIRED -Windows.Win32.Foundation.ERROR_SYSTEM_HIVE_TOO_LARGE -Windows.Win32.Foundation.ERROR_SYSTEM_IMAGE_BAD_SIGNATURE -Windows.Win32.Foundation.ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION -Windows.Win32.Foundation.ERROR_SYSTEM_POWERSTATE_TRANSITION -Windows.Win32.Foundation.ERROR_SYSTEM_PROCESS_TERMINATED -Windows.Win32.Foundation.ERROR_SYSTEM_SHUTDOWN -Windows.Win32.Foundation.ERROR_SYSTEM_TRACE -Windows.Win32.Foundation.ERROR_THREAD_1_INACTIVE -Windows.Win32.Foundation.ERROR_THREAD_ALREADY_IN_TASK -Windows.Win32.Foundation.ERROR_THREAD_MODE_ALREADY_BACKGROUND -Windows.Win32.Foundation.ERROR_THREAD_MODE_NOT_BACKGROUND -Windows.Win32.Foundation.ERROR_THREAD_NOT_IN_PROCESS -Windows.Win32.Foundation.ERROR_THREAD_WAS_SUSPENDED -Windows.Win32.Foundation.ERROR_TIME_SENSITIVE_THREAD -Windows.Win32.Foundation.ERROR_TIME_SKEW -Windows.Win32.Foundation.ERROR_TIMEOUT -Windows.Win32.Foundation.ERROR_TIMER_NOT_CANCELED -Windows.Win32.Foundation.ERROR_TIMER_RESOLUTION_NOT_SET -Windows.Win32.Foundation.ERROR_TIMER_RESUME_IGNORED -Windows.Win32.Foundation.ERROR_TLW_WITH_WSCHILD -Windows.Win32.Foundation.ERROR_TOKEN_ALREADY_IN_USE -Windows.Win32.Foundation.ERROR_TOO_MANY_CMDS -Windows.Win32.Foundation.ERROR_TOO_MANY_CONTEXT_IDS -Windows.Win32.Foundation.ERROR_TOO_MANY_DESCRIPTORS -Windows.Win32.Foundation.ERROR_TOO_MANY_LINKS -Windows.Win32.Foundation.ERROR_TOO_MANY_LUIDS_REQUESTED -Windows.Win32.Foundation.ERROR_TOO_MANY_MODULES -Windows.Win32.Foundation.ERROR_TOO_MANY_MUXWAITERS -Windows.Win32.Foundation.ERROR_TOO_MANY_NAMES -Windows.Win32.Foundation.ERROR_TOO_MANY_OPEN_FILES -Windows.Win32.Foundation.ERROR_TOO_MANY_POSTS -Windows.Win32.Foundation.ERROR_TOO_MANY_SECRETS -Windows.Win32.Foundation.ERROR_TOO_MANY_SEM_REQUESTS -Windows.Win32.Foundation.ERROR_TOO_MANY_SEMAPHORES -Windows.Win32.Foundation.ERROR_TOO_MANY_SESS -Windows.Win32.Foundation.ERROR_TOO_MANY_SIDS -Windows.Win32.Foundation.ERROR_TOO_MANY_TCBS -Windows.Win32.Foundation.ERROR_TOO_MANY_THREADS -Windows.Win32.Foundation.ERROR_TRANSLATION_COMPLETE -Windows.Win32.Foundation.ERROR_TRUST_FAILURE -Windows.Win32.Foundation.ERROR_TRUSTED_DOMAIN_FAILURE -Windows.Win32.Foundation.ERROR_TRUSTED_RELATIONSHIP_FAILURE -Windows.Win32.Foundation.ERROR_UNABLE_TO_LOCK_MEDIA -Windows.Win32.Foundation.ERROR_UNABLE_TO_MOVE_REPLACEMENT -Windows.Win32.Foundation.ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 -Windows.Win32.Foundation.ERROR_UNABLE_TO_REMOVE_REPLACED -Windows.Win32.Foundation.ERROR_UNABLE_TO_UNLOAD_MEDIA -Windows.Win32.Foundation.ERROR_UNDEFINED_CHARACTER -Windows.Win32.Foundation.ERROR_UNDEFINED_SCOPE -Windows.Win32.Foundation.ERROR_UNEXP_NET_ERR -Windows.Win32.Foundation.ERROR_UNEXPECTED_MM_CREATE_ERR -Windows.Win32.Foundation.ERROR_UNEXPECTED_MM_EXTEND_ERR -Windows.Win32.Foundation.ERROR_UNEXPECTED_MM_MAP_ERROR -Windows.Win32.Foundation.ERROR_UNEXPECTED_NTCACHEMANAGER_ERROR -Windows.Win32.Foundation.ERROR_UNHANDLED_EXCEPTION -Windows.Win32.Foundation.ERROR_UNIDENTIFIED_ERROR -Windows.Win32.Foundation.ERROR_UNKNOWN_COMPONENT -Windows.Win32.Foundation.ERROR_UNKNOWN_FEATURE -Windows.Win32.Foundation.ERROR_UNKNOWN_PATCH -Windows.Win32.Foundation.ERROR_UNKNOWN_PORT -Windows.Win32.Foundation.ERROR_UNKNOWN_PRINTER_DRIVER -Windows.Win32.Foundation.ERROR_UNKNOWN_PRINTPROCESSOR -Windows.Win32.Foundation.ERROR_UNKNOWN_PRODUCT -Windows.Win32.Foundation.ERROR_UNKNOWN_PROPERTY -Windows.Win32.Foundation.ERROR_UNKNOWN_REVISION -Windows.Win32.Foundation.ERROR_UNRECOGNIZED_MEDIA -Windows.Win32.Foundation.ERROR_UNRECOGNIZED_VOLUME -Windows.Win32.Foundation.ERROR_UNSATISFIED_DEPENDENCIES -Windows.Win32.Foundation.ERROR_UNSUPPORTED_COMPRESSION -Windows.Win32.Foundation.ERROR_UNSUPPORTED_TYPE -Windows.Win32.Foundation.ERROR_UNTRUSTED_MOUNT_POINT -Windows.Win32.Foundation.ERROR_UNWIND -Windows.Win32.Foundation.ERROR_UNWIND_CONSOLIDATE -Windows.Win32.Foundation.ERROR_USER_APC -Windows.Win32.Foundation.ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_USER_EXISTS -Windows.Win32.Foundation.ERROR_USER_MAPPED_FILE -Windows.Win32.Foundation.ERROR_USER_PROFILE_LOAD -Windows.Win32.Foundation.ERROR_VALIDATE_CONTINUE -Windows.Win32.Foundation.ERROR_VC_DISCONNECTED -Windows.Win32.Foundation.ERROR_VDM_DISALLOWED -Windows.Win32.Foundation.ERROR_VDM_HARD_ERROR -Windows.Win32.Foundation.ERROR_VERIFIER_STOP -Windows.Win32.Foundation.ERROR_VERSION_PARSE_ERROR -Windows.Win32.Foundation.ERROR_VIRUS_DELETED -Windows.Win32.Foundation.ERROR_VIRUS_INFECTED -Windows.Win32.Foundation.ERROR_VOLSNAP_HIBERNATE_READY -Windows.Win32.Foundation.ERROR_VOLSNAP_PREPARE_HIBERNATE -Windows.Win32.Foundation.ERROR_VOLUME_MOUNTED -Windows.Win32.Foundation.ERROR_VOLUME_NOT_CLUSTER_ALIGNED -Windows.Win32.Foundation.ERROR_VOLUME_NOT_SIS_ENABLED -Windows.Win32.Foundation.ERROR_VOLUME_NOT_SUPPORT_EFS -Windows.Win32.Foundation.ERROR_VOLUME_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_VOLUME_WRITE_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_WAIT_1 -Windows.Win32.Foundation.ERROR_WAIT_2 -Windows.Win32.Foundation.ERROR_WAIT_3 -Windows.Win32.Foundation.ERROR_WAIT_63 -Windows.Win32.Foundation.ERROR_WAIT_FOR_OPLOCK -Windows.Win32.Foundation.ERROR_WAIT_NO_CHILDREN -Windows.Win32.Foundation.ERROR_WAKE_SYSTEM -Windows.Win32.Foundation.ERROR_WAKE_SYSTEM_DEBUGGER -Windows.Win32.Foundation.ERROR_WAS_LOCKED -Windows.Win32.Foundation.ERROR_WAS_UNLOCKED -Windows.Win32.Foundation.ERROR_WEAK_WHFBKEY_BLOCKED -Windows.Win32.Foundation.ERROR_WINDOW_NOT_COMBOBOX -Windows.Win32.Foundation.ERROR_WINDOW_NOT_DIALOG -Windows.Win32.Foundation.ERROR_WINDOW_OF_OTHER_THREAD -Windows.Win32.Foundation.ERROR_WIP_ENCRYPTION_FAILED -Windows.Win32.Foundation.ERROR_WOF_FILE_RESOURCE_TABLE_CORRUPT -Windows.Win32.Foundation.ERROR_WOF_WIM_HEADER_CORRUPT -Windows.Win32.Foundation.ERROR_WOF_WIM_RESOURCE_TABLE_CORRUPT -Windows.Win32.Foundation.ERROR_WORKING_SET_QUOTA -Windows.Win32.Foundation.ERROR_WOW_ASSERTION -Windows.Win32.Foundation.ERROR_WRITE_FAULT -Windows.Win32.Foundation.ERROR_WRITE_PROTECT -Windows.Win32.Foundation.ERROR_WRONG_COMPARTMENT -Windows.Win32.Foundation.ERROR_WRONG_DISK -Windows.Win32.Foundation.ERROR_WRONG_EFS -Windows.Win32.Foundation.ERROR_WRONG_PASSWORD -Windows.Win32.Foundation.ERROR_WRONG_TARGET_NAME -Windows.Win32.Foundation.ERROR_WX86_ERROR -Windows.Win32.Foundation.ERROR_WX86_WARNING -Windows.Win32.Foundation.ERROR_XML_PARSE_ERROR -Windows.Win32.Foundation.ERROR_XMLDSIG_ERROR -Windows.Win32.Foundation.EXCEPTION_STACK_OVERFLOW -Windows.Win32.Foundation.FALSE -Windows.Win32.Foundation.FARPROC -Windows.Win32.Foundation.FILETIME -Windows.Win32.Foundation.FRS_ERR_SYSVOL_POPULATE_TIMEOUT -Windows.Win32.Foundation.GENERIC_ACCESS_RIGHTS -Windows.Win32.Foundation.GENERIC_ALL -Windows.Win32.Foundation.GENERIC_EXECUTE -Windows.Win32.Foundation.GENERIC_READ -Windows.Win32.Foundation.GENERIC_WRITE -Windows.Win32.Foundation.GetLastError -Windows.Win32.Foundation.HANDLE -Windows.Win32.Foundation.HANDLE_FLAG_INHERIT -Windows.Win32.Foundation.HANDLE_FLAG_PROTECT_FROM_CLOSE -Windows.Win32.Foundation.HANDLE_FLAGS -Windows.Win32.Foundation.HMODULE -Windows.Win32.Foundation.LocalFree -Windows.Win32.Foundation.MAX_PATH -Windows.Win32.Foundation.NO_ERROR -Windows.Win32.Foundation.NTSTATUS -Windows.Win32.Foundation.RtlNtStatusToDosError -Windows.Win32.Foundation.SetHandleInformation -Windows.Win32.Foundation.SetLastError -Windows.Win32.Foundation.STATUS_DELETE_PENDING -Windows.Win32.Foundation.STATUS_DIRECTORY_NOT_EMPTY -Windows.Win32.Foundation.STATUS_END_OF_FILE -Windows.Win32.Foundation.STATUS_FILE_DELETED -Windows.Win32.Foundation.STATUS_INVALID_HANDLE -Windows.Win32.Foundation.STATUS_INVALID_PARAMETER -Windows.Win32.Foundation.STATUS_NOT_IMPLEMENTED -Windows.Win32.Foundation.STATUS_PENDING -Windows.Win32.Foundation.STATUS_SHARING_VIOLATION -Windows.Win32.Foundation.STATUS_SUCCESS -Windows.Win32.Foundation.TRUE -Windows.Win32.Foundation.UNICODE_STRING -Windows.Win32.Foundation.WAIT_ABANDONED -Windows.Win32.Foundation.WAIT_ABANDONED_0 -Windows.Win32.Foundation.WAIT_FAILED -Windows.Win32.Foundation.WAIT_IO_COMPLETION -Windows.Win32.Foundation.WAIT_OBJECT_0 -Windows.Win32.Foundation.WAIT_TIMEOUT -Windows.Win32.Foundation.WIN32_ERROR -Windows.Win32.Globalization.COMPARESTRING_RESULT -Windows.Win32.Globalization.CompareStringOrdinal -Windows.Win32.Globalization.CP_UTF8 -Windows.Win32.Globalization.CSTR_EQUAL -Windows.Win32.Globalization.CSTR_GREATER_THAN -Windows.Win32.Globalization.CSTR_LESS_THAN -Windows.Win32.Globalization.MB_COMPOSITE -Windows.Win32.Globalization.MB_ERR_INVALID_CHARS -Windows.Win32.Globalization.MB_PRECOMPOSED -Windows.Win32.Globalization.MB_USEGLYPHCHARS -Windows.Win32.Globalization.MULTI_BYTE_TO_WIDE_CHAR_FLAGS -Windows.Win32.Globalization.MultiByteToWideChar -Windows.Win32.Globalization.WC_ERR_INVALID_CHARS -Windows.Win32.Globalization.WideCharToMultiByte -Windows.Win32.Networking.WinSock.accept -Windows.Win32.Networking.WinSock.ADDRESS_FAMILY -Windows.Win32.Networking.WinSock.ADDRINFOA -Windows.Win32.Networking.WinSock.AF_INET -Windows.Win32.Networking.WinSock.AF_INET6 -Windows.Win32.Networking.WinSock.AF_UNIX -Windows.Win32.Networking.WinSock.AF_UNSPEC -Windows.Win32.Networking.WinSock.bind -Windows.Win32.Networking.WinSock.closesocket -Windows.Win32.Networking.WinSock.connect -Windows.Win32.Networking.WinSock.FD_SET -Windows.Win32.Networking.WinSock.FIONBIO -Windows.Win32.Networking.WinSock.freeaddrinfo -Windows.Win32.Networking.WinSock.getaddrinfo -Windows.Win32.Networking.WinSock.getpeername -Windows.Win32.Networking.WinSock.getsockname -Windows.Win32.Networking.WinSock.getsockopt -Windows.Win32.Networking.WinSock.IN6_ADDR -Windows.Win32.Networking.WinSock.IN_ADDR -Windows.Win32.Networking.WinSock.INVALID_SOCKET -Windows.Win32.Networking.WinSock.ioctlsocket -Windows.Win32.Networking.WinSock.IP_ADD_MEMBERSHIP -Windows.Win32.Networking.WinSock.IP_DROP_MEMBERSHIP -Windows.Win32.Networking.WinSock.IP_MREQ -Windows.Win32.Networking.WinSock.IP_MULTICAST_LOOP -Windows.Win32.Networking.WinSock.IP_MULTICAST_TTL -Windows.Win32.Networking.WinSock.IP_TTL -Windows.Win32.Networking.WinSock.IPPROTO -Windows.Win32.Networking.WinSock.IPPROTO_AH -Windows.Win32.Networking.WinSock.IPPROTO_CBT -Windows.Win32.Networking.WinSock.IPPROTO_DSTOPTS -Windows.Win32.Networking.WinSock.IPPROTO_EGP -Windows.Win32.Networking.WinSock.IPPROTO_ESP -Windows.Win32.Networking.WinSock.IPPROTO_FRAGMENT -Windows.Win32.Networking.WinSock.IPPROTO_GGP -Windows.Win32.Networking.WinSock.IPPROTO_HOPOPTS -Windows.Win32.Networking.WinSock.IPPROTO_ICLFXBM -Windows.Win32.Networking.WinSock.IPPROTO_ICMP -Windows.Win32.Networking.WinSock.IPPROTO_ICMPV6 -Windows.Win32.Networking.WinSock.IPPROTO_IDP -Windows.Win32.Networking.WinSock.IPPROTO_IGMP -Windows.Win32.Networking.WinSock.IPPROTO_IGP -Windows.Win32.Networking.WinSock.IPPROTO_IP -Windows.Win32.Networking.WinSock.IPPROTO_IPV4 -Windows.Win32.Networking.WinSock.IPPROTO_IPV6 -Windows.Win32.Networking.WinSock.IPPROTO_L2TP -Windows.Win32.Networking.WinSock.IPPROTO_MAX -Windows.Win32.Networking.WinSock.IPPROTO_ND -Windows.Win32.Networking.WinSock.IPPROTO_NONE -Windows.Win32.Networking.WinSock.IPPROTO_PGM -Windows.Win32.Networking.WinSock.IPPROTO_PIM -Windows.Win32.Networking.WinSock.IPPROTO_PUP -Windows.Win32.Networking.WinSock.IPPROTO_RAW -Windows.Win32.Networking.WinSock.IPPROTO_RDP -Windows.Win32.Networking.WinSock.IPPROTO_RESERVED_IPSEC -Windows.Win32.Networking.WinSock.IPPROTO_RESERVED_IPSECOFFLOAD -Windows.Win32.Networking.WinSock.IPPROTO_RESERVED_MAX -Windows.Win32.Networking.WinSock.IPPROTO_RESERVED_RAW -Windows.Win32.Networking.WinSock.IPPROTO_RESERVED_WNV -Windows.Win32.Networking.WinSock.IPPROTO_RM -Windows.Win32.Networking.WinSock.IPPROTO_ROUTING -Windows.Win32.Networking.WinSock.IPPROTO_SCTP -Windows.Win32.Networking.WinSock.IPPROTO_ST -Windows.Win32.Networking.WinSock.IPPROTO_TCP -Windows.Win32.Networking.WinSock.IPPROTO_UDP -Windows.Win32.Networking.WinSock.IPV6_ADD_MEMBERSHIP -Windows.Win32.Networking.WinSock.IPV6_DROP_MEMBERSHIP -Windows.Win32.Networking.WinSock.IPV6_MREQ -Windows.Win32.Networking.WinSock.IPV6_MULTICAST_LOOP -Windows.Win32.Networking.WinSock.IPV6_V6ONLY -Windows.Win32.Networking.WinSock.LINGER -Windows.Win32.Networking.WinSock.listen -Windows.Win32.Networking.WinSock.LPWSAOVERLAPPED_COMPLETION_ROUTINE -Windows.Win32.Networking.WinSock.MSG_DONTROUTE -Windows.Win32.Networking.WinSock.MSG_OOB -Windows.Win32.Networking.WinSock.MSG_PEEK -Windows.Win32.Networking.WinSock.MSG_PUSH_IMMEDIATE -Windows.Win32.Networking.WinSock.MSG_WAITALL -Windows.Win32.Networking.WinSock.recv -Windows.Win32.Networking.WinSock.recvfrom -Windows.Win32.Networking.WinSock.SD_BOTH -Windows.Win32.Networking.WinSock.SD_RECEIVE -Windows.Win32.Networking.WinSock.SD_SEND -Windows.Win32.Networking.WinSock.select -Windows.Win32.Networking.WinSock.send -Windows.Win32.Networking.WinSock.SEND_RECV_FLAGS -Windows.Win32.Networking.WinSock.sendto -Windows.Win32.Networking.WinSock.setsockopt -Windows.Win32.Networking.WinSock.shutdown -Windows.Win32.Networking.WinSock.SO_BROADCAST -Windows.Win32.Networking.WinSock.SO_ERROR -Windows.Win32.Networking.WinSock.SO_LINGER -Windows.Win32.Networking.WinSock.SO_RCVTIMEO -Windows.Win32.Networking.WinSock.SO_SNDTIMEO -Windows.Win32.Networking.WinSock.SOCK_DGRAM -Windows.Win32.Networking.WinSock.SOCK_RAW -Windows.Win32.Networking.WinSock.SOCK_RDM -Windows.Win32.Networking.WinSock.SOCK_SEQPACKET -Windows.Win32.Networking.WinSock.SOCK_STREAM -Windows.Win32.Networking.WinSock.SOCKADDR -Windows.Win32.Networking.WinSock.SOCKADDR_STORAGE -Windows.Win32.Networking.WinSock.SOCKADDR_UN -Windows.Win32.Networking.WinSock.SOCKET -Windows.Win32.Networking.WinSock.SOCKET_ERROR -Windows.Win32.Networking.WinSock.SOL_SOCKET -Windows.Win32.Networking.WinSock.TCP_NODELAY -Windows.Win32.Networking.WinSock.TIMEVAL -Windows.Win32.Networking.WinSock.WINSOCK_SHUTDOWN_HOW -Windows.Win32.Networking.WinSock.WINSOCK_SOCKET_TYPE -Windows.Win32.Networking.WinSock.WSA_E_CANCELLED -Windows.Win32.Networking.WinSock.WSA_E_NO_MORE -Windows.Win32.Networking.WinSock.WSA_ERROR -Windows.Win32.Networking.WinSock.WSA_FLAG_NO_HANDLE_INHERIT -Windows.Win32.Networking.WinSock.WSA_FLAG_OVERLAPPED -Windows.Win32.Networking.WinSock.WSA_INVALID_HANDLE -Windows.Win32.Networking.WinSock.WSA_INVALID_PARAMETER -Windows.Win32.Networking.WinSock.WSA_IO_INCOMPLETE -Windows.Win32.Networking.WinSock.WSA_IO_PENDING -Windows.Win32.Networking.WinSock.WSA_IPSEC_NAME_POLICY_ERROR -Windows.Win32.Networking.WinSock.WSA_NOT_ENOUGH_MEMORY -Windows.Win32.Networking.WinSock.WSA_OPERATION_ABORTED -Windows.Win32.Networking.WinSock.WSA_QOS_ADMISSION_FAILURE -Windows.Win32.Networking.WinSock.WSA_QOS_BAD_OBJECT -Windows.Win32.Networking.WinSock.WSA_QOS_BAD_STYLE -Windows.Win32.Networking.WinSock.WSA_QOS_EFILTERCOUNT -Windows.Win32.Networking.WinSock.WSA_QOS_EFILTERSTYLE -Windows.Win32.Networking.WinSock.WSA_QOS_EFILTERTYPE -Windows.Win32.Networking.WinSock.WSA_QOS_EFLOWCOUNT -Windows.Win32.Networking.WinSock.WSA_QOS_EFLOWDESC -Windows.Win32.Networking.WinSock.WSA_QOS_EFLOWSPEC -Windows.Win32.Networking.WinSock.WSA_QOS_EOBJLENGTH -Windows.Win32.Networking.WinSock.WSA_QOS_EPOLICYOBJ -Windows.Win32.Networking.WinSock.WSA_QOS_EPROVSPECBUF -Windows.Win32.Networking.WinSock.WSA_QOS_EPSFILTERSPEC -Windows.Win32.Networking.WinSock.WSA_QOS_EPSFLOWSPEC -Windows.Win32.Networking.WinSock.WSA_QOS_ESDMODEOBJ -Windows.Win32.Networking.WinSock.WSA_QOS_ESERVICETYPE -Windows.Win32.Networking.WinSock.WSA_QOS_ESHAPERATEOBJ -Windows.Win32.Networking.WinSock.WSA_QOS_EUNKOWNPSOBJ -Windows.Win32.Networking.WinSock.WSA_QOS_GENERIC_ERROR -Windows.Win32.Networking.WinSock.WSA_QOS_NO_RECEIVERS -Windows.Win32.Networking.WinSock.WSA_QOS_NO_SENDERS -Windows.Win32.Networking.WinSock.WSA_QOS_POLICY_FAILURE -Windows.Win32.Networking.WinSock.WSA_QOS_RECEIVERS -Windows.Win32.Networking.WinSock.WSA_QOS_REQUEST_CONFIRMED -Windows.Win32.Networking.WinSock.WSA_QOS_RESERVED_PETYPE -Windows.Win32.Networking.WinSock.WSA_QOS_SENDERS -Windows.Win32.Networking.WinSock.WSA_QOS_TRAFFIC_CTRL_ERROR -Windows.Win32.Networking.WinSock.WSA_SECURE_HOST_NOT_FOUND -Windows.Win32.Networking.WinSock.WSA_WAIT_EVENT_0 -Windows.Win32.Networking.WinSock.WSA_WAIT_IO_COMPLETION -Windows.Win32.Networking.WinSock.WSABASEERR -Windows.Win32.Networking.WinSock.WSABUF -Windows.Win32.Networking.WinSock.WSACleanup -Windows.Win32.Networking.WinSock.WSADATA -Windows.Win32.Networking.WinSock.WSADuplicateSocketW -Windows.Win32.Networking.WinSock.WSAEACCES -Windows.Win32.Networking.WinSock.WSAEADDRINUSE -Windows.Win32.Networking.WinSock.WSAEADDRNOTAVAIL -Windows.Win32.Networking.WinSock.WSAEAFNOSUPPORT -Windows.Win32.Networking.WinSock.WSAEALREADY -Windows.Win32.Networking.WinSock.WSAEBADF -Windows.Win32.Networking.WinSock.WSAECANCELLED -Windows.Win32.Networking.WinSock.WSAECONNABORTED -Windows.Win32.Networking.WinSock.WSAECONNREFUSED -Windows.Win32.Networking.WinSock.WSAECONNRESET -Windows.Win32.Networking.WinSock.WSAEDESTADDRREQ -Windows.Win32.Networking.WinSock.WSAEDISCON -Windows.Win32.Networking.WinSock.WSAEDQUOT -Windows.Win32.Networking.WinSock.WSAEFAULT -Windows.Win32.Networking.WinSock.WSAEHOSTDOWN -Windows.Win32.Networking.WinSock.WSAEHOSTUNREACH -Windows.Win32.Networking.WinSock.WSAEINPROGRESS -Windows.Win32.Networking.WinSock.WSAEINTR -Windows.Win32.Networking.WinSock.WSAEINVAL -Windows.Win32.Networking.WinSock.WSAEINVALIDPROCTABLE -Windows.Win32.Networking.WinSock.WSAEINVALIDPROVIDER -Windows.Win32.Networking.WinSock.WSAEISCONN -Windows.Win32.Networking.WinSock.WSAELOOP -Windows.Win32.Networking.WinSock.WSAEMFILE -Windows.Win32.Networking.WinSock.WSAEMSGSIZE -Windows.Win32.Networking.WinSock.WSAENAMETOOLONG -Windows.Win32.Networking.WinSock.WSAENETDOWN -Windows.Win32.Networking.WinSock.WSAENETRESET -Windows.Win32.Networking.WinSock.WSAENETUNREACH -Windows.Win32.Networking.WinSock.WSAENOBUFS -Windows.Win32.Networking.WinSock.WSAENOMORE -Windows.Win32.Networking.WinSock.WSAENOPROTOOPT -Windows.Win32.Networking.WinSock.WSAENOTCONN -Windows.Win32.Networking.WinSock.WSAENOTEMPTY -Windows.Win32.Networking.WinSock.WSAENOTSOCK -Windows.Win32.Networking.WinSock.WSAEOPNOTSUPP -Windows.Win32.Networking.WinSock.WSAEPFNOSUPPORT -Windows.Win32.Networking.WinSock.WSAEPROCLIM -Windows.Win32.Networking.WinSock.WSAEPROTONOSUPPORT -Windows.Win32.Networking.WinSock.WSAEPROTOTYPE -Windows.Win32.Networking.WinSock.WSAEPROVIDERFAILEDINIT -Windows.Win32.Networking.WinSock.WSAEREFUSED -Windows.Win32.Networking.WinSock.WSAEREMOTE -Windows.Win32.Networking.WinSock.WSAESHUTDOWN -Windows.Win32.Networking.WinSock.WSAESOCKTNOSUPPORT -Windows.Win32.Networking.WinSock.WSAESTALE -Windows.Win32.Networking.WinSock.WSAETIMEDOUT -Windows.Win32.Networking.WinSock.WSAETOOMANYREFS -Windows.Win32.Networking.WinSock.WSAEUSERS -Windows.Win32.Networking.WinSock.WSAEWOULDBLOCK -Windows.Win32.Networking.WinSock.WSAGetLastError -Windows.Win32.Networking.WinSock.WSAHOST_NOT_FOUND -Windows.Win32.Networking.WinSock.WSANO_DATA -Windows.Win32.Networking.WinSock.WSANO_RECOVERY -Windows.Win32.Networking.WinSock.WSANOTINITIALISED -Windows.Win32.Networking.WinSock.WSAPROTOCOL_INFOW -Windows.Win32.Networking.WinSock.WSAPROTOCOLCHAIN -Windows.Win32.Networking.WinSock.WSARecv -Windows.Win32.Networking.WinSock.WSASend -Windows.Win32.Networking.WinSock.WSASERVICE_NOT_FOUND -Windows.Win32.Networking.WinSock.WSASocketW -Windows.Win32.Networking.WinSock.WSAStartup -Windows.Win32.Networking.WinSock.WSASYSCALLFAILURE -Windows.Win32.Networking.WinSock.WSASYSNOTREADY -Windows.Win32.Networking.WinSock.WSATRY_AGAIN -Windows.Win32.Networking.WinSock.WSATYPE_NOT_FOUND -Windows.Win32.Networking.WinSock.WSAVERNOTSUPPORTED -Windows.Win32.Security.Authentication.Identity.RtlGenRandom -Windows.Win32.Security.SECURITY_ATTRIBUTES -Windows.Win32.Security.TOKEN_ACCESS_MASK -Windows.Win32.Security.TOKEN_ACCESS_PSEUDO_HANDLE -Windows.Win32.Security.TOKEN_ACCESS_PSEUDO_HANDLE_WIN8 -Windows.Win32.Security.TOKEN_ACCESS_SYSTEM_SECURITY -Windows.Win32.Security.TOKEN_ADJUST_DEFAULT -Windows.Win32.Security.TOKEN_ADJUST_GROUPS -Windows.Win32.Security.TOKEN_ADJUST_PRIVILEGES -Windows.Win32.Security.TOKEN_ADJUST_SESSIONID -Windows.Win32.Security.TOKEN_ALL_ACCESS -Windows.Win32.Security.TOKEN_ASSIGN_PRIMARY -Windows.Win32.Security.TOKEN_DELETE -Windows.Win32.Security.TOKEN_DUPLICATE -Windows.Win32.Security.TOKEN_EXECUTE -Windows.Win32.Security.TOKEN_IMPERSONATE -Windows.Win32.Security.TOKEN_QUERY -Windows.Win32.Security.TOKEN_QUERY_SOURCE -Windows.Win32.Security.TOKEN_READ -Windows.Win32.Security.TOKEN_READ_CONTROL -Windows.Win32.Security.TOKEN_TRUST_CONSTRAINT_MASK -Windows.Win32.Security.TOKEN_WRITE -Windows.Win32.Security.TOKEN_WRITE_DAC -Windows.Win32.Security.TOKEN_WRITE_OWNER -Windows.Win32.Storage.FileSystem.BY_HANDLE_FILE_INFORMATION -Windows.Win32.Storage.FileSystem.CALLBACK_CHUNK_FINISHED -Windows.Win32.Storage.FileSystem.CALLBACK_STREAM_SWITCH -Windows.Win32.Storage.FileSystem.CopyFileExW -Windows.Win32.Storage.FileSystem.CREATE_ALWAYS -Windows.Win32.Storage.FileSystem.CREATE_NEW -Windows.Win32.Storage.FileSystem.CreateDirectoryW -Windows.Win32.Storage.FileSystem.CreateFileW -Windows.Win32.Storage.FileSystem.CreateHardLinkW -Windows.Win32.Storage.FileSystem.CreateSymbolicLinkW -Windows.Win32.Storage.FileSystem.DELETE -Windows.Win32.Storage.FileSystem.DeleteFileW -Windows.Win32.Storage.FileSystem.FILE_ACCESS_RIGHTS -Windows.Win32.Storage.FileSystem.FILE_ADD_FILE -Windows.Win32.Storage.FileSystem.FILE_ADD_SUBDIRECTORY -Windows.Win32.Storage.FileSystem.FILE_ALL_ACCESS -Windows.Win32.Storage.FileSystem.FILE_ALLOCATION_INFO -Windows.Win32.Storage.FileSystem.FILE_APPEND_DATA -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_ARCHIVE -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_COMPRESSED -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_DEVICE -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_DIRECTORY -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_EA -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_ENCRYPTED -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_HIDDEN -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_INTEGRITY_STREAM -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_NO_SCRUB_DATA -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_NORMAL -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_OFFLINE -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_PINNED -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_READONLY -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_RECALL_ON_OPEN -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_REPARSE_POINT -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_SPARSE_FILE -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_SYSTEM -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_TAG_INFO -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_TEMPORARY -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_UNPINNED -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_VIRTUAL -Windows.Win32.Storage.FileSystem.FILE_BASIC_INFO -Windows.Win32.Storage.FileSystem.FILE_BEGIN -Windows.Win32.Storage.FileSystem.FILE_CREATE_PIPE_INSTANCE -Windows.Win32.Storage.FileSystem.FILE_CREATION_DISPOSITION -Windows.Win32.Storage.FileSystem.FILE_CURRENT -Windows.Win32.Storage.FileSystem.FILE_DELETE_CHILD -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_DELETE -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_DO_NOT_DELETE -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_FORCE_IMAGE_SECTION_CHECK -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_IGNORE_READONLY_ATTRIBUTE -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_ON_CLOSE -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_POSIX_SEMANTICS -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_INFO -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_INFO_EX -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_INFO_EX_FLAGS -Windows.Win32.Storage.FileSystem.FILE_END -Windows.Win32.Storage.FileSystem.FILE_END_OF_FILE_INFO -Windows.Win32.Storage.FileSystem.FILE_EXECUTE -Windows.Win32.Storage.FileSystem.FILE_FLAG_BACKUP_SEMANTICS -Windows.Win32.Storage.FileSystem.FILE_FLAG_DELETE_ON_CLOSE -Windows.Win32.Storage.FileSystem.FILE_FLAG_FIRST_PIPE_INSTANCE -Windows.Win32.Storage.FileSystem.FILE_FLAG_NO_BUFFERING -Windows.Win32.Storage.FileSystem.FILE_FLAG_OPEN_NO_RECALL -Windows.Win32.Storage.FileSystem.FILE_FLAG_OPEN_REPARSE_POINT -Windows.Win32.Storage.FileSystem.FILE_FLAG_OVERLAPPED -Windows.Win32.Storage.FileSystem.FILE_FLAG_POSIX_SEMANTICS -Windows.Win32.Storage.FileSystem.FILE_FLAG_RANDOM_ACCESS -Windows.Win32.Storage.FileSystem.FILE_FLAG_SEQUENTIAL_SCAN -Windows.Win32.Storage.FileSystem.FILE_FLAG_SESSION_AWARE -Windows.Win32.Storage.FileSystem.FILE_FLAG_WRITE_THROUGH -Windows.Win32.Storage.FileSystem.FILE_FLAGS_AND_ATTRIBUTES -Windows.Win32.Storage.FileSystem.FILE_GENERIC_EXECUTE -Windows.Win32.Storage.FileSystem.FILE_GENERIC_READ -Windows.Win32.Storage.FileSystem.FILE_GENERIC_WRITE -Windows.Win32.Storage.FileSystem.FILE_ID_BOTH_DIR_INFO -Windows.Win32.Storage.FileSystem.FILE_INFO_BY_HANDLE_CLASS -Windows.Win32.Storage.FileSystem.FILE_IO_PRIORITY_HINT_INFO -Windows.Win32.Storage.FileSystem.FILE_LIST_DIRECTORY -Windows.Win32.Storage.FileSystem.FILE_NAME_NORMALIZED -Windows.Win32.Storage.FileSystem.FILE_NAME_OPENED -Windows.Win32.Storage.FileSystem.FILE_READ_ATTRIBUTES -Windows.Win32.Storage.FileSystem.FILE_READ_DATA -Windows.Win32.Storage.FileSystem.FILE_READ_EA -Windows.Win32.Storage.FileSystem.FILE_SHARE_DELETE -Windows.Win32.Storage.FileSystem.FILE_SHARE_MODE -Windows.Win32.Storage.FileSystem.FILE_SHARE_NONE -Windows.Win32.Storage.FileSystem.FILE_SHARE_READ -Windows.Win32.Storage.FileSystem.FILE_SHARE_WRITE -Windows.Win32.Storage.FileSystem.FILE_STANDARD_INFO -Windows.Win32.Storage.FileSystem.FILE_TRAVERSE -Windows.Win32.Storage.FileSystem.FILE_TYPE -Windows.Win32.Storage.FileSystem.FILE_TYPE_CHAR -Windows.Win32.Storage.FileSystem.FILE_TYPE_DISK -Windows.Win32.Storage.FileSystem.FILE_TYPE_PIPE -Windows.Win32.Storage.FileSystem.FILE_TYPE_REMOTE -Windows.Win32.Storage.FileSystem.FILE_TYPE_UNKNOWN -Windows.Win32.Storage.FileSystem.FILE_WRITE_ATTRIBUTES -Windows.Win32.Storage.FileSystem.FILE_WRITE_DATA -Windows.Win32.Storage.FileSystem.FILE_WRITE_EA -Windows.Win32.Storage.FileSystem.FileAlignmentInfo -Windows.Win32.Storage.FileSystem.FileAllocationInfo -Windows.Win32.Storage.FileSystem.FileAttributeTagInfo -Windows.Win32.Storage.FileSystem.FileBasicInfo -Windows.Win32.Storage.FileSystem.FileCaseSensitiveInfo -Windows.Win32.Storage.FileSystem.FileCompressionInfo -Windows.Win32.Storage.FileSystem.FileDispositionInfo -Windows.Win32.Storage.FileSystem.FileDispositionInfoEx -Windows.Win32.Storage.FileSystem.FileEndOfFileInfo -Windows.Win32.Storage.FileSystem.FileFullDirectoryInfo -Windows.Win32.Storage.FileSystem.FileFullDirectoryRestartInfo -Windows.Win32.Storage.FileSystem.FileIdBothDirectoryInfo -Windows.Win32.Storage.FileSystem.FileIdBothDirectoryRestartInfo -Windows.Win32.Storage.FileSystem.FileIdExtdDirectoryInfo -Windows.Win32.Storage.FileSystem.FileIdExtdDirectoryRestartInfo -Windows.Win32.Storage.FileSystem.FileIdInfo -Windows.Win32.Storage.FileSystem.FileIoPriorityHintInfo -Windows.Win32.Storage.FileSystem.FileNameInfo -Windows.Win32.Storage.FileSystem.FileNormalizedNameInfo -Windows.Win32.Storage.FileSystem.FileRemoteProtocolInfo -Windows.Win32.Storage.FileSystem.FileRenameInfo -Windows.Win32.Storage.FileSystem.FileRenameInfoEx -Windows.Win32.Storage.FileSystem.FileStandardInfo -Windows.Win32.Storage.FileSystem.FileStorageInfo -Windows.Win32.Storage.FileSystem.FileStreamInfo -Windows.Win32.Storage.FileSystem.FindClose -Windows.Win32.Storage.FileSystem.FindExInfoBasic -Windows.Win32.Storage.FileSystem.FindExSearchNameMatch -Windows.Win32.Storage.FileSystem.FindFirstFileExW -Windows.Win32.Storage.FileSystem.FindNextFileW -Windows.Win32.Storage.FileSystem.FlushFileBuffers -Windows.Win32.Storage.FileSystem.GetFileAttributesW -Windows.Win32.Storage.FileSystem.GetFileInformationByHandle -Windows.Win32.Storage.FileSystem.GetFileInformationByHandleEx -Windows.Win32.Storage.FileSystem.GetFileType -Windows.Win32.Storage.FileSystem.GETFINALPATHNAMEBYHANDLE_FLAGS -Windows.Win32.Storage.FileSystem.GetFinalPathNameByHandleW -Windows.Win32.Storage.FileSystem.GetFullPathNameW -Windows.Win32.Storage.FileSystem.GetTempPathW -Windows.Win32.Storage.FileSystem.INVALID_FILE_ATTRIBUTES -Windows.Win32.Storage.FileSystem.LOCKFILE_EXCLUSIVE_LOCK -Windows.Win32.Storage.FileSystem.LOCKFILE_FAIL_IMMEDIATELY -Windows.Win32.Storage.FileSystem.LockFileEx -Windows.Win32.Storage.FileSystem.LPPROGRESS_ROUTINE -Windows.Win32.Storage.FileSystem.LPPROGRESS_ROUTINE_CALLBACK_REASON -Windows.Win32.Storage.FileSystem.MAXIMUM_REPARSE_DATA_BUFFER_SIZE -Windows.Win32.Storage.FileSystem.MaximumFileInfoByHandleClass -Windows.Win32.Storage.FileSystem.MOVE_FILE_FLAGS -Windows.Win32.Storage.FileSystem.MOVEFILE_COPY_ALLOWED -Windows.Win32.Storage.FileSystem.MOVEFILE_CREATE_HARDLINK -Windows.Win32.Storage.FileSystem.MOVEFILE_DELAY_UNTIL_REBOOT -Windows.Win32.Storage.FileSystem.MOVEFILE_FAIL_IF_NOT_TRACKABLE -Windows.Win32.Storage.FileSystem.MOVEFILE_REPLACE_EXISTING -Windows.Win32.Storage.FileSystem.MOVEFILE_WRITE_THROUGH -Windows.Win32.Storage.FileSystem.MoveFileExW -Windows.Win32.Storage.FileSystem.OPEN_ALWAYS -Windows.Win32.Storage.FileSystem.OPEN_EXISTING -Windows.Win32.Storage.FileSystem.PIPE_ACCESS_DUPLEX -Windows.Win32.Storage.FileSystem.PIPE_ACCESS_INBOUND -Windows.Win32.Storage.FileSystem.PIPE_ACCESS_OUTBOUND -Windows.Win32.Storage.FileSystem.READ_CONTROL -Windows.Win32.Storage.FileSystem.ReadFile -Windows.Win32.Storage.FileSystem.ReadFileEx -Windows.Win32.Storage.FileSystem.RemoveDirectoryW -Windows.Win32.Storage.FileSystem.SECURITY_ANONYMOUS -Windows.Win32.Storage.FileSystem.SECURITY_CONTEXT_TRACKING -Windows.Win32.Storage.FileSystem.SECURITY_DELEGATION -Windows.Win32.Storage.FileSystem.SECURITY_EFFECTIVE_ONLY -Windows.Win32.Storage.FileSystem.SECURITY_IDENTIFICATION -Windows.Win32.Storage.FileSystem.SECURITY_IMPERSONATION -Windows.Win32.Storage.FileSystem.SECURITY_SQOS_PRESENT -Windows.Win32.Storage.FileSystem.SECURITY_VALID_SQOS_FLAGS -Windows.Win32.Storage.FileSystem.SET_FILE_POINTER_MOVE_METHOD -Windows.Win32.Storage.FileSystem.SetFileAttributesW -Windows.Win32.Storage.FileSystem.SetFileInformationByHandle -Windows.Win32.Storage.FileSystem.SetFilePointerEx -Windows.Win32.Storage.FileSystem.SetFileTime -Windows.Win32.Storage.FileSystem.SPECIFIC_RIGHTS_ALL -Windows.Win32.Storage.FileSystem.STANDARD_RIGHTS_ALL -Windows.Win32.Storage.FileSystem.STANDARD_RIGHTS_EXECUTE -Windows.Win32.Storage.FileSystem.STANDARD_RIGHTS_READ -Windows.Win32.Storage.FileSystem.STANDARD_RIGHTS_REQUIRED -Windows.Win32.Storage.FileSystem.STANDARD_RIGHTS_WRITE -Windows.Win32.Storage.FileSystem.SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE -Windows.Win32.Storage.FileSystem.SYMBOLIC_LINK_FLAG_DIRECTORY -Windows.Win32.Storage.FileSystem.SYMBOLIC_LINK_FLAGS -Windows.Win32.Storage.FileSystem.SYNCHRONIZE -Windows.Win32.Storage.FileSystem.TRUNCATE_EXISTING -Windows.Win32.Storage.FileSystem.UnlockFile -Windows.Win32.Storage.FileSystem.VOLUME_NAME_DOS -Windows.Win32.Storage.FileSystem.VOLUME_NAME_GUID -Windows.Win32.Storage.FileSystem.VOLUME_NAME_NONE -Windows.Win32.Storage.FileSystem.WIN32_FIND_DATAW -Windows.Win32.Storage.FileSystem.WRITE_DAC -Windows.Win32.Storage.FileSystem.WRITE_OWNER -Windows.Win32.Storage.FileSystem.WriteFileEx -Windows.Win32.System.Console.CONSOLE_MODE -Windows.Win32.System.Console.CONSOLE_READCONSOLE_CONTROL -Windows.Win32.System.Console.DISABLE_NEWLINE_AUTO_RETURN -Windows.Win32.System.Console.ENABLE_AUTO_POSITION -Windows.Win32.System.Console.ENABLE_ECHO_INPUT -Windows.Win32.System.Console.ENABLE_EXTENDED_FLAGS -Windows.Win32.System.Console.ENABLE_INSERT_MODE -Windows.Win32.System.Console.ENABLE_LINE_INPUT -Windows.Win32.System.Console.ENABLE_LVB_GRID_WORLDWIDE -Windows.Win32.System.Console.ENABLE_MOUSE_INPUT -Windows.Win32.System.Console.ENABLE_PROCESSED_INPUT -Windows.Win32.System.Console.ENABLE_PROCESSED_OUTPUT -Windows.Win32.System.Console.ENABLE_QUICK_EDIT_MODE -Windows.Win32.System.Console.ENABLE_VIRTUAL_TERMINAL_INPUT -Windows.Win32.System.Console.ENABLE_VIRTUAL_TERMINAL_PROCESSING -Windows.Win32.System.Console.ENABLE_WINDOW_INPUT -Windows.Win32.System.Console.ENABLE_WRAP_AT_EOL_OUTPUT -Windows.Win32.System.Console.GetConsoleMode -Windows.Win32.System.Console.GetStdHandle -Windows.Win32.System.Console.ReadConsoleW -Windows.Win32.System.Console.STD_ERROR_HANDLE -Windows.Win32.System.Console.STD_HANDLE -Windows.Win32.System.Console.STD_INPUT_HANDLE -Windows.Win32.System.Console.STD_OUTPUT_HANDLE -Windows.Win32.System.Console.WriteConsoleW -Windows.Win32.System.Diagnostics.Debug.AddVectoredExceptionHandler -Windows.Win32.System.Diagnostics.Debug.ARM64_NT_NEON128 -Windows.Win32.System.Diagnostics.Debug.CONTEXT -Windows.Win32.System.Diagnostics.Debug.EXCEPTION_RECORD -Windows.Win32.System.Diagnostics.Debug.FACILITY_CODE -Windows.Win32.System.Diagnostics.Debug.FACILITY_NT_BIT -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_ALLOCATE_BUFFER -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_ARGUMENT_ARRAY -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_FROM_HMODULE -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_FROM_STRING -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_FROM_SYSTEM -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_IGNORE_INSERTS -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_OPTIONS -Windows.Win32.System.Diagnostics.Debug.FormatMessageW -Windows.Win32.System.Diagnostics.Debug.M128A Windows.Win32.System.Diagnostics.Debug.XSAVE_FORMAT -Windows.Win32.System.Environment.FreeEnvironmentStringsW -Windows.Win32.System.Environment.GetCommandLineW -Windows.Win32.System.Environment.GetCurrentDirectoryW -Windows.Win32.System.Environment.GetEnvironmentStringsW -Windows.Win32.System.Environment.GetEnvironmentVariableW -Windows.Win32.System.Environment.SetCurrentDirectoryW -Windows.Win32.System.Environment.SetEnvironmentVariableW -Windows.Win32.System.IO.CancelIo -Windows.Win32.System.IO.DeviceIoControl -Windows.Win32.System.IO.GetOverlappedResult -Windows.Win32.System.IO.LPOVERLAPPED_COMPLETION_ROUTINE -Windows.Win32.System.IO.OVERLAPPED -Windows.Win32.System.Ioctl.FSCTL_GET_REPARSE_POINT -Windows.Win32.System.Ioctl.FSCTL_SET_REPARSE_POINT -Windows.Win32.System.Kernel.EXCEPTION_DISPOSITION -Windows.Win32.System.Kernel.ExceptionCollidedUnwind -Windows.Win32.System.Kernel.ExceptionContinueExecution -Windows.Win32.System.Kernel.ExceptionContinueSearch -Windows.Win32.System.Kernel.ExceptionNestedException Windows.Win32.System.Kernel.FLOATING_SAVE_AREA -Windows.Win32.System.Kernel.OBJ_DONT_REPARSE -Windows.Win32.System.LibraryLoader.GetModuleFileNameW -Windows.Win32.System.LibraryLoader.GetModuleHandleA -Windows.Win32.System.LibraryLoader.GetModuleHandleW -Windows.Win32.System.LibraryLoader.GetProcAddress -Windows.Win32.System.Performance.QueryPerformanceCounter -Windows.Win32.System.Performance.QueryPerformanceFrequency -Windows.Win32.System.Pipes.CreateNamedPipeW -Windows.Win32.System.Pipes.CreatePipe -Windows.Win32.System.Pipes.NAMED_PIPE_MODE -Windows.Win32.System.Pipes.PIPE_ACCEPT_REMOTE_CLIENTS -Windows.Win32.System.Pipes.PIPE_CLIENT_END -Windows.Win32.System.Pipes.PIPE_NOWAIT -Windows.Win32.System.Pipes.PIPE_READMODE_BYTE -Windows.Win32.System.Pipes.PIPE_READMODE_MESSAGE -Windows.Win32.System.Pipes.PIPE_REJECT_REMOTE_CLIENTS -Windows.Win32.System.Pipes.PIPE_SERVER_END -Windows.Win32.System.Pipes.PIPE_TYPE_BYTE -Windows.Win32.System.Pipes.PIPE_TYPE_MESSAGE -Windows.Win32.System.Pipes.PIPE_WAIT -Windows.Win32.System.SystemInformation.GetSystemDirectoryW -Windows.Win32.System.SystemInformation.GetSystemInfo -Windows.Win32.System.SystemInformation.GetSystemTimeAsFileTime -Windows.Win32.System.SystemInformation.GetSystemTimePreciseAsFileTime -Windows.Win32.System.SystemInformation.GetWindowsDirectoryW -Windows.Win32.System.SystemInformation.PROCESSOR_ARCHITECTURE -Windows.Win32.System.SystemInformation.SYSTEM_INFO -Windows.Win32.System.SystemServices.DLL_PROCESS_DETACH -Windows.Win32.System.SystemServices.DLL_THREAD_DETACH -Windows.Win32.System.SystemServices.EXCEPTION_MAXIMUM_PARAMETERS -Windows.Win32.System.SystemServices.FAST_FAIL_FATAL_APP_EXIT -Windows.Win32.System.SystemServices.IO_REPARSE_TAG_MOUNT_POINT -Windows.Win32.System.SystemServices.IO_REPARSE_TAG_SYMLINK -Windows.Win32.System.Threading.ABOVE_NORMAL_PRIORITY_CLASS -Windows.Win32.System.Threading.AcquireSRWLockExclusive -Windows.Win32.System.Threading.AcquireSRWLockShared -Windows.Win32.System.Threading.ALL_PROCESSOR_GROUPS -Windows.Win32.System.Threading.BELOW_NORMAL_PRIORITY_CLASS -Windows.Win32.System.Threading.CREATE_BREAKAWAY_FROM_JOB -Windows.Win32.System.Threading.CREATE_DEFAULT_ERROR_MODE -Windows.Win32.System.Threading.CREATE_FORCEDOS -Windows.Win32.System.Threading.CREATE_IGNORE_SYSTEM_DEFAULT -Windows.Win32.System.Threading.CREATE_NEW_CONSOLE -Windows.Win32.System.Threading.CREATE_NEW_PROCESS_GROUP -Windows.Win32.System.Threading.CREATE_NO_WINDOW -Windows.Win32.System.Threading.CREATE_PRESERVE_CODE_AUTHZ_LEVEL -Windows.Win32.System.Threading.CREATE_PROTECTED_PROCESS -Windows.Win32.System.Threading.CREATE_SECURE_PROCESS -Windows.Win32.System.Threading.CREATE_SEPARATE_WOW_VDM -Windows.Win32.System.Threading.CREATE_SHARED_WOW_VDM -Windows.Win32.System.Threading.CREATE_SUSPENDED -Windows.Win32.System.Threading.CREATE_UNICODE_ENVIRONMENT -Windows.Win32.System.Threading.CREATE_WAITABLE_TIMER_HIGH_RESOLUTION -Windows.Win32.System.Threading.CREATE_WAITABLE_TIMER_MANUAL_RESET -Windows.Win32.System.Threading.CreateEventW -Windows.Win32.System.Threading.CreateProcessW -Windows.Win32.System.Threading.CreateThread -Windows.Win32.System.Threading.CreateWaitableTimerExW -Windows.Win32.System.Threading.DEBUG_ONLY_THIS_PROCESS -Windows.Win32.System.Threading.DEBUG_PROCESS -Windows.Win32.System.Threading.DeleteProcThreadAttributeList -Windows.Win32.System.Threading.DETACHED_PROCESS -Windows.Win32.System.Threading.ExitProcess -Windows.Win32.System.Threading.EXTENDED_STARTUPINFO_PRESENT -Windows.Win32.System.Threading.GetActiveProcessorCount -Windows.Win32.System.Threading.GetCurrentProcess -Windows.Win32.System.Threading.GetCurrentProcessId -Windows.Win32.System.Threading.GetCurrentThread -Windows.Win32.System.Threading.GetExitCodeProcess -Windows.Win32.System.Threading.GetProcessId -Windows.Win32.System.Threading.HIGH_PRIORITY_CLASS -Windows.Win32.System.Threading.IDLE_PRIORITY_CLASS -Windows.Win32.System.Threading.INFINITE -Windows.Win32.System.Threading.INHERIT_CALLER_PRIORITY -Windows.Win32.System.Threading.INHERIT_PARENT_AFFINITY -Windows.Win32.System.Threading.INIT_ONCE_INIT_FAILED -Windows.Win32.System.Threading.InitializeProcThreadAttributeList -Windows.Win32.System.Threading.InitOnceBeginInitialize -Windows.Win32.System.Threading.InitOnceComplete -Windows.Win32.System.Threading.LPPROC_THREAD_ATTRIBUTE_LIST -Windows.Win32.System.Threading.LPTHREAD_START_ROUTINE -Windows.Win32.System.Threading.NORMAL_PRIORITY_CLASS -Windows.Win32.System.Threading.OpenProcessToken -Windows.Win32.System.Threading.PROCESS_CREATION_FLAGS -Windows.Win32.System.Threading.PROCESS_INFORMATION -Windows.Win32.System.Threading.PROCESS_MODE_BACKGROUND_BEGIN -Windows.Win32.System.Threading.PROCESS_MODE_BACKGROUND_END -Windows.Win32.System.Threading.PROFILE_KERNEL -Windows.Win32.System.Threading.PROFILE_SERVER -Windows.Win32.System.Threading.PROFILE_USER -Windows.Win32.System.Threading.REALTIME_PRIORITY_CLASS -Windows.Win32.System.Threading.ReleaseSRWLockExclusive -Windows.Win32.System.Threading.ReleaseSRWLockShared -Windows.Win32.System.Threading.SetThreadStackGuarantee -Windows.Win32.System.Threading.SetWaitableTimer -Windows.Win32.System.Threading.Sleep -Windows.Win32.System.Threading.SleepConditionVariableSRW -Windows.Win32.System.Threading.SleepEx -Windows.Win32.System.Threading.STACK_SIZE_PARAM_IS_A_RESERVATION -Windows.Win32.System.Threading.STARTF_FORCEOFFFEEDBACK -Windows.Win32.System.Threading.STARTF_FORCEONFEEDBACK -Windows.Win32.System.Threading.STARTF_PREVENTPINNING -Windows.Win32.System.Threading.STARTF_RUNFULLSCREEN -Windows.Win32.System.Threading.STARTF_TITLEISAPPID -Windows.Win32.System.Threading.STARTF_TITLEISLINKNAME -Windows.Win32.System.Threading.STARTF_UNTRUSTEDSOURCE -Windows.Win32.System.Threading.STARTF_USECOUNTCHARS -Windows.Win32.System.Threading.STARTF_USEFILLATTRIBUTE -Windows.Win32.System.Threading.STARTF_USEHOTKEY -Windows.Win32.System.Threading.STARTF_USEPOSITION -Windows.Win32.System.Threading.STARTF_USESHOWWINDOW -Windows.Win32.System.Threading.STARTF_USESIZE -Windows.Win32.System.Threading.STARTF_USESTDHANDLES -Windows.Win32.System.Threading.STARTUPINFOEXW -Windows.Win32.System.Threading.STARTUPINFOW -Windows.Win32.System.Threading.STARTUPINFOW_FLAGS -Windows.Win32.System.Threading.SwitchToThread -Windows.Win32.System.Threading.TerminateProcess -Windows.Win32.System.Threading.THREAD_CREATE_RUN_IMMEDIATELY -Windows.Win32.System.Threading.THREAD_CREATE_SUSPENDED -Windows.Win32.System.Threading.THREAD_CREATION_FLAGS -Windows.Win32.System.Threading.TIMER_ALL_ACCESS -Windows.Win32.System.Threading.TIMER_MODIFY_STATE -Windows.Win32.System.Threading.TLS_OUT_OF_INDEXES -Windows.Win32.System.Threading.TlsAlloc -Windows.Win32.System.Threading.TlsFree -Windows.Win32.System.Threading.TlsGetValue -Windows.Win32.System.Threading.TlsSetValue -Windows.Win32.System.Threading.TryAcquireSRWLockExclusive -Windows.Win32.System.Threading.TryAcquireSRWLockShared -Windows.Win32.System.Threading.UpdateProcThreadAttribute -Windows.Win32.System.Threading.WaitForMultipleObjects -Windows.Win32.System.Threading.WaitForSingleObject -Windows.Win32.System.Threading.WakeAllConditionVariable -Windows.Win32.System.Threading.WakeConditionVariable -Windows.Win32.System.WindowsProgramming.PROGRESS_CONTINUE -Windows.Win32.UI.Shell.GetUserProfileDirectoryW +WINSOCK_SHUTDOWN_HOW +WINSOCK_SOCKET_TYPE +WRITE_DAC +WRITE_OWNER +WriteConsoleW +WriteFileEx +WSA_E_CANCELLED +WSA_E_NO_MORE +WSA_ERROR +WSA_FLAG_NO_HANDLE_INHERIT +WSA_FLAG_OVERLAPPED +WSA_INVALID_HANDLE +WSA_INVALID_PARAMETER +WSA_IO_INCOMPLETE +WSA_IO_PENDING +WSA_IPSEC_NAME_POLICY_ERROR +WSA_NOT_ENOUGH_MEMORY +WSA_OPERATION_ABORTED +WSA_QOS_ADMISSION_FAILURE +WSA_QOS_BAD_OBJECT +WSA_QOS_BAD_STYLE +WSA_QOS_EFILTERCOUNT +WSA_QOS_EFILTERSTYLE +WSA_QOS_EFILTERTYPE +WSA_QOS_EFLOWCOUNT +WSA_QOS_EFLOWDESC +WSA_QOS_EFLOWSPEC +WSA_QOS_EOBJLENGTH +WSA_QOS_EPOLICYOBJ +WSA_QOS_EPROVSPECBUF +WSA_QOS_EPSFILTERSPEC +WSA_QOS_EPSFLOWSPEC +WSA_QOS_ESDMODEOBJ +WSA_QOS_ESERVICETYPE +WSA_QOS_ESHAPERATEOBJ +WSA_QOS_EUNKOWNPSOBJ +WSA_QOS_GENERIC_ERROR +WSA_QOS_NO_RECEIVERS +WSA_QOS_NO_SENDERS +WSA_QOS_POLICY_FAILURE +WSA_QOS_RECEIVERS +WSA_QOS_REQUEST_CONFIRMED +WSA_QOS_RESERVED_PETYPE +WSA_QOS_SENDERS +WSA_QOS_TRAFFIC_CTRL_ERROR +WSA_SECURE_HOST_NOT_FOUND +WSA_WAIT_EVENT_0 +WSA_WAIT_IO_COMPLETION +WSABASEERR +WSABUF +WSACleanup +WSADATA +WSADuplicateSocketW +WSAEACCES +WSAEADDRINUSE +WSAEADDRNOTAVAIL +WSAEAFNOSUPPORT +WSAEALREADY +WSAEBADF +WSAECANCELLED +WSAECONNABORTED +WSAECONNREFUSED +WSAECONNRESET +WSAEDESTADDRREQ +WSAEDISCON +WSAEDQUOT +WSAEFAULT +WSAEHOSTDOWN +WSAEHOSTUNREACH +WSAEINPROGRESS +WSAEINTR +WSAEINVAL +WSAEINVALIDPROCTABLE +WSAEINVALIDPROVIDER +WSAEISCONN +WSAELOOP +WSAEMFILE +WSAEMSGSIZE +WSAENAMETOOLONG +WSAENETDOWN +WSAENETRESET +WSAENETUNREACH +WSAENOBUFS +WSAENOMORE +WSAENOPROTOOPT +WSAENOTCONN +WSAENOTEMPTY +WSAENOTSOCK +WSAEOPNOTSUPP +WSAEPFNOSUPPORT +WSAEPROCLIM +WSAEPROTONOSUPPORT +WSAEPROTOTYPE +WSAEPROVIDERFAILEDINIT +WSAEREFUSED +WSAEREMOTE +WSAESHUTDOWN +WSAESOCKTNOSUPPORT +WSAESTALE +WSAETIMEDOUT +WSAETOOMANYREFS +WSAEUSERS +WSAEWOULDBLOCK +WSAGetLastError +WSAHOST_NOT_FOUND +WSANO_DATA +WSANO_RECOVERY +WSANOTINITIALISED +WSAPROTOCOL_INFOW +WSAPROTOCOLCHAIN +WSARecv +WSASend +WSASERVICE_NOT_FOUND +WSASocketW +WSAStartup +WSASYSCALLFAILURE +WSASYSNOTREADY +WSATRY_AGAIN +WSATYPE_NOT_FOUND +WSAVERNOTSUPPORTED diff --git a/std/src/sys/pal/windows/c/windows_sys.rs b/std/src/sys/pal/windows/c/windows_sys.rs index 19925e59dfe9c..1d0e89f5d0f0e 100644 --- a/std/src/sys/pal/windows/c/windows_sys.rs +++ b/std/src/sys/pal/windows/c/windows_sys.rs @@ -1,15 +1,14 @@ -// Bindings generated by `windows-bindgen` 0.58.0 +// Bindings generated by `windows-bindgen` 0.59.0 #![allow(non_snake_case, non_upper_case_globals, non_camel_case_types, dead_code, clippy::all)] -windows_targets::link!("advapi32.dll" "system" fn OpenProcessToken(processhandle : HANDLE, desiredaccess : TOKEN_ACCESS_MASK, tokenhandle : *mut HANDLE) -> BOOL); -windows_targets::link!("advapi32.dll" "system" "SystemFunction036" fn RtlGenRandom(randombuffer : *mut core::ffi::c_void, randombufferlength : u32) -> BOOLEAN); + windows_targets::link!("kernel32.dll" "system" fn AcquireSRWLockExclusive(srwlock : *mut SRWLOCK)); windows_targets::link!("kernel32.dll" "system" fn AcquireSRWLockShared(srwlock : *mut SRWLOCK)); windows_targets::link!("kernel32.dll" "system" fn AddVectoredExceptionHandler(first : u32, handler : PVECTORED_EXCEPTION_HANDLER) -> *mut core::ffi::c_void); windows_targets::link!("kernel32.dll" "system" fn CancelIo(hfile : HANDLE) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn CloseHandle(hobject : HANDLE) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn CompareStringOrdinal(lpstring1 : PCWSTR, cchcount1 : i32, lpstring2 : PCWSTR, cchcount2 : i32, bignorecase : BOOL) -> COMPARESTRING_RESULT); -windows_targets::link!("kernel32.dll" "system" fn CopyFileExW(lpexistingfilename : PCWSTR, lpnewfilename : PCWSTR, lpprogressroutine : LPPROGRESS_ROUTINE, lpdata : *const core::ffi::c_void, pbcancel : *mut BOOL, dwcopyflags : u32) -> BOOL); +windows_targets::link!("kernel32.dll" "system" fn CopyFileExW(lpexistingfilename : PCWSTR, lpnewfilename : PCWSTR, lpprogressroutine : LPPROGRESS_ROUTINE, lpdata : *const core::ffi::c_void, pbcancel : *mut BOOL, dwcopyflags : COPYFILE_FLAGS) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn CreateDirectoryW(lppathname : PCWSTR, lpsecurityattributes : *const SECURITY_ATTRIBUTES) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn CreateEventW(lpeventattributes : *const SECURITY_ATTRIBUTES, bmanualreset : BOOL, binitialstate : BOOL, lpname : PCWSTR) -> HANDLE); windows_targets::link!("kernel32.dll" "system" fn CreateFileW(lpfilename : PCWSTR, dwdesiredaccess : u32, dwsharemode : FILE_SHARE_MODE, lpsecurityattributes : *const SECURITY_ATTRIBUTES, dwcreationdisposition : FILE_CREATION_DISPOSITION, dwflagsandattributes : FILE_FLAGS_AND_ATTRIBUTES, htemplatefile : HANDLE) -> HANDLE); @@ -17,7 +16,7 @@ windows_targets::link!("kernel32.dll" "system" fn CreateHardLinkW(lpfilename : P windows_targets::link!("kernel32.dll" "system" fn CreateNamedPipeW(lpname : PCWSTR, dwopenmode : FILE_FLAGS_AND_ATTRIBUTES, dwpipemode : NAMED_PIPE_MODE, nmaxinstances : u32, noutbuffersize : u32, ninbuffersize : u32, ndefaulttimeout : u32, lpsecurityattributes : *const SECURITY_ATTRIBUTES) -> HANDLE); windows_targets::link!("kernel32.dll" "system" fn CreatePipe(hreadpipe : *mut HANDLE, hwritepipe : *mut HANDLE, lppipeattributes : *const SECURITY_ATTRIBUTES, nsize : u32) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn CreateProcessW(lpapplicationname : PCWSTR, lpcommandline : PWSTR, lpprocessattributes : *const SECURITY_ATTRIBUTES, lpthreadattributes : *const SECURITY_ATTRIBUTES, binherithandles : BOOL, dwcreationflags : PROCESS_CREATION_FLAGS, lpenvironment : *const core::ffi::c_void, lpcurrentdirectory : PCWSTR, lpstartupinfo : *const STARTUPINFOW, lpprocessinformation : *mut PROCESS_INFORMATION) -> BOOL); -windows_targets::link!("kernel32.dll" "system" fn CreateSymbolicLinkW(lpsymlinkfilename : PCWSTR, lptargetfilename : PCWSTR, dwflags : SYMBOLIC_LINK_FLAGS) -> BOOLEAN); +windows_targets::link!("kernel32.dll" "system" fn CreateSymbolicLinkW(lpsymlinkfilename : PCWSTR, lptargetfilename : PCWSTR, dwflags : SYMBOLIC_LINK_FLAGS) -> bool); windows_targets::link!("kernel32.dll" "system" fn CreateThread(lpthreadattributes : *const SECURITY_ATTRIBUTES, dwstacksize : usize, lpstartaddress : LPTHREAD_START_ROUTINE, lpparameter : *const core::ffi::c_void, dwcreationflags : THREAD_CREATION_FLAGS, lpthreadid : *mut u32) -> HANDLE); windows_targets::link!("kernel32.dll" "system" fn CreateWaitableTimerExW(lptimerattributes : *const SECURITY_ATTRIBUTES, lptimername : PCWSTR, dwflags : u32, dwdesiredaccess : u32) -> HANDLE); windows_targets::link!("kernel32.dll" "system" fn DeleteFileW(lpfilename : PCWSTR) -> BOOL); @@ -34,6 +33,7 @@ windows_targets::link!("kernel32.dll" "system" fn FreeEnvironmentStringsW(penv : windows_targets::link!("kernel32.dll" "system" fn GetActiveProcessorCount(groupnumber : u16) -> u32); windows_targets::link!("kernel32.dll" "system" fn GetCommandLineW() -> PCWSTR); windows_targets::link!("kernel32.dll" "system" fn GetConsoleMode(hconsolehandle : HANDLE, lpmode : *mut CONSOLE_MODE) -> BOOL); +windows_targets::link!("kernel32.dll" "system" fn GetConsoleOutputCP() -> u32); windows_targets::link!("kernel32.dll" "system" fn GetCurrentDirectoryW(nbufferlength : u32, lpbuffer : PWSTR) -> u32); windows_targets::link!("kernel32.dll" "system" fn GetCurrentProcess() -> HANDLE); windows_targets::link!("kernel32.dll" "system" fn GetCurrentProcessId() -> u32); @@ -60,6 +60,7 @@ windows_targets::link!("kernel32.dll" "system" fn GetSystemInfo(lpsysteminfo : * windows_targets::link!("kernel32.dll" "system" fn GetSystemTimeAsFileTime(lpsystemtimeasfiletime : *mut FILETIME)); windows_targets::link!("kernel32.dll" "system" fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime : *mut FILETIME)); windows_targets::link!("kernel32.dll" "system" fn GetTempPathW(nbufferlength : u32, lpbuffer : PWSTR) -> u32); +windows_targets::link!("userenv.dll" "system" fn GetUserProfileDirectoryW(htoken : HANDLE, lpprofiledir : PWSTR, lpcchsize : *mut u32) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn GetWindowsDirectoryW(lpbuffer : PWSTR, usize : u32) -> u32); windows_targets::link!("kernel32.dll" "system" fn InitOnceBeginInitialize(lpinitonce : *mut INIT_ONCE, dwflags : u32, fpending : *mut BOOL, lpcontext : *mut *mut core::ffi::c_void) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn InitOnceComplete(lpinitonce : *mut INIT_ONCE, dwflags : u32, lpcontext : *const core::ffi::c_void) -> BOOL); @@ -68,6 +69,11 @@ windows_targets::link!("kernel32.dll" "system" fn LocalFree(hmem : HLOCAL) -> HL windows_targets::link!("kernel32.dll" "system" fn LockFileEx(hfile : HANDLE, dwflags : LOCK_FILE_FLAGS, dwreserved : u32, nnumberofbytestolocklow : u32, nnumberofbytestolockhigh : u32, lpoverlapped : *mut OVERLAPPED) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn MoveFileExW(lpexistingfilename : PCWSTR, lpnewfilename : PCWSTR, dwflags : MOVE_FILE_FLAGS) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn MultiByteToWideChar(codepage : u32, dwflags : MULTI_BYTE_TO_WIDE_CHAR_FLAGS, lpmultibytestr : PCSTR, cbmultibyte : i32, lpwidecharstr : PWSTR, cchwidechar : i32) -> i32); +windows_targets::link!("ntdll.dll" "system" fn NtCreateFile(filehandle : *mut HANDLE, desiredaccess : FILE_ACCESS_RIGHTS, objectattributes : *const OBJECT_ATTRIBUTES, iostatusblock : *mut IO_STATUS_BLOCK, allocationsize : *const i64, fileattributes : FILE_FLAGS_AND_ATTRIBUTES, shareaccess : FILE_SHARE_MODE, createdisposition : NTCREATEFILE_CREATE_DISPOSITION, createoptions : NTCREATEFILE_CREATE_OPTIONS, eabuffer : *const core::ffi::c_void, ealength : u32) -> NTSTATUS); +windows_targets::link!("ntdll.dll" "system" fn NtOpenFile(filehandle : *mut HANDLE, desiredaccess : u32, objectattributes : *const OBJECT_ATTRIBUTES, iostatusblock : *mut IO_STATUS_BLOCK, shareaccess : u32, openoptions : u32) -> NTSTATUS); +windows_targets::link!("ntdll.dll" "system" fn NtReadFile(filehandle : HANDLE, event : HANDLE, apcroutine : PIO_APC_ROUTINE, apccontext : *const core::ffi::c_void, iostatusblock : *mut IO_STATUS_BLOCK, buffer : *mut core::ffi::c_void, length : u32, byteoffset : *const i64, key : *const u32) -> NTSTATUS); +windows_targets::link!("ntdll.dll" "system" fn NtWriteFile(filehandle : HANDLE, event : HANDLE, apcroutine : PIO_APC_ROUTINE, apccontext : *const core::ffi::c_void, iostatusblock : *mut IO_STATUS_BLOCK, buffer : *const core::ffi::c_void, length : u32, byteoffset : *const i64, key : *const u32) -> NTSTATUS); +windows_targets::link!("advapi32.dll" "system" fn OpenProcessToken(processhandle : HANDLE, desiredaccess : TOKEN_ACCESS_MASK, tokenhandle : *mut HANDLE) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn QueryPerformanceCounter(lpperformancecount : *mut i64) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn QueryPerformanceFrequency(lpfrequency : *mut i64) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn ReadConsoleW(hconsoleinput : HANDLE, lpbuffer : *mut core::ffi::c_void, nnumberofcharstoread : u32, lpnumberofcharsread : *mut u32, pinputcontrol : *const CONSOLE_READCONSOLE_CONTROL) -> BOOL); @@ -76,6 +82,8 @@ windows_targets::link!("kernel32.dll" "system" fn ReadFileEx(hfile : HANDLE, lpb windows_targets::link!("kernel32.dll" "system" fn ReleaseSRWLockExclusive(srwlock : *mut SRWLOCK)); windows_targets::link!("kernel32.dll" "system" fn ReleaseSRWLockShared(srwlock : *mut SRWLOCK)); windows_targets::link!("kernel32.dll" "system" fn RemoveDirectoryW(lppathname : PCWSTR) -> BOOL); +windows_targets::link!("advapi32.dll" "system" "SystemFunction036" fn RtlGenRandom(randombuffer : *mut core::ffi::c_void, randombufferlength : u32) -> bool); +windows_targets::link!("ntdll.dll" "system" fn RtlNtStatusToDosError(status : NTSTATUS) -> u32); windows_targets::link!("kernel32.dll" "system" fn SetCurrentDirectoryW(lppathname : PCWSTR) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn SetEnvironmentVariableW(lpname : PCWSTR, lpvalue : PCWSTR) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn SetFileAttributesW(lpfilename : PCWSTR, dwfileattributes : FILE_FLAGS_AND_ATTRIBUTES) -> BOOL); @@ -95,23 +103,10 @@ windows_targets::link!("kernel32.dll" "system" fn TlsAlloc() -> u32); windows_targets::link!("kernel32.dll" "system" fn TlsFree(dwtlsindex : u32) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn TlsGetValue(dwtlsindex : u32) -> *mut core::ffi::c_void); windows_targets::link!("kernel32.dll" "system" fn TlsSetValue(dwtlsindex : u32, lptlsvalue : *const core::ffi::c_void) -> BOOL); -windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockExclusive(srwlock : *mut SRWLOCK) -> BOOLEAN); -windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockShared(srwlock : *mut SRWLOCK) -> BOOLEAN); +windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockExclusive(srwlock : *mut SRWLOCK) -> bool); +windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockShared(srwlock : *mut SRWLOCK) -> bool); windows_targets::link!("kernel32.dll" "system" fn UnlockFile(hfile : HANDLE, dwfileoffsetlow : u32, dwfileoffsethigh : u32, nnumberofbytestounlocklow : u32, nnumberofbytestounlockhigh : u32) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn UpdateProcThreadAttribute(lpattributelist : LPPROC_THREAD_ATTRIBUTE_LIST, dwflags : u32, attribute : usize, lpvalue : *const core::ffi::c_void, cbsize : usize, lppreviousvalue : *mut core::ffi::c_void, lpreturnsize : *const usize) -> BOOL); -windows_targets::link!("kernel32.dll" "system" fn WaitForMultipleObjects(ncount : u32, lphandles : *const HANDLE, bwaitall : BOOL, dwmilliseconds : u32) -> WAIT_EVENT); -windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT); -windows_targets::link!("kernel32.dll" "system" fn WakeAllConditionVariable(conditionvariable : *mut CONDITION_VARIABLE)); -windows_targets::link!("kernel32.dll" "system" fn WakeConditionVariable(conditionvariable : *mut CONDITION_VARIABLE)); -windows_targets::link!("kernel32.dll" "system" fn WideCharToMultiByte(codepage : u32, dwflags : u32, lpwidecharstr : PCWSTR, cchwidechar : i32, lpmultibytestr : PSTR, cbmultibyte : i32, lpdefaultchar : PCSTR, lpuseddefaultchar : *mut BOOL) -> i32); -windows_targets::link!("kernel32.dll" "system" fn WriteConsoleW(hconsoleoutput : HANDLE, lpbuffer : PCWSTR, nnumberofcharstowrite : u32, lpnumberofcharswritten : *mut u32, lpreserved : *const core::ffi::c_void) -> BOOL); -windows_targets::link!("kernel32.dll" "system" fn WriteFileEx(hfile : HANDLE, lpbuffer : *const u8, nnumberofbytestowrite : u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPOVERLAPPED_COMPLETION_ROUTINE) -> BOOL); -windows_targets::link!("ntdll.dll" "system" fn NtCreateFile(filehandle : *mut HANDLE, desiredaccess : FILE_ACCESS_RIGHTS, objectattributes : *const OBJECT_ATTRIBUTES, iostatusblock : *mut IO_STATUS_BLOCK, allocationsize : *const i64, fileattributes : FILE_FLAGS_AND_ATTRIBUTES, shareaccess : FILE_SHARE_MODE, createdisposition : NTCREATEFILE_CREATE_DISPOSITION, createoptions : NTCREATEFILE_CREATE_OPTIONS, eabuffer : *const core::ffi::c_void, ealength : u32) -> NTSTATUS); -windows_targets::link!("ntdll.dll" "system" fn NtOpenFile(filehandle : *mut HANDLE, desiredaccess : u32, objectattributes : *const OBJECT_ATTRIBUTES, iostatusblock : *mut IO_STATUS_BLOCK, shareaccess : u32, openoptions : u32) -> NTSTATUS); -windows_targets::link!("ntdll.dll" "system" fn NtReadFile(filehandle : HANDLE, event : HANDLE, apcroutine : PIO_APC_ROUTINE, apccontext : *const core::ffi::c_void, iostatusblock : *mut IO_STATUS_BLOCK, buffer : *mut core::ffi::c_void, length : u32, byteoffset : *const i64, key : *const u32) -> NTSTATUS); -windows_targets::link!("ntdll.dll" "system" fn NtWriteFile(filehandle : HANDLE, event : HANDLE, apcroutine : PIO_APC_ROUTINE, apccontext : *const core::ffi::c_void, iostatusblock : *mut IO_STATUS_BLOCK, buffer : *const core::ffi::c_void, length : u32, byteoffset : *const i64, key : *const u32) -> NTSTATUS); -windows_targets::link!("ntdll.dll" "system" fn RtlNtStatusToDosError(status : NTSTATUS) -> u32); -windows_targets::link!("userenv.dll" "system" fn GetUserProfileDirectoryW(htoken : HANDLE, lpprofiledir : PWSTR, lpcchsize : *mut u32) -> BOOL); windows_targets::link!("ws2_32.dll" "system" fn WSACleanup() -> i32); windows_targets::link!("ws2_32.dll" "system" fn WSADuplicateSocketW(s : SOCKET, dwprocessid : u32, lpprotocolinfo : *mut WSAPROTOCOL_INFOW) -> i32); windows_targets::link!("ws2_32.dll" "system" fn WSAGetLastError() -> WSA_ERROR); @@ -119,6 +114,13 @@ windows_targets::link!("ws2_32.dll" "system" fn WSARecv(s : SOCKET, lpbuffers : windows_targets::link!("ws2_32.dll" "system" fn WSASend(s : SOCKET, lpbuffers : *const WSABUF, dwbuffercount : u32, lpnumberofbytessent : *mut u32, dwflags : u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE) -> i32); windows_targets::link!("ws2_32.dll" "system" fn WSASocketW(af : i32, r#type : i32, protocol : i32, lpprotocolinfo : *const WSAPROTOCOL_INFOW, g : u32, dwflags : u32) -> SOCKET); windows_targets::link!("ws2_32.dll" "system" fn WSAStartup(wversionrequested : u16, lpwsadata : *mut WSADATA) -> i32); +windows_targets::link!("kernel32.dll" "system" fn WaitForMultipleObjects(ncount : u32, lphandles : *const HANDLE, bwaitall : BOOL, dwmilliseconds : u32) -> WAIT_EVENT); +windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT); +windows_targets::link!("kernel32.dll" "system" fn WakeAllConditionVariable(conditionvariable : *mut CONDITION_VARIABLE)); +windows_targets::link!("kernel32.dll" "system" fn WakeConditionVariable(conditionvariable : *mut CONDITION_VARIABLE)); +windows_targets::link!("kernel32.dll" "system" fn WideCharToMultiByte(codepage : u32, dwflags : u32, lpwidecharstr : PCWSTR, cchwidechar : i32, lpmultibytestr : PSTR, cbmultibyte : i32, lpdefaultchar : PCSTR, lpuseddefaultchar : *mut BOOL) -> i32); +windows_targets::link!("kernel32.dll" "system" fn WriteConsoleW(hconsoleoutput : HANDLE, lpbuffer : PCWSTR, nnumberofcharstowrite : u32, lpnumberofcharswritten : *mut u32, lpreserved : *const core::ffi::c_void) -> BOOL); +windows_targets::link!("kernel32.dll" "system" fn WriteFileEx(hfile : HANDLE, lpbuffer : *const u8, nnumberofbytestowrite : u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPOVERLAPPED_COMPLETION_ROUTINE) -> BOOL); windows_targets::link!("ws2_32.dll" "system" fn accept(s : SOCKET, addr : *mut SOCKADDR, addrlen : *mut i32) -> SOCKET); windows_targets::link!("ws2_32.dll" "system" fn bind(s : SOCKET, name : *const SOCKADDR, namelen : i32) -> i32); windows_targets::link!("ws2_32.dll" "system" fn closesocket(s : SOCKET) -> i32); @@ -138,6 +140,15 @@ windows_targets::link!("ws2_32.dll" "system" fn sendto(s : SOCKET, buf : PCSTR, windows_targets::link!("ws2_32.dll" "system" fn setsockopt(s : SOCKET, level : i32, optname : i32, optval : PCSTR, optlen : i32) -> i32); windows_targets::link!("ws2_32.dll" "system" fn shutdown(s : SOCKET, how : WINSOCK_SHUTDOWN_HOW) -> i32); pub const ABOVE_NORMAL_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 32768u32; +#[repr(C)] +#[derive(Clone, Copy)] +pub struct ACL { + pub AclRevision: u8, + pub Sbz1: u8, + pub AclSize: u16, + pub AceCount: u16, + pub Sbz2: u16, +} pub type ADDRESS_FAMILY = u16; #[repr(C)] #[derive(Clone, Copy)] @@ -173,7 +184,6 @@ pub struct ARM64_NT_NEON128_0 { } pub const BELOW_NORMAL_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 16384u32; pub type BOOL = i32; -pub type BOOLEAN = u8; #[repr(C)] #[derive(Clone, Copy)] pub struct BY_HANDLE_FILE_INFORMATION { @@ -206,64 +216,34 @@ pub struct CONSOLE_READCONSOLE_CONTROL { pub dwControlKeyState: u32, } #[repr(C)] -#[cfg(target_arch = "aarch64")] +#[cfg(target_arch = "x86")] #[derive(Clone, Copy)] pub struct CONTEXT { pub ContextFlags: CONTEXT_FLAGS, - pub Cpsr: u32, - pub Anonymous: CONTEXT_0, - pub Sp: u64, - pub Pc: u64, - pub V: [ARM64_NT_NEON128; 32], - pub Fpcr: u32, - pub Fpsr: u32, - pub Bcr: [u32; 8], - pub Bvr: [u64; 8], - pub Wcr: [u32; 2], - pub Wvr: [u64; 2], -} -#[repr(C)] -#[cfg(target_arch = "aarch64")] -#[derive(Clone, Copy)] -pub union CONTEXT_0 { - pub Anonymous: CONTEXT_0_0, - pub X: [u64; 31], -} -#[repr(C)] -#[cfg(target_arch = "aarch64")] -#[derive(Clone, Copy)] -pub struct CONTEXT_0_0 { - pub X0: u64, - pub X1: u64, - pub X2: u64, - pub X3: u64, - pub X4: u64, - pub X5: u64, - pub X6: u64, - pub X7: u64, - pub X8: u64, - pub X9: u64, - pub X10: u64, - pub X11: u64, - pub X12: u64, - pub X13: u64, - pub X14: u64, - pub X15: u64, - pub X16: u64, - pub X17: u64, - pub X18: u64, - pub X19: u64, - pub X20: u64, - pub X21: u64, - pub X22: u64, - pub X23: u64, - pub X24: u64, - pub X25: u64, - pub X26: u64, - pub X27: u64, - pub X28: u64, - pub Fp: u64, - pub Lr: u64, + pub Dr0: u32, + pub Dr1: u32, + pub Dr2: u32, + pub Dr3: u32, + pub Dr6: u32, + pub Dr7: u32, + pub FloatSave: FLOATING_SAVE_AREA, + pub SegGs: u32, + pub SegFs: u32, + pub SegEs: u32, + pub SegDs: u32, + pub Edi: u32, + pub Esi: u32, + pub Ebx: u32, + pub Edx: u32, + pub Ecx: u32, + pub Eax: u32, + pub Ebp: u32, + pub Eip: u32, + pub SegCs: u32, + pub EFlags: u32, + pub Esp: u32, + pub SegSs: u32, + pub ExtendedRegisters: [u8; 512], } #[repr(C)] #[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] @@ -347,36 +327,68 @@ pub struct CONTEXT_0_0 { pub Xmm15: M128A, } #[repr(C)] -#[cfg(target_arch = "x86")] +#[cfg(target_arch = "aarch64")] #[derive(Clone, Copy)] pub struct CONTEXT { pub ContextFlags: CONTEXT_FLAGS, - pub Dr0: u32, - pub Dr1: u32, - pub Dr2: u32, - pub Dr3: u32, - pub Dr6: u32, - pub Dr7: u32, - pub FloatSave: FLOATING_SAVE_AREA, - pub SegGs: u32, - pub SegFs: u32, - pub SegEs: u32, - pub SegDs: u32, - pub Edi: u32, - pub Esi: u32, - pub Ebx: u32, - pub Edx: u32, - pub Ecx: u32, - pub Eax: u32, - pub Ebp: u32, - pub Eip: u32, - pub SegCs: u32, - pub EFlags: u32, - pub Esp: u32, - pub SegSs: u32, - pub ExtendedRegisters: [u8; 512], + pub Cpsr: u32, + pub Anonymous: CONTEXT_0, + pub Sp: u64, + pub Pc: u64, + pub V: [ARM64_NT_NEON128; 32], + pub Fpcr: u32, + pub Fpsr: u32, + pub Bcr: [u32; 8], + pub Bvr: [u64; 8], + pub Wcr: [u32; 2], + pub Wvr: [u64; 2], +} +#[repr(C)] +#[cfg(target_arch = "aarch64")] +#[derive(Clone, Copy)] +pub union CONTEXT_0 { + pub Anonymous: CONTEXT_0_0, + pub X: [u64; 31], +} +#[repr(C)] +#[cfg(target_arch = "aarch64")] +#[derive(Clone, Copy)] +pub struct CONTEXT_0_0 { + pub X0: u64, + pub X1: u64, + pub X2: u64, + pub X3: u64, + pub X4: u64, + pub X5: u64, + pub X6: u64, + pub X7: u64, + pub X8: u64, + pub X9: u64, + pub X10: u64, + pub X11: u64, + pub X12: u64, + pub X13: u64, + pub X14: u64, + pub X15: u64, + pub X16: u64, + pub X17: u64, + pub X18: u64, + pub X19: u64, + pub X20: u64, + pub X21: u64, + pub X22: u64, + pub X23: u64, + pub X24: u64, + pub X25: u64, + pub X26: u64, + pub X27: u64, + pub X28: u64, + pub Fp: u64, + pub Lr: u64, } pub type CONTEXT_FLAGS = u32; +pub type COPYFILE_FLAGS = u32; +pub type COPYPROGRESSROUTINE_PROGRESS = u32; pub const CP_UTF8: u32 = 65001u32; pub const CREATE_ALWAYS: FILE_CREATION_DISPOSITION = 2u32; pub const CREATE_BREAKAWAY_FROM_JOB: PROCESS_CREATION_FLAGS = 16777216u32; @@ -2395,7 +2407,7 @@ pub const FILE_DISPOSITION_FLAG_POSIX_SEMANTICS: FILE_DISPOSITION_INFO_EX_FLAGS #[repr(C)] #[derive(Clone, Copy)] pub struct FILE_DISPOSITION_INFO { - pub DeleteFile: BOOLEAN, + pub DeleteFile: bool, } #[repr(C)] #[derive(Clone, Copy)] @@ -2472,6 +2484,22 @@ pub const FILE_RANDOM_ACCESS: NTCREATEFILE_CREATE_OPTIONS = 2048u32; pub const FILE_READ_ATTRIBUTES: FILE_ACCESS_RIGHTS = 128u32; pub const FILE_READ_DATA: FILE_ACCESS_RIGHTS = 1u32; pub const FILE_READ_EA: FILE_ACCESS_RIGHTS = 8u32; +pub const FILE_RENAME_FLAG_POSIX_SEMANTICS: u32 = 2u32; +pub const FILE_RENAME_FLAG_REPLACE_IF_EXISTS: u32 = 1u32; +#[repr(C)] +#[derive(Clone, Copy)] +pub struct FILE_RENAME_INFO { + pub Anonymous: FILE_RENAME_INFO_0, + pub RootDirectory: HANDLE, + pub FileNameLength: u32, + pub FileName: [u16; 1], +} +#[repr(C)] +#[derive(Clone, Copy)] +pub union FILE_RENAME_INFO_0 { + pub ReplaceIfExists: bool, + pub Flags: u32, +} pub const FILE_RESERVE_OPFILTER: NTCREATEFILE_CREATE_OPTIONS = 1048576u32; pub const FILE_SEQUENTIAL_ONLY: NTCREATEFILE_CREATE_OPTIONS = 4u32; pub const FILE_SESSION_AWARE: NTCREATEFILE_CREATE_OPTIONS = 262144u32; @@ -2486,8 +2514,8 @@ pub struct FILE_STANDARD_INFO { pub AllocationSize: i64, pub EndOfFile: i64, pub NumberOfLinks: u32, - pub DeletePending: BOOLEAN, - pub Directory: BOOLEAN, + pub DeletePending: bool, + pub Directory: bool, } pub const FILE_SUPERSEDE: NTCREATEFILE_CREATE_DISPOSITION = 0u32; pub const FILE_SYNCHRONOUS_IO_ALERT: NTCREATEFILE_CREATE_OPTIONS = 16u32; @@ -2508,7 +2536,7 @@ pub type FINDEX_SEARCH_OPS = i32; pub type FIND_FIRST_EX_FLAGS = u32; pub const FIONBIO: i32 = -2147195266i32; #[repr(C)] -#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] +#[cfg(target_arch = "x86")] #[derive(Clone, Copy)] pub struct FLOATING_SAVE_AREA { pub ControlWord: u32, @@ -2519,10 +2547,10 @@ pub struct FLOATING_SAVE_AREA { pub DataOffset: u32, pub DataSelector: u32, pub RegisterArea: [u8; 80], - pub Cr0NpxState: u32, + pub Spare0: u32, } #[repr(C)] -#[cfg(target_arch = "x86")] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] #[derive(Clone, Copy)] pub struct FLOATING_SAVE_AREA { pub ControlWord: u32, @@ -2533,7 +2561,7 @@ pub struct FLOATING_SAVE_AREA { pub DataOffset: u32, pub DataSelector: u32, pub RegisterArea: [u8; 80], - pub Spare0: u32, + pub Cr0NpxState: u32, } pub const FORMAT_MESSAGE_ALLOCATE_BUFFER: FORMAT_MESSAGE_OPTIONS = 256u32; pub const FORMAT_MESSAGE_ARGUMENT_ARRAY: FORMAT_MESSAGE_OPTIONS = 8192u32; @@ -2601,6 +2629,7 @@ pub type HANDLE_FLAGS = u32; pub const HANDLE_FLAG_INHERIT: HANDLE_FLAGS = 1u32; pub const HANDLE_FLAG_PROTECT_FROM_CLOSE: HANDLE_FLAGS = 2u32; pub const HIGH_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 128u32; +pub type HINSTANCE = *mut core::ffi::c_void; pub type HLOCAL = *mut core::ffi::c_void; pub type HMODULE = *mut core::ffi::c_void; pub type HRESULT = i32; @@ -2754,7 +2783,7 @@ pub type LPPROGRESS_ROUTINE = Option< hsourcefile: HANDLE, hdestinationfile: HANDLE, lpdata: *const core::ffi::c_void, - ) -> u32, + ) -> COPYPROGRESSROUTINE_PROGRESS, >; pub type LPPROGRESS_ROUTINE_CALLBACK_REASON = u32; pub type LPTHREAD_START_ROUTINE = @@ -2805,11 +2834,12 @@ pub struct OBJECT_ATTRIBUTES { pub Length: u32, pub RootDirectory: HANDLE, pub ObjectName: *const UNICODE_STRING, - pub Attributes: u32, - pub SecurityDescriptor: *const core::ffi::c_void, - pub SecurityQualityOfService: *const core::ffi::c_void, + pub Attributes: OBJECT_ATTRIBUTE_FLAGS, + pub SecurityDescriptor: *const SECURITY_DESCRIPTOR, + pub SecurityQualityOfService: *const SECURITY_QUALITY_OF_SERVICE, } -pub const OBJ_DONT_REPARSE: i32 = 4096i32; +pub type OBJECT_ATTRIBUTE_FLAGS = u32; +pub const OBJ_DONT_REPARSE: OBJECT_ATTRIBUTE_FLAGS = 4096u32; pub const OPEN_ALWAYS: FILE_CREATION_DISPOSITION = 4u32; pub const OPEN_EXISTING: FILE_CREATION_DISPOSITION = 3u32; #[repr(C)] @@ -2870,7 +2900,8 @@ pub const PROCESS_MODE_BACKGROUND_END: PROCESS_CREATION_FLAGS = 2097152u32; pub const PROFILE_KERNEL: PROCESS_CREATION_FLAGS = 536870912u32; pub const PROFILE_SERVER: PROCESS_CREATION_FLAGS = 1073741824u32; pub const PROFILE_USER: PROCESS_CREATION_FLAGS = 268435456u32; -pub const PROGRESS_CONTINUE: u32 = 0u32; +pub const PROGRESS_CONTINUE: COPYPROGRESSROUTINE_PROGRESS = 0u32; +pub type PSID = *mut core::ffi::c_void; pub type PSTR = *mut u8; pub type PTIMERAPCROUTINE = Option< unsafe extern "system" fn( @@ -2897,9 +2928,30 @@ pub struct SECURITY_ATTRIBUTES { } pub const SECURITY_CONTEXT_TRACKING: FILE_FLAGS_AND_ATTRIBUTES = 262144u32; pub const SECURITY_DELEGATION: FILE_FLAGS_AND_ATTRIBUTES = 196608u32; +#[repr(C)] +#[derive(Clone, Copy)] +pub struct SECURITY_DESCRIPTOR { + pub Revision: u8, + pub Sbz1: u8, + pub Control: SECURITY_DESCRIPTOR_CONTROL, + pub Owner: PSID, + pub Group: PSID, + pub Sacl: *mut ACL, + pub Dacl: *mut ACL, +} +pub type SECURITY_DESCRIPTOR_CONTROL = u16; pub const SECURITY_EFFECTIVE_ONLY: FILE_FLAGS_AND_ATTRIBUTES = 524288u32; pub const SECURITY_IDENTIFICATION: FILE_FLAGS_AND_ATTRIBUTES = 65536u32; pub const SECURITY_IMPERSONATION: FILE_FLAGS_AND_ATTRIBUTES = 131072u32; +pub type SECURITY_IMPERSONATION_LEVEL = i32; +#[repr(C)] +#[derive(Clone, Copy)] +pub struct SECURITY_QUALITY_OF_SERVICE { + pub Length: u32, + pub ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL, + pub ContextTrackingMode: u8, + pub EffectiveOnly: bool, +} pub const SECURITY_SQOS_PRESENT: FILE_FLAGS_AND_ATTRIBUTES = 1048576u32; pub const SECURITY_VALID_SQOS_FLAGS: FILE_FLAGS_AND_ATTRIBUTES = 2031616u32; pub type SEND_RECV_FLAGS = i32; @@ -3120,28 +3172,28 @@ pub struct WSABUF { pub buf: PSTR, } #[repr(C)] -#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] +#[cfg(target_arch = "x86")] #[derive(Clone, Copy)] pub struct WSADATA { pub wVersion: u16, pub wHighVersion: u16, + pub szDescription: [i8; 257], + pub szSystemStatus: [i8; 129], pub iMaxSockets: u16, pub iMaxUdpDg: u16, pub lpVendorInfo: PSTR, - pub szDescription: [i8; 257], - pub szSystemStatus: [i8; 129], } #[repr(C)] -#[cfg(target_arch = "x86")] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] #[derive(Clone, Copy)] pub struct WSADATA { pub wVersion: u16, pub wHighVersion: u16, - pub szDescription: [i8; 257], - pub szSystemStatus: [i8; 129], pub iMaxSockets: u16, pub iMaxUdpDg: u16, pub lpVendorInfo: PSTR, + pub szDescription: [i8; 257], + pub szSystemStatus: [i8; 129], } pub const WSAEACCES: WSA_ERROR = 10013i32; pub const WSAEADDRINUSE: WSA_ERROR = 10048i32; @@ -3276,7 +3328,7 @@ pub const WSA_SECURE_HOST_NOT_FOUND: WSA_ERROR = 11032i32; pub const WSA_WAIT_EVENT_0: WSA_ERROR = 0i32; pub const WSA_WAIT_IO_COMPLETION: WSA_ERROR = 192i32; #[repr(C)] -#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] +#[cfg(target_arch = "x86")] #[derive(Clone, Copy)] pub struct XSAVE_FORMAT { pub ControlWord: u16, @@ -3293,11 +3345,11 @@ pub struct XSAVE_FORMAT { pub MxCsr: u32, pub MxCsr_Mask: u32, pub FloatRegisters: [M128A; 8], - pub XmmRegisters: [M128A; 16], - pub Reserved4: [u8; 96], + pub XmmRegisters: [M128A; 8], + pub Reserved4: [u8; 224], } #[repr(C)] -#[cfg(target_arch = "x86")] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] #[derive(Clone, Copy)] pub struct XSAVE_FORMAT { pub ControlWord: u16, @@ -3314,9 +3366,10 @@ pub struct XSAVE_FORMAT { pub MxCsr: u32, pub MxCsr_Mask: u32, pub FloatRegisters: [M128A; 8], - pub XmmRegisters: [M128A; 8], - pub Reserved4: [u8; 224], + pub XmmRegisters: [M128A; 16], + pub Reserved4: [u8; 96], } + #[cfg(target_arch = "arm")] #[repr(C)] pub struct WSADATA { diff --git a/std/src/sys/pal/windows/compat.rs b/std/src/sys/pal/windows/compat.rs index 42999da166451..2b9838437e9c1 100644 --- a/std/src/sys/pal/windows/compat.rs +++ b/std/src/sys/pal/windows/compat.rs @@ -39,7 +39,7 @@ use crate::sys::c; // See https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-initialization?view=msvc-170 #[cfg(target_vendor = "win7")] #[used] -#[link_section = ".CRT$XCT"] +#[unsafe(link_section = ".CRT$XCT")] static INIT_TABLE_ENTRY: unsafe extern "C" fn() = init; /// Preload some imported functions. diff --git a/std/src/sys/pal/windows/futex.rs b/std/src/sys/pal/windows/futex.rs index 38afb8c043b3b..aebf638239ca9 100644 --- a/std/src/sys/pal/windows/futex.rs +++ b/std/src/sys/pal/windows/futex.rs @@ -1,10 +1,10 @@ use core::ffi::c_void; +use core::ptr; use core::sync::atomic::{ AtomicBool, AtomicI8, AtomicI16, AtomicI32, AtomicI64, AtomicIsize, AtomicPtr, AtomicU8, AtomicU16, AtomicU32, AtomicU64, AtomicUsize, }; use core::time::Duration; -use core::{mem, ptr}; use super::api::{self, WinError}; use crate::sys::{c, dur2timeout}; @@ -61,7 +61,7 @@ pub fn wait_on_address( ) -> bool { unsafe { let addr = ptr::from_ref(address).cast::(); - let size = mem::size_of::(); + let size = size_of::(); let compare_addr = (&raw const compare).cast::(); let timeout = timeout.map(dur2timeout).unwrap_or(c::INFINITE); c::WaitOnAddress(addr, compare_addr, size, timeout) == c::TRUE diff --git a/std/src/sys/pal/windows/mod.rs b/std/src/sys/pal/windows/mod.rs index aca69490d7a1a..6eb68f3a3bc41 100644 --- a/std/src/sys/pal/windows/mod.rs +++ b/std/src/sys/pal/windows/mod.rs @@ -17,16 +17,12 @@ pub mod api; pub mod args; pub mod c; pub mod env; -pub mod fs; #[cfg(not(target_vendor = "win7"))] pub mod futex; pub mod handle; -pub mod io; -pub mod net; pub mod os; pub mod pipe; pub mod process; -pub mod stdio; pub mod thread; pub mod time; cfg_if::cfg_if! { @@ -39,7 +35,7 @@ cfg_if::cfg_if! { } /// Map a [`Result`] to [`io::Result`](crate::io::Result). -trait IoResult { +pub trait IoResult { fn io_result(self) -> crate::io::Result; } impl IoResult for Result { @@ -63,7 +59,7 @@ pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) { // SAFETY: must be called only once during runtime cleanup. // NOTE: this is not guaranteed to run, for example when the program aborts. pub unsafe fn cleanup() { - net::cleanup(); + crate::sys::net::cleanup(); } #[inline] @@ -113,7 +109,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { c::ERROR_WRITE_PROTECT => return ReadOnlyFilesystem, c::ERROR_DISK_FULL | c::ERROR_HANDLE_DISK_FULL => return StorageFull, c::ERROR_SEEK_ON_DEVICE => return NotSeekable, - c::ERROR_DISK_QUOTA_EXCEEDED => return FilesystemQuotaExceeded, + c::ERROR_DISK_QUOTA_EXCEEDED => return QuotaExceeded, c::ERROR_FILE_TOO_LARGE => return FileTooLarge, c::ERROR_BUSY => return ResourceBusy, c::ERROR_POSSIBLE_DEADLOCK => return Deadlock, @@ -138,7 +134,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { c::WSAEHOSTUNREACH => HostUnreachable, c::WSAENETDOWN => NetworkDown, c::WSAENETUNREACH => NetworkUnreachable, - c::WSAEDQUOT => FilesystemQuotaExceeded, + c::WSAEDQUOT => QuotaExceeded, _ => Uncategorized, } @@ -183,7 +179,7 @@ pub fn to_u16s>(s: S) -> crate::io::Result> { maybe_result.extend(s.encode_wide()); if unrolled_find_u16s(0, &maybe_result).is_some() { - return Err(crate::io::const_io_error!( + return Err(crate::io::const_error!( ErrorKind::InvalidInput, "strings passed to WinAPI cannot contain NULs", )); @@ -272,7 +268,7 @@ where unreachable!(); } else { // Safety: First `k` values are initialized. - let slice: &[u16] = MaybeUninit::slice_assume_init_ref(&buf[..k]); + let slice: &[u16] = buf[..k].assume_init_ref(); return Ok(f2(slice)); } } diff --git a/std/src/sys/pal/windows/os.rs b/std/src/sys/pal/windows/os.rs index 5242bc9da31fe..044dc2e8cd8fa 100644 --- a/std/src/sys/pal/windows/os.rs +++ b/std/src/sys/pal/windows/os.rs @@ -5,8 +5,9 @@ #[cfg(test)] mod tests; -use super::api::{self, WinError}; -use super::to_u16s; +#[cfg(not(target_vendor = "uwp"))] +use super::api::WinError; +use super::{api, to_u16s}; use crate::error::Error as StdError; use crate::ffi::{OsStr, OsString}; use crate::os::windows::ffi::EncodeWide; @@ -377,8 +378,8 @@ fn home_dir_crt() -> Option { } pub fn home_dir() -> Option { - crate::env::var_os("HOME") - .or_else(|| crate::env::var_os("USERPROFILE")) + crate::env::var_os("USERPROFILE") + .filter(|s| !s.is_empty()) .map(PathBuf::from) .or_else(home_dir_crt) } diff --git a/std/src/sys/pal/windows/pipe.rs b/std/src/sys/pal/windows/pipe.rs index a8f6617c9dc8f..8521cf4162f5c 100644 --- a/std/src/sys/pal/windows/pipe.rs +++ b/std/src/sys/pal/windows/pipe.rs @@ -151,7 +151,7 @@ pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Res opts.write(ours_readable); opts.read(!ours_readable); opts.share_mode(0); - let size = mem::size_of::(); + let size = size_of::(); let mut sa = c::SECURITY_ATTRIBUTES { nLength: size as u32, lpSecurityDescriptor: ptr::null_mut(), diff --git a/std/src/sys/pal/windows/process.rs b/std/src/sys/pal/windows/process.rs index 17bb03fe7af04..c57ff355d124d 100644 --- a/std/src/sys/pal/windows/process.rs +++ b/std/src/sys/pal/windows/process.rs @@ -10,10 +10,10 @@ use crate::collections::BTreeMap; use crate::env::consts::{EXE_EXTENSION, EXE_SUFFIX}; use crate::ffi::{OsStr, OsString}; use crate::io::{self, Error, ErrorKind}; -use crate::mem::MaybeUninit; use crate::num::NonZero; use crate::os::windows::ffi::{OsStrExt, OsStringExt}; use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle}; +use crate::os::windows::process::ProcThreadAttributeList; use crate::path::{Path, PathBuf}; use crate::sync::Mutex; use crate::sys::args::{self, Arg}; @@ -24,7 +24,7 @@ use crate::sys::pipe::{self, AnonPipe}; use crate::sys::{cvt, path, stdio}; use crate::sys_common::IntoInner; use crate::sys_common::process::{CommandEnv, CommandEnvs}; -use crate::{cmp, env, fmt, mem, ptr}; +use crate::{cmp, env, fmt, ptr}; //////////////////////////////////////////////////////////////////////////////// // Command @@ -142,11 +142,11 @@ impl AsRef for EnvKey { } } -pub(crate) fn ensure_no_nuls>(str: T) -> io::Result { - if str.as_ref().encode_wide().any(|b| b == 0) { - Err(io::const_io_error!(ErrorKind::InvalidInput, "nul byte found in provided data")) +pub(crate) fn ensure_no_nuls>(s: T) -> io::Result { + if s.as_ref().encode_wide().any(|b| b == 0) { + Err(io::const_error!(ErrorKind::InvalidInput, "nul byte found in provided data")) } else { - Ok(str) + Ok(s) } } @@ -162,7 +162,6 @@ pub struct Command { stdout: Option, stderr: Option, force_quotes_enabled: bool, - proc_thread_attributes: BTreeMap, } pub enum Stdio { @@ -194,7 +193,6 @@ impl Command { stdout: None, stderr: None, force_quotes_enabled: false, - proc_thread_attributes: Default::default(), } } @@ -248,25 +246,24 @@ impl Command { self.cwd.as_ref().map(Path::new) } - pub unsafe fn raw_attribute( + pub fn spawn( &mut self, - attribute: usize, - value: T, - ) { - self.proc_thread_attributes.insert(attribute, ProcThreadAttributeValue { - size: mem::size_of::(), - data: Box::new(value), - }); + default: Stdio, + needs_stdin: bool, + ) -> io::Result<(Process, StdioPipes)> { + self.spawn_with_attributes(default, needs_stdin, None) } - pub fn spawn( + pub fn spawn_with_attributes( &mut self, default: Stdio, needs_stdin: bool, + proc_thread_attribute_list: Option<&ProcThreadAttributeList<'_>>, ) -> io::Result<(Process, StdioPipes)> { + let env_saw_path = self.env.have_changed_path(); let maybe_env = self.env.capture_if_changed(); - let child_paths = if let Some(env) = maybe_env.as_ref() { + let child_paths = if env_saw_path && let Some(env) = maybe_env.as_ref() { env.get(&EnvKey::new("PATH")).map(|s| s.as_os_str()) } else { None @@ -355,22 +352,22 @@ impl Command { let si_ptr: *mut c::STARTUPINFOW; - let mut proc_thread_attribute_list; let mut si_ex; - if !self.proc_thread_attributes.is_empty() { - si.cb = mem::size_of::() as u32; + if let Some(proc_thread_attribute_list) = proc_thread_attribute_list { + si.cb = size_of::() as u32; flags |= c::EXTENDED_STARTUPINFO_PRESENT; - proc_thread_attribute_list = - make_proc_thread_attribute_list(&self.proc_thread_attributes)?; si_ex = c::STARTUPINFOEXW { StartupInfo: si, - lpAttributeList: proc_thread_attribute_list.0.as_mut_ptr() as _, + // SAFETY: Casting this `*const` pointer to a `*mut` pointer is "safe" + // here because windows does not internally mutate the attribute list. + // Ideally this should be reflected in the interface of the `windows-sys` crate. + lpAttributeList: proc_thread_attribute_list.as_ptr().cast::().cast_mut(), }; si_ptr = (&raw mut si_ex) as _; } else { - si.cb = mem::size_of::() as u32; + si.cb = size_of::() as u32; si_ptr = (&raw mut si) as _; } @@ -439,10 +436,7 @@ fn resolve_exe<'a>( ) -> io::Result> { // Early return if there is no filename. if exe_path.is_empty() || path::has_trailing_slash(exe_path) { - return Err(io::const_io_error!( - io::ErrorKind::InvalidInput, - "program path has no file name", - )); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "program path has no file name")); } // Test if the file name has the `exe` extension. // This does a case-insensitive `ends_with`. @@ -492,7 +486,7 @@ fn resolve_exe<'a>( } } // If we get here then the executable cannot be found. - Err(io::const_io_error!(io::ErrorKind::NotFound, "program not found")) + Err(io::const_error!(io::ErrorKind::NotFound, "program not found")) } // Calls `f` for every path that should be used to find an executable. @@ -605,7 +599,7 @@ impl Stdio { // permissions as well as the ability to be inherited to child // processes (as this is about to be inherited). Stdio::Null => { - let size = mem::size_of::(); + let size = size_of::(); let mut sa = c::SECURITY_ATTRIBUTES { nLength: size as u32, lpSecurityDescriptor: ptr::null_mut(), @@ -897,79 +891,6 @@ fn make_dirp(d: Option<&OsString>) -> io::Result<(*const u16, Vec)> { } } -struct ProcThreadAttributeList(Box<[MaybeUninit]>); - -impl Drop for ProcThreadAttributeList { - fn drop(&mut self) { - let lp_attribute_list = self.0.as_mut_ptr() as _; - unsafe { c::DeleteProcThreadAttributeList(lp_attribute_list) } - } -} - -/// Wrapper around the value data to be used as a Process Thread Attribute. -struct ProcThreadAttributeValue { - data: Box, - size: usize, -} - -fn make_proc_thread_attribute_list( - attributes: &BTreeMap, -) -> io::Result { - // To initialize our ProcThreadAttributeList, we need to determine - // how many bytes to allocate for it. The Windows API simplifies this process - // by allowing us to call `InitializeProcThreadAttributeList` with - // a null pointer to retrieve the required size. - let mut required_size = 0; - let Ok(attribute_count) = attributes.len().try_into() else { - return Err(io::const_io_error!( - ErrorKind::InvalidInput, - "maximum number of ProcThreadAttributes exceeded", - )); - }; - unsafe { - c::InitializeProcThreadAttributeList( - ptr::null_mut(), - attribute_count, - 0, - &mut required_size, - ) - }; - - let mut proc_thread_attribute_list = - ProcThreadAttributeList(vec![MaybeUninit::uninit(); required_size].into_boxed_slice()); - - // Once we've allocated the necessary memory, it's safe to invoke - // `InitializeProcThreadAttributeList` to properly initialize the list. - cvt(unsafe { - c::InitializeProcThreadAttributeList( - proc_thread_attribute_list.0.as_mut_ptr() as *mut _, - attribute_count, - 0, - &mut required_size, - ) - })?; - - // # Add our attributes to the buffer. - // It's theoretically possible for the attribute count to exceed a u32 value. - // Therefore, we ensure that we don't add more attributes than the buffer was initialized for. - for (&attribute, value) in attributes.iter().take(attribute_count as usize) { - let value_ptr = (&raw const *value.data) as _; - cvt(unsafe { - c::UpdateProcThreadAttribute( - proc_thread_attribute_list.0.as_mut_ptr() as _, - 0, - attribute, - value_ptr, - value.size, - ptr::null_mut(), - ptr::null_mut(), - ) - })?; - } - - Ok(proc_thread_attribute_list) -} - pub struct CommandArgs<'a> { iter: crate::slice::Iter<'a, Arg>, } diff --git a/std/src/sys/pal/windows/process/tests.rs b/std/src/sys/pal/windows/process/tests.rs index 1bcc5fa6b2048..1377e12162f2f 100644 --- a/std/src/sys/pal/windows/process/tests.rs +++ b/std/src/sys/pal/windows/process/tests.rs @@ -33,7 +33,7 @@ fn test_thread_handle() { assert!(p.is_ok()); let mut p = p.unwrap(); - extern "system" { + unsafe extern "system" { fn ResumeThread(_: BorrowedHandle<'_>) -> u32; } unsafe { @@ -138,8 +138,10 @@ fn windows_env_unicode_case() { let mut cmd = Command::new("cmd"); cmd.env(a, "1"); cmd.env(b, "2"); - env::set_var(a, "1"); - env::set_var(b, "2"); + unsafe { + env::set_var(a, "1"); + env::set_var(b, "2"); + } for (key, value) in cmd.get_envs() { assert_eq!( @@ -158,7 +160,7 @@ fn windows_exe_resolver() { use super::resolve_exe; use crate::io; use crate::sys::fs::symlink; - use crate::sys_common::io::test::tmpdir; + use crate::test_helpers::tmpdir; let env_paths = || env::var_os("PATH"); diff --git a/std/src/sys/pal/windows/stack_overflow.rs b/std/src/sys/pal/windows/stack_overflow.rs index 467e21ab56a28..734cd30bed08f 100644 --- a/std/src/sys/pal/windows/stack_overflow.rs +++ b/std/src/sys/pal/windows/stack_overflow.rs @@ -18,10 +18,10 @@ unsafe extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POIN let code = rec.ExceptionCode; if code == c::EXCEPTION_STACK_OVERFLOW { - rtprintpanic!( - "\nthread '{}' has overflowed its stack\n", - thread::current().name().unwrap_or("") - ); + thread::with_current_name(|name| { + let name = name.unwrap_or(""); + rtprintpanic!("\nthread '{name}' has overflowed its stack\n"); + }); } c::EXCEPTION_CONTINUE_SEARCH } diff --git a/std/src/sys/pal/windows/stack_overflow_uwp.rs b/std/src/sys/pal/windows/stack_overflow_uwp.rs index 9e9b3efaf1b14..6f1ea12fc1e06 100644 --- a/std/src/sys/pal/windows/stack_overflow_uwp.rs +++ b/std/src/sys/pal/windows/stack_overflow_uwp.rs @@ -1,4 +1,4 @@ #![cfg_attr(test, allow(dead_code))] -pub unsafe fn reserve_stack() {} -pub unsafe fn init() {} +pub fn reserve_stack() {} +pub fn init() {} diff --git a/std/src/sys/pal/windows/thread.rs b/std/src/sys/pal/windows/thread.rs index 2c8ce42f4148b..45e52cf4d047f 100644 --- a/std/src/sys/pal/windows/thread.rs +++ b/std/src/sys/pal/windows/thread.rs @@ -19,6 +19,7 @@ pub struct Thread { impl Thread { // unsafe: see thread::Builder::spawn_unchecked for safety requirements + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub unsafe fn new(stack: usize, p: Box) -> io::Result { let p = Box::into_raw(Box::new(p)); diff --git a/std/src/sys/pal/xous/mod.rs b/std/src/sys/pal/xous/mod.rs index a64cd06856006..7d823012ad145 100644 --- a/std/src/sys/pal/xous/mod.rs +++ b/std/src/sys/pal/xous/mod.rs @@ -3,17 +3,11 @@ pub mod args; #[path = "../unsupported/env.rs"] pub mod env; -#[path = "../unsupported/fs.rs"] -pub mod fs; -#[path = "../unsupported/io.rs"] -pub mod io; -pub mod net; pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; #[path = "../unsupported/process.rs"] pub mod process; -pub mod stdio; pub mod thread; pub mod time; diff --git a/std/src/sys/pal/xous/net/mod.rs b/std/src/sys/pal/xous/net/mod.rs deleted file mode 100644 index 3e18ed24208d3..0000000000000 --- a/std/src/sys/pal/xous/net/mod.rs +++ /dev/null @@ -1,83 +0,0 @@ -mod dns; - -mod tcpstream; -pub use tcpstream::*; - -mod tcplistener; -pub use tcplistener::*; - -mod udp; -pub use udp::*; - -// this structure needs to be synchronized with what's in net/src/api.rs -#[repr(C)] -#[derive(Debug)] -enum NetError { - // Ok = 0, - Unaddressable = 1, - SocketInUse = 2, - // AccessDenied = 3, - Invalid = 4, - // Finished = 5, - LibraryError = 6, - // AlreadyUsed = 7, - TimedOut = 8, - WouldBlock = 9, -} - -#[repr(C, align(4096))] -struct ConnectRequest { - raw: [u8; 4096], -} - -#[repr(C, align(4096))] -struct SendData { - raw: [u8; 4096], -} - -#[repr(C, align(4096))] -pub struct ReceiveData { - raw: [u8; 4096], -} - -#[repr(C, align(4096))] -pub struct GetAddress { - raw: [u8; 4096], -} - -pub use dns::LookupHost; - -#[allow(nonstandard_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/std/src/sys/pal/xous/os.rs b/std/src/sys/pal/xous/os.rs index b0ab01a6383d2..2c87e7d91f27d 100644 --- a/std/src/sys/pal/xous/os.rs +++ b/std/src/sys/pal/xous/os.rs @@ -37,16 +37,16 @@ mod eh_unwinding { #[cfg(not(test))] mod c_compat { use crate::os::xous::ffi::exit; - extern "C" { + unsafe extern "C" { fn main() -> u32; } - #[no_mangle] + #[unsafe(no_mangle)] pub extern "C" fn abort() { exit(1); } - #[no_mangle] + #[unsafe(no_mangle)] pub extern "C" fn _start(eh_frame: usize, params_address: usize) { #[cfg(feature = "panic_unwind")] { @@ -67,7 +67,7 @@ mod c_compat { // This function is needed by the panic runtime. The symbol is named in // pre-link args for the target specification, so keep that in sync. - #[no_mangle] + #[unsafe(no_mangle)] // NB. used by both libunwind and libpanic_abort pub extern "C" fn __rust_abort() -> ! { exit(101); diff --git a/std/src/sys/pal/zkvm/abi.rs b/std/src/sys/pal/zkvm/abi.rs index 53332d90e02c0..d000574f6844d 100644 --- a/std/src/sys/pal/zkvm/abi.rs +++ b/std/src/sys/pal/zkvm/abi.rs @@ -18,7 +18,7 @@ pub mod fileno { pub const JOURNAL: u32 = 3; } -extern "C" { +unsafe extern "C" { // Wrappers around syscalls provided by risc0-zkvm-platform: pub fn sys_halt(); pub fn sys_output(output_id: u32, output_value: u32); diff --git a/std/src/sys/pal/zkvm/mod.rs b/std/src/sys/pal/zkvm/mod.rs index 6ea057720296d..499e27872015f 100644 --- a/std/src/sys/pal/zkvm/mod.rs +++ b/std/src/sys/pal/zkvm/mod.rs @@ -8,24 +8,17 @@ //! will likely change over time. #![forbid(unsafe_op_in_unsafe_fn)] -const WORD_SIZE: usize = core::mem::size_of::(); +const WORD_SIZE: usize = size_of::(); pub mod abi; #[path = "../zkvm/args.rs"] pub mod args; pub mod env; -#[path = "../unsupported/fs.rs"] -pub mod fs; -#[path = "../unsupported/io.rs"] -pub mod io; -#[path = "../unsupported/net.rs"] -pub mod net; pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; #[path = "../unsupported/process.rs"] pub mod process; -pub mod stdio; #[path = "../unsupported/thread.rs"] pub mod thread; #[path = "../unsupported/time.rs"] diff --git a/std/src/sys/pal/zkvm/os.rs b/std/src/sys/pal/zkvm/os.rs index 5d224ffd1ba5a..868b19e33b672 100644 --- a/std/src/sys/pal/zkvm/os.rs +++ b/std/src/sys/pal/zkvm/os.rs @@ -115,11 +115,11 @@ pub fn getenv(varname: &OsStr) -> Option { } pub unsafe fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> { - Err(io::const_io_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform")) + Err(io::const_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform")) } pub unsafe fn unsetenv(_: &OsStr) -> io::Result<()> { - Err(io::const_io_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform")) + Err(io::const_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform")) } pub fn temp_dir() -> PathBuf { diff --git a/std/src/sys/path/mod.rs b/std/src/sys/path/mod.rs index 24a94ec782824..1fa4e80d6780c 100644 --- a/std/src/sys/path/mod.rs +++ b/std/src/sys/path/mod.rs @@ -5,12 +5,12 @@ cfg_if::cfg_if! { } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { mod sgx; pub use sgx::*; - } else if #[cfg(any( - target_os = "uefi", - target_os = "solid_asp3", - ))] { + } else if #[cfg(target_os = "solid_asp3")] { mod unsupported_backslash; pub use unsupported_backslash::*; + } else if #[cfg(target_os = "uefi")] { + mod uefi; + pub use uefi::*; } else { mod unix; pub use unix::*; diff --git a/std/src/sys/path/sgx.rs b/std/src/sys/path/sgx.rs index c805c15e70245..32c7752f605d9 100644 --- a/std/src/sys/path/sgx.rs +++ b/std/src/sys/path/sgx.rs @@ -23,3 +23,7 @@ pub const MAIN_SEP: char = '/'; pub(crate) fn absolute(_path: &Path) -> io::Result { unsupported() } + +pub(crate) fn is_absolute(path: &Path) -> bool { + path.has_root() && path.prefix().is_some() +} diff --git a/std/src/sys/path/uefi.rs b/std/src/sys/path/uefi.rs new file mode 100644 index 0000000000000..a3f4a3bfe1b67 --- /dev/null +++ b/std/src/sys/path/uefi.rs @@ -0,0 +1,105 @@ +#![forbid(unsafe_op_in_unsafe_fn)] +use crate::ffi::OsStr; +use crate::io; +use crate::path::{Path, PathBuf, Prefix}; +use crate::sys::{helpers, unsupported_err}; + +const FORWARD_SLASH: u8 = b'/'; +const COLON: u8 = b':'; + +#[inline] +pub fn is_sep_byte(b: u8) -> bool { + b == b'\\' +} + +#[inline] +pub fn is_verbatim_sep(b: u8) -> bool { + b == b'\\' +} + +pub fn parse_prefix(_: &OsStr) -> Option> { + None +} + +pub const MAIN_SEP_STR: &str = "\\"; +pub const MAIN_SEP: char = '\\'; + +/// UEFI paths can be of 4 types: +/// +/// 1. Absolute Shell Path: Uses shell mappings (eg: `FS0:`). Does not exist if UEFI shell not present. +/// It can be identified with `:`. +/// Eg: FS0:\abc\run.efi +/// +/// 2. Absolute Device Path: this is what we want +/// It can be identified with `/`. +/// Eg: PciRoot(0x0)/Pci(0x1,0x1)/Ata(Secondary,Slave,0x0)/\abc\run.efi +/// +/// 3: Relative root: path relative to the current volume. +/// It will start with `\`. +/// Eg: \abc\run.efi +/// +/// 4: Relative +/// Eg: run.efi +/// +/// The algorithm is mostly taken from edk2 UEFI shell implementation and is +/// somewhat simple. Check for the path type in order. +/// +/// The volume mapping in Absolute Shell Path (not the rest of the path) can be converted to Device +/// Path Protocol using `EFI_SHELL->GetDevicePathFromMap`. The rest of the path (Relative root +/// path), can just be appended to the remaining path. +/// +/// For Relative root, we get the current volume (either in Shell Mapping, or Device Path Protocol +/// form) and join it with the relative root path. We then recurse the function to resolve the Shell +/// Mapping if present. +/// +/// For Relative paths, we use the current working directory to construct +/// the new path and recurse the function to resolve the Shell mapping if present. +/// +/// Finally, at the end, we get the 2nd form, i.e. Absolute Device Path, which can be used in the +/// normal UEFI APIs such as file, process, etc. +/// Eg: PciRoot(0x0)/Pci(0x1,0x1)/Ata(Secondary,Slave,0x0)/\abc\run.efi +pub(crate) fn absolute(path: &Path) -> io::Result { + // Absolute Shell Path + if path.as_os_str().as_encoded_bytes().contains(&COLON) { + let mut path_components = path.components(); + // Since path is not empty, it has at least one Component + let prefix = path_components.next().unwrap(); + + let dev_path = helpers::get_device_path_from_map(prefix.as_ref())?; + let mut dev_path_text = dev_path.to_text().map_err(|_| unsupported_err())?; + + // UEFI Shell does not seem to end device path with `/` + if *dev_path_text.as_encoded_bytes().last().unwrap() != FORWARD_SLASH { + dev_path_text.push("/"); + } + + let mut ans = PathBuf::from(dev_path_text); + ans.push(path_components); + + return Ok(ans); + } + + // Absolute Device Path + if path.as_os_str().as_encoded_bytes().contains(&FORWARD_SLASH) { + return Ok(path.to_path_buf()); + } + + // cur_dir() always returns something + let cur_dir = crate::env::current_dir().unwrap(); + let mut path_components = path.components(); + + // Relative Root + if path_components.next().unwrap() == crate::path::Component::RootDir { + let mut ans = PathBuf::new(); + ans.push(cur_dir.components().next().unwrap()); + ans.push(path_components); + return absolute(&ans); + } + + absolute(&cur_dir.join(path)) +} + +pub(crate) fn is_absolute(path: &Path) -> bool { + let temp = path.as_os_str().as_encoded_bytes(); + temp.contains(&COLON) || temp.contains(&FORWARD_SLASH) +} diff --git a/std/src/sys/path/unix.rs b/std/src/sys/path/unix.rs index 2a7c025c3c46a..361e99964f18c 100644 --- a/std/src/sys/path/unix.rs +++ b/std/src/sys/path/unix.rs @@ -60,3 +60,14 @@ pub(crate) fn absolute(path: &Path) -> io::Result { Ok(normalized) } + +pub(crate) fn is_absolute(path: &Path) -> bool { + if cfg!(target_os = "redox") { + // FIXME: Allow Redox prefixes + path.has_root() || crate::path::has_redox_scheme(path.as_u8_slice()) + } else if cfg!(any(unix, target_os = "hermit", target_os = "wasi")) { + path.has_root() + } else { + path.has_root() && path.prefix().is_some() + } +} diff --git a/std/src/sys/path/unsupported_backslash.rs b/std/src/sys/path/unsupported_backslash.rs index 855f443678c6c..30b06c132c98d 100644 --- a/std/src/sys/path/unsupported_backslash.rs +++ b/std/src/sys/path/unsupported_backslash.rs @@ -24,3 +24,7 @@ pub const MAIN_SEP: char = '\\'; pub(crate) fn absolute(_path: &Path) -> io::Result { unsupported() } + +pub(crate) fn is_absolute(path: &Path) -> bool { + path.has_root() && path.prefix().is_some() +} diff --git a/std/src/sys/path/windows.rs b/std/src/sys/path/windows.rs index 9267602cb9715..1c53472191699 100644 --- a/std/src/sys/path/windows.rs +++ b/std/src/sys/path/windows.rs @@ -328,7 +328,7 @@ pub(crate) fn absolute(path: &Path) -> io::Result { if prefix.map(|x| x.is_verbatim()).unwrap_or(false) { // NULs in verbatim paths are rejected for consistency. if path.as_encoded_bytes().contains(&0) { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidInput, "strings passed to WinAPI cannot contain NULs", )); @@ -346,3 +346,7 @@ pub(crate) fn absolute(path: &Path) -> io::Result { os2path, ) } + +pub(crate) fn is_absolute(path: &Path) -> bool { + path.has_root() && path.prefix().is_some() +} diff --git a/std/src/sys/personality/dwarf/eh.rs b/std/src/sys/personality/dwarf/eh.rs index 778d8686f023e..ef5112ad74f13 100644 --- a/std/src/sys/personality/dwarf/eh.rs +++ b/std/src/sys/personality/dwarf/eh.rs @@ -12,7 +12,7 @@ #![allow(non_upper_case_globals)] #![allow(unused)] -use core::{mem, ptr}; +use core::ptr; use super::DwarfReader; @@ -245,8 +245,7 @@ unsafe fn read_encoded_pointer( DW_EH_PE_datarel => (*context.get_data_start)(), // aligned means the value is aligned to the size of a pointer DW_EH_PE_aligned => { - reader.ptr = - reader.ptr.with_addr(round_up(reader.ptr.addr(), mem::size_of::<*const u8>())?); + reader.ptr = reader.ptr.with_addr(round_up(reader.ptr.addr(), size_of::<*const u8>())?); core::ptr::null() } _ => return Err(()), diff --git a/std/src/sys/personality/dwarf/mod.rs b/std/src/sys/personality/dwarf/mod.rs index 5c52d96c4cad4..2bc91951b49fd 100644 --- a/std/src/sys/personality/dwarf/mod.rs +++ b/std/src/sys/personality/dwarf/mod.rs @@ -12,8 +12,6 @@ mod tests; pub mod eh; -use core::mem; - pub struct DwarfReader { pub ptr: *const u8, } @@ -29,7 +27,7 @@ impl DwarfReader { pub unsafe fn read(&mut self) -> T { unsafe { let result = self.ptr.cast::().read_unaligned(); - self.ptr = self.ptr.byte_add(mem::size_of::()); + self.ptr = self.ptr.byte_add(size_of::()); result } } diff --git a/std/src/sys/personality/gcc.rs b/std/src/sys/personality/gcc.rs index ad596ecff65d5..cd2c7899f4bf1 100644 --- a/std/src/sys/personality/gcc.rs +++ b/std/src/sys/personality/gcc.rs @@ -5,7 +5,7 @@ //! documents linked from it. //! These are also good reads: //! * -//! * +//! * //! * //! //! ## A brief summary @@ -194,7 +194,7 @@ cfg_if::cfg_if! { } } // defined in libgcc - extern "C" { + unsafe extern "C" { fn __gnu_unwind_frame( exception_object: *mut uw::_Unwind_Exception, context: *mut uw::_Unwind_Context, diff --git a/std/src/sys/personality/mod.rs b/std/src/sys/personality/mod.rs index 9754e840d151a..2e1d2e53a2979 100644 --- a/std/src/sys/personality/mod.rs +++ b/std/src/sys/personality/mod.rs @@ -31,7 +31,7 @@ cfg_if::cfg_if! { target_os = "psp", target_os = "xous", target_os = "solid_asp3", - all(target_family = "unix", not(target_os = "espidf"), not(target_os = "l4re"), not(target_os = "rtems"), not(target_os = "nuttx")), + all(target_family = "unix", not(target_os = "espidf"), not(target_os = "l4re"), not(target_os = "nuttx")), all(target_vendor = "fortanix", target_env = "sgx"), ))] { mod gcc; diff --git a/std/src/sys/random/arc4random.rs b/std/src/sys/random/arc4random.rs index 32467e9ebaa64..e1957bceb9002 100644 --- a/std/src/sys/random/arc4random.rs +++ b/std/src/sys/random/arc4random.rs @@ -25,7 +25,7 @@ use libc::arc4random_buf; target_os = "vita", // See https://github.com/vitasdk/newlib/blob/b89e5bc183b516945f9ee07eef483ecb916e45ff/newlib/libc/include/stdlib.h#L74 ))] #[cfg_attr(target_os = "haiku", link(name = "bsd"))] -extern "C" { +unsafe extern "C" { fn arc4random_buf(buf: *mut core::ffi::c_void, nbytes: libc::size_t); } diff --git a/std/src/sys/random/espidf.rs b/std/src/sys/random/espidf.rs index fd52cb5559ce5..6f48f7f1f2952 100644 --- a/std/src/sys/random/espidf.rs +++ b/std/src/sys/random/espidf.rs @@ -1,6 +1,6 @@ use crate::ffi::c_void; -extern "C" { +unsafe extern "C" { fn esp_fill_random(buf: *mut c_void, len: usize); } diff --git a/std/src/sys/random/fuchsia.rs b/std/src/sys/random/fuchsia.rs index 77d72b3c5b784..269e0d9aeeb57 100644 --- a/std/src/sys/random/fuchsia.rs +++ b/std/src/sys/random/fuchsia.rs @@ -4,7 +4,7 @@ //! . #[link(name = "zircon")] -extern "C" { +unsafe extern "C" { fn zx_cprng_draw(buffer: *mut u8, len: usize); } diff --git a/std/src/sys/random/teeos.rs b/std/src/sys/random/teeos.rs index fd6b24e19e982..6ca59cc12c98f 100644 --- a/std/src/sys/random/teeos.rs +++ b/std/src/sys/random/teeos.rs @@ -1,4 +1,4 @@ -extern "C" { +unsafe extern "C" { fn TEE_GenerateRandom(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t); } diff --git a/std/src/sys/random/windows.rs b/std/src/sys/random/windows.rs index 7566000f9e6ff..f5da637f56ca9 100644 --- a/std/src/sys/random/windows.rs +++ b/std/src/sys/random/windows.rs @@ -14,7 +14,7 @@ pub fn fill_bytes(mut bytes: &mut [u8]) { while !bytes.is_empty() { let len = bytes.len().try_into().unwrap_or(u32::MAX); let ret = unsafe { c::RtlGenRandom(bytes.as_mut_ptr().cast(), len) }; - assert_ne!(ret, 0, "failed to generate random data"); + assert!(ret, "failed to generate random data"); bytes = &mut bytes[len as usize..]; } } diff --git a/std/src/sys/stdio/mod.rs b/std/src/sys/stdio/mod.rs new file mode 100644 index 0000000000000..2a9167bfe966c --- /dev/null +++ b/std/src/sys/stdio/mod.rs @@ -0,0 +1,38 @@ +#![forbid(unsafe_op_in_unsafe_fn)] + +cfg_if::cfg_if! { + if #[cfg(any( + target_family = "unix", + target_os = "hermit" + ))] { + mod unix; + pub use unix::*; + } else if #[cfg(target_os = "windows")] { + mod windows; + pub use windows::*; + } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { + mod sgx; + pub use sgx::*; + } else if #[cfg(target_os = "solid_asp3")] { + mod solid; + pub use solid::*; + } else if #[cfg(target_os = "teeos")] { + mod teeos; + pub use teeos::*; + } else if #[cfg(target_os = "uefi")] { + mod uefi; + pub use uefi::*; + } else if #[cfg(target_os = "wasi")] { + mod wasi; + pub use wasi::*; + } else if #[cfg(target_os = "xous")] { + mod xous; + pub use xous::*; + } else if #[cfg(target_os = "zkvm")] { + mod zkvm; + pub use zkvm::*; + } else { + mod unsupported; + pub use unsupported::*; + } +} diff --git a/std/src/sys/pal/sgx/stdio.rs b/std/src/sys/stdio/sgx.rs similarity index 68% rename from std/src/sys/pal/sgx/stdio.rs rename to std/src/sys/stdio/sgx.rs index 2e680e740fde3..03d754cb2173f 100644 --- a/std/src/sys/pal/sgx/stdio.rs +++ b/std/src/sys/stdio/sgx.rs @@ -1,10 +1,6 @@ use fortanix_sgx_abi as abi; use crate::io; -#[cfg(not(test))] -use crate::slice; -#[cfg(not(test))] -use crate::str; use crate::sys::fd::FileDesc; pub struct Stdin(()); @@ -62,7 +58,7 @@ impl io::Write for Stderr { } } -pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE; +pub const STDIN_BUF_SIZE: usize = crate::sys::io::DEFAULT_BUF_SIZE; pub fn is_ebadf(err: &io::Error) -> bool { // FIXME: Rust normally maps Unix EBADF to `Uncategorized` @@ -70,19 +66,5 @@ pub fn is_ebadf(err: &io::Error) -> bool { } pub fn panic_output() -> Option { - super::abi::panic::SgxPanicOutput::new() -} - -// This function is needed by libunwind. The symbol is named in pre-link args -// for the target specification, so keep that in sync. -#[cfg(not(test))] -#[no_mangle] -pub unsafe extern "C" fn __rust_print_err(m: *mut u8, s: i32) { - if s < 0 { - return; - } - let buf = unsafe { slice::from_raw_parts(m as *const u8, s as _) }; - if let Ok(s) = str::from_utf8(&buf[..buf.iter().position(|&b| b == 0).unwrap_or(buf.len())]) { - eprint!("{s}"); - } + crate::sys::pal::abi::panic::SgxPanicOutput::new() } diff --git a/std/src/sys/pal/solid/stdio.rs b/std/src/sys/stdio/solid.rs similarity index 98% rename from std/src/sys/pal/solid/stdio.rs rename to std/src/sys/stdio/solid.rs index 50f0176967b2d..a2ff4bb212ff5 100644 --- a/std/src/sys/pal/solid/stdio.rs +++ b/std/src/sys/stdio/solid.rs @@ -1,5 +1,5 @@ -use super::abi; use crate::io; +use crate::sys::pal::abi; pub struct Stdin; pub struct Stdout; diff --git a/std/src/sys/pal/teeos/stdio.rs b/std/src/sys/stdio/teeos.rs similarity index 100% rename from std/src/sys/pal/teeos/stdio.rs rename to std/src/sys/stdio/teeos.rs diff --git a/std/src/sys/pal/uefi/stdio.rs b/std/src/sys/stdio/uefi.rs similarity index 98% rename from std/src/sys/pal/uefi/stdio.rs rename to std/src/sys/stdio/uefi.rs index 703e8ba8e5710..257e321dd03d7 100644 --- a/std/src/sys/pal/uefi/stdio.rs +++ b/std/src/sys/stdio/uefi.rs @@ -71,7 +71,7 @@ impl io::Read for Stdin { }; if ch.len() > 1 { - return Err(io::Error::new(io::ErrorKind::InvalidData, "invalid utf-16 sequence")); + return Err(io::const_error!(io::ErrorKind::InvalidData, "invalid UTF-16 sequence")); } match ch.pop().unwrap() { diff --git a/std/src/sys/pal/unix/stdio.rs b/std/src/sys/stdio/unix.rs similarity index 56% rename from std/src/sys/pal/unix/stdio.rs rename to std/src/sys/stdio/unix.rs index 97e75f1b5b669..8d133857c596d 100644 --- a/std/src/sys/pal/unix/stdio.rs +++ b/std/src/sys/stdio/unix.rs @@ -1,5 +1,15 @@ -use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; +#[cfg(target_os = "hermit")] +use hermit_abi::{EBADF, STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO}; +#[cfg(target_family = "unix")] +use libc::{EBADF, STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO}; + +#[cfg(target_family = "unix")] +use crate::io::BorrowedCursor; +use crate::io::{self, IoSlice, IoSliceMut}; use crate::mem::ManuallyDrop; +#[cfg(target_os = "hermit")] +use crate::os::hermit::io::FromRawFd; +#[cfg(target_family = "unix")] use crate::os::unix::io::FromRawFd; use crate::sys::fd::FileDesc; @@ -15,15 +25,16 @@ impl Stdin { impl io::Read for Stdin { fn read(&mut self, buf: &mut [u8]) -> io::Result { - unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(libc::STDIN_FILENO)).read(buf) } + unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(STDIN_FILENO)).read(buf) } } + #[cfg(not(target_os = "hermit"))] fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> { - unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(libc::STDIN_FILENO)).read_buf(buf) } + unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(STDIN_FILENO)).read_buf(buf) } } fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { - unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(libc::STDIN_FILENO)).read_vectored(bufs) } + unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(STDIN_FILENO)).read_vectored(bufs) } } #[inline] @@ -40,13 +51,11 @@ impl Stdout { impl io::Write for Stdout { fn write(&mut self, buf: &[u8]) -> io::Result { - unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(libc::STDOUT_FILENO)).write(buf) } + unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(STDOUT_FILENO)).write(buf) } } fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { - unsafe { - ManuallyDrop::new(FileDesc::from_raw_fd(libc::STDOUT_FILENO)).write_vectored(bufs) - } + unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(STDOUT_FILENO)).write_vectored(bufs) } } #[inline] @@ -68,13 +77,11 @@ impl Stderr { impl io::Write for Stderr { fn write(&mut self, buf: &[u8]) -> io::Result { - unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(libc::STDERR_FILENO)).write(buf) } + unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(STDERR_FILENO)).write(buf) } } fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { - unsafe { - ManuallyDrop::new(FileDesc::from_raw_fd(libc::STDERR_FILENO)).write_vectored(bufs) - } + unsafe { ManuallyDrop::new(FileDesc::from_raw_fd(STDERR_FILENO)).write_vectored(bufs) } } #[inline] @@ -89,10 +96,10 @@ impl io::Write for Stderr { } pub fn is_ebadf(err: &io::Error) -> bool { - err.raw_os_error() == Some(libc::EBADF as i32) + err.raw_os_error() == Some(EBADF as i32) } -pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE; +pub const STDIN_BUF_SIZE: usize = crate::sys::io::DEFAULT_BUF_SIZE; pub fn panic_output() -> Option { Some(Stderr::new()) diff --git a/std/src/sys/pal/unsupported/stdio.rs b/std/src/sys/stdio/unsupported.rs similarity index 100% rename from std/src/sys/pal/unsupported/stdio.rs rename to std/src/sys/stdio/unsupported.rs diff --git a/std/src/sys/pal/wasi/stdio.rs b/std/src/sys/stdio/wasi.rs similarity index 87% rename from std/src/sys/pal/wasi/stdio.rs rename to std/src/sys/stdio/wasi.rs index ca49f871e1957..8105b0cfa2f15 100644 --- a/std/src/sys/pal/wasi/stdio.rs +++ b/std/src/sys/stdio/wasi.rs @@ -1,10 +1,10 @@ #![forbid(unsafe_op_in_unsafe_fn)] -use super::fd::WasiFd; -use crate::io::{self, IoSlice, IoSliceMut}; +use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; use crate::mem::ManuallyDrop; use crate::os::raw; use crate::os::wasi::io::{AsRawFd, FromRawFd}; +use crate::sys::pal::fd::WasiFd; pub struct Stdin; pub struct Stdout; @@ -28,6 +28,10 @@ impl io::Read for Stdin { self.read_vectored(&mut [IoSliceMut::new(data)]) } + fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> { + ManuallyDrop::new(unsafe { WasiFd::from_raw_fd(self.as_raw_fd()) }).read_buf(buf) + } + fn read_vectored(&mut self, data: &mut [IoSliceMut<'_>]) -> io::Result { ManuallyDrop::new(unsafe { WasiFd::from_raw_fd(self.as_raw_fd()) }).read(data) } @@ -64,6 +68,7 @@ impl io::Write for Stdout { fn is_write_vectored(&self) -> bool { true } + fn flush(&mut self) -> io::Result<()> { Ok(()) } @@ -101,7 +106,7 @@ impl io::Write for Stderr { } } -pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE; +pub const STDIN_BUF_SIZE: usize = crate::sys::io::DEFAULT_BUF_SIZE; pub fn is_ebadf(err: &io::Error) -> bool { err.raw_os_error() == Some(wasi::ERRNO_BADF.raw().into()) diff --git a/std/src/sys/pal/windows/stdio.rs b/std/src/sys/stdio/windows.rs similarity index 92% rename from std/src/sys/pal/windows/stdio.rs rename to std/src/sys/stdio/windows.rs index 575f2250eb91c..9b27f76b9dd1a 100644 --- a/std/src/sys/pal/windows/stdio.rs +++ b/std/src/sys/stdio/windows.rs @@ -1,11 +1,12 @@ #![unstable(issue = "none", feature = "windows_stdio")] +use core::char::MAX_LEN_UTF8; use core::str::utf8_char_width; -use super::api::{self, WinError}; use crate::mem::MaybeUninit; use crate::os::windows::io::{FromRawHandle, IntoRawHandle}; use crate::sys::handle::Handle; +use crate::sys::pal::api::{self, WinError}; use crate::sys::{c, cvt}; use crate::{cmp, io, ptr, str}; @@ -84,21 +85,43 @@ fn is_console(handle: c::HANDLE) -> bool { unsafe { c::GetConsoleMode(handle, &mut mode) != 0 } } +/// Returns true if the attached console's code page is currently UTF-8. +#[cfg(not(target_vendor = "win7"))] +fn is_utf8_console() -> bool { + unsafe { c::GetConsoleOutputCP() == c::CP_UTF8 } +} + +#[cfg(target_vendor = "win7")] +fn is_utf8_console() -> bool { + // Windows 7 has a fun "feature" where WriteFile on a console handle will return + // the number of UTF-16 code units written and not the number of bytes from the input string. + // So we always claim the console isn't UTF-8 to trigger the WriteConsole fallback code. + false +} + fn write(handle_id: u32, data: &[u8], incomplete_utf8: &mut IncompleteUtf8) -> io::Result { if data.is_empty() { return Ok(0); } let handle = get_handle(handle_id)?; - if !is_console(handle) { + if !is_console(handle) || is_utf8_console() { unsafe { let handle = Handle::from_raw_handle(handle); let ret = handle.write(data); let _ = handle.into_raw_handle(); // Don't close the handle return ret; } + } else { + write_console_utf16(data, incomplete_utf8, handle) } +} +fn write_console_utf16( + data: &[u8], + incomplete_utf8: &mut IncompleteUtf8, + handle: c::HANDLE, +) -> io::Result { if incomplete_utf8.len > 0 { assert!( incomplete_utf8.len < 4, @@ -107,7 +130,7 @@ fn write(handle_id: u32, data: &[u8], incomplete_utf8: &mut IncompleteUtf8) -> i if data[0] >> 6 != 0b10 { // not a continuation byte - reject incomplete_utf8.len = 0; - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidData, "Windows stdio in console mode does not support writing non-UTF-8 byte sequences", )); @@ -129,7 +152,7 @@ fn write(handle_id: u32, data: &[u8], incomplete_utf8: &mut IncompleteUtf8) -> i return Ok(1); } Err(_) => { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidData, "Windows stdio in console mode does not support writing non-UTF-8 byte sequences", )); @@ -153,7 +176,7 @@ fn write(handle_id: u32, data: &[u8], incomplete_utf8: &mut IncompleteUtf8) -> i incomplete_utf8.len = 1; return Ok(1); } else { - return Err(io::const_io_error!( + return Err(io::const_error!( io::ErrorKind::InvalidData, "Windows stdio in console mode does not support writing non-UTF-8 byte sequences", )); @@ -185,7 +208,7 @@ fn write_valid_utf8_to_console(handle: c::HANDLE, utf8: &str) -> io::Result return Ok(bytes_copied + value), Err(e) => return Err(e), @@ -336,7 +359,7 @@ fn read_u16s(handle: c::HANDLE, buf: &mut [MaybeUninit]) -> io::Result() as u32, + nLength: size_of::() as u32, nInitialChars: 0, dwCtrlWakeupMask: CTRL_Z_MASK, dwControlKeyState: 0, @@ -392,7 +415,7 @@ fn utf16_to_utf8(utf16: &[u16], utf8: &mut [u8]) -> io::Result { }; if result == 0 { // We can't really do any better than forget all data and return an error. - Err(io::const_io_error!( + Err(io::const_error!( io::ErrorKind::InvalidData, "Windows stdin in console mode does not support non-UTF-16 input; \ encountered unpaired surrogate", @@ -404,7 +427,7 @@ fn utf16_to_utf8(utf16: &[u16], utf8: &mut [u8]) -> io::Result { impl IncompleteUtf8 { pub const fn new() -> IncompleteUtf8 { - IncompleteUtf8 { bytes: [0; 4], len: 0 } + IncompleteUtf8 { bytes: [0; MAX_LEN_UTF8], len: 0 } } } diff --git a/std/src/sys/pal/windows/stdio/tests.rs b/std/src/sys/stdio/windows/tests.rs similarity index 100% rename from std/src/sys/pal/windows/stdio/tests.rs rename to std/src/sys/stdio/windows/tests.rs diff --git a/std/src/sys/pal/xous/stdio.rs b/std/src/sys/stdio/xous.rs similarity index 98% rename from std/src/sys/pal/xous/stdio.rs rename to std/src/sys/stdio/xous.rs index dfd47a1775ae2..717361452213b 100644 --- a/std/src/sys/pal/xous/stdio.rs +++ b/std/src/sys/stdio/xous.rs @@ -87,7 +87,7 @@ pub struct PanicWriter { impl io::Write for PanicWriter { fn write(&mut self, s: &[u8]) -> core::result::Result { - for c in s.chunks(core::mem::size_of::() * 4) { + for c in s.chunks(size_of::() * 4) { // Text is grouped into 4x `usize` words. The id is 1100 plus // the number of characters in this message. // Ignore errors since we're already panicking. diff --git a/std/src/sys/pal/zkvm/stdio.rs b/std/src/sys/stdio/zkvm.rs similarity index 72% rename from std/src/sys/pal/zkvm/stdio.rs rename to std/src/sys/stdio/zkvm.rs index dd218c8894ca5..f31c6c26e87cd 100644 --- a/std/src/sys/pal/zkvm/stdio.rs +++ b/std/src/sys/stdio/zkvm.rs @@ -1,6 +1,5 @@ -use super::abi; -use super::abi::fileno; -use crate::io; +use crate::io::{self, BorrowedCursor}; +use crate::sys::pal::abi::{self, fileno}; pub struct Stdin; pub struct Stdout; @@ -16,6 +15,14 @@ impl io::Read for Stdin { fn read(&mut self, buf: &mut [u8]) -> io::Result { Ok(unsafe { abi::sys_read(fileno::STDIN, buf.as_mut_ptr(), buf.len()) }) } + + fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> { + unsafe { + let n = abi::sys_read(fileno::STDIN, buf.as_mut().as_mut_ptr().cast(), buf.capacity()); + buf.advance_unchecked(n); + } + Ok(()) + } } impl Stdout { @@ -54,7 +61,7 @@ impl io::Write for Stderr { } } -pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE; +pub const STDIN_BUF_SIZE: usize = crate::sys::io::DEFAULT_BUF_SIZE; pub fn is_ebadf(_err: &io::Error) -> bool { true diff --git a/std/src/sys/sync/condvar/no_threads.rs b/std/src/sys/sync/condvar/no_threads.rs index 2a67ed766aa0c..18d97d4b17ab0 100644 --- a/std/src/sys/sync/condvar/no_threads.rs +++ b/std/src/sys/sync/condvar/no_threads.rs @@ -1,11 +1,11 @@ use crate::sys::sync::Mutex; +use crate::thread::sleep; use crate::time::Duration; pub struct Condvar {} impl Condvar { #[inline] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_locks", since = "1.63.0"))] pub const fn new() -> Condvar { Condvar {} } @@ -20,7 +20,8 @@ impl Condvar { panic!("condvar wait not supported") } - pub unsafe fn wait_timeout(&self, _mutex: &Mutex, _dur: Duration) -> bool { - panic!("condvar wait not supported"); + pub unsafe fn wait_timeout(&self, _mutex: &Mutex, dur: Duration) -> bool { + sleep(dur); + false } } diff --git a/std/src/sys/sync/condvar/pthread.rs b/std/src/sys/sync/condvar/pthread.rs index cee728e35cdfc..5bb7431eecf0c 100644 --- a/std/src/sys/sync/condvar/pthread.rs +++ b/std/src/sys/sync/condvar/pthread.rs @@ -1,196 +1,88 @@ -use crate::cell::UnsafeCell; +#![forbid(unsafe_op_in_unsafe_fn)] + +use crate::pin::Pin; use crate::ptr; -use crate::sync::atomic::AtomicPtr; +use crate::sync::atomic::AtomicUsize; use crate::sync::atomic::Ordering::Relaxed; +use crate::sys::pal::sync as pal; use crate::sys::sync::{Mutex, OnceBox}; -#[cfg(not(target_os = "nto"))] -use crate::sys::time::TIMESPEC_MAX; -#[cfg(target_os = "nto")] -use crate::sys::time::TIMESPEC_MAX_CAPPED; -use crate::time::Duration; - -struct AllocatedCondvar(UnsafeCell); +use crate::time::{Duration, Instant}; pub struct Condvar { - inner: OnceBox, - mutex: AtomicPtr, -} - -unsafe impl Send for AllocatedCondvar {} -unsafe impl Sync for AllocatedCondvar {} - -impl AllocatedCondvar { - fn new() -> Box { - let condvar = Box::new(AllocatedCondvar(UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER))); - - cfg_if::cfg_if! { - if #[cfg(any( - target_os = "l4re", - target_os = "android", - target_os = "redox", - target_vendor = "apple", - ))] { - // `pthread_condattr_setclock` is unfortunately not supported on these platforms. - } else if #[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "teeos"))] { - // NOTE: ESP-IDF's PTHREAD_COND_INITIALIZER support is not released yet - // So on that platform, init() should always be called - // Moreover, that platform does not have pthread_condattr_setclock support, - // hence that initialization should be skipped as well - // - // Similar story for the 3DS (horizon). - let r = unsafe { libc::pthread_cond_init(condvar.0.get(), crate::ptr::null()) }; - assert_eq!(r, 0); - } else { - use crate::mem::MaybeUninit; - let mut attr = MaybeUninit::::uninit(); - let r = unsafe { libc::pthread_condattr_init(attr.as_mut_ptr()) }; - assert_eq!(r, 0); - let r = unsafe { libc::pthread_condattr_setclock(attr.as_mut_ptr(), libc::CLOCK_MONOTONIC) }; - assert_eq!(r, 0); - let r = unsafe { libc::pthread_cond_init(condvar.0.get(), attr.as_ptr()) }; - assert_eq!(r, 0); - let r = unsafe { libc::pthread_condattr_destroy(attr.as_mut_ptr()) }; - assert_eq!(r, 0); - } - } - - condvar - } -} - -impl Drop for AllocatedCondvar { - #[inline] - fn drop(&mut self) { - let r = unsafe { libc::pthread_cond_destroy(self.0.get()) }; - if cfg!(target_os = "dragonfly") { - // On DragonFly pthread_cond_destroy() returns EINVAL if called on - // a condvar that was just initialized with - // libc::PTHREAD_COND_INITIALIZER. Once it is used or - // pthread_cond_init() is called, this behavior no longer occurs. - debug_assert!(r == 0 || r == libc::EINVAL); - } else { - debug_assert_eq!(r, 0); - } - } + cvar: OnceBox, + mutex: AtomicUsize, } impl Condvar { pub const fn new() -> Condvar { - Condvar { inner: OnceBox::new(), mutex: AtomicPtr::new(ptr::null_mut()) } + Condvar { cvar: OnceBox::new(), mutex: AtomicUsize::new(0) } } - fn get(&self) -> *mut libc::pthread_cond_t { - self.inner.get_or_init(AllocatedCondvar::new).0.get() + #[inline] + fn get(&self) -> Pin<&pal::Condvar> { + self.cvar.get_or_init(|| { + let mut cvar = Box::pin(pal::Condvar::new()); + // SAFETY: we only call `init` once per `pal::Condvar`, namely here. + unsafe { cvar.as_mut().init() }; + cvar + }) } #[inline] - fn verify(&self, mutex: *mut libc::pthread_mutex_t) { - // Relaxed is okay here because we never read through `self.addr`, and only use it to + fn verify(&self, mutex: Pin<&pal::Mutex>) { + let addr = ptr::from_ref::(&mutex).addr(); + // Relaxed is okay here because we never read through `self.mutex`, and only use it to // compare addresses. - match self.mutex.compare_exchange(ptr::null_mut(), mutex, Relaxed, Relaxed) { - Ok(_) => {} // Stored the address - Err(n) if n == mutex => {} // Lost a race to store the same address + match self.mutex.compare_exchange(0, addr, Relaxed, Relaxed) { + Ok(_) => {} // Stored the address + Err(n) if n == addr => {} // Lost a race to store the same address _ => panic!("attempted to use a condition variable with two mutexes"), } } #[inline] pub fn notify_one(&self) { - let r = unsafe { libc::pthread_cond_signal(self.get()) }; - debug_assert_eq!(r, 0); + // SAFETY: we called `init` above. + unsafe { self.get().notify_one() } } #[inline] pub fn notify_all(&self) { - let r = unsafe { libc::pthread_cond_broadcast(self.get()) }; - debug_assert_eq!(r, 0); + // SAFETY: we called `init` above. + unsafe { self.get().notify_all() } } #[inline] pub unsafe fn wait(&self, mutex: &Mutex) { - let mutex = mutex.get_assert_locked(); + // SAFETY: the caller guarantees that the lock is owned, thus the mutex + // must have been initialized already. + let mutex = unsafe { mutex.pal.get_unchecked() }; self.verify(mutex); - let r = libc::pthread_cond_wait(self.get(), mutex); - debug_assert_eq!(r, 0); + // SAFETY: we called `init` above, we verified that this condition + // variable is only used with `mutex` and the caller guarantees that + // `mutex` is locked by the current thread. + unsafe { self.get().wait(mutex) } } - // This implementation is used on systems that support pthread_condattr_setclock - // where we configure condition variable to use monotonic clock (instead of - // default system clock). This approach avoids all problems that result - // from changes made to the system time. - #[cfg(not(any( - target_os = "android", - target_os = "espidf", - target_os = "horizon", - target_vendor = "apple", - )))] pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool { - use crate::sys::time::Timespec; - - let mutex = mutex.get_assert_locked(); + // SAFETY: the caller guarantees that the lock is owned, thus the mutex + // must have been initialized already. + let mutex = unsafe { mutex.pal.get_unchecked() }; self.verify(mutex); - #[cfg(not(target_os = "nto"))] - let timeout = Timespec::now(libc::CLOCK_MONOTONIC) - .checked_add_duration(&dur) - .and_then(|t| t.to_timespec()) - .unwrap_or(TIMESPEC_MAX); - - #[cfg(target_os = "nto")] - let timeout = Timespec::now(libc::CLOCK_MONOTONIC) - .checked_add_duration(&dur) - .and_then(|t| t.to_timespec_capped()) - .unwrap_or(TIMESPEC_MAX_CAPPED); - - let r = libc::pthread_cond_timedwait(self.get(), mutex, &timeout); - assert!(r == libc::ETIMEDOUT || r == 0); - r == 0 - } - - // This implementation is modeled after libcxx's condition_variable - // https://github.com/llvm-mirror/libcxx/blob/release_35/src/condition_variable.cpp#L46 - // https://github.com/llvm-mirror/libcxx/blob/release_35/include/__mutex_base#L367 - #[cfg(any( - target_os = "android", - target_os = "espidf", - target_os = "horizon", - target_vendor = "apple", - ))] - pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool { - use crate::sys::time::SystemTime; - use crate::time::Instant; - - let mutex = mutex.get_assert_locked(); - self.verify(mutex); - - // OSX implementation of `pthread_cond_timedwait` is buggy - // with super long durations. When duration is greater than - // 0x100_0000_0000_0000 seconds, `pthread_cond_timedwait` - // in macOS Sierra returns error 316. - // - // This program demonstrates the issue: - // https://gist.github.com/stepancheg/198db4623a20aad2ad7cddb8fda4a63c - // - // To work around this issue, and possible bugs of other OSes, timeout - // is clamped to 1000 years, which is allowable per the API of `wait_timeout` - // because of spurious wakeups. - let dur = Duration::min(dur, Duration::from_secs(1000 * 365 * 86400)); - - // pthread_cond_timedwait uses system time, but we want to report timeout - // based on stable time. - let now = Instant::now(); - - let timeout = SystemTime::now() - .t - .checked_add_duration(&dur) - .and_then(|t| t.to_timespec()) - .unwrap_or(TIMESPEC_MAX); - - let r = libc::pthread_cond_timedwait(self.get(), mutex, &timeout); - debug_assert!(r == libc::ETIMEDOUT || r == 0); - - // ETIMEDOUT is not a totally reliable method of determining timeout due - // to clock shifts, so do the check ourselves - now.elapsed() < dur + if pal::Condvar::PRECISE_TIMEOUT { + // SAFETY: we called `init` above, we verified that this condition + // variable is only used with `mutex` and the caller guarantees that + // `mutex` is locked by the current thread. + unsafe { self.get().wait_timeout(mutex, dur) } + } else { + // Timeout reports are not reliable, so do the check ourselves. + let now = Instant::now(); + // SAFETY: we called `init` above, we verified that this condition + // variable is only used with `mutex` and the caller guarantees that + // `mutex` is locked by the current thread. + let woken = unsafe { self.get().wait_timeout(mutex, dur) }; + woken || now.elapsed() < dur + } } } diff --git a/std/src/sys/sync/condvar/sgx.rs b/std/src/sys/sync/condvar/sgx.rs index e60715e4b592e..2bde9d0694eda 100644 --- a/std/src/sys/sync/condvar/sgx.rs +++ b/std/src/sys/sync/condvar/sgx.rs @@ -13,17 +13,19 @@ impl Condvar { } fn get(&self) -> &SpinMutex> { - self.inner.get_or_init(|| Box::new(SpinMutex::new(WaitVariable::new(())))) + self.inner.get_or_init(|| Box::pin(SpinMutex::new(WaitVariable::new(())))).get_ref() } #[inline] pub fn notify_one(&self) { - let _ = WaitQueue::notify_one(self.get().lock()); + let guard = self.get().lock(); + let _ = WaitQueue::notify_one(guard); } #[inline] pub fn notify_all(&self) { - let _ = WaitQueue::notify_all(self.get().lock()); + let guard = self.get().lock(); + let _ = WaitQueue::notify_all(guard); } pub unsafe fn wait(&self, mutex: &Mutex) { diff --git a/std/src/sys/sync/mutex/no_threads.rs b/std/src/sys/sync/mutex/no_threads.rs index 7b243575e018e..57c78f454c57c 100644 --- a/std/src/sys/sync/mutex/no_threads.rs +++ b/std/src/sys/sync/mutex/no_threads.rs @@ -10,7 +10,6 @@ unsafe impl Sync for Mutex {} // no threads on this platform impl Mutex { #[inline] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_locks", since = "1.63.0"))] pub const fn new() -> Mutex { Mutex { locked: Cell::new(false) } } diff --git a/std/src/sys/sync/mutex/pthread.rs b/std/src/sys/sync/mutex/pthread.rs index abd58122523cf..75b4b9c6dad9b 100644 --- a/std/src/sys/sync/mutex/pthread.rs +++ b/std/src/sys/sync/mutex/pthread.rs @@ -1,163 +1,66 @@ -use crate::cell::UnsafeCell; -use crate::io::Error; -use crate::mem::{MaybeUninit, forget}; -use crate::sys::cvt_nz; -use crate::sys::sync::OnceBox; +#![forbid(unsafe_op_in_unsafe_fn)] -struct AllocatedMutex(UnsafeCell); +use crate::mem::forget; +use crate::pin::Pin; +use crate::sys::pal::sync as pal; +use crate::sys::sync::OnceBox; pub struct Mutex { - inner: OnceBox, -} - -unsafe impl Send for AllocatedMutex {} -unsafe impl Sync for AllocatedMutex {} - -impl AllocatedMutex { - fn new() -> Box { - let mutex = Box::new(AllocatedMutex(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER))); - - // Issue #33770 - // - // A pthread mutex initialized with PTHREAD_MUTEX_INITIALIZER will have - // a type of PTHREAD_MUTEX_DEFAULT, which has undefined behavior if you - // try to re-lock it from the same thread when you already hold a lock - // (https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_init.html). - // This is the case even if PTHREAD_MUTEX_DEFAULT == PTHREAD_MUTEX_NORMAL - // (https://github.com/rust-lang/rust/issues/33770#issuecomment-220847521) -- in that - // case, `pthread_mutexattr_settype(PTHREAD_MUTEX_DEFAULT)` will of course be the same - // as setting it to `PTHREAD_MUTEX_NORMAL`, but not setting any mode will result in - // a Mutex where re-locking is UB. - // - // In practice, glibc takes advantage of this undefined behavior to - // implement hardware lock elision, which uses hardware transactional - // memory to avoid acquiring the lock. While a transaction is in - // progress, the lock appears to be unlocked. This isn't a problem for - // other threads since the transactional memory will abort if a conflict - // is detected, however no abort is generated when re-locking from the - // same thread. - // - // Since locking the same mutex twice will result in two aliasing &mut - // references, we instead create the mutex with type - // PTHREAD_MUTEX_NORMAL which is guaranteed to deadlock if we try to - // re-lock it from the same thread, thus avoiding undefined behavior. - unsafe { - let mut attr = MaybeUninit::::uninit(); - cvt_nz(libc::pthread_mutexattr_init(attr.as_mut_ptr())).unwrap(); - let attr = PthreadMutexAttr(&mut attr); - cvt_nz(libc::pthread_mutexattr_settype( - attr.0.as_mut_ptr(), - libc::PTHREAD_MUTEX_NORMAL, - )) - .unwrap(); - cvt_nz(libc::pthread_mutex_init(mutex.0.get(), attr.0.as_ptr())).unwrap(); - } - - mutex - } -} - -impl Drop for AllocatedMutex { - #[inline] - fn drop(&mut self) { - let r = unsafe { libc::pthread_mutex_destroy(self.0.get()) }; - if cfg!(target_os = "dragonfly") { - // On DragonFly pthread_mutex_destroy() returns EINVAL if called on a - // mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER. - // Once it is used (locked/unlocked) or pthread_mutex_init() is called, - // this behavior no longer occurs. - debug_assert!(r == 0 || r == libc::EINVAL); - } else { - debug_assert_eq!(r, 0); - } - } + pub pal: OnceBox, } impl Mutex { #[inline] pub const fn new() -> Mutex { - Mutex { inner: OnceBox::new() } + Mutex { pal: OnceBox::new() } } - /// Gets access to the pthread mutex under the assumption that the mutex is - /// locked. - /// - /// This allows skipping the initialization check, as the mutex can only be - /// locked if it is already initialized, and allows relaxing the ordering - /// on the pointer load, since the allocation cannot have been modified - /// since the `lock` and the lock must have occurred on the current thread. - /// - /// # Safety - /// Causes undefined behavior if the mutex is not locked. #[inline] - pub(crate) unsafe fn get_assert_locked(&self) -> *mut libc::pthread_mutex_t { - unsafe { self.inner.get_unchecked().0.get() } - } - - #[inline] - fn get(&self) -> *mut libc::pthread_mutex_t { - // If initialization fails, the mutex is destroyed. This is always sound, - // however, as the mutex cannot have been locked yet. - self.inner.get_or_init(AllocatedMutex::new).0.get() + fn get(&self) -> Pin<&pal::Mutex> { + // If the initialization race is lost, the new mutex is destroyed. + // This is sound however, as it cannot have been locked. + self.pal.get_or_init(|| { + let mut pal = Box::pin(pal::Mutex::new()); + // SAFETY: we only call `init` once per `pal::Mutex`, namely here. + unsafe { pal.as_mut().init() }; + pal + }) } #[inline] pub fn lock(&self) { - #[cold] - #[inline(never)] - fn fail(r: i32) -> ! { - let error = Error::from_raw_os_error(r); - panic!("failed to lock mutex: {error}"); - } - - let r = unsafe { libc::pthread_mutex_lock(self.get()) }; - // As we set the mutex type to `PTHREAD_MUTEX_NORMAL` above, we expect - // the lock call to never fail. Unfortunately however, some platforms - // (Solaris) do not conform to the standard, and instead always provide - // deadlock detection. How kind of them! Unfortunately that means that - // we need to check the error code here. To save us from UB on other - // less well-behaved platforms in the future, we do it even on "good" - // platforms like macOS. See #120147 for more context. - if r != 0 { - fail(r) - } + // SAFETY: we call `init` above, therefore reentrant locking is safe. + // In `drop` we ensure that the mutex is not destroyed while locked. + unsafe { self.get().lock() } } #[inline] pub unsafe fn unlock(&self) { - let r = libc::pthread_mutex_unlock(self.get_assert_locked()); - debug_assert_eq!(r, 0); + // SAFETY: the mutex can only be locked if it is already initialized + // and we observed this initialization since we observed the locking. + unsafe { self.pal.get_unchecked().unlock() } } #[inline] pub fn try_lock(&self) -> bool { - unsafe { libc::pthread_mutex_trylock(self.get()) == 0 } + // SAFETY: we call `init` above, therefore reentrant locking is safe. + // In `drop` we ensure that the mutex is not destroyed while locked. + unsafe { self.get().try_lock() } } } impl Drop for Mutex { fn drop(&mut self) { - let Some(mutex) = self.inner.take() else { return }; + let Some(pal) = self.pal.take() else { return }; // We're not allowed to pthread_mutex_destroy a locked mutex, // so check first if it's unlocked. - if unsafe { libc::pthread_mutex_trylock(mutex.0.get()) == 0 } { - unsafe { libc::pthread_mutex_unlock(mutex.0.get()) }; - drop(mutex); + if unsafe { pal.as_ref().try_lock() } { + unsafe { pal.as_ref().unlock() }; + drop(pal) } else { // The mutex is locked. This happens if a MutexGuard is leaked. // In this case, we just leak the Mutex too. - forget(mutex); - } - } -} - -pub(super) struct PthreadMutexAttr<'a>(pub &'a mut MaybeUninit); - -impl Drop for PthreadMutexAttr<'_> { - fn drop(&mut self) { - unsafe { - let result = libc::pthread_mutexattr_destroy(self.0.as_mut_ptr()); - debug_assert_eq!(result, 0); + forget(pal) } } } diff --git a/std/src/sys/sync/mutex/sgx.rs b/std/src/sys/sync/mutex/sgx.rs index 8529e85797043..3eb981bc65af6 100644 --- a/std/src/sys/sync/mutex/sgx.rs +++ b/std/src/sys/sync/mutex/sgx.rs @@ -13,7 +13,7 @@ impl Mutex { } fn get(&self) -> &SpinMutex> { - self.inner.get_or_init(|| Box::new(SpinMutex::new(WaitVariable::new(false)))) + self.inner.get_or_init(|| Box::pin(SpinMutex::new(WaitVariable::new(false)))).get_ref() } #[inline] @@ -33,7 +33,7 @@ impl Mutex { pub unsafe fn unlock(&self) { // SAFETY: the mutex was locked by the current thread, so it has been // initialized already. - let guard = unsafe { self.inner.get_unchecked().lock() }; + let guard = unsafe { self.inner.get_unchecked().get_ref().lock() }; if let Err(mut guard) = WaitQueue::notify_one(guard) { // No other waiters, unlock *guard.lock_var_mut() = false; diff --git a/std/src/sys/sync/mutex/windows7.rs b/std/src/sys/sync/mutex/windows7.rs index 689dba10f01ed..0b57de78ba6dd 100644 --- a/std/src/sys/sync/mutex/windows7.rs +++ b/std/src/sys/sync/mutex/windows7.rs @@ -44,7 +44,7 @@ impl Mutex { #[inline] pub fn try_lock(&self) -> bool { - unsafe { c::TryAcquireSRWLockExclusive(raw(self)) != 0 } + unsafe { c::TryAcquireSRWLockExclusive(raw(self)) } } #[inline] diff --git a/std/src/sys/sync/once/futex.rs b/std/src/sys/sync/once/futex.rs index 10bfa81a6d72a..539f0fe89eaaa 100644 --- a/std/src/sys/sync/once/futex.rs +++ b/std/src/sys/sync/once/futex.rs @@ -1,7 +1,7 @@ use crate::cell::Cell; use crate::sync as public; use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; -use crate::sync::once::ExclusiveState; +use crate::sync::poison::once::ExclusiveState; use crate::sys::futex::{Futex, Primitive, futex_wait, futex_wake_all}; // On some platforms, the OS is very nice and handles the waiter queue for us. diff --git a/std/src/sys/sync/once/no_threads.rs b/std/src/sys/sync/once/no_threads.rs index fb1b496510aba..2568059cfe3a8 100644 --- a/std/src/sys/sync/once/no_threads.rs +++ b/std/src/sys/sync/once/no_threads.rs @@ -1,6 +1,6 @@ use crate::cell::Cell; use crate::sync as public; -use crate::sync::once::ExclusiveState; +use crate::sync::poison::once::ExclusiveState; pub struct Once { state: Cell, @@ -35,7 +35,6 @@ unsafe impl Sync for Once {} impl Once { #[inline] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_once_new", since = "1.32.0"))] pub const fn new() -> Once { Once { state: Cell::new(State::Incomplete) } } diff --git a/std/src/sys/sync/once/queue.rs b/std/src/sys/sync/once/queue.rs index 87837915b396e..fde1e0ca51029 100644 --- a/std/src/sys/sync/once/queue.rs +++ b/std/src/sys/sync/once/queue.rs @@ -58,7 +58,7 @@ use crate::cell::Cell; use crate::sync::atomic::Ordering::{AcqRel, Acquire, Release}; use crate::sync::atomic::{AtomicBool, AtomicPtr}; -use crate::sync::once::ExclusiveState; +use crate::sync::poison::once::ExclusiveState; use crate::thread::{self, Thread}; use crate::{fmt, ptr, sync as public}; @@ -116,7 +116,6 @@ fn to_state(current: StateAndQueue) -> usize { impl Once { #[inline] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_once_new", since = "1.32.0"))] pub const fn new() -> Once { Once { state_and_queue: AtomicPtr::new(ptr::without_provenance_mut(INCOMPLETE)) } } diff --git a/std/src/sys/sync/once_box.rs b/std/src/sys/sync/once_box.rs index 4105af503295f..6953b91999ad1 100644 --- a/std/src/sys/sync/once_box.rs +++ b/std/src/sys/sync/once_box.rs @@ -6,6 +6,7 @@ #![allow(dead_code)] // Only used on some platforms. use crate::mem::replace; +use crate::pin::Pin; use crate::ptr::null_mut; use crate::sync::atomic::AtomicPtr; use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; @@ -27,46 +28,46 @@ impl OnceBox { /// pointer load in this function can be performed with relaxed ordering, /// potentially allowing the optimizer to turn code like this: /// ```rust, ignore - /// once_box.get_or_init(|| Box::new(42)); + /// once_box.get_or_init(|| Box::pin(42)); /// unsafe { once_box.get_unchecked() } /// ``` /// into /// ```rust, ignore - /// once_box.get_or_init(|| Box::new(42)) + /// once_box.get_or_init(|| Box::pin(42)) /// ``` /// /// # Safety /// This causes undefined behavior if the assumption above is violated. #[inline] - pub unsafe fn get_unchecked(&self) -> &T { - unsafe { &*self.ptr.load(Relaxed) } + pub unsafe fn get_unchecked(&self) -> Pin<&T> { + unsafe { Pin::new_unchecked(&*self.ptr.load(Relaxed)) } } #[inline] - pub fn get_or_init(&self, f: impl FnOnce() -> Box) -> &T { + pub fn get_or_init(&self, f: impl FnOnce() -> Pin>) -> Pin<&T> { let ptr = self.ptr.load(Acquire); match unsafe { ptr.as_ref() } { - Some(val) => val, + Some(val) => unsafe { Pin::new_unchecked(val) }, None => self.initialize(f), } } #[inline] - pub fn take(&mut self) -> Option> { + pub fn take(&mut self) -> Option>> { let ptr = replace(self.ptr.get_mut(), null_mut()); - if !ptr.is_null() { Some(unsafe { Box::from_raw(ptr) }) } else { None } + if !ptr.is_null() { Some(unsafe { Pin::new_unchecked(Box::from_raw(ptr)) }) } else { None } } #[cold] - fn initialize(&self, f: impl FnOnce() -> Box) -> &T { - let new_ptr = Box::into_raw(f()); + fn initialize(&self, f: impl FnOnce() -> Pin>) -> Pin<&T> { + let new_ptr = Box::into_raw(unsafe { Pin::into_inner_unchecked(f()) }); match self.ptr.compare_exchange(null_mut(), new_ptr, Release, Acquire) { - Ok(_) => unsafe { &*new_ptr }, + Ok(_) => unsafe { Pin::new_unchecked(&*new_ptr) }, Err(ptr) => { // Lost the race to another thread. // Drop the value we created, and use the one from the other thread instead. drop(unsafe { Box::from_raw(new_ptr) }); - unsafe { &*ptr } + unsafe { Pin::new_unchecked(&*ptr) } } } } diff --git a/std/src/sys/sync/rwlock/no_threads.rs b/std/src/sys/sync/rwlock/no_threads.rs index c11e59f719e93..573d0d602dbd6 100644 --- a/std/src/sys/sync/rwlock/no_threads.rs +++ b/std/src/sys/sync/rwlock/no_threads.rs @@ -10,7 +10,6 @@ unsafe impl Sync for RwLock {} // no threads on this platform impl RwLock { #[inline] - #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_locks", since = "1.63.0"))] pub const fn new() -> RwLock { RwLock { mode: Cell::new(0) } } diff --git a/std/src/sys/sync/thread_parking/darwin.rs b/std/src/sys/sync/thread_parking/darwin.rs index 0553c5e19a91f..a0d24a91e7c69 100644 --- a/std/src/sys/sync/thread_parking/darwin.rs +++ b/std/src/sys/sync/thread_parking/darwin.rs @@ -24,7 +24,7 @@ const DISPATCH_TIME_NOW: dispatch_time_t = 0; const DISPATCH_TIME_FOREVER: dispatch_time_t = !0; // Contained in libSystem.dylib, which is linked by default. -extern "C" { +unsafe extern "C" { fn dispatch_time(when: dispatch_time_t, delta: i64) -> dispatch_time_t; fn dispatch_semaphore_create(val: isize) -> dispatch_semaphore_t; fn dispatch_semaphore_wait(dsema: dispatch_semaphore_t, timeout: dispatch_time_t) -> isize; diff --git a/std/src/sys/sync/thread_parking/pthread.rs b/std/src/sys/sync/thread_parking/pthread.rs index 76df73b2a8e06..19cabd7dd75c8 100644 --- a/std/src/sys/sync/thread_parking/pthread.rs +++ b/std/src/sys/sync/thread_parking/pthread.rs @@ -1,93 +1,19 @@ //! Thread parking without `futex` using the `pthread` synchronization primitives. -use crate::cell::UnsafeCell; -use crate::marker::PhantomPinned; use crate::pin::Pin; use crate::sync::atomic::AtomicUsize; use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; -#[cfg(not(target_os = "nto"))] -use crate::sys::time::TIMESPEC_MAX; -#[cfg(target_os = "nto")] -use crate::sys::time::TIMESPEC_MAX_CAPPED; +use crate::sys::pal::sync::{Condvar, Mutex}; use crate::time::Duration; const EMPTY: usize = 0; const PARKED: usize = 1; const NOTIFIED: usize = 2; -unsafe fn lock(lock: *mut libc::pthread_mutex_t) { - let r = libc::pthread_mutex_lock(lock); - debug_assert_eq!(r, 0); -} - -unsafe fn unlock(lock: *mut libc::pthread_mutex_t) { - let r = libc::pthread_mutex_unlock(lock); - debug_assert_eq!(r, 0); -} - -unsafe fn notify_one(cond: *mut libc::pthread_cond_t) { - let r = libc::pthread_cond_signal(cond); - debug_assert_eq!(r, 0); -} - -unsafe fn wait(cond: *mut libc::pthread_cond_t, lock: *mut libc::pthread_mutex_t) { - let r = libc::pthread_cond_wait(cond, lock); - debug_assert_eq!(r, 0); -} - -unsafe fn wait_timeout( - cond: *mut libc::pthread_cond_t, - lock: *mut libc::pthread_mutex_t, - dur: Duration, -) { - // Use the system clock on systems that do not support pthread_condattr_setclock. - // This unfortunately results in problems when the system time changes. - #[cfg(any(target_os = "espidf", target_os = "horizon", target_vendor = "apple"))] - let (now, dur) = { - use crate::cmp::min; - use crate::sys::time::SystemTime; - - // OSX implementation of `pthread_cond_timedwait` is buggy - // with super long durations. When duration is greater than - // 0x100_0000_0000_0000 seconds, `pthread_cond_timedwait` - // in macOS Sierra return error 316. - // - // This program demonstrates the issue: - // https://gist.github.com/stepancheg/198db4623a20aad2ad7cddb8fda4a63c - // - // To work around this issue, and possible bugs of other OSes, timeout - // is clamped to 1000 years, which is allowable per the API of `park_timeout` - // because of spurious wakeups. - let dur = min(dur, Duration::from_secs(1000 * 365 * 86400)); - let now = SystemTime::now().t; - (now, dur) - }; - // Use the monotonic clock on other systems. - #[cfg(not(any(target_os = "espidf", target_os = "horizon", target_vendor = "apple")))] - let (now, dur) = { - use crate::sys::time::Timespec; - - (Timespec::now(libc::CLOCK_MONOTONIC), dur) - }; - - #[cfg(not(target_os = "nto"))] - let timeout = - now.checked_add_duration(&dur).and_then(|t| t.to_timespec()).unwrap_or(TIMESPEC_MAX); - #[cfg(target_os = "nto")] - let timeout = now - .checked_add_duration(&dur) - .and_then(|t| t.to_timespec_capped()) - .unwrap_or(TIMESPEC_MAX_CAPPED); - let r = libc::pthread_cond_timedwait(cond, lock, &timeout); - debug_assert!(r == libc::ETIMEDOUT || r == 0); -} - pub struct Parker { state: AtomicUsize, - lock: UnsafeCell, - cvar: UnsafeCell, - // The `pthread` primitives require a stable address, so make this struct `!Unpin`. - _pinned: PhantomPinned, + lock: Mutex, + cvar: Condvar, } impl Parker { @@ -96,38 +22,21 @@ impl Parker { /// # Safety /// The constructed parker must never be moved. pub unsafe fn new_in_place(parker: *mut Parker) { - // Use the default mutex implementation to allow for simpler initialization. - // This could lead to undefined behavior when deadlocking. This is avoided - // by not deadlocking. Note in particular the unlocking operation before any - // panic, as code after the panic could try to park again. - (&raw mut (*parker).state).write(AtomicUsize::new(EMPTY)); - (&raw mut (*parker).lock).write(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER)); + parker.write(Parker { + state: AtomicUsize::new(EMPTY), + lock: Mutex::new(), + cvar: Condvar::new(), + }); - cfg_if::cfg_if! { - if #[cfg(any( - target_os = "l4re", - target_os = "android", - target_os = "redox", - target_os = "vita", - target_vendor = "apple", - ))] { - (&raw mut (*parker).cvar).write(UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER)); - } else if #[cfg(any(target_os = "espidf", target_os = "horizon"))] { - let r = libc::pthread_cond_init((&raw mut (*parker).cvar).cast(), crate::ptr::null()); - assert_eq!(r, 0); - } else { - use crate::mem::MaybeUninit; - let mut attr = MaybeUninit::::uninit(); - let r = libc::pthread_condattr_init(attr.as_mut_ptr()); - assert_eq!(r, 0); - let r = libc::pthread_condattr_setclock(attr.as_mut_ptr(), libc::CLOCK_MONOTONIC); - assert_eq!(r, 0); - let r = libc::pthread_cond_init((&raw mut (*parker).cvar).cast(), attr.as_ptr()); - assert_eq!(r, 0); - let r = libc::pthread_condattr_destroy(attr.as_mut_ptr()); - assert_eq!(r, 0); - } - } + Pin::new_unchecked(&mut (*parker).cvar).init(); + } + + fn lock(self: Pin<&Self>) -> Pin<&Mutex> { + unsafe { self.map_unchecked(|p| &p.lock) } + } + + fn cvar(self: Pin<&Self>) -> Pin<&Condvar> { + unsafe { self.map_unchecked(|p| &p.cvar) } } // This implementation doesn't require `unsafe`, but other implementations @@ -142,7 +51,7 @@ impl Parker { } // Otherwise we need to coordinate going to sleep - lock(self.lock.get()); + self.lock().lock(); match self.state.compare_exchange(EMPTY, PARKED, Relaxed, Relaxed) { Ok(_) => {} Err(NOTIFIED) => { @@ -154,20 +63,20 @@ impl Parker { // read from the write it made to `state`. let old = self.state.swap(EMPTY, Acquire); - unlock(self.lock.get()); + self.lock().unlock(); assert_eq!(old, NOTIFIED, "park state changed unexpectedly"); return; } // should consume this notification, so prohibit spurious wakeups in next park. Err(_) => { - unlock(self.lock.get()); + self.lock().unlock(); panic!("inconsistent park state") } } loop { - wait(self.cvar.get(), self.lock.get()); + self.cvar().wait(self.lock()); match self.state.compare_exchange(NOTIFIED, EMPTY, Acquire, Relaxed) { Ok(_) => break, // got a notification @@ -175,7 +84,7 @@ impl Parker { } } - unlock(self.lock.get()); + self.lock().unlock(); } // This implementation doesn't require `unsafe`, but other implementations @@ -189,19 +98,19 @@ impl Parker { return; } - lock(self.lock.get()); + self.lock().lock(); match self.state.compare_exchange(EMPTY, PARKED, Relaxed, Relaxed) { Ok(_) => {} Err(NOTIFIED) => { // We must read again here, see `park`. let old = self.state.swap(EMPTY, Acquire); - unlock(self.lock.get()); + self.lock().unlock(); assert_eq!(old, NOTIFIED, "park state changed unexpectedly"); return; } // should consume this notification, so prohibit spurious wakeups in next park. Err(_) => { - unlock(self.lock.get()); + self.lock().unlock(); panic!("inconsistent park_timeout state") } } @@ -210,13 +119,13 @@ impl Parker { // from a notification we just want to unconditionally set the state back to // empty, either consuming a notification or un-flagging ourselves as // parked. - wait_timeout(self.cvar.get(), self.lock.get(), dur); + self.cvar().wait_timeout(self.lock(), dur); match self.state.swap(EMPTY, Acquire) { - NOTIFIED => unlock(self.lock.get()), // got a notification, hurray! - PARKED => unlock(self.lock.get()), // no notification, alas + NOTIFIED => self.lock().unlock(), // got a notification, hurray! + PARKED => self.lock().unlock(), // no notification, alas n => { - unlock(self.lock.get()); + self.lock().unlock(); panic!("inconsistent park_timeout state: {n}") } } @@ -248,21 +157,9 @@ impl Parker { // parked thread wakes it doesn't get woken only to have to wait for us // to release `lock`. unsafe { - lock(self.lock.get()); - unlock(self.lock.get()); - notify_one(self.cvar.get()); + self.lock().lock(); + self.lock().unlock(); + self.cvar().notify_one(); } } } - -impl Drop for Parker { - fn drop(&mut self) { - unsafe { - libc::pthread_cond_destroy(self.cvar.get_mut()); - libc::pthread_mutex_destroy(self.lock.get_mut()); - } - } -} - -unsafe impl Sync for Parker {} -unsafe impl Send for Parker {} diff --git a/std/src/sys/sync/thread_parking/windows7.rs b/std/src/sys/sync/thread_parking/windows7.rs index f7585e882f055..a1a0f8427cd83 100644 --- a/std/src/sys/sync/thread_parking/windows7.rs +++ b/std/src/sys/sync/thread_parking/windows7.rs @@ -195,7 +195,7 @@ mod keyed_events { pub unsafe fn park(parker: Pin<&Parker>) { // Wait for unpark() to produce this event. - c::NtWaitForKeyedEvent(keyed_event_handle(), parker.ptr(), 0, ptr::null_mut()); + c::NtWaitForKeyedEvent(keyed_event_handle(), parker.ptr(), false, ptr::null_mut()); // Set the state back to EMPTY (from either PARKED or NOTIFIED). // Note that we don't just write EMPTY, but use swap() to also // include an acquire-ordered read to synchronize with unpark()'s @@ -218,7 +218,7 @@ mod keyed_events { // Wait for unpark() to produce this event. let unparked = - c::NtWaitForKeyedEvent(handle, parker.ptr(), 0, &mut timeout) == c::STATUS_SUCCESS; + c::NtWaitForKeyedEvent(handle, parker.ptr(), false, &mut timeout) == c::STATUS_SUCCESS; // Set the state back to EMPTY (from either PARKED or NOTIFIED). let prev_state = parker.state.swap(EMPTY, Acquire); @@ -228,7 +228,7 @@ mod keyed_events { // was set to NOTIFIED, which means we *just* missed an // unpark(), which is now blocked on us to wait for it. // Wait for it to consume the event and unblock that thread. - c::NtWaitForKeyedEvent(handle, parker.ptr(), 0, ptr::null_mut()); + c::NtWaitForKeyedEvent(handle, parker.ptr(), false, ptr::null_mut()); } } pub unsafe fn unpark(parker: Pin<&Parker>) { @@ -239,7 +239,7 @@ mod keyed_events { // To prevent this thread from blocking indefinitely in that case, // park_impl() will, after seeing the state set to NOTIFIED after // waking up, call NtWaitForKeyedEvent again to unblock us. - c::NtReleaseKeyedEvent(keyed_event_handle(), parker.ptr(), 0, ptr::null_mut()); + c::NtReleaseKeyedEvent(keyed_event_handle(), parker.ptr(), false, ptr::null_mut()); } fn keyed_event_handle() -> c::HANDLE { diff --git a/std/src/sys/thread_local/destructors/linux_like.rs b/std/src/sys/thread_local/destructors/linux_like.rs index f473dc4d79df5..817941229eefe 100644 --- a/std/src/sys/thread_local/destructors/linux_like.rs +++ b/std/src/sys/thread_local/destructors/linux_like.rs @@ -27,7 +27,7 @@ pub unsafe fn register(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { #[allow(non_camel_case_types)] pub struct c_int(#[allow(dead_code)] pub core::ffi::c_int); - extern "C" { + unsafe extern "C" { #[linkage = "extern_weak"] static __dso_handle: *mut u8; #[linkage = "extern_weak"] diff --git a/std/src/sys/thread_local/guard/apple.rs b/std/src/sys/thread_local/guard/apple.rs index fa25b116622fc..edcedf21e9ec6 100644 --- a/std/src/sys/thread_local/guard/apple.rs +++ b/std/src/sys/thread_local/guard/apple.rs @@ -10,7 +10,7 @@ pub fn enable() { #[thread_local] static REGISTERED: Cell = Cell::new(false); - extern "C" { + unsafe extern "C" { fn _tlv_atexit(dtor: unsafe extern "C" fn(*mut u8), arg: *mut u8); } diff --git a/std/src/sys/thread_local/guard/windows.rs b/std/src/sys/thread_local/guard/windows.rs index 1752b0e1208af..b15a0d7c0bdfb 100644 --- a/std/src/sys/thread_local/guard/windows.rs +++ b/std/src/sys/thread_local/guard/windows.rs @@ -74,7 +74,7 @@ pub fn enable() { unsafe { ptr::from_ref(&CALLBACK).read_volatile() }; } -#[link_section = ".CRT$XLB"] +#[unsafe(link_section = ".CRT$XLB")] #[cfg_attr(miri, used)] // Miri only considers explicitly `#[used]` statics for `lookup_link_section` pub static CALLBACK: unsafe extern "system" fn(*mut c_void, u32, *mut c_void) = tls_callback; diff --git a/std/src/sys/thread_local/key/racy.rs b/std/src/sys/thread_local/key/racy.rs index 97df8997b80de..e1bc08eabb358 100644 --- a/std/src/sys/thread_local/key/racy.rs +++ b/std/src/sys/thread_local/key/racy.rs @@ -30,7 +30,6 @@ const KEY_SENTVAL: usize = 0; const KEY_SENTVAL: usize = libc::PTHREAD_KEYS_MAX + 1; impl LazyKey { - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "thread_local_internals", issue = "none"))] pub const fn new(dtor: Option) -> LazyKey { LazyKey { key: atomic::AtomicUsize::new(KEY_SENTVAL), dtor } } diff --git a/std/src/sys/thread_local/key/unix.rs b/std/src/sys/thread_local/key/unix.rs index 28e48a750b9bf..93bd0d1f66850 100644 --- a/std/src/sys/thread_local/key/unix.rs +++ b/std/src/sys/thread_local/key/unix.rs @@ -1,5 +1,25 @@ use crate::mem; +// For WASI add a few symbols not in upstream `libc` just yet. +#[cfg(all(target_os = "wasi", target_env = "p1", target_feature = "atomics"))] +mod libc { + use crate::ffi; + + #[allow(non_camel_case_types)] + pub type pthread_key_t = ffi::c_uint; + + unsafe extern "C" { + pub fn pthread_key_create( + key: *mut pthread_key_t, + destructor: unsafe extern "C" fn(*mut ffi::c_void), + ) -> ffi::c_int; + #[allow(dead_code)] + pub fn pthread_getspecific(key: pthread_key_t) -> *mut ffi::c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const ffi::c_void) -> ffi::c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> ffi::c_int; + } +} + pub type Key = libc::pthread_key_t; #[inline] diff --git a/std/src/sys/thread_local/key/xous.rs b/std/src/sys/thread_local/key/xous.rs index 2ab4bba7d8e98..48dfe17ab3261 100644 --- a/std/src/sys/thread_local/key/xous.rs +++ b/std/src/sys/thread_local/key/xous.rs @@ -51,15 +51,15 @@ const TLS_MEMORY_SIZE: usize = 4096; /// TLS keys start at `1`. Index `0` is unused #[cfg(not(test))] -#[export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key13TLS_KEY_INDEXE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key13TLS_KEY_INDEXE")] static TLS_KEY_INDEX: AtomicUsize = AtomicUsize::new(1); #[cfg(not(test))] -#[export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key9DTORSE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key9DTORSE")] static DTORS: AtomicPtr = AtomicPtr::new(ptr::null_mut()); #[cfg(test)] -extern "Rust" { +unsafe extern "Rust" { #[link_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key13TLS_KEY_INDEXE"] static TLS_KEY_INDEX: AtomicUsize; @@ -85,7 +85,7 @@ fn tls_table() -> &'static mut [*mut u8] { if !tp.is_null() { return unsafe { - core::slice::from_raw_parts_mut(tp, TLS_MEMORY_SIZE / core::mem::size_of::<*mut u8>()) + core::slice::from_raw_parts_mut(tp, TLS_MEMORY_SIZE / size_of::<*mut u8>()) }; } // If the TP register is `0`, then this thread hasn't initialized @@ -94,7 +94,7 @@ fn tls_table() -> &'static mut [*mut u8] { map_memory( None, None, - TLS_MEMORY_SIZE / core::mem::size_of::<*mut u8>(), + TLS_MEMORY_SIZE / size_of::<*mut u8>(), MemoryFlags::R | MemoryFlags::W, ) .expect("Unable to allocate memory for thread local storage") @@ -177,11 +177,8 @@ pub unsafe fn destroy_tls() { // Finally, free the TLS array unsafe { - unmap_memory(core::slice::from_raw_parts_mut( - tp, - TLS_MEMORY_SIZE / core::mem::size_of::(), - )) - .unwrap() + unmap_memory(core::slice::from_raw_parts_mut(tp, TLS_MEMORY_SIZE / size_of::())) + .unwrap() }; } diff --git a/std/src/sys/thread_local/mod.rs b/std/src/sys/thread_local/mod.rs index 31d3b43906004..f0a13323ec93f 100644 --- a/std/src/sys/thread_local/mod.rs +++ b/std/src/sys/thread_local/mod.rs @@ -86,7 +86,9 @@ pub(crate) mod guard { mod windows; pub(crate) use windows::enable; } else if #[cfg(any( - target_family = "wasm", + all(target_family = "wasm", not( + all(target_os = "wasi", target_env = "p1", target_feature = "atomics") + )), target_os = "uefi", target_os = "zkvm", ))] { @@ -135,6 +137,7 @@ pub(crate) mod key { target_family = "unix", ), target_os = "teeos", + all(target_os = "wasi", target_env = "p1", target_feature = "atomics"), ))] { mod racy; mod unix; diff --git a/std/src/sys/thread_local/os.rs b/std/src/sys/thread_local/os.rs index 58f291ffdb985..fe6af27db3a17 100644 --- a/std/src/sys/thread_local/os.rs +++ b/std/src/sys/thread_local/os.rs @@ -28,9 +28,7 @@ pub macro thread_local_inner { // user provided type or type alias with a matching name. Please update the shadowing test // in `tests/thread.rs` if these types are renamed. unsafe { - // Inlining does not work on windows-gnu due to linking errors around - // dllimports. See https://github.com/rust-lang/rust/issues/109797. - $crate::thread::LocalKey::new(#[cfg_attr(windows, inline(never))] |init| { + $crate::thread::LocalKey::new(|init| { static VAL: $crate::thread::local_impl::Storage<$t> = $crate::thread::local_impl::Storage::new(); VAL.get(init, __init) @@ -60,7 +58,6 @@ struct Value { } impl Storage { - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "thread_local_internals", issue = "none"))] pub const fn new() -> Storage { Storage { key: LazyKey::new(Some(destroy_value::)), marker: PhantomData } } diff --git a/std/src/sys_common/io.rs b/std/src/sys_common/io.rs deleted file mode 100644 index 6f6f282d432d6..0000000000000 --- a/std/src/sys_common/io.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Bare metal platforms usually have very small amounts of RAM -// (in the order of hundreds of KB) -pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { 8 * 1024 }; - -#[cfg(test)] -#[allow(dead_code)] // not used on emscripten and wasi -pub mod test { - use rand::RngCore; - - use crate::path::{Path, PathBuf}; - use crate::{env, fs, thread}; - - pub struct TempDir(PathBuf); - - impl TempDir { - pub fn join(&self, path: &str) -> PathBuf { - let TempDir(ref p) = *self; - p.join(path) - } - - pub fn path(&self) -> &Path { - let TempDir(ref p) = *self; - p - } - } - - impl Drop for TempDir { - fn drop(&mut self) { - // Gee, seeing how we're testing the fs module I sure hope that we - // at least implement this correctly! - let TempDir(ref p) = *self; - let result = fs::remove_dir_all(p); - // Avoid panicking while panicking as this causes the process to - // immediately abort, without displaying test results. - if !thread::panicking() { - result.unwrap(); - } - } - } - - #[track_caller] // for `test_rng` - pub fn tmpdir() -> TempDir { - let p = env::temp_dir(); - let mut r = crate::test_helpers::test_rng(); - let ret = p.join(&format!("rust-{}", r.next_u32())); - fs::create_dir(&ret).unwrap(); - TempDir(ret) - } -} diff --git a/std/src/sys_common/mod.rs b/std/src/sys_common/mod.rs index 4f7a131f6bb90..2a5de7f66661c 100644 --- a/std/src/sys_common/mod.rs +++ b/std/src/sys_common/mod.rs @@ -20,26 +20,10 @@ #[cfg(test)] mod tests; -pub mod fs; -pub mod io; pub mod process; pub mod wstr; pub mod wtf8; -cfg_if::cfg_if! { - if #[cfg(any( - all(unix, not(target_os = "l4re")), - windows, - target_os = "hermit", - target_os = "solid_asp3", - all(target_os = "wasi", target_env = "p2") - ))] { - pub mod net; - } else { - pub use crate::sys::net; - } -} - // common error constructors /// A trait for viewing representations from std types diff --git a/std/src/sys_common/process.rs b/std/src/sys_common/process.rs index 5333ee146f7d6..9f61d69d85875 100644 --- a/std/src/sys_common/process.rs +++ b/std/src/sys_common/process.rs @@ -8,19 +8,13 @@ use crate::sys::process::{EnvKey, ExitStatus, Process, StdioPipes}; use crate::{env, fmt, io}; // Stores a set of changes to an environment -#[derive(Clone)] +#[derive(Clone, Default)] pub struct CommandEnv { clear: bool, saw_path: bool, vars: BTreeMap>, } -impl Default for CommandEnv { - fn default() -> Self { - CommandEnv { clear: false, saw_path: false, vars: Default::default() } - } -} - impl fmt::Debug for CommandEnv { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut debug_command_env = f.debug_struct("CommandEnv"); diff --git a/std/src/sys_common/wtf8.rs b/std/src/sys_common/wtf8.rs index 666942bb8a10f..f9ec112b19747 100644 --- a/std/src/sys_common/wtf8.rs +++ b/std/src/sys_common/wtf8.rs @@ -18,7 +18,7 @@ #[cfg(test)] mod tests; -use core::char::{encode_utf8_raw, encode_utf16_raw}; +use core::char::{MAX_LEN_UTF8, MAX_LEN_UTF16, encode_utf8_raw, encode_utf16_raw}; use core::clone::CloneToUninit; use core::str::next_code_point; @@ -156,9 +156,12 @@ impl ops::DerefMut for Wtf8Buf { } } -/// Format the string with double quotes, -/// and surrogates as `\u` followed by four hexadecimal digits. -/// Example: `"a\u{D800}"` for a string with code points [U+0061, U+D800] +/// Formats the string in double quotes, with characters escaped according to +/// [`char::escape_debug`] and unpaired surrogates represented as `\u{xxxx}`, +/// where each `x` is a hexadecimal digit. +/// +/// For example, the code units [U+0061, U+D800, U+000A] are formatted as +/// `"a\u{D800}\n"`. impl fmt::Debug for Wtf8Buf { #[inline] fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -166,6 +169,18 @@ impl fmt::Debug for Wtf8Buf { } } +/// Formats the string with unpaired surrogates substituted with the replacement +/// character, U+FFFD. +impl fmt::Display for Wtf8Buf { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + if let Some(s) = self.as_known_utf8() { + fmt::Display::fmt(s, formatter) + } else { + fmt::Display::fmt(&**self, formatter) + } + } +} + impl Wtf8Buf { /// Creates a new, empty WTF-8 string. #[inline] @@ -181,7 +196,7 @@ impl Wtf8Buf { /// Creates a WTF-8 string from a WTF-8 byte vec. /// - /// Since the byte vec is not checked for valid WTF-8, this functions is + /// Since the byte vec is not checked for valid WTF-8, this function is /// marked unsafe. #[inline] pub unsafe fn from_bytes_unchecked(value: Vec) -> Wtf8Buf { @@ -204,8 +219,8 @@ impl Wtf8Buf { /// /// Since WTF-8 is a superset of UTF-8, this always succeeds. #[inline] - pub fn from_str(str: &str) -> Wtf8Buf { - Wtf8Buf { bytes: <[_]>::to_vec(str.as_bytes()), is_known_utf8: true } + pub fn from_str(s: &str) -> Wtf8Buf { + Wtf8Buf { bytes: s.as_bytes().to_vec(), is_known_utf8: true } } pub fn clear(&mut self) { @@ -237,10 +252,11 @@ impl Wtf8Buf { string } - /// Copied from String::push + /// Appends the given `char` to the end of this string. /// This does **not** include the WTF-8 concatenation check or `is_known_utf8` check. + /// Copied from String::push. fn push_code_point_unchecked(&mut self, code_point: CodePoint) { - let mut bytes = [0; 4]; + let mut bytes = [0; MAX_LEN_UTF8]; let bytes = encode_utf8_raw(code_point.value, &mut bytes); self.bytes.extend_from_slice(bytes) } @@ -258,22 +274,34 @@ impl Wtf8Buf { unsafe { Wtf8::from_mut_bytes_unchecked(&mut self.bytes) } } + /// Converts the string to UTF-8 without validation, if it was created from + /// valid UTF-8. + #[inline] + fn as_known_utf8(&self) -> Option<&str> { + if self.is_known_utf8 { + // SAFETY: The buffer is known to be valid UTF-8. + Some(unsafe { str::from_utf8_unchecked(self.as_bytes()) }) + } else { + None + } + } + /// Reserves capacity for at least `additional` more bytes to be inserted /// in the given `Wtf8Buf`. /// The collection may reserve more space to avoid frequent reallocations. /// /// # Panics /// - /// Panics if the new capacity overflows `usize`. + /// Panics if the new capacity exceeds `isize::MAX` bytes. #[inline] pub fn reserve(&mut self, additional: usize) { self.bytes.reserve(additional) } - /// Tries to reserve capacity for at least `additional` more length units - /// in the given `Wtf8Buf`. The `Wtf8Buf` may reserve more space to avoid - /// frequent reallocations. After calling `try_reserve`, capacity will be - /// greater than or equal to `self.len() + additional`. Does nothing if + /// Tries to reserve capacity for at least `additional` more bytes to be + /// inserted in the given `Wtf8Buf`. The `Wtf8Buf` may reserve more space to + /// avoid frequent reallocations. After calling `try_reserve`, capacity will + /// be greater than or equal to `self.len() + additional`. Does nothing if /// capacity is already sufficient. This method preserves the contents even /// if an error occurs. /// @@ -291,8 +319,8 @@ impl Wtf8Buf { self.bytes.reserve_exact(additional) } - /// Tries to reserve the minimum capacity for exactly `additional` - /// length units in the given `Wtf8Buf`. After calling + /// Tries to reserve the minimum capacity for exactly `additional` more + /// bytes to be inserted in the given `Wtf8Buf`. After calling /// `try_reserve_exact`, capacity will be greater than or equal to /// `self.len() + additional` if it returns `Ok(())`. /// Does nothing if the capacity is already sufficient. @@ -360,7 +388,7 @@ impl Wtf8Buf { _ => { // If we'll be pushing a string containing a surrogate, we may // no longer have UTF-8. - if other.next_surrogate(0).is_some() { + if self.is_known_utf8 && other.next_surrogate(0).is_some() { self.is_known_utf8 = false; } @@ -440,22 +468,17 @@ impl Wtf8Buf { /// /// Surrogates are replaced with `"\u{FFFD}"` (the replacement character “�”) pub fn into_string_lossy(mut self) -> String { - // Fast path: If we already have UTF-8, we can return it immediately. - if self.is_known_utf8 { - return unsafe { String::from_utf8_unchecked(self.bytes) }; - } - - let mut pos = 0; - loop { - match self.next_surrogate(pos) { - Some((surrogate_pos, _)) => { - pos = surrogate_pos + 3; - self.bytes[surrogate_pos..pos] - .copy_from_slice(UTF8_REPLACEMENT_CHARACTER.as_bytes()); - } - None => return unsafe { String::from_utf8_unchecked(self.bytes) }, + if !self.is_known_utf8 { + let mut pos = 0; + while let Some((surrogate_pos, _)) = self.next_surrogate(pos) { + pos = surrogate_pos + 3; + // Surrogates and the replacement character are all 3 bytes, so + // they can substituted in-place. + self.bytes[surrogate_pos..pos] + .copy_from_slice(UTF8_REPLACEMENT_CHARACTER.as_bytes()); } } + unsafe { String::from_utf8_unchecked(self.bytes) } } /// Converts this `Wtf8Buf` into a boxed `Wtf8`. @@ -535,9 +558,9 @@ impl AsInner<[u8]> for Wtf8 { } } -/// Format the slice with double quotes, -/// and surrogates as `\u` followed by four hexadecimal digits. -/// Example: `"a\u{D800}"` for a slice with code points [U+0061, U+D800] +/// Formats the string in double quotes, with characters escaped according to +/// [`char::escape_debug`] and unpaired surrogates represented as `\u{xxxx}`, +/// where each `x` is a hexadecimal digit. impl fmt::Debug for Wtf8 { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fn write_str_escaped(f: &mut fmt::Formatter<'_>, s: &str) -> fmt::Result { @@ -562,6 +585,8 @@ impl fmt::Debug for Wtf8 { } } +/// Formats the string with unpaired surrogates substituted with the replacement +/// character, U+FFFD. impl fmt::Display for Wtf8 { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { let wtf8_bytes = &self.bytes; @@ -672,9 +697,8 @@ impl Wtf8 { /// /// This only copies the data if necessary (if it contains any surrogate). pub fn to_string_lossy(&self) -> Cow<'_, str> { - let surrogate_pos = match self.next_surrogate(0) { - None => return Cow::Borrowed(unsafe { str::from_utf8_unchecked(&self.bytes) }), - Some((pos, _)) => pos, + let Some((surrogate_pos, _)) = self.next_surrogate(0) else { + return Cow::Borrowed(unsafe { str::from_utf8_unchecked(&self.bytes) }); }; let wtf8_bytes = &self.bytes; let mut utf8_bytes = Vec::with_capacity(self.len()); @@ -964,7 +988,7 @@ pub struct Wtf8CodePoints<'a> { bytes: slice::Iter<'a, u8>, } -impl<'a> Iterator for Wtf8CodePoints<'a> { +impl Iterator for Wtf8CodePoints<'_> { type Item = CodePoint; #[inline] @@ -990,7 +1014,7 @@ pub struct EncodeWide<'a> { // Copied from libunicode/u_str.rs #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Iterator for EncodeWide<'a> { +impl Iterator for EncodeWide<'_> { type Item = u16; #[inline] @@ -1001,7 +1025,7 @@ impl<'a> Iterator for EncodeWide<'a> { return Some(tmp); } - let mut buf = [0; 2]; + let mut buf = [0; MAX_LEN_UTF16]; self.code_points.next().map(|code_point| { let n = encode_utf16_raw(code_point.value, &mut buf).len(); if n == 2 { diff --git a/std/src/sys_common/wtf8/tests.rs b/std/src/sys_common/wtf8/tests.rs index bc06eaa2b8fa1..b57c99a8452a1 100644 --- a/std/src/sys_common/wtf8/tests.rs +++ b/std/src/sys_common/wtf8/tests.rs @@ -356,32 +356,32 @@ fn wtf8buf_from_iterator() { fn f(values: &[u32]) -> Wtf8Buf { values.iter().map(|&c| CodePoint::from_u32(c).unwrap()).collect::() } - assert_eq!(f(&[0x61, 0xE9, 0x20, 0x1F4A9]), Wtf8Buf { - bytes: b"a\xC3\xA9 \xF0\x9F\x92\xA9".to_vec(), - is_known_utf8: true - }); + assert_eq!( + f(&[0x61, 0xE9, 0x20, 0x1F4A9]), + Wtf8Buf { bytes: b"a\xC3\xA9 \xF0\x9F\x92\xA9".to_vec(), is_known_utf8: true } + ); assert_eq!(f(&[0xD83D, 0xDCA9]).bytes, b"\xF0\x9F\x92\xA9"); // Magic! - assert_eq!(f(&[0xD83D, 0x20, 0xDCA9]), Wtf8Buf { - bytes: b"\xED\xA0\xBD \xED\xB2\xA9".to_vec(), - is_known_utf8: false - }); - assert_eq!(f(&[0xD800, 0xDBFF]), Wtf8Buf { - bytes: b"\xED\xA0\x80\xED\xAF\xBF".to_vec(), - is_known_utf8: false - }); - assert_eq!(f(&[0xD800, 0xE000]), Wtf8Buf { - bytes: b"\xED\xA0\x80\xEE\x80\x80".to_vec(), - is_known_utf8: false - }); - assert_eq!(f(&[0xD7FF, 0xDC00]), Wtf8Buf { - bytes: b"\xED\x9F\xBF\xED\xB0\x80".to_vec(), - is_known_utf8: false - }); - assert_eq!(f(&[0x61, 0xDC00]), Wtf8Buf { - bytes: b"\x61\xED\xB0\x80".to_vec(), - is_known_utf8: false - }); + assert_eq!( + f(&[0xD83D, 0x20, 0xDCA9]), + Wtf8Buf { bytes: b"\xED\xA0\xBD \xED\xB2\xA9".to_vec(), is_known_utf8: false } + ); + assert_eq!( + f(&[0xD800, 0xDBFF]), + Wtf8Buf { bytes: b"\xED\xA0\x80\xED\xAF\xBF".to_vec(), is_known_utf8: false } + ); + assert_eq!( + f(&[0xD800, 0xE000]), + Wtf8Buf { bytes: b"\xED\xA0\x80\xEE\x80\x80".to_vec(), is_known_utf8: false } + ); + assert_eq!( + f(&[0xD7FF, 0xDC00]), + Wtf8Buf { bytes: b"\xED\x9F\xBF\xED\xB0\x80".to_vec(), is_known_utf8: false } + ); + assert_eq!( + f(&[0x61, 0xDC00]), + Wtf8Buf { bytes: b"\x61\xED\xB0\x80".to_vec(), is_known_utf8: false } + ); assert_eq!(f(&[0xDC00]), Wtf8Buf { bytes: b"\xED\xB0\x80".to_vec(), is_known_utf8: false }); } @@ -396,36 +396,36 @@ fn wtf8buf_extend() { string } - assert_eq!(e(&[0x61, 0xE9], &[0x20, 0x1F4A9]), Wtf8Buf { - bytes: b"a\xC3\xA9 \xF0\x9F\x92\xA9".to_vec(), - is_known_utf8: true - }); + assert_eq!( + e(&[0x61, 0xE9], &[0x20, 0x1F4A9]), + Wtf8Buf { bytes: b"a\xC3\xA9 \xF0\x9F\x92\xA9".to_vec(), is_known_utf8: true } + ); assert_eq!(e(&[0xD83D], &[0xDCA9]).bytes, b"\xF0\x9F\x92\xA9"); // Magic! - assert_eq!(e(&[0xD83D, 0x20], &[0xDCA9]), Wtf8Buf { - bytes: b"\xED\xA0\xBD \xED\xB2\xA9".to_vec(), - is_known_utf8: false - }); - assert_eq!(e(&[0xD800], &[0xDBFF]), Wtf8Buf { - bytes: b"\xED\xA0\x80\xED\xAF\xBF".to_vec(), - is_known_utf8: false - }); - assert_eq!(e(&[0xD800], &[0xE000]), Wtf8Buf { - bytes: b"\xED\xA0\x80\xEE\x80\x80".to_vec(), - is_known_utf8: false - }); - assert_eq!(e(&[0xD7FF], &[0xDC00]), Wtf8Buf { - bytes: b"\xED\x9F\xBF\xED\xB0\x80".to_vec(), - is_known_utf8: false - }); - assert_eq!(e(&[0x61], &[0xDC00]), Wtf8Buf { - bytes: b"\x61\xED\xB0\x80".to_vec(), - is_known_utf8: false - }); - assert_eq!(e(&[], &[0xDC00]), Wtf8Buf { - bytes: b"\xED\xB0\x80".to_vec(), - is_known_utf8: false - }); + assert_eq!( + e(&[0xD83D, 0x20], &[0xDCA9]), + Wtf8Buf { bytes: b"\xED\xA0\xBD \xED\xB2\xA9".to_vec(), is_known_utf8: false } + ); + assert_eq!( + e(&[0xD800], &[0xDBFF]), + Wtf8Buf { bytes: b"\xED\xA0\x80\xED\xAF\xBF".to_vec(), is_known_utf8: false } + ); + assert_eq!( + e(&[0xD800], &[0xE000]), + Wtf8Buf { bytes: b"\xED\xA0\x80\xEE\x80\x80".to_vec(), is_known_utf8: false } + ); + assert_eq!( + e(&[0xD7FF], &[0xDC00]), + Wtf8Buf { bytes: b"\xED\x9F\xBF\xED\xB0\x80".to_vec(), is_known_utf8: false } + ); + assert_eq!( + e(&[0x61], &[0xDC00]), + Wtf8Buf { bytes: b"\x61\xED\xB0\x80".to_vec(), is_known_utf8: false } + ); + assert_eq!( + e(&[], &[0xDC00]), + Wtf8Buf { bytes: b"\xED\xB0\x80".to_vec(), is_known_utf8: false } + ); } #[test] @@ -556,9 +556,10 @@ fn wtf8_encode_wide() { let mut string = Wtf8Buf::from_str("aé "); string.push(CodePoint::from_u32(0xD83D).unwrap()); string.push_char('💩'); - assert_eq!(string.encode_wide().collect::>(), vec![ - 0x61, 0xE9, 0x20, 0xD83D, 0xD83D, 0xDCA9 - ]); + assert_eq!( + string.encode_wide().collect::>(), + vec![0x61, 0xE9, 0x20, 0xD83D, 0xD83D, 0xDCA9] + ); } #[test] diff --git a/std/src/test_helpers.rs b/std/src/test_helpers.rs new file mode 100644 index 0000000000000..7c20f38c863b6 --- /dev/null +++ b/std/src/test_helpers.rs @@ -0,0 +1,65 @@ +use rand::{RngCore, SeedableRng}; + +use crate::hash::{BuildHasher, Hash, Hasher, RandomState}; +use crate::panic::Location; +use crate::path::{Path, PathBuf}; +use crate::{env, fs, thread}; + +/// Test-only replacement for `rand::thread_rng()`, which is unusable for +/// us, as we want to allow running stdlib tests on tier-3 targets which may +/// not have `getrandom` support. +/// +/// Does a bit of a song and dance to ensure that the seed is different on +/// each call (as some tests sadly rely on this), but doesn't try that hard. +/// +/// This is duplicated in the `core`, `alloc` test suites (as well as +/// `std`'s integration tests), but figuring out a mechanism to share these +/// seems far more painful than copy-pasting a 7 line function a couple +/// times, given that even under a perma-unstable feature, I don't think we +/// want to expose types from `rand` from `std`. +#[track_caller] +pub(crate) fn test_rng() -> rand_xorshift::XorShiftRng { + let mut hasher = RandomState::new().build_hasher(); + Location::caller().hash(&mut hasher); + let hc64 = hasher.finish(); + let seed_vec = hc64.to_le_bytes().into_iter().chain(0u8..8).collect::>(); + let seed: [u8; 16] = seed_vec.as_slice().try_into().unwrap(); + SeedableRng::from_seed(seed) +} + +pub struct TempDir(PathBuf); + +impl TempDir { + pub fn join(&self, path: &str) -> PathBuf { + let TempDir(ref p) = *self; + p.join(path) + } + + pub fn path(&self) -> &Path { + let TempDir(ref p) = *self; + p + } +} + +impl Drop for TempDir { + fn drop(&mut self) { + // Gee, seeing how we're testing the fs module I sure hope that we + // at least implement this correctly! + let TempDir(ref p) = *self; + let result = fs::remove_dir_all(p); + // Avoid panicking while panicking as this causes the process to + // immediately abort, without displaying test results. + if !thread::panicking() { + result.unwrap(); + } + } +} + +#[track_caller] // for `test_rng` +pub fn tmpdir() -> TempDir { + let p = env::temp_dir(); + let mut r = test_rng(); + let ret = p.join(&format!("rust-{}", r.next_u32())); + fs::create_dir(&ret).unwrap(); + TempDir(ret) +} diff --git a/std/src/thread/current.rs b/std/src/thread/current.rs index b9b959f98946b..414711298f047 100644 --- a/std/src/thread/current.rs +++ b/std/src/thread/current.rs @@ -15,7 +15,7 @@ local_pointer! { /// /// We store the thread ID so that it never gets destroyed during the lifetime /// of a thread, either using `#[thread_local]` or multiple `local_pointer!`s. -mod id { +pub(super) mod id { use super::*; cfg_if::cfg_if! { @@ -27,7 +27,7 @@ mod id { pub(super) const CHEAP: bool = true; - pub(super) fn get() -> Option { + pub(crate) fn get() -> Option { ID.get() } @@ -44,7 +44,7 @@ mod id { pub(super) const CHEAP: bool = false; - pub(super) fn get() -> Option { + pub(crate) fn get() -> Option { let id0 = ID0.get().addr() as u64; let id16 = ID16.get().addr() as u64; let id32 = ID32.get().addr() as u64; @@ -67,7 +67,7 @@ mod id { pub(super) const CHEAP: bool = false; - pub(super) fn get() -> Option { + pub(crate) fn get() -> Option { let id0 = ID0.get().addr() as u64; let id32 = ID32.get().addr() as u64; ThreadId::from_u64((id32 << 32) + id0) @@ -85,7 +85,7 @@ mod id { pub(super) const CHEAP: bool = true; - pub(super) fn get() -> Option { + pub(crate) fn get() -> Option { let id = ID.get().addr() as u64; ThreadId::from_u64(id) } @@ -112,7 +112,7 @@ mod id { /// Tries to set the thread handle for the current thread. Fails if a handle was /// already set or if the thread ID of `thread` would change an already-set ID. -pub(crate) fn set_current(thread: Thread) -> Result<(), Thread> { +pub(super) fn set_current(thread: Thread) -> Result<(), Thread> { if CURRENT.get() != NONE { return Err(thread); } @@ -136,32 +136,35 @@ pub(crate) fn set_current(thread: Thread) -> Result<(), Thread> { /// one thread and is guaranteed not to call the global allocator. #[inline] pub(crate) fn current_id() -> ThreadId { - // If accessing the persistant thread ID takes multiple TLS accesses, try + // If accessing the persistent thread ID takes multiple TLS accesses, try // to retrieve it from the current thread handle, which will only take one // TLS access. if !id::CHEAP { - let current = CURRENT.get(); - if current > DESTROYED { - unsafe { - let current = ManuallyDrop::new(Thread::from_raw(current)); - return current.id(); - } + if let Some(id) = try_with_current(|t| t.map(|t| t.id())) { + return id; } } id::get_or_init() } -/// Gets a handle to the thread that invokes it, if the handle has been initialized. -pub(crate) fn try_current() -> Option { +/// Gets a reference to the handle of the thread that invokes it, if the handle +/// has been initialized. +pub(super) fn try_with_current(f: F) -> R +where + F: FnOnce(Option<&Thread>) -> R, +{ let current = CURRENT.get(); if current > DESTROYED { + // SAFETY: `Arc` does not contain interior mutability, so it does not + // matter that the address of the handle might be different depending + // on where this is called. unsafe { let current = ManuallyDrop::new(Thread::from_raw(current)); - Some((*current).clone()) + f(Some(¤t)) } } else { - None + f(None) } } @@ -176,7 +179,7 @@ pub(crate) fn current_or_unnamed() -> Thread { (*current).clone() } } else if current == DESTROYED { - Thread::new_unnamed(id::get_or_init()) + Thread::new(id::get_or_init(), None) } else { init_current(current) } @@ -221,7 +224,7 @@ fn init_current(current: *mut ()) -> Thread { CURRENT.set(BUSY); // If the thread ID was initialized already, use it. let id = id::get_or_init(); - let thread = Thread::new_unnamed(id); + let thread = Thread::new(id, None); // Make sure that `crate::rt::thread_cleanup` will be run, which will // call `drop_current`. @@ -243,17 +246,17 @@ fn init_current(current: *mut ()) -> Thread { // a particular API should be entirely allocation-free, feel free to open // an issue on the Rust repository, we'll see what we can do. rtabort!( - "\n - Attempted to access thread-local data while allocating said data.\n - Do not access functions that allocate in the global allocator!\n - This is a bug in the global allocator.\n - " + "\n\ + Attempted to access thread-local data while allocating said data.\n\ + Do not access functions that allocate in the global allocator!\n\ + This is a bug in the global allocator.\n\ + " ) } else { debug_assert_eq!(current, DESTROYED); panic!( - "use of std::thread::current() is not possible after the thread's - local data has been destroyed" + "use of std::thread::current() is not possible after the thread's \ + local data has been destroyed" ) } } diff --git a/std/src/thread/local.rs b/std/src/thread/local.rs index 9edb3fa41933d..d5a5d10205dd8 100644 --- a/std/src/thread/local.rs +++ b/std/src/thread/local.rs @@ -2,17 +2,11 @@ #![unstable(feature = "thread_local_internals", issue = "none")] -#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] -mod tests; - -#[cfg(test)] -mod dynamic_tests; - use crate::cell::{Cell, RefCell}; use crate::error::Error; use crate::fmt; -/// A thread local storage key which owns its contents. +/// A thread local storage (TLS) key which owns its contents. /// /// This key uses the fastest possible implementation available to it for the /// target platform. It is instantiated with the [`thread_local!`] macro and the @@ -56,7 +50,8 @@ use crate::fmt; /// use std::cell::Cell; /// use std::thread; /// -/// thread_local!(static FOO: Cell = Cell::new(1)); +/// // explicit `const {}` block enables more efficient initialization +/// thread_local!(static FOO: Cell = const { Cell::new(1) }); /// /// assert_eq!(FOO.get(), 1); /// FOO.set(2); @@ -144,7 +139,7 @@ impl fmt::Debug for LocalKey { /// use std::cell::{Cell, RefCell}; /// /// thread_local! { -/// pub static FOO: Cell = Cell::new(1); +/// pub static FOO: Cell = const { Cell::new(1) }; /// /// static BAR: RefCell> = RefCell::new(vec![1.0, 2.0]); /// } @@ -230,6 +225,14 @@ impl fmt::Display for AccessError { #[stable(feature = "thread_local_try_with", since = "1.26.0")] impl Error for AccessError {} +// This ensures the panicking code is outlined from `with` for `LocalKey`. +#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] +#[track_caller] +#[cold] +fn panic_access_error(err: AccessError) -> ! { + panic!("cannot access a Thread Local Storage value during or after destruction: {err:?}") +} + impl LocalKey { #[doc(hidden)] #[unstable( @@ -237,7 +240,6 @@ impl LocalKey { reason = "recently added to create a key", issue = "none" )] - #[cfg_attr(bootstrap, rustc_const_unstable(feature = "thread_local_internals", issue = "none"))] pub const unsafe fn new(inner: fn(Option<&mut Option>) -> *const T) -> LocalKey { LocalKey { inner } } @@ -252,15 +254,28 @@ impl LocalKey { /// This function will `panic!()` if the key currently has its /// destructor running, and it **may** panic if the destructor has /// previously been run for this thread. + /// + /// # Examples + /// + /// ``` + /// thread_local! { + /// pub static STATIC: String = String::from("I am"); + /// } + /// + /// assert_eq!( + /// STATIC.with(|original_value| format!("{original_value} initialized")), + /// "I am initialized", + /// ); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn with(&'static self, f: F) -> R where F: FnOnce(&T) -> R, { - self.try_with(f).expect( - "cannot access a Thread Local Storage value \ - during or after destruction", - ) + match self.try_with(f) { + Ok(r) => r, + Err(err) => panic_access_error(err), + } } /// Acquires a reference to the value in this TLS key. @@ -273,6 +288,19 @@ impl LocalKey { /// /// This function will still `panic!()` if the key is uninitialized and the /// key's initializer panics. + /// + /// # Examples + /// + /// ``` + /// thread_local! { + /// pub static STATIC: String = String::from("I am"); + /// } + /// + /// assert_eq!( + /// STATIC.try_with(|original_value| format!("{original_value} initialized")), + /// Ok(String::from("I am initialized")), + /// ); + /// ``` #[stable(feature = "thread_local_try_with", since = "1.26.0")] #[inline] pub fn try_with(&'static self, f: F) -> Result @@ -302,10 +330,10 @@ impl LocalKey { let mut init = Some(init); let reference = unsafe { - (self.inner)(Some(&mut init)).as_ref().expect( - "cannot access a Thread Local Storage value \ - during or after destruction", - ) + match (self.inner)(Some(&mut init)).as_ref() { + Some(r) => r, + None => panic_access_error(AccessError), + } }; f(init, reference) @@ -367,7 +395,7 @@ impl LocalKey> { /// use std::cell::Cell; /// /// thread_local! { - /// static X: Cell = Cell::new(1); + /// static X: Cell = const { Cell::new(1) }; /// } /// /// assert_eq!(X.get(), 1); @@ -396,7 +424,7 @@ impl LocalKey> { /// use std::cell::Cell; /// /// thread_local! { - /// static X: Cell> = Cell::new(Some(1)); + /// static X: Cell> = const { Cell::new(Some(1)) }; /// } /// /// assert_eq!(X.take(), Some(1)); @@ -426,7 +454,7 @@ impl LocalKey> { /// use std::cell::Cell; /// /// thread_local! { - /// static X: Cell = Cell::new(1); + /// static X: Cell = const { Cell::new(1) }; /// } /// /// assert_eq!(X.replace(2), 1); @@ -452,7 +480,7 @@ impl LocalKey> { /// Panics if the key currently has its destructor running, /// and it **may** panic if the destructor has previously been run for this thread. /// - /// # Example + /// # Examples /// /// ``` /// use std::cell::RefCell; @@ -483,7 +511,7 @@ impl LocalKey> { /// Panics if the key currently has its destructor running, /// and it **may** panic if the destructor has previously been run for this thread. /// - /// # Example + /// # Examples /// /// ``` /// use std::cell::RefCell; diff --git a/std/src/thread/mod.rs b/std/src/thread/mod.rs index 2ff44fcd4c6b7..3f3ba02361cc8 100644 --- a/std/src/thread/mod.rs +++ b/std/src/thread/mod.rs @@ -158,12 +158,9 @@ #[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] mod tests; -use core::cell::SyncUnsafeCell; -use core::ffi::CStr; -use core::mem::MaybeUninit; - use crate::any::Any; use crate::cell::UnsafeCell; +use crate::ffi::CStr; use crate::marker::PhantomData; use crate::mem::{self, ManuallyDrop, forget}; use crate::num::NonZero; @@ -186,7 +183,8 @@ mod current; #[stable(feature = "rust1", since = "1.0.0")] pub use current::current; -pub(crate) use current::{current_id, current_or_unnamed, drop_current, set_current, try_current}; +pub(crate) use current::{current_id, current_or_unnamed, drop_current}; +use current::{set_current, try_with_current}; mod spawnhook; @@ -391,6 +389,7 @@ impl Builder { /// handler.join().unwrap(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn spawn(self, f: F) -> io::Result> where F: FnOnce() -> T, @@ -458,6 +457,7 @@ impl Builder { /// /// [`io::Result`]: crate::io::Result #[stable(feature = "thread_spawn_unchecked", since = "1.82.0")] + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub unsafe fn spawn_unchecked(self, f: F) -> io::Result> where F: FnOnce() -> T, @@ -467,6 +467,7 @@ impl Builder { Ok(JoinHandle(unsafe { self.spawn_unchecked_(f, None) }?)) } + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces unsafe fn spawn_unchecked_<'scope, F, T>( self, f: F, @@ -498,10 +499,7 @@ impl Builder { }); let id = ThreadId::new(); - let my_thread = match name { - Some(name) => Thread::new(id, name.into()), - None => Thread::new_unnamed(id), - }; + let my_thread = Thread::new(id, name); let hooks = if no_hooks { spawnhook::ChildSpawnHooks::default() @@ -721,6 +719,7 @@ impl Builder { /// [`join`]: JoinHandle::join /// [`Err`]: crate::result::Result::Err #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn spawn(f: F) -> JoinHandle where F: FnOnce() -> T, @@ -1021,11 +1020,11 @@ impl Drop for PanicGuard { /// /// # Memory Ordering /// -/// Calls to `park` _synchronize-with_ calls to `unpark`, meaning that memory +/// Calls to `unpark` _synchronize-with_ calls to `park`, meaning that memory /// operations performed before a call to `unpark` are made visible to the thread that /// consumes the token and returns from `park`. Note that all `park` and `unpark` -/// operations for a given thread form a total order and `park` synchronizes-with -/// _all_ prior `unpark` operations. +/// operations for a given thread form a total order and _all_ prior `unpark` operations +/// synchronize-with `park`. /// /// In atomic ordering terms, `unpark` performs a `Release` operation and `park` /// performs the corresponding `Acquire` operation. Calls to `unpark` for the same @@ -1231,7 +1230,7 @@ impl ThreadId { } } - #[cfg(not(target_thread_local))] + #[cfg(any(not(target_thread_local), target_has_atomic = "64"))] fn from_u64(v: u64) -> Option { NonZero::new(v).map(ThreadId) } @@ -1257,29 +1256,14 @@ impl ThreadId { // This module ensures private fields are kept private, which is necessary to enforce the safety requirements. mod thread_name_string { - use core::str; - use crate::ffi::{CStr, CString}; + use crate::str; /// Like a `String` it's guaranteed UTF-8 and like a `CString` it's null terminated. pub(crate) struct ThreadNameString { inner: CString, } - impl ThreadNameString { - pub fn as_str(&self) -> &str { - // SAFETY: `self.inner` is only initialised via `String`, which upholds the validity invariant of `str`. - unsafe { str::from_utf8_unchecked(self.inner.to_bytes()) } - } - } - - impl core::ops::Deref for ThreadNameString { - type Target = CStr; - fn deref(&self) -> &CStr { - &self.inner - } - } - impl From for ThreadNameString { fn from(s: String) -> Self { Self { @@ -1287,82 +1271,124 @@ mod thread_name_string { } } } -} -pub(crate) use thread_name_string::ThreadNameString; - -static MAIN_THREAD_INFO: SyncUnsafeCell<(MaybeUninit, MaybeUninit)> = - SyncUnsafeCell::new((MaybeUninit::uninit(), MaybeUninit::uninit())); - -/// The internal representation of a `Thread` that is not the main thread. -struct OtherInner { - name: Option, - id: ThreadId, - parker: Parker, -} - -/// The internal representation of a `Thread` handle. -#[derive(Clone)] -enum Inner { - /// Represents the main thread. May only be constructed by Thread::new_main. - Main(&'static (ThreadId, Parker)), - /// Represents any other thread. - Other(Pin>), -} - -impl Inner { - fn id(&self) -> ThreadId { - match self { - Self::Main((thread_id, _)) => *thread_id, - Self::Other(other) => other.id, - } - } - fn cname(&self) -> Option<&CStr> { - match self { - Self::Main(_) => Some(c"main"), - Self::Other(other) => other.name.as_deref(), + impl ThreadNameString { + pub fn as_cstr(&self) -> &CStr { + &self.inner } - } - fn name(&self) -> Option<&str> { - match self { - Self::Main(_) => Some("main"), - Self::Other(other) => other.name.as_ref().map(ThreadNameString::as_str), + pub fn as_str(&self) -> &str { + // SAFETY: `ThreadNameString` is guaranteed to be UTF-8. + unsafe { str::from_utf8_unchecked(self.inner.to_bytes()) } } } +} - fn into_raw(self) -> *const () { - match self { - // Just return the pointer to `MAIN_THREAD_INFO`. - Self::Main(ptr) => crate::ptr::from_ref(ptr).cast(), - Self::Other(arc) => { - // Safety: We only expose an opaque pointer, which maintains the `Pin` invariant. - let inner = unsafe { Pin::into_inner_unchecked(arc) }; - Arc::into_raw(inner) as *const () +use thread_name_string::ThreadNameString; + +/// Store the ID of the main thread. +/// +/// The thread handle for the main thread is created lazily, and this might even +/// happen pre-main. Since not every platform has a way to identify the main +/// thread when that happens – macOS's `pthread_main_np` function being a notable +/// exception – we cannot assign it the right name right then. Instead, in our +/// runtime startup code, we remember the thread ID of the main thread (through +/// this modules `set` function) and use it to identify the main thread from then +/// on. This works reliably and has the additional advantage that we can report +/// the right thread name on main even after the thread handle has been destroyed. +/// Note however that this also means that the name reported in pre-main functions +/// will be incorrect, but that's just something we have to live with. +pub(crate) mod main_thread { + cfg_if::cfg_if! { + if #[cfg(target_has_atomic = "64")] { + use super::ThreadId; + use crate::sync::atomic::AtomicU64; + use crate::sync::atomic::Ordering::Relaxed; + + static MAIN: AtomicU64 = AtomicU64::new(0); + + pub(super) fn get() -> Option { + ThreadId::from_u64(MAIN.load(Relaxed)) } - } - } - /// # Safety - /// - /// See [`Thread::from_raw`]. - unsafe fn from_raw(ptr: *const ()) -> Self { - // If the pointer is to `MAIN_THREAD_INFO`, we know it is the `Main` variant. - if crate::ptr::eq(ptr.cast(), &MAIN_THREAD_INFO) { - Self::Main(unsafe { &*ptr.cast() }) + /// # Safety + /// May only be called once. + pub(crate) unsafe fn set(id: ThreadId) { + MAIN.store(id.as_u64().get(), Relaxed) + } } else { - // Safety: Upheld by caller - Self::Other(unsafe { Pin::new_unchecked(Arc::from_raw(ptr as *const OtherInner)) }) + use super::ThreadId; + use crate::mem::MaybeUninit; + use crate::sync::atomic::AtomicBool; + use crate::sync::atomic::Ordering::{Acquire, Release}; + + static INIT: AtomicBool = AtomicBool::new(false); + static mut MAIN: MaybeUninit = MaybeUninit::uninit(); + + pub(super) fn get() -> Option { + if INIT.load(Acquire) { + Some(unsafe { MAIN.assume_init() }) + } else { + None + } + } + + /// # Safety + /// May only be called once. + pub(crate) unsafe fn set(id: ThreadId) { + unsafe { MAIN = MaybeUninit::new(id) }; + INIT.store(true, Release); + } } } +} - fn parker(&self) -> Pin<&Parker> { - match self { - Self::Main((_, parker_ref)) => Pin::static_ref(parker_ref), - Self::Other(inner) => unsafe { - Pin::map_unchecked(inner.as_ref(), |inner| &inner.parker) - }, +/// Run a function with the current thread's name. +/// +/// Modulo thread local accesses, this function is safe to call from signal +/// handlers and in similar circumstances where allocations are not possible. +pub(crate) fn with_current_name(f: F) -> R +where + F: FnOnce(Option<&str>) -> R, +{ + try_with_current(|thread| { + if let Some(thread) = thread { + // If there is a current thread handle, try to use the name stored + // there. + if let Some(name) = &thread.inner.name { + return f(Some(name.as_str())); + } else if Some(thread.inner.id) == main_thread::get() { + // The main thread doesn't store its name in the handle, we must + // identify it through its ID. Since we already have the `Thread`, + // we can retrieve the ID from it instead of going through another + // thread local. + return f(Some("main")); + } + } else if let Some(main) = main_thread::get() + && let Some(id) = current::id::get() + && id == main + { + // The main thread doesn't always have a thread handle, we must + // identify it through its ID instead. The checks are ordered so + // that the current ID is only loaded if it is actually needed, + // since loading it from TLS might need multiple expensive accesses. + return f(Some("main")); } + + f(None) + }) +} + +/// The internal representation of a `Thread` handle +struct Inner { + name: Option, + id: ThreadId, + parker: Parker, +} + +impl Inner { + fn parker(self: Pin<&Self>) -> Pin<&Parker> { + unsafe { Pin::map_unchecked(self, |inner| &inner.parker) } } } @@ -1386,47 +1412,21 @@ impl Inner { /// docs of [`Builder`] and [`spawn`] for more details. /// /// [`thread::current`]: current::current -pub struct Thread(Inner); +pub struct Thread { + inner: Pin>, +} impl Thread { - /// Used only internally to construct a thread object without spawning. - pub(crate) fn new(id: ThreadId, name: String) -> Thread { - Self::new_inner(id, Some(ThreadNameString::from(name))) - } + pub(crate) fn new(id: ThreadId, name: Option) -> Thread { + let name = name.map(ThreadNameString::from); - pub(crate) fn new_unnamed(id: ThreadId) -> Thread { - Self::new_inner(id, None) - } - - /// Used in runtime to construct main thread - /// - /// # Safety - /// - /// This must only ever be called once, and must be called on the main thread. - pub(crate) unsafe fn new_main(thread_id: ThreadId) -> Thread { - // Safety: As this is only called once and on the main thread, nothing else is accessing MAIN_THREAD_INFO - // as the only other read occurs in `main_thread_info` *after* the main thread has been constructed, - // and this function is the only one that constructs the main thread. - // - // Pre-main thread spawning cannot hit this either, as the caller promises that this is only called on the main thread. - let main_thread_info = unsafe { &mut *MAIN_THREAD_INFO.get() }; - - unsafe { Parker::new_in_place((&raw mut main_thread_info.1).cast()) }; - main_thread_info.0.write(thread_id); - - // Store a `'static` ref to the initialised ThreadId and Parker, - // to avoid having to repeatedly prove initialisation. - Self(Inner::Main(unsafe { &*MAIN_THREAD_INFO.get().cast() })) - } - - fn new_inner(id: ThreadId, name: Option) -> Thread { // We have to use `unsafe` here to construct the `Parker` in-place, // which is required for the UNIX implementation. // // SAFETY: We pin the Arc immediately after creation, so its address never // changes. let inner = unsafe { - let mut arc = Arc::::new_uninit(); + let mut arc = Arc::::new_uninit(); let ptr = Arc::get_mut_unchecked(&mut arc).as_mut_ptr(); (&raw mut (*ptr).name).write(name); (&raw mut (*ptr).id).write(id); @@ -1434,7 +1434,7 @@ impl Thread { Pin::new_unchecked(arc.assume_init()) }; - Self(Inner::Other(inner)) + Thread { inner } } /// Like the public [`park`], but callable on any handle. This is used to @@ -1443,7 +1443,7 @@ impl Thread { /// # Safety /// May only be called from the thread to which this handle belongs. pub(crate) unsafe fn park(&self) { - unsafe { self.0.parker().park() } + unsafe { self.inner.as_ref().parker().park() } } /// Like the public [`park_timeout`], but callable on any handle. This is @@ -1452,7 +1452,7 @@ impl Thread { /// # Safety /// May only be called from the thread to which this handle belongs. pub(crate) unsafe fn park_timeout(&self, dur: Duration) { - unsafe { self.0.parker().park_timeout(dur) } + unsafe { self.inner.as_ref().parker().park_timeout(dur) } } /// Atomically makes the handle's token available if it is not already. @@ -1488,7 +1488,7 @@ impl Thread { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn unpark(&self) { - self.0.parker().unpark(); + self.inner.as_ref().parker().unpark(); } /// Gets the thread's unique identifier. @@ -1508,7 +1508,7 @@ impl Thread { #[stable(feature = "thread_id", since = "1.19.0")] #[must_use] pub fn id(&self) -> ThreadId { - self.0.id() + self.inner.id } /// Gets the thread's name. @@ -1551,11 +1551,13 @@ impl Thread { #[stable(feature = "rust1", since = "1.0.0")] #[must_use] pub fn name(&self) -> Option<&str> { - self.0.name() - } - - fn cname(&self) -> Option<&CStr> { - self.0.cname() + if let Some(name) = &self.inner.name { + Some(name.as_str()) + } else if main_thread::get() == Some(self.inner.id) { + Some("main") + } else { + None + } } /// Consumes the `Thread`, returning a raw pointer. @@ -1579,7 +1581,9 @@ impl Thread { /// ``` #[unstable(feature = "thread_raw", issue = "97523")] pub fn into_raw(self) -> *const () { - self.0.into_raw() + // Safety: We only expose an opaque pointer, which maintains the `Pin` invariant. + let inner = unsafe { Pin::into_inner_unchecked(self.inner) }; + Arc::into_raw(inner) as *const () } /// Constructs a `Thread` from a raw pointer. @@ -1601,7 +1605,17 @@ impl Thread { #[unstable(feature = "thread_raw", issue = "97523")] pub unsafe fn from_raw(ptr: *const ()) -> Thread { // Safety: Upheld by caller. - unsafe { Thread(Inner::from_raw(ptr)) } + unsafe { Thread { inner: Pin::new_unchecked(Arc::from_raw(ptr as *const Inner)) } } + } + + fn cname(&self) -> Option<&CStr> { + if let Some(name) = &self.inner.name { + Some(name.as_cstr()) + } else if main_thread::get() == Some(self.inner.id) { + Some(c"main") + } else { + None + } } } @@ -1725,7 +1739,16 @@ struct JoinInner<'scope, T> { impl<'scope, T> JoinInner<'scope, T> { fn join(mut self) -> Result { self.native.join(); - Arc::get_mut(&mut self.packet).unwrap().result.get_mut().take().unwrap() + Arc::get_mut(&mut self.packet) + // FIXME(fuzzypixelz): returning an error instead of panicking here + // would require updating the documentation of + // `std::thread::Result`; currently we can return `Err` if and only + // if the thread had panicked. + .expect("threads should not terminate unexpectedly") + .result + .get_mut() + .take() + .unwrap() } } diff --git a/std/src/thread/tests.rs b/std/src/thread/tests.rs index ff45e82bd9c71..06c347af1819f 100644 --- a/std/src/thread/tests.rs +++ b/std/src/thread/tests.rs @@ -1,12 +1,12 @@ use super::Builder; use crate::any::Any; use crate::panic::panic_any; +use crate::result; use crate::sync::atomic::{AtomicBool, Ordering}; use crate::sync::mpsc::{Sender, channel}; use crate::sync::{Arc, Barrier}; use crate::thread::{self, Scope, ThreadId}; use crate::time::{Duration, Instant}; -use crate::{mem, result}; // !!! These tests are dangerous. If something is buggy, they will hang, !!! // !!! instead of exiting cleanly. This might wedge the buildbots. !!! @@ -327,7 +327,7 @@ fn sleep_ms_smoke() { #[test] fn test_size_of_option_thread_id() { - assert_eq!(mem::size_of::>(), mem::size_of::()); + assert_eq!(size_of::>(), size_of::()); } #[test] diff --git a/std/src/time.rs b/std/src/time.rs index 9f4f8a0d0880c..5ab71413586dc 100644 --- a/std/src/time.rs +++ b/std/src/time.rs @@ -31,9 +31,6 @@ #![stable(feature = "time", since = "1.3.0")] -#[cfg(test)] -mod tests; - #[stable(feature = "time", since = "1.3.0")] pub use core::time::Duration; #[stable(feature = "duration_checked_float", since = "1.66.0")] @@ -96,11 +93,17 @@ use crate::sys_common::{FromInner, IntoInner}; /// use std::time::{Instant, Duration}; /// /// let now = Instant::now(); -/// let max_seconds = u64::MAX / 1_000_000_000; -/// let duration = Duration::new(max_seconds, 0); +/// let days_per_10_millennia = 365_2425; +/// let solar_seconds_per_day = 60 * 60 * 24; +/// let millenium_in_solar_seconds = 31_556_952_000; +/// assert_eq!(millenium_in_solar_seconds, days_per_10_millennia * solar_seconds_per_day / 10); +/// +/// let duration = Duration::new(millenium_in_solar_seconds, 0); /// println!("{:?}", now + duration); /// ``` /// +/// For cross-platform code, you can comfortably use durations of up to around one hundred years. +/// /// # Underlying System calls /// /// The following system calls are [currently] being used by `now()` to find out diff --git a/std/tests/common/mod.rs b/std/tests/common/mod.rs index 7cf70c725e411..1e8e4cced6c03 100644 --- a/std/tests/common/mod.rs +++ b/std/tests/common/mod.rs @@ -18,7 +18,7 @@ pub(crate) fn test_rng() -> rand_xorshift::XorShiftRng { rand::SeedableRng::from_seed(seed) } -// Copied from std::sys_common::io +// Copied from std::test_helpers pub(crate) struct TempDir(PathBuf); impl TempDir { diff --git a/std/tests/env.rs b/std/tests/env.rs index 4e472b4ce9953..e754cf8263b0f 100644 --- a/std/tests/env.rs +++ b/std/tests/env.rs @@ -1,163 +1,123 @@ use std::env::*; -use std::ffi::{OsStr, OsString}; - -use rand::distributions::{Alphanumeric, DistString}; +use std::path::Path; mod common; -use std::thread; - -use common::test_rng; - -#[track_caller] -fn make_rand_name() -> OsString { - let n = format!("TEST{}", Alphanumeric.sample_string(&mut test_rng(), 10)); - let n = OsString::from(n); - assert!(var_os(&n).is_none()); - n -} - -fn eq(a: Option, b: Option<&str>) { - assert_eq!(a.as_ref().map(|s| &**s), b.map(OsStr::new).map(|s| &*s)); -} #[test] -fn test_set_var() { - let n = make_rand_name(); - set_var(&n, "VALUE"); - eq(var_os(&n), Some("VALUE")); +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi", target_env = "sgx"), ignore)] +fn test_self_exe_path() { + let path = current_exe(); + assert!(path.is_ok()); + let path = path.unwrap(); + + // Hard to test this function + assert!(path.is_absolute()); } #[test] -fn test_remove_var() { - let n = make_rand_name(); - set_var(&n, "VALUE"); - remove_var(&n); - eq(var_os(&n), None); -} +fn test() { + assert!((!Path::new("test-path").is_absolute())); -#[test] -fn test_set_var_overwrite() { - let n = make_rand_name(); - set_var(&n, "1"); - set_var(&n, "2"); - eq(var_os(&n), Some("2")); - set_var(&n, ""); - eq(var_os(&n), Some("")); + #[cfg(not(target_env = "sgx"))] + current_dir().unwrap(); } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] -fn test_var_big() { - let mut s = "".to_string(); - let mut i = 0; - while i < 100 { - s.push_str("aaaaaaaaaa"); - i += 1; +#[cfg(windows)] +fn split_paths_windows() { + use std::path::PathBuf; + + fn check_parse(unparsed: &str, parsed: &[&str]) -> bool { + split_paths(unparsed).collect::>() + == parsed.iter().map(|s| PathBuf::from(*s)).collect::>() } - let n = make_rand_name(); - set_var(&n, &s); - eq(var_os(&n), Some(&s)); -} -#[test] -#[cfg_attr(target_os = "emscripten", ignore)] -fn test_env_set_get_huge() { - let n = make_rand_name(); - let s = "x".repeat(10000); - set_var(&n, &s); - eq(var_os(&n), Some(&s)); - remove_var(&n); - eq(var_os(&n), None); + assert!(check_parse("", &mut [""])); + assert!(check_parse(r#""""#, &mut [""])); + assert!(check_parse(";;", &mut ["", "", ""])); + assert!(check_parse(r"c:\", &mut [r"c:\"])); + assert!(check_parse(r"c:\;", &mut [r"c:\", ""])); + assert!(check_parse(r"c:\;c:\Program Files\", &mut [r"c:\", r"c:\Program Files\"])); + assert!(check_parse(r#"c:\;c:\"foo"\"#, &mut [r"c:\", r"c:\foo\"])); + assert!(check_parse(r#"c:\;c:\"foo;bar"\;c:\baz"#, &mut [r"c:\", r"c:\foo;bar\", r"c:\baz"])); } #[test] -fn test_env_set_var() { - let n = make_rand_name(); +#[cfg(unix)] +fn split_paths_unix() { + use std::path::PathBuf; - let mut e = vars_os(); - set_var(&n, "VALUE"); - assert!(!e.any(|(k, v)| { &*k == &*n && &*v == "VALUE" })); + fn check_parse(unparsed: &str, parsed: &[&str]) -> bool { + split_paths(unparsed).collect::>() + == parsed.iter().map(|s| PathBuf::from(*s)).collect::>() + } - assert!(vars_os().any(|(k, v)| { &*k == &*n && &*v == "VALUE" })); + assert!(check_parse("", &mut [""])); + assert!(check_parse("::", &mut ["", "", ""])); + assert!(check_parse("/", &mut ["/"])); + assert!(check_parse("/:", &mut ["/", ""])); + assert!(check_parse("/:/usr/local", &mut ["/", "/usr/local"])); } #[test] -#[cfg_attr(not(any(unix, windows)), ignore, allow(unused))] -#[allow(deprecated)] -fn env_home_dir() { - use std::path::PathBuf; +#[cfg(unix)] +fn join_paths_unix() { + use std::ffi::OsStr; - fn var_to_os_string(var: Result) -> Option { - match var { - Ok(var) => Some(OsString::from(var)), - Err(VarError::NotUnicode(var)) => Some(var), - _ => None, - } + fn test_eq(input: &[&str], output: &str) -> bool { + &*join_paths(input.iter().cloned()).unwrap() == OsStr::new(output) } - cfg_if::cfg_if! { - if #[cfg(unix)] { - let oldhome = var_to_os_string(var("HOME")); - - set_var("HOME", "/home/MountainView"); - assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); - - remove_var("HOME"); - if cfg!(target_os = "android") { - assert!(home_dir().is_none()); - } else { - // When HOME is not set, some platforms return `None`, - // but others return `Some` with a default. - // Just check that it is not "/home/MountainView". - assert_ne!(home_dir(), Some(PathBuf::from("/home/MountainView"))); - } - - if let Some(oldhome) = oldhome { set_var("HOME", oldhome); } - } else if #[cfg(windows)] { - let oldhome = var_to_os_string(var("HOME")); - let olduserprofile = var_to_os_string(var("USERPROFILE")); - - remove_var("HOME"); - remove_var("USERPROFILE"); - - assert!(home_dir().is_some()); + assert!(test_eq(&[], "")); + assert!(test_eq(&["/bin", "/usr/bin", "/usr/local/bin"], "/bin:/usr/bin:/usr/local/bin")); + assert!(test_eq(&["", "/bin", "", "", "/usr/bin", ""], ":/bin:::/usr/bin:")); + assert!(join_paths(["/te:st"].iter().cloned()).is_err()); +} - set_var("HOME", "/home/MountainView"); - assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); +#[test] +#[cfg(windows)] +fn join_paths_windows() { + use std::ffi::OsStr; - remove_var("HOME"); + fn test_eq(input: &[&str], output: &str) -> bool { + &*join_paths(input.iter().cloned()).unwrap() == OsStr::new(output) + } - set_var("USERPROFILE", "/home/MountainView"); - assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); + assert!(test_eq(&[], "")); + assert!(test_eq(&[r"c:\windows", r"c:\"], r"c:\windows;c:\")); + assert!(test_eq(&["", r"c:\windows", "", "", r"c:\", ""], r";c:\windows;;;c:\;")); + assert!(test_eq(&[r"c:\te;st", r"c:\"], r#""c:\te;st";c:\"#)); + assert!(join_paths([r#"c:\te"st"#].iter().cloned()).is_err()); +} - set_var("HOME", "/home/MountainView"); - set_var("USERPROFILE", "/home/PaloAlto"); - assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); +#[test] +fn args_debug() { + assert_eq!( + format!("Args {{ inner: {:?} }}", args().collect::>()), + format!("{:?}", args()) + ); +} - remove_var("HOME"); - remove_var("USERPROFILE"); +#[test] +fn args_os_debug() { + assert_eq!( + format!("ArgsOs {{ inner: {:?} }}", args_os().collect::>()), + format!("{:?}", args_os()) + ); +} - if let Some(oldhome) = oldhome { set_var("HOME", oldhome); } - if let Some(olduserprofile) = olduserprofile { set_var("USERPROFILE", olduserprofile); } - } - } +#[test] +fn vars_debug() { + assert_eq!( + format!("Vars {{ inner: {:?} }}", vars().collect::>()), + format!("{:?}", vars()) + ); } -#[test] // miri shouldn't detect any data race in this fn -#[cfg_attr(any(not(miri), target_os = "emscripten"), ignore)] -fn test_env_get_set_multithreaded() { - let getter = thread::spawn(|| { - for _ in 0..100 { - let _ = var_os("foo"); - } - }); - - let setter = thread::spawn(|| { - for _ in 0..100 { - set_var("foo", "bar"); - } - }); - - let _ = getter.join(); - let _ = setter.join(); +#[test] +fn vars_os_debug() { + assert_eq!( + format!("VarsOs {{ inner: {:?} }}", vars_os().collect::>()), + format!("{:?}", vars_os()) + ); } diff --git a/std/tests/env_modify.rs b/std/tests/env_modify.rs new file mode 100644 index 0000000000000..ba84978b35f8f --- /dev/null +++ b/std/tests/env_modify.rs @@ -0,0 +1,184 @@ +// These tests are in a separate integration test as they modify the environment, +// and would otherwise cause some other tests to fail. + +use std::env::*; +use std::ffi::{OsStr, OsString}; + +use rand::distr::{Alphanumeric, SampleString}; + +mod common; +use std::thread; + +use common::test_rng; + +#[track_caller] +fn make_rand_name() -> OsString { + let n = format!("TEST{}", Alphanumeric.sample_string(&mut test_rng(), 10)); + let n = OsString::from(n); + assert!(var_os(&n).is_none()); + n +} + +fn eq(a: Option, b: Option<&str>) { + assert_eq!(a.as_ref().map(|s| &**s), b.map(OsStr::new).map(|s| &*s)); +} + +#[test] +fn test_set_var() { + let n = make_rand_name(); + unsafe { + set_var(&n, "VALUE"); + } + eq(var_os(&n), Some("VALUE")); +} + +#[test] +fn test_remove_var() { + let n = make_rand_name(); + unsafe { + set_var(&n, "VALUE"); + remove_var(&n); + } + eq(var_os(&n), None); +} + +#[test] +fn test_set_var_overwrite() { + let n = make_rand_name(); + unsafe { + set_var(&n, "1"); + set_var(&n, "2"); + eq(var_os(&n), Some("2")); + set_var(&n, ""); + eq(var_os(&n), Some("")); + } +} + +#[test] +#[cfg_attr(target_os = "emscripten", ignore)] +fn test_var_big() { + let mut s = "".to_string(); + let mut i = 0; + while i < 100 { + s.push_str("aaaaaaaaaa"); + i += 1; + } + let n = make_rand_name(); + unsafe { + set_var(&n, &s); + } + eq(var_os(&n), Some(&s)); +} + +#[test] +#[cfg_attr(target_os = "emscripten", ignore)] +fn test_env_set_get_huge() { + let n = make_rand_name(); + let s = "x".repeat(10000); + unsafe { + set_var(&n, &s); + eq(var_os(&n), Some(&s)); + remove_var(&n); + eq(var_os(&n), None); + } +} + +#[test] +fn test_env_set_var() { + let n = make_rand_name(); + + let mut e = vars_os(); + unsafe { + set_var(&n, "VALUE"); + } + assert!(!e.any(|(k, v)| { &*k == &*n && &*v == "VALUE" })); + + assert!(vars_os().any(|(k, v)| { &*k == &*n && &*v == "VALUE" })); +} + +#[test] +#[cfg_attr(not(any(unix, windows)), ignore, allow(unused))] +#[allow(deprecated)] +fn env_home_dir() { + use std::path::PathBuf; + + fn var_to_os_string(var: Result) -> Option { + match var { + Ok(var) => Some(OsString::from(var)), + Err(VarError::NotUnicode(var)) => Some(var), + _ => None, + } + } + + cfg_if::cfg_if! { + if #[cfg(unix)] { + let oldhome = var_to_os_string(var("HOME")); + + unsafe { + set_var("HOME", "/home/MountainView"); + assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); + + remove_var("HOME"); + } + if cfg!(target_os = "android") { + assert!(home_dir().is_none()); + } else { + // When HOME is not set, some platforms return `None`, + // but others return `Some` with a default. + // Just check that it is not "/home/MountainView". + assert_ne!(home_dir(), Some(PathBuf::from("/home/MountainView"))); + } + + if let Some(oldhome) = oldhome { unsafe { set_var("HOME", oldhome); } } + } else if #[cfg(windows)] { + let oldhome = var_to_os_string(var("HOME")); + let olduserprofile = var_to_os_string(var("USERPROFILE")); + + unsafe { + remove_var("HOME"); + remove_var("USERPROFILE"); + + assert!(home_dir().is_some()); + + set_var("HOME", "/home/PaloAlto"); + assert_ne!(home_dir(), Some(PathBuf::from("/home/PaloAlto")), "HOME must not be used"); + + set_var("USERPROFILE", "/home/MountainView"); + assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); + + remove_var("HOME"); + + assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); + + set_var("USERPROFILE", ""); + assert_ne!(home_dir(), Some(PathBuf::from("")), "Empty USERPROFILE must be ignored"); + + remove_var("USERPROFILE"); + + if let Some(oldhome) = oldhome { set_var("HOME", oldhome); } + if let Some(olduserprofile) = olduserprofile { set_var("USERPROFILE", olduserprofile); } + } + } + } +} + +#[test] // miri shouldn't detect any data race in this fn +#[cfg_attr(any(not(miri), target_os = "emscripten"), ignore)] +fn test_env_get_set_multithreaded() { + let getter = thread::spawn(|| { + for _ in 0..100 { + let _ = var_os("foo"); + } + }); + + let setter = thread::spawn(|| { + for _ in 0..100 { + unsafe { + set_var("foo", "bar"); + } + } + }); + + let _ = getter.join(); + let _ = setter.join(); +} diff --git a/std/src/error/tests.rs b/std/tests/error.rs similarity index 98% rename from std/src/error/tests.rs rename to std/tests/error.rs index 88a9f33c07908..8fd6eb3c02065 100644 --- a/std/src/error/tests.rs +++ b/std/tests/error.rs @@ -1,7 +1,8 @@ -use core::error::Request; +#![feature(error_generic_member_access, error_reporter)] -use super::Error; -use crate::fmt; +use std::backtrace::Backtrace; +use std::error::{Error, Report, Request}; +use std::fmt; #[derive(Debug, PartialEq)] struct A; @@ -38,9 +39,6 @@ fn downcasting() { } } -use crate::backtrace::Backtrace; -use crate::error::Report; - #[derive(Debug)] struct SuperError { source: SuperErrorSideKick, diff --git a/std/src/f128/tests.rs b/std/tests/floats/f128.rs similarity index 99% rename from std/src/f128/tests.rs rename to std/tests/floats/f128.rs index cbcf9f96239bb..d0e8b157e6b6f 100644 --- a/std/src/f128/tests.rs +++ b/std/tests/floats/f128.rs @@ -1,11 +1,11 @@ // FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy #![cfg(reliable_f128)] -use crate::f128::consts; -use crate::num::FpCategory as Fp; +use std::f128::consts; +use std::num::FpCategory as Fp; #[cfg(reliable_f128_math)] -use crate::ops::Rem; -use crate::ops::{Add, Div, Mul, Sub}; +use std::ops::Rem; +use std::ops::{Add, Div, Mul, Sub}; // Note these tolerances make sense around zero, but not for more extreme exponents. @@ -762,8 +762,6 @@ fn test_ln_gamma() { #[test] fn test_real_consts() { - use super::consts; - let pi: f128 = consts::PI; let frac_pi_2: f128 = consts::FRAC_PI_2; let frac_pi_3: f128 = consts::FRAC_PI_3; diff --git a/std/src/f16/tests.rs b/std/tests/floats/f16.rs similarity index 99% rename from std/src/f16/tests.rs rename to std/tests/floats/f16.rs index 684ee3f3855b8..5180f3d40f3a7 100644 --- a/std/src/f16/tests.rs +++ b/std/tests/floats/f16.rs @@ -1,8 +1,8 @@ // FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy #![cfg(reliable_f16)] -use crate::f16::consts; -use crate::num::{FpCategory as Fp, *}; +use std::f16::consts; +use std::num::FpCategory as Fp; /// Tolerance for results on the order of 10.0e-2 #[allow(unused)] @@ -54,7 +54,7 @@ macro_rules! assert_f16_biteq { #[test] fn test_num_f16() { - test_num(10f16, 2f16); + crate::test_num(10f16, 2f16); } #[test] @@ -734,7 +734,6 @@ fn test_ln_gamma() { #[test] fn test_real_consts() { // FIXME(f16_f128): add math tests when available - use super::consts; let pi: f16 = consts::PI; let frac_pi_2: f16 = consts::FRAC_PI_2; diff --git a/std/src/f32/tests.rs b/std/tests/floats/f32.rs similarity index 99% rename from std/src/f32/tests.rs rename to std/tests/floats/f32.rs index 99cfcfb231dad..bf7641986ada8 100644 --- a/std/src/f32/tests.rs +++ b/std/tests/floats/f32.rs @@ -1,5 +1,5 @@ -use crate::f32::consts; -use crate::num::{FpCategory as Fp, *}; +use std::f32::consts; +use std::num::FpCategory as Fp; /// Smallest number const TINY_BITS: u32 = 0x1; @@ -35,7 +35,7 @@ macro_rules! assert_f32_biteq { #[test] fn test_num_f32() { - test_num(10f32, 2f32); + crate::test_num(10f32, 2f32); } #[test] @@ -700,8 +700,6 @@ fn test_ln_gamma() { #[test] fn test_real_consts() { - use super::consts; - let pi: f32 = consts::PI; let frac_pi_2: f32 = consts::FRAC_PI_2; let frac_pi_3: f32 = consts::FRAC_PI_3; diff --git a/std/src/f64/tests.rs b/std/tests/floats/f64.rs similarity index 98% rename from std/src/f64/tests.rs rename to std/tests/floats/f64.rs index 3fac2efe0d76c..cbbfcd15efd26 100644 --- a/std/src/f64/tests.rs +++ b/std/tests/floats/f64.rs @@ -1,5 +1,5 @@ -use crate::f64::consts; -use crate::num::{FpCategory as Fp, *}; +use std::f64::consts; +use std::num::FpCategory as Fp; /// Smallest number const TINY_BITS: u64 = 0x1; @@ -35,7 +35,7 @@ macro_rules! assert_f64_biteq { #[test] fn test_num_f64() { - test_num(10f64, 2f64); + crate::test_num(10f64, 2f64); } #[test] @@ -112,7 +112,6 @@ fn test_neg_zero() { assert_eq!(Fp::Zero, neg_zero.classify()); } -#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 #[test] fn test_one() { let one: f64 = 1.0f64; @@ -165,7 +164,6 @@ fn test_is_finite() { assert!((-109.2f64).is_finite()); } -#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 #[test] fn test_is_normal() { let nan: f64 = f64::NAN; @@ -183,7 +181,6 @@ fn test_is_normal() { assert!(!1e-308f64.is_normal()); } -#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 #[test] fn test_classify() { let nan: f64 = f64::NAN; @@ -683,7 +680,6 @@ fn test_ln_gamma() { #[test] fn test_real_consts() { - use super::consts; let pi: f64 = consts::PI; let frac_pi_2: f64 = consts::FRAC_PI_2; let frac_pi_3: f64 = consts::FRAC_PI_3; diff --git a/std/tests/floats/lib.rs b/std/tests/floats/lib.rs new file mode 100644 index 0000000000000..ad82f1a44e711 --- /dev/null +++ b/std/tests/floats/lib.rs @@ -0,0 +1,42 @@ +#![feature(f16, f128, float_gamma, float_minimum_maximum)] + +use std::fmt; +use std::ops::{Add, Div, Mul, Rem, Sub}; + +/// Verify that floats are within a tolerance of each other, 1.0e-6 by default. +macro_rules! assert_approx_eq { + ($a:expr, $b:expr) => {{ assert_approx_eq!($a, $b, 1.0e-6) }}; + ($a:expr, $b:expr, $lim:expr) => {{ + let (a, b) = (&$a, &$b); + let diff = (*a - *b).abs(); + assert!( + diff < $lim, + "{a:?} is not approximately equal to {b:?} (threshold {lim:?}, difference {diff:?})", + lim = $lim + ); + }}; +} + +/// Helper function for testing numeric operations +pub fn test_num(ten: T, two: T) +where + T: PartialEq + + Add + + Sub + + Mul + + Div + + Rem + + fmt::Debug + + Copy, +{ + assert_eq!(ten.add(two), ten + two); + assert_eq!(ten.sub(two), ten - two); + assert_eq!(ten.mul(two), ten * two); + assert_eq!(ten.div(two), ten / two); + assert_eq!(ten.rem(two), ten % two); +} + +mod f128; +mod f16; +mod f32; +mod f64; diff --git a/std/tests/istr.rs b/std/tests/istr.rs index 9a127ae803e77..e481872977abf 100644 --- a/std/tests/istr.rs +++ b/std/tests/istr.rs @@ -5,7 +5,7 @@ fn test_stack_assign() { let t: String = "a".to_string(); assert_eq!(s, t); let u: String = "b".to_string(); - assert!((s != u)); + assert!(s != u); } #[test] @@ -19,7 +19,7 @@ fn test_heap_assign() { let t: String = "a big ol' string".to_string(); assert_eq!(s, t); let u: String = "a bad ol' string".to_string(); - assert!((s != u)); + assert!(s != u); } #[test] diff --git a/std/src/num/tests.rs b/std/tests/num.rs similarity index 98% rename from std/src/num/tests.rs rename to std/tests/num.rs index df0df3f23f756..a7400f1c02df0 100644 --- a/std/src/num/tests.rs +++ b/std/tests/num.rs @@ -1,4 +1,4 @@ -use crate::ops::Mul; +use std::ops::Mul; #[test] fn test_saturating_add_uint() { @@ -190,8 +190,8 @@ fn test_uint_to_str_overflow() { assert_eq!(u64_val.to_string(), "0"); } -fn from_str(t: &str) -> Option { - crate::str::FromStr::from_str(t).ok() +fn from_str(t: &str) -> Option { + std::str::FromStr::from_str(t).ok() } #[test] diff --git a/std/src/panic/tests.rs b/std/tests/panic.rs similarity index 89% rename from std/src/panic/tests.rs rename to std/tests/panic.rs index b37d74011cc67..f13b931dd222e 100644 --- a/std/src/panic/tests.rs +++ b/std/tests/panic.rs @@ -1,9 +1,9 @@ #![allow(dead_code)] -use crate::cell::RefCell; -use crate::panic::{AssertUnwindSafe, UnwindSafe}; -use crate::rc::Rc; -use crate::sync::{Arc, Mutex, RwLock}; +use std::cell::RefCell; +use std::panic::{AssertUnwindSafe, UnwindSafe}; +use std::rc::Rc; +use std::sync::{Arc, Mutex, RwLock}; struct Foo { a: i32, diff --git a/std/src/path/tests.rs b/std/tests/path.rs similarity index 93% rename from std/src/path/tests.rs rename to std/tests/path.rs index ff3f7151bb834..978402b6fdaea 100644 --- a/std/src/path/tests.rs +++ b/std/tests/path.rs @@ -1,10 +1,19 @@ -use core::hint::black_box; - -use super::*; -use crate::collections::{BTreeSet, HashSet}; -use crate::hash::DefaultHasher; -use crate::mem::MaybeUninit; -use crate::ptr; +#![feature( + clone_to_uninit, + path_add_extension, + path_file_prefix, + maybe_uninit_slice, + os_string_pathbuf_leak +)] + +use std::clone::CloneToUninit; +use std::ffi::OsStr; +use std::hash::{DefaultHasher, Hash, Hasher}; +use std::mem::MaybeUninit; +use std::path::*; +use std::ptr; +use std::rc::Rc; +use std::sync::Arc; #[allow(unknown_lints, unused_macro_rules)] macro_rules! t ( @@ -110,7 +119,7 @@ macro_rules! t ( #[test] fn into() { - use crate::borrow::Cow; + use std::borrow::Cow; let static_path = Path::new("/home/foo"); let static_cow_path: Cow<'static, Path> = static_path.into(); @@ -1525,7 +1534,7 @@ pub fn test_with_added_extension() { #[test] fn test_eq_receivers() { - use crate::borrow::Cow; + use std::borrow::Cow; let borrowed: &Path = Path::new("foo/bar"); let mut owned: PathBuf = PathBuf::new(); @@ -1550,7 +1559,7 @@ fn test_eq_receivers() { #[test] pub fn test_compare() { - use crate::hash::{DefaultHasher, Hash, Hasher}; + use std::hash::{DefaultHasher, Hash, Hasher}; fn hash(t: T) -> u64 { let mut s = DefaultHasher::new(); @@ -1867,12 +1876,12 @@ fn test_ord() { #[test] #[cfg(any(unix, target_os = "wasi"))] fn test_unix_absolute() { - use crate::path::absolute; + use std::path::absolute; assert!(absolute("").is_err()); let relative = "a/b"; - let mut expected = crate::env::current_dir().unwrap(); + let mut expected = std::env::current_dir().unwrap(); expected.push(relative); assert_eq!(absolute(relative).unwrap().as_os_str(), expected.as_os_str()); @@ -1888,7 +1897,7 @@ fn test_unix_absolute() { ); // Test leading `.` and `..` components - let curdir = crate::env::current_dir().unwrap(); + let curdir = std::env::current_dir().unwrap(); assert_eq!(absolute("./a").unwrap().as_os_str(), curdir.join("a").as_os_str()); assert_eq!(absolute("../a").unwrap().as_os_str(), curdir.join("../a").as_os_str()); // return /pwd/../a } @@ -1896,12 +1905,12 @@ fn test_unix_absolute() { #[test] #[cfg(windows)] fn test_windows_absolute() { - use crate::path::absolute; + use std::path::absolute; // An empty path is an error. assert!(absolute("").is_err()); let relative = r"a\b"; - let mut expected = crate::env::current_dir().unwrap(); + let mut expected = std::env::current_dir().unwrap(); expected.push(relative); assert_eq!(absolute(relative).unwrap().as_os_str(), expected.as_os_str()); @@ -1953,125 +1962,13 @@ fn test_extension_path_sep_alternate() { assert_eq!(path, Path::new("path/to/file.d\\test")); } -#[bench] -#[cfg_attr(miri, ignore)] // Miri isn't fast... -fn bench_path_cmp_fast_path_buf_sort(b: &mut test::Bencher) { - let prefix = "my/home"; - let mut paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); - - paths.sort(); - - b.iter(|| { - black_box(paths.as_mut_slice()).sort_unstable(); - }); -} - -#[bench] -#[cfg_attr(miri, ignore)] // Miri isn't fast... -fn bench_path_cmp_fast_path_long(b: &mut test::Bencher) { - let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; - let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); - - let mut set = BTreeSet::new(); - - paths.iter().for_each(|p| { - set.insert(p.as_path()); - }); - - b.iter(|| { - set.remove(paths[500].as_path()); - set.insert(paths[500].as_path()); - }); -} - -#[bench] -#[cfg_attr(miri, ignore)] // Miri isn't fast... -fn bench_path_cmp_fast_path_short(b: &mut test::Bencher) { - let prefix = "my/home"; - let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); - - let mut set = BTreeSet::new(); - - paths.iter().for_each(|p| { - set.insert(p.as_path()); - }); - - b.iter(|| { - set.remove(paths[500].as_path()); - set.insert(paths[500].as_path()); - }); -} - -#[bench] -#[cfg_attr(miri, ignore)] // Miri isn't fast... -fn bench_path_hashset(b: &mut test::Bencher) { - let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; - let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); - - let mut set = HashSet::new(); - - paths.iter().for_each(|p| { - set.insert(p.as_path()); - }); - - b.iter(|| { - set.remove(paths[500].as_path()); - set.insert(black_box(paths[500].as_path())) - }); -} - -#[bench] -#[cfg_attr(miri, ignore)] // Miri isn't fast... -fn bench_path_hashset_miss(b: &mut test::Bencher) { - let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; - let paths: Vec<_> = - (0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); - - let mut set = HashSet::new(); - - paths.iter().for_each(|p| { - set.insert(p.as_path()); - }); - - let probe = PathBuf::from(prefix).join("other"); - - b.iter(|| set.remove(black_box(probe.as_path()))); -} - -#[bench] -fn bench_hash_path_short(b: &mut test::Bencher) { - let mut hasher = DefaultHasher::new(); - let path = Path::new("explorer.exe"); - - b.iter(|| black_box(path).hash(&mut hasher)); - - black_box(hasher.finish()); -} - -#[bench] -fn bench_hash_path_long(b: &mut test::Bencher) { - let mut hasher = DefaultHasher::new(); - let path = - Path::new("/aaaaa/aaaaaa/./../aaaaaaaa/bbbbbbbbbbbbb/ccccccccccc/ddddddddd/eeeeeee.fff"); - - b.iter(|| black_box(path).hash(&mut hasher)); - - black_box(hasher.finish()); -} - #[test] fn clone_to_uninit() { let a = Path::new("hello.txt"); let mut storage = vec![MaybeUninit::::uninit(); size_of_val::(a)]; unsafe { a.clone_to_uninit(ptr::from_mut::<[_]>(storage.as_mut_slice()).cast()) }; - assert_eq!(a.as_os_str().as_encoded_bytes(), unsafe { - MaybeUninit::slice_assume_init_ref(&storage) - }); + assert_eq!(a.as_os_str().as_encoded_bytes(), unsafe { storage.assume_init_ref() }); let mut b: Box = Path::new("world.exe").into(); assert_eq!(size_of_val::(a), size_of_val::(&b)); diff --git a/std/tests/pipe_subprocess.rs b/std/tests/pipe_subprocess.rs index 1535742a83a21..00d99a578d580 100644 --- a/std/tests/pipe_subprocess.rs +++ b/std/tests/pipe_subprocess.rs @@ -1,10 +1,9 @@ #![feature(anonymous_pipe)] fn main() { - #[cfg(all(not(miri), any(unix, windows)))] + #[cfg(all(not(miri), any(unix, windows), not(target_os = "emscripten")))] { - use std::io::Read; - use std::pipe::pipe; + use std::io::{Read, pipe}; use std::{env, process}; if env::var("I_AM_THE_CHILD").is_ok() { diff --git a/std/tests/process_spawning.rs b/std/tests/process_spawning.rs index 3e72e371ade19..43b45cb2d2b5c 100644 --- a/std/tests/process_spawning.rs +++ b/std/tests/process_spawning.rs @@ -5,7 +5,8 @@ use std::{env, fs, process, str}; mod common; #[test] -#[cfg_attr(any(miri, target_os = "wasi"), ignore)] // Process spawning not supported by Miri and wasi +// Process spawning not supported by Miri, Emscripten and wasi +#[cfg_attr(any(miri, target_os = "emscripten", target_os = "wasi"), ignore)] fn issue_15149() { // If we're the parent, copy our own binary to a new directory. let my_path = env::current_exe().unwrap(); diff --git a/std/tests/seq-compare.rs b/std/tests/seq-compare.rs index 221f1c7cabde5..ec39c5b603ccc 100644 --- a/std/tests/seq-compare.rs +++ b/std/tests/seq-compare.rs @@ -1,15 +1,15 @@ #[test] fn seq_compare() { - assert!(("hello".to_string() < "hellr".to_string())); - assert!(("hello ".to_string() > "hello".to_string())); - assert!(("hello".to_string() != "there".to_string())); - assert!((vec![1, 2, 3, 4] > vec![1, 2, 3])); - assert!((vec![1, 2, 3] < vec![1, 2, 3, 4])); - assert!((vec![1, 2, 4, 4] > vec![1, 2, 3, 4])); - assert!((vec![1, 2, 3, 4] < vec![1, 2, 4, 4])); - assert!((vec![1, 2, 3] <= vec![1, 2, 3])); - assert!((vec![1, 2, 3] <= vec![1, 2, 3, 3])); - assert!((vec![1, 2, 3, 4] > vec![1, 2, 3])); + assert!("hello".to_string() < "hellr".to_string()); + assert!("hello ".to_string() > "hello".to_string()); + assert!("hello".to_string() != "there".to_string()); + assert!(vec![1, 2, 3, 4] > vec![1, 2, 3]); + assert!(vec![1, 2, 3] < vec![1, 2, 3, 4]); + assert!(vec![1, 2, 4, 4] > vec![1, 2, 3, 4]); + assert!(vec![1, 2, 3, 4] < vec![1, 2, 4, 4]); + assert!(vec![1, 2, 3] <= vec![1, 2, 3]); + assert!(vec![1, 2, 3] <= vec![1, 2, 3, 3]); + assert!(vec![1, 2, 3, 4] > vec![1, 2, 3]); assert_eq!(vec![1, 2, 3], vec![1, 2, 3]); - assert!((vec![1, 2, 3] != vec![1, 1, 3])); + assert!(vec![1, 2, 3] != vec![1, 1, 3]); } diff --git a/std/tests/switch-stdout.rs b/std/tests/switch-stdout.rs index 42011a9b3da62..91fe0200f6cae 100644 --- a/std/tests/switch-stdout.rs +++ b/std/tests/switch-stdout.rs @@ -14,7 +14,7 @@ use std::os::windows::io::OwnedHandle; fn switch_stdout_to(file: OwnedFd) -> OwnedFd { use std::os::unix::prelude::*; - extern "C" { + unsafe extern "C" { fn dup(old: i32) -> i32; fn dup2(old: i32, new: i32) -> i32; } @@ -32,7 +32,7 @@ fn switch_stdout_to(file: OwnedFd) -> OwnedFd { fn switch_stdout_to(file: OwnedHandle) -> OwnedHandle { use std::os::windows::prelude::*; - extern "system" { + unsafe extern "system" { fn GetStdHandle(nStdHandle: u32) -> *mut u8; fn SetStdHandle(nStdHandle: u32, handle: *mut u8) -> i32; } diff --git a/std/src/sync/barrier/tests.rs b/std/tests/sync/barrier.rs similarity index 89% rename from std/src/sync/barrier/tests.rs rename to std/tests/sync/barrier.rs index 0fbcd9988127b..8aefff9d5071c 100644 --- a/std/src/sync/barrier/tests.rs +++ b/std/tests/sync/barrier.rs @@ -1,6 +1,6 @@ -use crate::sync::mpsc::{TryRecvError, channel}; -use crate::sync::{Arc, Barrier}; -use crate::thread; +use std::sync::mpsc::{TryRecvError, channel}; +use std::sync::{Arc, Barrier}; +use std::thread; #[test] #[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads diff --git a/std/src/sync/condvar/tests.rs b/std/tests/sync/condvar.rs similarity index 97% rename from std/src/sync/condvar/tests.rs rename to std/tests/sync/condvar.rs index f9e9066bc92a2..834de6bb1c295 100644 --- a/std/src/sync/condvar/tests.rs +++ b/std/tests/sync/condvar.rs @@ -1,8 +1,8 @@ -use crate::sync::atomic::{AtomicBool, Ordering}; -use crate::sync::mpsc::channel; -use crate::sync::{Arc, Condvar, Mutex}; -use crate::thread; -use crate::time::Duration; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::mpsc::channel; +use std::sync::{Arc, Condvar, Mutex}; +use std::thread; +use std::time::Duration; #[test] fn smoke() { diff --git a/std/src/sync/lazy_lock/tests.rs b/std/tests/sync/lazy_lock.rs similarity index 93% rename from std/src/sync/lazy_lock/tests.rs rename to std/tests/sync/lazy_lock.rs index 7d7dde5434990..6c14b79f2ce7c 100644 --- a/std/src/sync/lazy_lock/tests.rs +++ b/std/tests/sync/lazy_lock.rs @@ -1,8 +1,8 @@ -use crate::cell::LazyCell; -use crate::sync::atomic::AtomicUsize; -use crate::sync::atomic::Ordering::SeqCst; -use crate::sync::{LazyLock, Mutex, OnceLock}; -use crate::{panic, thread}; +use std::cell::LazyCell; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::SeqCst; +use std::sync::{LazyLock, Mutex, OnceLock}; +use std::{panic, thread}; fn spawn_and_wait(f: impl FnOnce() -> R + Send + 'static) -> R { thread::spawn(f).join().unwrap() @@ -149,7 +149,7 @@ fn is_sync_send() { #[should_panic = "has previously been poisoned"] fn lazy_force_mut_panic() { let mut lazy = LazyLock::::new(|| panic!()); - crate::panic::catch_unwind(crate::panic::AssertUnwindSafe(|| { + panic::catch_unwind(panic::AssertUnwindSafe(|| { let _ = LazyLock::force_mut(&mut lazy); })) .unwrap_err(); diff --git a/std/tests/sync/lib.rs b/std/tests/sync/lib.rs new file mode 100644 index 0000000000000..51190f0894fb7 --- /dev/null +++ b/std/tests/sync/lib.rs @@ -0,0 +1,31 @@ +#![feature(lazy_get)] +#![feature(mapped_lock_guards)] +#![feature(mpmc_channel)] +#![feature(once_cell_try)] +#![feature(lock_value_accessors)] +#![feature(reentrant_lock)] +#![feature(rwlock_downgrade)] +#![feature(std_internals)] +#![allow(internal_features)] + +mod barrier; +mod condvar; +mod lazy_lock; +#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] +mod mpmc; +#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] +mod mpsc; +#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] +mod mpsc_sync; +#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] +mod mutex; +#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] +mod once; +mod once_lock; +#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] +mod reentrant_lock; +#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] +mod rwlock; + +#[path = "../common/mod.rs"] +mod common; diff --git a/std/tests/sync/mpmc.rs b/std/tests/sync/mpmc.rs new file mode 100644 index 0000000000000..81b92297f76a3 --- /dev/null +++ b/std/tests/sync/mpmc.rs @@ -0,0 +1,729 @@ +use std::sync::mpmc::*; +use std::time::{Duration, Instant}; +use std::{env, thread}; + +pub fn stress_factor() -> usize { + match env::var("RUST_TEST_STRESS") { + Ok(val) => val.parse().unwrap(), + Err(..) => 1, + } +} + +#[test] +fn smoke() { + let (tx, rx) = channel::(); + tx.send(1).unwrap(); + assert_eq!(rx.recv().unwrap(), 1); +} + +#[test] +fn drop_full() { + let (tx, _rx) = channel::>(); + tx.send(Box::new(1)).unwrap(); +} + +#[test] +fn drop_full_shared() { + let (tx, _rx) = channel::>(); + drop(tx.clone()); + drop(tx.clone()); + tx.send(Box::new(1)).unwrap(); +} + +#[test] +fn smoke_shared() { + let (tx, rx) = channel::(); + tx.send(1).unwrap(); + assert_eq!(rx.recv().unwrap(), 1); + let tx = tx.clone(); + tx.send(1).unwrap(); + assert_eq!(rx.recv().unwrap(), 1); +} + +#[test] +fn smoke_threads() { + let (tx, rx) = channel::(); + let t1 = thread::spawn(move || { + for i in 0..2 { + tx.send(i).unwrap(); + } + }); + let t2 = thread::spawn(move || { + assert_eq!(rx.recv().unwrap(), 0); + assert_eq!(rx.recv().unwrap(), 1); + }); + t1.join().unwrap(); + t2.join().unwrap(); +} + +#[test] +fn smoke_port_gone() { + let (tx, rx) = channel::(); + drop(rx); + assert!(tx.send(1).is_err()); +} + +#[test] +fn smoke_shared_port_gone() { + let (tx, rx) = channel::(); + drop(rx); + assert!(tx.send(1).is_err()) +} + +#[test] +fn smoke_shared_port_gone2() { + let (tx, rx) = channel::(); + drop(rx); + let tx2 = tx.clone(); + drop(tx); + assert!(tx2.send(1).is_err()); +} + +#[test] +fn port_gone_concurrent() { + let (tx, rx) = channel::(); + let _t = thread::spawn(move || { + rx.recv().unwrap(); + }); + while tx.send(1).is_ok() {} +} + +#[test] +fn port_gone_concurrent_shared() { + let (tx, rx) = channel::(); + let tx2 = tx.clone(); + let _t = thread::spawn(move || { + rx.recv().unwrap(); + }); + while tx.send(1).is_ok() && tx2.send(1).is_ok() {} +} + +#[test] +fn smoke_chan_gone() { + let (tx, rx) = channel::(); + drop(tx); + assert!(rx.recv().is_err()); +} + +#[test] +fn smoke_chan_gone_shared() { + let (tx, rx) = channel::<()>(); + let tx2 = tx.clone(); + drop(tx); + drop(tx2); + assert!(rx.recv().is_err()); +} + +#[test] +fn chan_gone_concurrent() { + let (tx, rx) = channel::(); + let _t = thread::spawn(move || { + tx.send(1).unwrap(); + tx.send(1).unwrap(); + }); + while rx.recv().is_ok() {} +} + +#[test] +fn stress() { + let count = if cfg!(miri) { 100 } else { 10000 }; + let (tx, rx) = channel::(); + let t = thread::spawn(move || { + for _ in 0..count { + tx.send(1).unwrap(); + } + }); + for _ in 0..count { + assert_eq!(rx.recv().unwrap(), 1); + } + t.join().ok().expect("thread panicked"); +} + +#[test] +fn stress_shared() { + const AMT: u32 = if cfg!(miri) { 100 } else { 10000 }; + const NTHREADS: u32 = 8; + let (tx, rx) = channel::(); + + let t = thread::spawn(move || { + for _ in 0..AMT * NTHREADS { + assert_eq!(rx.recv().unwrap(), 1); + } + match rx.try_recv() { + Ok(..) => panic!(), + _ => {} + } + }); + + for _ in 0..NTHREADS { + let tx = tx.clone(); + thread::spawn(move || { + for _ in 0..AMT { + tx.send(1).unwrap(); + } + }); + } + drop(tx); + t.join().ok().expect("thread panicked"); +} + +#[test] +fn send_from_outside_runtime() { + let (tx1, rx1) = channel::<()>(); + let (tx2, rx2) = channel::(); + let t1 = thread::spawn(move || { + tx1.send(()).unwrap(); + for _ in 0..40 { + assert_eq!(rx2.recv().unwrap(), 1); + } + }); + rx1.recv().unwrap(); + let t2 = thread::spawn(move || { + for _ in 0..40 { + tx2.send(1).unwrap(); + } + }); + t1.join().ok().expect("thread panicked"); + t2.join().ok().expect("thread panicked"); +} + +#[test] +fn recv_from_outside_runtime() { + let (tx, rx) = channel::(); + let t = thread::spawn(move || { + for _ in 0..40 { + assert_eq!(rx.recv().unwrap(), 1); + } + }); + for _ in 0..40 { + tx.send(1).unwrap(); + } + t.join().ok().expect("thread panicked"); +} + +#[test] +fn no_runtime() { + let (tx1, rx1) = channel::(); + let (tx2, rx2) = channel::(); + let t1 = thread::spawn(move || { + assert_eq!(rx1.recv().unwrap(), 1); + tx2.send(2).unwrap(); + }); + let t2 = thread::spawn(move || { + tx1.send(1).unwrap(); + assert_eq!(rx2.recv().unwrap(), 2); + }); + t1.join().ok().expect("thread panicked"); + t2.join().ok().expect("thread panicked"); +} + +#[test] +fn oneshot_single_thread_close_port_first() { + // Simple test of closing without sending + let (_tx, rx) = channel::(); + drop(rx); +} + +#[test] +fn oneshot_single_thread_close_chan_first() { + // Simple test of closing without sending + let (tx, _rx) = channel::(); + drop(tx); +} + +#[test] +fn oneshot_single_thread_send_port_close() { + // Testing that the sender cleans up the payload if receiver is closed + let (tx, rx) = channel::>(); + drop(rx); + assert!(tx.send(Box::new(0)).is_err()); +} + +#[test] +fn oneshot_single_thread_recv_chan_close() { + // Receiving on a closed chan will panic + let res = thread::spawn(move || { + let (tx, rx) = channel::(); + drop(tx); + rx.recv().unwrap(); + }) + .join(); + // What is our res? + assert!(res.is_err()); +} + +#[test] +fn oneshot_single_thread_send_then_recv() { + let (tx, rx) = channel::>(); + tx.send(Box::new(10)).unwrap(); + assert!(*rx.recv().unwrap() == 10); +} + +#[test] +fn oneshot_single_thread_try_send_open() { + let (tx, rx) = channel::(); + assert!(tx.send(10).is_ok()); + assert!(rx.recv().unwrap() == 10); +} + +#[test] +fn oneshot_single_thread_try_send_closed() { + let (tx, rx) = channel::(); + drop(rx); + assert!(tx.send(10).is_err()); +} + +#[test] +fn oneshot_single_thread_try_recv_open() { + let (tx, rx) = channel::(); + tx.send(10).unwrap(); + assert!(rx.recv() == Ok(10)); +} + +#[test] +fn oneshot_single_thread_try_recv_closed() { + let (tx, rx) = channel::(); + drop(tx); + assert!(rx.recv().is_err()); +} + +#[test] +fn oneshot_single_thread_peek_data() { + let (tx, rx) = channel::(); + assert_eq!(rx.try_recv(), Err(TryRecvError::Empty)); + tx.send(10).unwrap(); + assert_eq!(rx.try_recv(), Ok(10)); +} + +#[test] +fn oneshot_single_thread_peek_close() { + let (tx, rx) = channel::(); + drop(tx); + assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected)); + assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected)); +} + +#[test] +fn oneshot_single_thread_peek_open() { + let (_tx, rx) = channel::(); + assert_eq!(rx.try_recv(), Err(TryRecvError::Empty)); +} + +#[test] +fn oneshot_multi_task_recv_then_send() { + let (tx, rx) = channel::>(); + let _t = thread::spawn(move || { + assert!(*rx.recv().unwrap() == 10); + }); + + tx.send(Box::new(10)).unwrap(); +} + +#[test] +fn oneshot_multi_task_recv_then_close() { + let (tx, rx) = channel::>(); + let _t = thread::spawn(move || { + drop(tx); + }); + let res = thread::spawn(move || { + assert!(*rx.recv().unwrap() == 10); + }) + .join(); + assert!(res.is_err()); +} + +#[test] +fn oneshot_multi_thread_close_stress() { + for _ in 0..stress_factor() { + let (tx, rx) = channel::(); + let _t = thread::spawn(move || { + drop(rx); + }); + drop(tx); + } +} + +#[test] +fn oneshot_multi_thread_send_close_stress() { + for _ in 0..stress_factor() { + let (tx, rx) = channel::(); + let _t = thread::spawn(move || { + drop(rx); + }); + let _ = thread::spawn(move || { + tx.send(1).unwrap(); + }) + .join(); + } +} + +#[test] +fn oneshot_multi_thread_recv_close_stress() { + for _ in 0..stress_factor() { + let (tx, rx) = channel::(); + thread::spawn(move || { + let res = thread::spawn(move || { + rx.recv().unwrap(); + }) + .join(); + assert!(res.is_err()); + }); + let _t = thread::spawn(move || { + thread::spawn(move || { + drop(tx); + }); + }); + } +} + +#[test] +fn oneshot_multi_thread_send_recv_stress() { + for _ in 0..stress_factor() { + let (tx, rx) = channel::>(); + let _t = thread::spawn(move || { + tx.send(Box::new(10)).unwrap(); + }); + assert!(*rx.recv().unwrap() == 10); + } +} + +#[test] +fn stream_send_recv_stress() { + for _ in 0..stress_factor() { + let (tx, rx) = channel(); + + send(tx, 0); + recv(rx, 0); + + fn send(tx: Sender>, i: i32) { + if i == 10 { + return; + } + + thread::spawn(move || { + tx.send(Box::new(i)).unwrap(); + send(tx, i + 1); + }); + } + + fn recv(rx: Receiver>, i: i32) { + if i == 10 { + return; + } + + thread::spawn(move || { + assert!(*rx.recv().unwrap() == i); + recv(rx, i + 1); + }); + } + } +} + +#[test] +fn oneshot_single_thread_recv_timeout() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Ok(())); + assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Err(RecvTimeoutError::Timeout)); + tx.send(()).unwrap(); + assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Ok(())); +} + +#[test] +fn stress_recv_timeout_two_threads() { + let (tx, rx) = channel(); + let stress = stress_factor() + 100; + let timeout = Duration::from_millis(100); + + thread::spawn(move || { + for i in 0..stress { + if i % 2 == 0 { + thread::sleep(timeout * 2); + } + tx.send(1usize).unwrap(); + } + }); + + let mut recv_count = 0; + loop { + match rx.recv_timeout(timeout) { + Ok(n) => { + assert_eq!(n, 1usize); + recv_count += 1; + } + Err(RecvTimeoutError::Timeout) => continue, + Err(RecvTimeoutError::Disconnected) => break, + } + } + + assert_eq!(recv_count, stress); +} + +#[test] +fn recv_timeout_upgrade() { + let (tx, rx) = channel::<()>(); + let timeout = Duration::from_millis(1); + let _tx_clone = tx.clone(); + + let start = Instant::now(); + assert_eq!(rx.recv_timeout(timeout), Err(RecvTimeoutError::Timeout)); + assert!(Instant::now() >= start + timeout); +} + +#[test] +fn stress_recv_timeout_shared() { + let (tx, rx) = channel(); + let stress = stress_factor() + 100; + + for i in 0..stress { + let tx = tx.clone(); + thread::spawn(move || { + thread::sleep(Duration::from_millis(i as u64 * 10)); + tx.send(1usize).unwrap(); + }); + } + + drop(tx); + + let mut recv_count = 0; + loop { + match rx.recv_timeout(Duration::from_millis(10)) { + Ok(n) => { + assert_eq!(n, 1usize); + recv_count += 1; + } + Err(RecvTimeoutError::Timeout) => continue, + Err(RecvTimeoutError::Disconnected) => break, + } + } + + assert_eq!(recv_count, stress); +} + +#[test] +fn very_long_recv_timeout_wont_panic() { + let (tx, rx) = channel::<()>(); + let join_handle = thread::spawn(move || rx.recv_timeout(Duration::from_secs(u64::MAX))); + thread::sleep(Duration::from_secs(1)); + assert!(tx.send(()).is_ok()); + assert_eq!(join_handle.join().unwrap(), Ok(())); +} + +#[test] +fn recv_a_lot() { + let count = if cfg!(miri) { 1000 } else { 10000 }; + // Regression test that we don't run out of stack in scheduler context + let (tx, rx) = channel(); + for _ in 0..count { + tx.send(()).unwrap(); + } + for _ in 0..count { + rx.recv().unwrap(); + } +} + +#[test] +fn shared_recv_timeout() { + let (tx, rx) = channel(); + let total = 5; + for _ in 0..total { + let tx = tx.clone(); + thread::spawn(move || { + tx.send(()).unwrap(); + }); + } + + for _ in 0..total { + rx.recv().unwrap(); + } + + assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Err(RecvTimeoutError::Timeout)); + tx.send(()).unwrap(); + assert_eq!(rx.recv_timeout(Duration::from_millis(1)), Ok(())); +} + +#[test] +fn shared_chan_stress() { + let (tx, rx) = channel(); + let total = stress_factor() + 100; + for _ in 0..total { + let tx = tx.clone(); + thread::spawn(move || { + tx.send(()).unwrap(); + }); + } + + for _ in 0..total { + rx.recv().unwrap(); + } +} + +#[test] +fn test_nested_recv_iter() { + let (tx, rx) = channel::(); + let (total_tx, total_rx) = channel::(); + + let _t = thread::spawn(move || { + let mut acc = 0; + for x in rx.iter() { + acc += x; + } + total_tx.send(acc).unwrap(); + }); + + tx.send(3).unwrap(); + tx.send(1).unwrap(); + tx.send(2).unwrap(); + drop(tx); + assert_eq!(total_rx.recv().unwrap(), 6); +} + +#[test] +fn test_recv_iter_break() { + let (tx, rx) = channel::(); + let (count_tx, count_rx) = channel(); + + let _t = thread::spawn(move || { + let mut count = 0; + for x in rx.iter() { + if count >= 3 { + break; + } else { + count += x; + } + } + count_tx.send(count).unwrap(); + }); + + tx.send(2).unwrap(); + tx.send(2).unwrap(); + tx.send(2).unwrap(); + let _ = tx.send(2); + drop(tx); + assert_eq!(count_rx.recv().unwrap(), 4); +} + +#[test] +fn test_recv_try_iter() { + let (request_tx, request_rx) = channel(); + let (response_tx, response_rx) = channel(); + + // Request `x`s until we have `6`. + let t = thread::spawn(move || { + let mut count = 0; + loop { + for x in response_rx.try_iter() { + count += x; + if count == 6 { + return count; + } + } + request_tx.send(()).unwrap(); + } + }); + + for _ in request_rx.iter() { + if response_tx.send(2).is_err() { + break; + } + } + + assert_eq!(t.join().unwrap(), 6); +} + +#[test] +fn test_recv_into_iter_owned() { + let mut iter = { + let (tx, rx) = channel::(); + tx.send(1).unwrap(); + tx.send(2).unwrap(); + + rx.into_iter() + }; + assert_eq!(iter.next().unwrap(), 1); + assert_eq!(iter.next().unwrap(), 2); + assert_eq!(iter.next().is_none(), true); +} + +#[test] +fn test_recv_into_iter_borrowed() { + let (tx, rx) = channel::(); + tx.send(1).unwrap(); + tx.send(2).unwrap(); + drop(tx); + let mut iter = (&rx).into_iter(); + assert_eq!(iter.next().unwrap(), 1); + assert_eq!(iter.next().unwrap(), 2); + assert_eq!(iter.next().is_none(), true); +} + +#[test] +fn try_recv_states() { + let (tx1, rx1) = channel::(); + let (tx2, rx2) = channel::<()>(); + let (tx3, rx3) = channel::<()>(); + let _t = thread::spawn(move || { + rx2.recv().unwrap(); + tx1.send(1).unwrap(); + tx3.send(()).unwrap(); + rx2.recv().unwrap(); + drop(tx1); + tx3.send(()).unwrap(); + }); + + assert_eq!(rx1.try_recv(), Err(TryRecvError::Empty)); + tx2.send(()).unwrap(); + rx3.recv().unwrap(); + assert_eq!(rx1.try_recv(), Ok(1)); + assert_eq!(rx1.try_recv(), Err(TryRecvError::Empty)); + tx2.send(()).unwrap(); + rx3.recv().unwrap(); + assert_eq!(rx1.try_recv(), Err(TryRecvError::Disconnected)); +} + +// This bug used to end up in a livelock inside of the Receiver destructor +// because the internal state of the Shared packet was corrupted +#[test] +fn destroy_upgraded_shared_port_when_sender_still_active() { + let (tx, rx) = channel(); + let (tx2, rx2) = channel(); + let _t = thread::spawn(move || { + rx.recv().unwrap(); // wait on a oneshot + drop(rx); // destroy a shared + tx2.send(()).unwrap(); + }); + // make sure the other thread has gone to sleep + for _ in 0..5000 { + thread::yield_now(); + } + + // upgrade to a shared chan and send a message + let t = tx.clone(); + drop(tx); + t.send(()).unwrap(); + + // wait for the child thread to exit before we exit + rx2.recv().unwrap(); +} + +#[test] +fn issue_32114() { + let (tx, _) = channel(); + let _ = tx.send(123); + assert_eq!(tx.send(123), Err(SendError(123))); +} + +#[test] +fn issue_39364() { + let (tx, rx) = channel::<()>(); + let t = thread::spawn(move || { + thread::sleep(Duration::from_millis(300)); + let _ = tx.clone(); + // Don't drop; hand back to caller. + tx + }); + + let _ = rx.recv_timeout(Duration::from_millis(500)); + let _tx = t.join().unwrap(); // delay dropping until end of test + let _ = rx.recv_timeout(Duration::from_millis(500)); +} diff --git a/std/src/sync/mpsc/tests.rs b/std/tests/sync/mpsc.rs similarity index 99% rename from std/src/sync/mpsc/tests.rs rename to std/tests/sync/mpsc.rs index 13892fa0d18e4..1d8edfde44bed 100644 --- a/std/src/sync/mpsc/tests.rs +++ b/std/tests/sync/mpsc.rs @@ -1,5 +1,6 @@ -use super::*; -use crate::{env, thread}; +use std::sync::mpsc::*; +use std::time::{Duration, Instant}; +use std::{env, thread}; pub fn stress_factor() -> usize { match env::var("RUST_TEST_STRESS") { diff --git a/std/src/sync/mpsc/sync_tests.rs b/std/tests/sync/mpsc_sync.rs similarity index 99% rename from std/src/sync/mpsc/sync_tests.rs rename to std/tests/sync/mpsc_sync.rs index 49b65c8efe692..a7f326d201b00 100644 --- a/std/src/sync/mpsc/sync_tests.rs +++ b/std/tests/sync/mpsc_sync.rs @@ -1,7 +1,8 @@ -use super::*; -use crate::rc::Rc; -use crate::sync::mpmc::SendTimeoutError; -use crate::{env, thread}; +use std::rc::Rc; +use std::sync::mpmc::SendTimeoutError; +use std::sync::mpsc::*; +use std::time::Duration; +use std::{env, thread}; pub fn stress_factor() -> usize { match env::var("RUST_TEST_STRESS") { diff --git a/std/src/sync/mutex/tests.rs b/std/tests/sync/mutex.rs similarity index 68% rename from std/src/sync/mutex/tests.rs rename to std/tests/sync/mutex.rs index 19ec096c59334..74c627201073e 100644 --- a/std/src/sync/mutex/tests.rs +++ b/std/tests/sync/mutex.rs @@ -1,13 +1,34 @@ -use crate::sync::atomic::{AtomicUsize, Ordering}; -use crate::sync::mpsc::channel; -use crate::sync::{Arc, Condvar, MappedMutexGuard, Mutex, MutexGuard, TryLockError}; -use crate::thread; +use std::fmt::Debug; +use std::ops::FnMut; +use std::panic::{self, AssertUnwindSafe}; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::mpsc::channel; +use std::sync::{Arc, Condvar, MappedMutexGuard, Mutex, MutexGuard, TryLockError}; +use std::{hint, mem, thread}; struct Packet(Arc<(Mutex, Condvar)>); #[derive(Eq, PartialEq, Debug)] struct NonCopy(i32); +#[derive(Eq, PartialEq, Debug)] +struct NonCopyNeedsDrop(i32); + +impl Drop for NonCopyNeedsDrop { + fn drop(&mut self) { + hint::black_box(()); + } +} + +#[test] +fn test_needs_drop() { + assert!(!mem::needs_drop::()); + assert!(mem::needs_drop::()); +} + +#[derive(Clone, Eq, PartialEq, Debug)] +struct Cloneable(i32); + #[test] fn smoke() { let m = Mutex::new(()); @@ -57,6 +78,21 @@ fn try_lock() { *m.try_lock().unwrap() = (); } +fn new_poisoned_mutex(value: T) -> Mutex { + let mutex = Mutex::new(value); + + let catch_unwind_result = panic::catch_unwind(AssertUnwindSafe(|| { + let _guard = mutex.lock().unwrap(); + + panic!("test panic to poison mutex"); + })); + + assert!(catch_unwind_result.is_err()); + assert!(mutex.is_poisoned()); + + mutex +} + #[test] fn test_into_inner() { let m = Mutex::new(NonCopy(10)); @@ -83,21 +119,31 @@ fn test_into_inner_drop() { #[test] fn test_into_inner_poison() { - let m = Arc::new(Mutex::new(NonCopy(10))); - let m2 = m.clone(); - let _ = thread::spawn(move || { - let _lock = m2.lock().unwrap(); - panic!("test panic in inner thread to poison mutex"); - }) - .join(); + let m = new_poisoned_mutex(NonCopy(10)); - assert!(m.is_poisoned()); - match Arc::try_unwrap(m).unwrap().into_inner() { + match m.into_inner() { Err(e) => assert_eq!(e.into_inner(), NonCopy(10)), Ok(x) => panic!("into_inner of poisoned Mutex is Ok: {x:?}"), } } +#[test] +fn test_get_cloned() { + let m = Mutex::new(Cloneable(10)); + + assert_eq!(m.get_cloned().unwrap(), Cloneable(10)); +} + +#[test] +fn test_get_cloned_poison() { + let m = new_poisoned_mutex(Cloneable(10)); + + match m.get_cloned() { + Err(e) => assert_eq!(e.into_inner(), ()), + Ok(x) => panic!("get of poisoned Mutex is Ok: {x:?}"), + } +} + #[test] fn test_get_mut() { let mut m = Mutex::new(NonCopy(10)); @@ -107,21 +153,90 @@ fn test_get_mut() { #[test] fn test_get_mut_poison() { - let m = Arc::new(Mutex::new(NonCopy(10))); - let m2 = m.clone(); - let _ = thread::spawn(move || { - let _lock = m2.lock().unwrap(); - panic!("test panic in inner thread to poison mutex"); - }) - .join(); + let mut m = new_poisoned_mutex(NonCopy(10)); - assert!(m.is_poisoned()); - match Arc::try_unwrap(m).unwrap().get_mut() { + match m.get_mut() { Err(e) => assert_eq!(*e.into_inner(), NonCopy(10)), Ok(x) => panic!("get_mut of poisoned Mutex is Ok: {x:?}"), } } +#[test] +fn test_set() { + fn inner(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T) + where + T: Debug + Eq, + { + let m = Mutex::new(init()); + + assert_eq!(*m.lock().unwrap(), init()); + m.set(value()).unwrap(); + assert_eq!(*m.lock().unwrap(), value()); + } + + inner(|| NonCopy(10), || NonCopy(20)); + inner(|| NonCopyNeedsDrop(10), || NonCopyNeedsDrop(20)); +} + +#[test] +fn test_set_poison() { + fn inner(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T) + where + T: Debug + Eq, + { + let m = new_poisoned_mutex(init()); + + match m.set(value()) { + Err(e) => { + assert_eq!(e.into_inner(), value()); + assert_eq!(m.into_inner().unwrap_err().into_inner(), init()); + } + Ok(x) => panic!("set of poisoned Mutex is Ok: {x:?}"), + } + } + + inner(|| NonCopy(10), || NonCopy(20)); + inner(|| NonCopyNeedsDrop(10), || NonCopyNeedsDrop(20)); +} + +#[test] +fn test_replace() { + fn inner(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T) + where + T: Debug + Eq, + { + let m = Mutex::new(init()); + + assert_eq!(*m.lock().unwrap(), init()); + assert_eq!(m.replace(value()).unwrap(), init()); + assert_eq!(*m.lock().unwrap(), value()); + } + + inner(|| NonCopy(10), || NonCopy(20)); + inner(|| NonCopyNeedsDrop(10), || NonCopyNeedsDrop(20)); +} + +#[test] +fn test_replace_poison() { + fn inner(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T) + where + T: Debug + Eq, + { + let m = new_poisoned_mutex(init()); + + match m.replace(value()) { + Err(e) => { + assert_eq!(e.into_inner(), value()); + assert_eq!(m.into_inner().unwrap_err().into_inner(), init()); + } + Ok(x) => panic!("replace of poisoned Mutex is Ok: {x:?}"), + } + } + + inner(|| NonCopy(10), || NonCopy(20)); + inner(|| NonCopyNeedsDrop(10), || NonCopyNeedsDrop(20)); +} + #[test] fn test_mutex_arc_condvar() { let packet = Packet(Arc::new((Mutex::new(false), Condvar::new()))); @@ -269,7 +384,7 @@ fn test_mapping_mapped_guard() { fn panic_while_mapping_unlocked_poison() { let lock = Mutex::new(()); - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.lock().unwrap(); let _guard = MutexGuard::map::<(), _>(guard, |_| panic!()); }); @@ -282,7 +397,7 @@ fn panic_while_mapping_unlocked_poison() { Err(TryLockError::Poisoned(_)) => {} } - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.lock().unwrap(); let _guard = MutexGuard::try_map::<(), _>(guard, |_| panic!()); }); @@ -295,7 +410,7 @@ fn panic_while_mapping_unlocked_poison() { Err(TryLockError::Poisoned(_)) => {} } - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.lock().unwrap(); let guard = MutexGuard::map::<(), _>(guard, |val| val); let _guard = MappedMutexGuard::map::<(), _>(guard, |_| panic!()); @@ -309,7 +424,7 @@ fn panic_while_mapping_unlocked_poison() { Err(TryLockError::Poisoned(_)) => {} } - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.lock().unwrap(); let guard = MutexGuard::map::<(), _>(guard, |val| val); let _guard = MappedMutexGuard::try_map::<(), _>(guard, |_| panic!()); diff --git a/std/src/sync/once/tests.rs b/std/tests/sync/once.rs similarity index 94% rename from std/src/sync/once/tests.rs rename to std/tests/sync/once.rs index ce96468aeb6e1..a3ffc73fe06b9 100644 --- a/std/src/sync/once/tests.rs +++ b/std/tests/sync/once.rs @@ -1,9 +1,9 @@ -use super::Once; -use crate::sync::atomic::AtomicBool; -use crate::sync::atomic::Ordering::Relaxed; -use crate::sync::mpsc::channel; -use crate::time::Duration; -use crate::{panic, thread}; +use std::sync::Once; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering::Relaxed; +use std::sync::mpsc::channel; +use std::time::Duration; +use std::{panic, thread}; #[test] fn smoke_once() { diff --git a/std/src/sync/once_lock/tests.rs b/std/tests/sync/once_lock.rs similarity index 91% rename from std/src/sync/once_lock/tests.rs rename to std/tests/sync/once_lock.rs index 5113d436c3c99..ac9aaa8892eff 100644 --- a/std/src/sync/once_lock/tests.rs +++ b/std/tests/sync/once_lock.rs @@ -1,8 +1,8 @@ -use crate::sync::OnceLock; -use crate::sync::atomic::AtomicUsize; -use crate::sync::atomic::Ordering::SeqCst; -use crate::sync::mpsc::channel; -use crate::{panic, thread}; +use std::sync::OnceLock; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::SeqCst; +use std::sync::mpsc::channel; +use std::{panic, thread}; fn spawn_and_wait(f: impl FnOnce() -> R + Send + 'static) -> R { thread::spawn(f).join().unwrap() @@ -33,15 +33,6 @@ fn sync_once_cell_get_mut() { assert_eq!(c.get_mut(), Some(&mut 92)); } -#[test] -fn sync_once_cell_get_unchecked() { - let c = OnceLock::new(); - c.set(92).unwrap(); - unsafe { - assert_eq!(c.get_unchecked(), &92); - } -} - #[test] #[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn sync_once_cell_drop() { @@ -88,7 +79,6 @@ fn get_or_try_init() { let res = panic::catch_unwind(|| cell.get_or_try_init(|| -> Result<_, ()> { panic!() })); assert!(res.is_err()); - assert!(!cell.is_initialized()); assert!(cell.get().is_none()); assert_eq!(cell.get_or_try_init(|| Err(())), Err(())); @@ -174,7 +164,7 @@ fn sync_once_cell_does_not_leak_partially_constructed_boxes() { break; } #[cfg(target_env = "sgx")] - crate::thread::yield_now(); + std::thread::yield_now(); } }); } diff --git a/std/src/sync/reentrant_lock/tests.rs b/std/tests/sync/reentrant_lock.rs similarity index 91% rename from std/src/sync/reentrant_lock/tests.rs rename to std/tests/sync/reentrant_lock.rs index aeef0289d28f8..2b7b87e36234a 100644 --- a/std/src/sync/reentrant_lock/tests.rs +++ b/std/tests/sync/reentrant_lock.rs @@ -1,7 +1,6 @@ -use super::ReentrantLock; -use crate::cell::RefCell; -use crate::sync::Arc; -use crate::thread; +use std::cell::RefCell; +use std::sync::{Arc, ReentrantLock}; +use std::thread; #[test] fn smoke() { diff --git a/std/src/sync/rwlock/tests.rs b/std/tests/sync/rwlock.rs similarity index 80% rename from std/src/sync/rwlock/tests.rs rename to std/tests/sync/rwlock.rs index 29cad4400f189..49f260648c6ac 100644 --- a/std/src/sync/rwlock/tests.rs +++ b/std/tests/sync/rwlock.rs @@ -1,16 +1,37 @@ -use rand::Rng; - -use crate::sync::atomic::{AtomicUsize, Ordering}; -use crate::sync::mpsc::channel; -use crate::sync::{ +use std::fmt::Debug; +use std::ops::FnMut; +use std::panic::{self, AssertUnwindSafe}; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::mpsc::channel; +use std::sync::{ Arc, MappedRwLockReadGuard, MappedRwLockWriteGuard, RwLock, RwLockReadGuard, RwLockWriteGuard, TryLockError, }; -use crate::thread; +use std::{hint, mem, thread}; + +use rand::Rng; #[derive(Eq, PartialEq, Debug)] struct NonCopy(i32); +#[derive(Eq, PartialEq, Debug)] +struct NonCopyNeedsDrop(i32); + +impl Drop for NonCopyNeedsDrop { + fn drop(&mut self) { + hint::black_box(()); + } +} + +#[test] +fn test_needs_drop() { + assert!(!mem::needs_drop::()); + assert!(mem::needs_drop::()); +} + +#[derive(Clone, Eq, PartialEq, Debug)] +struct Cloneable(i32); + #[test] fn smoke() { let l = RwLock::new(()); @@ -36,9 +57,9 @@ fn frob() { let tx = tx.clone(); let r = r.clone(); thread::spawn(move || { - let mut rng = crate::test_helpers::test_rng(); + let mut rng = crate::common::test_rng(); for _ in 0..M { - if rng.gen_bool(1.0 / (N as f64)) { + if rng.random_bool(1.0 / (N as f64)) { drop(r.write().unwrap()); } else { drop(r.read().unwrap()); @@ -255,6 +276,21 @@ fn test_rwlock_try_write() { drop(mapped_read_guard); } +fn new_poisoned_rwlock(value: T) -> RwLock { + let lock = RwLock::new(value); + + let catch_unwind_result = panic::catch_unwind(AssertUnwindSafe(|| { + let _guard = lock.write().unwrap(); + + panic!("test panic to poison RwLock"); + })); + + assert!(catch_unwind_result.is_err()); + assert!(lock.is_poisoned()); + + lock +} + #[test] fn test_into_inner() { let m = RwLock::new(NonCopy(10)); @@ -281,21 +317,31 @@ fn test_into_inner_drop() { #[test] fn test_into_inner_poison() { - let m = Arc::new(RwLock::new(NonCopy(10))); - let m2 = m.clone(); - let _ = thread::spawn(move || { - let _lock = m2.write().unwrap(); - panic!("test panic in inner thread to poison RwLock"); - }) - .join(); + let m = new_poisoned_rwlock(NonCopy(10)); - assert!(m.is_poisoned()); - match Arc::try_unwrap(m).unwrap().into_inner() { + match m.into_inner() { Err(e) => assert_eq!(e.into_inner(), NonCopy(10)), Ok(x) => panic!("into_inner of poisoned RwLock is Ok: {x:?}"), } } +#[test] +fn test_get_cloned() { + let m = RwLock::new(Cloneable(10)); + + assert_eq!(m.get_cloned().unwrap(), Cloneable(10)); +} + +#[test] +fn test_get_cloned_poison() { + let m = new_poisoned_rwlock(Cloneable(10)); + + match m.get_cloned() { + Err(e) => assert_eq!(e.into_inner(), ()), + Ok(x) => panic!("get of poisoned RwLock is Ok: {x:?}"), + } +} + #[test] fn test_get_mut() { let mut m = RwLock::new(NonCopy(10)); @@ -305,21 +351,90 @@ fn test_get_mut() { #[test] fn test_get_mut_poison() { - let m = Arc::new(RwLock::new(NonCopy(10))); - let m2 = m.clone(); - let _ = thread::spawn(move || { - let _lock = m2.write().unwrap(); - panic!("test panic in inner thread to poison RwLock"); - }) - .join(); + let mut m = new_poisoned_rwlock(NonCopy(10)); - assert!(m.is_poisoned()); - match Arc::try_unwrap(m).unwrap().get_mut() { + match m.get_mut() { Err(e) => assert_eq!(*e.into_inner(), NonCopy(10)), Ok(x) => panic!("get_mut of poisoned RwLock is Ok: {x:?}"), } } +#[test] +fn test_set() { + fn inner(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T) + where + T: Debug + Eq, + { + let m = RwLock::new(init()); + + assert_eq!(*m.read().unwrap(), init()); + m.set(value()).unwrap(); + assert_eq!(*m.read().unwrap(), value()); + } + + inner(|| NonCopy(10), || NonCopy(20)); + inner(|| NonCopyNeedsDrop(10), || NonCopyNeedsDrop(20)); +} + +#[test] +fn test_set_poison() { + fn inner(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T) + where + T: Debug + Eq, + { + let m = new_poisoned_rwlock(init()); + + match m.set(value()) { + Err(e) => { + assert_eq!(e.into_inner(), value()); + assert_eq!(m.into_inner().unwrap_err().into_inner(), init()); + } + Ok(x) => panic!("set of poisoned RwLock is Ok: {x:?}"), + } + } + + inner(|| NonCopy(10), || NonCopy(20)); + inner(|| NonCopyNeedsDrop(10), || NonCopyNeedsDrop(20)); +} + +#[test] +fn test_replace() { + fn inner(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T) + where + T: Debug + Eq, + { + let m = RwLock::new(init()); + + assert_eq!(*m.read().unwrap(), init()); + assert_eq!(m.replace(value()).unwrap(), init()); + assert_eq!(*m.read().unwrap(), value()); + } + + inner(|| NonCopy(10), || NonCopy(20)); + inner(|| NonCopyNeedsDrop(10), || NonCopyNeedsDrop(20)); +} + +#[test] +fn test_replace_poison() { + fn inner(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T) + where + T: Debug + Eq, + { + let m = new_poisoned_rwlock(init()); + + match m.replace(value()) { + Err(e) => { + assert_eq!(e.into_inner(), value()); + assert_eq!(m.into_inner().unwrap_err().into_inner(), init()); + } + Ok(x) => panic!("replace of poisoned RwLock is Ok: {x:?}"), + } + } + + inner(|| NonCopy(10), || NonCopy(20)); + inner(|| NonCopyNeedsDrop(10), || NonCopyNeedsDrop(20)); +} + #[test] fn test_read_guard_covariance() { fn do_stuff<'a>(_: RwLockReadGuard<'_, &'a i32>, _: &'a i32) {} @@ -370,7 +485,7 @@ fn test_mapping_mapped_guard() { fn panic_while_mapping_read_unlocked_no_poison() { let lock = RwLock::new(()); - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.read().unwrap(); let _guard = RwLockReadGuard::map::<(), _>(guard, |_| panic!()); }); @@ -385,7 +500,7 @@ fn panic_while_mapping_read_unlocked_no_poison() { } } - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.read().unwrap(); let _guard = RwLockReadGuard::try_map::<(), _>(guard, |_| panic!()); }); @@ -400,7 +515,7 @@ fn panic_while_mapping_read_unlocked_no_poison() { } } - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.read().unwrap(); let guard = RwLockReadGuard::map::<(), _>(guard, |val| val); let _guard = MappedRwLockReadGuard::map::<(), _>(guard, |_| panic!()); @@ -416,7 +531,7 @@ fn panic_while_mapping_read_unlocked_no_poison() { } } - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.read().unwrap(); let guard = RwLockReadGuard::map::<(), _>(guard, |val| val); let _guard = MappedRwLockReadGuard::try_map::<(), _>(guard, |_| panic!()); @@ -439,7 +554,7 @@ fn panic_while_mapping_read_unlocked_no_poison() { fn panic_while_mapping_write_unlocked_poison() { let lock = RwLock::new(()); - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.write().unwrap(); let _guard = RwLockWriteGuard::map::<(), _>(guard, |_| panic!()); }); @@ -452,7 +567,7 @@ fn panic_while_mapping_write_unlocked_poison() { Err(TryLockError::Poisoned(_)) => {} } - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.write().unwrap(); let _guard = RwLockWriteGuard::try_map::<(), _>(guard, |_| panic!()); }); @@ -467,7 +582,7 @@ fn panic_while_mapping_write_unlocked_poison() { Err(TryLockError::Poisoned(_)) => {} } - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.write().unwrap(); let guard = RwLockWriteGuard::map::<(), _>(guard, |val| val); let _guard = MappedRwLockWriteGuard::map::<(), _>(guard, |_| panic!()); @@ -483,7 +598,7 @@ fn panic_while_mapping_write_unlocked_poison() { Err(TryLockError::Poisoned(_)) => {} } - let _ = crate::panic::catch_unwind(|| { + let _ = panic::catch_unwind(|| { let guard = lock.write().unwrap(); let guard = RwLockWriteGuard::map::<(), _>(guard, |val| val); let _guard = MappedRwLockWriteGuard::try_map::<(), _>(guard, |_| panic!()); @@ -511,12 +626,15 @@ fn test_downgrade_basic() { } #[test] +// FIXME: On macOS we use a provenance-incorrect implementation and Miri catches that issue. +// See for details. +#[cfg_attr(all(miri, target_os = "macos"), ignore)] fn test_downgrade_observe() { // Taken from the test `test_rwlock_downgrade` from: // https://github.com/Amanieu/parking_lot/blob/master/src/rwlock.rs const W: usize = 20; - const N: usize = 100; + const N: usize = if cfg!(miri) { 40 } else { 100 }; // This test spawns `W` writer threads, where each will increment a counter `N` times, ensuring // that the value they wrote has not changed after downgrading. @@ -586,7 +704,7 @@ fn test_downgrade_atomic() { // Wait for a good amount of time so that evil threads go to sleep. // Note: this is not strictly necessary... - let eternity = crate::time::Duration::from_millis(42); + let eternity = std::time::Duration::from_millis(42); thread::sleep(eternity); // Once everyone is asleep, set the value to `NEW_VALUE`. diff --git a/std/src/thread/local/dynamic_tests.rs b/std/tests/thread_local/dynamic_tests.rs similarity index 89% rename from std/src/thread/local/dynamic_tests.rs rename to std/tests/thread_local/dynamic_tests.rs index dd18004164824..454462b392510 100644 --- a/std/src/thread/local/dynamic_tests.rs +++ b/std/tests/thread_local/dynamic_tests.rs @@ -1,6 +1,6 @@ -use crate::cell::RefCell; -use crate::collections::HashMap; -use crate::thread_local; +use std::cell::RefCell; +use std::collections::HashMap; +use std::thread_local; #[test] fn smoke() { diff --git a/std/tests/thread_local/lib.rs b/std/tests/thread_local/lib.rs new file mode 100644 index 0000000000000..c52914354253c --- /dev/null +++ b/std/tests/thread_local/lib.rs @@ -0,0 +1,4 @@ +#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] +mod tests; + +mod dynamic_tests; diff --git a/std/src/thread/local/tests.rs b/std/tests/thread_local/tests.rs similarity index 98% rename from std/src/thread/local/tests.rs rename to std/tests/thread_local/tests.rs index 9d4f52a09218e..aa020c2559cc5 100644 --- a/std/src/thread/local/tests.rs +++ b/std/tests/thread_local/tests.rs @@ -1,8 +1,8 @@ -use crate::cell::{Cell, UnsafeCell}; -use crate::sync::atomic::{AtomicU8, Ordering}; -use crate::sync::{Arc, Condvar, Mutex}; -use crate::thread::{self, Builder, LocalKey}; -use crate::thread_local; +use std::cell::{Cell, UnsafeCell}; +use std::sync::atomic::{AtomicU8, Ordering}; +use std::sync::{Arc, Condvar, Mutex}; +use std::thread::{self, Builder, LocalKey}; +use std::thread_local; #[derive(Clone, Default)] struct Signal(Arc<(Mutex, Condvar)>); diff --git a/std/src/time/tests.rs b/std/tests/time.rs similarity index 81% rename from std/src/time/tests.rs rename to std/tests/time.rs index e88f2d5e80676..40709eae37cfc 100644 --- a/std/src/time/tests.rs +++ b/std/tests/time.rs @@ -1,9 +1,7 @@ -use core::fmt::Debug; +#![feature(duration_constants)] -#[cfg(not(target_arch = "wasm32"))] -use test::{Bencher, black_box}; - -use super::{Duration, Instant, SystemTime, UNIX_EPOCH}; +use std::fmt::Debug; +use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH}; macro_rules! assert_almost_eq { ($a:expr, $b:expr) => {{ @@ -29,10 +27,10 @@ fn instant_monotonic() { #[test] #[cfg(not(target_arch = "wasm32"))] -fn instant_monotonic_concurrent() -> crate::thread::Result<()> { +fn instant_monotonic_concurrent() -> std::thread::Result<()> { let threads: Vec<_> = (0..8) .map(|_| { - crate::thread::spawn(|| { + std::thread::spawn(|| { let mut old = Instant::now(); let count = if cfg!(miri) { 1_000 } else { 5_000_000 }; for _ in 0..count { @@ -229,46 +227,3 @@ fn big_math() { check(instant.checked_add(Duration::from_secs(100)), Instant::checked_sub); check(instant.checked_add(Duration::from_secs(i64::MAX as _)), Instant::checked_sub); } - -macro_rules! bench_instant_threaded { - ($bench_name:ident, $thread_count:expr) => { - #[bench] - #[cfg(not(target_arch = "wasm32"))] - fn $bench_name(b: &mut Bencher) -> crate::thread::Result<()> { - use crate::sync::Arc; - use crate::sync::atomic::{AtomicBool, Ordering}; - - let running = Arc::new(AtomicBool::new(true)); - - let threads: Vec<_> = (0..$thread_count) - .map(|_| { - let flag = Arc::clone(&running); - crate::thread::spawn(move || { - while flag.load(Ordering::Relaxed) { - black_box(Instant::now()); - } - }) - }) - .collect(); - - b.iter(|| { - let a = Instant::now(); - let b = Instant::now(); - assert!(b >= a); - }); - - running.store(false, Ordering::Relaxed); - - for t in threads { - t.join()?; - } - Ok(()) - } - }; -} - -bench_instant_threaded!(instant_contention_01_threads, 0); -bench_instant_threaded!(instant_contention_02_threads, 1); -bench_instant_threaded!(instant_contention_04_threads, 3); -bench_instant_threaded!(instant_contention_08_threads, 7); -bench_instant_threaded!(instant_contention_16_threads, 15); diff --git a/std/tests/win_delete_self.rs b/std/tests/win_delete_self.rs new file mode 100644 index 0000000000000..ce505de69a22d --- /dev/null +++ b/std/tests/win_delete_self.rs @@ -0,0 +1,9 @@ +#![cfg(windows)] + +/// Attempting to delete a running binary should return an error on Windows. +#[test] +#[cfg_attr(miri, ignore)] // `remove_file` does not work in Miri on Windows +fn win_delete_self() { + let path = std::env::current_exe().unwrap(); + assert!(std::fs::remove_file(path).is_err()); +} diff --git a/stdarch b/stdarch index e5e00aab0a8c8..9426bb56586c6 160000 --- a/stdarch +++ b/stdarch @@ -1 +1 @@ -Subproject commit e5e00aab0a8c8fa35fb7865e88fa82366f615c53 +Subproject commit 9426bb56586c6ae4095a2dcbd66c570253e6fb32 diff --git a/sysroot/Cargo.toml b/sysroot/Cargo.toml index aa6c3dc32e2ba..0f6fa2d291ab3 100644 --- a/sysroot/Cargo.toml +++ b/sysroot/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["public-dependency"] + [package] name = "sysroot" version = "0.0.0" @@ -5,10 +7,10 @@ edition = "2021" # this is a dummy crate to ensure that all required crates appear in the sysroot [dependencies] -proc_macro = { path = "../proc_macro" } +proc_macro = { path = "../proc_macro", public = true } profiler_builtins = { path = "../profiler_builtins", optional = true } -std = { path = "../std" } -test = { path = "../test" } +std = { path = "../std", public = true } +test = { path = "../test", public = true } # Forward features to the `std` crate as necessary [features] @@ -19,11 +21,13 @@ compiler-builtins-mem = ["std/compiler-builtins-mem"] compiler-builtins-no-asm = ["std/compiler-builtins-no-asm"] compiler-builtins-no-f16-f128 = ["std/compiler-builtins-no-f16-f128"] compiler-builtins-mangled-names = ["std/compiler-builtins-mangled-names"] +debug_refcell = ["std/debug_refcell"] +debug_typeid = ["std/debug_typeid"] llvm-libunwind = ["std/llvm-libunwind"] system-llvm-libunwind = ["std/system-llvm-libunwind"] +optimize_for_size = ["std/optimize_for_size"] panic-unwind = ["std/panic_unwind"] panic_immediate_abort = ["std/panic_immediate_abort"] -optimize_for_size = ["std/optimize_for_size"] profiler = ["dep:profiler_builtins"] std_detect_file_io = ["std/std_detect_file_io"] std_detect_dlsym_getauxval = ["std/std_detect_dlsym_getauxval"] diff --git a/test/Cargo.toml b/test/Cargo.toml index 75cc7c00e389c..241ef324b0088 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["public-dependency"] + [package] name = "test" version = "0.0.0" @@ -5,8 +7,8 @@ edition = "2021" [dependencies] getopts = { version = "0.2.21", features = ['rustc-dep-of-std'] } -std = { path = "../std" } -core = { path = "../core" } +std = { path = "../std", public = true } +core = { path = "../core", public = true } [target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies] libc = { version = "0.2.150", default-features = false } diff --git a/test/src/cli.rs b/test/src/cli.rs index 4ccd825bf8dd3..ef6786f431670 100644 --- a/test/src/cli.rs +++ b/test/src/cli.rs @@ -1,7 +1,7 @@ //! Module converting command-line arguments into test configuration. use std::env; -use std::io::{self, IsTerminal}; +use std::io::{self, IsTerminal, Write}; use std::path::PathBuf; use super::options::{ColorConfig, Options, OutputFormat, RunIgnored}; @@ -44,7 +44,7 @@ impl TestOpts { } /// Result of parsing the options. -pub type OptRes = Result; +pub(crate) type OptRes = Result; /// Result of parsing the option part. type OptPartRes = Result; @@ -58,7 +58,7 @@ fn optgroups() -> getopts::Options { .optflag("", "bench", "Run benchmarks instead of tests") .optflag("", "list", "List all tests and benchmarks") .optflag("h", "help", "Display this message") - .optopt("", "logfile", "Write logs to the specified file", "PATH") + .optopt("", "logfile", "Write logs to the specified file (deprecated)", "PATH") .optflag( "", "nocapture", @@ -281,6 +281,10 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes { let options = Options::new().display_output(matches.opt_present("show-output")); + if logfile.is_some() { + let _ = write!(io::stderr(), "warning: `--logfile` is deprecated"); + } + let test_opts = TestOpts { list, filters, diff --git a/test/src/console.rs b/test/src/console.rs index 4d4cdcf4d7b6c..8f29f1dada528 100644 --- a/test/src/console.rs +++ b/test/src/console.rs @@ -20,7 +20,7 @@ use super::types::{NamePadding, TestDesc, TestDescAndFn}; use super::{filter_tests, run_tests, term}; /// Generic wrapper over stdout. -pub enum OutputLocation { +pub(crate) enum OutputLocation { Pretty(Box), Raw(T), } @@ -41,7 +41,7 @@ impl Write for OutputLocation { } } -pub struct ConsoleTestDiscoveryState { +pub(crate) struct ConsoleTestDiscoveryState { pub log_out: Option, pub tests: usize, pub benchmarks: usize, @@ -49,7 +49,7 @@ pub struct ConsoleTestDiscoveryState { } impl ConsoleTestDiscoveryState { - pub fn new(opts: &TestOpts) -> io::Result { + pub(crate) fn new(opts: &TestOpts) -> io::Result { let log_out = match opts.logfile { Some(ref path) => Some(File::create(path)?), None => None, @@ -58,7 +58,7 @@ impl ConsoleTestDiscoveryState { Ok(ConsoleTestDiscoveryState { log_out, tests: 0, benchmarks: 0, ignored: 0 }) } - pub fn write_log(&mut self, msg: F) -> io::Result<()> + pub(crate) fn write_log(&mut self, msg: F) -> io::Result<()> where S: AsRef, F: FnOnce() -> S, @@ -74,7 +74,7 @@ impl ConsoleTestDiscoveryState { } } -pub struct ConsoleTestState { +pub(crate) struct ConsoleTestState { pub log_out: Option, pub total: usize, pub passed: usize, @@ -92,7 +92,7 @@ pub struct ConsoleTestState { } impl ConsoleTestState { - pub fn new(opts: &TestOpts) -> io::Result { + pub(crate) fn new(opts: &TestOpts) -> io::Result { let log_out = match opts.logfile { Some(ref path) => Some(File::create(path)?), None => None, @@ -116,7 +116,7 @@ impl ConsoleTestState { }) } - pub fn write_log(&mut self, msg: F) -> io::Result<()> + pub(crate) fn write_log(&mut self, msg: F) -> io::Result<()> where S: AsRef, F: FnOnce() -> S, @@ -131,7 +131,7 @@ impl ConsoleTestState { } } - pub fn write_log_result( + pub(crate) fn write_log_result( &mut self, test: &TestDesc, result: &TestResult, @@ -170,7 +170,7 @@ impl ConsoleTestState { } // List the tests to console, and optionally to logfile. Filters are honored. -pub fn list_tests_console(opts: &TestOpts, tests: Vec) -> io::Result<()> { +pub(crate) fn list_tests_console(opts: &TestOpts, tests: Vec) -> io::Result<()> { let output = match term::stdout() { None => OutputLocation::Raw(io::stdout().lock()), Some(t) => OutputLocation::Pretty(t), @@ -314,9 +314,10 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec) -> io::Resu let mut st = ConsoleTestState::new(opts)?; // Prevent the usage of `Instant` in some cases: - // - It's currently not supported for wasm targets. + // - It's currently not supported for wasm targets without Emscripten nor WASI. + // - It's currently not supported for zkvm targets. let is_instant_unsupported = - (cfg!(target_family = "wasm") && !cfg!(target_os = "wasi")) || cfg!(target_os = "zkvm"); + (cfg!(target_family = "wasm") && cfg!(target_os = "unknown")) || cfg!(target_os = "zkvm"); let start_time = (!is_instant_unsupported).then(Instant::now); run_tests(opts, tests, |x| on_test_event(&x, &mut st, &mut *out))?; diff --git a/test/src/formatters/json.rs b/test/src/formatters/json.rs index aa1c50641cb54..92c1c0716f1f2 100644 --- a/test/src/formatters/json.rs +++ b/test/src/formatters/json.rs @@ -13,7 +13,7 @@ pub(crate) struct JsonFormatter { } impl JsonFormatter { - pub fn new(out: OutputLocation) -> Self { + pub(crate) fn new(out: OutputLocation) -> Self { Self { out } } diff --git a/test/src/formatters/junit.rs b/test/src/formatters/junit.rs index 96b432008404b..84153a9d05b59 100644 --- a/test/src/formatters/junit.rs +++ b/test/src/formatters/junit.rs @@ -8,13 +8,13 @@ use crate::test_result::TestResult; use crate::time; use crate::types::{TestDesc, TestType}; -pub struct JunitFormatter { +pub(crate) struct JunitFormatter { out: OutputLocation, results: Vec<(TestDesc, TestResult, Duration, Vec)>, } impl JunitFormatter { - pub fn new(out: OutputLocation) -> Self { + pub(crate) fn new(out: OutputLocation) -> Self { Self { out, results: Vec::new() } } @@ -39,15 +39,15 @@ fn str_to_cdata(s: &str) -> String { impl OutputFormatter for JunitFormatter { fn write_discovery_start(&mut self) -> io::Result<()> { - Err(io::Error::new(io::ErrorKind::NotFound, "Not yet implemented!")) + Err(io::const_error!(io::ErrorKind::NotFound, "not yet implemented!")) } fn write_test_discovered(&mut self, _desc: &TestDesc, _test_type: &str) -> io::Result<()> { - Err(io::Error::new(io::ErrorKind::NotFound, "Not yet implemented!")) + Err(io::const_error!(io::ErrorKind::NotFound, "not yet implemented!")) } fn write_discovery_finish(&mut self, _state: &ConsoleTestDiscoveryState) -> io::Result<()> { - Err(io::Error::new(io::ErrorKind::NotFound, "Not yet implemented!")) + Err(io::const_error!(io::ErrorKind::NotFound, "not yet implemented!")) } fn write_run_start( diff --git a/test/src/formatters/pretty.rs b/test/src/formatters/pretty.rs index 7089eae4330a0..bf3fc40db4117 100644 --- a/test/src/formatters/pretty.rs +++ b/test/src/formatters/pretty.rs @@ -20,7 +20,7 @@ pub(crate) struct PrettyFormatter { } impl PrettyFormatter { - pub fn new( + pub(crate) fn new( out: OutputLocation, use_color: bool, max_name_len: usize, @@ -31,19 +31,19 @@ impl PrettyFormatter { } #[cfg(test)] - pub fn output_location(&self) -> &OutputLocation { + pub(crate) fn output_location(&self) -> &OutputLocation { &self.out } - pub fn write_ok(&mut self) -> io::Result<()> { + pub(crate) fn write_ok(&mut self) -> io::Result<()> { self.write_short_result("ok", term::color::GREEN) } - pub fn write_failed(&mut self) -> io::Result<()> { + pub(crate) fn write_failed(&mut self) -> io::Result<()> { self.write_short_result("FAILED", term::color::RED) } - pub fn write_ignored(&mut self, message: Option<&'static str>) -> io::Result<()> { + pub(crate) fn write_ignored(&mut self, message: Option<&'static str>) -> io::Result<()> { if let Some(message) = message { self.write_short_result(&format!("ignored, {message}"), term::color::YELLOW) } else { @@ -51,15 +51,15 @@ impl PrettyFormatter { } } - pub fn write_time_failed(&mut self) -> io::Result<()> { + pub(crate) fn write_time_failed(&mut self) -> io::Result<()> { self.write_short_result("FAILED (time limit exceeded)", term::color::RED) } - pub fn write_bench(&mut self) -> io::Result<()> { + pub(crate) fn write_bench(&mut self) -> io::Result<()> { self.write_pretty("bench", term::color::CYAN) } - pub fn write_short_result( + pub(crate) fn write_short_result( &mut self, result: &str, color: term::color::Color, @@ -67,7 +67,7 @@ impl PrettyFormatter { self.write_pretty(result, color) } - pub fn write_pretty(&mut self, word: &str, color: term::color::Color) -> io::Result<()> { + pub(crate) fn write_pretty(&mut self, word: &str, color: term::color::Color) -> io::Result<()> { match self.out { OutputLocation::Pretty(ref mut term) => { if self.use_color { @@ -86,7 +86,7 @@ impl PrettyFormatter { } } - pub fn write_plain>(&mut self, s: S) -> io::Result<()> { + pub(crate) fn write_plain>(&mut self, s: S) -> io::Result<()> { let s = s.as_ref(); self.out.write_all(s.as_bytes())?; self.out.flush() @@ -154,15 +154,15 @@ impl PrettyFormatter { Ok(()) } - pub fn write_successes(&mut self, state: &ConsoleTestState) -> io::Result<()> { + pub(crate) fn write_successes(&mut self, state: &ConsoleTestState) -> io::Result<()> { self.write_results(&state.not_failures, "successes") } - pub fn write_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> { + pub(crate) fn write_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> { self.write_results(&state.failures, "failures") } - pub fn write_time_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> { + pub(crate) fn write_time_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> { self.write_results(&state.time_failures, "failures (time limit exceeded)") } diff --git a/test/src/formatters/terse.rs b/test/src/formatters/terse.rs index 534aa2f33110c..b28120ab56e69 100644 --- a/test/src/formatters/terse.rs +++ b/test/src/formatters/terse.rs @@ -25,7 +25,7 @@ pub(crate) struct TerseFormatter { } impl TerseFormatter { - pub fn new( + pub(crate) fn new( out: OutputLocation, use_color: bool, max_name_len: usize, @@ -42,11 +42,11 @@ impl TerseFormatter { } } - pub fn write_ok(&mut self) -> io::Result<()> { + pub(crate) fn write_ok(&mut self) -> io::Result<()> { self.write_short_result(".", term::color::GREEN) } - pub fn write_failed(&mut self, name: &str) -> io::Result<()> { + pub(crate) fn write_failed(&mut self, name: &str) -> io::Result<()> { // Put failed tests on their own line and include the test name, so that it's faster // to see which test failed without having to wait for them all to run. @@ -62,15 +62,15 @@ impl TerseFormatter { self.write_plain("\n") } - pub fn write_ignored(&mut self) -> io::Result<()> { + pub(crate) fn write_ignored(&mut self) -> io::Result<()> { self.write_short_result("i", term::color::YELLOW) } - pub fn write_bench(&mut self) -> io::Result<()> { + pub(crate) fn write_bench(&mut self) -> io::Result<()> { self.write_pretty("bench", term::color::CYAN) } - pub fn write_short_result( + pub(crate) fn write_short_result( &mut self, result: &str, color: term::color::Color, @@ -95,7 +95,7 @@ impl TerseFormatter { Ok(()) } - pub fn write_pretty(&mut self, word: &str, color: term::color::Color) -> io::Result<()> { + pub(crate) fn write_pretty(&mut self, word: &str, color: term::color::Color) -> io::Result<()> { match self.out { OutputLocation::Pretty(ref mut term) => { if self.use_color { @@ -114,13 +114,13 @@ impl TerseFormatter { } } - pub fn write_plain>(&mut self, s: S) -> io::Result<()> { + pub(crate) fn write_plain>(&mut self, s: S) -> io::Result<()> { let s = s.as_ref(); self.out.write_all(s.as_bytes())?; self.out.flush() } - pub fn write_outputs(&mut self, state: &ConsoleTestState) -> io::Result<()> { + pub(crate) fn write_outputs(&mut self, state: &ConsoleTestState) -> io::Result<()> { self.write_plain("\nsuccesses:\n")?; let mut successes = Vec::new(); let mut stdouts = String::new(); @@ -146,7 +146,7 @@ impl TerseFormatter { Ok(()) } - pub fn write_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> { + pub(crate) fn write_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> { self.write_plain("\nfailures:\n")?; let mut failures = Vec::new(); let mut fail_out = String::new(); diff --git a/test/src/helpers/concurrency.rs b/test/src/helpers/concurrency.rs index b1545cbec438a..6648b669125f7 100644 --- a/test/src/helpers/concurrency.rs +++ b/test/src/helpers/concurrency.rs @@ -4,7 +4,7 @@ use std::num::NonZero; use std::{env, thread}; -pub fn get_concurrency() -> usize { +pub(crate) fn get_concurrency() -> usize { if let Ok(value) = env::var("RUST_TEST_THREADS") { match value.parse::>().ok() { Some(n) => n.get(), diff --git a/test/src/helpers/mod.rs b/test/src/helpers/mod.rs index 3c79b90b16754..2fb29b4c7bee5 100644 --- a/test/src/helpers/mod.rs +++ b/test/src/helpers/mod.rs @@ -1,6 +1,6 @@ //! Module with common helpers not directly related to tests //! but used in `libtest`. -pub mod concurrency; -pub mod metrics; -pub mod shuffle; +pub(crate) mod concurrency; +pub(crate) mod metrics; +pub(crate) mod shuffle; diff --git a/test/src/helpers/shuffle.rs b/test/src/helpers/shuffle.rs index 14389eb0e37af..53d1d0e42d4e8 100644 --- a/test/src/helpers/shuffle.rs +++ b/test/src/helpers/shuffle.rs @@ -4,7 +4,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use crate::cli::TestOpts; use crate::types::{TestDescAndFn, TestId, TestName}; -pub fn get_shuffle_seed(opts: &TestOpts) -> Option { +pub(crate) fn get_shuffle_seed(opts: &TestOpts) -> Option { opts.shuffle_seed.or_else(|| { if opts.shuffle { Some( @@ -19,7 +19,7 @@ pub fn get_shuffle_seed(opts: &TestOpts) -> Option { }) } -pub fn shuffle_tests(shuffle_seed: u64, tests: &mut [(TestId, TestDescAndFn)]) { +pub(crate) fn shuffle_tests(shuffle_seed: u64, tests: &mut [(TestId, TestDescAndFn)]) { let test_names: Vec<&TestName> = tests.iter().map(|test| &test.1.desc.name).collect(); let test_names_hash = calculate_hash(&test_names); let mut rng = Rng::new(shuffle_seed, test_names_hash); diff --git a/test/src/lib.rs b/test/src/lib.rs index 47407df909bdf..7ada3f269a002 100644 --- a/test/src/lib.rs +++ b/test/src/lib.rs @@ -20,6 +20,7 @@ #![feature(rustdoc_internals)] #![feature(file_buffered)] #![feature(internal_output_capture)] +#![feature(io_const_error)] #![feature(staged_api)] #![feature(process_exitcode_internals)] #![feature(panic_can_unwind)] @@ -27,6 +28,7 @@ #![feature(thread_spawn_hook)] #![allow(internal_features)] #![warn(rustdoc::unescaped_backticks)] +#![warn(unreachable_pub)] pub use cli::TestOpts; @@ -183,12 +185,16 @@ pub fn test_main_static_abort(tests: &[&TestDescAndFn]) { // If we're being run in SpawnedSecondary mode, run the test here. run_test // will then exit the process. if let Ok(name) = env::var(SECONDARY_TEST_INVOKER_VAR) { - env::remove_var(SECONDARY_TEST_INVOKER_VAR); + unsafe { + env::remove_var(SECONDARY_TEST_INVOKER_VAR); + } // Convert benchmarks to tests if we're not benchmarking. let mut tests = tests.iter().map(make_owned_test).collect::>(); if env::var(SECONDARY_TEST_BENCH_BENCHMARKS_VAR).is_ok() { - env::remove_var(SECONDARY_TEST_BENCH_BENCHMARKS_VAR); + unsafe { + env::remove_var(SECONDARY_TEST_BENCH_BENCHMARKS_VAR); + } } else { tests = convert_benchmarks_to_tests(tests); }; diff --git a/test/src/options.rs b/test/src/options.rs index 3eaad59474a12..7a5c55f4e2411 100644 --- a/test/src/options.rs +++ b/test/src/options.rs @@ -2,7 +2,7 @@ /// Number of times to run a benchmarked function #[derive(Clone, PartialEq, Eq)] -pub enum BenchMode { +pub(crate) enum BenchMode { Auto, Single, } diff --git a/test/src/stats/tests.rs b/test/src/stats/tests.rs index 4b209dcf214da..7804ddc929132 100644 --- a/test/src/stats/tests.rs +++ b/test/src/stats/tests.rs @@ -573,13 +573,13 @@ fn test_sum_f64_between_ints_that_sum_to_0() { } #[bench] -pub fn sum_three_items(b: &mut Bencher) { +fn sum_three_items(b: &mut Bencher) { b.iter(|| { [1e20f64, 1.5f64, -1e20f64].sum(); }) } #[bench] -pub fn sum_many_f64(b: &mut Bencher) { +fn sum_many_f64(b: &mut Bencher) { let nums = [-1e30f64, 1e60, 1e30, 1.0, -1e60]; let v = (0..500).map(|i| nums[i % 5]).collect::>(); @@ -589,4 +589,4 @@ pub fn sum_many_f64(b: &mut Bencher) { } #[bench] -pub fn no_iter(_: &mut Bencher) {} +fn no_iter(_: &mut Bencher) {} diff --git a/test/src/term.rs b/test/src/term.rs index e736e85d46966..d9880a776406d 100644 --- a/test/src/term.rs +++ b/test/src/term.rs @@ -62,7 +62,7 @@ pub(crate) mod color { /// A terminal with similar capabilities to an ANSI Terminal /// (foreground/background colors etc). -pub trait Terminal: Write { +pub(crate) trait Terminal: Write { /// Sets the foreground color to the given color. /// /// If the color is a bright color, but the terminal only supports 8 colors, diff --git a/test/src/term/terminfo/mod.rs b/test/src/term/terminfo/mod.rs index 974b8afd598dd..75fa594908d56 100644 --- a/test/src/term/terminfo/mod.rs +++ b/test/src/term/terminfo/mod.rs @@ -90,7 +90,7 @@ impl TermInfo { get_dbpath_for_term(name) .ok_or_else(|| { - Error::IoError(io::Error::new(io::ErrorKind::NotFound, "terminfo file not found")) + Error::IoError(io::const_error!(io::ErrorKind::NotFound, "terminfo file not found")) }) .and_then(|p| TermInfo::from_path(&(*p))) } diff --git a/test/src/term/terminfo/parser/compiled.rs b/test/src/term/terminfo/parser/compiled.rs index e687b3be41fbf..d1dd0f10d8636 100644 --- a/test/src/term/terminfo/parser/compiled.rs +++ b/test/src/term/terminfo/parser/compiled.rs @@ -173,7 +173,7 @@ fn read_le_u32(r: &mut dyn io::Read) -> io::Result { fn read_byte(r: &mut dyn io::Read) -> io::Result { match r.bytes().next() { Some(s) => s, - None => Err(io::Error::new(io::ErrorKind::Other, "end of file")), + None => Err(io::const_error!(io::ErrorKind::Other, "end of file")), } } diff --git a/test/src/term/terminfo/searcher/tests.rs b/test/src/term/terminfo/searcher/tests.rs index e1edd3b25cf4b..ff532a97d5eb9 100644 --- a/test/src/term/terminfo/searcher/tests.rs +++ b/test/src/term/terminfo/searcher/tests.rs @@ -11,7 +11,11 @@ fn test_get_dbpath_for_term() { } assert_eq!(x("screen"), PathBuf::from("/usr/share/terminfo/s/screen")); assert_eq!(get_dbpath_for_term(""), None); - env::set_var("TERMINFO_DIRS", ":"); + unsafe { + env::set_var("TERMINFO_DIRS", ":"); + } assert_eq!(x("screen"), PathBuf::from("/usr/share/terminfo/s/screen")); - env::remove_var("TERMINFO_DIRS"); + unsafe { + env::remove_var("TERMINFO_DIRS"); + } } diff --git a/test/src/term/win.rs b/test/src/term/win.rs index c77e6aac478bc..62e5c43ea2745 100644 --- a/test/src/term/win.rs +++ b/test/src/term/win.rs @@ -52,7 +52,7 @@ struct CONSOLE_SCREEN_BUFFER_INFO { #[allow(non_snake_case)] #[link(name = "kernel32")] -extern "system" { +unsafe extern "system" { fn SetConsoleTextAttribute(handle: HANDLE, attr: WORD) -> BOOL; fn GetStdHandle(which: DWORD) -> HANDLE; fn GetConsoleScreenBufferInfo(handle: HANDLE, info: *mut CONSOLE_SCREEN_BUFFER_INFO) -> BOOL; diff --git a/test/src/test_result.rs b/test/src/test_result.rs index 79fe07bc1ac5c..73dcc2e2a0cca 100644 --- a/test/src/test_result.rs +++ b/test/src/test_result.rs @@ -12,7 +12,7 @@ use super::types::TestDesc; // Return code for secondary process. // Start somewhere other than 0 so we know the return code means what we think // it means. -pub const TR_OK: i32 = 50; +pub(crate) const TR_OK: i32 = 50; // On Windows we use __fastfail to abort, which is documented to use this // exception code. @@ -39,7 +39,7 @@ pub enum TestResult { /// Creates a `TestResult` depending on the raw result of test execution /// and associated data. -pub fn calc_result<'a>( +pub(crate) fn calc_result<'a>( desc: &TestDesc, task_result: Result<(), &'a (dyn Any + 'static + Send)>, time_opts: Option<&time::TestTimeOptions>, @@ -93,7 +93,7 @@ pub fn calc_result<'a>( } /// Creates a `TestResult` depending on the exit code of test subprocess. -pub fn get_result_from_exit_code( +pub(crate) fn get_result_from_exit_code( desc: &TestDesc, status: ExitStatus, time_opts: Option<&time::TestTimeOptions>, diff --git a/test/src/tests.rs b/test/src/tests.rs index e85e61090a91b..47f581fefae1f 100644 --- a/test/src/tests.rs +++ b/test/src/tests.rs @@ -78,7 +78,7 @@ fn one_ignored_one_unignored_test() -> Vec { } #[test] -pub fn do_not_run_ignored_tests() { +fn do_not_run_ignored_tests() { fn f() -> Result<(), String> { panic!(); } @@ -106,7 +106,7 @@ pub fn do_not_run_ignored_tests() { } #[test] -pub fn ignored_tests_result_in_ignored() { +fn ignored_tests_result_in_ignored() { fn f() -> Result<(), String> { Ok(()) } @@ -133,9 +133,7 @@ pub fn ignored_tests_result_in_ignored() { assert_eq!(result, TrIgnored); } -// FIXME: Re-enable emscripten once it can catch panics again (introduced by #65251) #[test] -#[cfg(not(target_os = "emscripten"))] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn test_should_panic() { fn f() -> Result<(), String> { @@ -164,9 +162,7 @@ fn test_should_panic() { assert_eq!(result, TrOk); } -// FIXME: Re-enable emscripten once it can catch panics again (introduced by #65251) #[test] -#[cfg(not(target_os = "emscripten"))] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn test_should_panic_good_message() { fn f() -> Result<(), String> { @@ -195,9 +191,7 @@ fn test_should_panic_good_message() { assert_eq!(result, TrOk); } -// FIXME: Re-enable emscripten once it can catch panics again (introduced by #65251) #[test] -#[cfg(not(target_os = "emscripten"))] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn test_should_panic_bad_message() { use crate::tests::TrFailedMsg; @@ -231,9 +225,7 @@ fn test_should_panic_bad_message() { assert_eq!(result, TrFailedMsg(failed_msg.to_string())); } -// FIXME: Re-enable emscripten once it can catch panics again (introduced by #65251) #[test] -#[cfg(not(target_os = "emscripten"))] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn test_should_panic_non_string_message_type() { use std::any::TypeId; @@ -272,9 +264,7 @@ fn test_should_panic_non_string_message_type() { assert_eq!(result, TrFailedMsg(failed_msg)); } -// FIXME: Re-enable emscripten once it can catch panics again (introduced by #65251) #[test] -#[cfg(not(target_os = "emscripten"))] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn test_should_panic_but_succeeds() { let should_panic_variants = [ShouldPanic::Yes, ShouldPanic::YesWithMessage("error message")]; @@ -479,7 +469,7 @@ fn parse_include_ignored_flag() { } #[test] -pub fn filter_for_ignored_option() { +fn filter_for_ignored_option() { // When we run ignored tests the test filter should filter out all the // unignored tests and flip the ignore flag on the rest to false @@ -496,7 +486,7 @@ pub fn filter_for_ignored_option() { } #[test] -pub fn run_include_ignored_option() { +fn run_include_ignored_option() { // When we "--include-ignored" tests, the ignore flag should be set to false on // all tests and no test filtered out @@ -513,7 +503,7 @@ pub fn run_include_ignored_option() { } #[test] -pub fn exclude_should_panic_option() { +fn exclude_should_panic_option() { let mut opts = TestOpts::new(); opts.run_tests = true; opts.exclude_should_panic = true; @@ -544,7 +534,7 @@ pub fn exclude_should_panic_option() { } #[test] -pub fn exact_filter_match() { +fn exact_filter_match() { fn tests() -> Vec { ["base", "base::test", "base::test1", "base::test2"] .into_iter() @@ -667,7 +657,7 @@ fn sample_tests() -> Vec { } #[test] -pub fn shuffle_tests() { +fn shuffle_tests() { let mut opts = TestOpts::new(); opts.shuffle = true; @@ -686,7 +676,7 @@ pub fn shuffle_tests() { } #[test] -pub fn shuffle_tests_with_seed() { +fn shuffle_tests_with_seed() { let mut opts = TestOpts::new(); opts.shuffle = true; @@ -704,7 +694,7 @@ pub fn shuffle_tests_with_seed() { } #[test] -pub fn order_depends_on_more_than_seed() { +fn order_depends_on_more_than_seed() { let mut opts = TestOpts::new(); opts.shuffle = true; @@ -732,7 +722,7 @@ pub fn order_depends_on_more_than_seed() { } #[test] -pub fn test_metricmap_compare() { +fn test_metricmap_compare() { let mut m1 = MetricMap::new(); let mut m2 = MetricMap::new(); m1.insert_metric("in-both-noise", 1000.0, 200.0); @@ -755,7 +745,7 @@ pub fn test_metricmap_compare() { } #[test] -pub fn test_bench_once_no_iter() { +fn test_bench_once_no_iter() { fn f(_: &mut Bencher) -> Result<(), String> { Ok(()) } @@ -763,7 +753,7 @@ pub fn test_bench_once_no_iter() { } #[test] -pub fn test_bench_once_iter() { +fn test_bench_once_iter() { fn f(b: &mut Bencher) -> Result<(), String> { b.iter(|| {}); Ok(()) @@ -772,7 +762,7 @@ pub fn test_bench_once_iter() { } #[test] -pub fn test_bench_no_iter() { +fn test_bench_no_iter() { fn f(_: &mut Bencher) -> Result<(), String> { Ok(()) } @@ -799,7 +789,7 @@ pub fn test_bench_no_iter() { } #[test] -pub fn test_bench_iter() { +fn test_bench_iter() { fn f(b: &mut Bencher) -> Result<(), String> { b.iter(|| {}); Ok(()) diff --git a/test/src/time.rs b/test/src/time.rs index 02ae050db55bd..f63b156b3dc5a 100644 --- a/test/src/time.rs +++ b/test/src/time.rs @@ -11,7 +11,7 @@ use std::{env, fmt}; use super::types::{TestDesc, TestType}; -pub const TEST_WARN_TIMEOUT_S: u64 = 60; +pub(crate) const TEST_WARN_TIMEOUT_S: u64 = 60; /// This small module contains constants used by `report-time` option. /// Those constants values will be used if corresponding environment variables are not set. @@ -22,42 +22,42 @@ pub const TEST_WARN_TIMEOUT_S: u64 = 60; /// /// Example of the expected format is `RUST_TEST_TIME_xxx=100,200`, where 100 means /// warn time, and 200 means critical time. -pub mod time_constants { +pub(crate) mod time_constants { use std::time::Duration; use super::TEST_WARN_TIMEOUT_S; /// Environment variable for overriding default threshold for unit-tests. - pub const UNIT_ENV_NAME: &str = "RUST_TEST_TIME_UNIT"; + pub(crate) const UNIT_ENV_NAME: &str = "RUST_TEST_TIME_UNIT"; // Unit tests are supposed to be really quick. - pub const UNIT_WARN: Duration = Duration::from_millis(50); - pub const UNIT_CRITICAL: Duration = Duration::from_millis(100); + pub(crate) const UNIT_WARN: Duration = Duration::from_millis(50); + pub(crate) const UNIT_CRITICAL: Duration = Duration::from_millis(100); /// Environment variable for overriding default threshold for unit-tests. - pub const INTEGRATION_ENV_NAME: &str = "RUST_TEST_TIME_INTEGRATION"; + pub(crate) const INTEGRATION_ENV_NAME: &str = "RUST_TEST_TIME_INTEGRATION"; // Integration tests may have a lot of work, so they can take longer to execute. - pub const INTEGRATION_WARN: Duration = Duration::from_millis(500); - pub const INTEGRATION_CRITICAL: Duration = Duration::from_millis(1000); + pub(crate) const INTEGRATION_WARN: Duration = Duration::from_millis(500); + pub(crate) const INTEGRATION_CRITICAL: Duration = Duration::from_millis(1000); /// Environment variable for overriding default threshold for unit-tests. - pub const DOCTEST_ENV_NAME: &str = "RUST_TEST_TIME_DOCTEST"; + pub(crate) const DOCTEST_ENV_NAME: &str = "RUST_TEST_TIME_DOCTEST"; // Doctests are similar to integration tests, because they can include a lot of // initialization code. - pub const DOCTEST_WARN: Duration = INTEGRATION_WARN; - pub const DOCTEST_CRITICAL: Duration = INTEGRATION_CRITICAL; + pub(crate) const DOCTEST_WARN: Duration = INTEGRATION_WARN; + pub(crate) const DOCTEST_CRITICAL: Duration = INTEGRATION_CRITICAL; // Do not suppose anything about unknown tests, base limits on the // `TEST_WARN_TIMEOUT_S` constant. - pub const UNKNOWN_WARN: Duration = Duration::from_secs(TEST_WARN_TIMEOUT_S); - pub const UNKNOWN_CRITICAL: Duration = Duration::from_secs(TEST_WARN_TIMEOUT_S * 2); + pub(crate) const UNKNOWN_WARN: Duration = Duration::from_secs(TEST_WARN_TIMEOUT_S); + pub(crate) const UNKNOWN_CRITICAL: Duration = Duration::from_secs(TEST_WARN_TIMEOUT_S * 2); } /// Returns an `Instance` object denoting when the test should be considered /// timed out. -pub fn get_default_test_timeout() -> Instant { +pub(crate) fn get_default_test_timeout() -> Instant { Instant::now() + Duration::from_secs(TEST_WARN_TIMEOUT_S) } @@ -73,7 +73,7 @@ impl fmt::Display for TestExecTime { /// The measured execution time of the whole test suite. #[derive(Debug, Clone, Default, PartialEq)] -pub struct TestSuiteExecTime(pub Duration); +pub(crate) struct TestSuiteExecTime(pub Duration); impl fmt::Display for TestSuiteExecTime { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/unwind/Cargo.toml b/unwind/Cargo.toml index 569a1b3299e5f..66e8d1a3ffe5f 100644 --- a/unwind/Cargo.toml +++ b/unwind/Cargo.toml @@ -22,7 +22,7 @@ cfg-if = "1.0" libc = { version = "0.2.140", features = ['rustc-dep-of-std'], default-features = false } [target.'cfg(target_os = "xous")'.dependencies] -unwinding = { version = "0.2.3", features = ['rustc-dep-of-std', 'unwinder', 'fde-custom'], default-features = false } +unwinding = { version = "0.2.5", features = ['rustc-dep-of-std', 'unwinder', 'fde-custom'], default-features = false } [features] @@ -37,7 +37,4 @@ system-llvm-libunwind = [] [lints.rust.unexpected_cfgs] level = "warn" -check-cfg = [ - # #[cfg(bootstrap)] rtems - 'cfg(target_os, values("rtems"))', -] +check-cfg = ['cfg(emscripten_wasm_eh)'] diff --git a/unwind/src/lib.rs b/unwind/src/lib.rs index 79baa5b0b83ec..5451a38a674ca 100644 --- a/unwind/src/lib.rs +++ b/unwind/src/lib.rs @@ -1,13 +1,15 @@ #![no_std] #![unstable(feature = "panic_unwind", issue = "32837")] +#![feature(cfg_emscripten_wasm_eh)] #![feature(link_cfg)] #![feature(staged_api)] #![cfg_attr(not(target_env = "msvc"), feature(libc))] #![cfg_attr( - all(target_family = "wasm", not(target_os = "emscripten")), + all(target_family = "wasm", any(not(target_os = "emscripten"), emscripten_wasm_eh)), feature(simd_wasm64, wasm_exception_handling_intrinsics) )] #![allow(internal_features)] +#![deny(unsafe_op_in_unsafe_fn)] // Force libc to be included even if unused. This is required by many platforms. #[cfg(not(all(windows, target_env = "msvc")))] @@ -20,7 +22,6 @@ cfg_if::cfg_if! { target_os = "l4re", target_os = "none", target_os = "espidf", - target_os = "rtems", target_os = "nuttx", ))] { // These "unix" family members do not have unwinder. @@ -56,15 +57,15 @@ cfg_if::cfg_if! { compile_error!("`llvm-libunwind` and `system-llvm-libunwind` cannot be enabled at the same time"); } else if #[cfg(feature = "llvm-libunwind")] { #[link(name = "unwind", kind = "static", modifiers = "-bundle")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(feature = "system-llvm-libunwind")] { #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "unwind", cfg(not(target_feature = "crt-static")))] - extern "C" {} + unsafe extern "C" {} } else { #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))] - extern "C" {} + unsafe extern "C" {} } } @@ -76,11 +77,11 @@ cfg_if::cfg_if! { compile_error!("`llvm-libunwind` and `system-llvm-libunwind` cannot be enabled at the same time"); } else if #[cfg(feature = "llvm-libunwind")] { #[link(name = "unwind", kind = "static", modifiers = "-bundle")] - extern "C" {} + unsafe extern "C" {} } else { #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "unwind", cfg(not(target_feature = "crt-static")))] - extern "C" {} + unsafe extern "C" {} } } @@ -91,14 +92,14 @@ cfg_if::cfg_if! { } else { #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "unwind", cfg(not(target_feature = "crt-static")))] - extern "C" {} + unsafe extern "C" {} } } // Android's unwinding library depends on dl_iterate_phdr in `libdl`. #[cfg(target_os = "android")] #[link(name = "dl", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "dl", cfg(not(target_feature = "crt-static")))] -extern "C" {} +unsafe extern "C" {} // When building with crt-static, we get `gcc_eh` from the `libc` crate, since // glibc needs it, and needs it listed later on the linker command line. We @@ -110,7 +111,7 @@ extern "C" {} not(feature = "system-llvm-libunwind") ))] #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))] -extern "C" {} +unsafe extern "C" {} #[cfg(all( target_os = "linux", @@ -119,62 +120,67 @@ extern "C" {} feature = "system-llvm-libunwind" ))] #[link(name = "unwind", cfg(not(target_feature = "crt-static")))] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "redox")] #[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))] -extern "C" {} +unsafe extern "C" {} #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] #[link(name = "unwind", kind = "static", modifiers = "-bundle")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "netbsd")] #[link(name = "gcc_s")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "freebsd")] #[link(name = "gcc", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))] -extern "C" {} +unsafe extern "C" {} #[cfg(all(target_os = "openbsd", target_arch = "sparc64"))] #[link(name = "gcc")] -extern "C" {} +unsafe extern "C" {} #[cfg(all(target_os = "openbsd", not(target_arch = "sparc64")))] #[link(name = "c++abi")] -extern "C" {} +unsafe extern "C" {} #[cfg(any(target_os = "solaris", target_os = "illumos"))] #[link(name = "gcc_s")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "dragonfly")] #[link(name = "gcc_pic")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "haiku")] #[link(name = "gcc_s")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "aix")] #[link(name = "unwind")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "nto")] cfg_if::cfg_if! { if #[cfg(target_env = "nto70")] { #[link(name = "gcc")] - extern "C" {} + unsafe extern "C" {} } else { #[link(name = "gcc_s")] - extern "C" {} + unsafe extern "C" {} } } #[cfg(target_os = "hurd")] #[link(name = "gcc_s")] -extern "C" {} +unsafe extern "C" {} + +#[cfg(all(target_os = "windows", target_env = "gnu", target_abi = "llvm"))] +#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] +#[link(name = "unwind", cfg(not(target_feature = "crt-static")))] +unsafe extern "C" {} diff --git a/unwind/src/libunwind.rs b/unwind/src/libunwind.rs index 715f8b57876ae..ced8e82b8ebe8 100644 --- a/unwind/src/libunwind.rs +++ b/unwind/src/libunwind.rs @@ -72,9 +72,12 @@ pub const unwinder_private_data_size: usize = 2; #[cfg(any(target_arch = "riscv64", target_arch = "riscv32"))] pub const unwinder_private_data_size: usize = 2; -#[cfg(target_os = "emscripten")] +#[cfg(all(target_arch = "wasm32", target_os = "emscripten"))] pub const unwinder_private_data_size: usize = 20; +#[cfg(all(target_arch = "wasm32", target_os = "linux"))] +pub const unwinder_private_data_size: usize = 2; + #[cfg(all(target_arch = "hexagon", target_os = "linux"))] pub const unwinder_private_data_size: usize = 35; @@ -102,19 +105,16 @@ pub type _Unwind_Exception_Cleanup_Fn = // rustc_codegen_ssa::src::back::symbol_export, rustc_middle::middle::exported_symbols // and RFC 2841 #[cfg_attr( - any( - all( - feature = "llvm-libunwind", - any(target_os = "fuchsia", target_os = "linux", target_os = "xous") - ), - all(target_os = "windows", target_env = "gnu", target_abi = "llvm") + all( + feature = "llvm-libunwind", + any(target_os = "fuchsia", target_os = "linux", target_os = "xous") ), link(name = "unwind", kind = "static", modifiers = "-bundle") )] -extern "C-unwind" { +unsafe extern "C-unwind" { pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !; } -extern "C" { +unsafe extern "C" { pub fn _Unwind_DeleteException(exception: *mut _Unwind_Exception); pub fn _Unwind_GetLanguageSpecificData(ctx: *mut _Unwind_Context) -> *mut c_void; pub fn _Unwind_GetRegionStart(ctx: *mut _Unwind_Context) -> _Unwind_Ptr; @@ -143,7 +143,7 @@ if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "a all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] - extern "C" { + unsafe extern "C" { pub fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word; pub fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word); pub fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> _Unwind_Word; @@ -201,7 +201,7 @@ if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "a all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] - extern "C" { + unsafe extern "C" { fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context, regclass: _Unwind_VRS_RegClass, regno: _Unwind_Word, @@ -221,36 +221,38 @@ if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "a pub unsafe fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word { let mut val: _Unwind_Word = core::ptr::null(); - _Unwind_VRS_Get(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, - (&raw mut val) as *mut c_void); + unsafe { _Unwind_VRS_Get(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, + (&raw mut val) as *mut c_void); } val } pub unsafe fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word) { let mut value = value; - _Unwind_VRS_Set(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, - (&raw mut value) as *mut c_void); + unsafe { _Unwind_VRS_Set(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, + (&raw mut value) as *mut c_void); } } pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> _Unwind_Word { - let val = _Unwind_GetGR(ctx, UNWIND_IP_REG); + let val = unsafe { _Unwind_GetGR(ctx, UNWIND_IP_REG) }; val.map_addr(|v| v & !1) } pub unsafe fn _Unwind_SetIP(ctx: *mut _Unwind_Context, value: _Unwind_Word) { // Propagate thumb bit to instruction pointer - let thumb_state = _Unwind_GetGR(ctx, UNWIND_IP_REG).addr() & 1; + let thumb_state = unsafe { _Unwind_GetGR(ctx, UNWIND_IP_REG).addr() & 1 }; let value = value.map_addr(|v| v | thumb_state); - _Unwind_SetGR(ctx, UNWIND_IP_REG, value); + unsafe { _Unwind_SetGR(ctx, UNWIND_IP_REG, value); } } pub unsafe fn _Unwind_GetIPInfo(ctx: *mut _Unwind_Context, ip_before_insn: *mut c_int) -> _Unwind_Word { - *ip_before_insn = 0; - _Unwind_GetIP(ctx) + unsafe { + *ip_before_insn = 0; + _Unwind_GetIP(ctx) + } } // This function also doesn't exist on Android or ARM/Linux, so make it a no-op @@ -264,7 +266,7 @@ cfg_if::cfg_if! { if #[cfg(all(target_vendor = "apple", not(target_os = "watchos"), target_arch = "arm"))] { // 32-bit ARM Apple (except for watchOS armv7k specifically) uses SjLj and // does not provide _Unwind_Backtrace() - extern "C-unwind" { + unsafe extern "C-unwind" { pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code; } @@ -274,14 +276,14 @@ if #[cfg(all(target_vendor = "apple", not(target_os = "watchos"), target_arch = all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] - extern "C-unwind" { + unsafe extern "C-unwind" { pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code; } #[cfg_attr( all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] - extern "C" { + unsafe extern "C" { pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn, trace_argument: *mut c_void) -> _Unwind_Reason_Code; @@ -305,7 +307,7 @@ if #[cfg(all(windows, any(target_arch = "aarch64", target_arch = "x86_64"), targ context: *mut _Unwind_Context) -> _Unwind_Reason_Code; - extern "C" { + unsafe extern "C" { pub fn _GCC_specific_handler(exceptionRecord: *mut EXCEPTION_RECORD, establisherFrame: LPVOID, contextRecord: *mut CONTEXT, diff --git a/unwind/src/unwinding.rs b/unwind/src/unwinding.rs index 1b94005ab6cd0..fa8a8c385839b 100644 --- a/unwind/src/unwinding.rs +++ b/unwind/src/unwinding.rs @@ -39,9 +39,9 @@ pub type _Unwind_Exception_Class = u64; pub type _Unwind_Word = *const u8; pub type _Unwind_Ptr = *const u8; -pub const unwinder_private_data_size: usize = core::mem::size_of::() - - core::mem::size_of::<_Unwind_Exception_Class>() - - core::mem::size_of::<_Unwind_Exception_Cleanup_Fn>(); +pub const unwinder_private_data_size: usize = size_of::() + - size_of::<_Unwind_Exception_Class>() + - size_of::<_Unwind_Exception_Cleanup_Fn>(); pub type _Unwind_Exception_Cleanup_Fn = Option; diff --git a/windows_targets/src/lib.rs b/windows_targets/src/lib.rs index 395cd6a4bab55..939fab7d5fe62 100644 --- a/windows_targets/src/lib.rs +++ b/windows_targets/src/lib.rs @@ -34,9 +34,9 @@ pub macro link { } #[cfg(not(feature = "windows_raw_dylib"))] -#[link(name = "advapi32")] +#[cfg_attr(target_vendor = "win7", link(name = "advapi32"))] #[link(name = "ntdll")] #[link(name = "userenv")] #[link(name = "ws2_32")] #[link(name = "dbghelp")] // required for backtrace-rs symbolization -extern "C" {} +unsafe extern "C" {} From 99b7fdb36073519d1515dc20924be429e398557c Mon Sep 17 00:00:00 2001 From: gitbot Date: Wed, 19 Mar 2025 20:11:30 +0000 Subject: [PATCH 2/7] Update toolchain to 2025-03-17 --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4c1961eea0864..c4ac176617fac 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -2,5 +2,5 @@ # standard library we currently track. [toolchain] -channel = "nightly-2025-03-13" +channel = "nightly-2025-03-17" components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"] From 56c048328daf2d2b7e33e12c03e21c78ea18ec50 Mon Sep 17 00:00:00 2001 From: gitbot Date: Wed, 19 Mar 2025 20:11:30 +0000 Subject: [PATCH 3/7] Update Kani version to 62dd13c914191b91ffd8244f70508791e6270a52 --- tool_config/kani-version.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool_config/kani-version.toml b/tool_config/kani-version.toml index 6256b6d478186..aee64d37da844 100644 --- a/tool_config/kani-version.toml +++ b/tool_config/kani-version.toml @@ -2,4 +2,4 @@ # incompatible with the verify-std repo. [kani] -commit = "e48888716ac16e2ce098c00355a52205c683f679" +commit = "62dd13c914191b91ffd8244f70508791e6270a52" From 9b0c0d64efe4ee5e8bebdaf3b68473b7f451d685 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Wed, 19 Mar 2025 20:49:29 +0000 Subject: [PATCH 4/7] Fixup automated mis-merge --- library/Cargo.lock | 30 +- library/alloc/Cargo.toml | 5 +- library/alloc/src/lib.rs | 3 - library/alloc/src/rc.rs | 34 +- library/alloc/src/sync.rs | 30 +- library/core/Cargo.toml | 5 +- library/core/src/any.rs | 2 +- library/core/src/array/ascii.rs | 1 - library/core/src/bool.rs | 2 +- library/core/src/cell.rs | 4 +- library/core/src/char/methods.rs | 2 +- library/core/src/clone.rs | 175 ++++-- library/core/src/cmp.rs | 4 +- library/core/src/convert/mod.rs | 4 +- library/core/src/default.rs | 2 +- library/core/src/error.rs | 2 +- library/core/src/fmt/mod.rs | 11 +- library/core/src/intrinsics/mod.rs | 201 ++++++- library/core/src/iter/adapters/enumerate.rs | 2 +- library/core/src/iter/sources/repeat.rs | 2 +- library/core/src/iter/traits/double_ended.rs | 2 +- library/core/src/iter/traits/iterator.rs | 19 +- library/core/src/lib.rs | 19 +- library/core/src/macros/mod.rs | 26 +- library/core/src/marker.rs | 12 +- library/core/src/mem/mod.rs | 105 ++-- library/core/src/net/ip_addr.rs | 2 +- library/core/src/net/socket_addr.rs | 32 +- library/core/src/num/f128.rs | 6 +- library/core/src/num/f16.rs | 6 +- library/core/src/num/f32.rs | 7 +- library/core/src/num/f64.rs | 7 +- library/core/src/num/int_macros.rs | 6 - library/core/src/num/mod.rs | 3 - library/core/src/num/uint_macros.rs | 6 - library/core/src/ops/control_flow.rs | 2 +- library/core/src/option.rs | 4 +- library/core/src/panic/unwind_safe.rs | 4 +- library/core/src/ptr/alignment.rs | 3 - library/core/src/ptr/const_ptr.rs | 4 - library/core/src/ptr/metadata.rs | 2 + library/core/src/ptr/mod.rs | 3 - library/core/src/ptr/mut_ptr.rs | 3 - library/core/src/ptr/non_null.rs | 18 - library/core/src/ptr/unique.rs | 3 - library/core/src/result.rs | 2 +- library/core/src/slice/ascii.rs | 7 - library/core/src/slice/cmp.rs | 2 +- library/core/src/slice/mod.rs | 5 +- library/core/src/str/mod.rs | 17 +- library/core/src/str/pattern.rs | 9 +- library/core/src/str/validations.rs | 3 - library/core/src/sync/atomic.rs | 26 +- library/core/src/task/wake.rs | 2 +- library/core/src/time.rs | 8 +- library/core/src/unit.rs | 16 + library/coretests/Cargo.toml | 1 + library/coretests/tests/fmt/mod.rs | 35 +- library/panic_abort/Cargo.toml | 2 +- library/panic_unwind/Cargo.toml | 2 +- library/proc_macro/Cargo.toml | 2 +- library/profiler_builtins/Cargo.toml | 2 +- library/rustc-std-workspace-alloc/Cargo.toml | 2 +- library/rustc-std-workspace-core/Cargo.toml | 2 +- library/rustc-std-workspace-std/Cargo.toml | 2 +- library/std/Cargo.toml | 4 +- library/std/build.rs | 1 + library/std/src/collections/hash/map.rs | 497 +----------------- library/std/src/collections/hash/map/tests.rs | 93 ---- library/std/src/fs.rs | 3 +- library/std/src/io/buffered/bufreader.rs | 6 +- library/std/src/io/error.rs | 4 +- library/std/src/io/tests.rs | 16 +- library/std/src/keyword_docs.rs | 2 +- library/std/src/lib.rs | 6 +- library/std/src/macros.rs | 8 +- library/std/src/net/tcp.rs | 3 +- library/std/src/net/udp.rs | 3 +- library/std/src/os/fd/mod.rs | 1 + library/std/src/os/fd/owned.rs | 28 +- library/std/src/os/fd/raw.rs | 10 +- library/std/src/os/mod.rs | 4 +- library/std/src/os/unix/fs.rs | 124 +++-- library/std/src/os/windows/process.rs | 2 +- library/std/src/path.rs | 8 +- library/std/src/process.rs | 3 +- library/std/src/sys/alloc/mod.rs | 1 + library/std/src/sys/pal/mod.rs | 3 + .../src/sys/pal/sgx/abi/usercalls/alloc.rs | 64 ++- .../std/src/sys/pal/sgx/abi/usercalls/mod.rs | 17 +- library/std/src/sys/pal/sgx/fd.rs | 2 +- library/std/src/sys/pal/uefi/helpers.rs | 179 +++++++ library/std/src/sys/pal/unix/os.rs | 7 +- .../sys/pal/unix/process/process_common.rs | 2 - library/std/src/sys/path/unix.rs | 5 +- library/std/src/sys/random/mod.rs | 3 + library/std/src/sys/stdio/mod.rs | 3 + library/std/src/sys/stdio/sgx.rs | 33 +- library/std/src/sys/thread_local/mod.rs | 2 + library/std/tests/floats/f16.rs | 84 ++- library/std/tests/run-time-detect.rs | 30 ++ library/sysroot/Cargo.toml | 2 +- library/test/Cargo.toml | 2 +- library/unwind/Cargo.toml | 2 +- library/windows_targets/Cargo.toml | 2 +- library/windows_targets/src/lib.rs | 4 +- 106 files changed, 1182 insertions(+), 1063 deletions(-) diff --git a/library/Cargo.lock b/library/Cargo.lock index 8f174f284724f..ac8740605144a 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -85,6 +85,7 @@ version = "0.0.0" dependencies = [ "rand", "rand_xorshift", + "regex", ] [[package]] @@ -157,9 +158,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.170" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" dependencies = [ "rustc-std-workspace-core", ] @@ -303,6 +304,31 @@ dependencies = [ "rand_core", ] +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + [[package]] name = "rustc-demangle" version = "0.1.24" diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml index 6123b5f278efa..cd78f948b47c7 100644 --- a/library/alloc/Cargo.toml +++ b/library/alloc/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/rust-lang/rust.git" description = "The Rust core allocation and collections library" autotests = false autobenches = false -edition = "2021" +edition = "2024" [lib] test = false @@ -17,10 +17,7 @@ bench = false [dependencies] core = { path = "../core", public = true } compiler_builtins = { version = "=0.1.151", features = ['rustc-dep-of-std'] } -<<<<<<< HEAD safety = { path = "../contracts/safety" } -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 [features] compiler-builtins-mem = ['compiler_builtins/mem'] diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index c2854c01287d6..ff83a379f5701 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -93,10 +93,7 @@ // // Library features: // tidy-alphabetical-start -<<<<<<< HEAD #![cfg_attr(kani, feature(kani))] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 #![feature(alloc_layout_extra)] #![feature(allocator_api)] #![feature(array_chunks)] diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index fc1cee28d0334..619d9f258e342 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1327,11 +1327,14 @@ impl Rc { /// /// # Safety /// - /// The pointer must have been obtained through `Rc::into_raw`, the - /// associated `Rc` instance must be valid (i.e. the strong count must be at + /// The pointer must have been obtained through `Rc::into_raw` and must satisfy the + /// same layout requirements specified in [`Rc::from_raw_in`][from_raw_in]. + /// The associated `Rc` instance must be valid (i.e. the strong count must be at /// least 1) for the duration of this method, and `ptr` must point to a block of memory /// allocated by the global allocator. /// + /// [from_raw_in]: Rc::from_raw_in + /// /// # Examples /// /// ``` @@ -1360,12 +1363,15 @@ impl Rc { /// /// # Safety /// - /// The pointer must have been obtained through `Rc::into_raw`, the - /// associated `Rc` instance must be valid (i.e. the strong count must be at + /// The pointer must have been obtained through `Rc::into_raw`and must satisfy the + /// same layout requirements specified in [`Rc::from_raw_in`][from_raw_in]. + /// The associated `Rc` instance must be valid (i.e. the strong count must be at /// least 1) when invoking this method, and `ptr` must point to a block of memory /// allocated by the global allocator. This method can be used to release the final `Rc` and /// backing storage, but **should not** be called after the final `Rc` has been released. /// + /// [from_raw_in]: Rc::from_raw_in + /// /// # Examples /// /// ``` @@ -1623,10 +1629,13 @@ impl Rc { /// /// # Safety /// - /// The pointer must have been obtained through `Rc::into_raw`, the - /// associated `Rc` instance must be valid (i.e. the strong count must be at + /// The pointer must have been obtained through `Rc::into_raw` and must satisfy the + /// same layout requirements specified in [`Rc::from_raw_in`][from_raw_in]. + /// The associated `Rc` instance must be valid (i.e. the strong count must be at /// least 1) for the duration of this method, and `ptr` must point to a block of memory - /// allocated by `alloc` + /// allocated by `alloc`. + /// + /// [from_raw_in]: Rc::from_raw_in /// /// # Examples /// @@ -1665,11 +1674,14 @@ impl Rc { /// /// # Safety /// - /// The pointer must have been obtained through `Rc::into_raw`, the - /// associated `Rc` instance must be valid (i.e. the strong count must be at + /// The pointer must have been obtained through `Rc::into_raw`and must satisfy the + /// same layout requirements specified in [`Rc::from_raw_in`][from_raw_in]. + /// The associated `Rc` instance must be valid (i.e. the strong count must be at /// least 1) when invoking this method, and `ptr` must point to a block of memory - /// allocated by `alloc`. This method can be used to release the final `Rc` and backing storage, - /// but **should not** be called after the final `Rc` has been released. + /// allocated by `alloc`. This method can be used to release the final `Rc` and + /// backing storage, but **should not** be called after the final `Rc` has been released. + /// + /// [from_raw_in]: Rc::from_raw_in /// /// # Examples /// diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 4999319f618e4..104cb35c23b65 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1453,11 +1453,14 @@ impl Arc { /// /// # Safety /// - /// The pointer must have been obtained through `Arc::into_raw`, and the - /// associated `Arc` instance must be valid (i.e. the strong count must be at + /// The pointer must have been obtained through `Arc::into_raw` and must satisfy the + /// same layout requirements specified in [`Arc::from_raw_in`][from_raw_in]. + /// The associated `Arc` instance must be valid (i.e. the strong count must be at /// least 1) for the duration of this method, and `ptr` must point to a block of memory /// allocated by the global allocator. /// + /// [from_raw_in]: Arc::from_raw_in + /// /// # Examples /// /// ``` @@ -1488,13 +1491,16 @@ impl Arc { /// /// # Safety /// - /// The pointer must have been obtained through `Arc::into_raw`, and the - /// associated `Arc` instance must be valid (i.e. the strong count must be at + /// The pointer must have been obtained through `Arc::into_raw` and must satisfy the + /// same layout requirements specified in [`Arc::from_raw_in`][from_raw_in]. + /// The associated `Arc` instance must be valid (i.e. the strong count must be at /// least 1) when invoking this method, and `ptr` must point to a block of memory /// allocated by the global allocator. This method can be used to release the final /// `Arc` and backing storage, but **should not** be called after the final `Arc` has been /// released. /// + /// [from_raw_in]: Arc::from_raw_in + /// /// # Examples /// /// ``` @@ -1806,11 +1812,14 @@ impl Arc { /// /// # Safety /// - /// The pointer must have been obtained through `Arc::into_raw`, and the - /// associated `Arc` instance must be valid (i.e. the strong count must be at - /// least 1) for the duration of this method,, and `ptr` must point to a block of memory + /// The pointer must have been obtained through `Arc::into_raw` and must satisfy the + /// same layout requirements specified in [`Arc::from_raw_in`][from_raw_in]. + /// The associated `Arc` instance must be valid (i.e. the strong count must be at + /// least 1) for the duration of this method, and `ptr` must point to a block of memory /// allocated by `alloc`. /// + /// [from_raw_in]: Arc::from_raw_in + /// /// # Examples /// /// ``` @@ -1850,13 +1859,16 @@ impl Arc { /// /// # Safety /// - /// The pointer must have been obtained through `Arc::into_raw`, the - /// associated `Arc` instance must be valid (i.e. the strong count must be at + /// The pointer must have been obtained through `Arc::into_raw` and must satisfy the + /// same layout requirements specified in [`Arc::from_raw_in`][from_raw_in]. + /// The associated `Arc` instance must be valid (i.e. the strong count must be at /// least 1) when invoking this method, and `ptr` must point to a block of memory /// allocated by `alloc`. This method can be used to release the final /// `Arc` and backing storage, but **should not** be called after the final `Arc` has been /// released. /// + /// [from_raw_in]: Arc::from_raw_in + /// /// # Examples /// /// ``` diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml index a0712b3d9a088..0bd15254e8547 100644 --- a/library/core/Cargo.toml +++ b/library/core/Cargo.toml @@ -9,18 +9,15 @@ autobenches = false # If you update this, be sure to update it in a bunch of other places too! # As of 2024, it was src/tools/opt-dist, the core-no-fp-fmt-parse test and # the version of the prelude imported in core/lib.rs. -edition = "2021" +edition = "2024" [lib] test = false bench = false -<<<<<<< HEAD [dependencies] safety = {path = "../contracts/safety" } -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 [features] # Make panics and failed asserts immediately abort without formatting any message panic_immediate_abort = [] diff --git a/library/core/src/any.rs b/library/core/src/any.rs index 9ed2c8e9f3ad1..10f2a11d558be 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -109,7 +109,7 @@ use crate::{fmt, hash, intrinsics}; // unsafe traits and unsafe methods (i.e., `type_id` would still be safe to call, // but we would likely want to indicate as such in documentation). #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "Any")] +#[rustc_diagnostic_item = "Any"] pub trait Any: 'static { /// Gets the `TypeId` of `self`. /// diff --git a/library/core/src/array/ascii.rs b/library/core/src/array/ascii.rs index e2faef855bc2c..792a57e3fa25c 100644 --- a/library/core/src/array/ascii.rs +++ b/library/core/src/array/ascii.rs @@ -1,6 +1,5 @@ use crate::ascii; -#[cfg(not(test))] impl [u8; N] { /// Converts this array of bytes into an array of ASCII characters, /// or returns `None` if any of the characters is non-ASCII. diff --git a/library/core/src/bool.rs b/library/core/src/bool.rs index 3c589ca5dfa7e..d525ab425e60d 100644 --- a/library/core/src/bool.rs +++ b/library/core/src/bool.rs @@ -56,7 +56,7 @@ impl bool { /// ``` #[doc(alias = "then_with")] #[stable(feature = "lazy_bool_to_option", since = "1.50.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "bool_then")] + #[rustc_diagnostic_item = "bool_then"] #[inline] pub fn then T>(self, f: F) -> Option { if self { Some(f()) } else { None } diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index cbf00106c5173..1a320b316a41a 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -304,7 +304,7 @@ pub use once::OnceCell; /// ``` /// /// See the [module-level documentation](self) for more. -#[cfg_attr(not(test), rustc_diagnostic_item = "Cell")] +#[rustc_diagnostic_item = "Cell"] #[stable(feature = "rust1", since = "1.0.0")] #[repr(transparent)] #[rustc_pub_transparent] @@ -725,7 +725,7 @@ impl Cell<[T; N]> { /// A mutable memory location with dynamically checked borrow rules /// /// See the [module-level documentation](self) for more. -#[cfg_attr(not(test), rustc_diagnostic_item = "RefCell")] +#[rustc_diagnostic_item = "RefCell"] #[stable(feature = "rust1", since = "1.0.0")] pub struct RefCell { borrow: Cell, diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 10e9e40db1fda..39c37b7090d61 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -1180,7 +1180,7 @@ impl char { #[must_use] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] #[rustc_const_stable(feature = "const_char_is_ascii", since = "1.32.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "char_is_ascii")] + #[rustc_diagnostic_item = "char_is_ascii"] #[inline] pub const fn is_ascii(&self) -> bool { *self as u32 <= 0x7F diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs index c777dd995a656..e0ac0bfc5289f 100644 --- a/library/core/src/clone.rs +++ b/library/core/src/clone.rs @@ -262,34 +262,150 @@ pub struct AssertParamIsCopy { _field: crate::marker::PhantomData, } -/// A generalization of [`Clone`] to dynamically-sized types stored in arbitrary containers. +/// A generalization of [`Clone`] to [dynamically-sized types][DST] stored in arbitrary containers. /// -/// This trait is implemented for all types implementing [`Clone`], and also [slices](slice) of all -/// such types. You may also implement this trait to enable cloning trait objects and custom DSTs -/// (structures containing dynamically-sized fields). +/// This trait is implemented for all types implementing [`Clone`], [slices](slice) of all +/// such types, and other dynamically-sized types in the standard library. +/// You may also implement this trait to enable cloning custom DSTs +/// (structures containing dynamically-sized fields), or use it as a supertrait to enable +/// cloning a [trait object]. +/// +/// This trait is normally used via operations on container types which support DSTs, +/// so you should not typically need to call `.clone_to_uninit()` explicitly except when +/// implementing such a container or otherwise performing explicit management of an allocation, +/// or when implementing `CloneToUninit` itself. /// /// # Safety /// -/// Implementations must ensure that when `.clone_to_uninit(dst)` returns normally rather than -/// panicking, it always leaves `*dst` initialized as a valid value of type `Self`. +/// Implementations must ensure that when `.clone_to_uninit(dest)` returns normally rather than +/// panicking, it always leaves `*dest` initialized as a valid value of type `Self`. +/// +/// # Examples +/// +// FIXME(#126799): when `Box::clone` allows use of `CloneToUninit`, rewrite these examples with it +// since `Rc` is a distraction. +/// +/// If you are defining a trait, you can add `CloneToUninit` as a supertrait to enable cloning of +/// `dyn` values of your trait: +/// +/// ``` +/// #![feature(clone_to_uninit)] +/// use std::rc::Rc; +/// +/// trait Foo: std::fmt::Debug + std::clone::CloneToUninit { +/// fn modify(&mut self); +/// fn value(&self) -> i32; +/// } +/// +/// impl Foo for i32 { +/// fn modify(&mut self) { +/// *self *= 10; +/// } +/// fn value(&self) -> i32 { +/// *self +/// } +/// } +/// +/// let first: Rc = Rc::new(1234); +/// +/// let mut second = first.clone(); +/// Rc::make_mut(&mut second).modify(); // make_mut() will call clone_to_uninit() +/// +/// assert_eq!(first.value(), 1234); +/// assert_eq!(second.value(), 12340); +/// ``` +/// +/// The following is an example of implementing `CloneToUninit` for a custom DST. +/// (It is essentially a limited form of what `derive(CloneToUninit)` would do, +/// if such a derive macro existed.) /// -/// # See also +/// ``` +/// #![feature(clone_to_uninit)] +/// use std::clone::CloneToUninit; +/// use std::mem::offset_of; +/// use std::rc::Rc; +/// +/// #[derive(PartialEq)] +/// struct MyDst { +/// label: String, +/// contents: T, +/// } /// -/// * [`Clone::clone_from`] is a safe function which may be used instead when `Self` is a [`Sized`] +/// unsafe impl CloneToUninit for MyDst { +/// unsafe fn clone_to_uninit(&self, dest: *mut u8) { +/// // The offset of `self.contents` is dynamic because it depends on the alignment of T +/// // which can be dynamic (if `T = dyn SomeTrait`). Therefore, we have to obtain it +/// // dynamically by examining `self`, rather than using `offset_of!`. +/// // +/// // SAFETY: `self` by definition points somewhere before `&self.contents` in the same +/// // allocation. +/// let offset_of_contents = unsafe { +/// (&raw const self.contents).byte_offset_from_unsigned(self) +/// }; +/// +/// // Clone the *sized* fields of `self` (just one, in this example). +/// // (By cloning this first and storing it temporarily in a local variable, we avoid +/// // leaking it in case of any panic, using the ordinary automatic cleanup of local +/// // variables. Such a leak would be sound, but undesirable.) +/// let label = self.label.clone(); +/// +/// // SAFETY: The caller must provide a `dest` such that these field offsets are valid +/// // to write to. +/// unsafe { +/// // Clone the unsized field directly from `self` to `dest`. +/// self.contents.clone_to_uninit(dest.add(offset_of_contents)); +/// +/// // Now write all the sized fields. +/// // +/// // Note that we only do this once all of the clone() and clone_to_uninit() calls +/// // have completed, and therefore we know that there are no more possible panics; +/// // this ensures no memory leaks in case of panic. +/// dest.add(offset_of!(Self, label)).cast::().write(label); +/// } +/// // All fields of the struct have been initialized; therefore, the struct is initialized, +/// // and we have satisfied our `unsafe impl CloneToUninit` obligations. +/// } +/// } +/// +/// fn main() { +/// // Construct MyDst<[u8; 4]>, then coerce to MyDst<[u8]>. +/// let first: Rc> = Rc::new(MyDst { +/// label: String::from("hello"), +/// contents: [1, 2, 3, 4], +/// }); +/// +/// let mut second = first.clone(); +/// // make_mut() will call clone_to_uninit(). +/// for elem in Rc::make_mut(&mut second).contents.iter_mut() { +/// *elem *= 10; +/// } +/// +/// assert_eq!(first.contents, [1, 2, 3, 4]); +/// assert_eq!(second.contents, [10, 20, 30, 40]); +/// assert_eq!(second.label, "hello"); +/// } +/// ``` +/// +/// # See Also +/// +/// * [`Clone::clone_from`] is a safe function which may be used instead when [`Self: Sized`](Sized) /// and the destination is already initialized; it may be able to reuse allocations owned by -/// the destination. +/// the destination, whereas `clone_to_uninit` cannot, since its destination is assumed to be +/// uninitialized. /// * [`ToOwned`], which allocates a new destination container. /// /// [`ToOwned`]: ../../std/borrow/trait.ToOwned.html +/// [DST]: https://doc.rust-lang.org/reference/dynamically-sized-types.html +/// [trait object]: https://doc.rust-lang.org/reference/types/trait-object.html #[unstable(feature = "clone_to_uninit", issue = "126799")] pub unsafe trait CloneToUninit { - /// Performs copy-assignment from `self` to `dst`. + /// Performs copy-assignment from `self` to `dest`. /// - /// This is analogous to `std::ptr::write(dst.cast(), self.clone())`, - /// except that `self` may be a dynamically-sized type ([`!Sized`](Sized)). + /// This is analogous to `std::ptr::write(dest.cast(), self.clone())`, + /// except that `Self` may be a dynamically-sized type ([`!Sized`](Sized)). /// - /// Before this function is called, `dst` may point to uninitialized memory. - /// After this function is called, `dst` will point to initialized memory; it will be + /// Before this function is called, `dest` may point to uninitialized memory. + /// After this function is called, `dest` will point to initialized memory; it will be /// sound to create a `&Self` reference from the pointer with the [pointer metadata] /// from `self`. /// @@ -297,8 +413,8 @@ pub unsafe trait CloneToUninit { /// /// Behavior is undefined if any of the following conditions are violated: /// - /// * `dst` must be [valid] for writes for `size_of_val(self)` bytes. - /// * `dst` must be properly aligned to `align_of_val(self)`. + /// * `dest` must be [valid] for writes for `size_of_val(self)` bytes. + /// * `dest` must be properly aligned to `align_of_val(self)`. /// /// [valid]: crate::ptr#safety /// [pointer metadata]: crate::ptr::metadata() @@ -307,27 +423,26 @@ pub unsafe trait CloneToUninit { /// /// This function may panic. (For example, it might panic if memory allocation for a clone /// of a value owned by `self` fails.) - /// If the call panics, then `*dst` should be treated as uninitialized memory; it must not be + /// If the call panics, then `*dest` should be treated as uninitialized memory; it must not be /// read or dropped, because even if it was previously valid, it may have been partially /// overwritten. /// - /// The caller may also need to take care to deallocate the allocation pointed to by `dst`, - /// if applicable, to avoid a memory leak, and may need to take other precautions to ensure - /// soundness in the presence of unwinding. + /// The caller may wish to to take care to deallocate the allocation pointed to by `dest`, + /// if applicable, to avoid a memory leak (but this is not a requirement). /// /// Implementors should avoid leaking values by, upon unwinding, dropping all component values /// that might have already been created. (For example, if a `[Foo]` of length 3 is being /// cloned, and the second of the three calls to `Foo::clone()` unwinds, then the first `Foo` /// cloned should be dropped.) - unsafe fn clone_to_uninit(&self, dst: *mut u8); + unsafe fn clone_to_uninit(&self, dest: *mut u8); } #[unstable(feature = "clone_to_uninit", issue = "126799")] unsafe impl CloneToUninit for T { #[inline] - unsafe fn clone_to_uninit(&self, dst: *mut u8) { + unsafe fn clone_to_uninit(&self, dest: *mut u8) { // SAFETY: we're calling a specialization with the same contract - unsafe { ::clone_one(self, dst.cast::()) } + unsafe { ::clone_one(self, dest.cast::()) } } } @@ -335,10 +450,10 @@ unsafe impl CloneToUninit for T { unsafe impl CloneToUninit for [T] { #[inline] #[cfg_attr(debug_assertions, track_caller)] - unsafe fn clone_to_uninit(&self, dst: *mut u8) { - let dst: *mut [T] = dst.with_metadata_of(self); + unsafe fn clone_to_uninit(&self, dest: *mut u8) { + let dest: *mut [T] = dest.with_metadata_of(self); // SAFETY: we're calling a specialization with the same contract - unsafe { ::clone_slice(self, dst) } + unsafe { ::clone_slice(self, dest) } } } @@ -346,21 +461,21 @@ unsafe impl CloneToUninit for [T] { unsafe impl CloneToUninit for str { #[inline] #[cfg_attr(debug_assertions, track_caller)] - unsafe fn clone_to_uninit(&self, dst: *mut u8) { + unsafe fn clone_to_uninit(&self, dest: *mut u8) { // SAFETY: str is just a [u8] with UTF-8 invariant - unsafe { self.as_bytes().clone_to_uninit(dst) } + unsafe { self.as_bytes().clone_to_uninit(dest) } } } #[unstable(feature = "clone_to_uninit", issue = "126799")] unsafe impl CloneToUninit for crate::ffi::CStr { #[cfg_attr(debug_assertions, track_caller)] - unsafe fn clone_to_uninit(&self, dst: *mut u8) { + unsafe fn clone_to_uninit(&self, dest: *mut u8) { // SAFETY: For now, CStr is just a #[repr(trasnsparent)] [c_char] with some invariants. // And we can cast [c_char] to [u8] on all supported platforms (see: to_bytes_with_nul). // The pointer metadata properly preserves the length (so NUL is also copied). // See: `cstr_metadata_is_length_with_nul` in tests. - unsafe { self.to_bytes_with_nul().clone_to_uninit(dst) } + unsafe { self.to_bytes_with_nul().clone_to_uninit(dest) } } } diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index b29251b4b436c..25bd17d5802fd 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1481,7 +1481,7 @@ pub macro PartialOrd($item:item) { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "cmp_min")] +#[rustc_diagnostic_item = "cmp_min"] pub fn min(v1: T, v2: T) -> T { v1.min(v2) } @@ -1573,7 +1573,7 @@ pub fn min_by_key K, K: Ord>(v1: T, v2: T, mut f: F) -> T { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "cmp_max")] +#[rustc_diagnostic_item = "cmp_max"] pub fn max(v1: T, v2: T) -> T { v1.max(v2) } diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 43fd54f881dae..e1b10e1074d27 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -214,7 +214,7 @@ pub const fn identity(x: T) -> T { /// is_hello(s); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "AsRef")] +#[rustc_diagnostic_item = "AsRef"] pub trait AsRef { /// Converts this type into a shared reference of the (usually inferred) input type. #[stable(feature = "rust1", since = "1.0.0")] @@ -365,7 +365,7 @@ pub trait AsRef { /// Note, however, that APIs don't need to be generic. In many cases taking a `&mut [u8]` or /// `&mut Vec`, for example, is the better choice (callers need to pass the correct type then). #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "AsMut")] +#[rustc_diagnostic_item = "AsMut"] pub trait AsMut { /// Converts this type into a mutable reference of the (usually inferred) input type. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/default.rs b/library/core/src/default.rs index 4c30290ff263b..044997a81a9a2 100644 --- a/library/core/src/default.rs +++ b/library/core/src/default.rs @@ -101,7 +101,7 @@ use crate::ascii::Char as AsciiChar; /// bar: f32, /// } /// ``` -#[cfg_attr(not(test), rustc_diagnostic_item = "Default")] +#[rustc_diagnostic_item = "Default"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_trivial_field_reads] pub trait Default: Sized { diff --git a/library/core/src/error.rs b/library/core/src/error.rs index 94847685ec965..bfa392003b91b 100644 --- a/library/core/src/error.rs +++ b/library/core/src/error.rs @@ -47,7 +47,7 @@ use crate::fmt::{self, Debug, Display, Formatter}; /// impl Error for ReadConfigError {} /// ``` #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "Error")] +#[rustc_diagnostic_item = "Error"] #[rustc_has_incoherent_inherent_impls] #[allow(multiple_supertrait_upcastable)] pub trait Error: Debug + Display { diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index e0dc632df7051..b13c7ee5aa28b 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -18,7 +18,7 @@ mod num; mod rt; #[stable(feature = "fmt_flags_align", since = "1.28.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "Alignment")] +#[rustc_diagnostic_item = "Alignment"] /// Possible alignments returned by `Formatter::align` #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Alignment { @@ -2771,7 +2771,14 @@ impl Display for char { #[stable(feature = "rust1", since = "1.0.0")] impl Pointer for *const T { fn fmt(&self, f: &mut Formatter<'_>) -> Result { - pointer_fmt_inner(self.expose_provenance(), f) + if <::Metadata as core::unit::IsUnit>::is_unit() { + pointer_fmt_inner(self.expose_provenance(), f) + } else { + f.debug_struct("Pointer") + .field_with("addr", |f| pointer_fmt_inner(self.expose_provenance(), f)) + .field("metadata", &core::ptr::metadata(*self)) + .finish() + } } } diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index df1fd5d46a177..5f41638e8d780 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -94,6 +94,7 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { // memory, which is not valid for either `&` or `&mut`. /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -103,6 +104,7 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { #[rustc_nounwind] pub unsafe fn atomic_cxchg_relaxed_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -112,6 +114,7 @@ pub unsafe fn atomic_cxchg_relaxed_relaxed(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_relaxed_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -121,6 +124,7 @@ pub unsafe fn atomic_cxchg_relaxed_acquire(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_relaxed_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -130,6 +134,7 @@ pub unsafe fn atomic_cxchg_relaxed_seqcst(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_acquire_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -139,6 +144,7 @@ pub unsafe fn atomic_cxchg_acquire_relaxed(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_acquire_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -148,6 +154,7 @@ pub unsafe fn atomic_cxchg_acquire_acquire(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_acquire_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -157,6 +164,7 @@ pub unsafe fn atomic_cxchg_acquire_seqcst(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_release_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -166,6 +174,7 @@ pub unsafe fn atomic_cxchg_release_relaxed(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_release_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -175,6 +184,7 @@ pub unsafe fn atomic_cxchg_release_acquire(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_release_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -184,6 +194,7 @@ pub unsafe fn atomic_cxchg_release_seqcst(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_acqrel_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -193,6 +204,7 @@ pub unsafe fn atomic_cxchg_acqrel_relaxed(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_acqrel_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -202,6 +214,7 @@ pub unsafe fn atomic_cxchg_acqrel_acquire(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_acqrel_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -211,6 +224,7 @@ pub unsafe fn atomic_cxchg_acqrel_seqcst(dst: *mut T, old: T, src: T) - #[rustc_nounwind] pub unsafe fn atomic_cxchg_seqcst_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -220,6 +234,7 @@ pub unsafe fn atomic_cxchg_seqcst_relaxed(dst: *mut T, old: T, src: T) #[rustc_nounwind] pub unsafe fn atomic_cxchg_seqcst_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange` method by passing @@ -230,6 +245,7 @@ pub unsafe fn atomic_cxchg_seqcst_acquire(dst: *mut T, old: T, src: T) pub unsafe fn atomic_cxchg_seqcst_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -243,6 +259,7 @@ pub unsafe fn atomic_cxchgweak_relaxed_relaxed( _src: T, ) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -256,6 +273,7 @@ pub unsafe fn atomic_cxchgweak_relaxed_acquire( _src: T, ) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -265,6 +283,7 @@ pub unsafe fn atomic_cxchgweak_relaxed_acquire( #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_relaxed_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -278,6 +297,7 @@ pub unsafe fn atomic_cxchgweak_acquire_relaxed( _src: T, ) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -291,6 +311,7 @@ pub unsafe fn atomic_cxchgweak_acquire_acquire( _src: T, ) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -300,6 +321,7 @@ pub unsafe fn atomic_cxchgweak_acquire_acquire( #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_acquire_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -313,6 +335,7 @@ pub unsafe fn atomic_cxchgweak_release_relaxed( _src: T, ) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -326,6 +349,7 @@ pub unsafe fn atomic_cxchgweak_release_acquire( _src: T, ) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -335,6 +359,7 @@ pub unsafe fn atomic_cxchgweak_release_acquire( #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_release_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -344,6 +369,7 @@ pub unsafe fn atomic_cxchgweak_release_seqcst(dst: *mut T, old: T, src: #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_acqrel_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -353,6 +379,7 @@ pub unsafe fn atomic_cxchgweak_acqrel_relaxed(dst: *mut T, old: T, src: #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_acqrel_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -362,6 +389,7 @@ pub unsafe fn atomic_cxchgweak_acqrel_acquire(dst: *mut T, old: T, src: #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_acqrel_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -371,6 +399,7 @@ pub unsafe fn atomic_cxchgweak_acqrel_seqcst(dst: *mut T, old: T, src: #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_seqcst_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -380,6 +409,7 @@ pub unsafe fn atomic_cxchgweak_seqcst_relaxed(dst: *mut T, old: T, src: #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_seqcst_acquire(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `compare_exchange_weak` method by passing @@ -390,6 +420,7 @@ pub unsafe fn atomic_cxchgweak_seqcst_acquire(dst: *mut T, old: T, src: pub unsafe fn atomic_cxchgweak_seqcst_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); /// Loads the current value of the pointer. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `load` method by passing @@ -398,6 +429,7 @@ pub unsafe fn atomic_cxchgweak_seqcst_seqcst(dst: *mut T, old: T, src: #[rustc_nounwind] pub unsafe fn atomic_load_seqcst(src: *const T) -> T; /// Loads the current value of the pointer. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `load` method by passing @@ -406,6 +438,7 @@ pub unsafe fn atomic_load_seqcst(src: *const T) -> T; #[rustc_nounwind] pub unsafe fn atomic_load_acquire(src: *const T) -> T; /// Loads the current value of the pointer. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `load` method by passing @@ -421,6 +454,7 @@ pub unsafe fn atomic_load_relaxed(src: *const T) -> T; pub unsafe fn atomic_load_unordered(src: *const T) -> T; /// Stores the value at the specified memory location. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `store` method by passing @@ -429,6 +463,7 @@ pub unsafe fn atomic_load_unordered(src: *const T) -> T; #[rustc_nounwind] pub unsafe fn atomic_store_seqcst(dst: *mut T, val: T); /// Stores the value at the specified memory location. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `store` method by passing @@ -437,6 +472,7 @@ pub unsafe fn atomic_store_seqcst(dst: *mut T, val: T); #[rustc_nounwind] pub unsafe fn atomic_store_release(dst: *mut T, val: T); /// Stores the value at the specified memory location. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `store` method by passing @@ -452,6 +488,7 @@ pub unsafe fn atomic_store_relaxed(dst: *mut T, val: T); pub unsafe fn atomic_store_unordered(dst: *mut T, val: T); /// Stores the value at the specified memory location, returning the old value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing @@ -460,6 +497,7 @@ pub unsafe fn atomic_store_unordered(dst: *mut T, val: T); #[rustc_nounwind] pub unsafe fn atomic_xchg_seqcst(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing @@ -468,6 +506,7 @@ pub unsafe fn atomic_xchg_seqcst(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xchg_acquire(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing @@ -476,6 +515,7 @@ pub unsafe fn atomic_xchg_acquire(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xchg_release(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing @@ -484,6 +524,7 @@ pub unsafe fn atomic_xchg_release(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xchg_acqrel(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. +/// `T` must be an integer or pointer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing @@ -493,6 +534,9 @@ pub unsafe fn atomic_xchg_acqrel(dst: *mut T, src: T) -> T; pub unsafe fn atomic_xchg_relaxed(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing @@ -501,6 +545,9 @@ pub unsafe fn atomic_xchg_relaxed(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xadd_seqcst(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing @@ -509,6 +556,9 @@ pub unsafe fn atomic_xadd_seqcst(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xadd_acquire(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing @@ -517,6 +567,9 @@ pub unsafe fn atomic_xadd_acquire(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xadd_release(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing @@ -525,6 +578,9 @@ pub unsafe fn atomic_xadd_release(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xadd_acqrel(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing @@ -534,6 +590,9 @@ pub unsafe fn atomic_xadd_acqrel(dst: *mut T, src: T) -> T; pub unsafe fn atomic_xadd_relaxed(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing @@ -542,6 +601,9 @@ pub unsafe fn atomic_xadd_relaxed(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xsub_seqcst(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing @@ -550,6 +612,9 @@ pub unsafe fn atomic_xsub_seqcst(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xsub_acquire(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing @@ -558,6 +623,9 @@ pub unsafe fn atomic_xsub_acquire(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xsub_release(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing @@ -566,6 +634,9 @@ pub unsafe fn atomic_xsub_release(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xsub_acqrel(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing @@ -575,6 +646,9 @@ pub unsafe fn atomic_xsub_acqrel(dst: *mut T, src: T) -> T; pub unsafe fn atomic_xsub_relaxed(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing @@ -583,6 +657,9 @@ pub unsafe fn atomic_xsub_relaxed(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_and_seqcst(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing @@ -591,6 +668,9 @@ pub unsafe fn atomic_and_seqcst(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_and_acquire(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing @@ -599,6 +679,9 @@ pub unsafe fn atomic_and_acquire(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_and_release(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing @@ -607,6 +690,9 @@ pub unsafe fn atomic_and_release(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_and_acqrel(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing @@ -616,6 +702,9 @@ pub unsafe fn atomic_and_acqrel(dst: *mut T, src: T) -> T; pub unsafe fn atomic_and_relaxed(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing @@ -624,6 +713,9 @@ pub unsafe fn atomic_and_relaxed(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_nand_seqcst(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing @@ -632,6 +724,9 @@ pub unsafe fn atomic_nand_seqcst(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_nand_acquire(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing @@ -640,6 +735,9 @@ pub unsafe fn atomic_nand_acquire(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_nand_release(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing @@ -648,6 +746,9 @@ pub unsafe fn atomic_nand_release(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_nand_acqrel(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing @@ -657,6 +758,9 @@ pub unsafe fn atomic_nand_acqrel(dst: *mut T, src: T) -> T; pub unsafe fn atomic_nand_relaxed(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing @@ -665,6 +769,9 @@ pub unsafe fn atomic_nand_relaxed(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_or_seqcst(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing @@ -673,6 +780,9 @@ pub unsafe fn atomic_or_seqcst(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_or_acquire(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing @@ -681,6 +791,9 @@ pub unsafe fn atomic_or_acquire(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_or_release(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing @@ -689,6 +802,9 @@ pub unsafe fn atomic_or_release(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_or_acqrel(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing @@ -698,6 +814,9 @@ pub unsafe fn atomic_or_acqrel(dst: *mut T, src: T) -> T; pub unsafe fn atomic_or_relaxed(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing @@ -706,6 +825,9 @@ pub unsafe fn atomic_or_relaxed(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xor_seqcst(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing @@ -714,6 +836,9 @@ pub unsafe fn atomic_xor_seqcst(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xor_acquire(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing @@ -722,6 +847,9 @@ pub unsafe fn atomic_xor_acquire(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xor_release(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing @@ -730,6 +858,9 @@ pub unsafe fn atomic_xor_release(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_xor_acqrel(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. +/// `T` must be an integer or pointer type. +/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new +/// value stored at `*dst` will have the provenance of the old value stored there. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing @@ -739,6 +870,7 @@ pub unsafe fn atomic_xor_acqrel(dst: *mut T, src: T) -> T; pub unsafe fn atomic_xor_relaxed(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. +/// `T` must be a signed integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing @@ -747,6 +879,7 @@ pub unsafe fn atomic_xor_relaxed(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_max_seqcst(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. +/// `T` must be a signed integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing @@ -755,6 +888,7 @@ pub unsafe fn atomic_max_seqcst(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_max_acquire(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. +/// `T` must be a signed integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing @@ -763,6 +897,7 @@ pub unsafe fn atomic_max_acquire(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_max_release(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. +/// `T` must be a signed integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing @@ -770,7 +905,8 @@ pub unsafe fn atomic_max_release(dst: *mut T, src: T) -> T; #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn atomic_max_acqrel(dst: *mut T, src: T) -> T; -/// Maximum with the current value. +/// Maximum with the current value using a signed comparison. +/// `T` must be a signed integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing @@ -780,6 +916,7 @@ pub unsafe fn atomic_max_acqrel(dst: *mut T, src: T) -> T; pub unsafe fn atomic_max_relaxed(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. +/// `T` must be a signed integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing @@ -788,6 +925,7 @@ pub unsafe fn atomic_max_relaxed(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_min_seqcst(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. +/// `T` must be a signed integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing @@ -796,6 +934,7 @@ pub unsafe fn atomic_min_seqcst(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_min_acquire(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. +/// `T` must be a signed integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing @@ -804,6 +943,7 @@ pub unsafe fn atomic_min_acquire(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_min_release(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. +/// `T` must be a signed integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing @@ -812,6 +952,7 @@ pub unsafe fn atomic_min_release(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_min_acqrel(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. +/// `T` must be a signed integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing @@ -821,6 +962,7 @@ pub unsafe fn atomic_min_acqrel(dst: *mut T, src: T) -> T; pub unsafe fn atomic_min_relaxed(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. +/// `T` must be an unsigned integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing @@ -829,6 +971,7 @@ pub unsafe fn atomic_min_relaxed(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_umin_seqcst(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. +/// `T` must be an unsigned integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing @@ -837,6 +980,7 @@ pub unsafe fn atomic_umin_seqcst(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_umin_acquire(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. +/// `T` must be an unsigned integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing @@ -845,6 +989,7 @@ pub unsafe fn atomic_umin_acquire(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_umin_release(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. +/// `T` must be an unsigned integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing @@ -853,6 +998,7 @@ pub unsafe fn atomic_umin_release(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_umin_acqrel(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. +/// `T` must be an unsigned integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing @@ -862,6 +1008,7 @@ pub unsafe fn atomic_umin_acqrel(dst: *mut T, src: T) -> T; pub unsafe fn atomic_umin_relaxed(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. +/// `T` must be an unsigned integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing @@ -870,6 +1017,7 @@ pub unsafe fn atomic_umin_relaxed(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_umax_seqcst(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. +/// `T` must be an unsigned integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing @@ -878,6 +1026,7 @@ pub unsafe fn atomic_umax_seqcst(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_umax_acquire(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. +/// `T` must be an unsigned integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing @@ -886,6 +1035,7 @@ pub unsafe fn atomic_umax_acquire(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_umax_release(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. +/// `T` must be an unsigned integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing @@ -894,6 +1044,7 @@ pub unsafe fn atomic_umax_release(dst: *mut T, src: T) -> T; #[rustc_nounwind] pub unsafe fn atomic_umax_acqrel(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. +/// `T` must be an unsigned integer type. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing @@ -1627,10 +1778,14 @@ pub fn ptr_mask(ptr: *const T, mask: usize) -> *const T; /// a size of `count` * `size_of::()` and an alignment of /// `min_align_of::()` /// -/// The volatile parameter is set to `true`, so it will not be optimized out -/// unless size is equal to zero. -/// /// This intrinsic does not have a stable counterpart. +/// # Safety +/// +/// The safety requirements are consistent with [`copy_nonoverlapping`] +/// while the read and write behaviors are volatile, +/// which means it will not be optimized out unless `_count` or `size_of::()` is equal to zero. +/// +/// [`copy_nonoverlapping`]: ptr::copy_nonoverlapping #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn volatile_copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: usize); @@ -1649,10 +1804,13 @@ pub unsafe fn volatile_copy_memory(dst: *mut T, src: *const T, count: usize); /// size of `count * size_of::()` and an alignment of /// `min_align_of::()`. /// -/// The volatile parameter is set to `true`, so it will not be optimized out -/// unless size is equal to zero. -/// /// This intrinsic does not have a stable counterpart. +/// # Safety +/// +/// The safety requirements are consistent with [`write_bytes`] while the write behavior is volatile, +/// which means it will not be optimized out unless `_count` or `size_of::()` is equal to zero. +/// +/// [`write_bytes`]: ptr::write_bytes #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn volatile_set_memory(dst: *mut T, val: u8, count: usize); @@ -3194,14 +3352,23 @@ pub const fn is_val_statically_known(_arg: T) -> bool { /// The stabilized form of this intrinsic is [`crate::mem::swap`]. /// /// # Safety +/// Behavior is undefined if any of the following conditions are violated: +/// +/// * Both `x` and `y` must be [valid] for both reads and writes. +/// +/// * Both `x` and `y` must be properly aligned. /// -/// `x` and `y` are readable and writable as `T`, and non-overlapping. +/// * The region of memory beginning at `x` must *not* overlap with the region of memory +/// beginning at `y`. +/// +/// * The memory pointed by `x` and `y` must both contain values of type `T`. +/// +/// [valid]: crate::ptr#safety #[rustc_nounwind] #[inline] #[rustc_intrinsic] #[rustc_intrinsic_const_stable_indirect] #[rustc_allow_const_fn_unstable(const_swap_nonoverlapping)] // this is anyway not called since CTFE implements the intrinsic -<<<<<<< HEAD #[cfg_attr(kani, kani::modifies(x))] #[cfg_attr(kani, kani::modifies(y))] #[requires(ub_checks::can_dereference(x) && ub_checks::can_write(x))] @@ -3209,8 +3376,6 @@ pub const fn is_val_statically_known(_arg: T) -> bool { #[requires(x.addr() != y.addr() || core::mem::size_of::() == 0)] #[requires(ub_checks::maybe_is_nonoverlapping(x as *const (), y as *const (), size_of::(), 1))] #[ensures(|_| ub_checks::can_dereference(x) && ub_checks::can_dereference(y))] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub const unsafe fn typed_swap_nonoverlapping(x: *mut T, y: *mut T) { // SAFETY: The caller provided single non-overlapping items behind // pointers, so swapping them with `count: 1` is fine. @@ -3325,17 +3490,13 @@ pub fn contract_check_ensures<'a, Ret, C: Fn(&'a Ret) -> bool>(ret: &'a Ret, con #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -<<<<<<< HEAD // VTable pointers must be valid for dereferencing at least 3 `usize` (size, alignment and drop): // // TODO: we can no longer do this given https://github.com/model-checking/kani/issues/3325 (this // function used to have a dummy body, but no longer has since // https://github.com/rust-lang/rust/pull/137489 has been merged). // #[requires(ub_checks::can_dereference(_ptr as *const [usize; 3]))] -pub unsafe fn vtable_size(_ptr: *const ()) -> usize; -======= pub unsafe fn vtable_size(ptr: *const ()) -> usize; ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 /// The intrinsic will return the alignment stored in that vtable. /// @@ -3345,18 +3506,13 @@ pub unsafe fn vtable_size(ptr: *const ()) -> usize; #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -<<<<<<< HEAD // VTable pointers must be valid for dereferencing at least 3 `usize` (size, alignment and drop): // // TODO: we can no longer do this given https://github.com/model-checking/kani/issues/3325 (this // function used to have a dummy body, but no longer has since // https://github.com/rust-lang/rust/pull/137489 has been merged). -// #[requires(ub_checks::can_dereference(_ptr as *const [usize; 3]))] -// #[requires(ub_checks::can_dereference(_ptr as *const [usize; 3]))] -pub unsafe fn vtable_align(_ptr: *const ()) -> usize; -======= +// #[requires(ub_checks::can_dereference(ptr as *const [usize; 3]))] pub unsafe fn vtable_align(ptr: *const ()) -> usize; ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 /// The size of a type in bytes. /// @@ -3987,7 +4143,6 @@ pub const unsafe fn copysignf64(x: f64, y: f64) -> f64; #[rustc_nounwind] #[rustc_intrinsic] pub const unsafe fn copysignf128(x: f128, y: f128) -> f128; -<<<<<<< HEAD /// Return whether the initialization state is preserved. /// @@ -4018,8 +4173,6 @@ fn check_copy_untyped(src: *const T, dst: *mut T, count: usize) -> bool { #[cfg(not(kani))] false } -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 /// Inform Miri that a given pointer definitely has a certain alignment. #[cfg(miri)] diff --git a/library/core/src/iter/adapters/enumerate.rs b/library/core/src/iter/adapters/enumerate.rs index ac15e3767fc09..f9c388e8564d3 100644 --- a/library/core/src/iter/adapters/enumerate.rs +++ b/library/core/src/iter/adapters/enumerate.rs @@ -14,7 +14,7 @@ use crate::ops::Try; #[derive(Clone, Debug)] #[must_use = "iterators are lazy and do nothing unless consumed"] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "Enumerate")] +#[rustc_diagnostic_item = "Enumerate"] pub struct Enumerate { iter: I, count: usize, diff --git a/library/core/src/iter/sources/repeat.rs b/library/core/src/iter/sources/repeat.rs index 243f938bce2af..c4f5a483e5c2a 100644 --- a/library/core/src/iter/sources/repeat.rs +++ b/library/core/src/iter/sources/repeat.rs @@ -56,7 +56,7 @@ use crate::num::NonZero; /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "iter_repeat")] +#[rustc_diagnostic_item = "iter_repeat"] pub fn repeat(elt: T) -> Repeat { Repeat { element: elt } } diff --git a/library/core/src/iter/traits/double_ended.rs b/library/core/src/iter/traits/double_ended.rs index 3b12678572841..7dabaece95561 100644 --- a/library/core/src/iter/traits/double_ended.rs +++ b/library/core/src/iter/traits/double_ended.rs @@ -37,7 +37,7 @@ use crate::ops::{ControlFlow, Try}; /// assert_eq!(None, iter.next_back()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "DoubleEndedIterator")] +#[rustc_diagnostic_item = "DoubleEndedIterator"] pub trait DoubleEndedIterator: Iterator { /// Removes and returns an element from the end of the iterator. /// diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 10ae43ac3fcd5..075da02285449 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -862,7 +862,7 @@ pub trait Iterator { /// Note that `iter.filter(f).next()` is equivalent to `iter.find(f)`. #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "iter_filter")] + #[rustc_diagnostic_item = "iter_filter"] fn filter

(self, predicate: P) -> Filter where Self: Sized, @@ -954,7 +954,7 @@ pub trait Iterator { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "enumerate_method")] + #[rustc_diagnostic_item = "enumerate_method"] fn enumerate(self) -> Enumerate where Self: Sized, @@ -1972,11 +1972,20 @@ pub trait Iterator { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"] - #[cfg_attr(not(test), rustc_diagnostic_item = "iterator_collect_fn")] + #[rustc_diagnostic_item = "iterator_collect_fn"] fn collect>(self) -> B where Self: Sized, { + // This is too aggressive to turn on for everything all the time, but PR#137908 + // accidentally noticed that some rustc iterators had malformed `size_hint`s, + // so this will help catch such things in debug-assertions-std runners, + // even if users won't actually ever see it. + if cfg!(debug_assertions) { + let hint = self.size_hint(); + assert!(hint.1.is_none_or(|high| high >= hint.0), "Malformed size_hint {hint:?}"); + } + FromIterator::from_iter(self) } @@ -3367,7 +3376,7 @@ pub trait Iterator { /// assert_eq!(v_map, vec![1, 2, 3]); /// ``` #[stable(feature = "iter_copied", since = "1.36.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "iter_copied")] + #[rustc_diagnostic_item = "iter_copied"] fn copied<'a, T: 'a>(self) -> Copied where Self: Sized + Iterator, @@ -3415,7 +3424,7 @@ pub trait Iterator { /// assert_eq!(&[vec![23]], &faster[..]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "iter_cloned")] + #[rustc_diagnostic_item = "iter_cloned"] fn cloned<'a, T: 'a>(self) -> Cloned where Self: Sized + Iterator, diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 0e250193cace8..74e301dc132a9 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -43,18 +43,6 @@ //! which do not trigger a panic can be assured that this function is never //! called. The `lang` attribute is called `eh_personality`. -// Since core defines many fundamental lang items, all tests live in a -// separate crate, coretests (library/coretests), to avoid bizarre issues. -// -// Here we explicitly #[cfg]-out this whole crate when testing. If we don't do -// this, both the generated test artifact and the linked libtest (which -// transitively includes core) will both define the same set of lang items, -// and this will cause the E0152 "found duplicate lang item" error. See -// discussion in #50466 for details. -// -// This cfg won't affect doc tests. -#![cfg(not(test))] -// #![stable(feature = "core", since = "1.6.0")] #![doc( html_playground_url = "https://play.rust-lang.org/", @@ -64,7 +52,6 @@ )] #![doc(rust_logo)] #![doc(cfg_hide( - not(test), no_fp_fmt_parse, target_pointer_width = "16", target_pointer_width = "32", @@ -228,15 +215,11 @@ extern crate self as core; #[prelude_import] #[allow(unused)] -use prelude::rust_2021::*; +use prelude::rust_2024::*; -#[cfg(not(test))] // See #65860 #[macro_use] mod macros; -// We don't export this through #[macro_export] for now, to avoid breakage. -// See https://github.com/rust-lang/rust/issues/82913 -#[cfg(not(test))] #[unstable(feature = "assert_matches", issue = "82775")] /// Unstable module containing the unstable `assert_matches` macro. pub mod assert_matches { diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index a527a2ea5aada..fa0d882181a51 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -37,7 +37,7 @@ macro_rules! panic { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "assert_eq_macro")] +#[rustc_diagnostic_item = "assert_eq_macro"] #[allow_internal_unstable(panic_internals)] macro_rules! assert_eq { ($left:expr, $right:expr $(,)?) => { @@ -93,7 +93,7 @@ macro_rules! assert_eq { /// ``` #[macro_export] #[stable(feature = "assert_ne", since = "1.13.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "assert_ne_macro")] +#[rustc_diagnostic_item = "assert_ne_macro"] #[allow_internal_unstable(panic_internals)] macro_rules! assert_ne { ($left:expr, $right:expr $(,)?) => { @@ -331,7 +331,7 @@ macro_rules! debug_assert { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "debug_assert_eq_macro")] +#[rustc_diagnostic_item = "debug_assert_eq_macro"] macro_rules! debug_assert_eq { ($($arg:tt)*) => { if $crate::cfg!(debug_assertions) { @@ -361,7 +361,7 @@ macro_rules! debug_assert_eq { /// ``` #[macro_export] #[stable(feature = "assert_ne", since = "1.13.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "debug_assert_ne_macro")] +#[rustc_diagnostic_item = "debug_assert_ne_macro"] macro_rules! debug_assert_ne { ($($arg:tt)*) => { if $crate::cfg!(debug_assertions) { @@ -442,7 +442,7 @@ pub macro debug_assert_matches($($arg:tt)*) { /// ``` #[macro_export] #[stable(feature = "matches_macro", since = "1.42.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "matches_macro")] +#[rustc_diagnostic_item = "matches_macro"] macro_rules! matches { ($expression:expr, $pattern:pat $(if $guard:expr)? $(,)?) => { match $expression { @@ -617,7 +617,7 @@ macro_rules! r#try { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "write_macro")] +#[rustc_diagnostic_item = "write_macro"] macro_rules! write { ($dst:expr, $($arg:tt)*) => { $dst.write_fmt($crate::format_args!($($arg)*)) @@ -651,7 +651,7 @@ macro_rules! write { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "writeln_macro")] +#[rustc_diagnostic_item = "writeln_macro"] #[allow_internal_unstable(format_args_nl)] macro_rules! writeln { ($dst:expr $(,)?) => { @@ -718,7 +718,7 @@ macro_rules! writeln { #[rustc_builtin_macro(unreachable)] #[allow_internal_unstable(edition_panic)] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "unreachable_macro")] +#[rustc_diagnostic_item = "unreachable_macro"] macro_rules! unreachable { // Expands to either `$crate::panic::unreachable_2015` or `$crate::panic::unreachable_2021` // depending on the edition of the caller. @@ -803,7 +803,7 @@ macro_rules! unreachable { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "unimplemented_macro")] +#[rustc_diagnostic_item = "unimplemented_macro"] #[allow_internal_unstable(panic_internals)] macro_rules! unimplemented { () => { @@ -883,7 +883,7 @@ macro_rules! unimplemented { /// ``` #[macro_export] #[stable(feature = "todo_macro", since = "1.40.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "todo_macro")] +#[rustc_diagnostic_item = "todo_macro"] #[allow_internal_unstable(panic_internals)] macro_rules! todo { () => { @@ -995,7 +995,7 @@ pub(crate) mod builtin { /// and cannot be stored for later use. /// This is a known limitation, see [#92698](https://github.com/rust-lang/rust/issues/92698). #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "format_args_macro")] + #[rustc_diagnostic_item = "format_args_macro"] #[allow_internal_unsafe] #[allow_internal_unstable(fmt_internals)] #[rustc_builtin_macro] @@ -1342,7 +1342,7 @@ pub(crate) mod builtin { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_builtin_macro] #[macro_export] - #[cfg_attr(not(test), rustc_diagnostic_item = "include_str_macro")] + #[rustc_diagnostic_item = "include_str_macro"] macro_rules! include_str { ($file:expr $(,)?) => {{ /* compiler built-in */ }}; } @@ -1382,7 +1382,7 @@ pub(crate) mod builtin { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_builtin_macro] #[macro_export] - #[cfg_attr(not(test), rustc_diagnostic_item = "include_bytes_macro")] + #[rustc_diagnostic_item = "include_bytes_macro"] macro_rules! include_bytes { ($file:expr $(,)?) => {{ /* compiler built-in */ }}; } diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index e234f105b0b76..68011310d2cad 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -82,7 +82,7 @@ macro marker_impls { /// [arc]: ../../std/sync/struct.Arc.html /// [ub]: ../../reference/behavior-considered-undefined.html #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "Send")] +#[rustc_diagnostic_item = "Send"] #[diagnostic::on_unimplemented( message = "`{Self}` cannot be sent between threads safely", label = "`{Self}` cannot be sent between threads safely" @@ -465,9 +465,13 @@ impl Copy for &T {} /// Notably, this doesn't include all trivially-destructible types for semver /// reasons. /// -/// Bikeshed name for now. +/// Bikeshed name for now. This trait does not do anything other than reflect the +/// set of types that are allowed within unions for field validity. #[unstable(feature = "bikeshed_guaranteed_no_drop", issue = "none")] #[lang = "bikeshed_guaranteed_no_drop"] +#[rustc_deny_explicit_impl] +#[rustc_do_not_implement_via_object] +#[doc(hidden)] pub trait BikeshedGuaranteedNoDrop {} /// Types for which it is safe to share references between threads. @@ -541,7 +545,7 @@ pub trait BikeshedGuaranteedNoDrop {} /// [transmute]: crate::mem::transmute /// [nomicon-send-and-sync]: ../../nomicon/send-and-sync.html #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "Sync")] +#[rustc_diagnostic_item = "Sync"] #[lang = "sync"] #[rustc_on_unimplemented( on( @@ -1301,7 +1305,7 @@ pub trait FnPtr: Copy + Clone { /// ``` #[rustc_builtin_macro(CoercePointee, attributes(pointee))] #[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize, coerce_pointee_validated)] -#[cfg_attr(not(test), rustc_diagnostic_item = "CoercePointee")] +#[rustc_diagnostic_item = "CoercePointee"] #[unstable(feature = "derive_coerce_pointee", issue = "123430")] pub macro CoercePointee($item:item) { /* compiler built-in */ diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 4900d5e0c0ac1..a1fe1e9e2b5d4 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -142,7 +142,7 @@ pub use crate::intrinsics::transmute; #[inline] #[rustc_const_stable(feature = "const_forget", since = "1.46.0")] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "mem_forget")] +#[rustc_diagnostic_item = "mem_forget"] pub const fn forget(t: T) { let _ = ManuallyDrop::new(t); } @@ -302,7 +302,7 @@ pub fn forget_unsized(t: T) { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_promotable] #[rustc_const_stable(feature = "const_mem_size_of", since = "1.24.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "mem_size_of")] +#[rustc_diagnostic_item = "mem_size_of"] pub const fn size_of() -> usize { intrinsics::size_of::() } @@ -330,7 +330,7 @@ pub const fn size_of() -> usize { #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_size_of_val", since = "1.85.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "mem_size_of_val")] +#[rustc_diagnostic_item = "mem_size_of_val"] pub const fn size_of_val(val: &T) -> usize { // SAFETY: `val` is a reference, so it's a valid raw pointer unsafe { intrinsics::size_of_val(val) } @@ -850,7 +850,7 @@ pub fn take(dest: &mut T) -> T { #[stable(feature = "rust1", since = "1.0.0")] #[must_use = "if you don't need the old value, you can just assign the new value directly"] #[rustc_const_stable(feature = "const_replace", since = "1.83.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "mem_replace")] +#[rustc_diagnostic_item = "mem_replace"] pub const fn replace(dest: &mut T, src: T) -> T { // It may be tempting to use `swap` to avoid `unsafe` here. Don't! // The compiler optimizes the implementation below to two `memcpy`s @@ -860,8 +860,13 @@ pub const fn replace(dest: &mut T, src: T) -> T { // such that the old value is not duplicated. Nothing is dropped and // nothing here can panic. unsafe { - let result = ptr::read(dest); - ptr::write(dest, src); + // Ideally we wouldn't use the intrinsics here, but going through the + // `ptr` methods introduces two unnecessary UbChecks, so until we can + // remove those for pointers that come from references, this uses the + // intrinsics instead so this stays very cheap in MIR (and debug). + + let result = crate::intrinsics::read_via_copy(dest); + crate::intrinsics::write_via_move(dest, src); result } } @@ -930,7 +935,7 @@ pub const fn replace(dest: &mut T, src: T) -> T { /// [`RefCell`]: crate::cell::RefCell #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "mem_drop")] +#[rustc_diagnostic_item = "mem_drop"] pub fn drop(_x: T) {} /// Bitwise-copies a value. @@ -1153,7 +1158,7 @@ impl fmt::Debug for Discriminant { /// ``` #[stable(feature = "discriminant_value", since = "1.21.0")] #[rustc_const_stable(feature = "const_discriminant", since = "1.75.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "mem_discriminant")] +#[rustc_diagnostic_item = "mem_discriminant"] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const fn discriminant(v: &T) -> Discriminant { Discriminant(intrinsics::discriminant_value(v)) @@ -1253,42 +1258,56 @@ impl SizedTypeProperties for T {} /// Expands to the offset in bytes of a field from the beginning of the given type. /// -/// Structs, enums, unions and tuples are supported. -/// -/// Nested field accesses may be used, but not array indexes. +/// The type may be a `struct`, `enum`, `union`, or tuple. /// -/// If the nightly-only feature `offset_of_enum` is enabled, -/// variants may be traversed as if they were fields. -/// Variants themselves do not have an offset. +/// The field may be a nested field (`field1.field2`), but not an array index. +/// The field must be visible to the call site. /// -/// Visibility is respected - all types and fields must be visible to the call site: +/// The offset is returned as a [`usize`]. /// -/// ``` -/// mod nested { -/// #[repr(C)] -/// pub struct Struct { -/// private: u8, -/// } -/// } +/// # Offsets of, and in, dynamically sized types /// -/// // assert_eq!(mem::offset_of!(nested::Struct, private), 0); -/// // ^^^ error[E0616]: field `private` of struct `Struct` is private -/// ``` +/// The field’s type must be [`Sized`], but it may be located in a [dynamically sized] container. +/// If the field type is dynamically sized, then you cannot use `offset_of!` (since the field's +/// alignment, and therefore its offset, may also be dynamic) and must take the offset from an +/// actual pointer to the container instead. /// -/// Only [`Sized`] fields are supported, but the container may be unsized: /// ``` /// # use core::mem; +/// # use core::fmt::Debug; /// #[repr(C)] -/// pub struct Struct { +/// pub struct Struct { /// a: u8, -/// b: [u8], +/// b: T, /// } /// -/// assert_eq!(mem::offset_of!(Struct, a), 0); // OK -/// // assert_eq!(mem::offset_of!(Struct, b), 1); -/// // ^^^ error[E0277]: doesn't have a size known at compile-time +/// #[derive(Debug)] +/// #[repr(C, align(4))] +/// struct Align4(u32); +/// +/// assert_eq!(mem::offset_of!(Struct, a), 0); // OK — Sized field +/// assert_eq!(mem::offset_of!(Struct, b), 4); // OK — not DST +/// +/// // assert_eq!(mem::offset_of!(Struct, b), 1); +/// // ^^^ error[E0277]: ... cannot be known at compilation time +/// +/// // To obtain the offset of a !Sized field, examine a concrete value +/// // instead of using offset_of!. +/// let value: Struct = Struct { a: 1, b: Align4(2) }; +/// let ref_unsized: &Struct = &value; +/// let offset_of_b = unsafe { +/// (&raw const ref_unsized.b).byte_offset_from_unsigned(ref_unsized) +/// }; +/// assert_eq!(offset_of_b, 4); /// ``` /// +/// If you need to obtain the offset of a field of a `!Sized` type, then, since the offset may +/// depend on the particular value being stored (in particular, `dyn Trait` values have a +/// dynamically-determined alignment), you must retrieve the offset from a specific reference +/// or pointer, and so you cannot use `offset_of!` to work without one. +/// +/// # Layout is subject to change +/// /// Note that type layout is, in general, [subject to change and /// platform-specific](https://doc.rust-lang.org/reference/type-layout.html). If /// layout stability is required, consider using an [explicit `repr` attribute]. @@ -1324,11 +1343,16 @@ impl SizedTypeProperties for T {} /// /// [explicit `repr` attribute]: https://doc.rust-lang.org/reference/type-layout.html#representations /// +/// # Unstable features +/// +/// The following unstable features expand the functionality of `offset_of!`: +/// +/// * [`offset_of_enum`] — allows `enum` variants to be traversed as if they were fields. +/// * [`offset_of_slice`] — allows getting the offset of a field of type `[T]`. +/// /// # Examples /// /// ``` -/// #![feature(offset_of_enum)] -/// /// use std::mem; /// #[repr(C)] /// struct FieldStruct { @@ -1350,18 +1374,11 @@ impl SizedTypeProperties for T {} /// struct NestedB(u8); /// /// assert_eq!(mem::offset_of!(NestedA, b.0), 0); -/// -/// #[repr(u8)] -/// enum Enum { -/// A(u8, u16), -/// B { one: u8, two: u16 }, -/// } -/// -/// assert_eq!(mem::offset_of!(Enum, A.0), 1); -/// assert_eq!(mem::offset_of!(Enum, B.two), 2); -/// -/// assert_eq!(mem::offset_of!(Option<&u8>, Some.0), 0); /// ``` +/// +/// [dynamically sized]: https://doc.rust-lang.org/reference/dynamically-sized-types.html +/// [`offset_of_enum`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/offset-of-enum.html +/// [`offset_of_slice`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/offset-of-slice.html #[stable(feature = "offset_of", since = "1.77.0")] #[allow_internal_unstable(builtin_syntax)] pub macro offset_of($Container:ty, $($fields:expr)+ $(,)?) { diff --git a/library/core/src/net/ip_addr.rs b/library/core/src/net/ip_addr.rs index 8e4417ec461b8..7aa5ed60d0467 100644 --- a/library/core/src/net/ip_addr.rs +++ b/library/core/src/net/ip_addr.rs @@ -25,7 +25,7 @@ use crate::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not}; /// assert_eq!(localhost_v4.is_ipv6(), false); /// assert_eq!(localhost_v4.is_ipv4(), true); /// ``` -#[cfg_attr(not(test), rustc_diagnostic_item = "IpAddr")] +#[rustc_diagnostic_item = "IpAddr"] #[stable(feature = "ip_addr", since = "1.7.0")] #[derive(Copy, Clone, Eq, PartialEq, Hash, PartialOrd, Ord)] pub enum IpAddr { diff --git a/library/core/src/net/socket_addr.rs b/library/core/src/net/socket_addr.rs index 57f47e66e81e7..21753d0092497 100644 --- a/library/core/src/net/socket_addr.rs +++ b/library/core/src/net/socket_addr.rs @@ -8,11 +8,15 @@ use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr}; /// as possibly some version-dependent additional information. See [`SocketAddrV4`]'s and /// [`SocketAddrV6`]'s respective documentation for more details. /// -/// The size of a `SocketAddr` instance may vary depending on the target operating -/// system. -/// /// [IP address]: IpAddr /// +/// # Portability +/// +/// `SocketAddr` is intended to be a portable representation of socket addresses and is likely not +/// the same as the internal socket address type used by the target operating system's API. Like all +/// `repr(Rust)` structs, however, its exact layout remains undefined and should not be relied upon +/// between builds. +/// /// # Examples /// /// ``` @@ -42,13 +46,16 @@ pub enum SocketAddr { /// /// See [`SocketAddr`] for a type encompassing both IPv4 and IPv6 socket addresses. /// -/// The size of a `SocketAddrV4` struct may vary depending on the target operating -/// system. Do not assume that this type has the same memory layout as the underlying -/// system representation. -/// /// [IETF RFC 793]: https://tools.ietf.org/html/rfc793 /// [`IPv4` address]: Ipv4Addr /// +/// # Portability +/// +/// `SocketAddrV4` is intended to be a portable representation of socket addresses and is likely not +/// the same as the internal socket address type used by the target operating system's API. Like all +/// `repr(Rust)` structs, however, its exact layout remains undefined and should not be relied upon +/// between builds. +/// /// # Textual representation /// /// `SocketAddrV4` provides a [`FromStr`](crate::str::FromStr) implementation. @@ -84,13 +91,16 @@ pub struct SocketAddrV4 { /// /// See [`SocketAddr`] for a type encompassing both IPv4 and IPv6 socket addresses. /// -/// The size of a `SocketAddrV6` struct may vary depending on the target operating -/// system. Do not assume that this type has the same memory layout as the underlying -/// system representation. -/// /// [IETF RFC 2553, Section 3.3]: https://tools.ietf.org/html/rfc2553#section-3.3 /// [`IPv6` address]: Ipv6Addr /// +/// # Portability +/// +/// `SocketAddrV6` is intended to be a portable representation of socket addresses and is likely not +/// the same as the internal socket address type used by the target operating system's API. Like all +/// `repr(Rust)` structs, however, its exact layout remains undefined and should not be relied upon +/// between builds. +/// /// # Textual representation /// /// `SocketAddrV6` provides a [`FromStr`](crate::str::FromStr) implementation, diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index 9a1db8f289a75..325fa4b357ed8 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -14,15 +14,14 @@ use safety::requires; use crate::convert::FloatToInt; -#[cfg(not(test))] -use crate::intrinsics; #[cfg(kani)] use crate::kani; -use crate::mem; use crate::num::FpCategory; use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; +use crate::{intrinsics, mem}; + /// Basic mathematical constants. #[unstable(feature = "f128", issue = "116909")] pub mod consts { @@ -143,7 +142,6 @@ pub mod consts { pub const LN_10: f128 = 2.30258509299404568401799145468436420760110148862877297603333_f128; } -#[cfg(not(test))] impl f128 { // FIXME(f16_f128): almost all methods in this `impl` are missing examples and a const // implementation. Add these once we can run code on all platforms and have f16/f128 in CTFE. diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index d33e7255f416d..9583742322659 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -14,15 +14,14 @@ use safety::requires; use crate::convert::FloatToInt; -#[cfg(not(test))] -use crate::intrinsics; #[cfg(kani)] use crate::kani; -use crate::mem; use crate::num::FpCategory; use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; +use crate::{intrinsics, mem}; + /// Basic mathematical constants. #[unstable(feature = "f16", issue = "116909")] pub mod consts { @@ -138,7 +137,6 @@ pub mod consts { pub const LN_10: f16 = 2.30258509299404568401799145468436421_f16; } -#[cfg(not(test))] impl f16 { // FIXME(f16_f128): almost all methods in this `impl` are missing examples and a const // implementation. Add these once we can run code on all platforms and have f16/f128 in CTFE. diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 33b84535fb62a..39897fbf1da9c 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -14,15 +14,13 @@ use safety::requires; use crate::convert::FloatToInt; -#[cfg(not(test))] -use crate::intrinsics; #[cfg(kani)] use crate::kani; -use crate::mem; use crate::num::FpCategory; use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; +use crate::{intrinsics, mem}; /// The radix or base of the internal representation of `f32`. /// Use [`f32::RADIX`] instead. @@ -392,7 +390,6 @@ pub mod consts { pub const LN_10: f32 = 2.30258509299404568401799145468436421_f32; } -#[cfg(not(test))] impl f32 { /// The radix or base of the internal representation of `f32`. #[stable(feature = "assoc_int_consts", since = "1.43.0")] @@ -422,7 +419,7 @@ impl f32 { /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon /// [`MANTISSA_DIGITS`]: f32::MANTISSA_DIGITS #[stable(feature = "assoc_int_consts", since = "1.43.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "f32_epsilon")] + #[rustc_diagnostic_item = "f32_epsilon"] pub const EPSILON: f32 = 1.19209290e-07_f32; /// Smallest finite `f32` value. diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index 759869d1bb98d..f54ba1a0a6d9f 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -14,15 +14,13 @@ use safety::requires; use crate::convert::FloatToInt; -#[cfg(not(test))] -use crate::intrinsics; #[cfg(kani)] use crate::kani; -use crate::mem; use crate::num::FpCategory; use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; +use crate::{intrinsics, mem}; /// The radix or base of the internal representation of `f64`. /// Use [`f64::RADIX`] instead. @@ -392,7 +390,6 @@ pub mod consts { pub const LN_10: f64 = 2.30258509299404568401799145468436421_f64; } -#[cfg(not(test))] impl f64 { /// The radix or base of the internal representation of `f64`. #[stable(feature = "assoc_int_consts", since = "1.43.0")] @@ -421,7 +418,7 @@ impl f64 { /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon /// [`MANTISSA_DIGITS`]: f64::MANTISSA_DIGITS #[stable(feature = "assoc_int_consts", since = "1.43.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "f64_epsilon")] + #[rustc_diagnostic_item = "f64_epsilon"] pub const EPSILON: f64 = 2.2204460492503131e-16_f64; /// Smallest finite `f64` value. diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 62fc813e4d5eb..a95b1c4cf82de 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -2182,10 +2182,7 @@ macro_rules! int_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] -<<<<<<< HEAD #[ensures(|result| *result == self << (rhs & (Self::BITS - 1)))] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub const fn wrapping_shl(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds @@ -2215,10 +2212,7 @@ macro_rules! int_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] -<<<<<<< HEAD #[ensures(|result| *result == self >> (rhs & (Self::BITS - 1)))] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub const fn wrapping_shr(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index c99eb08ed1a0a..82cd3a12f4606 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -1606,7 +1606,6 @@ macro_rules! from_str_int_impl { from_str_int_impl! { signed isize i8 i16 i32 i64 i128 } from_str_int_impl! { unsigned usize u8 u16 u32 u64 u128 } -<<<<<<< HEAD #[cfg(kani)] #[unstable(feature = "kani", issue = "none")] @@ -2317,5 +2316,3 @@ mod verify { checked_f128_to_int_unchecked_usize ); } -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 761a29c20432e..3d4dc7b3748b3 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -2283,10 +2283,7 @@ macro_rules! uint_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] -<<<<<<< HEAD #[ensures(|result| *result == self << (rhs & (Self::BITS - 1)))] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub const fn wrapping_shl(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds @@ -2319,10 +2316,7 @@ macro_rules! uint_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] -<<<<<<< HEAD #[ensures(|result| *result == self >> (rhs & (Self::BITS - 1)))] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub const fn wrapping_shr(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds diff --git a/library/core/src/ops/control_flow.rs b/library/core/src/ops/control_flow.rs index 8993e14fcd379..0d910685927e0 100644 --- a/library/core/src/ops/control_flow.rs +++ b/library/core/src/ops/control_flow.rs @@ -79,7 +79,7 @@ use crate::{convert, ops}; /// [`Break`]: ControlFlow::Break /// [`Continue`]: ControlFlow::Continue #[stable(feature = "control_flow_enum_type", since = "1.55.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "ControlFlow")] +#[rustc_diagnostic_item = "ControlFlow"] // ControlFlow should not implement PartialOrd or Ord, per RFC 3058: // https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#traits-for-controlflow #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] diff --git a/library/core/src/option.rs b/library/core/src/option.rs index d74d8519ecb41..cbf46937f7991 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -924,7 +924,7 @@ impl Option { #[inline] #[track_caller] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "option_expect")] + #[rustc_diagnostic_item = "option_expect"] #[rustc_allow_const_fn_unstable(const_precise_live_drops)] #[rustc_const_stable(feature = "const_option", since = "1.83.0")] pub const fn expect(self, msg: &str) -> T { @@ -969,7 +969,7 @@ impl Option { #[inline(always)] #[track_caller] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "option_unwrap")] + #[rustc_diagnostic_item = "option_unwrap"] #[rustc_allow_const_fn_unstable(const_precise_live_drops)] #[rustc_const_stable(feature = "const_option", since = "1.83.0")] pub const fn unwrap(self) -> T { diff --git a/library/core/src/panic/unwind_safe.rs b/library/core/src/panic/unwind_safe.rs index 37859212c0ee3..a60f0799c0eae 100644 --- a/library/core/src/panic/unwind_safe.rs +++ b/library/core/src/panic/unwind_safe.rs @@ -82,7 +82,7 @@ use crate::task::{Context, Poll}; /// [`AssertUnwindSafe`] wrapper struct can be used to force this trait to be /// implemented for any closed over variables passed to `catch_unwind`. #[stable(feature = "catch_unwind", since = "1.9.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "unwind_safe_trait")] +#[rustc_diagnostic_item = "unwind_safe_trait"] #[diagnostic::on_unimplemented( message = "the type `{Self}` may not be safely transferred across an unwind boundary", label = "`{Self}` may not be safely transferred across an unwind boundary" @@ -98,7 +98,7 @@ pub auto trait UnwindSafe {} /// This is a "helper marker trait" used to provide impl blocks for the /// [`UnwindSafe`] trait, for more information see that documentation. #[stable(feature = "catch_unwind", since = "1.9.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "ref_unwind_safe_trait")] +#[rustc_diagnostic_item = "ref_unwind_safe_trait"] #[diagnostic::on_unimplemented( message = "the type `{Self}` may contain interior mutability and a reference may not be safely \ transferrable across a catch_unwind boundary", diff --git a/library/core/src/ptr/alignment.rs b/library/core/src/ptr/alignment.rs index f5b58bbb17242..c14c2b67c3ddf 100644 --- a/library/core/src/ptr/alignment.rs +++ b/library/core/src/ptr/alignment.rs @@ -50,11 +50,8 @@ impl Alignment { #[unstable(feature = "ptr_alignment_type", issue = "102070")] #[inline] #[must_use] -<<<<<<< HEAD #[requires(mem::align_of::().is_power_of_two())] #[ensures(|result| result.as_usize().is_power_of_two())] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub const fn of() -> Self { // This can't actually panic since type alignment is always a power of two. const { Alignment::new(align_of::()).unwrap() } diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 662896f1ba95a..8f7d644dbbf39 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -3,11 +3,8 @@ use safety::{ensures, requires}; use super::*; use crate::cmp::Ordering::{Equal, Greater, Less}; use crate::intrinsics::const_eval_select; -<<<<<<< HEAD #[cfg(kani)] use crate::kani; -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 use crate::mem::{self, SizedTypeProperties}; use crate::slice::{self, SliceIndex}; @@ -200,7 +197,6 @@ impl *const T { /// This is an [Exposed Provenance][crate::ptr#exposed-provenance] API. /// /// [`with_exposed_provenance`]: with_exposed_provenance - #[must_use] #[inline(always)] #[stable(feature = "exposed_provenance", since = "1.84.0")] pub fn expose_provenance(self) -> usize { diff --git a/library/core/src/ptr/metadata.rs b/library/core/src/ptr/metadata.rs index 4870750638957..9c5da306e27a7 100644 --- a/library/core/src/ptr/metadata.rs +++ b/library/core/src/ptr/metadata.rs @@ -61,6 +61,8 @@ pub trait Pointee { // NOTE: Keep trait bounds in `static_assert_expected_bounds_for_metadata` // in `library/core/src/ptr/metadata.rs` // in sync with those here: + // NOTE: The metadata of `dyn Trait + 'a` is `DynMetadata` + // so a `'static` bound must not be added. type Metadata: fmt::Debug + Copy + Send + Sync + Ord + Hash + Unpin + Freeze; } diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index a7bacba3abfb3..f541c2df33b3a 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -396,11 +396,8 @@ use crate::cmp::Ordering; use crate::intrinsics::const_eval_select; -<<<<<<< HEAD #[cfg(kani)] use crate::kani; -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 use crate::marker::FnPtr; use crate::mem::{self, MaybeUninit, SizedTypeProperties}; use crate::{fmt, hash, intrinsics, ub_checks}; diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 29fc916ad043d..1791f912db8ab 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -3,11 +3,8 @@ use safety::{ensures, requires}; use super::*; use crate::cmp::Ordering::{Equal, Greater, Less}; use crate::intrinsics::const_eval_select; -<<<<<<< HEAD #[cfg(kani)] use crate::kani; -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 use crate::mem::{self, SizedTypeProperties}; use crate::slice::{self, SliceIndex}; diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 3913af323eb87..5938f4cca1bab 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -332,10 +332,7 @@ impl NonNull { #[must_use] #[inline] #[stable(feature = "strict_provenance", since = "1.84.0")] -<<<<<<< HEAD #[ensures(|result| result.get() == self.as_ptr() as *const() as usize)] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub fn addr(self) -> NonZero { // SAFETY: The pointer is guaranteed by the type to be non-null, // meaning that the address will be non-zero. @@ -364,10 +361,7 @@ impl NonNull { #[must_use] #[inline] #[stable(feature = "strict_provenance", since = "1.84.0")] -<<<<<<< HEAD #[ensures(|result: &Self| !result.as_ptr().is_null() && result.addr() == addr)] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub fn with_addr(self, addr: NonZero) -> Self { // SAFETY: The result of `ptr::from::with_addr` is non-null because `addr` is guaranteed to be non-zero. unsafe { NonNull::new_unchecked(self.as_ptr().with_addr(addr.get()) as *mut _) } @@ -382,10 +376,7 @@ impl NonNull { #[must_use] #[inline] #[stable(feature = "strict_provenance", since = "1.84.0")] -<<<<<<< HEAD #[ensures(|result: &Self| !result.as_ptr().is_null())] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub fn map_addr(self, f: impl FnOnce(NonZero) -> NonZero) -> Self { self.with_addr(f(self.addr())) } @@ -745,15 +736,12 @@ impl NonNull { #[must_use = "returns a new pointer rather than modifying its argument"] #[stable(feature = "non_null_convenience", since = "1.80.0")] #[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")] -<<<<<<< HEAD #[requires( count.checked_mul(core::mem::size_of::()).is_some() && count * core::mem::size_of::() <= isize::MAX as usize && core::ub_checks::same_allocation(self.as_ptr(), self.as_ptr().wrapping_sub(count)) )] #[ensures(|result: &NonNull| result.as_ptr() == self.as_ptr().offset(-(count as isize)))] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub const unsafe fn sub(self, count: usize) -> Self where T: Sized, @@ -996,7 +984,6 @@ impl NonNull { #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] -<<<<<<< HEAD #[requires( self.as_ptr().addr().checked_sub(subtracted.as_ptr().addr()).is_some() && core::ub_checks::same_allocation(self.as_ptr(), subtracted.as_ptr()) && @@ -1004,8 +991,6 @@ impl NonNull { (self.as_ptr().addr() - subtracted.as_ptr().addr()) % core::mem::size_of::() == 0 )] #[ensures(|result: &usize| *result == self.as_ptr().offset_from(subtracted.as_ptr()) as usize)] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub const unsafe fn offset_from_unsigned(self, subtracted: NonNull) -> usize where T: Sized, @@ -1324,12 +1309,9 @@ impl NonNull { #[inline(always)] #[stable(feature = "non_null_convenience", since = "1.80.0")] #[rustc_const_stable(feature = "const_swap", since = "1.85.0")] -<<<<<<< HEAD #[cfg_attr(kani, kani::modifies(self.as_ptr(), with.as_ptr()))] #[requires(ub_checks::can_dereference(self.as_ptr()) && ub_checks::can_write(self.as_ptr()))] #[requires(ub_checks::can_dereference(with.as_ptr()) && ub_checks::can_write(with.as_ptr()))] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub const unsafe fn swap(self, with: NonNull) where T: Sized, diff --git a/library/core/src/ptr/unique.rs b/library/core/src/ptr/unique.rs index 81bf727ecd6db..a0fdfbfef3d96 100644 --- a/library/core/src/ptr/unique.rs +++ b/library/core/src/ptr/unique.rs @@ -98,11 +98,8 @@ impl Unique { /// Creates a new `Unique` if `ptr` is non-null. #[inline] -<<<<<<< HEAD #[ensures(|result| result.is_none() == ptr.is_null())] #[ensures(|result| result.is_none() || result.unwrap().as_ptr() == ptr)] -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 pub const fn new(ptr: *mut T) -> Option { if let Some(pointer) = NonNull::new(ptr) { Some(Unique { pointer, _marker: PhantomData }) diff --git a/library/core/src/result.rs b/library/core/src/result.rs index ee98a47523fef..48ab9267f216c 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -654,7 +654,7 @@ impl Result { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "result_ok_method")] + #[rustc_diagnostic_item = "result_ok_method"] pub fn ok(self) -> Option { match self { Ok(x) => Some(x), diff --git a/library/core/src/slice/ascii.rs b/library/core/src/slice/ascii.rs index ded9a54f4498e..b14348ba986ab 100644 --- a/library/core/src/slice/ascii.rs +++ b/library/core/src/slice/ascii.rs @@ -5,14 +5,10 @@ use core::ascii::EscapeDefault; use crate::fmt::{self, Write}; #[cfg(not(all(target_arch = "x86_64", target_feature = "sse2")))] use crate::intrinsics::const_eval_select; -<<<<<<< HEAD #[cfg(kani)] use crate::kani; -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 use crate::{ascii, iter, ops}; -#[cfg(not(test))] impl [u8] { /// Checks if all bytes in this slice are within the ASCII range. #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] @@ -510,7 +506,6 @@ const fn is_ascii(bytes: &[u8]) -> bool { is_ascii } -<<<<<<< HEAD #[cfg(kani)] #[unstable(feature = "kani", issue = "none")] @@ -536,5 +531,3 @@ pub mod verify { } } } -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 diff --git a/library/core/src/slice/cmp.rs b/library/core/src/slice/cmp.rs index 804bdfcbb4fc7..da85f42926e6b 100644 --- a/library/core/src/slice/cmp.rs +++ b/library/core/src/slice/cmp.rs @@ -282,4 +282,4 @@ macro_rules! impl_slice_contains { }; } -impl_slice_contains!(u16, u32, u64, i16, i32, i64, f32, f64, usize, isize); +impl_slice_contains!(u16, u32, u64, i16, i32, i64, f32, f64, usize, isize, char); diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 3570d8d087660..2c699ee9fdd4c 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -97,7 +97,6 @@ enum Direction { Back, } -#[cfg(not(test))] impl [T] { /// Returns the number of elements in the slice. /// @@ -1045,7 +1044,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - #[cfg_attr(not(test), rustc_diagnostic_item = "slice_iter")] + #[rustc_diagnostic_item = "slice_iter"] pub fn iter(&self) -> Iter<'_, T> { Iter::new(self) } @@ -4844,7 +4843,6 @@ impl [[T; N]] { } } -#[cfg(not(test))] impl [f32] { /// Sorts the slice of floats. /// @@ -4873,7 +4871,6 @@ impl [f32] { } } -#[cfg(not(test))] impl [f64] { /// Sorts the slice of floats. /// diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 83ad10db2da45..5cc08f8a71afb 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -114,7 +114,6 @@ fn slice_error_fail_rt(s: &str, begin: usize, end: usize) -> ! { ); } -#[cfg(not(test))] impl str { /// Returns the length of `self`. /// @@ -134,7 +133,7 @@ impl str { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_str_len", since = "1.39.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "str_len")] + #[rustc_diagnostic_item = "str_len"] #[must_use] #[inline] pub const fn len(&self) -> usize { @@ -1029,7 +1028,7 @@ impl str { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - #[cfg_attr(not(test), rustc_diagnostic_item = "str_chars")] + #[rustc_diagnostic_item = "str_chars"] pub fn chars(&self) -> Chars<'_> { Chars { iter: self.as_bytes().iter() } } @@ -1160,7 +1159,7 @@ impl str { #[must_use = "this returns the split string as an iterator, \ without modifying the original"] #[stable(feature = "split_whitespace", since = "1.1.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "str_split_whitespace")] + #[rustc_diagnostic_item = "str_split_whitespace"] #[inline] pub fn split_whitespace(&self) -> SplitWhitespace<'_> { SplitWhitespace { inner: self.split(IsWhitespace).filter(IsNotEmpty) } @@ -1355,7 +1354,7 @@ impl str { /// assert!(bananas.starts_with(&['a', 'b', 'c', 'd'])); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "str_starts_with")] + #[rustc_diagnostic_item = "str_starts_with"] pub fn starts_with(&self, pat: P) -> bool { pat.is_prefix_of(self) } @@ -1380,7 +1379,7 @@ impl str { /// assert!(!bananas.ends_with("nana")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "str_ends_with")] + #[rustc_diagnostic_item = "str_ends_with"] pub fn ends_with(&self, pat: P) -> bool where for<'a> P::Searcher<'a>: ReverseSearcher<'a>, @@ -2114,7 +2113,7 @@ impl str { #[must_use = "this returns the trimmed string as a slice, \ without modifying the original"] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "str_trim")] + #[rustc_diagnostic_item = "str_trim"] pub fn trim(&self) -> &str { self.trim_matches(|c: char| c.is_whitespace()) } @@ -2153,7 +2152,7 @@ impl str { #[must_use = "this returns the trimmed string as a new slice, \ without modifying the original"] #[stable(feature = "trim_direction", since = "1.30.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "str_trim_start")] + #[rustc_diagnostic_item = "str_trim_start"] pub fn trim_start(&self) -> &str { self.trim_start_matches(|c: char| c.is_whitespace()) } @@ -2192,7 +2191,7 @@ impl str { #[must_use = "this returns the trimmed string as a new slice, \ without modifying the original"] #[stable(feature = "trim_direction", since = "1.30.0")] - #[cfg_attr(not(test), rustc_diagnostic_item = "str_trim_end")] + #[rustc_diagnostic_item = "str_trim_end"] pub fn trim_end(&self) -> &str { self.trim_end_matches(|c: char| c.is_whitespace()) } diff --git a/library/core/src/str/pattern.rs b/library/core/src/str/pattern.rs index ede320ee73f3d..a85bc95e73d3c 100644 --- a/library/core/src/str/pattern.rs +++ b/library/core/src/str/pattern.rs @@ -38,12 +38,9 @@ issue = "27721" )] -<<<<<<< HEAD #[cfg(all(target_arch = "x86_64", any(kani, target_feature = "sse2")))] use safety::{loop_invariant, requires}; -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 use crate::char::MAX_LEN_UTF8; use crate::cmp::Ordering; use crate::convert::TryInto as _; @@ -652,21 +649,21 @@ where impl MultiCharEq for [char; N] { #[inline] fn matches(&mut self, c: char) -> bool { - self.iter().any(|&m| m == c) + self.contains(&c) } } impl MultiCharEq for &[char; N] { #[inline] fn matches(&mut self, c: char) -> bool { - self.iter().any(|&m| m == c) + self.contains(&c) } } impl MultiCharEq for &[char] { #[inline] fn matches(&mut self, c: char) -> bool { - self.iter().any(|&m| m == c) + self.contains(&c) } } diff --git a/library/core/src/str/validations.rs b/library/core/src/str/validations.rs index 72eb9ff0b87f3..c5a3fdf360674 100644 --- a/library/core/src/str/validations.rs +++ b/library/core/src/str/validations.rs @@ -2,11 +2,8 @@ use super::Utf8Error; use crate::intrinsics::const_eval_select; -<<<<<<< HEAD #[cfg(kani)] use crate::kani; -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 /// Returns the initial codepoint accumulator for the first byte. /// The first byte is special, only want bottom 5 bits for width 2, 4 bits diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 54a65c8459e96..88bee62203101 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -295,7 +295,7 @@ unsafe impl Sync for AtomicBool {} /// loads and stores of pointers. Its size depends on the target pointer's size. #[cfg(target_has_atomic_load_store = "ptr")] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "AtomicPtr")] +#[rustc_diagnostic_item = "AtomicPtr"] #[cfg_attr(target_pointer_width = "16", repr(C, align(2)))] #[cfg_attr(target_pointer_width = "32", repr(C, align(4)))] #[cfg_attr(target_pointer_width = "64", repr(C, align(8)))] @@ -3446,7 +3446,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicI8"), + rustc_diagnostic_item = "AtomicI8", "i8", "", atomic_min, atomic_max, @@ -3465,7 +3465,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicU8"), + rustc_diagnostic_item = "AtomicU8", "u8", "", atomic_umin, atomic_umax, @@ -3484,7 +3484,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicI16"), + rustc_diagnostic_item = "AtomicI16", "i16", "", atomic_min, atomic_max, @@ -3503,7 +3503,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicU16"), + rustc_diagnostic_item = "AtomicU16", "u16", "", atomic_umin, atomic_umax, @@ -3522,7 +3522,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicI32"), + rustc_diagnostic_item = "AtomicI32", "i32", "", atomic_min, atomic_max, @@ -3541,7 +3541,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicU32"), + rustc_diagnostic_item = "AtomicU32", "u32", "", atomic_umin, atomic_umax, @@ -3560,7 +3560,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicI64"), + rustc_diagnostic_item = "AtomicI64", "i64", "", atomic_min, atomic_max, @@ -3579,7 +3579,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicU64"), + rustc_diagnostic_item = "AtomicU64", "u64", "", atomic_umin, atomic_umax, @@ -3598,7 +3598,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicI128"), + rustc_diagnostic_item = "AtomicI128", "i128", "#![feature(integer_atomics)]\n\n", atomic_min, atomic_max, @@ -3617,7 +3617,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicU128"), + rustc_diagnostic_item = "AtomicU128", "u128", "#![feature(integer_atomics)]\n\n", atomic_umin, atomic_umax, @@ -3640,7 +3640,7 @@ macro_rules! atomic_int_ptr_sized { stable(feature = "atomic_nand", since = "1.27.0"), rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicIsize"), + rustc_diagnostic_item = "AtomicIsize", "isize", "", atomic_min, atomic_max, @@ -3659,7 +3659,7 @@ macro_rules! atomic_int_ptr_sized { stable(feature = "atomic_nand", since = "1.27.0"), rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicUsize"), + rustc_diagnostic_item = "AtomicUsize", "usize", "", atomic_umin, atomic_umax, diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 3f57b04753a6b..9b8fefe42af60 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -402,7 +402,7 @@ impl<'a> ContextBuilder<'a> { /// [`Wake`]: ../../alloc/task/trait.Wake.html #[repr(transparent)] #[stable(feature = "futures_api", since = "1.36.0")] -#[cfg_attr(not(test), rustc_diagnostic_item = "Waker")] +#[rustc_diagnostic_item = "Waker"] pub struct Waker { waker: RawWaker, } diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 35666e08c81c1..c0d67cc51edf5 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -23,11 +23,8 @@ use safety::{Invariant, ensures}; use crate::fmt; use crate::iter::Sum; -<<<<<<< HEAD #[cfg(kani)] use crate::kani; -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 use crate::num::niche_types::Nanoseconds; use crate::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; use crate::ub_checks::Invariant; @@ -46,7 +43,6 @@ const HOURS_PER_DAY: u64 = 24; #[unstable(feature = "duration_units", issue = "120301")] const DAYS_PER_WEEK: u64 = 7; -<<<<<<< HEAD #[unstable(feature = "ub_checks", issue = "none")] impl Invariant for Nanoseconds { fn is_safe(&self) -> bool { @@ -54,8 +50,6 @@ impl Invariant for Nanoseconds { } } -======= ->>>>>>> fdc0067d05b875da82a5bed4bd364df0b4fde980 /// A `Duration` type to represent a span of time, typically used for system /// timeouts. /// @@ -95,7 +89,7 @@ impl Invariant for Nanoseconds { /// crate to do so. #[stable(feature = "duration", since = "1.3.0")] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[cfg_attr(not(test), rustc_diagnostic_item = "Duration")] +#[rustc_diagnostic_item = "Duration"] #[derive(Invariant)] pub struct Duration { secs: u64, diff --git a/library/core/src/unit.rs b/library/core/src/unit.rs index d656005f3d42d..d54816c444bc4 100644 --- a/library/core/src/unit.rs +++ b/library/core/src/unit.rs @@ -17,3 +17,19 @@ impl FromIterator<()> for () { iter.into_iter().for_each(|()| {}) } } + +pub(crate) trait IsUnit { + fn is_unit() -> bool; +} + +impl IsUnit for T { + default fn is_unit() -> bool { + false + } +} + +impl IsUnit for () { + fn is_unit() -> bool { + true + } +} diff --git a/library/coretests/Cargo.toml b/library/coretests/Cargo.toml index e44f01d347b3d..88a7e159c956b 100644 --- a/library/coretests/Cargo.toml +++ b/library/coretests/Cargo.toml @@ -25,3 +25,4 @@ test = true [dev-dependencies] rand = { version = "0.9.0", default-features = false } rand_xorshift = { version = "0.4.0", default-features = false } +regex = { version = "1.11.1", default-features = false } diff --git a/library/coretests/tests/fmt/mod.rs b/library/coretests/tests/fmt/mod.rs index 025c69c4f6236..cb185dae9de35 100644 --- a/library/coretests/tests/fmt/mod.rs +++ b/library/coretests/tests/fmt/mod.rs @@ -15,8 +15,39 @@ fn test_format_flags() { fn test_pointer_formats_data_pointer() { let b: &[u8] = b""; let s: &str = ""; - assert_eq!(format!("{s:p}"), format!("{:p}", s.as_ptr())); - assert_eq!(format!("{b:p}"), format!("{:p}", b.as_ptr())); + assert_eq!(format!("{s:p}"), format!("{:p}", s as *const _)); + assert_eq!(format!("{b:p}"), format!("{:p}", b as *const _)); +} + +#[test] +fn test_fmt_debug_of_raw_pointers() { + use core::fmt::Debug; + + fn check_fmt(t: T, expected: &str) { + use std::sync::LazyLock; + + use regex::Regex; + + static ADDR_REGEX: LazyLock = + LazyLock::new(|| Regex::new(r"0x[0-9a-fA-F]+").unwrap()); + + let formatted = format!("{:?}", t); + let normalized = ADDR_REGEX.replace_all(&formatted, "$$HEX"); + + assert_eq!(normalized, expected); + } + + let plain = &mut 100; + check_fmt(plain as *mut i32, "$HEX"); + check_fmt(plain as *const i32, "$HEX"); + + let slice = &mut [200, 300, 400][..]; + check_fmt(slice as *mut [i32], "Pointer { addr: $HEX, metadata: 3 }"); + check_fmt(slice as *const [i32], "Pointer { addr: $HEX, metadata: 3 }"); + + let vtable = &mut 500 as &mut dyn Debug; + check_fmt(vtable as *mut dyn Debug, "Pointer { addr: $HEX, metadata: DynMetadata($HEX) }"); + check_fmt(vtable as *const dyn Debug, "Pointer { addr: $HEX, metadata: DynMetadata($HEX) }"); } #[test] diff --git a/library/panic_abort/Cargo.toml b/library/panic_abort/Cargo.toml index a9d1f53761cbf..6f43ac4809a32 100644 --- a/library/panic_abort/Cargo.toml +++ b/library/panic_abort/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/rust.git" description = "Implementation of Rust panics via process aborts" -edition = "2021" +edition = "2024" [lib] test = false diff --git a/library/panic_unwind/Cargo.toml b/library/panic_unwind/Cargo.toml index c2abb79192e9f..d176434e06ba1 100644 --- a/library/panic_unwind/Cargo.toml +++ b/library/panic_unwind/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/rust.git" description = "Implementation of Rust panics via stack unwinding" -edition = "2021" +edition = "2024" [lib] test = false diff --git a/library/proc_macro/Cargo.toml b/library/proc_macro/Cargo.toml index e54a50aa15c61..72cb4e4166f8e 100644 --- a/library/proc_macro/Cargo.toml +++ b/library/proc_macro/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "proc_macro" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] std = { path = "../std" } diff --git a/library/profiler_builtins/Cargo.toml b/library/profiler_builtins/Cargo.toml index 230e8051602e4..e075a38daea11 100644 --- a/library/profiler_builtins/Cargo.toml +++ b/library/profiler_builtins/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "profiler_builtins" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] test = false diff --git a/library/rustc-std-workspace-alloc/Cargo.toml b/library/rustc-std-workspace-alloc/Cargo.toml index 049ca3e46b57d..5a177808d1bd8 100644 --- a/library/rustc-std-workspace-alloc/Cargo.toml +++ b/library/rustc-std-workspace-alloc/Cargo.toml @@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0' description = """ Hack for the compiler's own build system """ -edition = "2021" +edition = "2024" [lib] path = "lib.rs" diff --git a/library/rustc-std-workspace-core/Cargo.toml b/library/rustc-std-workspace-core/Cargo.toml index ff5cfcbd64144..9315c08a4d199 100644 --- a/library/rustc-std-workspace-core/Cargo.toml +++ b/library/rustc-std-workspace-core/Cargo.toml @@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0' description = """ Hack for the compiler's own build system """ -edition = "2021" +edition = "2024" [lib] path = "lib.rs" diff --git a/library/rustc-std-workspace-std/Cargo.toml b/library/rustc-std-workspace-std/Cargo.toml index 3a1dc2a02b557..f70994e1f8868 100644 --- a/library/rustc-std-workspace-std/Cargo.toml +++ b/library/rustc-std-workspace-std/Cargo.toml @@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0' description = """ Hack for the compiler's own build system """ -edition = "2021" +edition = "2024" [lib] path = "lib.rs" diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 79001a1969e48..56e98850e1208 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -6,7 +6,7 @@ version = "0.0.0" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/rust.git" description = "The Rust Standard Library" -edition = "2021" +edition = "2024" autobenches = false [lib] @@ -36,7 +36,7 @@ miniz_oxide = { version = "0.8.0", optional = true, default-features = false } addr2line = { version = "0.24.0", optional = true, default-features = false } [target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies] -libc = { version = "0.2.170", default-features = false, features = [ +libc = { version = "0.2.171", default-features = false, features = [ 'rustc-dep-of-std', ], public = true } diff --git a/library/std/build.rs b/library/std/build.rs index cedfd7406a1aa..a0cfbc4685ee5 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -42,6 +42,7 @@ fn main() { || target_os == "fuchsia" || (target_vendor == "fortanix" && target_env == "sgx") || target_os == "hermit" + || target_os == "trusty" || target_os == "l4re" || target_os == "redox" || target_os == "haiku" diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index ff4a4b35ce450..2487f5a2a503f 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -208,20 +208,32 @@ use crate::ops::Index; /// # Usage in `const` and `static` /// /// As explained above, `HashMap` is randomly seeded: each `HashMap` instance uses a different seed, -/// which means that `HashMap::new` cannot be used in const context. To construct a `HashMap` in the -/// initializer of a `const` or `static` item, you will have to use a different hasher that does not -/// involve a random seed, as demonstrated in the following example. **A `HashMap` constructed this -/// way is not resistant against HashDoS!** +/// which means that `HashMap::new` normally cannot be used in a `const` or `static` initializer. /// +/// However, if you need to use a `HashMap` in a `const` or `static` initializer while retaining +/// random seed generation, you can wrap the `HashMap` in [`LazyLock`]. +/// +/// Alternatively, you can construct a `HashMap` in a `const` or `static` initializer using a different +/// hasher that does not rely on a random seed. **Be aware that a `HashMap` created this way is not +/// resistant to HashDoS attacks!** +/// +/// [`LazyLock`]: crate::sync::LazyLock /// ```rust /// use std::collections::HashMap; /// use std::hash::{BuildHasherDefault, DefaultHasher}; -/// use std::sync::Mutex; +/// use std::sync::{LazyLock, Mutex}; /// -/// const EMPTY_MAP: HashMap, BuildHasherDefault> = +/// // HashMaps with a fixed, non-random hasher +/// const NONRANDOM_EMPTY_MAP: HashMap, BuildHasherDefault> = /// HashMap::with_hasher(BuildHasherDefault::new()); -/// static MAP: Mutex, BuildHasherDefault>> = +/// static NONRANDOM_MAP: Mutex, BuildHasherDefault>> = /// Mutex::new(HashMap::with_hasher(BuildHasherDefault::new())); +/// +/// // HashMaps using LazyLock to retain random seeding +/// const RANDOM_EMPTY_MAP: LazyLock>> = +/// LazyLock::new(HashMap::new); +/// static RANDOM_MAP: LazyLock>>> = +/// LazyLock::new(|| Mutex::new(HashMap::new())); /// ``` #[cfg_attr(not(test), rustc_diagnostic_item = "HashMap")] @@ -1278,69 +1290,6 @@ where } } -impl HashMap -where - S: BuildHasher, -{ - /// Creates a raw entry builder for the `HashMap`. - /// - /// Raw entries provide the lowest level of control for searching and - /// manipulating a map. They must be manually initialized with a hash and - /// then manually searched. After this, insertions into a vacant entry - /// still require an owned key to be provided. - /// - /// Raw entries are useful for such exotic situations as: - /// - /// * Hash memoization - /// * Deferring the creation of an owned key until it is known to be required - /// * Using a search key that doesn't work with the Borrow trait - /// * Using custom comparison logic without newtype wrappers - /// - /// Because raw entries provide much more low-level control, it's much easier - /// to put the `HashMap` into an inconsistent state which, while memory-safe, - /// will cause the map to produce seemingly random results. Higher-level and - /// more foolproof APIs like `entry` should be preferred when possible. - /// - /// In particular, the hash used to initialize the raw entry must still be - /// consistent with the hash of the key that is ultimately stored in the entry. - /// This is because implementations of `HashMap` may need to recompute hashes - /// when resizing, at which point only the keys are available. - /// - /// Raw entries give mutable access to the keys. This must not be used - /// to modify how the key would compare or hash, as the map will not re-evaluate - /// where the key should go, meaning the keys may become "lost" if their - /// location does not reflect their state. For instance, if you change a key - /// so that the map now contains keys which compare equal, search may start - /// acting erratically, with two keys randomly masking each other. Implementations - /// are free to assume this doesn't happen (within the limits of memory-safety). - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S> { - RawEntryBuilderMut { map: self } - } - - /// Creates a raw immutable entry builder for the `HashMap`. - /// - /// Raw entries provide the lowest level of control for searching and - /// manipulating a map. They must be manually initialized with a hash and - /// then manually searched. - /// - /// This is useful for - /// * Hash memoization - /// * Using a search key that doesn't work with the Borrow trait - /// * Using custom comparison logic without newtype wrappers - /// - /// Unless you are in such a situation, higher-level and more foolproof APIs like - /// `get` should be preferred. - /// - /// Immutable raw entries have very limited use; you might instead want `raw_entry_mut`. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S> { - RawEntryBuilder { map: self } - } -} - #[stable(feature = "rust1", since = "1.0.0")] impl Clone for HashMap where @@ -1828,404 +1777,6 @@ impl Default for IntoValues { } } -/// A builder for computing where in a HashMap a key-value pair would be stored. -/// -/// See the [`HashMap::raw_entry_mut`] docs for usage examples. -#[unstable(feature = "hash_raw_entry", issue = "56167")] -pub struct RawEntryBuilderMut<'a, K: 'a, V: 'a, S: 'a> { - map: &'a mut HashMap, -} - -/// A view into a single entry in a map, which may either be vacant or occupied. -/// -/// This is a lower-level version of [`Entry`]. -/// -/// This `enum` is constructed through the [`raw_entry_mut`] method on [`HashMap`], -/// then calling one of the methods of that [`RawEntryBuilderMut`]. -/// -/// [`raw_entry_mut`]: HashMap::raw_entry_mut -#[unstable(feature = "hash_raw_entry", issue = "56167")] -pub enum RawEntryMut<'a, K: 'a, V: 'a, S: 'a> { - /// An occupied entry. - Occupied(RawOccupiedEntryMut<'a, K, V, S>), - /// A vacant entry. - Vacant(RawVacantEntryMut<'a, K, V, S>), -} - -/// A view into an occupied entry in a `HashMap`. -/// It is part of the [`RawEntryMut`] enum. -#[unstable(feature = "hash_raw_entry", issue = "56167")] -pub struct RawOccupiedEntryMut<'a, K: 'a, V: 'a, S: 'a> { - base: base::RawOccupiedEntryMut<'a, K, V, S>, -} - -/// A view into a vacant entry in a `HashMap`. -/// It is part of the [`RawEntryMut`] enum. -#[unstable(feature = "hash_raw_entry", issue = "56167")] -pub struct RawVacantEntryMut<'a, K: 'a, V: 'a, S: 'a> { - base: base::RawVacantEntryMut<'a, K, V, S>, -} - -/// A builder for computing where in a HashMap a key-value pair would be stored. -/// -/// See the [`HashMap::raw_entry`] docs for usage examples. -#[unstable(feature = "hash_raw_entry", issue = "56167")] -pub struct RawEntryBuilder<'a, K: 'a, V: 'a, S: 'a> { - map: &'a HashMap, -} - -impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S> -where - S: BuildHasher, -{ - /// Creates a `RawEntryMut` from the given key. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn from_key(self, k: &Q) -> RawEntryMut<'a, K, V, S> - where - K: Borrow, - Q: Hash + Eq, - { - map_raw_entry(self.map.base.raw_entry_mut().from_key(k)) - } - - /// Creates a `RawEntryMut` from the given key and its hash. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn from_key_hashed_nocheck(self, hash: u64, k: &Q) -> RawEntryMut<'a, K, V, S> - where - K: Borrow, - Q: Eq, - { - map_raw_entry(self.map.base.raw_entry_mut().from_key_hashed_nocheck(hash, k)) - } - - /// Creates a `RawEntryMut` from the given hash. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn from_hash(self, hash: u64, is_match: F) -> RawEntryMut<'a, K, V, S> - where - for<'b> F: FnMut(&'b K) -> bool, - { - map_raw_entry(self.map.base.raw_entry_mut().from_hash(hash, is_match)) - } -} - -impl<'a, K, V, S> RawEntryBuilder<'a, K, V, S> -where - S: BuildHasher, -{ - /// Access an entry by key. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn from_key(self, k: &Q) -> Option<(&'a K, &'a V)> - where - K: Borrow, - Q: Hash + Eq, - { - self.map.base.raw_entry().from_key(k) - } - - /// Access an entry by a key and its hash. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn from_key_hashed_nocheck(self, hash: u64, k: &Q) -> Option<(&'a K, &'a V)> - where - K: Borrow, - Q: Hash + Eq, - { - self.map.base.raw_entry().from_key_hashed_nocheck(hash, k) - } - - /// Access an entry by hash. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn from_hash(self, hash: u64, is_match: F) -> Option<(&'a K, &'a V)> - where - F: FnMut(&K) -> bool, - { - self.map.base.raw_entry().from_hash(hash, is_match) - } -} - -impl<'a, K, V, S> RawEntryMut<'a, K, V, S> { - /// Ensures a value is in the entry by inserting the default if empty, and returns - /// mutable references to the key and value in the entry. - /// - /// # Examples - /// - /// ``` - /// #![feature(hash_raw_entry)] - /// use std::collections::HashMap; - /// - /// let mut map: HashMap<&str, u32> = HashMap::new(); - /// - /// map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 3); - /// assert_eq!(map["poneyland"], 3); - /// - /// *map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 10).1 *= 2; - /// assert_eq!(map["poneyland"], 6); - /// ``` - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn or_insert(self, default_key: K, default_val: V) -> (&'a mut K, &'a mut V) - where - K: Hash, - S: BuildHasher, - { - match self { - RawEntryMut::Occupied(entry) => entry.into_key_value(), - RawEntryMut::Vacant(entry) => entry.insert(default_key, default_val), - } - } - - /// Ensures a value is in the entry by inserting the result of the default function if empty, - /// and returns mutable references to the key and value in the entry. - /// - /// # Examples - /// - /// ``` - /// #![feature(hash_raw_entry)] - /// use std::collections::HashMap; - /// - /// let mut map: HashMap<&str, String> = HashMap::new(); - /// - /// map.raw_entry_mut().from_key("poneyland").or_insert_with(|| { - /// ("poneyland", "hoho".to_string()) - /// }); - /// - /// assert_eq!(map["poneyland"], "hoho".to_string()); - /// ``` - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn or_insert_with(self, default: F) -> (&'a mut K, &'a mut V) - where - F: FnOnce() -> (K, V), - K: Hash, - S: BuildHasher, - { - match self { - RawEntryMut::Occupied(entry) => entry.into_key_value(), - RawEntryMut::Vacant(entry) => { - let (k, v) = default(); - entry.insert(k, v) - } - } - } - - /// Provides in-place mutable access to an occupied entry before any - /// potential inserts into the map. - /// - /// # Examples - /// - /// ``` - /// #![feature(hash_raw_entry)] - /// use std::collections::HashMap; - /// - /// let mut map: HashMap<&str, u32> = HashMap::new(); - /// - /// map.raw_entry_mut() - /// .from_key("poneyland") - /// .and_modify(|_k, v| { *v += 1 }) - /// .or_insert("poneyland", 42); - /// assert_eq!(map["poneyland"], 42); - /// - /// map.raw_entry_mut() - /// .from_key("poneyland") - /// .and_modify(|_k, v| { *v += 1 }) - /// .or_insert("poneyland", 0); - /// assert_eq!(map["poneyland"], 43); - /// ``` - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn and_modify(self, f: F) -> Self - where - F: FnOnce(&mut K, &mut V), - { - match self { - RawEntryMut::Occupied(mut entry) => { - { - let (k, v) = entry.get_key_value_mut(); - f(k, v); - } - RawEntryMut::Occupied(entry) - } - RawEntryMut::Vacant(entry) => RawEntryMut::Vacant(entry), - } - } -} - -impl<'a, K, V, S> RawOccupiedEntryMut<'a, K, V, S> { - /// Gets a reference to the key in the entry. - #[inline] - #[must_use] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn key(&self) -> &K { - self.base.key() - } - - /// Gets a mutable reference to the key in the entry. - #[inline] - #[must_use] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn key_mut(&mut self) -> &mut K { - self.base.key_mut() - } - - /// Converts the entry into a mutable reference to the key in the entry - /// with a lifetime bound to the map itself. - #[inline] - #[must_use = "`self` will be dropped if the result is not used"] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn into_key(self) -> &'a mut K { - self.base.into_key() - } - - /// Gets a reference to the value in the entry. - #[inline] - #[must_use] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn get(&self) -> &V { - self.base.get() - } - - /// Converts the `OccupiedEntry` into a mutable reference to the value in the entry - /// with a lifetime bound to the map itself. - #[inline] - #[must_use = "`self` will be dropped if the result is not used"] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn into_mut(self) -> &'a mut V { - self.base.into_mut() - } - - /// Gets a mutable reference to the value in the entry. - #[inline] - #[must_use] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn get_mut(&mut self) -> &mut V { - self.base.get_mut() - } - - /// Gets a reference to the key and value in the entry. - #[inline] - #[must_use] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn get_key_value(&mut self) -> (&K, &V) { - self.base.get_key_value() - } - - /// Gets a mutable reference to the key and value in the entry. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn get_key_value_mut(&mut self) -> (&mut K, &mut V) { - self.base.get_key_value_mut() - } - - /// Converts the `OccupiedEntry` into a mutable reference to the key and value in the entry - /// with a lifetime bound to the map itself. - #[inline] - #[must_use = "`self` will be dropped if the result is not used"] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn into_key_value(self) -> (&'a mut K, &'a mut V) { - self.base.into_key_value() - } - - /// Sets the value of the entry, and returns the entry's old value. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn insert(&mut self, value: V) -> V { - self.base.insert(value) - } - - /// Sets the value of the entry, and returns the entry's old value. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn insert_key(&mut self, key: K) -> K { - self.base.insert_key(key) - } - - /// Takes the value out of the entry, and returns it. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn remove(self) -> V { - self.base.remove() - } - - /// Take the ownership of the key and value from the map. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn remove_entry(self) -> (K, V) { - self.base.remove_entry() - } -} - -impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> { - /// Sets the value of the entry with the `VacantEntry`'s key, - /// and returns a mutable reference to it. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn insert(self, key: K, value: V) -> (&'a mut K, &'a mut V) - where - K: Hash, - S: BuildHasher, - { - self.base.insert(key, value) - } - - /// Sets the value of the entry with the VacantEntry's key, - /// and returns a mutable reference to it. - #[inline] - #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn insert_hashed_nocheck(self, hash: u64, key: K, value: V) -> (&'a mut K, &'a mut V) - where - K: Hash, - S: BuildHasher, - { - self.base.insert_hashed_nocheck(hash, key, value) - } -} - -#[unstable(feature = "hash_raw_entry", issue = "56167")] -impl Debug for RawEntryBuilderMut<'_, K, V, S> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RawEntryBuilder").finish_non_exhaustive() - } -} - -#[unstable(feature = "hash_raw_entry", issue = "56167")] -impl Debug for RawEntryMut<'_, K, V, S> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match *self { - RawEntryMut::Vacant(ref v) => f.debug_tuple("RawEntry").field(v).finish(), - RawEntryMut::Occupied(ref o) => f.debug_tuple("RawEntry").field(o).finish(), - } - } -} - -#[unstable(feature = "hash_raw_entry", issue = "56167")] -impl Debug for RawOccupiedEntryMut<'_, K, V, S> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RawOccupiedEntryMut") - .field("key", self.key()) - .field("value", self.get()) - .finish_non_exhaustive() - } -} - -#[unstable(feature = "hash_raw_entry", issue = "56167")] -impl Debug for RawVacantEntryMut<'_, K, V, S> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RawVacantEntryMut").finish_non_exhaustive() - } -} - -#[unstable(feature = "hash_raw_entry", issue = "56167")] -impl Debug for RawEntryBuilder<'_, K, V, S> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RawEntryBuilder").finish_non_exhaustive() - } -} - /// A view into a single entry in a map, which may either be vacant or occupied. /// /// This `enum` is constructed from the [`entry`] method on [`HashMap`]. @@ -3298,16 +2849,6 @@ pub(super) fn map_try_reserve_error(err: hashbrown::TryReserveError) -> TryReser } } -#[inline] -fn map_raw_entry<'a, K: 'a, V: 'a, S: 'a>( - raw: base::RawEntryMut<'a, K, V, S>, -) -> RawEntryMut<'a, K, V, S> { - match raw { - base::RawEntryMut::Occupied(base) => RawEntryMut::Occupied(RawOccupiedEntryMut { base }), - base::RawEntryMut::Vacant(base) => RawEntryMut::Vacant(RawVacantEntryMut { base }), - } -} - #[allow(dead_code)] fn assert_covariance() { fn map_key<'new>(v: HashMap<&'static str, u8>) -> HashMap<&'new str, u8> { diff --git a/library/std/src/collections/hash/map/tests.rs b/library/std/src/collections/hash/map/tests.rs index a275488a55602..9f7df20a1d7e4 100644 --- a/library/std/src/collections/hash/map/tests.rs +++ b/library/std/src/collections/hash/map/tests.rs @@ -852,99 +852,6 @@ fn test_try_reserve() { } } -#[test] -fn test_raw_entry() { - use super::RawEntryMut::{Occupied, Vacant}; - - let xs = [(1i32, 10i32), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)]; - - let mut map: HashMap<_, _> = xs.iter().cloned().collect(); - - let compute_hash = |map: &HashMap, k: i32| -> u64 { - use core::hash::{BuildHasher, Hash, Hasher}; - - let mut hasher = map.hasher().build_hasher(); - k.hash(&mut hasher); - hasher.finish() - }; - - // Existing key (insert) - match map.raw_entry_mut().from_key(&1) { - Vacant(_) => unreachable!(), - Occupied(mut view) => { - assert_eq!(view.get(), &10); - assert_eq!(view.insert(100), 10); - } - } - let hash1 = compute_hash(&map, 1); - assert_eq!(map.raw_entry().from_key(&1).unwrap(), (&1, &100)); - assert_eq!(map.raw_entry().from_hash(hash1, |k| *k == 1).unwrap(), (&1, &100)); - assert_eq!(map.raw_entry().from_key_hashed_nocheck(hash1, &1).unwrap(), (&1, &100)); - assert_eq!(map.len(), 6); - - // Existing key (update) - match map.raw_entry_mut().from_key(&2) { - Vacant(_) => unreachable!(), - Occupied(mut view) => { - let v = view.get_mut(); - let new_v = (*v) * 10; - *v = new_v; - } - } - let hash2 = compute_hash(&map, 2); - assert_eq!(map.raw_entry().from_key(&2).unwrap(), (&2, &200)); - assert_eq!(map.raw_entry().from_hash(hash2, |k| *k == 2).unwrap(), (&2, &200)); - assert_eq!(map.raw_entry().from_key_hashed_nocheck(hash2, &2).unwrap(), (&2, &200)); - assert_eq!(map.len(), 6); - - // Existing key (take) - let hash3 = compute_hash(&map, 3); - match map.raw_entry_mut().from_key_hashed_nocheck(hash3, &3) { - Vacant(_) => unreachable!(), - Occupied(view) => { - assert_eq!(view.remove_entry(), (3, 30)); - } - } - assert_eq!(map.raw_entry().from_key(&3), None); - assert_eq!(map.raw_entry().from_hash(hash3, |k| *k == 3), None); - assert_eq!(map.raw_entry().from_key_hashed_nocheck(hash3, &3), None); - assert_eq!(map.len(), 5); - - // Nonexistent key (insert) - match map.raw_entry_mut().from_key(&10) { - Occupied(_) => unreachable!(), - Vacant(view) => { - assert_eq!(view.insert(10, 1000), (&mut 10, &mut 1000)); - } - } - assert_eq!(map.raw_entry().from_key(&10).unwrap(), (&10, &1000)); - assert_eq!(map.len(), 6); - - // Ensure all lookup methods produce equivalent results. - for k in 0..12 { - let hash = compute_hash(&map, k); - let v = map.get(&k).cloned(); - let kv = v.as_ref().map(|v| (&k, v)); - - assert_eq!(map.raw_entry().from_key(&k), kv); - assert_eq!(map.raw_entry().from_hash(hash, |q| *q == k), kv); - assert_eq!(map.raw_entry().from_key_hashed_nocheck(hash, &k), kv); - - match map.raw_entry_mut().from_key(&k) { - Occupied(mut o) => assert_eq!(Some(o.get_key_value()), kv), - Vacant(_) => assert_eq!(v, None), - } - match map.raw_entry_mut().from_key_hashed_nocheck(hash, &k) { - Occupied(mut o) => assert_eq!(Some(o.get_key_value()), kv), - Vacant(_) => assert_eq!(v, None), - } - match map.raw_entry_mut().from_hash(hash, |q| *q == k) { - Occupied(mut o) => assert_eq!(Some(o.get_key_value()), kv), - Vacant(_) => assert_eq!(v, None), - } - } -} - mod test_extract_if { use super::*; use crate::panic::{AssertUnwindSafe, catch_unwind}; diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 46b5860123fc1..f9a360585e852 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -14,7 +14,8 @@ target_os = "emscripten", target_os = "wasi", target_env = "sgx", - target_os = "xous" + target_os = "xous", + target_os = "trusty", )) ))] mod tests; diff --git a/library/std/src/io/buffered/bufreader.rs b/library/std/src/io/buffered/bufreader.rs index 697fb5974a3dd..40441dc057d0d 100644 --- a/library/std/src/io/buffered/bufreader.rs +++ b/library/std/src/io/buffered/bufreader.rs @@ -109,9 +109,13 @@ impl BufReader { /// /// `n` must be less than or equal to `capacity`. /// - /// the returned slice may be less than `n` bytes long if + /// The returned slice may be less than `n` bytes long if /// end of file is reached. /// + /// After calling this method, you may call [`consume`](BufRead::consume) + /// with a value less than or equal to `n` to advance over some or all of + /// the returned bytes. + /// /// ## Examples /// /// ```rust diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 5aa048c4cbc85..8472f90305007 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -373,8 +373,8 @@ pub enum ErrorKind { TooManyLinks, /// A filename was invalid. /// - /// This error can also cause if it exceeded the filename length limit. - #[unstable(feature = "io_error_more", issue = "86442")] + /// This error can also occur if a length limit for a name was exceeded. + #[stable(feature = "io_error_invalid_filename", since = "CURRENT_RUSTC_VERSION")] InvalidFilename, /// Program argument list too long. /// diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs index f64f034cce779..fd962b0415c7d 100644 --- a/library/std/src/io/tests.rs +++ b/library/std/src/io/tests.rs @@ -811,13 +811,17 @@ fn read_to_end_error() { } #[test] -// Miri does not support signalling OOM -#[cfg_attr(miri, ignore)] -// 64-bit only to be sure the allocator will fail fast on an impossible to satisfy size -#[cfg(target_pointer_width = "64")] fn try_oom_error() { - let mut v = Vec::::new(); - let reserve_err = v.try_reserve(isize::MAX as usize - 1).unwrap_err(); + use alloc::alloc::Layout; + use alloc::collections::{TryReserveError, TryReserveErrorKind}; + + // We simulate a `Vec::try_reserve` error rather than attempting a huge size for real. This way + // we're not subject to the whims of optimization that might skip the actual allocation, and it + // also works for 32-bit targets and miri that might not OOM at all. + let layout = Layout::new::(); + let kind = TryReserveErrorKind::AllocError { layout, non_exhaustive: () }; + let reserve_err = TryReserveError::from(kind); + let io_err = io::Error::from(reserve_err); assert_eq!(io::ErrorKind::OutOfMemory, io_err.kind()); } diff --git a/library/std/src/keyword_docs.rs b/library/std/src/keyword_docs.rs index 5ac3dbc3e9852..c07c391892d80 100644 --- a/library/std/src/keyword_docs.rs +++ b/library/std/src/keyword_docs.rs @@ -1064,7 +1064,7 @@ mod move_keyword {} /// ```rust,compile_fail,E0502 /// let mut v = vec![0, 1]; /// let mut_ref_v = &mut v; -/// ##[allow(unused)] +/// # #[allow(unused)] /// let ref_v = &v; /// mut_ref_v.push(2); /// ``` diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 104637496276e..101a7565ca6b7 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -174,7 +174,9 @@ //! //! - after-main use of thread-locals, which also affects additional features: //! - [`thread::current()`] -//! - before-main stdio file descriptors are not guaranteed to be open on unix platforms +//! - under UNIX, before main, file descriptors 0, 1, and 2 may be unchanged +//! (they are guaranteed to be open during main, +//! and are opened to /dev/null O_RDWR if they weren't open on program start) //! //! //! [I/O]: io @@ -667,6 +669,8 @@ pub mod arch { pub use std_detect::is_loongarch_feature_detected; #[unstable(feature = "is_riscv_feature_detected", issue = "111192")] pub use std_detect::is_riscv_feature_detected; + #[unstable(feature = "stdarch_s390x_feature_detection", issue = "135413")] + pub use std_detect::is_s390x_feature_detected; #[stable(feature = "simd_x86", since = "1.27.0")] pub use std_detect::is_x86_feature_detected; #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] diff --git a/library/std/src/macros.rs b/library/std/src/macros.rs index e0f9f0bb5cee4..f008d42804c08 100644 --- a/library/std/src/macros.rs +++ b/library/std/src/macros.rs @@ -41,7 +41,7 @@ macro_rules! panic { /// Use `print!` only for the primary output of your program. Use /// [`eprint!`] instead to print error and progress messages. /// -/// See [the formatting documentation in `std::fmt`](../std/fmt/index.html) +/// See the formatting documentation in [`std::fmt`](crate::fmt) /// for details of the macro argument syntax. /// /// [flush]: crate::io::Write::flush @@ -106,7 +106,7 @@ macro_rules! print { /// Use `println!` only for the primary output of your program. Use /// [`eprintln!`] instead to print error and progress messages. /// -/// See [the formatting documentation in `std::fmt`](../std/fmt/index.html) +/// See the formatting documentation in [`std::fmt`](crate::fmt) /// for details of the macro argument syntax. /// /// [`std::fmt`]: crate::fmt @@ -156,7 +156,7 @@ macro_rules! println { /// [`io::stderr`]: crate::io::stderr /// [`io::stdout`]: crate::io::stdout /// -/// See [the formatting documentation in `std::fmt`](../std/fmt/index.html) +/// See the formatting documentation in [`std::fmt`](crate::fmt) /// for details of the macro argument syntax. /// /// # Panics @@ -190,7 +190,7 @@ macro_rules! eprint { /// Use `eprintln!` only for error and progress messages. Use `println!` /// instead for the primary output of your program. /// -/// See [the formatting documentation in `std::fmt`](../std/fmt/index.html) +/// See the formatting documentation in [`std::fmt`](crate::fmt) /// for details of the macro argument syntax. /// /// [`io::stderr`]: crate::io::stderr diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index 9b68f872955c0..6a95142640726 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -5,7 +5,8 @@ not(any( target_os = "emscripten", all(target_os = "wasi", target_env = "p1"), - target_os = "xous" + target_os = "xous", + target_os = "trusty", )) ))] mod tests; diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index 3eb798ad34aaa..a97b3299774bb 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -4,7 +4,8 @@ target_os = "emscripten", all(target_os = "wasi", target_env = "p1"), target_env = "sgx", - target_os = "xous" + target_os = "xous", + target_os = "trusty", )) ))] mod tests; diff --git a/library/std/src/os/fd/mod.rs b/library/std/src/os/fd/mod.rs index 35de4860fe249..95cf4932e6e2c 100644 --- a/library/std/src/os/fd/mod.rs +++ b/library/std/src/os/fd/mod.rs @@ -13,6 +13,7 @@ mod raw; mod owned; // Implementations for `AsRawFd` etc. for network types. +#[cfg(not(target_os = "trusty"))] mod net; #[cfg(test)] diff --git a/library/std/src/os/fd/owned.rs b/library/std/src/os/fd/owned.rs index 5cec11ecccf1c..701cf82335757 100644 --- a/library/std/src/os/fd/owned.rs +++ b/library/std/src/os/fd/owned.rs @@ -4,12 +4,20 @@ #![deny(unsafe_op_in_unsafe_fn)] use super::raw::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; +#[cfg(not(target_os = "trusty"))] +use crate::fs; use crate::marker::PhantomData; use crate::mem::ManuallyDrop; -#[cfg(not(any(target_arch = "wasm32", target_env = "sgx", target_os = "hermit")))] +#[cfg(not(any( + target_arch = "wasm32", + target_env = "sgx", + target_os = "hermit", + target_os = "trusty" +)))] use crate::sys::cvt; +#[cfg(not(target_os = "trusty"))] use crate::sys_common::{AsInner, FromInner, IntoInner}; -use crate::{fmt, fs, io}; +use crate::{fmt, io}; type ValidRawFd = core::num::niche_types::NotAllOnes; @@ -87,7 +95,7 @@ impl OwnedFd { impl BorrowedFd<'_> { /// Creates a new `OwnedFd` instance that shares the same underlying file /// description as the existing `BorrowedFd` instance. - #[cfg(not(any(target_arch = "wasm32", target_os = "hermit")))] + #[cfg(not(any(target_arch = "wasm32", target_os = "hermit", target_os = "trusty")))] #[stable(feature = "io_safety", since = "1.63.0")] pub fn try_clone_to_owned(&self) -> crate::io::Result { // We want to atomically duplicate this file descriptor and set the @@ -110,7 +118,7 @@ impl BorrowedFd<'_> { /// Creates a new `OwnedFd` instance that shares the same underlying file /// description as the existing `BorrowedFd` instance. - #[cfg(any(target_arch = "wasm32", target_os = "hermit"))] + #[cfg(any(target_arch = "wasm32", target_os = "hermit", target_os = "trusty"))] #[stable(feature = "io_safety", since = "1.63.0")] pub fn try_clone_to_owned(&self) -> crate::io::Result { Err(crate::io::Error::UNSUPPORTED_PLATFORM) @@ -280,6 +288,7 @@ impl AsFd for OwnedFd { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl AsFd for fs::File { #[inline] fn as_fd(&self) -> BorrowedFd<'_> { @@ -288,6 +297,7 @@ impl AsFd for fs::File { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl From for OwnedFd { /// Takes ownership of a [`File`](fs::File)'s underlying file descriptor. #[inline] @@ -297,6 +307,7 @@ impl From for OwnedFd { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl From for fs::File { /// Returns a [`File`](fs::File) that takes ownership of the given /// file descriptor. @@ -307,6 +318,7 @@ impl From for fs::File { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl AsFd for crate::net::TcpStream { #[inline] fn as_fd(&self) -> BorrowedFd<'_> { @@ -315,6 +327,7 @@ impl AsFd for crate::net::TcpStream { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl From for OwnedFd { /// Takes ownership of a [`TcpStream`](crate::net::TcpStream)'s socket file descriptor. #[inline] @@ -324,6 +337,7 @@ impl From for OwnedFd { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl From for crate::net::TcpStream { #[inline] fn from(owned_fd: OwnedFd) -> Self { @@ -334,6 +348,7 @@ impl From for crate::net::TcpStream { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl AsFd for crate::net::TcpListener { #[inline] fn as_fd(&self) -> BorrowedFd<'_> { @@ -342,6 +357,7 @@ impl AsFd for crate::net::TcpListener { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl From for OwnedFd { /// Takes ownership of a [`TcpListener`](crate::net::TcpListener)'s socket file descriptor. #[inline] @@ -351,6 +367,7 @@ impl From for OwnedFd { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl From for crate::net::TcpListener { #[inline] fn from(owned_fd: OwnedFd) -> Self { @@ -361,6 +378,7 @@ impl From for crate::net::TcpListener { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl AsFd for crate::net::UdpSocket { #[inline] fn as_fd(&self) -> BorrowedFd<'_> { @@ -369,6 +387,7 @@ impl AsFd for crate::net::UdpSocket { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl From for OwnedFd { /// Takes ownership of a [`UdpSocket`](crate::net::UdpSocket)'s file descriptor. #[inline] @@ -378,6 +397,7 @@ impl From for OwnedFd { } #[stable(feature = "io_safety", since = "1.63.0")] +#[cfg(not(target_os = "trusty"))] impl From for crate::net::UdpSocket { #[inline] fn from(owned_fd: OwnedFd) -> Self { diff --git a/library/std/src/os/fd/raw.rs b/library/std/src/os/fd/raw.rs index 03dff94350dad..083ac6e3fe6b1 100644 --- a/library/std/src/os/fd/raw.rs +++ b/library/std/src/os/fd/raw.rs @@ -5,6 +5,9 @@ #[cfg(target_os = "hermit")] use hermit_abi as libc; +#[cfg(not(target_os = "trusty"))] +use crate::fs; +use crate::io; #[cfg(target_os = "hermit")] use crate::os::hermit::io::OwnedFd; #[cfg(not(target_os = "hermit"))] @@ -15,8 +18,8 @@ use crate::os::unix::io::AsFd; use crate::os::unix::io::OwnedFd; #[cfg(target_os = "wasi")] use crate::os::wasi::io::OwnedFd; +#[cfg(not(target_os = "trusty"))] use crate::sys_common::{AsInner, IntoInner}; -use crate::{fs, io}; /// Raw file descriptors. #[stable(feature = "rust1", since = "1.0.0")] @@ -161,6 +164,7 @@ impl FromRawFd for RawFd { } #[stable(feature = "rust1", since = "1.0.0")] +#[cfg(not(target_os = "trusty"))] impl AsRawFd for fs::File { #[inline] fn as_raw_fd(&self) -> RawFd { @@ -168,6 +172,7 @@ impl AsRawFd for fs::File { } } #[stable(feature = "from_raw_os", since = "1.1.0")] +#[cfg(not(target_os = "trusty"))] impl FromRawFd for fs::File { #[inline] unsafe fn from_raw_fd(fd: RawFd) -> fs::File { @@ -175,6 +180,7 @@ impl FromRawFd for fs::File { } } #[stable(feature = "into_raw_os", since = "1.4.0")] +#[cfg(not(target_os = "trusty"))] impl IntoRawFd for fs::File { #[inline] fn into_raw_fd(self) -> RawFd { @@ -183,6 +189,7 @@ impl IntoRawFd for fs::File { } #[stable(feature = "asraw_stdio", since = "1.21.0")] +#[cfg(not(target_os = "trusty"))] impl AsRawFd for io::Stdin { #[inline] fn as_raw_fd(&self) -> RawFd { @@ -207,6 +214,7 @@ impl AsRawFd for io::Stderr { } #[stable(feature = "asraw_stdio_locks", since = "1.35.0")] +#[cfg(not(target_os = "trusty"))] impl<'a> AsRawFd for io::StdinLock<'a> { #[inline] fn as_raw_fd(&self) -> RawFd { diff --git a/library/std/src/os/mod.rs b/library/std/src/os/mod.rs index e28a1c3e6d5f4..58cbecd30e538 100644 --- a/library/std/src/os/mod.rs +++ b/library/std/src/os/mod.rs @@ -169,6 +169,8 @@ pub mod rtems; pub mod solaris; #[cfg(target_os = "solid_asp3")] pub mod solid; +#[cfg(target_os = "trusty")] +pub mod trusty; #[cfg(target_os = "uefi")] pub mod uefi; #[cfg(target_os = "vita")] @@ -178,7 +180,7 @@ pub mod vxworks; #[cfg(target_os = "xous")] pub mod xous; -#[cfg(any(unix, target_os = "hermit", target_os = "wasi", doc))] +#[cfg(any(unix, target_os = "hermit", target_os = "trusty", target_os = "wasi", doc))] pub mod fd; #[cfg(any(target_os = "linux", target_os = "android", doc))] diff --git a/library/std/src/os/unix/fs.rs b/library/std/src/os/unix/fs.rs index 04a45fd035a55..0427feb29550f 100644 --- a/library/std/src/os/unix/fs.rs +++ b/library/std/src/os/unix/fs.rs @@ -276,63 +276,89 @@ impl FileExt for fs::File { } /// Unix-specific extensions to [`fs::Permissions`]. +/// +/// # Examples +/// +/// ```no_run +/// use std::fs::{File, Permissions}; +/// use std::io::{ErrorKind, Result as IoResult}; +/// use std::os::unix::fs::PermissionsExt; +/// +/// fn main() -> IoResult<()> { +/// let name = "test_file_for_permissions"; +/// +/// // make sure file does not exist +/// let _ = std::fs::remove_file(name); +/// assert_eq!( +/// File::open(name).unwrap_err().kind(), +/// ErrorKind::NotFound, +/// "file already exists" +/// ); +/// +/// // full read/write/execute mode bits for owner of file +/// // that we want to add to existing mode bits +/// let my_mode = 0o700; +/// +/// // create new file with specified permissions +/// { +/// let file = File::create(name)?; +/// let mut permissions = file.metadata()?.permissions(); +/// eprintln!("Current permissions: {:o}", permissions.mode()); +/// +/// // make sure new permissions are not already set +/// assert!( +/// permissions.mode() & my_mode != my_mode, +/// "permissions already set" +/// ); +/// +/// // either use `set_mode` to change an existing Permissions struct +/// permissions.set_mode(permissions.mode() | my_mode); +/// +/// // or use `from_mode` to construct a new Permissions struct +/// permissions = Permissions::from_mode(permissions.mode() | my_mode); +/// +/// // write new permissions to file +/// file.set_permissions(permissions)?; +/// } +/// +/// let permissions = File::open(name)?.metadata()?.permissions(); +/// eprintln!("New permissions: {:o}", permissions.mode()); +/// +/// // assert new permissions were set +/// assert_eq!( +/// permissions.mode() & my_mode, +/// my_mode, +/// "new permissions not set" +/// ); +/// Ok(()) +/// } +/// ``` +/// +/// ```no_run +/// use std::fs::Permissions; +/// use std::os::unix::fs::PermissionsExt; +/// +/// // read/write for owner and read for others +/// let my_mode = 0o644; +/// let mut permissions = Permissions::from_mode(my_mode); +/// assert_eq!(permissions.mode(), my_mode); +/// +/// // read/write/execute for owner +/// let other_mode = 0o700; +/// permissions.set_mode(other_mode); +/// assert_eq!(permissions.mode(), other_mode); +/// ``` #[stable(feature = "fs_ext", since = "1.1.0")] pub trait PermissionsExt { - /// Returns the underlying raw `st_mode` bits that contain the standard - /// Unix permissions for this file. - /// - /// # Examples - /// - /// ```no_run - /// use std::fs::File; - /// use std::os::unix::fs::PermissionsExt; - /// - /// fn main() -> std::io::Result<()> { - /// let f = File::create("foo.txt")?; - /// let metadata = f.metadata()?; - /// let permissions = metadata.permissions(); - /// - /// println!("permissions: {:o}", permissions.mode()); - /// Ok(()) - /// } - /// ``` + /// Returns the mode permission bits #[stable(feature = "fs_ext", since = "1.1.0")] fn mode(&self) -> u32; - /// Sets the underlying raw bits for this set of permissions. - /// - /// # Examples - /// - /// ```no_run - /// use std::fs::File; - /// use std::os::unix::fs::PermissionsExt; - /// - /// fn main() -> std::io::Result<()> { - /// let f = File::create("foo.txt")?; - /// let metadata = f.metadata()?; - /// let mut permissions = metadata.permissions(); - /// - /// permissions.set_mode(0o644); // Read/write for owner and read for others. - /// assert_eq!(permissions.mode(), 0o644); - /// Ok(()) - /// } - /// ``` + /// Sets the mode permission bits. #[stable(feature = "fs_ext", since = "1.1.0")] fn set_mode(&mut self, mode: u32); - /// Creates a new instance of `Permissions` from the given set of Unix - /// permission bits. - /// - /// # Examples - /// - /// ``` - /// use std::fs::Permissions; - /// use std::os::unix::fs::PermissionsExt; - /// - /// // Read/write for owner and read for others. - /// let permissions = Permissions::from_mode(0o644); - /// assert_eq!(permissions.mode(), 0o644); - /// ``` + /// Creates a new instance from the given mode permission bits. #[stable(feature = "fs_ext", since = "1.1.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "permissions_from_mode")] fn from_mode(mode: u32) -> Self; diff --git a/library/std/src/os/windows/process.rs b/library/std/src/os/windows/process.rs index fa65a7c51bfa0..a084f452e55d0 100644 --- a/library/std/src/os/windows/process.rs +++ b/library/std/src/os/windows/process.rs @@ -531,7 +531,7 @@ impl<'a> ProcThreadAttributeListBuilder<'a> { /// pub Y: i16, /// } /// - /// extern "system" { + /// unsafe extern "system" { /// fn CreatePipe( /// hreadpipe: *mut HANDLE, /// hwritepipe: *mut HANDLE, diff --git a/library/std/src/path.rs b/library/std/src/path.rs index f9f3b488f0d03..980213be7ea90 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -294,11 +294,6 @@ where } } -// Detect scheme on Redox -pub(crate) fn has_redox_scheme(s: &[u8]) -> bool { - cfg!(target_os = "redox") && s.contains(&b':') -} - //////////////////////////////////////////////////////////////////////////////// // Cross-platform, iterator-independent parsing //////////////////////////////////////////////////////////////////////////////// @@ -2834,8 +2829,7 @@ impl Path { Components { path: self.as_u8_slice(), prefix, - has_physical_root: has_physical_root(self.as_u8_slice(), prefix) - || has_redox_scheme(self.as_u8_slice()), + has_physical_root: has_physical_root(self.as_u8_slice(), prefix), front: State::Prefix, back: State::Body, } diff --git a/library/std/src/process.rs b/library/std/src/process.rs index bdd4844b6511a..37762c65f6556 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -154,7 +154,8 @@ target_os = "emscripten", target_os = "wasi", target_env = "sgx", - target_os = "xous" + target_os = "xous", + target_os = "trusty", )) ))] mod tests; diff --git a/library/std/src/sys/alloc/mod.rs b/library/std/src/sys/alloc/mod.rs index 2c0b533a5703f..8489e17c971d9 100644 --- a/library/std/src/sys/alloc/mod.rs +++ b/library/std/src/sys/alloc/mod.rs @@ -72,6 +72,7 @@ cfg_if::cfg_if! { target_family = "unix", target_os = "wasi", target_os = "teeos", + target_os = "trusty", ))] { mod unix; } else if #[cfg(target_os = "windows")] { diff --git a/library/std/src/sys/pal/mod.rs b/library/std/src/sys/pal/mod.rs index 9be018c8a5312..fbefc62ac88eb 100644 --- a/library/std/src/sys/pal/mod.rs +++ b/library/std/src/sys/pal/mod.rs @@ -37,6 +37,9 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "hermit")] { mod hermit; pub use self::hermit::*; + } else if #[cfg(target_os = "trusty")] { + mod trusty; + pub use self::trusty::*; } else if #[cfg(all(target_os = "wasi", target_env = "p2"))] { mod wasip2; pub use self::wasip2::*; diff --git a/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs b/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs index 301e3299c0572..3fe6dee3d6f4f 100644 --- a/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs +++ b/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs @@ -6,7 +6,7 @@ use super::super::mem::{is_enclave_range, is_user_range}; use crate::arch::asm; use crate::cell::UnsafeCell; use crate::convert::TryInto; -use crate::mem::{self, ManuallyDrop}; +use crate::mem::{self, ManuallyDrop, MaybeUninit}; use crate::ops::{CoerceUnsized, Deref, DerefMut, Index, IndexMut}; use crate::pin::PinCoerceUnsized; use crate::ptr::{self, NonNull}; @@ -209,6 +209,45 @@ impl NewUserRef> for NonNull> { } } +/// A type which can a destination for safely copying from userspace. +/// +/// # Safety +/// +/// Requires that `T` and `Self` have identical layouts. +#[unstable(feature = "sgx_platform", issue = "56975")] +pub unsafe trait UserSafeCopyDestination { + /// Returns a pointer for writing to the value. + fn as_mut_ptr(&mut self) -> *mut T; +} + +#[unstable(feature = "sgx_platform", issue = "56975")] +unsafe impl UserSafeCopyDestination for T { + fn as_mut_ptr(&mut self) -> *mut T { + self as _ + } +} + +#[unstable(feature = "sgx_platform", issue = "56975")] +unsafe impl UserSafeCopyDestination<[T]> for [T] { + fn as_mut_ptr(&mut self) -> *mut [T] { + self as _ + } +} + +#[unstable(feature = "sgx_platform", issue = "56975")] +unsafe impl UserSafeCopyDestination for MaybeUninit { + fn as_mut_ptr(&mut self) -> *mut T { + self as *mut Self as _ + } +} + +#[unstable(feature = "sgx_platform", issue = "56975")] +unsafe impl UserSafeCopyDestination<[T]> for [MaybeUninit] { + fn as_mut_ptr(&mut self) -> *mut [T] { + self as *mut Self as _ + } +} + #[unstable(feature = "sgx_platform", issue = "56975")] impl User where @@ -544,12 +583,12 @@ where /// # Panics /// This function panics if the destination doesn't have the same size as /// the source. This can happen for dynamically-sized types such as slices. - pub fn copy_to_enclave(&self, dest: &mut T) { + pub fn copy_to_enclave>(&self, dest: &mut U) { unsafe { assert_eq!(size_of_val(dest), size_of_val(&*self.0.get())); copy_from_userspace( self.0.get() as *const T as *const u8, - dest as *mut T as *mut u8, + dest.as_mut_ptr() as *mut u8, size_of_val(dest), ); } @@ -639,25 +678,18 @@ where unsafe { (*self.0.get()).len() } } - /// Copies the value from user memory and place it into `dest`. Afterwards, - /// `dest` will contain exactly `self.len()` elements. - /// - /// # Panics - /// This function panics if the destination doesn't have the same size as - /// the source. This can happen for dynamically-sized types such as slices. - pub fn copy_to_enclave_vec(&self, dest: &mut Vec) { - if let Some(missing) = self.len().checked_sub(dest.capacity()) { - dest.reserve(missing) - } + /// Copies the value from user memory and appends it to `dest`. + pub fn append_to_enclave_vec(&self, dest: &mut Vec) { + dest.reserve(self.len()); + self.copy_to_enclave(&mut dest.spare_capacity_mut()[..self.len()]); // SAFETY: We reserve enough space above. - unsafe { dest.set_len(self.len()) }; - self.copy_to_enclave(&mut dest[..]); + unsafe { dest.set_len(dest.len() + self.len()) }; } /// Copies the value from user memory into a vector in enclave memory. pub fn to_enclave(&self) -> Vec { let mut ret = Vec::with_capacity(self.len()); - self.copy_to_enclave_vec(&mut ret); + self.append_to_enclave_vec(&mut ret); ret } diff --git a/library/std/src/sys/pal/sgx/abi/usercalls/mod.rs b/library/std/src/sys/pal/sgx/abi/usercalls/mod.rs index 90b9b59471a52..cbdaf439b2847 100644 --- a/library/std/src/sys/pal/sgx/abi/usercalls/mod.rs +++ b/library/std/src/sys/pal/sgx/abi/usercalls/mod.rs @@ -1,5 +1,7 @@ use crate::cmp; -use crate::io::{Error as IoError, ErrorKind, IoSlice, IoSliceMut, Result as IoResult}; +use crate::io::{ + BorrowedCursor, Error as IoError, ErrorKind, IoSlice, IoSliceMut, Result as IoResult, +}; use crate::random::{DefaultRandomSource, Random}; use crate::time::{Duration, Instant}; @@ -36,6 +38,19 @@ pub fn read(fd: Fd, bufs: &mut [IoSliceMut<'_>]) -> IoResult { } } +/// Usercall `read` with an uninitialized buffer. See the ABI documentation for +/// more information. +#[unstable(feature = "sgx_platform", issue = "56975")] +pub fn read_buf(fd: Fd, mut buf: BorrowedCursor<'_>) -> IoResult<()> { + unsafe { + let mut userbuf = alloc::User::<[u8]>::uninitialized(buf.capacity()); + let len = raw::read(fd, userbuf.as_mut_ptr().cast(), userbuf.len()).from_sgx_result()?; + userbuf[..len].copy_to_enclave(&mut buf.as_mut()[..len]); + buf.advance_unchecked(len); + Ok(()) + } +} + /// Usercall `read_alloc`. See the ABI documentation for more information. #[unstable(feature = "sgx_platform", issue = "56975")] pub fn read_alloc(fd: Fd) -> IoResult> { diff --git a/library/std/src/sys/pal/sgx/fd.rs b/library/std/src/sys/pal/sgx/fd.rs index 3bb3189a1d127..399f6a1648984 100644 --- a/library/std/src/sys/pal/sgx/fd.rs +++ b/library/std/src/sys/pal/sgx/fd.rs @@ -29,7 +29,7 @@ impl FileDesc { } pub fn read_buf(&self, buf: BorrowedCursor<'_>) -> io::Result<()> { - crate::io::default_read_buf(|b| self.read(b), buf) + usercalls::read_buf(self.fd, buf) } pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { diff --git a/library/std/src/sys/pal/uefi/helpers.rs b/library/std/src/sys/pal/uefi/helpers.rs index 0a2a8f5ef67be..60c33c637d762 100644 --- a/library/std/src/sys/pal/uefi/helpers.rs +++ b/library/std/src/sys/pal/uefi/helpers.rs @@ -216,6 +216,60 @@ pub(crate) fn device_path_to_text(path: NonNull) -> io::R Err(io::const_error!(io::ErrorKind::NotFound, "no device path to text protocol found")) } +fn device_node_to_text(path: NonNull) -> io::Result { + fn node_to_text( + protocol: NonNull, + path: NonNull, + ) -> io::Result { + let path_ptr: *mut r_efi::efi::Char16 = unsafe { + ((*protocol.as_ptr()).convert_device_node_to_text)( + path.as_ptr(), + // DisplayOnly + r_efi::efi::Boolean::FALSE, + // AllowShortcuts + r_efi::efi::Boolean::FALSE, + ) + }; + + let path = os_string_from_raw(path_ptr) + .ok_or(io::const_error!(io::ErrorKind::InvalidData, "Invalid path"))?; + + if let Some(boot_services) = crate::os::uefi::env::boot_services() { + let boot_services: NonNull = boot_services.cast(); + unsafe { + ((*boot_services.as_ptr()).free_pool)(path_ptr.cast()); + } + } + + Ok(path) + } + + static LAST_VALID_HANDLE: AtomicPtr = + AtomicPtr::new(crate::ptr::null_mut()); + + if let Some(handle) = NonNull::new(LAST_VALID_HANDLE.load(Ordering::Acquire)) { + if let Ok(protocol) = open_protocol::( + handle, + device_path_to_text::PROTOCOL_GUID, + ) { + return node_to_text(protocol, path); + } + } + + let device_path_to_text_handles = locate_handles(device_path_to_text::PROTOCOL_GUID)?; + for handle in device_path_to_text_handles { + if let Ok(protocol) = open_protocol::( + handle, + device_path_to_text::PROTOCOL_GUID, + ) { + LAST_VALID_HANDLE.store(handle.as_ptr(), Ordering::Release); + return node_to_text(protocol, path); + } + } + + Err(io::const_error!(io::ErrorKind::NotFound, "No device path to text protocol found")) +} + /// Gets RuntimeServices. pub(crate) fn runtime_services() -> Option> { let system_table: NonNull = @@ -319,6 +373,11 @@ impl<'a> BorrowedDevicePath<'a> { pub(crate) fn to_text(&self) -> io::Result { device_path_to_text(self.protocol) } + + #[expect(dead_code)] + pub(crate) const fn iter(&'a self) -> DevicePathIterator<'a> { + DevicePathIterator::new(DevicePathNode::new(self.protocol)) + } } impl<'a> crate::fmt::Debug for BorrowedDevicePath<'a> { @@ -330,6 +389,126 @@ impl<'a> crate::fmt::Debug for BorrowedDevicePath<'a> { } } +pub(crate) struct DevicePathIterator<'a>(Option>); + +impl<'a> DevicePathIterator<'a> { + const fn new(node: DevicePathNode<'a>) -> Self { + if node.is_end() { Self(None) } else { Self(Some(node)) } + } +} + +impl<'a> Iterator for DevicePathIterator<'a> { + type Item = DevicePathNode<'a>; + + fn next(&mut self) -> Option { + let cur_node = self.0?; + + let next_node = unsafe { cur_node.next_node() }; + self.0 = if next_node.is_end() { None } else { Some(next_node) }; + + Some(cur_node) + } +} + +#[derive(Copy, Clone)] +pub(crate) struct DevicePathNode<'a> { + protocol: NonNull, + phantom: PhantomData<&'a r_efi::protocols::device_path::Protocol>, +} + +impl<'a> DevicePathNode<'a> { + pub(crate) const fn new(protocol: NonNull) -> Self { + Self { protocol, phantom: PhantomData } + } + + pub(crate) const fn length(&self) -> u16 { + let len = unsafe { (*self.protocol.as_ptr()).length }; + u16::from_le_bytes(len) + } + + pub(crate) const fn node_type(&self) -> u8 { + unsafe { (*self.protocol.as_ptr()).r#type } + } + + pub(crate) const fn sub_type(&self) -> u8 { + unsafe { (*self.protocol.as_ptr()).sub_type } + } + + pub(crate) fn data(&self) -> &[u8] { + let length: usize = self.length().into(); + + // Some nodes do not have any special data + if length > 4 { + let raw_ptr: *const u8 = self.protocol.as_ptr().cast(); + let data = unsafe { raw_ptr.add(4) }; + unsafe { crate::slice::from_raw_parts(data, length - 4) } + } else { + &[] + } + } + + pub(crate) const fn is_end(&self) -> bool { + self.node_type() == r_efi::protocols::device_path::TYPE_END + && self.sub_type() == r_efi::protocols::device_path::End::SUBTYPE_ENTIRE + } + + #[expect(dead_code)] + pub(crate) const fn is_end_instance(&self) -> bool { + self.node_type() == r_efi::protocols::device_path::TYPE_END + && self.sub_type() == r_efi::protocols::device_path::End::SUBTYPE_INSTANCE + } + + pub(crate) unsafe fn next_node(&self) -> Self { + let node = unsafe { + self.protocol + .cast::() + .add(self.length().into()) + .cast::() + }; + Self::new(node) + } + + #[expect(dead_code)] + pub(crate) fn to_path(&'a self) -> BorrowedDevicePath<'a> { + BorrowedDevicePath::new(self.protocol) + } + + pub(crate) fn to_text(&self) -> io::Result { + device_node_to_text(self.protocol) + } +} + +impl<'a> PartialEq for DevicePathNode<'a> { + fn eq(&self, other: &Self) -> bool { + let self_len = self.length(); + let other_len = other.length(); + + self_len == other_len + && unsafe { + compiler_builtins::mem::memcmp( + self.protocol.as_ptr().cast(), + other.protocol.as_ptr().cast(), + usize::from(self_len), + ) == 0 + } + } +} + +impl<'a> crate::fmt::Debug for DevicePathNode<'a> { + fn fmt(&self, f: &mut crate::fmt::Formatter<'_>) -> crate::fmt::Result { + match self.to_text() { + Ok(p) => p.fmt(f), + Err(_) => f + .debug_struct("DevicePathNode") + .field("type", &self.node_type()) + .field("sub_type", &self.sub_type()) + .field("length", &self.length()) + .field("specific_device_path_data", &self.data()) + .finish(), + } + } +} + pub(crate) struct OwnedProtocol { guid: r_efi::efi::Guid, handle: NonNull, diff --git a/library/std/src/sys/pal/unix/os.rs b/library/std/src/sys/pal/unix/os.rs index 3a238d160cb57..91f55fcd32bb5 100644 --- a/library/std/src/sys/pal/unix/os.rs +++ b/library/std/src/sys/pal/unix/os.rs @@ -484,7 +484,12 @@ pub fn current_exe() -> io::Result { } } -#[cfg(any(target_os = "redox", target_os = "rtems"))] +#[cfg(target_os = "redox")] +pub fn current_exe() -> io::Result { + crate::fs::read_to_string("/scheme/sys/exe").map(PathBuf::from) +} + +#[cfg(target_os = "rtems")] pub fn current_exe() -> io::Result { crate::fs::read_to_string("sys:exe").map(PathBuf::from) } diff --git a/library/std/src/sys/pal/unix/process/process_common.rs b/library/std/src/sys/pal/unix/process/process_common.rs index 0ea9db211b311..dd41921f263e6 100644 --- a/library/std/src/sys/pal/unix/process/process_common.rs +++ b/library/std/src/sys/pal/unix/process/process_common.rs @@ -19,8 +19,6 @@ use crate::{fmt, io, ptr}; cfg_if::cfg_if! { if #[cfg(target_os = "fuchsia")] { // fuchsia doesn't have /dev/null - } else if #[cfg(target_os = "redox")] { - const DEV_NULL: &CStr = c"null:"; } else if #[cfg(target_os = "vxworks")] { const DEV_NULL: &CStr = c"/null"; } else { diff --git a/library/std/src/sys/path/unix.rs b/library/std/src/sys/path/unix.rs index 361e99964f18c..faa2616a6320d 100644 --- a/library/std/src/sys/path/unix.rs +++ b/library/std/src/sys/path/unix.rs @@ -62,10 +62,7 @@ pub(crate) fn absolute(path: &Path) -> io::Result { } pub(crate) fn is_absolute(path: &Path) -> bool { - if cfg!(target_os = "redox") { - // FIXME: Allow Redox prefixes - path.has_root() || crate::path::has_redox_scheme(path.as_u8_slice()) - } else if cfg!(any(unix, target_os = "hermit", target_os = "wasi")) { + if cfg!(any(unix, target_os = "hermit", target_os = "wasi")) { path.has_root() } else { path.has_root() && path.prefix().is_some() diff --git a/library/std/src/sys/random/mod.rs b/library/std/src/sys/random/mod.rs index f42351deb92c0..870039602bcf0 100644 --- a/library/std/src/sys/random/mod.rs +++ b/library/std/src/sys/random/mod.rs @@ -60,6 +60,9 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "teeos")] { mod teeos; pub use teeos::fill_bytes; + } else if #[cfg(target_os = "trusty")] { + mod trusty; + pub use trusty::fill_bytes; } else if #[cfg(target_os = "uefi")] { mod uefi; pub use uefi::fill_bytes; diff --git a/library/std/src/sys/stdio/mod.rs b/library/std/src/sys/stdio/mod.rs index 2a9167bfe966c..336d4c8527db3 100644 --- a/library/std/src/sys/stdio/mod.rs +++ b/library/std/src/sys/stdio/mod.rs @@ -19,6 +19,9 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "teeos")] { mod teeos; pub use teeos::*; + } else if #[cfg(target_os = "trusty")] { + mod trusty; + pub use trusty::*; } else if #[cfg(target_os = "uefi")] { mod uefi; pub use uefi::*; diff --git a/library/std/src/sys/stdio/sgx.rs b/library/std/src/sys/stdio/sgx.rs index 03d754cb2173f..1894c098d1851 100644 --- a/library/std/src/sys/stdio/sgx.rs +++ b/library/std/src/sys/stdio/sgx.rs @@ -1,6 +1,6 @@ use fortanix_sgx_abi as abi; -use crate::io; +use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; use crate::sys::fd::FileDesc; pub struct Stdin(()); @@ -24,6 +24,19 @@ impl io::Read for Stdin { fn read(&mut self, buf: &mut [u8]) -> io::Result { with_std_fd(abi::FD_STDIN, |fd| fd.read(buf)) } + + fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> { + with_std_fd(abi::FD_STDIN, |fd| fd.read_buf(buf)) + } + + fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { + with_std_fd(abi::FD_STDIN, |fd| fd.read_vectored(bufs)) + } + + #[inline] + fn is_read_vectored(&self) -> bool { + true + } } impl Stdout { @@ -40,6 +53,15 @@ impl io::Write for Stdout { fn flush(&mut self) -> io::Result<()> { with_std_fd(abi::FD_STDOUT, |fd| fd.flush()) } + + fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { + with_std_fd(abi::FD_STDOUT, |fd| fd.write_vectored(bufs)) + } + + #[inline] + fn is_write_vectored(&self) -> bool { + true + } } impl Stderr { @@ -56,6 +78,15 @@ impl io::Write for Stderr { fn flush(&mut self) -> io::Result<()> { with_std_fd(abi::FD_STDERR, |fd| fd.flush()) } + + fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { + with_std_fd(abi::FD_STDERR, |fd| fd.write_vectored(bufs)) + } + + #[inline] + fn is_write_vectored(&self) -> bool { + true + } } pub const STDIN_BUF_SIZE: usize = crate::sys::io::DEFAULT_BUF_SIZE; diff --git a/library/std/src/sys/thread_local/mod.rs b/library/std/src/sys/thread_local/mod.rs index f0a13323ec93f..1ff13154b7b3c 100644 --- a/library/std/src/sys/thread_local/mod.rs +++ b/library/std/src/sys/thread_local/mod.rs @@ -28,6 +28,7 @@ cfg_if::cfg_if! { all(target_family = "wasm", not(target_feature = "atomics")), target_os = "uefi", target_os = "zkvm", + target_os = "trusty", ))] { mod statik; pub use statik::{EagerStorage, LazyStorage, thread_local_inner}; @@ -91,6 +92,7 @@ pub(crate) mod guard { )), target_os = "uefi", target_os = "zkvm", + target_os = "trusty", ))] { pub(crate) fn enable() { // FIXME: Right now there is no concept of "thread exit" on diff --git a/library/std/tests/floats/f16.rs b/library/std/tests/floats/f16.rs index 5180f3d40f3a7..19389a9178e91 100644 --- a/library/std/tests/floats/f16.rs +++ b/library/std/tests/floats/f16.rs @@ -461,18 +461,16 @@ fn test_recip() { #[test] #[cfg(reliable_f16_math)] fn test_powi() { - // FIXME(llvm19): LLVM misoptimizes `powi.f16` - // - // let nan: f16 = f16::NAN; - // let inf: f16 = f16::INFINITY; - // let neg_inf: f16 = f16::NEG_INFINITY; - // assert_eq!(1.0f16.powi(1), 1.0); - // assert_approx_eq!((-3.1f16).powi(2), 9.61, TOL_0); - // assert_approx_eq!(5.9f16.powi(-2), 0.028727, TOL_N2); - // assert_eq!(8.3f16.powi(0), 1.0); - // assert!(nan.powi(2).is_nan()); - // assert_eq!(inf.powi(3), inf); - // assert_eq!(neg_inf.powi(2), inf); + let nan: f16 = f16::NAN; + let inf: f16 = f16::INFINITY; + let neg_inf: f16 = f16::NEG_INFINITY; + assert_eq!(1.0f16.powi(1), 1.0); + assert_approx_eq!((-3.1f16).powi(2), 9.61, TOL_0); + assert_approx_eq!(5.9f16.powi(-2), 0.028727, TOL_N2); + assert_eq!(8.3f16.powi(0), 1.0); + assert!(nan.powi(2).is_nan()); + assert_eq!(inf.powi(3), inf); + assert_eq!(neg_inf.powi(2), inf); } #[test] @@ -813,6 +811,7 @@ fn test_clamp_max_is_nan() { } #[test] +#[cfg(reliable_f16_math)] fn test_total_cmp() { use core::cmp::Ordering; @@ -820,14 +819,13 @@ fn test_total_cmp() { 1 << (f16::MANTISSA_DIGITS - 2) } - // FIXME(f16_f128): test subnormals when powf is available - // fn min_subnorm() -> f16 { - // f16::MIN_POSITIVE / f16::powf(2.0, f16::MANTISSA_DIGITS as f16 - 1.0) - // } + fn min_subnorm() -> f16 { + f16::MIN_POSITIVE / f16::powf(2.0, f16::MANTISSA_DIGITS as f16 - 1.0) + } - // fn max_subnorm() -> f16 { - // f16::MIN_POSITIVE - min_subnorm() - // } + fn max_subnorm() -> f16 { + f16::MIN_POSITIVE - min_subnorm() + } fn q_nan() -> f16 { f16::from_bits(f16::NAN.to_bits() | quiet_bit_mask()) @@ -846,12 +844,12 @@ fn test_total_cmp() { assert_eq!(Ordering::Equal, (-1.5_f16).total_cmp(&-1.5)); assert_eq!(Ordering::Equal, (-0.5_f16).total_cmp(&-0.5)); assert_eq!(Ordering::Equal, (-f16::MIN_POSITIVE).total_cmp(&-f16::MIN_POSITIVE)); - // assert_eq!(Ordering::Equal, (-max_subnorm()).total_cmp(&-max_subnorm())); - // assert_eq!(Ordering::Equal, (-min_subnorm()).total_cmp(&-min_subnorm())); + assert_eq!(Ordering::Equal, (-max_subnorm()).total_cmp(&-max_subnorm())); + assert_eq!(Ordering::Equal, (-min_subnorm()).total_cmp(&-min_subnorm())); assert_eq!(Ordering::Equal, (-0.0_f16).total_cmp(&-0.0)); assert_eq!(Ordering::Equal, 0.0_f16.total_cmp(&0.0)); - // assert_eq!(Ordering::Equal, min_subnorm().total_cmp(&min_subnorm())); - // assert_eq!(Ordering::Equal, max_subnorm().total_cmp(&max_subnorm())); + assert_eq!(Ordering::Equal, min_subnorm().total_cmp(&min_subnorm())); + assert_eq!(Ordering::Equal, max_subnorm().total_cmp(&max_subnorm())); assert_eq!(Ordering::Equal, f16::MIN_POSITIVE.total_cmp(&f16::MIN_POSITIVE)); assert_eq!(Ordering::Equal, 0.5_f16.total_cmp(&0.5)); assert_eq!(Ordering::Equal, 1.0_f16.total_cmp(&1.0)); @@ -870,13 +868,13 @@ fn test_total_cmp() { assert_eq!(Ordering::Less, (-1.5_f16).total_cmp(&-1.0)); assert_eq!(Ordering::Less, (-1.0_f16).total_cmp(&-0.5)); assert_eq!(Ordering::Less, (-0.5_f16).total_cmp(&-f16::MIN_POSITIVE)); - // assert_eq!(Ordering::Less, (-f16::MIN_POSITIVE).total_cmp(&-max_subnorm())); - // assert_eq!(Ordering::Less, (-max_subnorm()).total_cmp(&-min_subnorm())); - // assert_eq!(Ordering::Less, (-min_subnorm()).total_cmp(&-0.0)); + assert_eq!(Ordering::Less, (-f16::MIN_POSITIVE).total_cmp(&-max_subnorm())); + assert_eq!(Ordering::Less, (-max_subnorm()).total_cmp(&-min_subnorm())); + assert_eq!(Ordering::Less, (-min_subnorm()).total_cmp(&-0.0)); assert_eq!(Ordering::Less, (-0.0_f16).total_cmp(&0.0)); - // assert_eq!(Ordering::Less, 0.0_f16.total_cmp(&min_subnorm())); - // assert_eq!(Ordering::Less, min_subnorm().total_cmp(&max_subnorm())); - // assert_eq!(Ordering::Less, max_subnorm().total_cmp(&f16::MIN_POSITIVE)); + assert_eq!(Ordering::Less, 0.0_f16.total_cmp(&min_subnorm())); + assert_eq!(Ordering::Less, min_subnorm().total_cmp(&max_subnorm())); + assert_eq!(Ordering::Less, max_subnorm().total_cmp(&f16::MIN_POSITIVE)); assert_eq!(Ordering::Less, f16::MIN_POSITIVE.total_cmp(&0.5)); assert_eq!(Ordering::Less, 0.5_f16.total_cmp(&1.0)); assert_eq!(Ordering::Less, 1.0_f16.total_cmp(&1.5)); @@ -894,13 +892,13 @@ fn test_total_cmp() { assert_eq!(Ordering::Greater, (-1.0_f16).total_cmp(&-1.5)); assert_eq!(Ordering::Greater, (-0.5_f16).total_cmp(&-1.0)); assert_eq!(Ordering::Greater, (-f16::MIN_POSITIVE).total_cmp(&-0.5)); - // assert_eq!(Ordering::Greater, (-max_subnorm()).total_cmp(&-f16::MIN_POSITIVE)); - // assert_eq!(Ordering::Greater, (-min_subnorm()).total_cmp(&-max_subnorm())); - // assert_eq!(Ordering::Greater, (-0.0_f16).total_cmp(&-min_subnorm())); + assert_eq!(Ordering::Greater, (-max_subnorm()).total_cmp(&-f16::MIN_POSITIVE)); + assert_eq!(Ordering::Greater, (-min_subnorm()).total_cmp(&-max_subnorm())); + assert_eq!(Ordering::Greater, (-0.0_f16).total_cmp(&-min_subnorm())); assert_eq!(Ordering::Greater, 0.0_f16.total_cmp(&-0.0)); - // assert_eq!(Ordering::Greater, min_subnorm().total_cmp(&0.0)); - // assert_eq!(Ordering::Greater, max_subnorm().total_cmp(&min_subnorm())); - // assert_eq!(Ordering::Greater, f16::MIN_POSITIVE.total_cmp(&max_subnorm())); + assert_eq!(Ordering::Greater, min_subnorm().total_cmp(&0.0)); + assert_eq!(Ordering::Greater, max_subnorm().total_cmp(&min_subnorm())); + assert_eq!(Ordering::Greater, f16::MIN_POSITIVE.total_cmp(&max_subnorm())); assert_eq!(Ordering::Greater, 0.5_f16.total_cmp(&f16::MIN_POSITIVE)); assert_eq!(Ordering::Greater, 1.0_f16.total_cmp(&0.5)); assert_eq!(Ordering::Greater, 1.5_f16.total_cmp(&1.0)); @@ -918,12 +916,12 @@ fn test_total_cmp() { assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-1.0)); assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-0.5)); assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-f16::MIN_POSITIVE)); - // assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-max_subnorm())); - // assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-min_subnorm())); + assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-max_subnorm())); + assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-min_subnorm())); assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-0.0)); assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&0.0)); - // assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&min_subnorm())); - // assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&max_subnorm())); + assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&min_subnorm())); + assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&max_subnorm())); assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&f16::MIN_POSITIVE)); assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&0.5)); assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&1.0)); @@ -940,12 +938,12 @@ fn test_total_cmp() { assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-1.0)); assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-0.5)); assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-f16::MIN_POSITIVE)); - // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-max_subnorm())); - // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-min_subnorm())); + assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-max_subnorm())); + assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-min_subnorm())); assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-0.0)); assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&0.0)); - // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&min_subnorm())); - // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&max_subnorm())); + assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&min_subnorm())); + assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&max_subnorm())); assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&f16::MIN_POSITIVE)); assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&0.5)); assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&1.0)); diff --git a/library/std/tests/run-time-detect.rs b/library/std/tests/run-time-detect.rs index dd14c0266aa4d..e59ae2f3d7f18 100644 --- a/library/std/tests/run-time-detect.rs +++ b/library/std/tests/run-time-detect.rs @@ -8,6 +8,10 @@ all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")), feature(stdarch_aarch64_feature_detection) )] +#![cfg_attr( + all(target_arch = "s390x", target_os = "linux"), + feature(stdarch_s390x_feature_detection) +)] #![cfg_attr( all(target_arch = "powerpc", target_os = "linux"), feature(stdarch_powerpc_feature_detection) @@ -132,6 +136,32 @@ fn powerpc64_linux() { // tidy-alphabetical-end } +#[test] +#[cfg(all(target_arch = "s390x", target_os = "linux"))] +fn s390x_linux() { + use std::arch::is_s390x_feature_detected; + // tidy-alphabetical-start + println!("deflate-conversion: {}", is_s390x_feature_detected!("deflate-conversion")); + println!("enhanced-sort: {}", is_s390x_feature_detected!("enhanced-sort")); + println!("guarded-storage: {}", is_s390x_feature_detected!("guarded-storage")); + println!("high-word: {}", is_s390x_feature_detected!("high-word")); + println!("nnp-assist: {}", is_s390x_feature_detected!("nnp-assist")); + println!("transactional-execution: {}", is_s390x_feature_detected!("transactional-execution")); + println!("vector-enhancements-1: {}", is_s390x_feature_detected!("vector-enhancements-1")); + println!("vector-enhancements-2: {}", is_s390x_feature_detected!("vector-enhancements-2")); + println!( + "vector-packed-decimal-enhancement-2: {}", + is_s390x_feature_detected!("vector-packed-decimal-enhancement-2") + ); + println!( + "vector-packed-decimal-enhancement: {}", + is_s390x_feature_detected!("vector-packed-decimal-enhancement") + ); + println!("vector-packed-decimal: {}", is_s390x_feature_detected!("vector-packed-decimal")); + println!("vector: {}", is_s390x_feature_detected!("vector")); + // tidy-alphabetical-end +} + #[test] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] fn x86_all() { diff --git a/library/sysroot/Cargo.toml b/library/sysroot/Cargo.toml index 0f6fa2d291ab3..ec6ae31507e05 100644 --- a/library/sysroot/Cargo.toml +++ b/library/sysroot/Cargo.toml @@ -3,7 +3,7 @@ cargo-features = ["public-dependency"] [package] name = "sysroot" version = "0.0.0" -edition = "2021" +edition = "2024" # this is a dummy crate to ensure that all required crates appear in the sysroot [dependencies] diff --git a/library/test/Cargo.toml b/library/test/Cargo.toml index 241ef324b0088..2a32a7dd76eed 100644 --- a/library/test/Cargo.toml +++ b/library/test/Cargo.toml @@ -3,7 +3,7 @@ cargo-features = ["public-dependency"] [package] name = "test" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] getopts = { version = "0.2.21", features = ['rustc-dep-of-std'] } diff --git a/library/unwind/Cargo.toml b/library/unwind/Cargo.toml index 66e8d1a3ffe5f..da60924c2b419 100644 --- a/library/unwind/Cargo.toml +++ b/library/unwind/Cargo.toml @@ -3,7 +3,7 @@ name = "unwind" version = "0.0.0" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/rust.git" -edition = "2021" +edition = "2024" include = [ '/libunwind/*', ] diff --git a/library/windows_targets/Cargo.toml b/library/windows_targets/Cargo.toml index 94d7c8210647c..705c9e0438119 100644 --- a/library/windows_targets/Cargo.toml +++ b/library/windows_targets/Cargo.toml @@ -2,7 +2,7 @@ name = "windows-targets" description = "A drop-in replacement for the real windows-targets crate for use in std only." version = "0.0.0" -edition = "2021" +edition = "2024" [features] # Enable using raw-dylib for Windows imports. diff --git a/library/windows_targets/src/lib.rs b/library/windows_targets/src/lib.rs index 939fab7d5fe62..c7d158584ebd8 100644 --- a/library/windows_targets/src/lib.rs +++ b/library/windows_targets/src/lib.rs @@ -12,7 +12,7 @@ pub macro link { ($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => ( #[cfg_attr(not(target_arch = "x86"), link(name = $library, kind = "raw-dylib", modifiers = "+verbatim"))] #[cfg_attr(target_arch = "x86", link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated"))] - extern $abi { + unsafe extern $abi { $(#[link_name=$link_name])? pub fn $($function)*; } @@ -26,7 +26,7 @@ pub macro link { // libraries below by using an empty extern block. This works because extern blocks are not // connected to the library given in the #[link] attribute. #[link(name = "kernel32")] - extern $abi { + unsafe extern $abi { $(#[link_name=$link_name])? pub fn $($function)*; } From 8c454e39767940f34ba6568fd03eaea3e5852d37 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Fri, 21 Mar 2025 14:59:35 +0000 Subject: [PATCH 5/7] Further mis-merge fixes after comparing against new automation results --- library/core/src/intrinsics/mod.rs | 6 +- library/core/src/num/f128.rs | 2 + library/core/src/num/f16.rs | 2 + library/core/src/num/f32.rs | 2 + library/core/src/num/f64.rs | 2 + library/std/src/os/trusty/io/mod.rs | 4 ++ library/std/src/os/trusty/mod.rs | 3 + library/std/src/sys/pal/trusty/mod.rs | 21 +++++++ library/std/src/sys/random/trusty.rs | 7 +++ library/std/src/sys/stdio/trusty.rs | 81 +++++++++++++++++++++++++++ 10 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 library/std/src/os/trusty/io/mod.rs create mode 100644 library/std/src/os/trusty/mod.rs create mode 100644 library/std/src/sys/pal/trusty/mod.rs create mode 100644 library/std/src/sys/random/trusty.rs create mode 100644 library/std/src/sys/stdio/trusty.rs diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 5f41638e8d780..c7ca4d71c9cf4 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -3496,7 +3496,7 @@ pub fn contract_check_ensures<'a, Ret, C: Fn(&'a Ret) -> bool>(ret: &'a Ret, con // function used to have a dummy body, but no longer has since // https://github.com/rust-lang/rust/pull/137489 has been merged). // #[requires(ub_checks::can_dereference(_ptr as *const [usize; 3]))] -pub unsafe fn vtable_size(ptr: *const ()) -> usize; +pub unsafe fn vtable_size(_ptr: *const ()) -> usize; /// The intrinsic will return the alignment stored in that vtable. /// @@ -3511,8 +3511,8 @@ pub unsafe fn vtable_size(ptr: *const ()) -> usize; // TODO: we can no longer do this given https://github.com/model-checking/kani/issues/3325 (this // function used to have a dummy body, but no longer has since // https://github.com/rust-lang/rust/pull/137489 has been merged). -// #[requires(ub_checks::can_dereference(ptr as *const [usize; 3]))] -pub unsafe fn vtable_align(ptr: *const ()) -> usize; +// #[requires(ub_checks::can_dereference(_ptr as *const [usize; 3]))] +pub unsafe fn vtable_align(_ptr: *const ()) -> usize; /// The size of a type in bytes. /// diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index 325fa4b357ed8..bf19d82d34102 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -20,6 +20,8 @@ use crate::num::FpCategory; use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; +use crate::num::FpCategory; +use crate::panic::const_assert; use crate::{intrinsics, mem}; /// Basic mathematical constants. diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index 9583742322659..54e9b5eec198b 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -20,6 +20,8 @@ use crate::num::FpCategory; use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; +use crate::num::FpCategory; +use crate::panic::const_assert; use crate::{intrinsics, mem}; /// Basic mathematical constants. diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 39897fbf1da9c..cf0cb418ebd24 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -20,6 +20,8 @@ use crate::num::FpCategory; use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; +use crate::num::FpCategory; +use crate::panic::const_assert; use crate::{intrinsics, mem}; /// The radix or base of the internal representation of `f32`. diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index f54ba1a0a6d9f..1e4732e590d3a 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -20,6 +20,8 @@ use crate::num::FpCategory; use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; +use crate::num::FpCategory; +use crate::panic::const_assert; use crate::{intrinsics, mem}; /// The radix or base of the internal representation of `f64`. diff --git a/library/std/src/os/trusty/io/mod.rs b/library/std/src/os/trusty/io/mod.rs new file mode 100644 index 0000000000000..4cfd448305b65 --- /dev/null +++ b/library/std/src/os/trusty/io/mod.rs @@ -0,0 +1,4 @@ +#![stable(feature = "os_fd", since = "1.66.0")] + +#[stable(feature = "os_fd", since = "1.66.0")] +pub use crate::os::fd::*; diff --git a/library/std/src/os/trusty/mod.rs b/library/std/src/os/trusty/mod.rs new file mode 100644 index 0000000000000..cc67c92d7ff47 --- /dev/null +++ b/library/std/src/os/trusty/mod.rs @@ -0,0 +1,3 @@ +#![stable(feature = "rust1", since = "1.0.0")] + +pub mod io; diff --git a/library/std/src/sys/pal/trusty/mod.rs b/library/std/src/sys/pal/trusty/mod.rs new file mode 100644 index 0000000000000..7034b643d8e8e --- /dev/null +++ b/library/std/src/sys/pal/trusty/mod.rs @@ -0,0 +1,21 @@ +//! System bindings for the Trusty OS. + +#[path = "../unsupported/args.rs"] +pub mod args; +#[path = "../unsupported/common.rs"] +#[deny(unsafe_op_in_unsafe_fn)] +mod common; +#[path = "../unsupported/env.rs"] +pub mod env; +#[path = "../unsupported/os.rs"] +pub mod os; +#[path = "../unsupported/pipe.rs"] +pub mod pipe; +#[path = "../unsupported/process.rs"] +pub mod process; +#[path = "../unsupported/thread.rs"] +pub mod thread; +#[path = "../unsupported/time.rs"] +pub mod time; + +pub use common::*; diff --git a/library/std/src/sys/random/trusty.rs b/library/std/src/sys/random/trusty.rs new file mode 100644 index 0000000000000..da6ca3eea2426 --- /dev/null +++ b/library/std/src/sys/random/trusty.rs @@ -0,0 +1,7 @@ +extern "C" { + fn trusty_rng_secure_rand(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t); +} + +pub fn fill_bytes(bytes: &mut [u8]) { + unsafe { trusty_rng_secure_rand(bytes.as_mut_ptr().cast(), bytes.len()) } +} diff --git a/library/std/src/sys/stdio/trusty.rs b/library/std/src/sys/stdio/trusty.rs new file mode 100644 index 0000000000000..d393e95394d1a --- /dev/null +++ b/library/std/src/sys/stdio/trusty.rs @@ -0,0 +1,81 @@ +use crate::io; + +pub struct Stdin; +pub struct Stdout; +pub struct Stderr; + +impl Stdin { + pub const fn new() -> Stdin { + Stdin + } +} + +impl io::Read for Stdin { + fn read(&mut self, _buf: &mut [u8]) -> io::Result { + Ok(0) + } +} + +impl Stdout { + pub const fn new() -> Stdout { + Stdout + } +} + +impl io::Write for Stdout { + fn write(&mut self, buf: &[u8]) -> io::Result { + _write(libc::STDOUT_FILENO, buf) + } + + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } +} + +impl Stderr { + pub const fn new() -> Stderr { + Stderr + } +} + +impl io::Write for Stderr { + fn write(&mut self, buf: &[u8]) -> io::Result { + _write(libc::STDERR_FILENO, buf) + } + + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } +} + +pub const STDIN_BUF_SIZE: usize = 0; + +pub fn is_ebadf(_err: &io::Error) -> bool { + true +} + +pub fn panic_output() -> Option { + Some(Stderr) +} + +fn _write(fd: i32, message: &[u8]) -> io::Result { + let mut iov = libc::iovec { iov_base: message.as_ptr() as *mut _, iov_len: message.len() }; + loop { + // SAFETY: syscall, safe arguments. + let ret = unsafe { libc::writev(fd, &iov, 1) }; + if ret < 0 { + return Err(io::Error::last_os_error()); + } + let ret = ret as usize; + if ret > iov.iov_len { + return Err(io::Error::last_os_error()); + } + if ret == iov.iov_len { + return Ok(message.len()); + } + // SAFETY: ret has been checked to be less than the length of + // the buffer + iov.iov_base = unsafe { iov.iov_base.add(ret) }; + iov.iov_len -= ret; + } +} From 32ed2435c7945e3494a42735020b8d25d787e798 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Fri, 21 Mar 2025 15:55:23 +0000 Subject: [PATCH 6/7] Fix-up merge --- library/core/src/num/f128.rs | 2 -- library/core/src/num/f16.rs | 2 -- library/core/src/num/f32.rs | 2 -- library/core/src/num/f64.rs | 2 -- 4 files changed, 8 deletions(-) diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index bf19d82d34102..84fcc52126e84 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -16,8 +16,6 @@ use safety::requires; use crate::convert::FloatToInt; #[cfg(kani)] use crate::kani; -use crate::num::FpCategory; -use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; use crate::num::FpCategory; diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index 54e9b5eec198b..c8b2adc55efdb 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -16,8 +16,6 @@ use safety::requires; use crate::convert::FloatToInt; #[cfg(kani)] use crate::kani; -use crate::num::FpCategory; -use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; use crate::num::FpCategory; diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index cf0cb418ebd24..31a1b371b21bd 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -16,8 +16,6 @@ use safety::requires; use crate::convert::FloatToInt; #[cfg(kani)] use crate::kani; -use crate::num::FpCategory; -use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; use crate::num::FpCategory; diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index 1e4732e590d3a..702cd8571d730 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -16,8 +16,6 @@ use safety::requires; use crate::convert::FloatToInt; #[cfg(kani)] use crate::kani; -use crate::num::FpCategory; -use crate::panic::const_assert; #[allow(unused_imports)] use crate::ub_checks::float_to_int_in_range; use crate::num::FpCategory; From 7186e4f36ed84bbe5c778981721a6179d99a702f Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Fri, 21 Mar 2025 16:34:52 +0000 Subject: [PATCH 7/7] fmt --- library/core/src/num/f128.rs | 4 ++-- library/core/src/num/f16.rs | 4 ++-- library/core/src/num/f32.rs | 4 ++-- library/core/src/num/f64.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index 84fcc52126e84..325fa4b357ed8 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -16,10 +16,10 @@ use safety::requires; use crate::convert::FloatToInt; #[cfg(kani)] use crate::kani; -#[allow(unused_imports)] -use crate::ub_checks::float_to_int_in_range; use crate::num::FpCategory; use crate::panic::const_assert; +#[allow(unused_imports)] +use crate::ub_checks::float_to_int_in_range; use crate::{intrinsics, mem}; /// Basic mathematical constants. diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index c8b2adc55efdb..9583742322659 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -16,10 +16,10 @@ use safety::requires; use crate::convert::FloatToInt; #[cfg(kani)] use crate::kani; -#[allow(unused_imports)] -use crate::ub_checks::float_to_int_in_range; use crate::num::FpCategory; use crate::panic::const_assert; +#[allow(unused_imports)] +use crate::ub_checks::float_to_int_in_range; use crate::{intrinsics, mem}; /// Basic mathematical constants. diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 31a1b371b21bd..39897fbf1da9c 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -16,10 +16,10 @@ use safety::requires; use crate::convert::FloatToInt; #[cfg(kani)] use crate::kani; -#[allow(unused_imports)] -use crate::ub_checks::float_to_int_in_range; use crate::num::FpCategory; use crate::panic::const_assert; +#[allow(unused_imports)] +use crate::ub_checks::float_to_int_in_range; use crate::{intrinsics, mem}; /// The radix or base of the internal representation of `f32`. diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index 702cd8571d730..f54ba1a0a6d9f 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -16,10 +16,10 @@ use safety::requires; use crate::convert::FloatToInt; #[cfg(kani)] use crate::kani; -#[allow(unused_imports)] -use crate::ub_checks::float_to_int_in_range; use crate::num::FpCategory; use crate::panic::const_assert; +#[allow(unused_imports)] +use crate::ub_checks::float_to_int_in_range; use crate::{intrinsics, mem}; /// The radix or base of the internal representation of `f64`.