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
This commit is contained in:
kennytm
2019-02-20 01:13:39 +08:00
35 changed files with 219 additions and 219 deletions

View File

@@ -457,14 +457,14 @@ impl<'a> cmp::PartialOrd for PrefixComponent<'a> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> cmp::Ord for PrefixComponent<'a> {
fn cmp(&self, other: &PrefixComponent<'a>) -> cmp::Ordering {
impl cmp::Ord for PrefixComponent<'_> {
fn cmp(&self, other: &Self) -> cmp::Ordering {
cmp::Ord::cmp(&self.parsed, &other.parsed)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Hash for PrefixComponent<'a> {
impl Hash for PrefixComponent<'_> {
fn hash<H: Hasher>(&self, h: &mut H) {
self.parsed.hash(h);
}
@@ -561,14 +561,14 @@ impl<'a> Component<'a> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> AsRef<OsStr> for Component<'a> {
impl AsRef<OsStr> for Component<'_> {
fn as_ref(&self) -> &OsStr {
self.as_os_str()
}
}
#[stable(feature = "path_component_asref", since = "1.25.0")]
impl<'a> AsRef<Path> for Component<'a> {
impl AsRef<Path> for Component<'_> {
fn as_ref(&self) -> &Path {
self.as_os_str().as_ref()
}
@@ -630,11 +630,11 @@ pub struct Iter<'a> {
}
#[stable(feature = "path_components_debug", since = "1.13.0")]
impl<'a> fmt::Debug for Components<'a> {
impl fmt::Debug for Components<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
struct DebugHelper<'a>(&'a Path);
impl<'a> fmt::Debug for DebugHelper<'a> {
impl fmt::Debug for DebugHelper<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list()
.entries(self.0.components())
@@ -814,25 +814,25 @@ impl<'a> Components<'a> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> AsRef<Path> for Components<'a> {
impl AsRef<Path> for Components<'_> {
fn as_ref(&self) -> &Path {
self.as_path()
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> AsRef<OsStr> for Components<'a> {
impl AsRef<OsStr> for Components<'_> {
fn as_ref(&self) -> &OsStr {
self.as_path().as_os_str()
}
}
#[stable(feature = "path_iter_debug", since = "1.13.0")]
impl<'a> fmt::Debug for Iter<'a> {
impl fmt::Debug for Iter<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
struct DebugHelper<'a>(&'a Path);
impl<'a> fmt::Debug for DebugHelper<'a> {
impl fmt::Debug for DebugHelper<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list()
.entries(self.0.iter())
@@ -867,14 +867,14 @@ impl<'a> Iter<'a> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> AsRef<Path> for Iter<'a> {
impl AsRef<Path> for Iter<'_> {
fn as_ref(&self) -> &Path {
self.as_path()
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> AsRef<OsStr> for Iter<'a> {
impl AsRef<OsStr> for Iter<'_> {
fn as_ref(&self) -> &OsStr {
self.as_path().as_os_str()
}
@@ -897,7 +897,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> {
}
#[stable(feature = "fused", since = "1.26.0")]
impl<'a> FusedIterator for Iter<'a> {}
impl FusedIterator for Iter<'_> {}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Iterator for Components<'a> {
@@ -1000,7 +1000,7 @@ impl<'a> DoubleEndedIterator for Components<'a> {
}
#[stable(feature = "fused", since = "1.26.0")]
impl<'a> FusedIterator for Components<'a> {}
impl FusedIterator for Components<'_> {}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> cmp::PartialEq for Components<'a> {
@@ -1010,7 +1010,7 @@ impl<'a> cmp::PartialEq for Components<'a> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> cmp::Eq for Components<'a> {}
impl cmp::Eq for Components<'_> {}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> cmp::PartialOrd for Components<'a> {
@@ -1020,8 +1020,8 @@ impl<'a> cmp::PartialOrd for Components<'a> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> cmp::Ord for Components<'a> {
fn cmp(&self, other: &Components<'a>) -> cmp::Ordering {
impl cmp::Ord for Components<'_> {
fn cmp(&self, other: &Self) -> cmp::Ordering {
Iterator::cmp(self.clone(), other.clone())
}
}
@@ -1063,7 +1063,7 @@ impl<'a> Iterator for Ancestors<'a> {
}
#[stable(feature = "path_ancestors", since = "1.28.0")]
impl<'a> FusedIterator for Ancestors<'a> {}
impl FusedIterator for Ancestors<'_> {}
////////////////////////////////////////////////////////////////////////////////
// Basic types and traits
@@ -2610,14 +2610,14 @@ pub struct Display<'a> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> fmt::Debug for Display<'a> {
impl fmt::Debug for Display<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.path, f)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> fmt::Display for Display<'a> {
impl fmt::Display for Display<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.path.inner.display(f)
}
@@ -2671,7 +2671,7 @@ impl AsRef<Path> for OsStr {
}
#[stable(feature = "cow_os_str_as_ref_path", since = "1.8.0")]
impl<'a> AsRef<Path> for Cow<'a, OsStr> {
impl AsRef<Path> for Cow<'_, OsStr> {
fn as_ref(&self) -> &Path {
Path::new(self)
}