about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2024-08-17Auto merge of #126877 - GrigorenkoPV:clone_to_uninit, r=dtolnaybors-105/+150
CloneToUninit impls As per #126799. Also implements it for `Wtf8` and both versions of `os_str::Slice`. Maybe it is worth to slap `#[inline]` on some of those impls. r? `@dtolnay`
2024-08-17Auto merge of #128598 - RalfJung:float-comments, r=workingjubileebors-500/+85
float to/from bits and classify: update for float semantics RFC With https://github.com/rust-lang/rfcs/pull/3514 having been accepted, it is clear that hardware which e.g. flushes subnormal to zero is just non-conformant from a Rust perspective -- this is a hardware bug, or maybe an LLVM backend bug (where LLVM doesn't lower floating-point ops in a way that they have the standardized behavior). So update the comments here to make it clear that we don't have to do any of this, we're just being nice. Also remove the subnormal/NaN checks from the (unstable) const-version of to/from-bits; they are not needed since we decided with the aforementioned RFC that it is okay to get a different result at const-time and at run-time. r? `@workingjubilee` since I think you wrote many of the comments I am editing here.
2024-08-17Auto merge of #106943 - mina86:exact_size_take_repeat, r=dtolnaybors-0/+57
Implement DoubleEnded and ExactSize for Take<Repeat> and Take<RepeatWith> Repeat iterator always returns the same element and behaves the same way backwards and forwards. Take iterator can trivially implement backwards iteration over Repeat inner iterator by simply doing forwards iteration. DoubleEndedIterator is not currently implemented for Take<Repeat<T>> because Repeat doesn’t implement ExactSizeIterator which is a required bound on DEI implementation for Take. Similarly, since Repeat is an infinite iterator which never stops, Take can trivially know how many elements it’s going to return. This allows implementing ExactSizeIterator on Take<Repeat<T>>. While at it, observe that ExactSizeIterator can also be implemented for Take<RepeatWhile<F>> so add that implementation too. Since in contrast to Repeat, RepeatWhile doesn’t guarante to always return the same value, DoubleEndedIterator isn’t implemented. Those changes render core::iter::repeat_n somewhat redundant. Issue: https://github.com/rust-lang/rust/issues/104434 Issue: https://github.com/rust-lang/rust/issues/104729 - [ ] ACP: https://github.com/rust-lang/libs-team/issues/120 (this is actually ACP for repeat_n but this is nearly the same functionality so hijacking it so both approaches can be discussed in one place)
2024-08-16Auto merge of #116528 - daxpedda:stabilize-ready-into-inner, r=dtolnaybors-2/+1
Stabilize `Ready::into_inner()` This PR stabilizes `Ready::into_inner()`. Tracking issue: #101196. Implementation PR: #101189. Closes #101196.
2024-08-16Rollup merge of #129086 - slanterns:is_none_or, r=dtolnayMatthias Krüger-3/+1
Stabilize `is_none_or` Closes: https://github.com/rust-lang/rust/issues/126383. `@rustbot` label: +T-libs-api r? libs-api
2024-08-16float to/from bits and classify: update comments regarding non-conformant ↵Ralf Jung-500/+85
hardware
2024-08-15Rollup merge of #128064 - ijackson:noop-waker-doc, r=workingjubileeJubilee-1/+19
Improve docs for Waker::noop and LocalWaker::noop * Add a warning about a likely misuse. (See my commit message for longer rationale.) * Apply some probably-accidentally-omitted changes to `LocalWaker`'s docs * Add a comment about the clone-and-hack of the docs I have used [semantic linefeeds](https://rhodesmill.org/brandon/2012/one-sentence-per-line/) for the docs formatting.
2024-08-15Add cautionary paragraph about noop wakers.Ian Jackson-0/+8
Based on a suggestion from @kpreid, with some further editing.
2024-08-15Rollup merge of #128946 - orlp:faster-ip-hash, r=joboetMatthias Krüger-2/+23
Hash Ipv*Addr as an integer The `Ipv4Addr` and `Ipv6Addr` structs always have a fixed size, but directly derive `Hash`. This causes them to call the bytestring hasher implementation, which adds extra work for most hashers. This PR converts the internal representation to a fixed-width integer before passing to the hasher to prevent this.
2024-08-15Rollup merge of #128925 - dingxiangfei2009:smart-ptr-helper-attr, ↵Matthias Krüger-1/+1
r=compiler-errors derive(SmartPointer): register helper attributes Fix #128888 This PR enables built-in macros to register helper attributes, if any, to support correct name resolution in the correct lexical scope under the macros. Also, `#[pointee]` is moved into the scope under `derive(SmartPointer)`. cc `@Darksonn` `@davidtwco`
2024-08-14apply #[optimize(size)] to #[cold] ones and part of the panick machineryThe 8472-7/+8
2024-08-14Rollup merge of #128954 - zachs18:fromresidual-no-default, r=scottmcm许杰友 Jieyou Xu (Joe)-2/+6
Explicitly specify type parameter on FromResidual for Option and ControlFlow. ~~Remove type parameter default `R = <Self as Try>::Residual` from `FromResidual`~~ _Specify default type parameter on `FromResidual` impls in the stdlib_ to work around https://github.com/rust-lang/rust/issues/99940 / https://github.com/rust-lang/rust/issues/87350 ~~as mentioned in https://github.com/rust-lang/rust/issues/84277#issuecomment-1773259264~~. This does not completely fix the issue, but works around it for `Option` and `ControlFlow` specifically (`Result` does not have the issue since it already did not use the default parameter of `FromResidual`). ~~(Does this need an ACP or similar?)~~ ~~This probably needs at least an FCP since it changes the API described in [the RFC](https://github.com/rust-lang/rfcs/pull/3058). Not sure if T-lang, T-libs-api, T-libs, or some combination (The tracking issue is tagged T-lang, T-libs-api).~~ This probably doesn't need T-lang input, since it is not changing the API of `FromResidual` from the RFC? Maybe needs T-libs-api FCP?
2024-08-14Rollup merge of #128570 - folkertdev:stabilize-asm-const, r=Amanieu许杰友 Jieyou Xu (Joe)-1/+1
Stabilize `asm_const` tracking issue: https://github.com/rust-lang/rust/issues/93332 reference PR: https://github.com/rust-lang/reference/pull/1556 this will probably require some CI wrangling (and a rebase), so let's get that over with even though the final required PR is not merged yet. r? `@ghost`
2024-08-14stabilize `option_get_or_insert_default`Slanterns-3/+1
2024-08-14stabilize `is_none_or`Slanterns-3/+1
2024-08-14Auto merge of #129060 - matthiaskrgr:rollup-s72gpif, r=matthiaskrgrbors-89/+152
Rollup of 7 pull requests Successful merges: - #122884 (Optimize integer `pow` by removing the exit branch) - #127857 (Allow to customize `// TODO:` comment for deprecated safe autofix) - #129034 (Add `#[must_use]` attribute to `Coroutine` trait) - #129049 (compiletest: Don't panic on unknown JSON-like output lines) - #129050 (Emit a warning instead of an error if `--generate-link-to-definition` is used with other output formats than HTML) - #129056 (Fix one usage of target triple in bootstrap) - #129058 (Add mw back to review rotation) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-14Rollup merge of #129001 - cblh:fix/128713, r=NoratriebMatthias Krüger-0/+5
chore(lib): Enhance documentation for core::fmt::Formatter's write_fm… fix: #128713
2024-08-13stabilize `asm_const`Folkert-1/+1
2024-08-13Rollup merge of #129034 - henryksloan:coroutine-must-use, r=joboetMatthias Krüger-0/+1
Add `#[must_use]` attribute to `Coroutine` trait [Coroutines tracking issue](https://github.com/rust-lang/rust/issues/43122) Like closures (`FnOnce`, `AsyncFn`, etc.), coroutines are lazy and do nothing unless called (resumed). Closure traits like `FnOnce` have `#[must_use = "closures are lazy and do nothing unless called"]` to catch likely bugs for users of APIs that produce them. This PR adds such a `#[must_use]` attribute to `trait Coroutine`.
2024-08-13Rollup merge of #122884 - mzabaluev:pow-remove-exit-branch, r=AmanieuMatthias Krüger-89/+151
Optimize integer `pow` by removing the exit branch The branch at the end of the `pow` implementations is redundant with multiplication code already present in the loop. By rotating the exit check, this branch can be largely removed, improving code size and reducing instruction cache misses. Testing on my machine (`x86_64`, 11th Gen Intel Core i5-1135G7 @ 2.40GHz), the `num::int_pow` benchmarks improve by some 40% for the unchecked operations and show some slight improvement for the checked operations as well.
2024-08-13Mark location doctest as standalone since file information will not work in ↵Guillaume Gomez-1/+1
merged doctest file
2024-08-13simd_shuffle intrinsic: allow argument to be passed as vector (not just as ↵Ralf Jung-1/+1
array)
2024-08-13Revert to original loop for const pow exponentsMikhail Zabaluev-160/+110
Give LLVM the for original, optimizable loop in pow and wrapped_pow functions in the case when the exponent is statically known.
2024-08-12Add must_use attribute to Coroutine traitHenry Sloan-0/+1
2024-08-13chore(lib): fmt core::fmt::Formatter's write_fmt methodburlinchen-1/+1
2024-08-12Rollup merge of #129017 - its-the-shrimp:core_fmt_from_fn, r=NoratriebMatthias Krüger-6/+15
Replace `std::fmt:FormatterFn` with `std::fmt::from_fn` Modelled after the suggestion made in [this](https://github.com/rust-lang/rust/issues/117729#issuecomment-1837628559) comment, this should bring this functionality in line with the existing `array::from_fn` & `iter::from_fn`
2024-08-13derive(SmartPointer): register helper attributesDing Xiang Fei-1/+1
2024-08-12Explicitly specify type parameter on FromResidual impls in stdlib.Zachary S-2/+6
To work around coherence issue. Also adds regression test.
2024-08-12std::fmt::FormatterFn -> std::fmt::FromFnschvv31n-6/+15
2024-08-12Rollup merge of #128149 - RalfJung:nontemporal_store, r=jieyouxu,Amanieu,JubileeGuillaume Gomez-5/+5
nontemporal_store: make sure that the intrinsic is truly just a hint The `!nontemporal` flag for stores in LLVM *sounds* like it is just a hint, but actually, it is not -- at least on x86, non-temporal stores need very special treatment by the programmer or else the Rust memory model breaks down. LLVM still treats these stores as-if they were normal stores for optimizations, which is [highly dubious](https://github.com/llvm/llvm-project/issues/64521). Let's avoid all that dubiousness by making our own non-temporal stores be truly just a hint, which is possible on some targets (e.g. ARM). On all other targets, non-temporal stores become regular stores. ~~Blocked on https://github.com/rust-lang/stdarch/pull/1541 propagating to the rustc repo, to make sure the `_mm_stream` intrinsics are unaffected by this change.~~ Fixes https://github.com/rust-lang/rust/issues/114582 Cc `@Amanieu` `@workingjubilee`
2024-08-12chore(lib): Enhance documentation for core::fmt::Formatter's write_fmt methodburlinchen-0/+5
2024-08-12core: make documentation clearer, rename slice comparison specialization traitjoboet-15/+25
2024-08-12Auto merge of #128862 - cblh:fix/128855, r=scottmcmbors-0/+1
fix: #128855 Ensure `Guard`'s `drop` method is removed at `opt-level=s` for `… fix: #128855 …Copy` types Added `#[inline]` to the `drop` method in the `Guard` implementation to ensure that the method is removed by the compiler at optimization level `opt-level=s` for `Copy` types. This change aims to align the method's behavior with optimization expectations and ensure it does not affect performance. r​? `@scottmcm`
2024-08-12Auto merge of #126793 - saethlin:mono-rawvec, r=scottmcmbors-0/+5
Apply "polymorphization at home" to RawVec The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times. This uncovered https://github.com/rust-lang/rust-clippy/issues/12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
2024-08-11Do not use unnecessary endian conversion.Orson Peters-6/+4
2024-08-11Rollup merge of #128882 - RalfJung:local-waker-will-wake, r=cuviperMatthias Krüger-1/+7
make LocalWaker::will_wake consistent with Waker::will_wake This mirrors https://github.com/rust-lang/rust/pull/119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (https://github.com/rust-lang/rust/pull/118960).
2024-08-11Rollup merge of #120314 - mina86:i, r=Mark-SimulacrumMatthias Krüger-19/+13
core: optimise Debug impl for ascii::Char Rather than writing character at a time, optimise Debug implementation for core::ascii::Char such that it writes the entire representation with a single write_str call. With that, add tests for Display and Debug. Issue: https://github.com/rust-lang/rust/issues/110998
2024-08-11Fix stability annotation and expand commentOrson Peters-2/+8
2024-08-10Hash Ipv*Addr as an integerOrson Peters-2/+19
2024-08-10Auto merge of #128927 - GuillaumeGomez:rollup-ei2lr0f, r=GuillaumeGomezbors-49/+73
Rollup of 8 pull requests Successful merges: - #128273 (Improve `Ord` violation help) - #128807 (run-make: explaing why fmt-write-bloat is ignore-windows) - #128903 (rustdoc-json-types `Discriminant`: fix typo) - #128905 (gitignore: Add Zed and Helix editors) - #128908 (diagnostics: do not warn when a lifetime bound infers itself) - #128909 (Fix dump-ice-to-disk for RUSTC_ICE=0 users) - #128910 (Differentiate between methods and associated functions in diagnostics) - #128923 ([rustdoc] Stop showing impl items for negative impls) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-10Rollup merge of #128273 - Voultapher:improve-ord-violation-help, ↵Guillaume Gomez-49/+73
r=workingjubilee Improve `Ord` violation help Recent experience in #128083 showed that the panic message when an Ord violation is detected by the new sort implementations can be confusing. So this PR aims to improve it, together with minor bug fixes in the doc comments for sort*, sort_unstable* and select_nth_unstable*. Is it possible to get these changes into the 1.81 release? It doesn't change behavior and would greatly help when users encounter this panic for the first time, which they may after upgrading to 1.81. Tagging `@orlp`
2024-08-10Update std and compilerNadrieril-1/+1
2024-08-09Polymorphize RawVecBen Kimock-0/+5
2024-08-09core: optimise Debug impl for ascii::CharMichal Nazarewicz-19/+13
Rather than writing character at a time, optimise Debug implementation for core::ascii::Char such that it writes the entire representation as with a single write_str call. With that, add tests for Display and Debug implementations.
2024-08-09make LocalWaker::will_wake consistent with Waker::will_wakeRalf Jung-1/+7
2024-08-09Fix linkchecker issueLukas Bergdoll-1/+1
2024-08-09fix: Ensure `Guard`'s `drop` method is removed at `opt-level=s` for `Copy` typesburlinchen-0/+1
Added `#[inline]` to the `drop` method in the `Guard` implementation to ensure that the method is removed by the compiler at optimization level `opt-level=s` for `Copy` types. This change aims to align the method's behavior with optimization expectations and ensure it does not affect performance.
2024-08-08Rollup merge of #128749 - tgross35:float-inline, r=scottmcmMatthias Krüger-0/+6
Mark `{f32,f64}::{next_up,next_down,midpoint}` inline Most float functions are marked `#[inline]` so any float symbols used by these functions only need to be provided if the function itself is used. RFL recently noticed that `next_up`, `next_down`, and `midpoint` for `f32` and `f64` are not inline, which causes linker errors when building with certain configurations <https://lore.kernel.org/all/20240806150619.192882-1-ojeda@kernel.org/>. Add the missing attributes so the symbols should no longer be required.
2024-08-08Rollup merge of #128306 - ↵Matthias Krüger-3/+10
WiktorPrzetacznik:WiktorPrzetacznik-nonnull-alignoffset-update, r=Amanieu Update NonNull::align_offset quarantees This PR proposes to update [`NonNull::align_offset`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.align_offset) guarantees, which should to be matched with [`ptr::align_offset`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.align_offset-1) (as `NonNull::align_offset` delegates to `ptr::align_offset`). [PR #121201](https://github.com/rust-lang/rust/pull/121201) updated only `ptr::align_offset` docs.
2024-08-07Add tracking issue to core-pattern-typeltdk-2/+2