about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2022-06-10docs: Fix typo in ExitStatusMartin Kröning-1/+1
2022-06-10Make "windows_process_exit_code_from" unstableAron Parker-3/+3
2022-06-10Incorporate warning for potential exit code ambiguitiesAron Parker-0/+4
2022-06-10Fix copy paste errorAron Parker-1/+1
2022-06-10Auto merge of #96837 - tmiasko:stdio-fcntl, r=joshtriplettbors-35/+57
Use `fcntl(fd, F_GETFD)` to detect if standard streams are open In the previous implementation, if the standard streams were open, but the RLIMIT_NOFILE value was below three, the poll would fail with EINVAL: > ERRORS: EINVAL The nfds value exceeds the RLIMIT_NOFILE value. Switch to the existing fcntl based implementation to avoid the issue. Fixes #96621.
2022-06-10Rollup merge of #97922 - paolobarbolini:no-vecdeque-extra-reserve, r=the8472Yuki Okushi-2/+0
Remove redundant calls to reserve in impl Write for VecDeque Removes the reserve calls made redundant by #95904 (as discussed in https://github.com/rust-lang/rust/pull/95632#discussion_r846850293)
2022-06-10Auto merge of #95770 - nrc:read-buf-builder, r=joshtriplettbors-7/+11
std::io: Modify some ReadBuf method signatures to return `&mut Self` This allows using `ReadBuf` in a builder-like style and to setup a `ReadBuf` and pass it to `read_buf` in a single expression, e.g., ``` // With this PR: reader.read_buf(ReadBuf::uninit(buf).assume_init(init_len))?; // Previously: let mut buf = ReadBuf::uninit(buf); buf.assume_init(init_len); reader.read_buf(&mut buf)?; ``` r? `@sfackler` cc https://github.com/rust-lang/rust/issues/78485, https://github.com/rust-lang/rust/issues/94741
2022-06-10use fcntl fallback for additional poll-specific errorsThe 8472-7/+8
2022-06-09add cgroupv1 support to available_parallelismThe 8472-48/+128
2022-06-09Avoid `thread::panicking()` in non-poisoning methods of `Mutex` and `RwLock`Josh Stone-8/+15
`Mutex::lock()` and `RwLock::write()` are poison-guarded against panics, in that they set the poison flag if a panic occurs while they're locked. But if we're already in a panic (`thread::panicking()`), they leave the poison flag alone. That check is a bit of a waste for methods that never set the poison flag though, namely `get_mut()`, `into_inner()`, and `RwLock::read()`. These use-cases are now split to avoid that unnecessary call.
2022-06-09Remove redundant calls to reserve in impl Write for VecDequePaolo Barbolini-2/+0
2022-06-09Implement ExitCodeExt for WindowsAron Parker-0/+41
2022-06-09Implement `fmt::Write` for `OsString`Tobias Bucher-0/+8
This allows to format into an `OsString` without unnecessary allocations. E.g. ``` let mut temp_filename = path.into_os_string(); write!(&mut temp_filename, ".tmp.{}", process::id()); ```
2022-06-09Rollup merge of #95632 - evanrichter:master, r=joshtriplettYuki Okushi-0/+48
impl Read and Write for VecDeque<u8> Implementing `Read` and `Write` for `VecDeque<u8>` fills in the VecDeque api surface where `Vec<u8>` and `Cursor<Vec<u8>>` already impl Read and Write. Not only for completeness, but VecDeque in particular is a very handy mock interface for a TCP echo service, if only it supported Read/Write. Since this PR is just an impl trait, I don't think there is a way to limit it behind a feature flag, so it's "insta-stable". Please correct me if I'm wrong here, not trying to rush stability.
2022-06-08Fix bootstrap attrMichael Howell-2/+2
2022-06-08rustdoc: fixed messed-up rustdoc auto trait implsMichael Howell-1/+1
Before: impl<T, U> UnwindSafe for (T, ...) where T: UnwindSafe, U: UnwindSafe, After: impl<T> UnwindSafe for (T, ...) where T: UnwindSafe,
2022-06-08rustdoc: show tuple impls as `impl Trait for (T, ...)`Michael Howell-18/+7
This commit adds a new unstable attribute, `#[doc(tuple_varadic)]`, that shows a 1-tuple as `(T, ...)` instead of just `(T,)`, and links to a section in the tuple primitive docs that talks about these.
2022-06-08Fix FFI-unwind unsoundness with mixed panic modeGary Guo-0/+2
2022-06-08Rollup merge of #97830 - LucasDumont:add-example-alloc, r=yaahcMichael Goulet-0/+14
Add std::alloc::set_alloc_error_hook example
2022-06-08Fix trailing whitespace.Dan Gohman-1/+1
2022-06-08Reword the question in the section header too.Dan Gohman-2/+2
This adopts the wording suggested in https://github.com/rust-lang/rust/pull/97837#discussion_r892524129.
2022-06-08Update library/std/src/os/unix/io/mod.rsDan Gohman-3/+2
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2022-06-08Reword a question into a statement.Dan Gohman-2/+2
2022-06-08remove unneeded codeStefan Lankes-5/+0
2022-06-07Windows: No panic if function not (yet) availableChris Denton-4/+5
In some situations it is possible for required functions to be called before they've had a chance to be loaded. Therefore, we make it possible to recover from this situation simply by looking at error codes.
2022-06-07[core] add Exclusive to syncGus Wynn-0/+3
2022-06-07docs: show Clone and Copy on () doc pagesMichael Howell-0/+34
2022-06-07Inline Windows `OsStrExt::encode_wide`Nikolai Vazquez-0/+1
User crates currently produce much more code than necessary because the optimizer fails to make assumptions about this method.
2022-06-07rustdoc: show auto/blanket docs for tuple and unitMichael Howell-0/+10
2022-06-07Update library/std/src/os/unix/io/mod.rsDan Gohman-1/+1
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-06-07Update library/std/src/os/unix/io/mod.rsDan Gohman-1/+1
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-06-07Update library/std/src/os/unix/io/mod.rsDan Gohman-1/+1
Co-authored-by: Sean Stangl <sean.stangl@gmail.com>
2022-06-07Update library/std/src/os/unix/io/mod.rsDan Gohman-1/+1
Co-authored-by: Sean Stangl <sean.stangl@gmail.com>
2022-06-07Document Rust's stance on `/proc/self/mem`Dan Gohman-0/+20
Add documentation to `std::os::unix::io` describing Rust's stance on `/proc/self/mem`, treating it as an external entity which is outside the scope of Rust's safety guarantees.
2022-06-07Rollup merge of #97821 - Nilstrieb:mutex-docs, r=Dylan-DPCDylan DPC-5/+4
Remove confusing sentence from `Mutex` docs The docs were saying something about "statically initializing" the mutex, and it's not clear what this means. Remove that part to avoid confusion.
2022-06-07Update library/std/src/sync/mutex.rsDylan DPC-1/+1
Co-authored-by: Weiyi Wang <wwylele@gmail.com>
2022-06-07Add std::alloc::set_alloc_error_hook exampleLucas Dumont-0/+14
2022-06-07Rollup merge of #97771 - rtzoeller:haiku_no_sigio, r=kennytmDylan DPC-0/+1
Remove SIGIO reference on Haiku Haiku doesn't define SIGIO. The nix crate already employs this workaround: https://github.com/nix-rust/nix/blob/5dedbc7850448ae3922ab0a833f3eb971bf7e25f/src/sys/signal.rs#L92-L94
2022-06-07Remove confusing sentence from `Mutex` docsNilstrieb-5/+4
The docs were saying something about "statically initializing" the mutex, and it's not clear what this means. Remove that part to avoid confusion.
2022-06-07Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakisbors-2/+2
Remove migrate borrowck mode Closes #58781 Closes #43234 # Stabilization proposal This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile. Tracking issue: #43234 RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable). ## Motivation Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors. The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition. In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker. In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver. While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff. ## What is stabilized As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise. There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](https://github.com/rust-lang/rust/issues/95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl. As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions. ## What isn't stabilized This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck. ## Tests Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll` ## History * On 2017-07-14, [tracking issue opened](https://github.com/rust-lang/rust/issues/43234) * On 2017-07-20, [initial empty MIR pass added](https://github.com/rust-lang/rust/pull/43271) * On 2017-08-29, [RFC opened](https://github.com/rust-lang/rfcs/pull/2094) * On 2017-11-16, [Integrate MIR type-checker with NLL](https://github.com/rust-lang/rust/pull/45825) * On 2017-12-20, [NLL feature complete](https://github.com/rust-lang/rust/pull/46862) * On 2018-07-07, [Don't run AST borrowck on mir mode](https://github.com/rust-lang/rust/pull/52083) * On 2018-07-27, [Add migrate mode](https://github.com/rust-lang/rust/pull/52681) * On 2019-04-22, [Enable migrate mode on 2015 edition](https://github.com/rust-lang/rust/pull/59114) * On 2019-08-26, [Don't downgrade errors on 2015 edition](https://github.com/rust-lang/rust/pull/64221) * On 2019-08-27, [Remove AST borrowck](https://github.com/rust-lang/rust/pull/64790)
2022-06-07Rollup merge of #97700 - nzrq:patch-1, r=dtolnayMatthias Krüger-0/+6
Add note to documentation of HashSet::intersection The functionality of the `std::collections::HashSet::intersection(...)` method was slightly surprising to me so I wanted to take a sec to contribute to the documentation for this method. I've added a `Note:` section if that is appropriate.
2022-06-06Apply suggestions from code reviewnzrq-2/+3
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2022-06-06Make {Mutex, Condvar, RwLock}::new() const.Mara Bos-2/+5
2022-06-06Make all {Mutex, Condvar, RwLock}::new #[inline].Mara Bos-4/+21
2022-06-05Remove SIGIO reference on HaikuRyan Zoeller-0/+1
Haiku doesn't define SIGIO. The nix crate already employs this workaround: https://github.com/nix-rust/nix/blob/5dedbc7850448ae3922ab0a833f3eb971bf7e25f/src/sys/signal.rs#L92-L94
2022-06-05std: solve priority issue for Parkerjoboet-24/+31
2022-06-05Add diagnostic items to MutexGuard and RwLock GuardsAaron Kofsky-0/+3
I forgot to add the diagnostic to the actual types in `std` earlier.
2022-06-04Update library/std/src/collections/hash/set.rsnzrq-1/+1
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2022-06-04Auto merge of #97191 - wesleywiser:main_thread_name, r=ChrisDentonbors-1/+15
Call the OS function to set the main thread's name on program init Normally, `Thread::spawn` takes care of setting the thread's name, if one was provided, but since the main thread wasn't created by calling `Thread::spawn`, we need to call that function in `std::rt::init`. This is mainly useful for system tools like debuggers and profilers which might show the thread name to a user. Prior to these changes, gdb and WinDbg would show all thread names except the main thread's name to a user. I've validated that this patch resolves the issue for both debuggers.
2022-06-04keep using poll as fast path and only use fcntl as fallbackThe 8472-19/+65
this minimizes the amount of syscalls performed during startup