From 3bea2ca49d24606920b3a81811379debc0668992 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sun, 17 Feb 2019 19:42:36 -0800 Subject: Use more impl header lifetime elision There are two big categories of changes in here - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop` & `Debug`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl 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. --- src/libstd/ffi/c_str.rs | 4 ++-- src/libstd/ffi/os_str.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libstd/ffi') diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 765452e0288..7e82f33ad8a 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -659,8 +659,8 @@ impl fmt::Debug for CStr { } #[stable(feature = "cstr_default", since = "1.10.0")] -impl<'a> Default for &'a CStr { - fn default() -> &'a CStr { +impl Default for &CStr { + fn default() -> Self { const SLICE: &[c_char] = &[0]; unsafe { CStr::from_ptr(SLICE.as_ptr()) } } diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index f8176892513..5429079f5b8 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -778,10 +778,10 @@ impl Default for Box { } #[stable(feature = "osstring_default", since = "1.9.0")] -impl<'a> Default for &'a OsStr { +impl Default for &OsStr { /// Creates an empty `OsStr`. #[inline] - fn default() -> &'a OsStr { + fn default() -> Self { OsStr::new("") } } -- cgit 1.4.1-3-g733a5