Skip to content

Commit

Permalink
liballoc: elide some lifetimes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Feb 2, 2019
1 parent 748970d commit e70c2fb
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 126 deletions.
20 changes: 7 additions & 13 deletions src/liballoc/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ pub enum Cow<'a, B: ?Sized + 'a>
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Clone for Cow<'a, B>
where B: ToOwned
{
impl<'a, B: ?Sized + ToOwned> Clone for Cow<'a, B> {
fn clone(&self) -> Cow<'a, B> {
match *self {
Borrowed(b) => Borrowed(b),
Expand All @@ -208,9 +206,7 @@ impl<'a, B: ?Sized> Clone for Cow<'a, B>
}
}

impl<'a, B: ?Sized> Cow<'a, B>
where B: ToOwned
{
impl<B: ?Sized + ToOwned> Cow<'_, B> {
/// Acquires a mutable reference to the owned form of the data.
///
/// Clones the data if it is not already owned.
Expand Down Expand Up @@ -286,9 +282,7 @@ impl<'a, B: ?Sized> Cow<'a, B>
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Deref for Cow<'a, B>
where B: ToOwned
{
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B> {
type Target = B;

fn deref(&self) -> &B {
Expand All @@ -300,7 +294,7 @@ impl<'a, B: ?Sized> Deref for Cow<'a, B>
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Eq for Cow<'a, B> where B: Eq + ToOwned {}
impl<B: ?Sized> Eq for Cow<'_, B> where B: Eq + ToOwned {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Ord for Cow<'a, B>
Expand Down Expand Up @@ -334,7 +328,7 @@ impl<'a, B: ?Sized> PartialOrd for Cow<'a, B>
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> fmt::Debug for Cow<'a, B>
impl<B: ?Sized> fmt::Debug for Cow<'_, B>
where B: fmt::Debug + ToOwned,
<B as ToOwned>::Owned: fmt::Debug
{
Expand All @@ -347,7 +341,7 @@ impl<'a, B: ?Sized> fmt::Debug for Cow<'a, B>
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> fmt::Display for Cow<'a, B>
impl<B: ?Sized> fmt::Display for Cow<'_, B>
where B: fmt::Display + ToOwned,
<B as ToOwned>::Owned: fmt::Display
{
Expand Down Expand Up @@ -381,7 +375,7 @@ impl<'a, B: ?Sized> Hash for Cow<'a, B>
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: ?Sized + ToOwned> AsRef<T> for Cow<'a, T> {
impl<T: ?Sized + ToOwned> AsRef<T> for Cow<'_, T> {
fn as_ref(&self) -> &T {
self
}
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ impl<A, F> FnBox<A> for F

#[unstable(feature = "fnbox",
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
impl<'a, A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + 'a> {
impl<A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + '_> {
type Output = R;

extern "rust-call" fn call_once(self, args: A) -> R {
Expand All @@ -749,7 +749,7 @@ impl<'a, A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + 'a> {

#[unstable(feature = "fnbox",
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
impl<'a, A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + Send + 'a> {
impl<A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + Send + '_> {
type Output = R;

extern "rust-call" fn call_once(self, args: A) -> R {
Expand Down
24 changes: 12 additions & 12 deletions src/liballoc/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ pub struct PeekMut<'a, T: 'a + Ord> {
}

#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: Ord + fmt::Debug> fmt::Debug for PeekMut<'a, T> {
impl<T: Ord + fmt::Debug> fmt::Debug for PeekMut<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("PeekMut")
.field(&self.heap.data[0])
Expand All @@ -240,7 +240,7 @@ impl<'a, T: Ord + fmt::Debug> fmt::Debug for PeekMut<'a, T> {
}

#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
impl<'a, T: Ord> Drop for PeekMut<'a, T> {
impl<T: Ord> Drop for PeekMut<'_, T> {
fn drop(&mut self) {
if self.sift {
self.heap.sift_down(0);
Expand All @@ -249,15 +249,15 @@ impl<'a, T: Ord> Drop for PeekMut<'a, T> {
}

#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
impl<'a, T: Ord> Deref for PeekMut<'a, T> {
impl<T: Ord> Deref for PeekMut<'_, T> {
type Target = T;
fn deref(&self) -> &T {
&self.heap.data[0]
}
}

#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
impl<'a, T: Ord> DerefMut for PeekMut<'a, T> {
impl<T: Ord> DerefMut for PeekMut<'_, T> {
fn deref_mut(&mut self) -> &mut T {
&mut self.heap.data[0]
}
Expand Down Expand Up @@ -912,7 +912,7 @@ impl<'a, T> Hole<'a, T> {
}
}

impl<'a, T> Drop for Hole<'a, T> {
impl<T> Drop for Hole<'_, T> {
#[inline]
fn drop(&mut self) {
// fill the hole again
Expand All @@ -936,7 +936,7 @@ pub struct Iter<'a, T: 'a> {
}

#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> {
impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Iter")
.field(&self.iter.as_slice())
Expand Down Expand Up @@ -976,14 +976,14 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for Iter<'a, T> {
impl<T> ExactSizeIterator for Iter<'_, T> {
fn is_empty(&self) -> bool {
self.iter.is_empty()
}
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for Iter<'a, T> {}
impl<T> FusedIterator for Iter<'_, T> {}

/// An owning iterator over the elements of a `BinaryHeap`.
///
Expand Down Expand Up @@ -1054,7 +1054,7 @@ pub struct Drain<'a, T: 'a> {
}

#[stable(feature = "drain", since = "1.6.0")]
impl<'a, T: 'a> Iterator for Drain<'a, T> {
impl<T> Iterator for Drain<'_, T> {
type Item = T;

#[inline]
Expand All @@ -1069,22 +1069,22 @@ impl<'a, T: 'a> Iterator for Drain<'a, T> {
}

#[stable(feature = "drain", since = "1.6.0")]
impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> {
impl<T> DoubleEndedIterator for Drain<'_, T> {
#[inline]
fn next_back(&mut self) -> Option<T> {
self.iter.next_back()
}
}

#[stable(feature = "drain", since = "1.6.0")]
impl<'a, T: 'a> ExactSizeIterator for Drain<'a, T> {
impl<T> ExactSizeIterator for Drain<'_, T> {
fn is_empty(&self) -> bool {
self.iter.is_empty()
}
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T: 'a> FusedIterator for Drain<'a, T> {}
impl<T> FusedIterator for Drain<'_, T> {}

#[stable(feature = "binary_heap_extras_15", since = "1.5.0")]
impl<T: Ord> From<Vec<T>> for BinaryHeap<T> {
Expand Down
43 changes: 21 additions & 22 deletions src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ pub struct Iter<'a, K: 'a, V: 'a> {
}

#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Iter<'a, K, V> {
impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for Iter<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.clone()).finish()
}
Expand Down Expand Up @@ -337,7 +337,7 @@ pub struct Keys<'a, K: 'a, V: 'a> {
}

#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, K: 'a + fmt::Debug, V: 'a> fmt::Debug for Keys<'a, K, V> {
impl<K: fmt::Debug, V> fmt::Debug for Keys<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.clone()).finish()
}
Expand All @@ -356,7 +356,7 @@ pub struct Values<'a, K: 'a, V: 'a> {
}

#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, K: 'a, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V> {
impl<K, V: fmt::Debug> fmt::Debug for Values<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.clone()).finish()
}
Expand Down Expand Up @@ -389,7 +389,7 @@ pub struct Range<'a, K: 'a, V: 'a> {
}

#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Range<'a, K, V> {
impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for Range<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.clone()).finish()
}
Expand All @@ -412,7 +412,7 @@ pub struct RangeMut<'a, K: 'a, V: 'a> {
}

#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for RangeMut<'a, K, V> {
impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for RangeMut<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let range = Range {
front: self.front.reborrow(),
Expand Down Expand Up @@ -442,7 +442,7 @@ pub enum Entry<'a, K: 'a, V: 'a> {
}

#[stable(feature= "debug_btree_map", since = "1.12.0")]
impl<'a, K: 'a + Debug + Ord, V: 'a + Debug> Debug for Entry<'a, K, V> {
impl<K: Debug + Ord, V: Debug> Debug for Entry<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Vacant(ref v) => f.debug_tuple("Entry")
Expand Down Expand Up @@ -470,7 +470,7 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> {
}

#[stable(feature= "debug_btree_map", since = "1.12.0")]
impl<'a, K: 'a + Debug + Ord, V: 'a> Debug for VacantEntry<'a, K, V> {
impl<K: Debug + Ord, V> Debug for VacantEntry<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("VacantEntry")
.field(self.key())
Expand All @@ -493,7 +493,7 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
}

#[stable(feature= "debug_btree_map", since = "1.12.0")]
impl<'a, K: 'a + Debug + Ord, V: 'a + Debug> Debug for OccupiedEntry<'a, K, V> {
impl<K: Debug + Ord, V: Debug> Debug for OccupiedEntry<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("OccupiedEntry")
.field("key", self.key())
Expand Down Expand Up @@ -1202,7 +1202,7 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> {
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Iter<'a, K, V> {}
impl<K, V> FusedIterator for Iter<'_, K, V> {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: 'a, V: 'a> DoubleEndedIterator for Iter<'a, K, V> {
Expand All @@ -1217,7 +1217,7 @@ impl<'a, K: 'a, V: 'a> DoubleEndedIterator for Iter<'a, K, V> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: 'a, V: 'a> ExactSizeIterator for Iter<'a, K, V> {
impl<K, V> ExactSizeIterator for Iter<'_, K, V> {
fn len(&self) -> usize {
self.length
}
Expand Down Expand Up @@ -1274,14 +1274,14 @@ impl<'a, K: 'a, V: 'a> DoubleEndedIterator for IterMut<'a, K, V> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: 'a, V: 'a> ExactSizeIterator for IterMut<'a, K, V> {
impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
fn len(&self) -> usize {
self.length
}
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for IterMut<'a, K, V> {}
impl<K, V> FusedIterator for IterMut<'_, K, V> {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<K, V> IntoIterator for BTreeMap<K, V> {
Expand Down Expand Up @@ -1437,14 +1437,14 @@ impl<'a, K, V> DoubleEndedIterator for Keys<'a, K, V> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {
impl<K, V> ExactSizeIterator for Keys<'_, K, V> {
fn len(&self) -> usize {
self.inner.len()
}
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Keys<'a, K, V> {}
impl<K, V> FusedIterator for Keys<'_, K, V> {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Clone for Keys<'a, K, V> {
Expand Down Expand Up @@ -1474,14 +1474,14 @@ impl<'a, K, V> DoubleEndedIterator for Values<'a, K, V> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {
impl<K, V> ExactSizeIterator for Values<'_, K, V> {
fn len(&self) -> usize {
self.inner.len()
}
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Values<'a, K, V> {}
impl<K, V> FusedIterator for Values<'_, K, V> {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Clone for Values<'a, K, V> {
Expand Down Expand Up @@ -1524,15 +1524,14 @@ impl<'a, K, V> DoubleEndedIterator for ValuesMut<'a, K, V> {
}

#[stable(feature = "map_values_mut", since = "1.10.0")]
impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> {
impl<K, V> ExactSizeIterator for ValuesMut<'_, K, V> {
fn len(&self) -> usize {
self.inner.len()
}
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for ValuesMut<'a, K, V> {}

impl<K, V> FusedIterator for ValuesMut<'_, K, V> {}

impl<'a, K, V> Range<'a, K, V> {
unsafe fn next_unchecked(&mut self) -> (&'a K, &'a V) {
Expand Down Expand Up @@ -1610,7 +1609,7 @@ impl<'a, K, V> Range<'a, K, V> {
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Range<'a, K, V> {}
impl<K, V> FusedIterator for Range<'_, K, V> {}

#[stable(feature = "btree_range", since = "1.17.0")]
impl<'a, K, V> Clone for Range<'a, K, V> {
Expand Down Expand Up @@ -1679,7 +1678,7 @@ impl<'a, K, V> DoubleEndedIterator for RangeMut<'a, K, V> {
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for RangeMut<'a, K, V> {}
impl<K, V> FusedIterator for RangeMut<'_, K, V> {}

impl<'a, K, V> RangeMut<'a, K, V> {
unsafe fn next_back_unchecked(&mut self) -> (&'a K, &'a mut V) {
Expand Down Expand Up @@ -1790,7 +1789,7 @@ impl<K: Debug, V: Debug> Debug for BTreeMap<K, V> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap<K, V>
impl<K: Ord, Q: ?Sized, V> Index<&Q> for BTreeMap<K, V>
where K: Borrow<Q>,
Q: Ord
{
Expand Down
Loading

0 comments on commit e70c2fb

Please sign in to comment.