about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2025-01-16uefi: Implement pathAyush Singh-5/+158
UEFI paths can be of 4 types: 1. Absolute Shell Path: Uses shell mappings 2. Absolute Device Path: this is what we want 3: Relative root: path relative to the current root. 4: Relative Absolute shell path can be identified with `:` and Absolute Device path can be identified with `/`. Relative root path will start with `\`. The algorithm is mostly taken from edk2 UEFI shell implementation and is somewhat simple. Check for the path type in order. For Absolute Shell path, use `EFI_SHELL->GetDevicePathFromMap` to get a BorrowedDevicePath for the volume. For Relative paths, we use the current working directory to construct the new path. BorrowedDevicePath abstraction is needed to interact with `EFI_SHELL->GetDevicePathFromMap` which returns a Device Path Protocol with the lifetime of UEFI shell. Absolute Shell paths cannot exist if UEFI shell is missing. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-01-15Clarify note in `std::sync::LazyLock` exampleAeon-1/+1
2025-01-15Rollup merge of #132654 - joboet:lazy_main, r=ChrisDentonGuillaume Gomez-196/+198
std: lazily allocate the main thread handle https://github.com/rust-lang/rust/pull/123550 eliminated the allocation of the main thread handle, but at the cost of greatly increased complexity. This PR proposes another approach: Instead of creating the main thread handle itself, the runtime simply remembers the thread ID of the main thread. The main thread handle is then only allocated when it is used, using the same lazy-initialization mechanism as for non-runtime use of `thread::current`, and the `name` method uses the thread ID to identify the main thread handle and return the correct name ("main") for it. Thereby, we also allow accessing `thread::current` before main: as the runtime no longer tries to install its own handle, this will no longer trigger an abort. Rather, the name returned from `name` will only be "main" after the runtime initialization code has run, but I think that is acceptable. This new approach also requires some changes to the signal handling code, as calling `thread::current` would now allocate when called on the main thread, which is not acceptable. I fixed this by adding a new function (`with_current_name`) that performs all the naming logic without allocation or without initializing the thread ID (which could allocate on some platforms). Reverts #123550, CC ``@GnomedDev``
2025-01-14Update ReadDir::next in std::sys::pal::unix::fs to use `&raw const ↵Zachary S-23/+13
(*ptr).field` instead of `ptr.offset(...).cast()`. Also, the macro is only called three times, and all with the same local variable entry_ptr, so just use the local variable directly, and rename the macro to entry_field_ptr.
2025-01-14wasi/io: remove dead filesRalf Jung-29/+4
2025-01-14remove unnecessary rustc_allowed_through_unstable_modulesRalf Jung-5/+0
2025-01-14remove Rustc{En,De}codable from library and compilerRalf Jung-9/+0
2025-01-14make rustc_encodable_decodable feature properly unstableRalf Jung-2/+1
2025-01-14add comments explaining main thread identificationjoboet-0/+29
2025-01-14std: lazily allocate the main thread handlejoboet-114/+151
Thereby, we also allow accessing thread::current before main: as the runtime no longer tries to install its own handle, this will no longer trigger an abort. Rather, the name returned from name will only be "main" after the runtime initialization code has run, but I think that is acceptable. This new approach also requires some changes to the signal handling code, as calling `thread::current` would now allocate when called on the main thread, which is not acceptable. I fixed this by adding a new function (`with_current_name`) that performs all the naming logic without allocation or without initializing the thread ID (which could allocate on some platforms).
2025-01-14Revert "Remove the Arc rt::init allocation for thread info"joboet-118/+54
This reverts commit 0747f2898e83df7e601189c0f31762e84328becb.
2025-01-14Auto merge of #135359 - RalfJung:lang-start-unwind, r=joboetbors-17/+30
use a single large catch_unwind in lang_start I originally planned to use `abort_unwind` but reading the comment in `thread_cleanup` it seems we are deliberately going for slightly nicer error messages here, so this preserves that. It still seems nice to not repeat `catch_unwind` so often.
2025-01-14Auto merge of #135465 - jhpratt:rollup-7p93bct, r=jhprattbors-7/+16
Rollup of 10 pull requests Successful merges: - #134498 (Fix cycle error only occurring with -Zdump-mir) - #134977 (Detect `mut arg: &Ty` meant to be `arg: &mut Ty` and provide structured suggestion) - #135390 (Re-added regression test for #122638) - #135393 (uefi: helpers: Introduce OwnedDevicePath) - #135440 (rm unnecessary `OpaqueTypeDecl` wrapper) - #135441 (Make sure to mark `IMPL_TRAIT_REDUNDANT_CAPTURES` as `Allow` in edition 2024) - #135444 (Update books) - #135450 (Fix emscripten-wasm-eh with unwind=abort) - #135452 (bootstrap: fix outdated feature name in comment) - #135454 (llvm: Allow sized-word rather than ymmword in tests) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-13Rollup merge of #135393 - Ayush1325:uefi-helper-path, r=thomccJacob Pratt-7/+16
uefi: helpers: Introduce OwnedDevicePath This PR is split off from #135368 to reduce noise. No real functionality changes, just some quality of life improvements. Also implement Debug for OwnedDevicePath for some quality of life improvements.
2025-01-13uefi: helpers: Introduce OwnedDevicePathAyush Singh-7/+16
This PR is split off from #135368 to reduce noise. Rename DevicePath to OwnedDevicePath. This is to allow a non-owning version of DevicePath in the future to work with UEFI shell APIs which provide const pointers to device paths for UEFI shell fs mapping. Also implement Debug for OwnedDevicePath for some quality of life improvements. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-01-13further improve panic_immediate_abort by removing rtprintpanic messagesklensy-0/+5
2025-01-13Rollup merge of #135405 - Ayush1325:path-is-absolute, r=tgross35Matthias Krüger-11/+27
path: Move is_absolute check to sys::path I am working on fs support for UEFI [0], which similar to windows has prefix components, but is not quite same as Windows. It also seems that Prefix is tied closely to Windows and cannot really be extended [1]. This PR just tries to remove coupling between Prefix and absolute path checking to allow platforms to provide there own implementation to check if a path is absolute or not. I am not sure if any platform other than windows currently uses Prefix, so I have kept the path.prefix().is_some() check in most cases. [0]: https://github.com/rust-lang/rust/pull/135368 [1]: https://github.com/rust-lang/rust/issues/52331#issuecomment-2492796137
2025-01-13path: Move is_absolute check to sys::pathAyush Singh-11/+27
I am working on fs support for UEFI [0], which similar to windows has prefix components, but is not quite same as Windows. It also seems that Prefix is tied closely to Windows and cannot really be extended [1]. This PR just tries to remove coupling between Prefix and absolute path checking to allow platforms to provide there own implementation to check if a path is absolute or not. I am not sure if any platform other than windows currently uses Prefix, so I have kept the path.prefix().is_some() check in most cases. [0]: https://github.com/rust-lang/rust/pull/135368 [1]: https://github.com/rust-lang/rust/issues/52331#issuecomment-2492796137 Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-01-11Add inherent versions of MaybeUninit methods for slicesltdk-9/+7
2025-01-11avoid nesting the user-defined main so deeply on the stackRalf Jung-12/+17
2025-01-11use a single large catch_unwind in lang_startRalf Jung-14/+22
2025-01-11Rollup merge of #135347 - samueltardieu:push-qvyxtxsqyxyr, r=jhprattJacob Pratt-3/+5
Use `NonNull::without_provenance` within the standard library This API removes the need for several `unsafe` blocks, and leads to clearer code. It uses feature `nonnull_provenance` (#135243). Close #135343
2025-01-11Rollup merge of #135324 - Ayush1325:uefi-fs-unsupported, r=joboetJacob Pratt-1/+344
Initial fs module for uefi - Just a copy of unsupported fs right now to reduce the noise from future PRs to allow for easier review. - For the full working version of fs on uefi, see [0] - This is an effort to break the original PR (#129700) into much smaller chunks for faster upstreaming. [0]: https://github.com/Ayush1325/rust/tree/uefi-file-full
2025-01-11Rollup merge of #135236 - scottmcm:more-mcp807-library-updates, r=ChrisDentonJacob Pratt-84/+64
Update a bunch of library types for MCP807 This greatly reduces the number of places that actually use the `rustc_layout_scalar_valid_range_*` attributes down to just 3: ``` library/core\src\ptr\non_null.rs 68:#[rustc_layout_scalar_valid_range_start(1)] library/core\src\num\niche_types.rs 19: #[rustc_layout_scalar_valid_range_start($low)] 20: #[rustc_layout_scalar_valid_range_end($high)] ``` Everything else -- PAL Nanoseconds, alloc's `Cap`, niched FDs, etc -- all just wrap those `niche_types` types. r? ghost
2025-01-11Implement `ByteStr` and `ByteString` typesJosh Triplett-0/+8
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`, `Borrow`, `From`, and `PartialOrd`, when those would be the second implementation for a type (counting the `T` impl) or otherwise may cause inference failures. These impls are important, but we can attempt to add them 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).
2025-01-10Use `NonNull::without_provenance` within the standard librarySamuel Tardieu-3/+5
This API removes the need for several `unsafe` blocks, and leads to clearer code.
2025-01-10Rollup merge of #132607 - YohDeadfall:pthread-name-fn-with-result, r=tgross35Jacob Pratt-11/+13
Used pthread name functions returning result for FreeBSD and DragonFly `pthread_getname_np` and `pthread_setname_np` received a wider adoption in past years and was added to: * FreeBSD by June 11 2020 via [`2ef84b7da9a6c3e23b4a135e6e863581f16d46e1`](https://github.com/freebsd/freebsd-src/commit/2ef84b7da9a6c3e23b4a135e6e863581f16d46e1), * DargonFly by March 8 2021 via [`ab5dc9aceb34419d1c4b6006739e61acee8ee999`](https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/ab5dc9aceb34419d1c4b6006739e61acee8ee999). There's not so much advantage except that the result can be checked in debug builds. Ideally it should be unified with Linux' implementation, but it trims the input.
2025-01-09Update a bunch of library types for MCP807Scott McMurray-84/+64
This greatly reduces the number of places that actually use the `rustc_layout_scalar_valid_range_*` attributes down to just 3: ``` library/core\src\ptr\non_null.rs 68:#[rustc_layout_scalar_valid_range_start(1)] library/core\src\num\niche_types.rs 19: #[rustc_layout_scalar_valid_range_start($low)] 20: #[rustc_layout_scalar_valid_range_end($high)] ``` Everything else -- PAL Nanoseconds, alloc's `Cap`, niched FDs, etc -- all just wrap those `niche_types` types.
2025-01-10Initial fs module for uefiAyush Singh-1/+344
- Just a copy of unsupported fs right now to reduce the noise from future PRs to allow for easier review. - For the full working version of fs on uefi, see [0] [0]: https://github.com/Ayush1325/rust/tree/uefi-file-full Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-01-09Used pthread name functions returning result for FreeBSD and DragonFlyYoh Deadfall-11/+13
2025-01-09Auto merge of #135268 - pietroalbini:pa-bump-stage0, r=Mark-Simulacrumbors-15/+8
Master bootstrap update Part of the release process. r? `@Mark-Simulacrum`
2025-01-08Remove some unnecessary `.into()` callsEsteban Küber-1/+1
2025-01-08fmtPietro Albini-8/+2
2025-01-08update cfg(bootstrap)Pietro Albini-2/+1
2025-01-08update version placeholdersPietro Albini-8/+8
2025-01-08Rollup merge of #135176 - kornelski:env-example, r=cuviperJacob Pratt-7/+15
More compelling env_clear() examples `ls` isn't a command that people usually set env vars for, and `PATH` in particular isn't even used by `ls`.
2025-01-08Rollup merge of #134389 - rust-wasi-web:condvar-no-threads, r=m-ou-seJacob Pratt-2/+4
Condvar: implement wait_timeout for targets without threads This always falls back to sleeping since there is no way to notify a condvar on a target without threads. Even on a target that has no threads the following code is a legitimate use case: ```rust use std::sync::{Condvar, Mutex}; use std::time::Duration; fn main() { let cv = Condvar::new(); let mutex = Mutex::new(()); let mut guard = mutex.lock().unwrap(); cv.notify_one(); let res; (guard, res) = cv.wait_timeout(guard, Duration::from_secs(3)).unwrap(); assert!(res.timed_out()); } ```
2025-01-08Outline panicking code for `LocalKey::with`Joseph Perez-8/+16
See https://github.com/rust-lang/rust/pull/115491 for prior related modifications. https://godbolt.org/z/MTsz87jGj shows a reduction of the code size for TLS accesses.
2025-01-07Avoid naming variables `str`Josh Triplett-7/+7
This renames variables named `str` to other names, to make sure `str` always refers to a type. It's confusing to read code where `str` (or another standard type name) is used as an identifier. It also produces misleading syntax highlighting.
2025-01-06More compelling env_clear() examplesKornel-7/+15
2025-01-06Rollup merge of #135153 - crystalstall:master, r=workingjubileeMatthias Krüger-3/+3
chore: remove redundant words in comment
2025-01-06chore: remove redundant words in commentcrystalstall-3/+3
Signed-off-by: crystalstall <crystalruby@qq.com>
2025-01-06Rollup merge of #135111 - tgross35:float-doc-aliases, r=NoratriebMatthias Krüger-0/+8
Add doc aliases for `libm` and IEEE names Searching "fma" in the Rust documentation returns results for `intrinsics::fma*`, but does not point to the user-facing `mul_add`. Add aliases for `fma*` and the IEEE operation name `fusedMultiplyAdd`. Add the IEEE name to `sqrt` as well, `squareRoot`.
2025-01-04Rollup merge of #134996 - bdbai:uwp-support, r=jieyouxu,ChrisDentonJubilee-2/+3
Add UWP (msvc) target support page - Added Platform Support page for `x86_64-uwp-windows-msvc`, `i686-uwp-windows-msvc`, `thumbv7a-uwp-windows-msvc` and `aarch64-uwp-windows-msvc` - Adding myself as a maintainer - Removing the ticks for `thumbv7a-pc-windows-msvc` and `thumbv7a-uwp-windows-msvc` as they do not currently build due to #134565 and https://github.com/rust-lang/backtrace-rs/pull/685 - Fixed a few minor issues to let most of the UWP targets compile - Happy new year to all! r? jieyouxu
2025-01-05Add doc aliases for `libm` and IEEE namesTrevor Gross-0/+8
Searching "fma" in the Rust documentation returns results for `intrinsics::fma*`, but does not point to the user-facing `mul_add`. Add aliases for `fma*` and the IEEE operation name `fusedMultiplyAdd`. Add the IEEE name to `sqrt` as well, `squareRoot`.
2025-01-03Rollup merge of #133420 - thesummer:rtems-unwind, r=workingjubileeMatthias Krüger-1/+1
Switch rtems target to panic unwind Switch the RTEMS target to `panic_unwind`. Relates to https://github.com/rust-lang/backtrace-rs/pull/682
2025-01-03Auto merge of #135059 - matthiaskrgr:rollup-0ka9o3h, r=matthiaskrgrbors-1/+1
Rollup of 4 pull requests Successful merges: - #131729 (Make the `test` cfg a userspace check-cfg) - #134241 (more concrete source url of std docs [V2]) - #135042 (taint fcx on selection errors during unsizing) - #135049 (Remove unused fields from RepeatElementCopy obligation) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-03Rollup merge of #134241 - liigo:patch-16, r=dtolnayMatthias Krüger-1/+1
more concrete source url of std docs [V2] r? jhpratt since you have reivewed https://github.com/rust-lang/rust/pull/134193 > If someone is looking to contribute, they will want the repository as a whole, not the lib.rs for std. Now the repository url is reserved, I just add another concrete url as an example, to help people finding target page more quickly&easily.
2025-01-03Auto merge of #134692 - GrigorenkoPV:sync_poision, r=tgross35bors-27/+131
Move some things to `std::sync::poison` and reexport them in `std::sync` Tracking issue: #134646 r? `@tgross35` I've used `sync_poison_mod` feature flag instead, because `sync_poison` had already been used back in 1.2. try-job: x86_64-msvc
2025-01-03Fix UWP buildbdbai-2/+3