about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2025-01-30Rollup merge of #136259 - hkBst:patch-30, r=thomccStuart Cook-31/+27
Cleanup docs for Allocator This is an attempt to remove ungrammatical constructions and clean up the prose. I've sometimes had to try hard to understand what was being stated, so it is possible that I've misunderstood the original meaning. In particular, I did not see a difference between: - the borrow-checker lifetime of the allocator type itself. - as long as at least one of the allocator instance and all of its clones has not been dropped.
2025-01-30Rollup merge of #135847 - edwloef:slice_ptr_rotate_opt, r=scottmcmStuart Cook-152/+182
optimize slice::ptr_rotate for small rotates r? `@scottmcm` This swaps the positions and numberings of algorithms 1 and 2 in `slice::ptr_rotate`, and pulls the entire outer loop into algorithm 3 since it was redundant for the first two. Effectively, `ptr_rotate` now always does the `memcpy`+`memmove`+`memcpy` sequence if the shifts fit into the stack buffer. With this change, an `IndexMap`-style `move_index` function is optimized correctly. Assembly comparisons: - `move_index`, before: https://godbolt.org/z/Kr616KnYM - `move_index`, after: https://godbolt.org/z/1aoov6j8h - the code from `#89714`, before: https://godbolt.org/z/Y4zaPxEG6 - the code from `#89714`, after: https://godbolt.org/z/1dPx83axc related to #89714 some relevant discussion in https://internals.rust-lang.org/t/idea-shift-move-to-efficiently-move-elements-in-a-vec/22184 Behavior tests pass locally. I can't get any consistent microbenchmark results on my machine, but the assembly diffs look promising.
2025-01-29Cleanup docs for AllocatorMarijn Schouten-31/+27
2025-01-29add inline attribute and codegen testedwloef-0/+4
2025-01-29split slice::ptr_rotate into three separate algorithms, to hopefully help ↵edwloef-174/+195
inlining
2025-01-29Rollup merge of #135625 - c410-f3r:cfg-match-foo-bar-baz, r=tgross35,jhprattLeón Orell Valerian Liehr-0/+11
[cfg_match] Document the use of expressions. cc #115585 Adds documentation to this new feature introduced in #133720.
2025-01-28Auto merge of #136203 - matthiaskrgr:rollup-1k0f44l, r=matthiaskrgrbors-8/+10
Rollup of 9 pull requests Successful merges: - #135869 (Make docs for AtomicUsize::from_mut platform-independent) - #135892 (-Znext-solver: "normalize" signature before checking it mentions self in `deduce_closure_signature`) - #136055 (Implement MIR const trait stability checks) - #136066 (Pass spans to `perform_locally_in_new_solver`) - #136071 ([Clippy] Add vec_reserve & vecdeque_reserve diagnostic items) - #136124 (Arbitrary self types v2: explain test.) - #136149 (Flip the `rustc-rayon`/`indexmap` dependency order) - #136173 (Update comments and sort target_arch in c_char_definition) - #136178 (Update username in build helper example) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-28Rollup merge of #136173 - taiki-e:c-char, r=tgross35Matthias Krüger-7/+9
Update comments and sort target_arch in c_char_definition Follow-up to https://github.com/rust-lang/rust/pull/132975. - Clang's wrong default on MSP430 has been fixed in https://github.com/llvm/llvm-project/pull/115964, and will be included in LLVM 20, which will be used soon. - Add a reference on Xtensa's default (from https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240). - Fix link for Windows's default. - Add a link to the discussion on L4Re (https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240) - Sort `target_arch`. (now match with `target_arch`s in comments) r? `@tgross35`
2025-01-28Rollup merge of #135869 - hkBst:patch-12, r=NoratriebMatthias Krüger-1/+1
Make docs for AtomicUsize::from_mut platform-independent fixes #133342
2025-01-28Rollup merge of #135886 - hkBst:patch-14, r=workingjubileeMatthias Krüger-2/+2
Document purpose of closure in from_fn.rs more clearly partial fix for #135087 together with https://github.com/rust-lang/rust/pull/135895
2025-01-28Rollup merge of #133829 - GrigorenkoPV:fetch_update_infallible, r=NoratriebMatthias Krüger-3/+374
Implement `AtomicT::update` & `AtomicT::try_update` ACP accepted in https://github.com/rust-lang/libs-team/issues/490 ``@rustbot`` label +T-libs-api
2025-01-28Fix platform-specific doc string for AtomicUsize::from_mut to be ↵Marijn Schouten-1/+1
platform-independent
2025-01-28Update comments and sort target_arch in c_char_definitionTaiki Endo-7/+9
2025-01-27Rollup merge of #135807 - jhpratt:phantom-variance, r=AmanieuGuillaume Gomez-0/+267
Implement phantom variance markers ACP accepted https://github.com/rust-lang/libs-team/issues/488 Tracking issue #135806
2025-01-27Rollup merge of #135773 - hkBst:patch-10, r=tgross35Guillaume Gomez-4/+9
Clarify WindowsMut (Lending)Iterator fixes #133628
2025-01-27Clarify WindowsMut (Lending)IteratorMarijn Schouten-4/+9
fixes 133628
2025-01-27Auto merge of #136116 - fmease:rollup-c8pk3mj, r=fmeasebors-13/+13
Rollup of 8 pull requests Successful merges: - #126604 (Uplift `clippy::double_neg` lint as `double_negations`) - #135158 (Add `TooGeneric` variant to `LayoutError` and emit `Unknown`) - #135635 (Move `std::io::pipe` code into its own file) - #136072 (add two old crash tests) - #136079 (compiler_fence: fix example) - #136091 (Add some tracing to core bootstrap logic) - #136097 (rustc_ast: replace some len-checks + indexing with slice patterns etc.) - #136101 (triagebot: set myself on vacation) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-27Auto merge of #135937 - bjorn3:separate_coretests_crate, r=jieyouxu,tgross35bors-29164/+1
Put the core unit tests in a separate coretests package Having standard library tests in the same package as a standard library crate has bad side effects. It causes the test to have a dependency on a locally built standard library crate, while also indirectly depending on it through libtest. Currently this works out fine in the context of rust's build system as both copies are identical, but for example in cg_clif's tests I've found it basically impossible to compile both copies with the exact same compiler flags and thus the two copies would cause lang item conflicts. This PR moves the tests of libcore to a separate package which doesn't depend on libcore, thus preventing the duplicate crates even when compiler flags don't exactly match between building the sysroot (for libtest) and building the test itself. The rest of the standard library crates do still have this issue however.
2025-01-27Rollup merge of #136079 - RalfJung:compiler-fence-example, r=jhprattLeón Orell Valerian Liehr-13/+13
compiler_fence: fix example The old example was wrong, an acquire fence is required in the signal handler. To make the point more clear, I changed the "data" variable to use non-atomic accesses. Fixes https://github.com/rust-lang/rust/issues/133014
2025-01-26compiler_fence: fix exampleRalf Jung-13/+13
2025-01-26Document purpose of closure in from_fn.rs more clearlyMarijn Schouten-2/+2
2025-01-26Auto merge of #136087 - jhpratt:rollup-tam1mzn, r=jhprattbors-0/+7
Rollup of 7 pull requests Successful merges: - #133631 (Support QNX 7.1 with `io-sock`+libstd and QNX 8.0 (`no_std` only)) - #134358 (compiler: Set `target_abi = "ilp32e"` on all riscv32e targets) - #135812 (Fix GDB `OsString` provider on Windows ) - #135842 (TRPL: more backward-compatible Edition changes) - #135946 (Remove extra whitespace from rustdoc breadcrumbs for copypasting) - #135953 (ci.py: check the return code in `run-local`) - #136019 (Add an `unchecked_div` alias to the `Div<NonZero<_>>` impls) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-26Update commentbjorn3-1/+1
2025-01-26Put all coretests in a separate cratebjorn3-29163/+0
2025-01-26Rollup merge of #136019 - scottmcm:alias-unchecked-div, r=Mark-SimulacrumJacob Pratt-0/+7
Add an `unchecked_div` alias to the `Div<NonZero<_>>` impls Inspired by https://github.com/rust-lang/libs-team/issues/526, if people are looking for `unchecked_div`, point them to `u32: Div<NonZero<u32>>` and friends which do no runtime checks -- and are safe! -- rather than today's behaviour of [the intrinsic being the top result](https://doc.rust-lang.org/std/?search=unchecked_div). ![image](https://github.com/user-attachments/assets/cf2a3c06-4876-49c1-8e33-64cd431c772a)
2025-01-26Implement phantom variance markersJacob Pratt-0/+267
2025-01-25Rollup merge of #135948 - bjorn3:update_emscripten_std_tests, r=Mark-SimulacrumJacob Pratt-34/+29
Update emscripten std tests This disables a bunch of emscripten tests that test things emscripten doesn't support and re-enables a whole bunch of tests which now work just fine on emscripten. Tested with `EMCC_CFLAGS="-s MAXIMUM_MEMORY=2GB" ./x.py test library/ --target wasm32-unknown-emscripten`.
2025-01-25Rollup merge of #136039 - nvanbenschoten:pin-typo, r=AmanieuMatthias Krüger-2/+2
docs: fix typo in std::pin overview Unimportant fix in `std::pin` documentation.
2025-01-25Rollup merge of #136005 - BLANKatGITHUB:library, r=RalfJungMatthias Krüger-677/+957
ports last few library files to new intrinsic style This pr ports the last 2 library files to new intrinsic style this pr is part of issue #132735
2025-01-25Rollup merge of #135977 - nyurik:fix-fmt-options, r=joboetMatthias Krüger-1/+16
Fix `FormattingOptions` instantiation with `Default` The `fill` value by default should be set to `' '` (space), but the current implementation uses `#[derive(Default)]` which sets it to `\0`. Note that `FormattingOptions` is being released as part of 1.85 (unstable) - so this might warrant a backport to that branch. Tracking issue: https://github.com/rust-lang/rust/issues/118117 Follow up from https://github.com/rust-lang/rust/pull/118159 CC: ``@EliasHolzmann`` ``@programmerjake`` r? ``@m-ou-se``
2025-01-24docs: fix typo in std::pin overviewNathan VanBenschoten-2/+2
2025-01-24Rollup merge of #135938 - carlsverre:master, r=joboetMatthias Krüger-0/+20
Add memory layout documentation to generic NonZero<T> The documentation I've added is based on the same Layout documentation that appears on the other `NonZero*` types. For example see [the Layout docs on `NonZeroI8`](https://doc.rust-lang.org/std/num/type.NonZeroI8.html#layout-1).
2025-01-24Add an `unchecked_div` alias to the `Div<NonZero<_>>` implsScott McMurray-0/+7
2025-01-24Update library/core/src/num/nonzero.rs Carl Sverre-1/+1
Tweak language Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2025-01-24ports last few library files to new intrinsic styleaaishwarymishra@gmail.com-677/+957
2025-01-24Remove a bunch of emscripten test ignoresbjorn3-34/+29
They are either outdated as emscripten now supports i128 or they are subsumed by #[cfg_attr(not(panic = "unwind"), ignore]
2025-01-24Rollup merge of #135489 - RalfJung:TryFromSliceError, r=tgross35Matthias Krüger-1/+0
remove pointless allowed_through_unstable_modules on TryFromSliceError This got added in https://github.com/rust-lang/rust/pull/132482 but the PR does not explain why. `@lukas-code` do you still remember? Also Cc `@Noratrieb` as reviewer of that PR. If I understand the issue description correctly, all paths under which this type is exported are stable now: `core::array::TryFromSliceError` and `std::array::TryFromSliceError`. If that is the case, we shouldn't have the attribute; it's a terrible hack that should only be used when needed to maintain backward compatibility. Getting some historic information right is IMO *not* sufficient justification to risk accidentally exposing this type via more unstable paths today or in the future.
2025-01-24Fix `FormattingOptions` instantiation with `Default`Yuri Astrakhan-1/+16
The `fill` value by default should be set to `' '` (space), but the current implementation uses `#[derive(Default)]` which sets it to `\0`
2025-01-23Rollup merge of #135073 - joshtriplett:bstr, r=BurntSushiMatthias Krüger-0/+649
Implement `ByteStr` and `ByteString` types Approved ACP: https://github.com/rust-lang/libs-team/issues/502 Tracking issue: https://github.com/rust-lang/rust/issues/134915 These types represent human-readable strings that are conventionally, but not always, UTF-8. The `Debug` impl prints non-UTF-8 bytes using escape sequences, and the `Display` impl uses the Unicode replacement character. This is a minimal implementation of these types and associated trait impls. It does not add any helper methods to other types such as `[u8]` or `Vec<u8>`. I've omitted a few implementations of `AsRef`, `AsMut`, and `Borrow`, when those would be the second implementation for a type (counting the `T` impl), to avoid potential inference failures. We can attempt to add more impls later in standalone commits, and run them through crater. In addition to the `bstr` feature, I've added a `bstr_internals` feature for APIs provided by `core` for use by `alloc` but not currently intended for stabilization. This API and its implementation are based *heavily* on the `bstr` crate by Andrew Gallant (`@BurntSushi).` r? `@BurntSushi`
2025-01-23Add memory layout documentation to generic NonZero<T>Carl Sverre-0/+20
2025-01-22Implement `AtomicT::update` & `AtomicT::try_update`Pavel Grigorenko-3/+374
2025-01-22Implement `CloneToUninit` for `ByteStr`Josh Triplett-0/+10
2025-01-22Add doc aliases for BStr and BStringJosh Triplett-0/+1
2025-01-21Rollup merge of #135750 - scottmcm:cma-example, r=cuviperMatthias Krüger-2/+31
Add an example of using `carrying_mul_add` to write wider multiplication Just the basic quadratic version that you wouldn't actually use for really-big integers, but it's nice and short so is useful as for a demonstration of why you might find `carrying_mul_add` useful :) cc #85532 ``````@clarfonthey``````
2025-01-21optimize slice::ptr_rotate for compile-time-constant small rotatesedwloef-161/+166
2025-01-21[cfg_match] Document the use of expressionsCaio-0/+11
2025-01-20Auto merge of #134286 - Urgau:unreach_pub-std, r=ibraheemdevbors-100/+116
Enable `unreachable_pub` lint in core This PR enables the [`unreachable_pub`](https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unreachable-pub) as warn in `core`, `rtstartup` and `panic_unwind`. The motivation is similar to the compiler [MCP: Enable deny(unreachable_pub) on `rustc_*` crates](https://github.com/rust-lang/compiler-team/issues/773#issue-2467219005) : > "Where is this thing used?" is a question I ask all the time when reading unfamiliar code. Because of this, I generally find it annoying when things are marked with a more permissive visibility than necessary. "This thing marked pub, which other crates is it used in? Oh, it's not used in any other crates." Another motivation is to help to lint by utilizing it in-tree and seeing it's limitation in more complex scenarios. The diff was mostly generated with `./x.py fix --stage 1 library/core/ -- --broken-code`, as well as manual edits for code in macros, generated code and other targets. r? libs
2025-01-20Rollup merge of #135741 - bardiharborow:std/net/rfc9637, r=AmanieuMatthias Krüger-4/+17
Recognise new IPv6 documentation range from IETF RFC 9637 This PR adds the `3fff::/20` range defined by [IETF RFC 9637](https://datatracker.ietf.org/doc/rfc9637/) to those ranges which `Ipv6Addr::is_documentation` recognises as a documentation IP. See also: https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml Unstable tracking issue: #27709
2025-01-20Rollup merge of #133695 - x17jiri:hint_likely, r=AmanieuMatthias Krüger-0/+135
Reexport likely/unlikely in std::hint Since `likely`/`unlikely` should be working now, we could reexport them in `std::hint`. I'm not sure if this is already approved or if it requires approval Tracking issue: #26179
2025-01-20core: `#[allow(unreachable_pub)]` on unreachable `pub use`Urgau-1/+9