about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2025-07-08Auto merge of #134628 - estebank:const-default, r=oli-obkbors-15/+34
Make `Default` const and add some `const Default` impls Full list of `impl const Default` types: - () - bool - char - std::ascii::Char - usize - u8 - u16 - u32 - u64 - u128 - i8 - i16 - i32 - i64 - i128 - f16 - f32 - f64 - f128 - std::marker::PhantomData<T> - Option<T> - std::iter::Empty<T> - std::ptr::Alignment - &[T] - &mut [T] - &str - &mut str - String - Vec<T>
2025-07-08Auto merge of #143540 - yotamofek:pr/library/simplify-num-fmt, r=tgross35bors-22/+3
Simplify num formatting helpers Noticed `ilog10` was being open-coded when looking at this diff: https://github.com/rust-lang/rust/pull/143423/files/85d6768f4c437a0f3799234df20535ff65ee17c2..76d9775912ef3a7ee145053a5119538bf229d6e5#diff-6be9b44b52d946ccac652ddb7c98146a01b22ea0fc5737bc10db245a24796a45 That, and two other small cleanups 😁 (should probably go through perf just to make sure it doesn't regress formatting)
2025-07-08Rollup merge of #143608 - codexarafat:fix-string-doc, r=NoratriebMatthias Krüger-1/+1
Fix in std::String docs This PR removes the word “else” from the sentence ('something else similar') in the String documentation to improve clarity. Fixes rust-lang/rust#143579.
2025-07-08Rollup merge of #142098 - GuillaumeGomez:int_format_into, r=AmanieuMatthias Krüger-82/+325
Implement `int_format_into` feature I took over rust-lang/rust#138338 with `@madhav-madhusoodanan's` approval. Since https://github.com/rust-lang/rust/pull/136264, a lot of changes happened so I made use of them to reduce the number of changes. ACP approval: https://github.com/rust-lang/libs-team/issues/546#issuecomment-2707244569 ## Associated Issue - https://github.com/rust-lang/rust/issues/138215 r? `@hanna-kruppe`
2025-07-07Make `Default` const and add some `const Default` implsEsteban Küber-15/+34
Full list of `impl const Default` types: - () - bool - char - Cell - std::ascii::Char - usize - u8 - u16 - u32 - u64 - u128 - i8 - i16 - i32 - i64 - i128 - f16 - f32 - f64 - f128 - std::marker::PhantomData<T> - Option<T> - std::iter::Empty<T> - std::ptr::Alignment - &[T] - &mut [T] - &str - &mut str - String - Vec<T>
2025-07-08Fix in String docs: remove 'else' from 'something else similar'Md. Yeasin Arafat-1/+1
2025-07-07Rollup merge of #143340 - nabijaczleweli:awhile, r=mati865Matthias Krüger-2/+2
awhile -> a while where appropriate
2025-07-07Rollup merge of #143563 - xizheyin:fix-typo, r=joshtriplett许杰友 Jieyou Xu (Joe)-2/+2
std: fix typo in `std::path` I noticed that most of the document used `'` instead of `’`, so I adjusted it. r? `@ibraheemdev`
2025-07-07Rollup merge of #143130 - xizheyin:142966, r=ibraheemdev许杰友 Jieyou Xu (Joe)-0/+9
doc(std): clarify `NonZero<T>` usage limitation in doc comment Closes rust-lang/rust#142966 This PR clarifies `NonZero<T>` usage limitation in doc comment and fixes a typo. r? libs
2025-07-07std: fix typo in `std::path`xizheyin-2/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-07doc(std): clarify `NonZero<T>` usage limitation in doc commentxizheyin-0/+9
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-07Auto merge of #143556 - jhpratt:rollup-nid39y2, r=jhprattbors-51/+14
Rollup of 9 pull requests Successful merges: - rust-lang/rust#143206 (Align attr fixes) - rust-lang/rust#143236 (Stabilize `mixed_integer_ops_unsigned_sub`) - rust-lang/rust#143344 (Port `#[path]` to the new attribute parsing infrastructure ) - rust-lang/rust#143359 (Link to 2024 edition page for `!` fallback changes) - rust-lang/rust#143456 (mbe: Change `unused_macro_rules` to a `DenseBitSet`) - rust-lang/rust#143529 (Renamed retain_mut to retain on LinkedList as mentioned in the ACP) - rust-lang/rust#143535 (Remove duplicate word) - rust-lang/rust#143544 (compiler: rename BareFn to FnPtr) - rust-lang/rust#143552 (lib: more eagerly return `self.len()` from `ceil_char_boundary`) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-07Rollup merge of #143552 - nagisa:makes-ceil-char-boundary-go-zoom, r=jhprattJacob Pratt-1/+1
lib: more eagerly return `self.len()` from `ceil_char_boundary` There is no reason to go through the complicated branch as it would always return `self.len()` in this case. Also helps debug code somewhat and I guess might make optimizations easier (although I haven't really a sample to demonstrate this.) ref. https://github.com/rust-lang/rust/issues/93743 Suggested by `@chrisduerr`
2025-07-07Rollup merge of #143529 - pixel27:master, r=jhprattJacob Pratt-37/+2
Renamed retain_mut to retain on LinkedList as mentioned in the ACP This is for proposal: https://github.com/rust-lang/libs-team/issues/250 The original check-in (https://github.com/rust-lang/rust/pull/114136) contained both methods **retain** and **retain_mut**, which does not conform to https://github.com/rust-lang/libs-team/issues/250#issuecomment-1766822671. I updated the retain documentation to specify **&mut e**, removed the **retain** method and renamed **retain_mut** to **retain** to conform to the request. The pull request doesn't really contain much that is new, just removes the unwanted method to meet the requirements. I've run the tests "library/alloc" on the code and no issues. Hopefully I'm not stepping on the original author's toes. I just ran across a need for the method and wondered why it was unstable.
2025-07-07Rollup merge of #143359 - clubby789:fallback-2024-doc, r=ibraheemdevJacob Pratt-5/+3
Link to 2024 edition page for `!` fallback changes Closes rust-lang/rust#143207
2025-07-07Rollup merge of #143236 - nxsaken:mixed_integer_ops_unsigned_sub, r=ibraheemdevJacob Pratt-8/+8
Stabilize `mixed_integer_ops_unsigned_sub` Closes rust-lang/rust#126043.
2025-07-07lib: more eagerly return `self.len()` from `ceil_char_boundary`Simonas Kazlauskas-1/+1
There is no reason to go through the complicated branch as it would always return `self.len()` in this case. Also helps debug code somewhat and I guess might make optimizations easier (although I haven't really a sample to demonstrate this.) ref. #93743 Suggested by @chrisduerr
2025-07-06Auto merge of #141829 - dvdsk:sleep_until_linux, r=cuviper,RalfJungbors-25/+219
Specialize sleep_until implementation for unix (except mac) related tracking issue: https://github.com/rust-lang/rust/issues/113752 Supersedes https://github.com/rust-lang/rust/pull/118480 for the reasons see: https://github.com/rust-lang/rust/issues/113752#issuecomment-2902594469 Replaces the generic catch all implementation with target_os specific ones for: linux/netbsd/freebsd/android/solaris/illumos etc. Other platforms like wasi, macos/ios/tvos/watchos and windows will follow in later separate PR's (once this is merged).
2025-07-06Simplify num formatting helpersYotam Ofek-22/+3
2025-07-06sleep_until: add clock_nanosleep support to Miridvdsk-0/+1
The clock_nanosleep support is there to allow code using `sleep_until` to run under Miri. Therefore the implementation is minimal. - Only the clocks REALTIME and MONOTONIC are supported. The first is supported simply because it was trivial to add not because it was needed for sleep_until. - The only supported flag combinations are no flags or TIMER_ABSTIME only. If an unsupported flag combination or clock is passed in this throws unsupported.
2025-07-06sleep_until: use clock_nanosleep where possibledvdsk-25/+218
Using clock nanosleep leads to more accurate sleep times on platforms where it is supported. To enable using clock_nanosleep this makes `sleep_until` platform specific. That unfortunatly requires identical placeholder implementations for the other platforms (windows/mac/wasm etc). we will land platform specific implementations for those later. See the `sleep_until` tracking issue. This requires an accessors for the Instant type. As that accessor is only used on the platforms that have clock_nanosleep it is marked as allow_unused. 32bit time_t targets do not use clock_nanosleep atm, they instead rely on the same placeholder as the other platforms. We could make them use clock_nanosleep too in the future using `__clock_nanosleep_time64`. __clock_nanosleep_time64 is documented at: https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html
2025-07-06Renamed retain_mut to retain on LinkedList as mentioned in the ACPJoshua Gentry-37/+2
2025-07-06Rollup merge of #143477 - folkertdev:use-is-multiple-of, r=joshtriplettMatthias Krüger-13/+13
use `is_multiple_of` and `div_ceil` In tricky logic, these functions are much more informative than the manual implementations. They also catch subtle bugs: - the manual `is_multiple_of` often does not handle division by zero - manual `div_ceil` often does not consider overflow The transformation is free for `is_multiple_of` if the divisor is compile-time known to be non-zero. For `div_ceil` there is a small cost to considering overflow. Here is some assembly https://godbolt.org/z/5zP8KaE1d.
2025-07-06Rollup merge of #143470 - Ayush1325:uefi-tcp4-recv, r=joshtriplettMatthias Krüger-6/+52
std: sys: net: uefi: tcp4: Implement read - A blocking implementation of tcp4 read. - Basically a copy of [write](https://github.com/rust-lang/rust/pull/141532)
2025-07-05Rollup merge of #143445 - folkertdev:va-list-intrinsics, r=RalfJungBen Kimock-17/+24
move `va_copy`, `va_arg` and `va_end` to `core::intrinsics` some questions: - should these functions be `pub`? - is a separate module justified? r? `@RalfJung`
2025-07-05use `div_ceil` instead of manual logicFolkert de Vries-6/+6
2025-07-05use `is_multiple_of` instead of manual moduloFolkert de Vries-7/+7
2025-07-05move the `va_copy`, `va_arg` and `va_end` to `core::intrinsics`Folkert de Vries-17/+24
2025-07-04Rollup merge of #143086 - SciMind2460:patch-2, r=workingjubileeJubilee-1/+1
Update poison.rs to fix the typo (sys->sync)
2025-07-04Rollup merge of #143040 - SciMind2460:patch-1, r=workingjubileeJubilee-1/+1
Add `const Rem`
2025-07-05std: sys: net: uefi: tcp4: Implement readAyush Singh-6/+52
A blocking implementation of tcp4 read. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-07-04Make Rem const for floatsKurt Heiritz (pseudo)-1/+1
2025-07-05Rollup merge of #141532 - Ayush1325:uefi-tcp4-send, r=tgross35Matthias Krüger-6/+53
std: sys: net: uefi: tcp4: Implement write A blocking implementation of tcp4 write.
2025-07-04std: sys: net: uefi: tcp4: Implement writeAyush Singh-6/+53
A blocking implementation of tcp4 write. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-07-04Rollup merge of #143387 - dpaoliello:shouldpanicfn, r=bjorn3Matthias Krüger-4/+4
Make __rust_alloc_error_handler_should_panic a function Fixes rust-lang/rust#143253 `__rust_alloc_error_handler_should_panic` is a static but was being exported as a function. For most targets this doesn't matter, but Arm64EC Windows uses different decorations for exported variables vs functions, hence it fails to link when `-Z oom=abort` is enabled. We've had issues in the past with statics like this (see rust-lang/rust#141061) but the tldr; is that Arm64EC needs symbols correctly exported as either a function or data, and data MUST and MUST ONLY be marked `dllimport` when the symbol is being imported from another binary, which is non-trivial to calculate for these compiler-generated statics. So, instead, the easiest thing to do is to make `__rust_alloc_error_handler_should_panic` a function instead. Since `__rust_alloc_error_handler_should_panic` isn't involved in any linking shenanigans, I've marked it as `AlwaysInline` with the hopes that the various backends will see that it is just returning a constant and perform the same optimizations as the previous implementation. r? `@bjorn3`
2025-07-04Rollup merge of #143308 - compiler-errors:no-pointer-like, r=oli-obkMatthias Krüger-54/+3
Remove `PointerLike` trait r? oli-obk
2025-07-04Rollup merge of #143395 - Urgau:llvm-fallback-minimum-maximum, r=tgross35Jacob Pratt-2/+2
Always use the pure Rust fallback instead of `llvm.{maximum,minimum}` While https://github.com/llvm/llvm-project/pull/142170 was merged, it was reverted and next attempt (https://github.com/llvm/llvm-project/pull/140193) at fixing the LLVM implementation seems to have stall, so let's reverted back to pure Rust with the LLVM codegen. cc [#t-compiler/llvm > &#96;llvm.minimum&#96;/&#96;llvm.maximum&#96; issues @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/.60llvm.2Eminimum.60.2F.60llvm.2Emaximum.60.20issues/near/527044712) Fixes https://github.com/rust-lang/rust/issues/141087 r? `@tgross35`
2025-07-04Rollup merge of #143378 - hkBst:clippy-fix-6, r=tgross35Jacob Pratt-4/+4
simplify receivers for some array method calls
2025-07-04Rollup merge of #143370 - hkBst:clippy-fix-4, r=tgross35Jacob Pratt-4/+0
remove redundant #[must_use] Fixes these clippy warnings: ``` warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]` --> library/core/src/cmp.rs:1456:5 | 1456 | fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: either add some descriptive message or remove the attribute = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use = note: `-D clippy::double-must-use` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::double_must_use)]` warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]` --> library/core/src/cmp.rs:1465:5 | 1465 | fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: either add some descriptive message or remove the attribute = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]` --> library/core/src/cmp.rs:1474:5 | 1474 | fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: either add some descriptive message or remove the attribute = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]` --> library/core/src/cmp.rs:1483:5 | 1483 | fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: either add some descriptive message or remove the attribute = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use ```
2025-07-04Rollup merge of #143356 - hkBst:clippy-fix-2, r=scottmcmJacob Pratt-1/+1
use unsigned_abs instead of `abs` on signed int to silence clippy Use `unsigned_abs` instead of `abs` on signed int to silence clippy. Alternatively we could allow the lint, but if codegen is not affected, then this seems preferable.
2025-07-04Rollup merge of #142749 - LimpSquid:bool_to_result, r=scottmcmJacob Pratt-0/+76
Add methods for converting bool to `Result<(), E>` ## Tracking Issue https://github.com/rust-lang/rust/issues/142748 ## ACP https://github.com/rust-lang/libs-team/issues/606
2025-07-03Remove PointerLike traitMichael Goulet-54/+3
2025-07-03Always use the pure Rust fallback instead of `llvm.{maximum,minimum}`Urgau-2/+2
2025-07-03Make __rust_alloc_error_handler_should_panic a functionDaniel Paoliello-4/+4
2025-07-03Use `slice_buffer_to_str` in `GenericRadix::fmt_int`Guillaume Gomez-18/+8
2025-07-03Add test for `int_format_into` featureGuillaume Gomez-20/+27
2025-07-03Implement `int_format_into` featureGuillaume Gomez-44/+290
2025-07-03simplify receivers for some array method callsMarijn Schouten-4/+4
2025-07-03remove redundant #[must_use]Marijn Schouten-4/+0
2025-07-03Rollup merge of #143329 - folkertdev:minicore-diagnostic-on-unimplemented, ↵Jana Dönszelmann-0/+3
r=jieyouxu minicore: use core's `diagnostic::on_unimplemented` messages Without these attributes, the error message is different. Keeping the diagnostics up-to-date seems related to https://github.com/rust-lang/rust/issues/137531. The modified test files are reported in https://github.com/rust-lang/rust/issues/143319 as failing for `--target=riscv64gc-unknown-linux-gnu`. Using `minicore` for them makes it easier to troubleshoot this sort of issue. r? ``@jieyouxu``