1
Fork 0

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
commit e3a8f7db47
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C
35 changed files with 219 additions and 219 deletions

View file

@ -299,7 +299,7 @@ const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
struct Guard<'a> { buf: &'a mut Vec<u8>, len: usize }
impl<'a> Drop for Guard<'a> {
impl Drop for Guard<'_> {
fn drop(&mut self) {
unsafe { self.buf.set_len(self.len); }
}
@ -1114,7 +1114,7 @@ pub trait Write {
error: Result<()>,
}
impl<'a, T: Write + ?Sized> fmt::Write for Adaptor<'a, T> {
impl<T: Write + ?Sized> fmt::Write for Adaptor<'_, T> {
fn write_str(&mut self, s: &str) -> fmt::Result {
match self.inner.write_all(s.as_bytes()) {
Ok(()) => Ok(()),