about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
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
2021-02-23Rollup merge of #82128 - anall:feature/add_diagnostic_items, r=davidtwcoDylan DPC-0/+4
add diagnostic items for OsString/PathBuf/Owned as well as to_vec on slice This is adding diagnostic items to be used by rust-lang/rust-clippy#6730, but my understanding is the clippy-side change does need to be done over there since I am adding a new clippy feature. Add diagnostic items to the following types: OsString (os_string_type) PathBuf (path_buf_type) Owned (to_owned_trait) As well as the to_vec method on slice/[T]
2021-02-23Rollup merge of #81984 - sunfishcode:wasi-link, r=alexcrichtonDylan DPC-6/+2
Make WASI's `hard_link` behavior match other platforms. Following #78026, `std::fs::hard_link` on most platforms does not follow symlinks. Change the WASI implementation to also not follow symlinks. r? ```@alexcrichton```
2021-02-23ExitStatus: Improve documentation re wait status vs exit statusIan Jackson-9/+30
The use of `ExitStatus` as the Rust type name for a Unix *wait status*, not an *exit status*, is very confusing, but sadly probably too late to change. This area is confusing enough in Unix already (and many programmers are already confuxed). We can at least document it. I chose *not* to mention the way shells like to exit with signal numbers, thus turning signal numbers into exit statuses. This is only relevant for Rust programs using `std::process` if they run shells. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-23process::unix: Test wait status formattingIan Jackson-0/+26
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-22Add a `size()` function to WASI's `MetadataExt`.Dan Gohman-0/+5
WASI's `filestat` type includes a size field, so expose it in `MetadataExt` via a `size()` function, similar to the corresponding Unix function.
2021-02-22fix io::copy specialization when writer was opened with O_APPENDThe8472-8/+10
2021-02-22add test for failing io::copy specializationThe8472-0/+18
2021-02-22Avoid `cfg_if` in `std::os`Jonas Schievink-27/+27
2021-02-22process::unix: Handle other wait statuses in ExitStatus as DisplayIan Jackson-2/+11
Currently, on Nightly, this panics: ``` use std::process::ExitStatus; use std::os::unix::process::ExitStatusExt; fn main() { let st = ExitStatus::from_raw(0x007f); println!("st = {}", st); } ``` This is because the impl of Display assumes that if .code() is None, .signal() must be Some. That was a false assumption, although it was true with buggy code before 5b1316f78152a9c066b357ea9addf803d48e114a unix ExitStatus: Do not treat WIFSTOPPED as WIFSIGNALED This is not likely to have affected many people in practice, because `Command` will never produce such a wait status (`ExitStatus`). Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-22Add impl `Error` for `Arc`Richard Dodd-0/+22
2021-02-22Add missing "see its documentation for more" stdioIvan Tham-2/+2
StdoutLock and StderrLock does not have example, it would be better to leave "see its documentation for more" like iter docs.
2021-02-22Rollup merge of #82228 - ijackson:nonzero-cint, r=KodrAusYuki Okushi-54/+57
Provide NonZero_c_* integers I'm pretty sure I am going want this for #73125 and it seems like an omission that would be in any case good to remedy. <strike>Because the raw C types are in `std`, not `core`, to achieve this we must export the relevant macros from `core` so that `std` can use them. That's done with a new `num_internals` perma-unstable feature. The macros need to take more parameters for the module to get the types from and feature attributes to use. I have eyeballed the docs output for core, to check that my changes to these macros have made no difference to the core docs output.</strike>