From 0a3bd9b6abe1191121f0f6c3fab73dd388e62654 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Mon, 3 Sep 2018 04:50:14 -0700 Subject: [PATCH 1/3] Use impl_header_lifetime_elision in libcore --- src/libcore/borrow.rs | 6 +-- src/libcore/cell.rs | 18 +++---- src/libcore/clone.rs | 2 +- src/libcore/cmp.rs | 12 ++--- src/libcore/convert.rs | 6 +-- src/libcore/fmt/builders.rs | 2 +- src/libcore/fmt/mod.rs | 26 +++++----- src/libcore/hash/mod.rs | 6 +-- src/libcore/iter/iterator.rs | 2 +- src/libcore/iter/traits.rs | 6 +-- src/libcore/lib.rs | 1 + src/libcore/marker.rs | 10 ++-- src/libcore/ops/deref.rs | 6 +-- src/libcore/ops/function.rs | 10 ++-- src/libcore/ops/generator.rs | 2 +- src/libcore/ops/range.rs | 10 ++-- src/libcore/option.rs | 16 +++--- src/libcore/panic.rs | 4 +- src/libcore/result.rs | 16 +++--- src/libcore/slice/mod.rs | 96 ++++++++++++++++++------------------ src/libcore/str/mod.rs | 34 ++++++------- src/libcore/str/pattern.rs | 4 +- src/libcore/tests/iter.rs | 2 +- 23 files changed, 149 insertions(+), 148 deletions(-) diff --git a/src/libcore/borrow.rs b/src/libcore/borrow.rs index f45a32d4b94ac..84d4b21784180 100644 --- a/src/libcore/borrow.rs +++ b/src/libcore/borrow.rs @@ -226,16 +226,16 @@ impl BorrowMut for T { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Borrow for &'a T { +impl Borrow for &T { fn borrow(&self) -> &T { &**self } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Borrow for &'a mut T { +impl Borrow for &mut T { fn borrow(&self) -> &T { &**self } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> BorrowMut for &'a mut T { +impl BorrowMut for &mut T { fn borrow_mut(&mut self) -> &mut T { &mut **self } } diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 009aba5f59869..ec7d366c3f5ce 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1092,7 +1092,7 @@ impl<'b> BorrowRef<'b> { } } -impl<'b> Drop for BorrowRef<'b> { +impl Drop for BorrowRef<'_> { #[inline] fn drop(&mut self) { let borrow = self.borrow.get(); @@ -1101,9 +1101,9 @@ impl<'b> Drop for BorrowRef<'b> { } } -impl<'b> Clone for BorrowRef<'b> { +impl Clone for BorrowRef<'_> { #[inline] - fn clone(&self) -> BorrowRef<'b> { + fn clone(&self) -> Self { // Since this Ref exists, we know the borrow flag // is a reading borrow. let borrow = self.borrow.get(); @@ -1127,7 +1127,7 @@ pub struct Ref<'b, T: ?Sized + 'b> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'b, T: ?Sized> Deref for Ref<'b, T> { +impl Deref for Ref<'_, T> { type Target = T; #[inline] @@ -1219,7 +1219,7 @@ impl<'b, T: ?Sized> Ref<'b, T> { impl<'b, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for Ref<'b, T> {} #[stable(feature = "std_guard_impls", since = "1.20.0")] -impl<'a, T: ?Sized + fmt::Display> fmt::Display for Ref<'a, T> { +impl fmt::Display for Ref<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.value.fmt(f) } @@ -1305,7 +1305,7 @@ struct BorrowRefMut<'b> { borrow: &'b Cell, } -impl<'b> Drop for BorrowRefMut<'b> { +impl Drop for BorrowRefMut<'_> { #[inline] fn drop(&mut self) { let borrow = self.borrow.get(); @@ -1356,7 +1356,7 @@ pub struct RefMut<'b, T: ?Sized + 'b> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'b, T: ?Sized> Deref for RefMut<'b, T> { +impl Deref for RefMut<'_, T> { type Target = T; #[inline] @@ -1366,7 +1366,7 @@ impl<'b, T: ?Sized> Deref for RefMut<'b, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> { +impl DerefMut for RefMut<'_, T> { #[inline] fn deref_mut(&mut self) -> &mut T { self.value @@ -1377,7 +1377,7 @@ impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> { impl<'b, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for RefMut<'b, T> {} #[stable(feature = "std_guard_impls", since = "1.20.0")] -impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { +impl fmt::Display for RefMut<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.value.fmt(f) } diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 3b15ba2b4ab1f..46bb580dcddb1 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -204,7 +204,7 @@ mod impls { // Shared references can be cloned, but mutable references *cannot*! #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized> Clone for &'a T { + impl Clone for &T { #[inline] fn clone(&self) -> Self { *self diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index ef7d83a0993da..33881de30527e 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -1033,12 +1033,12 @@ mod impls { fn gt(&self, other: & &'b B) -> bool { PartialOrd::gt(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, A: ?Sized> Ord for &'a A where A: Ord { + impl Ord for &A where A: Ord { #[inline] - fn cmp(&self, other: & &'a A) -> Ordering { Ord::cmp(*self, *other) } + fn cmp(&self, other: &Self) -> Ordering { Ord::cmp(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, A: ?Sized> Eq for &'a A where A: Eq {} + impl Eq for &A where A: Eq {} // &mut pointers @@ -1065,12 +1065,12 @@ mod impls { fn gt(&self, other: &&'b mut B) -> bool { PartialOrd::gt(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, A: ?Sized> Ord for &'a mut A where A: Ord { + impl Ord for &mut A where A: Ord { #[inline] - fn cmp(&self, other: &&'a mut A) -> Ordering { Ord::cmp(*self, *other) } + fn cmp(&self, other: &Self) -> Ordering { Ord::cmp(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, A: ?Sized> Eq for &'a mut A where A: Eq {} + impl Eq for &mut A where A: Eq {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a A where A: PartialEq { diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index d5337868843df..b900990d0a726 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -407,7 +407,7 @@ pub trait TryFrom: Sized { // As lifts over & #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized, U: ?Sized> AsRef for &'a T where T: AsRef +impl AsRef for &T where T: AsRef { fn as_ref(&self) -> &U { >::as_ref(*self) @@ -416,7 +416,7 @@ impl<'a, T: ?Sized, U: ?Sized> AsRef for &'a T where T: AsRef // As lifts over &mut #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized, U: ?Sized> AsRef for &'a mut T where T: AsRef +impl AsRef for &mut T where T: AsRef { fn as_ref(&self) -> &U { >::as_ref(*self) @@ -433,7 +433,7 @@ impl<'a, T: ?Sized, U: ?Sized> AsRef for &'a mut T where T: AsRef // AsMut lifts over &mut #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized, U: ?Sized> AsMut for &'a mut T where T: AsMut +impl AsMut for &mut T where T: AsMut { fn as_mut(&mut self) -> &mut U { (*self).as_mut() diff --git a/src/libcore/fmt/builders.rs b/src/libcore/fmt/builders.rs index 3c5f934d4d8c7..4bc5b36d82ba2 100644 --- a/src/libcore/fmt/builders.rs +++ b/src/libcore/fmt/builders.rs @@ -28,7 +28,7 @@ impl<'a> PadAdapter<'a> { } } -impl<'a> fmt::Write for PadAdapter<'a> { +impl fmt::Write for PadAdapter<'_> { fn write_str(&mut self, mut s: &str) -> fmt::Result { while !s.is_empty() { if self.on_newline { diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 7d131b5c99dc0..bd253e69db319 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -208,7 +208,7 @@ pub trait Write { // requiring a `Sized` bound. struct Adapter<'a,T: ?Sized +'a>(&'a mut T); - impl<'a, T: ?Sized> Write for Adapter<'a, T> + impl Write for Adapter<'_, T> where T: Write { fn write_str(&mut self, s: &str) -> Result { @@ -229,7 +229,7 @@ pub trait Write { } #[stable(feature = "fmt_write_blanket_impl", since = "1.4.0")] -impl<'a, W: Write + ?Sized> Write for &'a mut W { +impl Write for &mut W { fn write_str(&mut self, s: &str) -> Result { (**self).write_str(s) } @@ -291,8 +291,8 @@ pub struct ArgumentV1<'a> { #[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "0")] -impl<'a> Clone for ArgumentV1<'a> { - fn clone(&self) -> ArgumentV1<'a> { +impl Clone for ArgumentV1<'_> { + fn clone(&self) -> Self { *self } } @@ -436,14 +436,14 @@ pub struct Arguments<'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Debug for Arguments<'a> { +impl Debug for Arguments<'_> { fn fmt(&self, fmt: &mut Formatter) -> Result { Display::fmt(self, fmt) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Display for Arguments<'a> { +impl Display for Arguments<'_> { fn fmt(&self, fmt: &mut Formatter) -> Result { write(fmt.buf, *self) } @@ -1884,7 +1884,7 @@ impl<'a> Formatter<'a> { } #[stable(since = "1.2.0", feature = "formatter_write")] -impl<'a> Write for Formatter<'a> { +impl Write for Formatter<'_> { fn write_str(&mut self, s: &str) -> Result { self.buf.write_str(s) } @@ -1911,11 +1911,11 @@ macro_rules! fmt_refs { ($($tr:ident),*) => { $( #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized + $tr> $tr for &'a T { + impl $tr for &T { fn fmt(&self, f: &mut Formatter) -> Result { $tr::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized + $tr> $tr for &'a mut T { + impl $tr for &mut T { fn fmt(&self, f: &mut Formatter) -> Result { $tr::fmt(&**self, f) } } )* @@ -2039,14 +2039,14 @@ impl Pointer for *mut T { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Pointer for &'a T { +impl Pointer for &T { fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(&(*self as *const T), f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Pointer for &'a mut T { +impl Pointer for &mut T { fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(&(&**self as *const T), f) } @@ -2153,14 +2153,14 @@ impl Debug for RefCell { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'b, T: ?Sized + Debug> Debug for Ref<'b, T> { +impl Debug for Ref<'_, T> { fn fmt(&self, f: &mut Formatter) -> Result { Debug::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'b, T: ?Sized + Debug> Debug for RefMut<'b, T> { +impl Debug for RefMut<'_, T> { fn fmt(&self, f: &mut Formatter) -> Result { Debug::fmt(&*(self.deref()), f) } diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index e7907e0344493..bbebadd452a26 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -361,7 +361,7 @@ pub trait Hasher { } #[stable(feature = "indirect_hasher_impl", since = "1.22.0")] -impl<'a, H: Hasher + ?Sized> Hasher for &'a mut H { +impl Hasher for &mut H { fn finish(&self) -> u64 { (**self).finish() } @@ -669,14 +669,14 @@ mod impls { #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized + Hash> Hash for &'a T { + impl Hash for &T { fn hash(&self, state: &mut H) { (**self).hash(state); } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized + Hash> Hash for &'a mut T { + impl Hash for &mut T { fn hash(&self, state: &mut H) { (**self).hash(state); } diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index d45c123d332eb..4ed4ddb5b656f 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -2557,7 +2557,7 @@ fn select_fold1(mut it: I, } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I { +impl Iterator for &mut I { type Item = I::Item; fn next(&mut self) -> Option { (**self).next() } fn size_hint(&self) -> (usize, Option) { (**self).size_hint() } diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs index 4b2c1aa551e99..f95f8e7dbcbb6 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -724,7 +724,7 @@ pub trait ExactSizeIterator: Iterator { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, I: ExactSizeIterator + ?Sized> ExactSizeIterator for &'a mut I { +impl ExactSizeIterator for &mut I { fn len(&self) -> usize { (**self).len() } @@ -974,7 +974,7 @@ impl Product> for Result pub trait FusedIterator: Iterator {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, I: FusedIterator + ?Sized> FusedIterator for &'a mut I {} +impl FusedIterator for &mut I {} /// An iterator that reports an accurate length using size_hint. /// @@ -999,4 +999,4 @@ impl<'a, I: FusedIterator + ?Sized> FusedIterator for &'a mut I {} pub unsafe trait TrustedLen : Iterator {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, I: TrustedLen + ?Sized> TrustedLen for &'a mut I {} +unsafe impl TrustedLen for &mut I {} diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 94e84106328e2..184ed19da9524 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -87,6 +87,7 @@ #![feature(doc_spotlight)] #![feature(extern_types)] #![feature(fundamental)] +#![feature(impl_header_lifetime_elision)] #![feature(intrinsics)] #![feature(lang_items)] #![feature(link_llvm_intrinsics)] diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 5572fe1512cbb..266c6913747f1 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -584,9 +584,9 @@ impls! { PhantomData } mod impls { #[stable(feature = "rust1", since = "1.0.0")] - unsafe impl<'a, T: Sync + ?Sized> Send for &'a T {} + unsafe impl Send for &T {} #[stable(feature = "rust1", since = "1.0.0")] - unsafe impl<'a, T: Send + ?Sized> Send for &'a mut T {} + unsafe impl Send for &mut T {} } /// Compiler-internal trait used to determine whether a type contains @@ -600,8 +600,8 @@ impl !Freeze for UnsafeCell {} unsafe impl Freeze for PhantomData {} unsafe impl Freeze for *const T {} unsafe impl Freeze for *mut T {} -unsafe impl<'a, T: ?Sized> Freeze for &'a T {} -unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {} +unsafe impl Freeze for &T {} +unsafe impl Freeze for &mut T {} /// Types which can be safely moved after being pinned. /// @@ -689,6 +689,6 @@ mod copy_impls { // Shared references can be copied, but mutable references *cannot*! #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized> Copy for &'a T {} + impl Copy for &T {} } diff --git a/src/libcore/ops/deref.rs b/src/libcore/ops/deref.rs index 54eecc82e19ef..91a3d77e8b2ef 100644 --- a/src/libcore/ops/deref.rs +++ b/src/libcore/ops/deref.rs @@ -83,14 +83,14 @@ pub trait Deref { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Deref for &'a T { +impl Deref for &T { type Target = T; fn deref(&self) -> &T { *self } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Deref for &'a mut T { +impl Deref for &mut T { type Target = T; fn deref(&self) -> &T { *self } @@ -174,6 +174,6 @@ pub trait DerefMut: Deref { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> DerefMut for &'a mut T { +impl DerefMut for &mut T { fn deref_mut(&mut self) -> &mut T { *self } } diff --git a/src/libcore/ops/function.rs b/src/libcore/ops/function.rs index 3ebd10a920919..c9591c3f57bb0 100644 --- a/src/libcore/ops/function.rs +++ b/src/libcore/ops/function.rs @@ -240,7 +240,7 @@ pub trait FnOnce { mod impls { #[stable(feature = "rust1", since = "1.0.0")] - impl<'a,A,F:?Sized> Fn for &'a F + impl Fn for &F where F : Fn { extern "rust-call" fn call(&self, args: A) -> F::Output { @@ -249,7 +249,7 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a,A,F:?Sized> FnMut for &'a F + impl FnMut for &F where F : Fn { extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output { @@ -258,7 +258,7 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a,A,F:?Sized> FnOnce for &'a F + impl FnOnce for &F where F : Fn { type Output = F::Output; @@ -269,7 +269,7 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a,A,F:?Sized> FnMut for &'a mut F + impl FnMut for &mut F where F : FnMut { extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output { @@ -278,7 +278,7 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a,A,F:?Sized> FnOnce for &'a mut F + impl FnOnce for &mut F where F : FnMut { type Output = F::Output; diff --git a/src/libcore/ops/generator.rs b/src/libcore/ops/generator.rs index 4b70c5398be4f..297089926b536 100644 --- a/src/libcore/ops/generator.rs +++ b/src/libcore/ops/generator.rs @@ -124,7 +124,7 @@ pub trait Generator { } #[unstable(feature = "generator_trait", issue = "43122")] -impl<'a, T> Generator for &'a mut T +impl Generator for &mut T where T: Generator + ?Sized { type Yield = T::Yield; diff --git a/src/libcore/ops/range.rs b/src/libcore/ops/range.rs index 9c635678d7aa0..f7e5a89a7aae1 100644 --- a/src/libcore/ops/range.rs +++ b/src/libcore/ops/range.rs @@ -851,7 +851,7 @@ impl<'a, T: ?Sized + 'a> RangeBounds for (Bound<&'a T>, Bound<&'a T>) { } #[stable(feature = "collections_range", since = "1.28.0")] -impl<'a, T> RangeBounds for RangeFrom<&'a T> { +impl RangeBounds for RangeFrom<&T> { fn start_bound(&self) -> Bound<&T> { Included(self.start) } @@ -861,7 +861,7 @@ impl<'a, T> RangeBounds for RangeFrom<&'a T> { } #[stable(feature = "collections_range", since = "1.28.0")] -impl<'a, T> RangeBounds for RangeTo<&'a T> { +impl RangeBounds for RangeTo<&T> { fn start_bound(&self) -> Bound<&T> { Unbounded } @@ -871,7 +871,7 @@ impl<'a, T> RangeBounds for RangeTo<&'a T> { } #[stable(feature = "collections_range", since = "1.28.0")] -impl<'a, T> RangeBounds for Range<&'a T> { +impl RangeBounds for Range<&T> { fn start_bound(&self) -> Bound<&T> { Included(self.start) } @@ -881,7 +881,7 @@ impl<'a, T> RangeBounds for Range<&'a T> { } #[stable(feature = "collections_range", since = "1.28.0")] -impl<'a, T> RangeBounds for RangeInclusive<&'a T> { +impl RangeBounds for RangeInclusive<&T> { fn start_bound(&self) -> Bound<&T> { Included(self.start) } @@ -891,7 +891,7 @@ impl<'a, T> RangeBounds for RangeInclusive<&'a T> { } #[stable(feature = "collections_range", since = "1.28.0")] -impl<'a, T> RangeBounds for RangeToInclusive<&'a T> { +impl RangeBounds for RangeToInclusive<&T> { fn start_bound(&self) -> Bound<&T> { Unbounded } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 58bf6be834d46..0255f7a0885ea 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1153,18 +1153,18 @@ impl<'a, A> DoubleEndedIterator for Iter<'a, A> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, A> ExactSizeIterator for Iter<'a, A> {} +impl ExactSizeIterator for Iter<'_, A> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, A> FusedIterator for Iter<'a, A> {} +impl FusedIterator for Iter<'_, A> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, A> TrustedLen for Iter<'a, A> {} +unsafe impl TrustedLen for Iter<'_, A> {} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, A> Clone for Iter<'a, A> { +impl Clone for Iter<'_, A> { #[inline] - fn clone(&self) -> Iter<'a, A> { + fn clone(&self) -> Self { Iter { inner: self.inner.clone() } } } @@ -1199,12 +1199,12 @@ impl<'a, A> DoubleEndedIterator for IterMut<'a, A> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, A> ExactSizeIterator for IterMut<'a, A> {} +impl ExactSizeIterator for IterMut<'_, A> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, A> FusedIterator for IterMut<'a, A> {} +impl FusedIterator for IterMut<'_, A> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, A> TrustedLen for IterMut<'a, A> {} +unsafe impl TrustedLen for IterMut<'_, A> {} /// An iterator over the value in [`Some`] variant of an [`Option`]. /// diff --git a/src/libcore/panic.rs b/src/libcore/panic.rs index 17cac5aa0a05f..f0efeb59e8d6e 100644 --- a/src/libcore/panic.rs +++ b/src/libcore/panic.rs @@ -133,7 +133,7 @@ impl<'a> PanicInfo<'a> { } #[stable(feature = "panic_hook_display", since = "1.26.0")] -impl<'a> fmt::Display for PanicInfo<'a> { +impl fmt::Display for PanicInfo<'_> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("panicked at ")?; if let Some(message) = self.message { @@ -258,7 +258,7 @@ impl<'a> Location<'a> { } #[stable(feature = "panic_hook_display", since = "1.26.0")] -impl<'a> fmt::Display for Location<'a> { +impl fmt::Display for Location<'_> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!(formatter, "{}:{}:{}", self.file, self.line, self.col) } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 93ee11aac36b0..3484664c24205 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -1098,18 +1098,18 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for Iter<'a, T> {} +impl ExactSizeIterator for Iter<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Iter<'a, T> {} +impl FusedIterator for Iter<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, A> TrustedLen for Iter<'a, A> {} +unsafe impl TrustedLen for Iter<'_, A> {} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Iter<'a, T> { +impl Clone for Iter<'_, T> { #[inline] - fn clone(&self) -> Iter<'a, T> { Iter { inner: self.inner } } + fn clone(&self) -> Self { Iter { inner: self.inner } } } /// An iterator over a mutable reference to the [`Ok`] variant of a [`Result`]. @@ -1143,13 +1143,13 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for IterMut<'a, T> {} +impl ExactSizeIterator for IterMut<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for IterMut<'a, T> {} +impl FusedIterator for IterMut<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, A> TrustedLen for IterMut<'a, A> {} +unsafe impl TrustedLen for IterMut<'_, A> {} /// An iterator over the value in a [`Ok`] variant of a [`Result`]. /// diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 05027bbe89890..a51c641cf35ad 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -2528,15 +2528,15 @@ impl SliceIndex<[T]> for ops::RangeToInclusive { //////////////////////////////////////////////////////////////////////////////// #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Default for &'a [T] { +impl Default for &[T] { /// Creates an empty slice. - fn default() -> &'a [T] { &[] } + fn default() -> Self { &[] } } #[stable(feature = "mut_slice_default", since = "1.5.0")] -impl<'a, T> Default for &'a mut [T] { +impl Default for &mut [T] { /// Creates a mutable empty slice. - fn default() -> &'a mut [T] { &mut [] } + fn default() -> Self { &mut [] } } // @@ -2863,7 +2863,7 @@ pub struct Iter<'a, T: 'a> { } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> { +impl fmt::Debug for Iter<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("Iter") .field(&self.as_slice()) @@ -2872,9 +2872,9 @@ impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Sync> Sync for Iter<'a, T> {} +unsafe impl Sync for Iter<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Sync> Send for Iter<'a, T> {} +unsafe impl Send for Iter<'_, T> {} impl<'a, T> Iter<'a, T> { /// View the underlying data as a subslice of the original data. @@ -2910,12 +2910,12 @@ impl<'a, T> Iter<'a, T> { iterator!{struct Iter -> *const T, &'a T, const, /* no mut */} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Iter<'a, T> { - fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } } +impl Clone for Iter<'_, T> { + fn clone(&self) -> Self { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } } } #[stable(feature = "slice_iter_as_ref", since = "1.13.0")] -impl<'a, T> AsRef<[T]> for Iter<'a, T> { +impl AsRef<[T]> for Iter<'_, T> { fn as_ref(&self) -> &[T] { self.as_slice() } @@ -2955,7 +2955,7 @@ pub struct IterMut<'a, T: 'a> { } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> { +impl fmt::Debug for IterMut<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("IterMut") .field(&self.make_slice()) @@ -2964,9 +2964,9 @@ impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Sync> Sync for IterMut<'a, T> {} +unsafe impl Sync for IterMut<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Send> Send for IterMut<'a, T> {} +unsafe impl Send for IterMut<'_, T> {} impl<'a, T> IterMut<'a, T> { /// View the underlying data as a subslice of the original data. @@ -3034,7 +3034,7 @@ pub struct Split<'a, T:'a, P> where P: FnMut(&T) -> bool { } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for Split<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for Split<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Split") .field("v", &self.v) @@ -3045,8 +3045,8 @@ impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for Split<'a, T, P> where P: FnMut(&T // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T, P> Clone for Split<'a, T, P> where P: Clone + FnMut(&T) -> bool { - fn clone(&self) -> Split<'a, T, P> { +impl Clone for Split<'_, T, P> where P: Clone + FnMut(&T) -> bool { + fn clone(&self) -> Self { Split { v: self.v, pred: self.pred.clone(), @@ -3108,7 +3108,7 @@ impl<'a, T, P> SplitIter for Split<'a, T, P> where P: FnMut(&T) -> bool { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T, P> FusedIterator for Split<'a, T, P> where P: FnMut(&T) -> bool {} +impl FusedIterator for Split<'_, T, P> where P: FnMut(&T) -> bool {} /// An iterator over the subslices of the vector which are separated /// by elements that match `pred`. @@ -3125,7 +3125,7 @@ pub struct SplitMut<'a, T:'a, P> where P: FnMut(&T) -> bool { } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for SplitMut<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for SplitMut<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SplitMut") .field("v", &self.v) @@ -3206,7 +3206,7 @@ impl<'a, T, P> DoubleEndedIterator for SplitMut<'a, T, P> where } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T, P> FusedIterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {} +impl FusedIterator for SplitMut<'_, T, P> where P: FnMut(&T) -> bool {} /// An iterator over subslices separated by elements that match a predicate /// function, starting from the end of the slice. @@ -3222,7 +3222,7 @@ pub struct RSplit<'a, T:'a, P> where P: FnMut(&T) -> bool { } #[stable(feature = "slice_rsplit", since = "1.27.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplit<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for RSplit<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RSplit") .field("v", &self.inner.v) @@ -3263,7 +3263,7 @@ impl<'a, T, P> SplitIter for RSplit<'a, T, P> where P: FnMut(&T) -> bool { } #[stable(feature = "slice_rsplit", since = "1.27.0")] -impl<'a, T, P> FusedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {} +impl FusedIterator for RSplit<'_, T, P> where P: FnMut(&T) -> bool {} /// An iterator over the subslices of the vector which are separated /// by elements that match `pred`, starting from the end of the slice. @@ -3278,7 +3278,7 @@ pub struct RSplitMut<'a, T:'a, P> where P: FnMut(&T) -> bool { } #[stable(feature = "slice_rsplit", since = "1.27.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for RSplitMut<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RSplitMut") .field("v", &self.inner.v) @@ -3321,7 +3321,7 @@ impl<'a, T, P> DoubleEndedIterator for RSplitMut<'a, T, P> where } #[stable(feature = "slice_rsplit", since = "1.27.0")] -impl<'a, T, P> FusedIterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {} +impl FusedIterator for RSplitMut<'_, T, P> where P: FnMut(&T) -> bool {} /// An private iterator over subslices separated by elements that /// match a predicate function, splitting at most a fixed number of @@ -3364,7 +3364,7 @@ pub struct SplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool { } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for SplitN<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for SplitN<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SplitN") .field("inner", &self.inner) @@ -3386,7 +3386,7 @@ pub struct RSplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool { } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitN<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for RSplitN<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RSplitN") .field("inner", &self.inner) @@ -3407,7 +3407,7 @@ pub struct SplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool { } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for SplitNMut<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for SplitNMut<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SplitNMut") .field("inner", &self.inner) @@ -3429,7 +3429,7 @@ pub struct RSplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool { } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitNMut<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for RSplitNMut<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RSplitNMut") .field("inner", &self.inner) @@ -3482,8 +3482,8 @@ pub struct Windows<'a, T:'a> { // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Windows<'a, T> { - fn clone(&self) -> Windows<'a, T> { +impl Clone for Windows<'_, T> { + fn clone(&self) -> Self { Windows { v: self.v, size: self.size, @@ -3560,13 +3560,13 @@ impl<'a, T> DoubleEndedIterator for Windows<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for Windows<'a, T> {} +impl ExactSizeIterator for Windows<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for Windows<'a, T> {} +unsafe impl TrustedLen for Windows<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Windows<'a, T> {} +impl FusedIterator for Windows<'_, T> {} #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for Windows<'a, T> { @@ -3595,8 +3595,8 @@ pub struct Chunks<'a, T:'a> { // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Chunks<'a, T> { - fn clone(&self) -> Chunks<'a, T> { +impl Clone for Chunks<'_, T> { + fn clone(&self) -> Self { Chunks { v: self.v, chunk_size: self.chunk_size, @@ -3682,13 +3682,13 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for Chunks<'a, T> {} +impl ExactSizeIterator for Chunks<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for Chunks<'a, T> {} +unsafe impl TrustedLen for Chunks<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Chunks<'a, T> {} +impl FusedIterator for Chunks<'_, T> {} #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for Chunks<'a, T> { @@ -3801,13 +3801,13 @@ impl<'a, T> DoubleEndedIterator for ChunksMut<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {} +impl ExactSizeIterator for ChunksMut<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for ChunksMut<'a, T> {} +unsafe impl TrustedLen for ChunksMut<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for ChunksMut<'a, T> {} +impl FusedIterator for ChunksMut<'_, T> {} #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for ChunksMut<'a, T> { @@ -3854,8 +3854,8 @@ impl<'a, T> ChunksExact<'a, T> { // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[unstable(feature = "chunks_exact", issue = "47115")] -impl<'a, T> Clone for ChunksExact<'a, T> { - fn clone(&self) -> ChunksExact<'a, T> { +impl Clone for ChunksExact<'_, T> { + fn clone(&self) -> Self { ChunksExact { v: self.v, rem: self.rem, @@ -3924,17 +3924,17 @@ impl<'a, T> DoubleEndedIterator for ChunksExact<'a, T> { } #[unstable(feature = "chunks_exact", issue = "47115")] -impl<'a, T> ExactSizeIterator for ChunksExact<'a, T> { +impl ExactSizeIterator for ChunksExact<'_, T> { fn is_empty(&self) -> bool { self.v.is_empty() } } #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for ChunksExact<'a, T> {} +unsafe impl TrustedLen for ChunksExact<'_, T> {} #[unstable(feature = "chunks_exact", issue = "47115")] -impl<'a, T> FusedIterator for ChunksExact<'a, T> {} +impl FusedIterator for ChunksExact<'_, T> {} #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for ChunksExact<'a, T> { @@ -4039,17 +4039,17 @@ impl<'a, T> DoubleEndedIterator for ChunksExactMut<'a, T> { } #[unstable(feature = "chunks_exact", issue = "47115")] -impl<'a, T> ExactSizeIterator for ChunksExactMut<'a, T> { +impl ExactSizeIterator for ChunksExactMut<'_, T> { fn is_empty(&self) -> bool { self.v.is_empty() } } #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for ChunksExactMut<'a, T> {} +unsafe impl TrustedLen for ChunksExactMut<'_, T> {} #[unstable(feature = "chunks_exact", issue = "47115")] -impl<'a, T> FusedIterator for ChunksExactMut<'a, T> {} +impl FusedIterator for ChunksExactMut<'_, T> {} #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> { diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 2c941c28d4b80..a2782dd8e2e43 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -617,7 +617,7 @@ impl<'a> DoubleEndedIterator for Chars<'a> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for Chars<'a> {} +impl FusedIterator for Chars<'_> {} impl<'a> Chars<'a> { /// View the underlying data as a subslice of the original data. @@ -707,7 +707,7 @@ impl<'a> DoubleEndedIterator for CharIndices<'a> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for CharIndices<'a> {} +impl FusedIterator for CharIndices<'_> {} impl<'a> CharIndices<'a> { /// View the underlying data as a subslice of the original data. @@ -733,7 +733,7 @@ impl<'a> CharIndices<'a> { pub struct Bytes<'a>(Cloned>); #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Iterator for Bytes<'a> { +impl Iterator for Bytes<'_> { type Item = u8; #[inline] @@ -794,7 +794,7 @@ impl<'a> Iterator for Bytes<'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> DoubleEndedIterator for Bytes<'a> { +impl DoubleEndedIterator for Bytes<'_> { #[inline] fn next_back(&mut self) -> Option { self.0.next_back() @@ -809,7 +809,7 @@ impl<'a> DoubleEndedIterator for Bytes<'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> ExactSizeIterator for Bytes<'a> { +impl ExactSizeIterator for Bytes<'_> { #[inline] fn len(&self) -> usize { self.0.len() @@ -822,10 +822,10 @@ impl<'a> ExactSizeIterator for Bytes<'a> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for Bytes<'a> {} +impl FusedIterator for Bytes<'_> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a> TrustedLen for Bytes<'a> {} +unsafe impl TrustedLen for Bytes<'_> {} #[doc(hidden)] unsafe impl<'a> TrustedRandomAccess for Bytes<'a> { @@ -1342,7 +1342,7 @@ impl<'a> DoubleEndedIterator for Lines<'a> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for Lines<'a> {} +impl FusedIterator for Lines<'_> {} /// Created with the method [`lines_any`]. /// @@ -1409,7 +1409,7 @@ impl<'a> DoubleEndedIterator for LinesAny<'a> { #[stable(feature = "fused", since = "1.26.0")] #[allow(deprecated)] -impl<'a> FusedIterator for LinesAny<'a> {} +impl FusedIterator for LinesAny<'_> {} /* Section: UTF-8 validation @@ -4033,15 +4033,15 @@ impl AsRef<[u8]> for str { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Default for &'a str { +impl Default for &str { /// Creates an empty str - fn default() -> &'a str { "" } + fn default() -> Self { "" } } #[stable(feature = "default_mut_str", since = "1.28.0")] -impl<'a> Default for &'a mut str { +impl Default for &mut str { /// Creates an empty mutable str - fn default() -> &'a mut str { unsafe { from_utf8_unchecked_mut(&mut []) } } + fn default() -> Self { unsafe { from_utf8_unchecked_mut(&mut []) } } } /// An iterator over the non-whitespace substrings of a string, @@ -4189,7 +4189,7 @@ impl<'a> DoubleEndedIterator for SplitWhitespace<'a> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for SplitWhitespace<'a> {} +impl FusedIterator for SplitWhitespace<'_> {} #[unstable(feature = "split_ascii_whitespace", issue = "48656")] impl<'a> Iterator for SplitAsciiWhitespace<'a> { @@ -4215,7 +4215,7 @@ impl<'a> DoubleEndedIterator for SplitAsciiWhitespace<'a> { } #[unstable(feature = "split_ascii_whitespace", issue = "48656")] -impl<'a> FusedIterator for SplitAsciiWhitespace<'a> {} +impl FusedIterator for SplitAsciiWhitespace<'_> {} /// An iterator of [`u16`] over the string encoded as UTF-16. /// @@ -4234,7 +4234,7 @@ pub struct EncodeUtf16<'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a> fmt::Debug for EncodeUtf16<'a> { +impl fmt::Debug for EncodeUtf16<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("EncodeUtf16 { .. }") } @@ -4273,4 +4273,4 @@ impl<'a> Iterator for EncodeUtf16<'a> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for EncodeUtf16<'a> {} +impl FusedIterator for EncodeUtf16<'_> {} diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 5e63fa9ff354c..1c974533e10c8 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -491,7 +491,7 @@ impl MultiCharEq for F where F: FnMut(char) -> bool { fn matches(&mut self, c: char) -> bool { (*self)(c) } } -impl<'a> MultiCharEq for &'a [char] { +impl MultiCharEq for &[char] { #[inline] fn matches(&mut self, c: char) -> bool { self.iter().any(|&m| { m == c }) @@ -666,7 +666,7 @@ impl<'a, 'b> Pattern<'a> for &'b [char] { pub struct CharPredicateSearcher<'a, F>( as Pattern<'a>>::Searcher) where F: FnMut(char) -> bool; -impl<'a, F> fmt::Debug for CharPredicateSearcher<'a, F> +impl fmt::Debug for CharPredicateSearcher<'_, F> where F: FnMut(char) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 72b115f8b5f77..2476c07cbd9ca 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -229,7 +229,7 @@ fn test_iterator_step_by_nth_overflow() { #[derive(Clone)] struct Test(Bigger); - impl<'a> Iterator for &'a mut Test { + impl Iterator for &mut Test { type Item = i32; fn next(&mut self) -> Option { Some(21) } fn nth(&mut self, n: usize) -> Option { From 8d6bee3442830cf7b420e8b1ad60fadee8336c0e Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 29 Sep 2018 22:05:07 -0700 Subject: [PATCH 2/3] UI test updates --- src/test/ui/coherence/coherence-impls-copy.stderr | 4 ++-- src/test/ui/e0119/issue-28981.stderr | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/ui/coherence/coherence-impls-copy.stderr b/src/test/ui/coherence/coherence-impls-copy.stderr index 24e7e85b1a961..613ee0a269e70 100644 --- a/src/test/ui/coherence/coherence-impls-copy.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.stderr @@ -14,7 +14,7 @@ LL | impl Copy for &'static NotSync {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - - impl<'a, T> std::marker::Copy for &'a T + - impl<'_, T> std::marker::Copy for &T where T: ?Sized; error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: @@ -24,7 +24,7 @@ LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - - impl<'a, T> std::marker::Copy for &'a T + - impl<'_, T> std::marker::Copy for &T where T: ?Sized; error[E0206]: the trait `Copy` may not be implemented for this type diff --git a/src/test/ui/e0119/issue-28981.stderr b/src/test/ui/e0119/issue-28981.stderr index afcbab4a5c6c0..4886ad7717574 100644 --- a/src/test/ui/e0119/issue-28981.stderr +++ b/src/test/ui/e0119/issue-28981.stderr @@ -5,7 +5,7 @@ LL | impl Deref for Foo { } //~ ERROR must be used | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - - impl<'a, T> std::ops::Deref for &'a T + - impl<'_, T> std::ops::Deref for &T where T: ?Sized; error[E0210]: type parameter `Foo` must be used as the type parameter for some local type (e.g. `MyStruct`) From d4840da77993d052bae2a900163026602ac89d3c Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 29 Sep 2018 23:29:58 -0700 Subject: [PATCH 3/3] Activate the feature in the libcore tests too --- src/libcore/tests/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index e034ff8059349..ada61d8dfd873 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -19,6 +19,7 @@ #![feature(flt2dec)] #![feature(fmt_internals)] #![feature(hashmap_internals)] +#![feature(impl_header_lifetime_elision)] #![feature(pattern)] #![feature(range_is_empty)] #![feature(raw)]