about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2025-02-17tests: Also gate `f16::erfc()` doctest with `reliable_f16_math` cfgMartin Nordholts-0/+2
In 136324 the doctest for `f16::erf()` was gated with `reliable_f16_math`. Add the same gate on `f16::erfc()` to avoid: rust_out.71e2e529d20ea47d-cgu.0:\ (.text._ZN8rust_out4main43_doctest_main_library_std_src_f16_rs_1321_017h485f3ffe6bf2a981E+0x38): \ undefined reference to `__gnu_h2f_ieee' on MIPS (and maybe other architectures).
2025-02-17Rollup merge of #136844 - thaliaarchi:const-io-error, r=ChrisDentonMatthias Krüger-101/+84
Use `const_error!` when possible Replace usages of `io::Error::new(io::ErrorKind::Variant, "constant string")` with `io::const_error!(io::ErrorKind::Variant, "constant string")` to avoid allocations when possible. Additionally, fix `&&str` error messages in SGX and missing/misplaced trailing commas in `const_error!`.
2025-02-16Synchronize platform adaptors for OsString/OsStrThalia Archibald-74/+119
* Order items as the average of the two adaptors. Enables easier diffs. * Consistently apply #[inline]. * Implement FromInner<Vec<u8>> for bytes::Buf. * Implement Clone::clone_from for wtf8::Buf.
2025-02-16Simplify control flow with while-letThalia Archibald-22/+14
2025-02-16Improve WTF-8 commentsThalia Archibald-15/+23
2025-02-16Rollup merge of #136986 - ehuss:library-unsafe-fun, r=NoratriebMatthias Krüger-7/+7
Apply unsafe_op_in_unsafe_fn to the standard library This applies unsafe_op_in_unsafe_fn to the standard library in preparation for updating to Rust 2024. Closes https://github.com/rust-lang/rust/issues/127747 (I think?) cc ``@workingjubilee`` I have been testing a variety of targets, and I feel like they are all pretty much covered. I'll continue doing some testing async, but I don't expect to catch any more.
2025-02-16add MAX_LEN_UTF8 and MAX_LEN_UTF16 constantsHTGAzureX1212-7/+10
2025-02-15Auto merge of #137065 - jhpratt:rollup-ree9mej, r=jhprattbors-2763/+2846
Rollup of 9 pull requests Successful merges: - #135687 (re-export `FromCoroutine` from `core::iter`) - #135813 (CI: split i686-mingw job to three free runners) - #136749 (Implement Extend<AsciiChar> for String) - #136879 (Add safe new() to NotAllOnes) - #136978 (Windows: Update generated bindings) - #137028 (mir_build: Clarify some code for lowering `hir::PatExpr` to THIR) - #137029 (Remove unnecessary check code in unused_delims) - #137056 (made check_argument_compat public for use in miri) - #137062 (Forward all default methods for I/O impls) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-15Rollup merge of #137062 - thaliaarchi:io-optional-methods/write, ↵Jacob Pratt-0/+62
r=workingjubilee Forward all default methods for I/O impls Forward all default methods for `&mut T` and `Box<T>` to the inner `io::Read`, `io::Write`, `io::Seek`, and `io::BufRead` types.
2025-02-15Rollup merge of #136978 - ChrisDenton:windows-bindgen, r=AmanieuJacob Pratt-2734/+2770
Windows: Update generated bindings Update to windows-bindgen 0.59. This update is aimed at reducing churn in the future, but means a bit more churn now: - `bindings.txt` no longer needs us to write the namespace for each item. This is good because it means in the future we won't need to change them if the namespace changes. However, there are a few where we still need to disambiguate due to duplicate items (this is a bug in the upstream metadata). - The output in `windows-sys.rs` is now sorted. It was mostly sorted before but not intentionally. This should mean future changes are less noisy. The actual code changes are minimal here. A few types are now `bool` instead of `BOOLEAN`, which is more convenient.
2025-02-15Rollup merge of #136879 - kornelski:non1, r=NoratriebJacob Pratt-29/+14
Add safe new() to NotAllOnes Replaces duplicated `unsafe` code with a single, easier to verify implementation.
2025-02-14Forward all default methods for I/O implsThalia Archibald-0/+62
2025-02-15Auto merge of #136324 - GrigorenkoPV:erf, r=tgross35bors-0/+280
Implement `f{16,32,64,128}::{erf,erfc}` (`#![feature(float_erf)]`) Tracking issue: #136321 try-job: x86_64-gnu-aux
2025-02-14Rollup merge of #136983 - ehuss:misc-2024-prep, r=tgross35Jubilee-81/+107
Prepare standard library for Rust 2024 migration This includes a variety of commits preparing the standard library for migration to Rust 2024. The actual migration is blocked on a few things, so I wanted to get this out of the way in a relatively digestable PR.
2025-02-14std: Apply unsafe_op_in_unsafe_fnEric Huss-5/+5
2025-02-14Fix safety of windows uwp functionsEric Huss-2/+2
These functions were changed to be safe in https://github.com/rust-lang/rust/pull/127763, but this particular UWP version was missed. Otherwise this causes unnecessary unsafe block warnings/errors.
2025-02-14Rollup merge of #136967 - DaniPopes:io-repeat-fill, r=joboetMatthias Krüger-18/+11
Use `slice::fill` in `io::Repeat` implementation Use the existing `fill` methods on slices instead of manually writing the fill loop.
2025-02-14Rollup merge of #136886 - ehuss:remove-prelude-common, r=jhprattMatthias Krüger-12/+6
Remove the common prelude module This fixes the issues described in https://github.com/rust-lang/rust/issues/136102. Primarily, this resolves some issues with how the documentation for the prelude is generated: - It avoids showing "unstable" for macros in the prelude that are actually stable. - Avoids duplication of some pages due to the previous lack of `doc(no_inline)`. - Makes the different edition preludes consistent, and sets a pattern that can be used by future editions. We may need to rearrange these modules in the future if we decide to remove anything from the prelude again. If we do, I think we should look into a different solution that avoids the documentation problems. Closes https://github.com/rust-lang/rust/issues/136102
2025-02-14Rollup merge of #136052 - no1wudi:fix, r=workingjubileeMatthias Krüger-1/+1
Correct comment for FreeBSD and DragonFly BSD in unix/thread
2025-02-14Add safe new to NotAllOnesKornel-29/+14
2025-02-13Rollup merge of #136908 - mustartt:aix-mutex-destory-einval, r=joboetJubilee-3/+3
[AIX] expect `EINVAL` for `pthread_mutex_destroy` Calling `pthread_mutex_destory` on a mutex initalized with the static initializer macro `PTHREAD_MUTEX_INITIALIZER` will result in `EINVAL` if the mutex is not lock/unlocked prior to calling `pthread_mutex_destroy`.
2025-02-14Implement `f{16,32,64,128}::{erf,erfc}`Pavel Grigorenko-0/+280
Also add ```rust // #[unstable(feature = "float_gamma", issue = "99842")] ``` to `gamma`-function-related methods on `f16` & `f128`, as per https://github.com/rust-lang/rust/pull/136324#issuecomment-2626270247
2025-02-13std: Apply deprecated_safe_2024Eric Huss-42/+66
2025-02-13std: Apply fixes for tail drop expressionsEric Huss-2/+2
2025-02-13std: Apply rust_2024_incompatible_patEric Huss-2/+2
2025-02-13std: Apply dependency_on_unit_never_type_fallbackEric Huss-1/+3
This generates a warning of irrefutable patterns. I decided to slightly tweak the example so the closure returns unit, since the intent wasn't to show the weird behavior of returning `!`.
2025-02-13std: Apply missing_unsafe_on_externEric Huss-2/+2
2025-02-13std: Apply unsafe_attr_outside_unsafeEric Huss-28/+28
2025-02-13Auto merge of #134633 - GrigorenkoPV:get_disjoint_mut, r=cuviperbors-1/+0
Stabilize `get_many_mut` as `get_disjoint_mut` Tracking issue: #104642 Closes #104642 FCP completed in https://github.com/rust-lang/rust/issues/104642#issuecomment-2558161073
2025-02-13library: Update rand to 0.9.0Eric Huss-4/+4
2025-02-13Consistently using as_mut_ptr() and as_ptr() in threadxizheyin-8/+11
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-13Replace mem::zeroed with mem::MaybeUninit::uninit for large struct in unixxizheyin-13/+31
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-13Use `slice::fill` in `io::Repeat` implementationDaniPopes-18/+11
Use the existing `fill` methods on slices instead of manually writing the fill loop.
2025-02-13Windows: Update generated bindings to 0.59Chris Denton-2734/+2770
2025-02-13Rollup merge of #136949 - ehuss:wasm-bench-time, r=jhprattJacob Pratt-2/+1
Fix import in bench for wasm This import was causing annoying unused import errors when checking the standard library for some wasm targets. The problem is that everything here is disabled if it is wasm32, but this import wasn't cfg'd.
2025-02-12Rollup merge of #136945 - samueltardieu:push-rsqlyknnvyqm, r=fmeaseJacob Pratt-0/+1
Add diagnostic item for `std::io::BufRead` This will be used in Clippy to detect unbuffered calls to `Read::bytes()`.
2025-02-12Rollup merge of #136818 - a1phyr:io_repeat_exact, r=jhprattJacob Pratt-0/+11
Implement `read*_exact` for `std:io::repeat` cc #136756
2025-02-12Rollup merge of #136699 - joboet:netaddr_from_inner, r=cuviperJacob Pratt-348/+155
std: replace the `FromInner` implementation for addresses with private conversion functions Having these implementation available crate-wide means that platforms not using sockets for their networking code have to stub out the libc definitions required to support them. This PR moves the conversions to private helper functions that are only available where actually needed. I also fixed the signature of the function converting from a C socket address to a Rust one: taking a reference to a `sockaddr_storage` resulted in unsound usage inside `LookupHost::next`, which could create a reference to a structure smaller than `sockaddr_storage`. Thus I've replaced the argument type with a pointer and made the function `unsafe`.
2025-02-12Fix import in bench for wasmEric Huss-2/+1
2025-02-12Add diagnostic item for `std::io::BufRead`Samuel Tardieu-0/+1
This will be used in Clippy to detect unbuffered calls to `Read::bytes()`.
2025-02-12std: replace the `FromInner` implementation for addresses with private ↵joboet-348/+155
conversion functions Having these implementation available crate-wide means that platforms not using sockets for their networking code have to stub out the libc definitions required to support them. This PR moves the conversions to private helper functions that are only available where actually needed. I also fixed the signature of the function converting from a C socket address to a Rust one: taking a reference to a `sockaddr_storage` resulted in unsound usage inside `LookupHost::next`, which could create a reference to a structure smaller than `sockaddr_storage`. Thus I've replaced the argument type with a pointer and made the function `unsafe`.
2025-02-12Auto merge of #136918 - GuillaumeGomez:rollup-f6h21gg, r=GuillaumeGomezbors-2/+2
Rollup of 8 pull requests Successful merges: - #134981 ( Explain that in paths generics can't be set on both the enum and the variant) - #136698 (Replace i686-unknown-redox target with i586-unknown-redox) - #136767 (improve host/cross target checking) - #136829 ([rustdoc] Move line numbers into the `<code>` directly) - #136875 (Rustc dev guide subtree update) - #136900 (compiler: replace `ExternAbi::name` calls with formatters) - #136913 (Put kobzol back on review rotation) - #136915 (documentation fix: `f16` and `f128` are not double-precision) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-12Auto merge of #136897 - workingjubilee:revert-unfcped-stab, r=WaffleLapkinbors-0/+3
Revert "Stabilize `extended_varargs_abi_support`" I cannot find an FCP for this, despite it being a stabilization PR which normally means we do an FCP of some kind? It would seem reasonable for _either_ compiler or lang to have FCPed it? I am thus opening a revert PR, which mostly-cleanly applies, so that we can later actually land this properly with a stability report and FCP. - https://github.com/rust-lang/rust/issues/136896 - https://github.com/rust-lang/rust/pull/116161 - https://github.com/rust-lang/rust/issues/100189
2025-02-12`f128` is quadruple-precisioneyelash-1/+1
2025-02-12`f16` is half-precisioneyelash-1/+1
2025-02-12expect EINVAL for pthread_mutex_destroy for aixHenry Jiang-3/+3
2025-02-11library: amend revert of extended_varargs_abi_support for beta diffJubilee Young-1/+3
And leave a comment on the unusual `cfg_attr` Co-authored-by: waffle <waffle.lapkin@gmail.com>
2025-02-11Optionally add type names to `TypeId`s.Kevin Reid-0/+7
This feature is intended to provide expensive but thorough help for developers who have an unexpected `TypeId` value and need to determine what type it actually is. It causes `impl Debug for TypeId` to print the type name in addition to the opaque ID hash, and in order to do so, adds a name field to `TypeId`. The cost of this is the increased size of `TypeId` and the need to store type names in the binary; therefore, it is an optional feature. It may be enabled via `cargo -Zbuild-std -Zbuild-std-features=debug_typeid`. (Note that `-Zbuild-std-features` disables default features which you may wish to reenable in addition; see <https://doc.rust-lang.org/cargo/reference/unstable.html#build-std-features>.) Example usage and output: ``` fn main() { use std::any::{Any, TypeId}; dbg!(TypeId::of::<usize>(), drop::<usize>.type_id()); } ``` ``` TypeId::of::<usize>() = TypeId(0x763d199bccd319899208909ed1a860c6 = usize) drop::<usize>.type_id() = TypeId(0xe6a34bd13f8c92dd47806da07b8cca9a = core::mem::drop<usize>) ``` Also added feature declarations for the existing `debug_refcell` feature so it is usable from the `rust.std-features` option of `config.toml`.
2025-02-11Revert "Stabilize `extended_varargs_abi_support`"Jubilee Young-0/+1
This reverts commit 685f189b4307435b83d625fea397ef36dff4e955.
2025-02-11Remove the common prelude moduleEric Huss-12/+6
This fixes the issues described in https://github.com/rust-lang/rust/issues/136102. Primarily, this resolves some issues with how the documentation for the prelude is generated: - It avoids showing "unstable" for macros in the prelude that are actually stable. - Avoids duplication of some pages due to the previous lack of `doc(no_inline)`. - Makes the different edition preludes consistent, and sets a pattern that can be used by future editions. We may need to rearrange these modules in the future if we decide to remove anything from the prelude again. If we do, I think we should look into a different solution that avoids the documentation problems.