diff options
| author | bors <bors@rust-lang.org> | 2021-03-27 16:34:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-27 16:34:59 +0000 |
| commit | afaf33dcafe9c7068b63eb997df221aa08db7c29 (patch) | |
| tree | 2bd2416c2a6dcbdf410e6d9f932960b124cb576a /library/std/src | |
| parent | 101003881418d23fee3fcb1b1721a216a366f2da (diff) | |
| parent | 1ad7c52812b336c23d86bc4c74c408fe5c850761 (diff) | |
| download | rust-afaf33dcafe9c7068b63eb997df221aa08db7c29.tar.gz rust-afaf33dcafe9c7068b63eb997df221aa08db7c29.zip | |
Auto merge of #83573 - JohnTitor:rollup-28jnzsr, r=JohnTitor
Rollup of 10 pull requests
Successful merges:
- #79399 (Use detailed and shorter fs error explaination)
- #83348 (format macro argument parsing fix)
- #83462 (ExitStatus: print "exit status: {}" rather than "exit code: {}" on unix)
- #83526 (lazily calls some fns)
- #83558 (Use DebugStruct::finish_non_exhaustive() in std.)
- #83559 (Fix Debug implementation for RwLock{Read,Write}Guard.)
- #83560 (Derive Debug for io::Chain instead of manually implementing it.)
- #83561 (Improve Debug implementations of Mutex and RwLock.)
- #83567 (Update rustup cross-compilation docs link)
- #83569 (Add regression tests for #56445)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/collections/hash/map.rs | 15 | ||||
| -rw-r--r-- | library/std/src/fs.rs | 8 | ||||
| -rw-r--r-- | library/std/src/io/buffered/linewriter.rs | 2 | ||||
| -rw-r--r-- | library/std/src/io/mod.rs | 8 | ||||
| -rw-r--r-- | library/std/src/lazy.rs | 2 | ||||
| -rw-r--r-- | library/std/src/process.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sync/mpsc/mod.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sync/mutex.rs | 12 | ||||
| -rw-r--r-- | library/std/src/sync/rwlock.rs | 16 | ||||
| -rw-r--r-- | library/std/src/sys/unix/process/process_unix.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/unix/process/process_unix/tests.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sys/wasi/fs.rs | 2 | ||||
| -rw-r--r-- | library/std/src/thread/mod.rs | 5 |
13 files changed, 46 insertions, 38 deletions
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index ed32668456d..3dcc5cd2b59 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -1793,7 +1793,7 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> { #[unstable(feature = "hash_raw_entry", issue = "56167")] impl<K, V, S> Debug for RawEntryBuilderMut<'_, K, V, S> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RawEntryBuilder").finish() + f.debug_struct("RawEntryBuilder").finish_non_exhaustive() } } @@ -1813,21 +1813,21 @@ impl<K: Debug, V: Debug, S> Debug for RawOccupiedEntryMut<'_, K, V, S> { f.debug_struct("RawOccupiedEntryMut") .field("key", self.key()) .field("value", self.get()) - .finish() + .finish_non_exhaustive() } } #[unstable(feature = "hash_raw_entry", issue = "56167")] impl<K, V, S> Debug for RawVacantEntryMut<'_, K, V, S> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RawVacantEntryMut").finish() + f.debug_struct("RawVacantEntryMut").finish_non_exhaustive() } } #[unstable(feature = "hash_raw_entry", issue = "56167")] impl<K, V, S> Debug for RawEntryBuilder<'_, K, V, S> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RawEntryBuilder").finish() + f.debug_struct("RawEntryBuilder").finish_non_exhaustive() } } @@ -1867,7 +1867,10 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> { #[stable(feature = "debug_hash_map", since = "1.12.0")] impl<K: Debug, V: Debug> Debug for OccupiedEntry<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("OccupiedEntry").field("key", self.key()).field("value", self.get()).finish() + f.debug_struct("OccupiedEntry") + .field("key", self.key()) + .field("value", self.get()) + .finish_non_exhaustive() } } @@ -1903,7 +1906,7 @@ impl<K: Debug, V: Debug> Debug for OccupiedError<'_, K, V> { .field("key", self.entry.key()) .field("old_value", self.entry.get()) .field("new_value", &self.value) - .finish() + .finish_non_exhaustive() } } diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index ccbc69a975c..860bc130b7d 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1154,7 +1154,7 @@ impl fmt::Debug for Metadata { .field("modified", &self.modified()) .field("accessed", &self.accessed()) .field("created", &self.created()) - .finish() + .finish_non_exhaustive() } } @@ -1677,9 +1677,9 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> /// This function will return an error in the following situations, but is not /// limited to just these cases: /// -/// * The `from` path is not a file. -/// * The `from` file does not exist. -/// * The current process does not have the permission rights to access +/// * `from` is neither a regular file nor a symlink to a regular file. +/// * `from` does not exist. +/// * The current process does not have the permission rights to read /// `from` or write `to`. /// /// # Examples diff --git a/library/std/src/io/buffered/linewriter.rs b/library/std/src/io/buffered/linewriter.rs index 502c6e3c6c0..d7b620d6f91 100644 --- a/library/std/src/io/buffered/linewriter.rs +++ b/library/std/src/io/buffered/linewriter.rs @@ -227,6 +227,6 @@ where "buffer", &format_args!("{}/{}", self.inner.buffer().len(), self.inner.capacity()), ) - .finish() + .finish_non_exhaustive() } } diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 5316305a303..9953bcd556d 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2114,6 +2114,7 @@ pub trait BufRead: Read { /// /// [`chain`]: Read::chain #[stable(feature = "rust1", since = "1.0.0")] +#[derive(Debug)] pub struct Chain<T, U> { first: T, second: U, @@ -2195,13 +2196,6 @@ impl<T, U> Chain<T, U> { } } -#[stable(feature = "std_debug", since = "1.16.0")] -impl<T: fmt::Debug, U: fmt::Debug> fmt::Debug for Chain<T, U> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Chain").field("t", &self.first).field("u", &self.second).finish() - } -} - #[stable(feature = "rust1", since = "1.0.0")] impl<T: Read, U: Read> Read for Chain<T, U> { fn read(&mut self, buf: &mut [u8]) -> Result<usize> { diff --git a/library/std/src/lazy.rs b/library/std/src/lazy.rs index 974851a8bd6..ca86e569bc1 100644 --- a/library/std/src/lazy.rs +++ b/library/std/src/lazy.rs @@ -515,7 +515,7 @@ pub struct SyncLazy<T, F = fn() -> T> { #[unstable(feature = "once_cell", issue = "74465")] impl<T: fmt::Debug, F> fmt::Debug for SyncLazy<T, F> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Lazy").field("cell", &self.cell).field("init", &"..").finish() + f.debug_struct("Lazy").field("cell", &self.cell).finish_non_exhaustive() } } diff --git a/library/std/src/process.rs b/library/std/src/process.rs index f9cfd11e906..5690de681ca 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -234,7 +234,7 @@ impl fmt::Debug for Child { .field("stdin", &self.stdin) .field("stdout", &self.stdout) .field("stderr", &self.stderr) - .finish() + .finish_non_exhaustive() } } diff --git a/library/std/src/sync/mpsc/mod.rs b/library/std/src/sync/mpsc/mod.rs index b12e7eeb138..c8f0a6b99fe 100644 --- a/library/std/src/sync/mpsc/mod.rs +++ b/library/std/src/sync/mpsc/mod.rs @@ -864,7 +864,7 @@ impl<T> Drop for Sender<T> { #[stable(feature = "mpsc_debug", since = "1.8.0")] impl<T> fmt::Debug for Sender<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Sender").finish() + f.debug_struct("Sender").finish_non_exhaustive() } } @@ -991,7 +991,7 @@ impl<T> Drop for SyncSender<T> { #[stable(feature = "mpsc_debug", since = "1.8.0")] impl<T> fmt::Debug for SyncSender<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("SyncSender").finish() + f.debug_struct("SyncSender").finish_non_exhaustive() } } @@ -1470,7 +1470,7 @@ impl<T> Drop for Receiver<T> { #[stable(feature = "mpsc_debug", since = "1.8.0")] impl<T> fmt::Debug for Receiver<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Receiver").finish() + f.debug_struct("Receiver").finish_non_exhaustive() } } diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index ab61618dc7d..98c34282e0c 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -441,10 +441,13 @@ impl<T: ?Sized + Default> Default for Mutex<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + fmt::Debug> fmt::Debug for Mutex<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut d = f.debug_struct("Mutex"); match self.try_lock() { - Ok(guard) => f.debug_struct("Mutex").field("data", &&*guard).finish(), + Ok(guard) => { + d.field("data", &&*guard); + } Err(TryLockError::Poisoned(err)) => { - f.debug_struct("Mutex").field("data", &&**err.get_ref()).finish() + d.field("data", &&**err.get_ref()); } Err(TryLockError::WouldBlock) => { struct LockedPlaceholder; @@ -453,10 +456,11 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Mutex<T> { f.write_str("<locked>") } } - - f.debug_struct("Mutex").field("data", &LockedPlaceholder).finish() + d.field("data", &LockedPlaceholder); } } + d.field("poisoned", &self.poison.get()); + d.finish_non_exhaustive() } } diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index 0298f59228c..351804ec979 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -422,10 +422,13 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for RwLock<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut d = f.debug_struct("RwLock"); match self.try_read() { - Ok(guard) => f.debug_struct("RwLock").field("data", &&*guard).finish(), + Ok(guard) => { + d.field("data", &&*guard); + } Err(TryLockError::Poisoned(err)) => { - f.debug_struct("RwLock").field("data", &&**err.get_ref()).finish() + d.field("data", &&**err.get_ref()); } Err(TryLockError::WouldBlock) => { struct LockedPlaceholder; @@ -434,10 +437,11 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> { f.write_str("<locked>") } } - - f.debug_struct("RwLock").field("data", &LockedPlaceholder).finish() + d.field("data", &LockedPlaceholder); } } + d.field("poisoned", &self.poison.get()); + d.finish_non_exhaustive() } } @@ -473,7 +477,7 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { #[stable(feature = "std_debug", since = "1.16.0")] impl<T: fmt::Debug> fmt::Debug for RwLockReadGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RwLockReadGuard").field("lock", &self.lock).finish() + (**self).fmt(f) } } @@ -487,7 +491,7 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RwLockReadGuard<'_, T> { #[stable(feature = "std_debug", since = "1.16.0")] impl<T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RwLockWriteGuard").field("lock", &self.lock).finish() + (**self).fmt(f) } } diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 01f1318fe80..53916cb9abd 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -535,7 +535,7 @@ impl From<c_int> for ExitStatus { impl fmt::Display for ExitStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(code) = self.code() { - write!(f, "exit code: {}", code) + write!(f, "exit status: {}", code) } else if let Some(signal) = self.signal() { if self.core_dumped() { write!(f, "signal: {} (core dumped)", signal) diff --git a/library/std/src/sys/unix/process/process_unix/tests.rs b/library/std/src/sys/unix/process/process_unix/tests.rs index 5819d2c2a5a..02c469fbcdf 100644 --- a/library/std/src/sys/unix/process/process_unix/tests.rs +++ b/library/std/src/sys/unix/process/process_unix/tests.rs @@ -9,8 +9,8 @@ fn exitstatus_display_tests() { t(0x0000f, "signal: 15"); t(0x0008b, "signal: 11 (core dumped)"); - t(0x00000, "exit code: 0"); - t(0x0ff00, "exit code: 255"); + t(0x00000, "exit status: 0"); + t(0x0ff00, "exit status: 255"); // On MacOS, 0x0137f is WIFCONTINUED, not WIFSTOPPED. Probably *BSD is similar. // https://github.com/rust-lang/rust/pull/82749#issuecomment-790525956 diff --git a/library/std/src/sys/wasi/fs.rs b/library/std/src/sys/wasi/fs.rs index 1ec3ff6a10f..ed0f03e4b71 100644 --- a/library/std/src/sys/wasi/fs.rs +++ b/library/std/src/sys/wasi/fs.rs @@ -130,7 +130,7 @@ impl FileType { impl fmt::Debug for ReadDir { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("ReadDir").finish() + f.debug_struct("ReadDir").finish_non_exhaustive() } } diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 0ef848ff0c4..ffdf4be1584 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -1176,7 +1176,10 @@ impl Thread { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Thread { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Thread").field("id", &self.id()).field("name", &self.name()).finish() + f.debug_struct("Thread") + .field("id", &self.id()) + .field("name", &self.name()) + .finish_non_exhaustive() } } |
