diff options
| author | bors <bors@rust-lang.org> | 2022-06-21 13:41:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-21 13:41:37 +0000 |
| commit | 72fd41a8b4d3488c97df3c3c75ddd9951aa3c73f (patch) | |
| tree | 2d58bdad267a557b934a58558900b57ea1fed4b4 /library/std | |
| parent | a25b1315ee968146a5b206a8f3c670c5b307ebfe (diff) | |
| parent | e5092425eb722910b2caeac1148d023fc6e95ba2 (diff) | |
| download | rust-72fd41a8b4d3488c97df3c3c75ddd9951aa3c73f.tar.gz rust-72fd41a8b4d3488c97df3c3c75ddd9951aa3c73f.zip | |
Auto merge of #98335 - JohnTitor:rollup-j2zudxv, r=JohnTitor
Rollup of 11 pull requests Successful merges: - #94033 (Improve docs for `is_running` to explain use case) - #97269 (adjust transmute const stabilization version) - #97805 (Add proper tracing spans to rustc_trait_selection::traits::error_reporting) - #98022 (Fix erroneous span for borrowck error) - #98124 (Improve loading of crates.js and sidebar-items.js) - #98278 (Some token stream cleanups) - #98306 (`try_fold_unevaluated` for infallible folders) - #98313 (Remove lies in comments.) - #98323 (:arrow_up: rust-analyzer) - #98329 (Avoid an ICE and instead let the compiler report a useful error) - #98330 (update ioslice docs to use shared slices) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std')
| -rw-r--r-- | library/std/src/io/mod.rs | 12 | ||||
| -rw-r--r-- | library/std/src/os/unix/net/ancillary.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sys_common/mutex.rs | 7 | ||||
| -rw-r--r-- | library/std/src/sys_common/rwlock.rs | 6 | ||||
| -rw-r--r-- | library/std/src/thread/mod.rs | 7 | ||||
| -rw-r--r-- | library/std/src/thread/scoped.rs | 7 |
6 files changed, 22 insertions, 21 deletions
diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index cad1fab7b8f..f4f2e3f2434 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -1240,8 +1240,8 @@ impl<'a> IoSlice<'a> { /// use std::io::IoSlice; /// use std::ops::Deref; /// - /// let mut data = [1; 8]; - /// let mut buf = IoSlice::new(&mut data); + /// let data = [1; 8]; + /// let mut buf = IoSlice::new(&data); /// /// // Mark 3 bytes as read. /// buf.advance(3); @@ -1435,10 +1435,10 @@ pub trait Write { /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { - /// let mut data1 = [1; 8]; - /// let mut data2 = [15; 8]; - /// let io_slice1 = IoSlice::new(&mut data1); - /// let io_slice2 = IoSlice::new(&mut data2); + /// let data1 = [1; 8]; + /// let data2 = [15; 8]; + /// let io_slice1 = IoSlice::new(&data1); + /// let io_slice2 = IoSlice::new(&data2); /// /// let mut buffer = File::create("foo.txt")?; /// diff --git a/library/std/src/os/unix/net/ancillary.rs b/library/std/src/os/unix/net/ancillary.rs index ecee123a9b6..7cc901a7944 100644 --- a/library/std/src/os/unix/net/ancillary.rs +++ b/library/std/src/os/unix/net/ancillary.rs @@ -583,8 +583,8 @@ impl<'a> SocketAncillary<'a> { /// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); /// ancillary.add_fds(&[sock.as_raw_fd()][..]); /// - /// let mut buf = [1; 8]; - /// let mut bufs = &mut [IoSlice::new(&mut buf[..])][..]; + /// let buf = [1; 8]; + /// let mut bufs = &mut [IoSlice::new(&buf[..])][..]; /// sock.send_vectored_with_ancillary(bufs, &mut ancillary)?; /// Ok(()) /// } diff --git a/library/std/src/sys_common/mutex.rs b/library/std/src/sys_common/mutex.rs index 81eefa1133f..48479f5bdb3 100644 --- a/library/std/src/sys_common/mutex.rs +++ b/library/std/src/sys_common/mutex.rs @@ -46,13 +46,12 @@ impl Drop for StaticMutexGuard { /// An OS-based mutual exclusion lock. /// -/// This mutex does *not* have a const constructor, cleans up its resources in -/// its `Drop` implementation, may safely be moved (when not borrowed), and -/// does not cause UB when used reentrantly. +/// This mutex cleans up its resources in its `Drop` implementation, may safely +/// be moved (when not borrowed), and does not cause UB when used reentrantly. /// /// This mutex does not implement poisoning. /// -/// This is either a wrapper around `Box<imp::Mutex>` or `imp::Mutex`, +/// This is either a wrapper around `LazyBox<imp::Mutex>` or `imp::Mutex`, /// depending on the platform. It is boxed on platforms where `imp::Mutex` may /// not be moved. pub struct MovableMutex(imp::MovableMutex); diff --git a/library/std/src/sys_common/rwlock.rs b/library/std/src/sys_common/rwlock.rs index 265cebfdc3e..ba56f3a8f1b 100644 --- a/library/std/src/sys_common/rwlock.rs +++ b/library/std/src/sys_common/rwlock.rs @@ -62,12 +62,12 @@ impl Drop for StaticRwLockWriteGuard { /// An OS-based reader-writer lock. /// -/// This rwlock does *not* have a const constructor, cleans up its resources in -/// its `Drop` implementation and may safely be moved (when not borrowed). +/// This rwlock cleans up its resources in its `Drop` implementation and may +/// safely be moved (when not borrowed). /// /// This rwlock does not implement poisoning. /// -/// This is either a wrapper around `Box<imp::RwLock>` or `imp::RwLock`, +/// This is either a wrapper around `LazyBox<imp::RwLock>` or `imp::RwLock`, /// depending on the platform. It is boxed on platforms where `imp::RwLock` may /// not be moved. pub struct MovableRwLock(imp::MovableRwLock); diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index f7af66ae5b5..0a6a7cfe976 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -1487,13 +1487,14 @@ impl<T> JoinHandle<T> { /// Checks if the associated thread has finished running its main function. /// + /// `is_finished` supports implementing a non-blocking join operation, by checking + /// `is_finished`, and calling `join` if it returns `true`. This function does not block. To + /// block while waiting on the thread to finish, use [`join`][Self::join]. + /// /// This might return `true` for a brief moment after the thread's main /// function has returned, but before the thread itself has stopped running. /// However, once this returns `true`, [`join`][Self::join] can be expected /// to return quickly, without blocking for any significant amount of time. - /// - /// This function does not block. To block while waiting on the thread to finish, - /// use [`join`][Self::join]. #[stable(feature = "thread_is_running", since = "1.61.0")] pub fn is_finished(&self) -> bool { Arc::strong_count(&self.0.packet) == 1 diff --git a/library/std/src/thread/scoped.rs b/library/std/src/thread/scoped.rs index 4fd076e4a2d..a387a09dc8b 100644 --- a/library/std/src/thread/scoped.rs +++ b/library/std/src/thread/scoped.rs @@ -308,13 +308,14 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> { /// Checks if the associated thread has finished running its main function. /// + /// `is_finished` supports implementing a non-blocking join operation, by checking + /// `is_finished`, and calling `join` if it returns `false`. This function does not block. To + /// block while waiting on the thread to finish, use [`join`][Self::join]. + /// /// This might return `true` for a brief moment after the thread's main /// function has returned, but before the thread itself has stopped running. /// However, once this returns `true`, [`join`][Self::join] can be expected /// to return quickly, without blocking for any significant amount of time. - /// - /// This function does not block. To block while waiting on the thread to finish, - /// use [`join`][Self::join]. #[stable(feature = "scoped_threads", since = "1.63.0")] pub fn is_finished(&self) -> bool { Arc::strong_count(&self.0.packet) == 1 |
