about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2021-03-04ExitStatus stop signal display test: Make it Linux onlyIan Jackson-2/+7
MacOS uses a different representation. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-03-03Add impls for iterators of Cow<OsStr>Ryan Lopopolo-0/+34
2021-03-03Avoid unnecessary Vec construction in BufReaderCaleb Sander-4/+4
2021-03-03Fix std testsRyan Levick-4/+4
2021-03-03Auto merge of #82718 - JohnTitor:rollup-vpfx3j2, r=JohnTitorbors-46/+49
Rollup of 10 pull requests Successful merges: - #81223 ([rustdoc] Generate redirect map file) - #82439 (BTree: fix untrue safety) - #82469 (Use a crate to produce rustdoc tree comparisons instead of the `diff` command) - #82589 (unix: Non-mutable bufs in send_vectored_with_ancillary_to) - #82689 (meta: Notify Zulip for rustdoc nominated issues) - #82695 (Revert non-power-of-two vector restriction) - #82706 (use outer_expn_data() instead of outer_expn().expn_data()) - #82710 (FloatToInit: Replacing round_unchecked_to --> to_int_unchecked) - #82712 (Remove unnecessary conditional `cfg(target_os)` for `redox` and `vxworks`) - #82713 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-03-03Rollup merge of #82712 - CDirkx:cfg-target_os, r=dtolnayYuki Okushi-1/+1
Remove unnecessary conditional `cfg(target_os)` for `redox` and `vxworks` `redox` and `vxworks` are now part of target_family `unix`, thus `cfg(unix)` already implies `cfg(target_os="redox")` and `cfg(target_os="vxworks")` https://github.com/rust-lang/rust/blob/35dbef235048f9a2939dc20effe083ca483c37ff/compiler/rustc_target/src/spec/redox_base.rs#L26 https://github.com/rust-lang/rust/blob/35dbef235048f9a2939dc20effe083ca483c37ff/compiler/rustc_target/src/spec/vxworks_base.rs#L27
2021-03-03Rollup merge of #82589 - LinkTed:master, r=joshtriplettYuki Okushi-45/+48
unix: Non-mutable bufs in send_vectored_with_ancillary_to This is the same PR as [#79753](https://github.com/rust-lang/rust/pull/79753). It was closed because of inactivity. Therefore, I create a new one. ````@lukaslihotzki````
2021-03-03Auto merge of #76345 - okready:sgx-mem-range-overflow-checks, r=joshtriplettbors-8/+34
Add is_enclave_range/is_user_range overflow checks Fixes #76343. This adds overflow checking to `is_enclave_range` and `is_user_range` in `sgx::os::fortanix_sgx::mem` in order to mitigate possible security issues with enclave code. It also accounts for an edge case where the memory range provided ends exactly at the end of the address space, where calculating `p + len` would overflow back to zero despite the range potentially being valid.
2021-03-03Remove unnecessary conditional `cfg(target_os)` for `redox` and `vxworks`Christiaan Dirkx-1/+1
`redox` and `vxworks` are part of target_family `unix`, thus `cfg(unix)` already implies `cfg(target_os="redox")` and `(target_os="vxworks")`
2021-03-02Rollup merge of #80189 - jyn514:convert-primitives, r=poliorceticsYuki Okushi-20/+15
Convert primitives in the standard library to intra-doc links Blocked on https://github.com/rust-lang/rust/pull/80181. I forgot that this needs to wait for the beta bump so the standard library can be documented with `doc --stage 0`. Notably I didn't convert `core::slice` because it's like 50 links and I got scared :fearful:
2021-03-02Rollup merge of #82598 - GuillaumeGomez:rustdoc-rustc-pass, r=jyn514Guillaume Gomez-1/+3
Check stability and feature attributes in rustdoc Fixes #82588. cc `@Nemo157` `@camelid` r? `@jyn514`
2021-03-02Move `std::sys::unix::platform` to `std::sys::unix::ext`Christiaan Dirkx-38/+40
2021-03-01Add missing stability attributes in libstdGuillaume Gomez-1/+3
2021-03-01Rollup merge of #82645 - rkjnsn:patch-3, r=Mark-SimulacrumJoshua Nelson-1/+4
Clarify that SyncOnceCell::set blocks. Reading the discussion of this feature, I gained the mistaken impression that neither `set` nor `get` blocked, and thus calling `get` immediately after `set` was not guaranteed to succeed. It turns out that `set` *does* block, guaranteeing that the cell contains a value once `set` returns. This change updates the documentation to state that explicitly. Happy to adjust the wording as desired.
2021-03-01Rollup merge of #82578 - camsteffen:diag-items, r=oli-obkJoshua Nelson-0/+1
Add some diagnostic items for Clippy
2021-03-01Add diagnostic itemsCameron Steffen-0/+1
2021-02-28Clarify that SyncOnceCell::set blocks.Erik Jensen-1/+4
Reading the discussion of this feature, I gained the mistaken impression that neither `set` nor `get` blocked, and thus calling `get` immediately after `set` was not guaranteed to succeed. It turns out that `set` *does* block, guaranteeing that the cell contains a value once `set` returns. This change updates the documentation to state that explicitly.
2021-02-28unix: Non-mutable bufs in send_vectored_with_ancillary_toLinkTed-45/+48
Change the arguments of `send_vectored_with_ancillary` and `send_vectored_with_ancillary_to` to take an non-mutable bufs.
2021-02-28Auto merge of #82594 - nagisa:nagisa/remove-rumprun, r=petrochenkovbors-4/+4
Remove the x86_64-rumprun-netbsd target Herein we remove the target from the compiler and the code from libstd intended to support the now-defunct rumprun project. Closes #81514
2021-02-27Rollup merge of #82596 - matklad:rwlock, r=sfacklerDylan DPC-1/+3
clarify RW lock's priority gotcha In particular, the following program works on Linux, but deadlocks on mac: ```rust use std::{ sync::{Arc, RwLock}, thread, time::Duration, }; fn main() { let lock = Arc::new(RwLock::new(())); let r1 = thread::spawn({ let lock = Arc::clone(&lock); move || { let _rg = lock.read(); eprintln!("r1/1"); sleep(1000); let _rg = lock.read(); eprintln!("r1/2"); sleep(5000); } }); sleep(100); let w = thread::spawn({ let lock = Arc::clone(&lock); move || { let _wg = lock.write(); eprintln!("w"); } }); sleep(100); let r2 = thread::spawn({ let lock = Arc::clone(&lock); move || { let _rg = lock.read(); eprintln!("r2"); sleep(2000); } }); r1.join().unwrap(); r2.join().unwrap(); w.join().unwrap(); } fn sleep(ms: u64) { std::thread::sleep(Duration::from_millis(ms)) } ``` Context: I was completely mystified by a my CI deadlocking on mac ([here](https://github.com/matklad/xshell/pull/7)), until ``@azdavis`` debugged the issue. See a stand-alone reproduciton here: https://github.com/matklad/xshell/pull/15
2021-02-27Rollup merge of #82561 - tspiteri:cube-root, r=Dylan-DPCDylan DPC-2/+2
doc: cube root, not cubic root Like we say square root, not quadratic root.
2021-02-27Rollup merge of #82395 - pickfire:see-more, r=GuillaumeGomezDylan DPC-2/+2
Add missing "see its documentation for more" stdio StdoutLock and StderrLock does not have example, it would be better to leave "see its documentation for more" like iter docs.
2021-02-27Update library/std/src/sync/rwlock.rsAleksey Kladov-1/+1
Co-authored-by: Steven Fackler <sfackler@gmail.com>
2021-02-27clarify RW lock's priority gotchaAleksey Kladov-1/+3
In particular, the following program works on Linux, but deadlocks on mac: use std::{ sync::{Arc, RwLock}, thread, time::Duration, }; fn main() { let lock = Arc::new(RwLock::new(())); let r1 = thread::spawn({ let lock = Arc::clone(&lock); move || { let _rg = lock.read(); eprintln!("r1/1"); sleep(1000); let _rg = lock.read(); eprintln!("r1/2"); sleep(5000); } }); sleep(100); let w = thread::spawn({ let lock = Arc::clone(&lock); move || { let _wg = lock.write(); eprintln!("w"); } }); sleep(100); let r2 = thread::spawn({ let lock = Arc::clone(&lock); move || { let _rg = lock.read(); eprintln!("r2"); sleep(2000); } }); r1.join().unwrap(); r2.join().unwrap(); w.join().unwrap(); } fn sleep(ms: u64) { std::thread::sleep(Duration::from_millis(ms)) }
2021-02-27Remove the x86_64-rumprun-netbsd targetSimonas Kazlauskas-4/+4
Closes #81514
2021-02-27Rollup merge of #82473 - de-vri-es:android-x86-accept4, r=m-ou-seDylan DPC-7/+1
Use libc::accept4 on Android instead of raw syscall. This PR replaces the use of a raw `accept4` syscall with `libc::accept4`. This was originally added (by me) because `std` couldn't update to the latest `libc` with `accept4` support for android. By now, libc is already on 0.2.85, so the workaround can be removed. `@rustbot` label +O-android +T-libs-impl
2021-02-27Rollup merge of #82421 - sunfishcode:wasi-metadata-size, r=alexcrichtonDylan DPC-0/+5
Add a `size()` function to WASI's `MetadataExt`. WASI's `filestat` type includes a size field, so expose it in `MetadataExt` via a `size()` function, similar to the corresponding Unix function. r? ``````@alexcrichton``````
2021-02-27Rollup merge of #82420 - sunfishcode:wasi-docs, r=alexcrichtonDylan DPC-29/+91
Enable API documentation for `std::os::wasi`. This adds API documentation support for `std::os::wasi` modeled after how `std::os::unix` works, so that WASI can be documented [here] along with the other platforms. [here]: https://doc.rust-lang.org/stable/std/os/index.html Two changes of particular interest: - This changes the `AsRawFd` for `io::Stdin` for WASI to return `libc::STDIN_FILENO` instead of `sys::stdio::Stdin.as_raw_fd()` (and similar for `Stdout` and `Stderr`), which matches how the `unix` version works. `STDIN_FILENO` etc. may not always be explicitly reserved at the WASI level, but as long as we have Rust's `std` and `libc`, I think it's reasonable to guarantee that we'll always use `libc::STDIN_FILENO` for stdin. - This duplicates the `osstr2str` utility function, rather than trying to share it across all the configurations that need it. r? ```@alexcrichton```
2021-02-26doc: cube root, not cubic rootTrevor Spiteri-2/+2
Like we say square root, not quadratic root.
2021-02-26Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-seGuillaume Gomez-1/+0
Stabilize str_split_once Closes #74773
2021-02-25Convert primitives to use intra-doc linksJoshua Nelson-20/+15
2021-02-25Rollup merge of #82467 - ojeda:tidy-normalize-safety-comments, r=kennytmAaron Hill-8/+14
library: Normalize safety-for-unsafe-block comments Almost all safety comments are of the form `// SAFETY:`, so normalize the rest and fix a few of them that should have been a `/// # Safety` section instead. Furthermore, make `tidy` only allow the uppercase form. While currently `tidy` only checks `core`, it is a good idea to prevent `core` from drifting to non-uppercase comments, so that later we can start checking `alloc` etc. too. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-25Rollup merge of #82464 - ehuss:unix-command-comment, r=kennytmAaron Hill-17/+7
Update outdated comment in unix Command. The big comment in the `Command` struct has been incorrect for some time (at least since #46789 which removed `envp`). Rather than try to remove the allocations, this PR just updates the comment to reflect reality. There is an explanation for the reasoning at https://github.com/rust-lang/rust/pull/31409#issuecomment-182122895, discussing the potential of being able to call `Command::exec` after `libc::fork`. That can still be done in the future, but I think for now it would be good to just correct the comment.
2021-02-25Rollup merge of #80553 - derekdreery:arc_error, r=m-ou-seDylan DPC-0/+22
Add an impl of Error on `Arc<impl Error>`. `Display` already exists so this should be a non-controversial change (famous last words). Would have to be insta-stable.
2021-02-25Use intra-doc links.Mara-4/+4
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-02-25Add {core,std}::prelude::{rust_2015,rust_2018,rust_2021}.Mara Bos-0/+35
rust_2015 and rust_2018 are just re-exports of v1. rust_2021 is a module that for now just re-exports everything from v1, such that we can add more things later.
2021-02-24Reuse `std::sys::unsupported::pipe` on `hermit`Christiaan Dirkx-38/+1
2021-02-24x.py fmtDan Gohman-3/+3
2021-02-24Mention "wasi" in the comment about "main modules".Dan Gohman-1/+1
2021-02-24Make the main `wasi` module `cfg(not(doc))`.Dan Gohman-2/+4
2021-02-24Use `super::` to refer to WASI-specific names.Dan Gohman-7/+7
This ensures that these names resolve to the right place even when building the WASI support on other platforms for generating the documentation.
2021-02-24Cast `libc::STDIN_FILENO` to `RawFd`.Dan Gohman-6/+6
WASI's `RawFd` is a `u32`, while `libc` uses `c_int`.
2021-02-24Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`Christiaan Dirkx-10/+21
The following methods are made unstable const under the `const_socketaddr` feature: `SocketAddr` - `ip` - `port` - `is_ipv4` - `is_ipv6` `SocketAddrV4` - `ip` - `port` `SocketAddrV6` - `ip` - `port` - `flowinfo` - `scope_id`
2021-02-24Use libc::accept4 on Android instead of raw syscall.Maarten de Vries-7/+1
2021-02-24library: Normalize safety-for-unsafe-block commentsMiguel Ojeda-8/+14
Almost all safety comments are of the form `// SAFETY:`, so normalize the rest and fix a few of them that should have been a `/// # Safety` section instead. Furthermore, make `tidy` only allow the uppercase form. While currently `tidy` only checks `core`, it is a good idea to prevent `core` from drifting to non-uppercase comments, so that later we can start checking `alloc` etc. too. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-23Update outdated comment in unix Command.Eric Huss-17/+7
2021-02-23Use #[doc = include_str!()] in stdLeSeulArtichaut-3/+2
2021-02-23Enable API documentation for `std::os::wasi`.Dan Gohman-19/+79
This adds API documentation support for `std::os::wasi` modeled after how `std::os::unix` works, so that WASI can be documented [here] along with the other platforms. [here]: https://doc.rust-lang.org/stable/std/os/index.html Two changes of particular interest: - This changes the `AsRawFd` for `io::Stdin` for WASI to return `libc::STDIN_FILENO` instead of `sys::stdio::Stdin.as_raw_fd()` (and similar for `Stdout` and `Stderr`), which matches how the `unix` version works. `STDIN_FILENO` etc. may not always be explicitly reserved at the WASI level, but as long as we have Rust's `std` and `libc`, I think it's reasonable to guarantee that we'll always use `libc::STDIN_FILENO` for stdin. - This duplicates the `osstr2str` utility function, rather than trying to share it across all the configurations that need it.
2021-02-23Auto merge of #82076 - jyn514:update-bootstrap, r=Mark-Simulacrumbors-17/+2
Update the bootstrap compiler This updates the bootstrap compiler, notably leaving out a change to enable semicolon in macro expressions lint, because stdarch still depends on the old behavior.
2021-02-23Add more links between hash and btree collectionsJoshua Nelson-2/+4
- Link from `core::hash` to `HashMap` and `HashSet` - Link from HashMap and HashSet to the module-level documentation on when to use the collection - Link from several collections to Wikipedia articles on the general concept