about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2023-10-19Auto merge of #114534 - niluxv:strict_prov_unwind, r=cuviper,workingjubileebors-46/+94
Strict provenance unwind 1. Turned many `usize`s in the personality/unwind code that are actually pointers into `*const u8`. 2. Rewrote `read_encoded_pointer` to conform to strict-provenance, along the lines as described by `@eddyb` [in zulip some time ago](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/strict.20provenance.20in.20dwarf.3A.3Aeh/near/276197290). This should make supporting CHERI in the future easier (but they use a [slightly modified format in the callsite table](https://cheri-compiler-explorer.cl.cam.ac.uk/z/n6GhhW), which requires a CHERI specific modification to `find_eh_action`).
2023-10-19Auto merge of #116402 - joboet:global_alloc_tls_unsoundness, ↵bors-29/+51
r=thomcc,workingjubilee Panic when the global allocator tries to register a TLS destructor Using a `RefCell` avoids the undefined behaviour encountered in #116390 and reduces the amount of `unsafe` code in the codebase.
2023-10-18std: send free message when xous thread parker is droppedjoboet-1/+7
2023-10-18std: implement thread parking for xousjoboet-1/+89
2023-10-18Add discussion that concurrent access to the environment is unsafeTobias Bucher-10/+28
The bug report #27970 has existed for 8 years, the actual bug dates back to Rust pre-1.0. I documented it since it's in the interest of the user to be aware of it. The note can be removed once #27970 is fixed.
2023-10-17Automatically enable cross-crate inlining for small functionsBen Kimock-0/+1
2023-10-17Auto merge of #116518 - vita-rust:vita, r=workingjubileebors-5/+5
Updated libc and doc for Vita target Doc changes: - Updated Vita target readme. The recommended approach to build artifacts for the platform now is [cargo-vita](https://crates.io/crates/cargo-vita) which wraps all the convoluted steps previously described in a yaml for `cargo-make` - Updated maintainer list for Vita target. (`@ZetaNumbers` `@pheki` please agree to be added to the list, `@amg98` please let us know if you're still planning on actively maintaining target support) Code changes: - ~Updated libc for rust-lang/libc#3284 and rust-lang/libc#3366~ (Already merged in #116527) - In dupfd changed the flag same as for esp target, there is no CLOEXEC on Vita - Enabled `new_pair` since we've implemented `socketpair` in Vita newlib
2023-10-17Updated libc and doc for Vita targetNikolay Arhipov-5/+5
2023-10-16Create `windows/api.rs` for safer FFIChris Denton-53/+212
2023-10-16Improve rewind documentationSean Linsley-0/+4
2023-10-16Auto merge of #116775 - nnethercote:inline-Bytes-next, r=the8472bors-0/+2
Inline `Bytes::next` and `Bytes::size_hint`. This greatly increases its speed. On one small test program using `Bytes::next` to iterate over a large file, execution time dropped from ~330ms to ~220ms. r? `@the8472`
2023-10-16Auto merge of #114589 - ijackson:exit-code-default, r=dtolnaybors-1/+9
impl Default for ExitCode As suggested here https://github.com/rust-lang/rust/pull/106425#issuecomment-1382952598 Needs FCP since this is an insta-stable impl. Ideally we would have `impl From<ExitCode> for ExitStatus` and implement the default `ExitStatus` using that. That is sadly not so easy because of the various strange confusions about `ExitCode` (unix: exit status) vs `ExitStatus` (unix: wait status) in the not-really-unix platforms in `library//src/sys/unix/process`. I'll try to follow that up.
2023-10-15Auto merge of #116772 - matthiaskrgr:rollup-mpff3lh, r=matthiaskrgrbors-4/+168
Rollup of 7 pull requests Successful merges: - #116172 (Broaden the consequences of recursive TLS initialization) - #116341 (Implement sys::args for UEFI) - #116522 (use `PatKind::Error` when an ADT const value has violation) - #116732 (Make x capable of resolving symlinks) - #116755 (Remove me from libcore review rotation) - #116760 (Remove trivial cast in `guaranteed_eq`) - #116771 (Ignore let-chains formatting) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-16Inline `Bytes::next` and `Bytes::size_hint`.Nicholas Nethercote-0/+2
This greatly increases its speed.
2023-10-15Rollup merge of #116341 - Ayush1325:uefi-args, r=Mark-SimulacrumMatthias Krüger-1/+165
Implement sys::args for UEFI - Uses `EFI_LOADED_IMAGE_PROTOCOL`, which is implemented for all loaded images. Tested on qemu with OVMF cc ``@nicholasbishop`` cc ``@dvdhrm``
2023-10-15Rollup merge of #116172 - joboet:recursive_tls_initialization, r=dtolnayMatthias Krüger-3/+3
Broaden the consequences of recursive TLS initialization This PR updates the documentation of `LocalKey` to clearly disallow the behaviour described in [this comment](https://github.com/rust-lang/rust/issues/110897#issuecomment-1525738849). This allows using `OnceCell` for the lazy initialization of TLS variables, which panics on reentrant initialization instead of updating the value like TLS variables currently do. ``@rustbot`` label +T-libs-api r? ``@m-ou-se``
2023-10-15Auto merge of #110604 - a1phyr:vecdeque_buf_read, r=dtolnaybors-0/+18
Implement `BufRead` for `VecDeque<u8>` Note: it would become insta-stable
2023-10-15Deduplicate std::process Default impl feature namesDavid Tolnay-2/+2
error[E0711]: feature `process-exitcode-default` is declared stable since 1.74.0-beta.1, but was previously declared stable since 1.73.0 --> library/std/src/process.rs:1964:1 | 1964 | #[stable(feature = "process-exitcode-default", since = "CURRENT_RUSTC_VERSION")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-15Implement args for UEFIAyush Singh-1/+165
- Uses `EFI_LOADED_IMAGE_PROTOCOL` - verify that cli args are valid UTF-16 - Update Docs Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-10-15Make File::create work on Windows hidden filesChris Denton-7/+64
Previously it failed on Windows if the file had the `FILE_ATTRIBUTE_HIDDEN` attribute set. This was inconsistent with `OpenOptions::new().write(true).truncate(true)` which can truncate an existing hidden file.
2023-10-15Auto merge of #116683 - ChrisDenton:exists, r=Mark-Simulacrumbors-0/+56
Make `try_exists` return `Ok(true)` for Windows Unix Sockets This is a follow up to #109106 but for[ `fs::try_exists`](https://doc.rust-lang.org/std/fs/fn.try_exists.html), which doesn't need to get the metadata of a file (which can fail even if a file exists). `fs::try_exists` currently fails on Windows if encountering a Unix Domain Socket (UDS). This PR fixes it by checking for an error code that's returned when there's a failure to use a reparse point. ## Reparse points A reparse point is a way to invoke a filesystem filter on a file instead of the file being opened normally. This is used to implement symbolic links (by redirecting to a different path) but also to implement other types of special files such as Unix domain sockets. If the reparse point is not a link type then opening it with `CreateFileW` may fail with `ERROR_CANT_ACCESS_FILE` because the filesystem filter does not implement that operation. This differs from resolving links which may fail with errors such as `ERROR_FILE_NOT_FOUND` or `ERROR_CANT_RESOLVE_FILENAME`. So `ERROR_CANT_ACCESS_FILE` means that the file exists but that we can't open it normally. Still, the file does exist on the filesystem so `try_exists` should report that as `Ok(true)`. r? libs
2023-10-14Add Seek::seek_relativeJonathan Behrens-0/+36
2023-10-14Rollup merge of #116540 - daxpedda:once-cell-lock-try-insert, r=Mark-SimulacrumGuillaume Gomez-3/+40
Implement `OnceCell/Lock::try_insert()` I took inspiration from [`once_cell`](https://crates.io/crates/once_cell): - [`once_cell::unsync::OnceCell::try_insert()`](https://github.com/matklad/once_cell/blob/874f9373abd7feaf923a3b3c34bfb3383529c671/src/lib.rs#L551-L563) - [`once_cell::sync::OnceCell::try_insert()`](https://github.com/matklad/once_cell/blob/874f9373abd7feaf923a3b3c34bfb3383529c671/src/lib.rs#L1080-L1087) I tried to change as little code as possible in the first commit and applied some obvious optimizations in the second one. ACP: https://github.com/rust-lang/libs-team/issues/276 Tracking issue: #116693
2023-10-14Fix broken build on ESP-IDF caused by #115108ivmarkov-4/+24
2023-10-14Auto merge of #116407 - Mark-Simulacrum:bootstrap-bump, r=onur-ozkanbors-14/+14
Bump bootstrap compiler to just-released beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2023-10-13Auto merge of #115108 - ijackson:broken-wait-status, r=dtolnaybors-50/+144
Fix exit status / wait status on non-Unix cfg(unix) platforms Fixes #114593 Needs FCP due to behavioural changes (NB only on non-Unix `#[cfg(unix)]` platforms). Also, I think this is likely to break in CI. I have not been yet able to compile the new bits of `process_unsupported.rs`, although I have compiled the new module. I'd like some help from people familiar with eg emscripten and fuchsia (which are going to be affected, I think).
2023-10-13Implement `OnceCell/Lock::try_insert()`daxpedda-3/+40
2023-10-13Make TCP connect() handle EINTR correctlyDenis Smirnov-12/+38
According to the POSIX standard, if connect() is interrupted by a signal that is caught while blocked waiting to establish a connection, connect() shall fail and set errno to EINTR, but the connection request shall not be aborted, and the connection shall be established asynchronously. If asynchronous connection was successfully established after EINTR and before the next connection attempt, OS returns EISCONN that was handled as an error before. This behavior is fixed now and we handle it as success. The problem affects MacOS users: Linux doesn't return EISCONN in this case, Windows connect() can not be interrupted without an old-fashoin WSACancelBlockingCall function that is not used in the library. So current solution gives connect() as OS specific implementation.
2023-10-13Test that unix sockets exist on WindowsChris Denton-0/+49
2023-10-13Make try_exists return Ok(true) for Windows UDSChris Denton-0/+7
`fs::try_exists` currently fails on Windows if encountering a Unix Domain Socket (UDS). Fix this by checking for an error code that's returned when there's a failure to use a reparse point. A reparse point is a way to invoke a filesystem filter on a file instead of the file being opened normally. This is used to implement symbolic links (by redirecting to a different path) but also to implement other types of special files such as Unix domain sockets. If the reparse point is not a link type then opening it with `CreateFileW` may fail with `ERROR_CANT_ACCESS_FILE` because the filesystem filter does not implement that operation. This differs from resolving links which may fail with errors such as `ERROR_FILE_NOT_FOUND` or `ERROR_CANT_RESOLVE_FILENAME`. So `ERROR_CANT_ACCESS_FILE` means that the file exists but that we can't open it normally. Still, the file does exist so `try_exists` should report that as `Ok(true)`.
2023-10-12Auto merge of #116506 - Wilfred:remove_tmp_var, r=workingjubileebors-2/+1
Remove unnecessary tmp variable in default_read_exact This `tmp` variable has existed since the original implementation (added in ff81920f03866674080ac63b565cc9d30f80c450), but it's not necessary (maybe non-lexical lifetimes helped?). It's common to read std source code to understand how things actually work, and this tripped me up on my first read.
2023-10-11Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmeasebors-0/+1
rustdoc: show crate name beside smaller logo *Blocked on https://github.com/rust-lang/cargo/pull/12800* ## Summary In this PR, the crate name and version are always shown in the sidebar, even in subpages, and the lateral navigation is always shown in the sidebar, even in modules. Clicking the crate name does the same thing clicking the logo always did: take you to the crate root (the crate's home page, at least within Rustdoc). The Rust logo is also no longer shown by default for non-Rust docs. ### Screenshots <details><summary>Before</summary> | | Macro | Module | |--|-------|--------| | In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/d5db0a46-2bb6-44a2-a3aa-2d915ecb8595) |![image](https://github.com/rust-lang/rust/assets/1593513/61f8c1ee-c298-4e2c-b791-18ecb79ab83b) | In module[^1] | ![image](https://github.com/rust-lang/rust/assets/1593513/73abca59-0b69-4650-a1e2-7278ca34795c) | ![image](https://github.com/rust-lang/rust/assets/1593513/0baf02c2-2ec7-4674-80e5-a6a74a973376) [^1]: This PR also includes a bug fix for derive macros not showing up in the lateral navigation part of the sidebar </details> #### Whole sidebar screenshots | | Macro | Module | |--|-------|--------| | In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/75d1bd07-41f7-4f11-ba24-fd5476e0586a) | ![image](https://github.com/rust-lang/rust/assets/1593513/52960259-2b65-4131-b380-01826f0a0eb7) | In module | ![image](https://github.com/rust-lang/rust/assets/1593513/06e57928-8cb0-41bd-b152-be16cc53e5ec) | ![image](https://github.com/rust-lang/rust/assets/1593513/37291c69-2a07-4467-a382-d9b029084a47) #### Different logo configurations | | Short crate name | Long crate name | |---------|------------------|-----------------| | Root | ![short-root] | ![long-root] | Subpage | ![short-subpage] | ![long-subpage] [short-root]: https://github.com/rust-lang/rust/assets/1593513/9e2b4fa8-f581-4106-b562-1e0372c13f79 [short-subpage]: https://github.com/rust-lang/rust/assets/1593513/8331cdb8-fa13-4671-a1e2-dcc1cdca7451 [long-root]: https://github.com/rust-lang/rust/assets/1593513/7d377fec-0f1d-4343-9f82-0e35a8f58056 [long-subpage]: https://github.com/rust-lang/rust/assets/1593513/3b3094a4-63c9-477c-8c15-b6075837df30 ##### Without a logo ![image](https://github.com/rust-lang/rust/assets/1593513/66672b79-6c59-4be8-a527-25ef6f0b04ab) ### Preview pages https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket/index.html https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket_sync_db_pools/index.html https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust-compiler/index.html https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust/std/index.html https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/tokio/index.html ## Motivation This improves visual information density (the construct with the logo and crate name is *shorter* than the logo on its own, because it's not square) and navigation clarity (we can now see what clicking the Rust logo does, specifically). Compare this with the layout at [Phoenix's Hexdocs] (which is what this proposal is closely based on), the old proposal on [Internals Discourse] (which always says "Rust standard library" in the sidebar, but doesn't do the side-by-side layout). [Phoenix's Hexdocs]: https://hexdocs.pm/phoenix/1.7.7/overview.html [Internals Discourse]: https://internals.rust-lang.org/t/poc-of-a-new-design-for-the-generated-rustdoc/11018 ## Guide-level explanation This PR cleans up some of the sidebar navigation. It makes the logo in the desktop sidebar a bit smaller, and puts the crate name and version next to it (either beside it, or below it, depending on if there's space), making it clearer what clicking on it does: click the crate name to open the crate's home page. It also removes the Rust logo from non-official-Rust crates, again to make the navigation and supply chain clearer (since the crate name has been added, the logo is no longer necessary for navigation). It adds a bit more clarifying information for lateral navigation. On items that don't add their own sidebar items, it just shows its siblings directly below the crate name and logo, but for other items, it shows "In crate alloc" instead of just "In alloc". It also shows the lateral navigation tools on module pages, making modules consistent with every other item. ## Drawbacks While this actually takes up less screen real estate than the old layout on desktop, it takes up more HTML. It's also a bit more visually complex. ## Rationale and alternatives I could do what the Internals POC did and keep the vertically stacked layout all the time, instead of doing a horizontal stack where possible. It would take up more screen real estate, though. ## Prior art This design is lifted almost verbatim from Hexdocs. It seems to work for them. [`opentelemetry_process_propagator`], for example, has a long application name. [`opentelemetry_process_propagator`]: https://hexdocs.pm/opentelemetry_process_propagator/OpentelemetryProcessPropagator.html ## Unresolved questions Maybe we should encourage crate authors to include their own logo more often? It certainly helps give people a better sense of "place." This seems to be blocked on coming up with an API to do it without requiring them to host the file somewhere. ## Future possibilities Beyond this, plenty of other changes could be made to improve the layout, like * Fix things so that clicking an item in the sidebar doesn't cause it to scroll back to the top. * The [Internals demo](https://utherii.github.io/new.html) does this right: clicking an item in the sidebar changes the content area, but the sidebar itself does not change. This is nice, because clicking is cheap and I can skim the opening few paragraphs while browsing. * The layout of the docs sidebar causes trouble to implement this, because it's different on different pages, but at least fix this on the file browser. * Come up with a less cluttered way to do disclosure. There's a lot of `[-]` on the page. * We don't lack ideas to fix this one. We have *too many*. * Do a better job of separating local navigation (vec::Vec links to vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new). * A possibility: add a Back arrow next to the "In [module]" header? ![image](https://github.com/rust-lang/rust/assets/1593513/e969faf7-7722-457a-b8c6-8d962e9e1e23) * Give readers more control of how much rustdoc shows them, and giving doc authors more control of how much it generates. Basically, https://github.com/rust-lang/rust/pull/115660 is great, let's do it too. But those are mostly orthogonal, not future possibilities unlocked by this change.
2023-10-10On Windows make readdir error on the empty pathChris Denton-0/+8
2023-10-10Rewrite `read_encoded_pointer` conforming to strict provenanceniluxv-28/+69
* Entries in the callsite table now use a dedicated function for reading an offset rather than a pointer * `read_encoded_pointer` uses that new function for reading offsets when the "application" part of the encoding indicates an offset (relative to some pointer) * It now errors out on nonsensical "application" and "value encoding" combinations Inspired by @eddyb's comment on zulip about this: <https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/strict.20provenance.20in.20dwarf.3A.3Aeh/near/276197290>
2023-10-10Use pointers instead of `usize` addresses for landing padsniluxv-34/+41
This bring unwind and personality code more in line with strict-provenance
2023-10-09std: explain unconventional choice of let-else binding over while-let loopjoboet-0/+3
2023-10-09Support AIX in Rust standard libraryQiu Chaofan-3/+457
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+1
2023-10-07std: fix registering of Windows TLS destructorsjoboet-1/+4
2023-10-07Auto merge of #109214 - tosti007:std_collection_hash_new_rework, ↵bors-1/+1
r=workingjubilee Use `HashMap::with_capacity_and_hasher` instead of using base Cleans up the internal logic for `HashMap::with_capacity` slightly.
2023-10-07Remove unnecessary tmp variable in default_read_exactWilfred Hughes-2/+1
This variable seems to serve no purpose, and it's a little confusing when reading std source code, so remove it.
2023-10-07Auto merge of #116501 - workingjubilee:rollup-fpzov6m, r=workingjubileebors-1/+1
Rollup of 4 pull requests Successful merges: - #116277 (dont call mir.post_mono_checks in codegen) - #116400 (Detect missing `=>` after match guard during parsing) - #116458 (Properly export function defined in test which uses global_asm!()) - #116500 (Add tvOS to target_os for register_dtor) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-06Rollup merge of #116500 - simlay:tvos-support-for-register_dtor, ↵Jubilee-1/+1
r=workingjubilee Add tvOS to target_os for register_dtor Closes #116491.
2023-10-06Auto merge of #114709 - ShE3py:wasi-io-error-more, r=workingjubileebors-23/+92
Use `io_error_more` on WASI #86442 added many variants to [`io::ErrorKind`](https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html), but `sys::wasi::decode_error_kind()` wasn't modified to use them. The preview1 `errno` list: https://github.com/WebAssembly/WASI/blob/4712d490fd7662f689af6faa5d718e042f014931/legacy/preview1/docs.md#-errno-variant Original implementation: #63814 `@rustbot` label +A-error-handling +C-enhancement +O-wasi
2023-10-06Add tvOS to target_os for register_dtorSebastian Imlay-1/+1
2023-10-06Rollup merge of #116484 - peterjoel:once-doc-clarify, r=cuviperMatthias Krüger-1/+1
Minor doc clarification in Once::call_once
2023-10-06Use `io_error_more` on WASIShE3py-23/+92
2023-10-06Auto merge of #116483 - GuillaumeGomez:rollup-z65pno1, r=GuillaumeGomezbors-0/+10
Rollup of 6 pull requests Successful merges: - #115454 (Clarify example in docs of str::char_slice) - #115522 (Clarify ManuallyDrop bit validity) - #115588 (Fix a comment in std::iter::successors) - #116198 (Add more diagnostic items for clippy) - #116329 (update some comments around swap()) - #116475 (rustdoc-search: fix bug with multi-item impl trait) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-06Minor doc clarification in Once::call_oncePeter Hall-1/+1
2023-10-06Rollup merge of #116198 - Jarcho:diag_items, r=WaffleLapkinGuillaume Gomez-0/+10
Add more diagnostic items for clippy