about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2022-02-01Add missing `pub` keywords.Dan Gohman-2/+2
2022-02-01Update the documentation for `{As,Into,From}Raw{Fd,Handle,Socket}`.Dan Gohman-63/+101
This change weakens the descriptions of the `{as,into,from}_raw_{fd,handle,socket}` descriptions from saying that they *do* express ownership relations to say that they are *typically used* in ways that express ownership relations. This needed needed since, for example, std's own [`RawFd`] implements `{As,From,Into}Fd` without any of the ownership relationships. This adds proper `# Safety` comments to `from_raw_{fd,handle,socket}`, adds the requirement that raw handles be not opened with the `FILE_FLAG_OVERLAPPED` flag, and merges the `OwnedHandle::from_raw_handle` comment into the main `FromRawHandle::from_raw_handle` comment. And, this changes `HandleOrNull` and `HandleOrInvalid` to not implement `FromRawHandle`, since they are intended for limited use in FFI situations, and not for generic use, and they have constraints that are stronger than the those of `FromRawHandle`. [`RawFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/type.RawFd.html
2022-02-01Fix annotation of code blocksGeorge Bateman-2/+3
2022-02-01Auto merge of #93442 - yaahc:Termination-abstraction, r=Mark-Simulacrumbors-9/+24
Change Termination::report return type to ExitCode Related to https://github.com/rust-lang/rust/issues/43301 The goal of this change is to minimize the forward compatibility risks in stabilizing Termination. By using the opaque type `ExitCode` instead of an `i32` we leave room for us to evolve the API over time to provide what cross-platform consistency we can / minimize footguns when working with exit codes, where as stabilizing on `i32` would limit what changes we could make in the future in how we represent and construct exit codes.
2022-02-01Link `try_exists` docs to `Path::exists`Chris Denton-2/+6
2022-02-01Rollup merge of #92584 - lcnr:query-stable-lint, r=estebankMatthias Krüger-0/+20
add rustc lint, warning when iterating over hashmaps 2 first introduced in #89558 and reverted in #90380 due to its perf impact r? ``@estebank``
2022-02-01add a rustc::query_stability lintlcnr-0/+20
2022-01-31Rollup merge of #93504 - solid-rs:fix-kmc-solid-stack-size, r=nagisaEric Huss-1/+2
kmc-solid: Increase the default stack size This PR increases the default minimum stack size on the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets to 64KiB (Arm) and 128KiB (AArch64). This value was chosen as a middle ground between supporting a relatively complex program (e.g., an application using a full-fledged off-the-shelf web server framework) with no additional configuration and minimizing resource consumption for the embedded platform that doesn't support lazily-allocated pages nor over-commitment (i.e., wasted stack spaces are wasted physical memory). If the need arises, the users can always set the `RUST_MIN_STACK` environmental variable to override the default stack size or use the platform API directly.
2022-01-31Rollup merge of #93090 - jyn514:errorkind-asstr, r=dtolnayEric Huss-1/+17
`impl Display for io::ErrorKind` This avoids having to convert from `ErrorKind` to `Error` just to print the error message.
2022-02-01Fix incorrect panic message in exampleTheVoid-1/+1
2022-01-31(#93493) Add items from code reviewGeorge Bateman-15/+35
2022-01-31fix error handling for pthread_sigmask(3)Ralf Sager-5/+5
Errors from pthread_sigmask(3) were handled using cvt(), which expects a return value of -1 on error and uses errno. However, pthread_sigmask(3) returns 0 on success and an error number otherwise. Fix it by replacing cvt() with cvt_nz().
2022-01-31add inline attribute to new methodJane Lusby-1/+2
2022-01-31kmc-solid: Increase the default stack sizeTomoaki Kawada-1/+2
2022-01-31Rollup merge of #93494 - solid-rs:fix-kmc-solid-spawned-task-priority, ↵Matthias Krüger-5/+2
r=Mark-Simulacrum kmc-solid: Inherit the calling task's base priority in `Thread::new` This PR fixes the initial priority calculation of spawned threads on the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets. Fixes a spawned task (an RTOS object on top of which threads are implemented for this target; unrelated to async tasks) getting an unexpectedly higher priority if it's spawned by a task whose priority is temporarily boosted by a priority-protection mutex.
2022-01-31Rollup merge of #93471 - cuviper:direntry-file_type-stat, r=the8472Matthias Krüger-2/+2
unix: Use metadata for `DirEntry::file_type` fallback When `DirEntry::file_type` fails to match a known `d_type`, we should fall back to `DirEntry::metadata` instead of a bare `lstat`, because this is faster and more reliable on targets with `fstatat`.
2022-01-31Rollup merge of #93462 - ChrisDenton:systime-doc, r=joshtriplettMatthias Krüger-1/+6
Document `SystemTime` platform precision Fixes #88822
2022-01-31kmc-solid: `SOLID_RTC_TIME::tm_mon` is 1-basedTomoaki Kawada-1/+1
2022-01-31kmc-solid: Inherit the calling task's base priority in `Thread::new`Tomoaki Kawada-5/+2
Fixes a spawned task getting an unexpectedly higher priority if it's spawned by a task whose priority is temporarily boosted by a priority- protection mutex.
2022-01-30Document char validityGeorge Bateman-5/+33
2022-01-30Rollup merge of #92887 - pietroalbini:pa-bootstrap-update, r=Mark-SimulacrumEric Huss-27/+13
Bootstrap compiler update r? ``@Mark-Simulacrum``
2022-01-29unix: Use metadata for `DirEntry::file_type` fallbackJosh Stone-2/+2
When `DirEntry::file_type` fails to match a known `d_type`, we should fall back to `DirEntry::metadata` instead of a bare `lstat`, because this is faster and more reliable on targets with `fstatat`.
2022-01-30Rollup merge of #93459 - tavianator:dirent-copy-only-reclen, r=cuviperMatthias Krüger-2/+26
fs: Don't copy d_name from struct dirent The dirent returned from readdir() is only guaranteed to be valid for d_reclen bytes on common platforms. Since we copy the name separately anyway, we can copy everything except d_name into DirEntry::entry. Fixes #93384.
2022-01-30Rollup merge of #93414 - Amanieu:std_arch_detect, r=m-ou-seMatthias Krüger-19/+25
Move unstable is_{arch}_feature_detected! macros to std::arch These macros are unstable, except for `is_x86_feature_detected` which is still exported from the crate root for backwards-compatibility. This should unblock the stabilization of `is_aarch64_feature_detected`. r? ```@m-ou-se```
2022-01-29fs: Add a regression test for #93384Tavian Barnes-0/+16
2022-01-29fs: Don't copy d_name from struct direntTavian Barnes-2/+10
The dirent returned from readdir() is only guaranteed to be valid for d_reclen bytes on common platforms. Since we copy the name separately anyway, we can copy everything except d_name into DirEntry::entry. Fixes #93384.
2022-01-29Document `SystemTime` platform precisionChris Denton-1/+6
2022-01-29Rollup merge of #93410 - solid-rs:feat-kmc-solid-net-dup, r=dtolnayMatthias Krüger-1/+4
kmc-solid: Implement `net::FileDesc::duplicate` This PR implements `std::sys::solid::net::FileDesc::duplicate`, which was accidentally left out when this target was added by #86191.
2022-01-29Auto merge of #93351 - anp:fuchsia-remove-dir-all, r=tmandrybors-2/+0
Bump libc and fix remove_dir_all on Fuchsia after CVE fix With the previous `is_dir` impl, we would attempt to unlink a directory in the None branch, but Fuchsia supports returning ENOTEMPTY from unlinkat() without the AT_REMOVEDIR flag because we don't currently differentiate unlinking files and directories by default. On the Fuchsia side I've opened https://fxbug.dev/92273 to discuss whether this is the correct behavior, but it doesn't seem like addressing the error code is necessary to make our tests happy. Depends on https://github.com/rust-lang/libc/pull/2654 since we apparently haven't needed to reference DT_UNKNOWN before this.
2022-01-28Change Termination::report return type to ExitCodeJane Lusby-9/+23
2022-01-28Fix remove_dir_all on Fuchsia after CVE fix.Adam Perry-2/+0
With the previous `is_dir` impl, we would attempt to unlink a directory in the None branch, but Fuchsia supports returning ENOTEMPTY from unlinkat() without the AT_REMOVEDIR flag because we don't currently differentiate unlinking files and directories by default. On the Fuchsia side I've opened https://fxbug.dev/92273 to discuss whether this is the correct behavior, but it doesn't seem like addressing the error code is necessary to make our tests happy. Updates std's libc crate to include DT_UNKNOWN for Fuchsia.
2022-01-28Rollup merge of #93295 - ChrisDenton:tempdir-double-panic, r=dtolnayMatthias Krüger-1/+7
Avoid double panics when using `TempDir` in tests `TempDir` could panic on drop if `remove_dir_all` returns an error. If this happens while already panicking, the test process would abort and therefore not show the test results. This PR tries to avoid such double panics.
2022-01-28Rollup merge of #93239 - Thomasdezeeuw:socketaddr_creation, r=m-ou-seMatthias Krüger-8/+48
Add os::unix::net::SocketAddr::from_path Creates a new SocketAddr from a path, supports both regular paths and abstract namespaces. Note that `SocketAddr::from_abstract_namespace` could be removed after this as `SocketAddr::unix` also supports abstract namespaces. Updates #65275 Unblocks https://github.com/tokio-rs/mio/issues/1527 r? `@m-ou-se`
2022-01-28update cfg(bootstrap)sPietro Albini-27/+13
2022-01-28Update tracking issue for unix_socket_creationThomas de Zeeuw-1/+1
2022-01-28wasi: enable TcpListener and TcpStreamHarald Hoyer-13/+77
With the addition of `sock_accept()` to snapshot1, simple networking via a passed `TcpListener` is possible. This patch implements the basics to make a simple server work. Signed-off-by: Harald Hoyer <harald@profian.com>
2022-01-28wasi: update to wasi 0.11.0Harald Hoyer-24/+44
To make use of `sock_accept()`, update the wasi crate to `0.11.0`. Signed-off-by: Harald Hoyer <harald@profian.com>
2022-01-28Move unstable is_{arch}_feature_detected! macros to std::archAmanieu d'Antras-19/+25
2022-01-28kmc-solid: Implement `FileDesc::duplicate`Tomoaki Kawada-1/+4
2022-01-27Rollup merge of #91641 - dtolnay:cchar-if, r=Mark-SimulacrumMatthias Krüger-88/+62
Define c_char using cfg_if rather than repeating 40-line cfg Libstd has a 40-line cfg that defines the targets on which `c_char` is unsigned, and then repeats the same cfg with `not(…)` for the targets on which `c_char` is signed. This PR replaces it with a `cfg_if!` in which an `else` takes care of the signed case. I confirmed that `x.py doc library/std` inlines the type alias because c_char_definition is not a publicly accessible path: ![Screenshot from 2021-12-07 13-42-07](https://user-images.githubusercontent.com/1940490/145110596-f1058406-9f32-44ff-9a81-1dfd19b4a24f.png)
2022-01-27pub use std::simd::StdFloat;Jubilee Young-2/+20
Make available the remaining float intrinsics that require runtime support from a platform's libm, and thus cannot be included in a no-deps libcore, by exposing them through a sealed trait, `std::simd::StdFloat`. We might use the trait approach a bit more in the future, or maybe not. Ideally, this trait doesn't stick around, even if so. If we don't need to intermesh it with std, it can be used as a crate, but currently that is somewhat uncertain.
2022-01-27Use sockaddr_un in unix SocketAddr::from_pathThomas de Zeeuw-35/+1
2022-01-27Make sockaddr_un safe and use copy_nonoverlappingThomas de Zeeuw-8/+11
The creation of libc::sockaddr_un is a safe operation, no need for it to be unsafe. This also uses the more performant copy_nonoverlapping instead of an iterator.
2022-01-26Add documentation about `BorrowedFd::to_owned`.Dan Gohman-0/+12
Following up on #88564, this adds documentation explaining why `BorrowedFd::to_owned` returns another `BorrowedFd` rather than an `OwnedFd`. And similar for `BorrowedHandle` and `BorrowedSocket`.
2022-01-26Rollup merge of #92778 - tavianator:linux-readdir-no-r, r=joshtriplettMatthias Krüger-36/+58
fs: Use readdir() instead of readdir_r() on Linux and Android See #40021 for more details. Fixes #86649. Fixes #34668.
2022-01-26Improve Duration::try_from_secs_f32/64 accuracy by directly processing ↵Артём Павлов [Artyom Pavlov]-2/+2
exponent and mantissa
2022-01-25make Windows abort_internal Miri-compatibleRalf Jung-0/+1
2022-01-25Avoid double panics when using `TempDir` in testsChris Denton-1/+7
2022-01-25Rollup merge of #88794 - sunfishcode:sunfishcode/try-clone, r=joshtriplettMatthias Krüger-91/+151
Add a `try_clone()` function to `OwnedFd`. As suggested in #88564. This adds a `try_clone()` to `OwnedFd` by refactoring the code out of the existing `File`/`Socket` code. r? ``@joshtriplett``
2022-01-24Rename SocketAddr::unix to from_pathThomas de Zeeuw-16/+20
And change it to disallow NULL bytes.