about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2024-04-12Stabilize (const_)slice_ptr_len and (const_)slice_ptr_is_empty_nonnullEduardo Sánchez Muñoz-1/+0
2024-04-12Add `unsafe` to two functions with safety invariantsEduardo Sánchez Muñoz-12/+14
2024-04-12zkvm: remove cmathMarijan Petričević-2/+0
- Remove cmath from zkvm module since cmath was moved to sys and is shared by all platforms (see #120109)
2024-04-12std::net: TcpListener shrinks the backlog argument to 32 for Haiku.David Carlier-0/+4
2024-04-12Update document for std::io::Error::downcastJiahao XU-6/+6
2024-04-12fix typo in library/std/src/lib.rskamaboko123-1/+1
2024-04-12Avoid panicking branch in `append_to_string`Benoît du Garreau-1/+4
2024-04-12`VecDeque::read_to_string`: avoid making the slices contiguousBenoît du Garreau-9/+2
2024-04-12Improve several `Read` implementationsBenoît du Garreau-1/+28
2024-04-12Rollup merge of #123826 - kornelski:one-in-a-quintillion, r=AmanieuMatthias Krüger-2/+8
Move rare overflow error to a cold function `scoped.spawn()` generates unnecessary inlined panic-formatting code for a branch that will never be taken.
2024-04-11Move rare overflow error to a cold functionKornel-2/+8
2024-04-11Rollup merge of #123806 - joboet:advanced_overflow, r=AmanieuMatthias Krüger-0/+9
Panic on overflow in `BorrowedCursor::advance` Passing `usize::MAX` to `advance` clearly isn't correct, but the current assertion fails to detect this when overflow checks are disabled. This isn't unsound, but should probably be fixed regardless.
2024-04-11Rollup merge of #122882 - Zoxc:panic-output-panic, r=AmanieuMatthias Krüger-9/+29
Avoid a panic in `set_output_capture` in the default panic handler This avoid a panic in the default panic handler by not using `set_output_capture` as `OUTPUT_CAPTURE.with` may panic once `OUTPUT_CAPTURE` is dropped. A new non-panicking `try_set_output_capture` variant of `set_output_capture` is added for use in the default panic handler.
2024-04-12Stabilize `Seek::seek_relative`Slanterns-2/+1
2024-04-11Auto merge of #123732 - a1phyr:io_error_factor, r=cuviperbors-159/+67
Factor some common `io::Error` constants
2024-04-11std: use queue-based `RwLock` on Windows 7joboet-50/+6
2024-04-11std: use queue-based `RwLock` on Xousjoboet-74/+0
2024-04-11std: use queue-based `RwLock` on SGXjoboet-261/+47
2024-04-11std: remove `sys_common::thread`joboet-24/+22
2024-04-11core: panic on overflow in `BorrowedCursor`joboet-0/+9
2024-04-11OpenBSD fix long socket addressesSebastien Marie-0/+10
Original diff from @notgull in #118349, small changes from me. on OpenBSD, getsockname(2) returns the actual size of the socket address, and not the len of the content. Figure out the length for ourselves. see https://marc.info/?l=openbsd-bugs&m=170105481926736&w=2 Fixes #116523
2024-04-11Factor some common `io::Error` constantsBenoît du Garreau-159/+67
2024-04-11Rollup merge of #123756 - lukas-code:file-sync, r=jhprattLeón Orell Valerian Liehr-3/+11
clean up docs for `File::sync_*` * Clarify that `sync_all` also writes data and not just metadata. * Clarify that dropping a file is not equivalent to calling `sync_all` and ignoring the result. `sync_all` the still the recommended way to detect errors before closing, because we don't have a dedicated method for that. * Add a link from `sync_all` to `sync_data`, because that's what the user might want to use instead. * Add doc aliases for `fsync` -> `sync_all` and `fdatasync` -> `sync_data`. Those are the POSIX standard names for these functions. I was trying to find out what we call `fsync` in Rust and had to search through the source code to find it, so this alias should help with that in the future.
2024-04-11Rollup merge of #123360 - adamgemmell:dev/adagem01/restricted-std, r=ehussLeón Orell Valerian Liehr-1/+10
Document restricted_std This PR aims to pin down exactly what restricted_std is meant to achieve and what it isn't. This commit fixes https://github.com/rust-lang/wg-cargo-std-aware/issues/87 by explaining why the error appears and what the choices the user has. The error describes how std cannot function without knowing about some form of OS/platform support. Any features of std that work without an OS should be moved to core/alloc (see https://github.com/rust-lang/rust/issues/27242 https://github.com/rust-lang/rust/issues/103765). Note that the message says "platform" and "environment" because, since https://github.com/rust-lang/rust/pull/120232, libstd can be built for some JSON targets. This is still unsupported (all JSON targets probably should be unstable https://github.com/rust-lang/wg-cargo-std-aware/issues/90), but a JSON target with the right configuration should hopefully have some partial libstd support. I propose closing https://github.com/rust-lang/wg-cargo-std-aware/issues/69 as "Won't fix" since any support of std without properly configured os, vendor or env fields is very fragile considering future upgrades of Rust or dependencies. In addition there's no likely path to it being fixed long term (making std buildable for all targets being the only solution). This is distinct from tier 3 platforms with limited std support implemented (and as such aren't restricted_std) because these platforms can conceptually work in the future and std support should mainly improve over time. The alternative to closing https://github.com/rust-lang/wg-cargo-std-aware/issues/69 is a new crate feature for std which escapes the restricted_std mechanism in build.rs. It could be used with the -Zbuild-std-features flag if we keep it permanently unstable, which I hope we can do anyway. A minor side-effect in this scenario is that std wouldn't be marked as unstable if documentation for it were generated with build-std. cc ```@ehuss```
2024-04-11Rollup merge of #122470 - tgross35:f16-f128-step4-libs-min, r=AmanieuLeón Orell Valerian Liehr-0/+114
`f16` and `f128` step 4: basic library support This is the next step after https://github.com/rust-lang/rust/pull/121926, another portion of https://github.com/rust-lang/rust/pull/114607 Tracking issue: https://github.com/rust-lang/rust/issues/116909 This PR adds the most basic operations to `f16` and `f128` that get lowered as LLVM intrinsics. This is a very small step but it seemed reasonable enough to add unopinionated basic operations before the larger modules that are built on top of them. r? ```@Amanieu``` since you were pretty involved in the RFC cc ```@compiler-errors``` ```@rustbot``` label +T-libs-api +S-blocked +F-f16_and_f128
2024-04-10clean up docs for `File::sync_*`Lukas Markeffsky-3/+11
2024-04-10Add basic f16 and f128 modulesTrevor Gross-0/+114
Create empty modules so `rustdoc` has someplace to link to for these types.
2024-04-10Auto merge of #123725 - GuillaumeGomez:rollup-gk2bbrg, r=GuillaumeGomezbors-6/+123
Rollup of 7 pull requests Successful merges: - #118391 (Add `REDUNDANT_LIFETIMES` lint to detect lifetimes which are semantically redundant) - #123534 (Windows: set main thread name without re-encoding) - #123659 (Add support to intrinsics fallback body) - #123689 (Add const generics support for pattern types) - #123701 (Only assert for child/parent projection compatibility AFTER checking that theyre coming from the same place) - #123702 (Further cleanup cfgs in the UI test suite) - #123706 (rustdoc: reduce per-page HTML overhead) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-10Rollup merge of #123534 - ChrisDenton:name, r=workingjubileeGuillaume Gomez-6/+123
Windows: set main thread name without re-encoding As a minor optimization, we can skip the runtime UTF-8 to UTF-16 conversion.
2024-04-10visionOS: Fix unused import warningMads Marquart-12/+1
The import is used once in this file, inside `posix_spawn`, so let's move the import into that function instead, to reduce the number of `cfg`s that need to be kept in sync.
2024-04-10Rework Path::ancestors documentation to remove unwrapsKriskras99-4/+3
If you take a quick glance at the documentation for Path::ancestors, the unwraps take the natural focus. Potentially indicating that ancestors might panic. In the reworked version I've also moved the link with parent returning None and that the iterator will always yield &self to before the yield examples.
2024-04-10Auto merge of #122393 - a1phyr:specialize_read_buf_exact, r=joboetbors-18/+74
Specialize many implementations of `Read::read_buf_exact` This makes all implementations of `Read` that have a specialized `read_exact` implementation also have one for `read_buf_exact`.
2024-04-10Bring documentation of Path::to_path_buf in line with the rest of Path/PathBufKriskras99-2/+2
Changes the example from using the qualified path of PathBuf with an import. This is what's done in all other Path/PathBuf examples and makes the code look a bit cleaner.
2024-04-10Auto merge of #122812 - dtolnay:mode, r=workingjubileebors-5/+186
Show mode_t as octal in std::fs Debug impls Example: ```rust fn main() { println!("{:?}", std::fs::metadata("Cargo.toml").unwrap().permissions()); } ``` - Before: `Permissions(FilePermissions { mode: 33204 })` - ~~After: `Permissions(FilePermissions { mode: 0o100664 })`~~ - After: `Permissions(FilePermissions { mode: 0o100664 (-rw-rw-r--) })` ~~I thought about using the format from `ls -l` (`-rw-rw-r--`, `drwxrwxr-x`) but I am not sure how transferable the meaning of the higher bits between different unix systems, and anyway starting the value with a leading negative-sign seems objectionable.~~
2024-04-09Update documentation related to the recent cmd.exe fixTrevor Gross-38/+59
Fix some grammar nits, change `bat` (extension) -> `batch` (file), and make line wrapping more consistent.
2024-04-10Rollup merge of #123633 - bjorn3:unsupported_command_data, r=jhprattMatthias Krüger-31/+119
Store all args in the unsupported Command implementation This allows printing them in the Debug impl as well as getting them again using the get_args() method. This allows programs that would normally spawn another process to more easily show which program they would have spawned if not for the fact that the target doesn't support spawning child processes without requiring intrusive changes to keep the args. For example rustc compiled to wasi will show the full linker invocation that would have been done.
2024-04-09Show mode_t as octal in std::fs Debug implsDavid Tolnay-5/+186
2024-04-09Add comment on UTF-16 surrogatesChris Denton-0/+2
2024-04-09Windows: set main thread name without reencodingChris Denton-4/+8
2024-04-09Add const UTF-8 to UTF-16 conversion macrosChris Denton-2/+113
`wide_str!` creates a null terminated UTF-16 string whereas `utf16!` just creates a UTF-16 string without adding a null.
2024-04-09Auto merge of #123683 - pietroalbini:pa-cve-2024-24576-nightly, r=pietroalbinibors-14/+226
Backport fix of CVE-2024-24576 See https://blog.rust-lang.org/2024/04/09/cve-2024-24576.html r? `@ghost`
2024-04-09Auto merge of #123485 - madsmtm:use-libc-copyfile, r=joboetbors-39/+10
macOS: Use `libc` definitions for copyfile `COPYFILE_ALL` is not yet exposed in `libc`, but the rest of what we need is, so use those definitions instead of manually defining them. The definitions were added in https://github.com/rust-lang/libc/pull/2667 and https://github.com/rust-lang/libc/pull/3346.
2024-04-09Fix dead code warningbjorn3-0/+1
2024-04-09Document Windows argument splittingChris Denton-2/+133
2024-04-09Disallow or quote all specials in bat argsChris Denton-12/+93
2024-04-08Change method calls to using the method directlyTrevor Gross-3/+3
This is in accordance with Clippy's redundant_closure_for_method_calls.
2024-04-08Add `SAFETY` comments to the thread local implementationTrevor Gross-10/+12
Reduce `unsafe` block scope and add `SAFETY` comments.
2024-04-08Update thread local docs with idiomatic cell type useTrevor Gross-15/+17
The `thread_local!` examples use `RefCell` for `Copy` types. Update examples to have one `Copy` and one non-`Copy` type using `Cell` and `RefCell`, respectively.
2024-04-08Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errorsbors-0/+6
Implement minimal, internal-only pattern types in the type system rebase of https://github.com/rust-lang/rust/pull/107606 You can create pattern types with `std::pat::pattern_type!(ty is pat)`. The feature is incomplete and will panic on you if you use any pattern other than integral range patterns. The only way to create or deconstruct a pattern type is via `transmute`. This PR's implementation differs from the MCP's text. Specifically > This means you could implement different traits for different pattern types with the same base type. Thus, we just forbid implementing any traits for pattern types. is violated in this PR. The reason is that we do need impls after all in order to make them usable as fields. constants of type `std::time::Nanoseconds` struct are used in patterns, so the type must be structural-eq, which it only can be if you derive several traits on it. It doesn't need to be structural-eq recursively, so we can just manually implement the relevant traits on the pattern type and use the pattern type as a private field. Waiting on: * [x] move all unrelated commits into their own PRs. * [x] fix niche computation (see 2db07f94f44f078daffe5823680d07d4fded883f) * [x] add lots more tests * [x] T-types MCP https://github.com/rust-lang/types-team/issues/126 to finish * [x] some commit cleanup * [x] full self-review * [x] remove 61bd325da19a918cc3e02bbbdce97281a389c648, it's not necessary anymore I think. * [ ] ~~make sure we never accidentally leak pattern types to user code (add stability checks or feature gate checks and appopriate tests)~~ we don't even do this for the new float primitives * [x] get approval that [the scope expansion to trait impls](https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/Pattern.20types.20types-team.23126/near/427670099) is ok r? `@BoxyUwU`
2024-04-08Store all args in the unsupported Command implementationbjorn3-31/+118
This allows printing them in the Debug impl as well as getting them again using the get_args() method. This allows programs that would normally spawn another process to more easily show which program they would have spawned if not for the fact that the target doesn't support spawning child processes without requiring intrusive changes to keep the args. For example rustc compiled to wasi will show the full linker invocation that would have been done.