about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
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-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: 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-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-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-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-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.
2022-01-24Rollup merge of #93152 - ivmarkov:master, r=m-ou-seMatthias Krüger-3/+7
Fix STD compilation for the ESP-IDF target (regression from CVE-2022-21658) Commit https://github.com/rust-lang/rust/commit/54e22eb7dbb615bd44355028d3fd867aa93c0972 broke the compilation of STD for the ESP-IDF embedded "unix-like" Tier 3 target, because the fix for [CVE-2022-21658](https://blog.rust-lang.org/2022/01/20/Rust-1.58.1.html) uses [libc flags](https://github.com/esp-rs/esp-idf-svc/runs/4892221554?check_suite_focus=true) which are not supported on the ESP-IDF platform. This PR simply redirects the ESP-IDF compilation to the "classic" implementation, similar to REDOX. This should be safe because: * Neither of the two filesystems supported by ESP-IDF (spiffs and fatfs) support [symlinks](https://github.com/natevw/fatfs/blob/master/README.md) in the first place * There is no notion of fs permissions at all, as the ESP-IDF is an embedded platform that does not have the notion of users, groups, etc. * Similarly, ESP-IDF has just one "process" - the firmware itself - which contains the user code and the "OS" fused together and running with all permissions
2022-01-24Rollup merge of #92513 - Xuanwo:path-buf, r=dtolnayMatthias Krüger-0/+19
std: Implement try_reserve and try_reserve_exact on PathBuf Part of https://github.com/rust-lang/rust/issues/91789 Signed-off-by: Xuanwo <github@xuanwo.io>
2022-01-23Rollup merge of #92555 - m-ou-se:scoped-threads, r=AmanieuMatthias Krüger-27/+382
Implement RFC 3151: Scoped threads. This implements https://github.com/rust-lang/rfcs/pull/3151 r? `@Amanieu`
2022-01-23Add os::unix::net::SocketAddr::unixThomas de Zeeuw-1/+68
Creates a new SocketAddr from a path, supports both regular paths and abstract namespaces.
2022-01-22Auto merge of #92998 - Amanieu:hashbrown12, r=Mark-Simulacrumbors-5/+16
Update hashbrown to 0.12.0 [Changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md#v0120---2022-01-17)
2022-01-22Add test for thread::Scope invariance.Mara Bos-0/+13
2022-01-22Add tracking issue number for scoped_threads.Mara Bos-2/+2
2022-01-22Simplify Send/Sync of std::thread::Packet.Mara Bos-7/+5
2022-01-22Rollup merge of #92828 - Amanieu:unwind-abort, r=dtolnayMatthias Krüger-9/+21
Print a helpful message if unwinding aborts when it reaches a nounwind function This is implemented by routing `TerminatorKind::Abort` back through the panic handler, but with a special flag in the `PanicInfo` which indicates that the panic handler should *not* attempt to unwind the stack and should instead abort immediately. This is useful for the planned change in https://github.com/rust-lang/lang-team/issues/97 which would make `Drop` impls `nounwind` by default. ### Code ```rust #![feature(c_unwind)] fn panic() { panic!() } extern "C" fn nounwind() { panic(); } fn main() { nounwind(); } ``` ### Before ``` $ ./test thread 'main' panicked at 'explicit panic', test.rs:4:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Illegal instruction (core dumped) ``` ### After ``` $ ./test thread 'main' panicked at 'explicit panic', test.rs:4:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread 'main' panicked at 'panic in a function that cannot unwind', test.rs:7:1 stack backtrace: 0: 0x556f8f86ec9b - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdccefe11a6ac4396 1: 0x556f8f88ac6c - core::fmt::write::he152b28c41466ebb 2: 0x556f8f85d6e2 - std::io::Write::write_fmt::h0c261480ab86f3d3 3: 0x556f8f8654fa - std::panicking::default_hook::{{closure}}::h5d7346f3ff7f6c1b 4: 0x556f8f86512b - std::panicking::default_hook::hd85803a1376cac7f 5: 0x556f8f865a91 - std::panicking::rust_panic_with_hook::h4dc1c5a3036257ac 6: 0x556f8f86f079 - std::panicking::begin_panic_handler::{{closure}}::hdda1d83c7a9d34d2 7: 0x556f8f86edc4 - std::sys_common::backtrace::__rust_end_short_backtrace::h5b70ed0cce71e95f 8: 0x556f8f865592 - rust_begin_unwind 9: 0x556f8f85a764 - core::panicking::panic_no_unwind::h2606ab3d78c87899 10: 0x556f8f85b910 - test::nounwind::hade6c7ee65050347 11: 0x556f8f85b936 - test::main::hdc6e02cb36343525 12: 0x556f8f85b7e3 - core::ops::function::FnOnce::call_once::h4d02663acfc7597f 13: 0x556f8f85b739 - std::sys_common::backtrace::__rust_begin_short_backtrace::h071d40135adb0101 14: 0x556f8f85c149 - std::rt::lang_start::{{closure}}::h70dbfbf38b685e93 15: 0x556f8f85c791 - std::rt::lang_start_internal::h798f1c0268d525aa 16: 0x556f8f85c131 - std::rt::lang_start::h476a7ee0a0bb663f 17: 0x556f8f85b963 - main 18: 0x7f64c0822b25 - __libc_start_main 19: 0x556f8f85ae8e - _start 20: 0x0 - <unknown> thread panicked while panicking. aborting. Aborted (core dumped) ```
2022-01-22Disable test_try_reserve on AndroidAmanieu d'Antras-0/+1
2022-01-21Rollup merge of #93134 - tlyu:delete-stdin-split, r=AmanieuMatthias Krüger-24/+1
delete `Stdin::split` forwarder Part of #87096. Delete the `Stdin::split` forwarder because it's seen as too niche to expose at this level. `@rustbot` label T-libs-api A-io
2022-01-21Rollup merge of #93109 - JakobDegen:arc-docs, r=m-ou-seMatthias Krüger-7/+13
Improve `Arc` and `Rc` documentation This makes two changes (I can split the PR if necessary, but the changes are pretty small): 1. A bunch of trait implementations claimed to be zero cost; however, they use the `Arc<T>: From<Box<T>>` impl which is definitely not free, especially for large dynamically sized `T`. 2. The code in deferred initialization examples unnecessarily used excessive amounts of `unsafe`. This has been reduced.
2022-01-21Rollup merge of #92586 - esp-rs:bugfix/allocation-alignment-espidf, r=yaahcMatthias Krüger-2/+8
Set the allocation MIN_ALIGN for espidf to 4. Closes https://github.com/esp-rs/rust/issues/99. cc: `@ivmarkov`
2022-01-21Update HashMap::try_reserve test to version from hashbrownAmanieu d'Antras-5/+15