about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2025-05-23Rollup merge of #141019 - ehuss:android-doctest-xcompile, r=Mark-SimulacrumMatthias Krüger-6/+21
Update std doctests for android This updates some doctests that fail to run on android. We will soon be supporting cross-compiled doctests, and the `arm-android` job fails to run these tests. In summary: - Android re-exports some traits from linux under a different path. - Android doesn't seem to have common unix utilities like `true`, `false`, or `whoami`, so these are disabled.
2025-05-23use `cfg_select!` to select the right `VaListImpl` definitionFolkert de Vries-175/+136
2025-05-23Remove #![feature(let_chains)] from libcoreest31-1/+0
2025-05-22Auto merge of #141396 - matthiaskrgr:rollup-feg050g, r=matthiaskrgrbors-70/+67
Rollup of 7 pull requests Successful merges: - #135562 (Add ignore value suggestion in closure body) - #139635 (Finalize repeat expr inference behaviour with inferred repeat counts) - #139668 (Handle regions equivalent to 'static in non_local_bounds) - #140218 (HIR ty lowering: Clean up & refactor the lowering of type-relative paths) - #140435 (use uX::from instead of _ as uX in non - const contexts) - #141130 (rustc_on_unimplemented cleanups) - #141286 (Querify `coroutine_hidden_types`) Failed merges: - #140247 (Don't build `ParamEnv` and do trait solving in `ItemCtxt`s when lowering IATs) r? `@ghost` `@rustbot` modify labels: rollup
2025-05-22docs: fix typosDannyyy93-3/+3
2025-05-22Rollup merge of #141381 - RalfJung:try_cast_aligned-strict-provenance, ↵Matthias Krüger-21/+15
r=tgross35 try_cast_aligned: avoid bare int-to-ptr casts This fixes a CI failure in https://github.com/rust-lang/miri-test-libstd caused by strict provenance violations in doctests added in https://github.com/rust-lang/rust/pull/141222. r? `@tgross35` Cc `@mathisbot`
2025-05-22Rollup merge of #141130 - mejrs:use_self, r=compiler-errorsMatthias Krüger-70/+67
rustc_on_unimplemented cleanups Addresses some of the fixmes from https://github.com/rust-lang/rust/pull/139091 and https://github.com/rust-lang/rust/pull/140307. - switch from `_Self` to `Self` in library - properly validate that arguments in the `on` filter and the format strings are actually valid See https://github.com/rust-lang/rustc-dev-guide/pull/2357 for the relevant documentation.
2025-05-22try_cast_aligned: avoid bare int-to-ptr castsRalf Jung-21/+15
2025-05-22libm: Clean up unused filesTrevor Gross-310/+0
These were deleted during refactoring in 0a2dc5d9 ("Combine the source files for more generic implementations") but got added back by accident in 54bac411 ("refactor: Move the libm crate to a subdirectory"). Remove them again here.
2025-05-22fixed typo in readmePályi Lőrinc-1/+1
2025-05-22Auto merge of #141379 - matthiaskrgr:rollup-g1cz0ic, r=matthiaskrgrbors-0/+1
Rollup of 6 pull requests Successful merges: - #140431 (dont handle bool transmute) - #140868 (rustdoc: Fix links with inline code in trait impl docs) - #141323 (Add bors environment to CI) - #141337 (bump stdarch) - #141364 (rustdoc-json: Remove false docs and add test for inline attribute) - #141370 (add doc alias `replace_first` for `str::replacen`) r? `@ghost` `@rustbot` modify labels: rollup
2025-05-22Rollup merge of #141370 - WaffleLapkin:hiiii, r=jhprattMatthias Krüger-0/+1
add doc alias `replace_first` for `str::replacen` `replace_first` is a sensible name for a function, analogous to actually existing `<[_]>::split_first`, for example. (I just saw someone try to search for it) I think it's reasonable to add such an alias for `replacen`, which replaces the first occurrence of passed a 1.
2025-05-22Rollup merge of #141337 - RalfJung:stdarch, r=AmanieuMatthias Krüger-0/+0
bump stdarch This should unblock https://github.com/rust-lang/rust/pull/135160. r? `@Amanieu`
2025-05-22Auto merge of #137198 - tgross35:cfg-match-rename, r=Amanieubors-51/+51
Rename `cfg_match!` to `cfg_select!` [`@Nemo157` pointed out](https://github.com/rust-lang/rust/issues/115585#issuecomment-2346307605) that `cfg_match!` syntax does not actually align well with match syntax, which is a possible source of confusion. The comment points out that usage is instead more similar to ecosystem `select!` macros. Rename `cfg_match!` to `cfg_select!` to match this. Tracking issue: https://github.com/rust-lang/rust/issues/115585 [1]: https://github.com/rust-lang/rust/issues/115585#issuecomment-2346307605
2025-05-21add doc alias `replace_first` for `str::replacen`waffle-0/+1
2025-05-21Rollup merge of #141341 - folkertdev:limit-VaArgSafe-impls, r=workingjubileeMatthias Krüger-28/+46
limit impls of `VaArgSafe` to just types that are actually safe tracking issue: https://github.com/rust-lang/rust/issues/44930 Retrieving 8- or 16-bit integer arguments from a `VaList` is not safe, because such types are subject to upcasting. See https://github.com/rust-lang/rust/issues/61275#issuecomment-2193942535 for more detail. This PR also makes the instances of `VaArgSafe` visible in the documentation, and uses a private sealed trait to make sure users cannot create additional impls of `VaArgSafe`, which would almost certainly cause UB. r? `@workingjubilee`
2025-05-21Rollup merge of #141230 - xizheyin:issue-141217, r=tgross35Matthias Krüger-5/+28
std: fix doctest and explain for `as_slices` and `as_mut_slices` in `VecDeque` Fixes #141217 r? libs
2025-05-21Rollup merge of #140526 - Natr1x:sort-direction-documentation, r=dtolnayMatthias Krüger-9/+12
docs: Specify that common sort functions sort in an ascending direction From [forum discussion](https://users.rust-lang.org/t/is-there-a-way-to-sort-a-slice-in-specifically-ascending-or-descending-order/128998?u=natr1x) it seems like the sorting direction can be expected to always be ascending (in terms of `cmp::Ordering`). If this is the case then it would be nice to have this stated in the documentation.
2025-05-21Enable `__powitf2` on MSVCbeetrees-4/+0
2025-05-21std: fix doctest and explain for as_slices and as_mut_slices in VecDequexizheyin-5/+28
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-21limit impls of `VaArgSafe` to just types that are actually safeFolkert de Vries-28/+46
8 and 16-bit integers are subject to upcasting in C, and hence are not reliably safe. users should perform their own casting and deal with the consequences
2025-05-21Add some track_caller info to precondition panicsBen Kimock-53/+86
2025-05-21bump stdarchRalf Jung-0/+0
2025-05-21allow aarch64_softfloat_neon for backwards compatibilityRalf Jung-0/+13
2025-05-21Rollup merge of #137759 - joshtriplett:command-chroot, r=AmanieuMatthias Krüger-0/+47
Add `std::os::unix::process::CommandExt::chroot` to safely chroot a child process This adds a `chroot` method to the `CommandExt` extension trait for the `Command` builder, to set a directory to chroot into. This will chroot the child process into that directory right before calling chdir for the `Command`'s working directory. To avoid allowing a process to have a working directory outside of the chroot, if the `Command` does not yet have a working directory set, `chroot` will set its working directory to "/". --- ACP: https://github.com/rust-lang/libs-team/issues/551 This PR currently has the tracking issue set to "none"; if the ACP is approved, I'll file a tracking issue and update the PR.
2025-05-21Disable autodiff bootstrappingMarcelo Domínguez-19/+29
2025-05-21Add ReentrantLock::data_ptrJonas Platte-0/+11
2025-05-21Add more docs to new data_ptr methodsJonas Platte-0/+10
2025-05-21Add data_ptr method to Mutex and RwLockJonas Platte-0/+12
2025-05-21Rollup merge of #141222 - mathisbot:ptr_trycastaligned, r=tgross35Matthias Krüger-0/+85
Implement `ptr::try_cast_aligned` and `NonNull::try_cast_aligned`. Implement three common methods on raw pointers and `NonNull`s: `try_cast_aligned`. ## Related links - Tracking Issue: https://github.com/rust-lang/rust/issues/141221 ## About `#[inline]` Since the result of a call to `align_of` is a power of two known at compile time, the compiler is able to reduce a call to `try_cast_aligned` to only test and sete (or test and jne if followed by `unwrap`), at least on every tier 1 target's arch. This seemed like a good reason to `#[inline]` the function. - https://godbolt.org/z/ocehvPWMx (raw inlining) - https://godbolt.org/z/3qa4j4Yrn (comparison with no inlining)
2025-05-21Apply suggestions from code reviewJosh Triplett-5/+5
Link `Command::current_dir`. Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2025-05-20Rename `cfg_match!` to `cfg_select!`Trevor Gross-51/+51
At [1] it was pointed out that `cfg_match!` syntax does not actually align well with match syntax, which is a possible source of confusion. The comment points out that usage is instead more similar to ecosystem `select!` macros. Rename `cfg_match!` to `cfg_select!` to match this. Tracking issue: https://github.com/rust-lang/rust/issues/115585 [1]: https://github.com/rust-lang/rust/issues/115585#issuecomment-2346307605
2025-05-20Add From<TryLockError> for io::ErrorChristopher Berner-0/+16
This makes error propagation from try_lock() and try_lock_shared() more convenient
2025-05-20Remove unnecessary handling of ERROR_IO_PENDINGChristopher Berner-8/+24
try_lock() and try_lock_shared() do not need to handle these per the discussion in https://github.com/rust-lang/rust/pull/140718#discussion_r2076678485
2025-05-20Implement `ptr::try_cast_aligned` and `NonNull::try_cast_aligned`.Mathis Bottinelli-0/+85
2025-05-20Rollup merge of #141289 - compiler-errors:more-self, r=jhprattMatthias Krüger-5/+5
use `Self` alias in self types rather than manually substituting it Of the rougly 145 uses of `self: Ty` in the standard library, 5 of them don't use `Self` but instead choose to manually "substitute" the `impl`'s self type into the type. This leads to weird behavior sometimes (https://github.com/rust-lang/rust/issues/140611#issuecomment-2883761300) -- **to be clear**, none of these usages actually trigger any bugs, but it's possible that they may break in the future (or at least lead to lints), so let's just "fix" them proactively.
2025-05-20Rollup merge of #141282 - DJMcNab:core-float-math-math, r=tgross35Matthias Krüger-933/+990
`core_float_math`: Move functions to `math` module When these functions were added in https://github.com/rust-lang/rust/pull/138087 It made a relatively common pattern for emulating these functions using an extension trait (which internally uses `libm`) much more fragile. If `core::f32` happened to be imported by the user (to access a constant, say), then that import in the module namespace would take precedence over the `f32` in the type namespace for resolving these functions, running headfirst into the stability attribute. We ran into this in [Color](https://github.com/linebender/color) and chose to release the remedial 0.3.1 and 0.2.4, to allow downstream crates to build on `docs.rs`. As these methods are perma-unstable, moving them into a new module should not have any long-term concerns, and ensures that this "breakage" doesn't adversely impact anyone else. I believe that I've made the module unstable correctly. I presume that this does not require a test to make sure stable code can't depend on the module existing? I've left the stability attribute on each function - happy to tweak this if a different pattern is more correct. Tracking issue for `core_float_math`: https://github.com/rust-lang/rust/issues/137578. This PR is as requested in https://github.com/rust-lang/rust/pull/138087. r? `@tgross35` Recommended reviewing with whitespace hidden. (This is my first PR to `std/core`/this repository, as far as I can remember)
2025-05-20use a tuple to return the condition codeFolkert de Vries-101/+48
2025-05-20`CommandExt::chroot`: Add tracking issueJosh Triplett-1/+1
2025-05-20`CommandExt::chroot`: Document difference to underlying `chroot`Josh Triplett-3/+5
2025-05-20Add `std::os::unix::process::CommandExt::chroot` to safely chroot a child ↵Josh Triplett-0/+45
process This adds a `chroot` method to the `CommandExt` extension trait for the `Command` builder, to set a directory to chroot into. This will chroot the child process into that directory right before calling chdir for the `Command`'s working directory. To avoid allowing a process to have a working directory outside of the chroot, if the `Command` does not yet have a working directory set, `chroot` will set its working directory to "/".
2025-05-20`core_float_math`: Move functions to `math` folderDaniel McNab-933/+990
When these functions were added in https://github.com/rust-lang/rust/pull/138087 It made a relatively common pattern for emulating these functions using an extension trait (which internally uses `libm`) much more fragile. If `core::f32` happened to be imported by the user (to access a constant, say), then that import in the module namespace would take precedence over `f32` in the type namespace for resolving these functions, running headfirst into the stability attribute. We ran into this in Color - https://github.com/linebender/color - and chose to release the remedial 0.3.1 and 0.2.4, to allow downstream crates to build on `docs.rs`. As these methods are perma-unstable, moving them into a new module should not have any long-term concerns, and ensures that this breakage doesn't adversely impact anyone else.
2025-05-20in `intrinsic-test`, format f16 like CFolkert de Vries-1/+102
2025-05-20use the right load instructionFolkert de Vries-3/+3
2025-05-20`avx512_target_feature` is now stable on nightlyFolkert de Vries-3/+0
2025-05-20use Self alias in self types rather than manually substituting itMichael Goulet-5/+5
2025-05-20Split `autodiff` into `autodiff_forward` and `autodiff_reverse`Marcelo Domínguez-1/+15
Pending fix. ``` error: cannot find a built-in macro with name `autodiff_forward` --> library\core\src\macros\mod.rs:1542:5 | 1542 | / pub macro autodiff_forward($item:item) { 1543 | | /* compiler built-in */ 1544 | | } | |_____^ error: cannot find a built-in macro with name `autodiff_reverse` --> library\core\src\macros\mod.rs:1549:5 | 1549 | / pub macro autodiff_reverse($item:item) { 1550 | | /* compiler built-in */ 1551 | | } | |_____^ error: could not compile `core` (lib) due to 2 previous errors ```
2025-05-20make std::intrinsic functions actually be intrinsicsRalf Jung-303/+309
2025-05-20Rollup merge of #141211 - fluiderson:dev, r=thomccStuart Cook-2/+1
Replace `try_reserve_exact` with `try_with_capacity` in `std::fs::read` This change restores the previous behavior prior to #117925. That PR was made to handle OOM errors that turn into a panic with `Vec::with_capacity`. `try_reserve_exact` was used for that since there was no `try_with_capacity` method at the time. It was added later in #120504. I think it'd a better fit here.
2025-05-19Auto merge of #138023 - melrief:97227_impl_Seek_for_Take, r=tgross35bors-1/+173
Add `std::io::Seek` instance for `std::io::Take` Library tracking issue [#97227](https://github.com/rust-lang/rust/issues/97227). ACP: https://github.com/rust-lang/libs-team/issues/555 1. add a `len` field to `Take` to keep track of the original number of bytes that `Take` could read 2. add a `position()` method to return the current position of the cursor inside `Take` 3. implement `std::io::Seek` for `std::io::Take` Closes: https://github.com/rust-lang/libs-team/issues/555