diff options
| author | kennytm <kennytm@gmail.com> | 2019-02-20 01:13:39 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2019-02-20 11:59:10 +0800 |
| commit | e3a8f7db479ce6562bfc312f412b65dc4f3c77d5 (patch) | |
| tree | 9312a71b7625ef7e88c687e49cdece9451519b2b /src/libstd/sync | |
| parent | ef0aaddf691030874e147ca5ee79332fec0c9566 (diff) | |
| parent | 3bea2ca49d24606920b3a81811379debc0668992 (diff) | |
| download | rust-e3a8f7db479ce6562bfc312f412b65dc4f3c77d5.tar.gz rust-e3a8f7db479ce6562bfc312f412b65dc4f3c77d5.zip | |
Rollup merge of #58553 - scottmcm:more-ihle, r=Centril
Use more impl header lifetime elision Inspired by seeing explicit lifetimes on these two: - https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html#impl-FusedIterator - https://doc.rust-lang.org/nightly/std/primitive.u32.html#impl-Not And a follow-up to https://github.com/rust-lang/rust/pull/54687, that started using IHLE in libcore. Most of the changes in here fall into two big categories: - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop`, `Debug`, and `Clone`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations [where the flipped one cannot elide the lifetime](https://internals.rust-lang.org/t/impl-type-parameter-aliases/9403/2?u=scottmcm). I also removed two lifetimes that turned out to be completely unused; see https://github.com/rust-lang/rust/issues/41960#issuecomment-464557423
Diffstat (limited to 'src/libstd/sync')
| -rw-r--r-- | src/libstd/sync/mpsc/select.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sync/mutex.rs | 14 | ||||
| -rw-r--r-- | src/libstd/sync/once.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sync/rwlock.rs | 26 |
4 files changed, 23 insertions, 23 deletions
diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 8f6f9818d5c..8591b55dc58 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -321,7 +321,7 @@ impl Drop for Select { } } -impl<'rx, T: Send> Drop for Handle<'rx, T> { +impl<T: Send> Drop for Handle<'_, T> { fn drop(&mut self) { unsafe { self.remove() } } @@ -347,7 +347,7 @@ impl fmt::Debug for Select { } } -impl<'rx, T:Send+'rx> fmt::Debug for Handle<'rx, T> { +impl<T: Send> fmt::Debug for Handle<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Handle").finish() } diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 340dca7ce73..954867911a0 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -150,9 +150,9 @@ pub struct MutexGuard<'a, T: ?Sized + 'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> !Send for MutexGuard<'a, T> { } +impl<T: ?Sized> !Send for MutexGuard<'_, T> { } #[stable(feature = "mutexguard", since = "1.19.0")] -unsafe impl<'a, T: ?Sized + Sync> Sync for MutexGuard<'a, T> { } +unsafe impl<T: ?Sized + Sync> Sync for MutexGuard<'_, T> { } impl<T> Mutex<T> { /// Creates a new mutex in an unlocked state ready for use. @@ -421,7 +421,7 @@ impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'mutex, T: ?Sized> Deref for MutexGuard<'mutex, T> { +impl<T: ?Sized> Deref for MutexGuard<'_, T> { type Target = T; fn deref(&self) -> &T { @@ -430,14 +430,14 @@ impl<'mutex, T: ?Sized> Deref for MutexGuard<'mutex, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'mutex, T: ?Sized> DerefMut for MutexGuard<'mutex, T> { +impl<T: ?Sized> DerefMut for MutexGuard<'_, T> { fn deref_mut(&mut self) -> &mut T { unsafe { &mut *self.__lock.data.get() } } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> { +impl<T: ?Sized> Drop for MutexGuard<'_, T> { #[inline] fn drop(&mut self) { unsafe { @@ -448,14 +448,14 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> { +impl<T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } #[stable(feature = "std_guard_impls", since = "1.20.0")] -impl<'a, T: ?Sized + fmt::Display> fmt::Display for MutexGuard<'a, T> { +impl<T: ?Sized + fmt::Display> fmt::Display for MutexGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 656389789d7..e207d0170d7 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -436,7 +436,7 @@ impl fmt::Debug for Once { } } -impl<'a> Drop for Finish<'a> { +impl Drop for Finish<'_> { fn drop(&mut self) { // Swap out our state with however we finished. We should only ever see // an old state which was RUNNING. diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 730362e2ac8..7f3cb4f72c7 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -91,10 +91,10 @@ pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> !Send for RwLockReadGuard<'a, T> {} +impl<T: ?Sized> !Send for RwLockReadGuard<'_, T> {} #[stable(feature = "rwlock_guard_sync", since = "1.23.0")] -unsafe impl<'a, T: ?Sized + Sync> Sync for RwLockReadGuard<'a, T> {} +unsafe impl<T: ?Sized + Sync> Sync for RwLockReadGuard<'_, T> {} /// RAII structure used to release the exclusive write access of a lock when /// dropped. @@ -113,10 +113,10 @@ pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> !Send for RwLockWriteGuard<'a, T> {} +impl<T: ?Sized> !Send for RwLockWriteGuard<'_, T> {} #[stable(feature = "rwlock_guard_sync", since = "1.23.0")] -unsafe impl<'a, T: ?Sized + Sync> Sync for RwLockWriteGuard<'a, T> {} +unsafe impl<T: ?Sized + Sync> Sync for RwLockWriteGuard<'_, T> {} impl<T> RwLock<T> { /// Creates a new instance of an `RwLock<T>` which is unlocked. @@ -480,7 +480,7 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, T: fmt::Debug> fmt::Debug for RwLockReadGuard<'a, T> { +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) @@ -489,14 +489,14 @@ impl<'a, T: fmt::Debug> fmt::Debug for RwLockReadGuard<'a, T> { } #[stable(feature = "std_guard_impls", since = "1.20.0")] -impl<'a, T: ?Sized + fmt::Display> fmt::Display for RwLockReadGuard<'a, T> { +impl<T: ?Sized + fmt::Display> fmt::Display for RwLockReadGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'a, T> { +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) @@ -505,14 +505,14 @@ impl<'a, T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'a, T> { } #[stable(feature = "std_guard_impls", since = "1.20.0")] -impl<'a, T: ?Sized + fmt::Display> fmt::Display for RwLockWriteGuard<'a, T> { +impl<T: ?Sized + fmt::Display> fmt::Display for RwLockWriteGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'rwlock, T: ?Sized> Deref for RwLockReadGuard<'rwlock, T> { +impl<T: ?Sized> Deref for RwLockReadGuard<'_, T> { type Target = T; fn deref(&self) -> &T { @@ -521,7 +521,7 @@ impl<'rwlock, T: ?Sized> Deref for RwLockReadGuard<'rwlock, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'rwlock, T: ?Sized> Deref for RwLockWriteGuard<'rwlock, T> { +impl<T: ?Sized> Deref for RwLockWriteGuard<'_, T> { type Target = T; fn deref(&self) -> &T { @@ -530,21 +530,21 @@ impl<'rwlock, T: ?Sized> Deref for RwLockWriteGuard<'rwlock, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'rwlock, T: ?Sized> DerefMut for RwLockWriteGuard<'rwlock, T> { +impl<T: ?Sized> DerefMut for RwLockWriteGuard<'_, T> { fn deref_mut(&mut self) -> &mut T { unsafe { &mut *self.__lock.data.get() } } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Drop for RwLockReadGuard<'a, T> { +impl<T: ?Sized> Drop for RwLockReadGuard<'_, T> { fn drop(&mut self) { unsafe { self.__lock.inner.read_unlock(); } } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Drop for RwLockWriteGuard<'a, T> { +impl<T: ?Sized> Drop for RwLockWriteGuard<'_, T> { fn drop(&mut self) { self.__lock.poison.done(&self.__poison); unsafe { self.__lock.inner.write_unlock(); } |
