diff options
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/borrow.rs | 4 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 6 | ||||
| -rw-r--r-- | src/liballoc/collections/binary_heap.rs | 14 | ||||
| -rw-r--r-- | src/liballoc/collections/btree/map.rs | 34 | ||||
| -rw-r--r-- | src/liballoc/collections/btree/node.rs | 20 | ||||
| -rw-r--r-- | src/liballoc/collections/btree/set.rs | 16 | ||||
| -rw-r--r-- | src/liballoc/collections/linked_list.rs | 16 | ||||
| -rw-r--r-- | src/liballoc/collections/vec_deque.rs | 16 | ||||
| -rw-r--r-- | src/liballoc/fmt.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/lib.rs | 3 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 8 | ||||
| -rw-r--r-- | src/liballoc/string.rs | 16 | ||||
| -rw-r--r-- | src/liballoc/sync.rs | 8 | ||||
| -rw-r--r-- | src/liballoc/vec.rs | 14 |
14 files changed, 90 insertions, 87 deletions
diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index 816cdbc9ce6..1fda36778f4 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -332,7 +332,7 @@ impl<B: ?Sized> fmt::Debug for Cow<'_, B> where B: fmt::Debug + ToOwned, <B as ToOwned>::Owned: fmt::Debug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Borrowed(ref b) => fmt::Debug::fmt(b, f), Owned(ref o) => fmt::Debug::fmt(o, f), @@ -345,7 +345,7 @@ impl<B: ?Sized> fmt::Display for Cow<'_, B> where B: fmt::Display + ToOwned, <B as ToOwned>::Owned: fmt::Display { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Borrowed(ref b) => fmt::Display::fmt(b, f), Owned(ref o) => fmt::Display::fmt(o, f), diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 6f6fff0a657..40b091b92c1 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -605,21 +605,21 @@ impl Box<dyn Any + Send> { #[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Display + ?Sized> fmt::Display for Box<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Debug + ?Sized> fmt::Debug for Box<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> fmt::Pointer for Box<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // It's not possible to extract the inner Uniq directly from the Box, // instead we cast it to a *const which aliases the Unique let ptr: *const T = &**self; diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index 43416e57591..5f0386400d7 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -232,7 +232,7 @@ pub struct PeekMut<'a, T: 'a + Ord> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: Ord + fmt::Debug> fmt::Debug for PeekMut<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("PeekMut") .field(&self.heap.data[0]) .finish() @@ -295,7 +295,7 @@ impl<T: Ord> Default for BinaryHeap<T> { #[stable(feature = "binaryheap_debug", since = "1.4.0")] impl<T: fmt::Debug + Ord> fmt::Debug for BinaryHeap<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.iter()).finish() } } @@ -353,7 +353,7 @@ impl<T: Ord> BinaryHeap<T> { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter<T> { + pub fn iter(&self) -> Iter<'_, T> { Iter { iter: self.data.iter() } } @@ -404,7 +404,7 @@ impl<T: Ord> BinaryHeap<T> { /// assert_eq!(heap.peek(), Some(&2)); /// ``` #[stable(feature = "binary_heap_peek_mut", since = "1.12.0")] - pub fn peek_mut(&mut self) -> Option<PeekMut<T>> { + pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T>> { if self.is_empty() { None } else { @@ -765,7 +765,7 @@ impl<T: Ord> BinaryHeap<T> { /// ``` #[inline] #[stable(feature = "drain", since = "1.6.0")] - pub fn drain(&mut self) -> Drain<T> { + pub fn drain(&mut self) -> Drain<'_, T> { Drain { iter: self.data.drain(..) } } @@ -937,7 +937,7 @@ pub struct Iter<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Iter") .field(&self.iter.as_slice()) .finish() @@ -1000,7 +1000,7 @@ pub struct IntoIter<T> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for IntoIter<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IntoIter") .field(&self.iter.as_slice()) .finish() diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index 27f162b1147..fe6b5fef210 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -249,7 +249,7 @@ impl<K, Q: ?Sized> super::Recover<Q> for BTreeMap<K, ()> fn replace(&mut self, key: K) -> Option<K> { self.ensure_root_is_owned(); - match search::search_tree::<marker::Mut, K, (), K>(self.root.as_mut(), &key) { + match search::search_tree::<marker::Mut<'_>, K, (), K>(self.root.as_mut(), &key) { Found(handle) => Some(mem::replace(handle.into_kv_mut().0, key)), GoDown(handle) => { VacantEntry { @@ -280,7 +280,7 @@ pub struct Iter<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for Iter<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -315,7 +315,7 @@ pub struct IntoIter<K, V> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for IntoIter<K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let range = Range { front: self.front.reborrow(), back: self.back.reborrow(), @@ -338,7 +338,7 @@ pub struct Keys<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<K: fmt::Debug, V> fmt::Debug for Keys<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -357,7 +357,7 @@ pub struct Values<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<K, V: fmt::Debug> fmt::Debug for Values<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -390,7 +390,7 @@ pub struct Range<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for Range<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -413,7 +413,7 @@ pub struct RangeMut<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for RangeMut<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let range = Range { front: self.front.reborrow(), back: self.back.reborrow(), @@ -443,7 +443,7 @@ pub enum Entry<'a, K: 'a, V: 'a> { #[stable(feature= "debug_btree_map", since = "1.12.0")] impl<K: Debug + Ord, V: Debug> Debug for Entry<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Vacant(ref v) => f.debug_tuple("Entry") .field(v) @@ -471,7 +471,7 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> { #[stable(feature= "debug_btree_map", since = "1.12.0")] impl<K: Debug + Ord, V> Debug for VacantEntry<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("VacantEntry") .field(self.key()) .finish() @@ -494,7 +494,7 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> { #[stable(feature= "debug_btree_map", since = "1.12.0")] impl<K: Debug + Ord, V: Debug> Debug for OccupiedEntry<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("OccupiedEntry") .field("key", self.key()) .field("value", self.get()) @@ -818,7 +818,7 @@ impl<K: Ord, V> BTreeMap<K, V> { /// assert_eq!(Some((&5, &"b")), map.range(4..).next()); /// ``` #[stable(feature = "btree_range", since = "1.17.0")] - pub fn range<T: ?Sized, R>(&self, range: R) -> Range<K, V> + pub fn range<T: ?Sized, R>(&self, range: R) -> Range<'_, K, V> where T: Ord, K: Borrow<T>, R: RangeBounds<T> { let root1 = self.root.as_ref(); @@ -859,7 +859,7 @@ impl<K: Ord, V> BTreeMap<K, V> { /// } /// ``` #[stable(feature = "btree_range", since = "1.17.0")] - pub fn range_mut<T: ?Sized, R>(&mut self, range: R) -> RangeMut<K, V> + pub fn range_mut<T: ?Sized, R>(&mut self, range: R) -> RangeMut<'_, K, V> where T: Ord, K: Borrow<T>, R: RangeBounds<T> { let root1 = self.root.as_mut(); @@ -892,7 +892,7 @@ impl<K: Ord, V> BTreeMap<K, V> { /// assert_eq!(count["a"], 3); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn entry(&mut self, key: K) -> Entry<K, V> { + pub fn entry(&mut self, key: K) -> Entry<'_, K, V> { // FIXME(@porglezomp) Avoid allocating if we don't insert self.ensure_root_is_owned(); match search::search_tree(self.root.as_mut(), &key) { @@ -1783,7 +1783,7 @@ impl<K: Ord, V: Ord> Ord for BTreeMap<K, V> { #[stable(feature = "rust1", since = "1.0.0")] impl<K: Debug, V: Debug> Debug for BTreeMap<K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_map().entries(self.iter()).finish() } } @@ -1940,7 +1940,7 @@ impl<K, V> BTreeMap<K, V> { /// assert_eq!((*first_key, *first_value), (1, "a")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter<K, V> { + pub fn iter(&self) -> Iter<'_, K, V> { Iter { range: Range { front: first_leaf_edge(self.root.as_ref()), @@ -1972,7 +1972,7 @@ impl<K, V> BTreeMap<K, V> { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter_mut(&mut self) -> IterMut<K, V> { + pub fn iter_mut(&mut self) -> IterMut<'_, K, V> { let root1 = self.root.as_mut(); let root2 = unsafe { ptr::read(&root1) }; IterMut { @@ -2049,7 +2049,7 @@ impl<K, V> BTreeMap<K, V> { /// String::from("goodbye!")]); /// ``` #[stable(feature = "map_values_mut", since = "1.10.0")] - pub fn values_mut(&mut self) -> ValuesMut<K, V> { + pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> { ValuesMut { inner: self.iter_mut() } } diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index f33a75bc45e..a5f90aa8974 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -230,7 +230,7 @@ impl<K, V> Root<K, V> { } pub fn as_ref(&self) - -> NodeRef<marker::Immut, K, V, marker::LeafOrInternal> { + -> NodeRef<marker::Immut<'_>, K, V, marker::LeafOrInternal> { NodeRef { height: self.height, node: self.node.as_ptr(), @@ -240,7 +240,7 @@ impl<K, V> Root<K, V> { } pub fn as_mut(&mut self) - -> NodeRef<marker::Mut, K, V, marker::LeafOrInternal> { + -> NodeRef<marker::Mut<'_>, K, V, marker::LeafOrInternal> { NodeRef { height: self.height, node: self.node.as_ptr(), @@ -262,7 +262,7 @@ impl<K, V> Root<K, V> { /// Adds a new internal node with a single edge, pointing to the previous root, and make that /// new node the root. This increases the height by 1 and is the opposite of `pop_level`. pub fn push_level(&mut self) - -> NodeRef<marker::Mut, K, V, marker::Internal> { + -> NodeRef<marker::Mut<'_>, K, V, marker::Internal> { debug_assert!(!self.is_shared_root()); let mut new_node = Box::new(unsafe { InternalNode::new() }); new_node.edges[0].set(unsafe { BoxedNode::from_ptr(self.node.as_ptr()) }); @@ -535,7 +535,7 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> { /// Unsafely asserts to the compiler some static information about whether this /// node is a `Leaf`. unsafe fn cast_unchecked<NewType>(&mut self) - -> NodeRef<marker::Mut, K, V, NewType> { + -> NodeRef<marker::Mut<'_>, K, V, NewType> { NodeRef { height: self.height, @@ -555,7 +555,7 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> { /// of a reborrowed handle, out of bounds. // FIXME(@gereeter) consider adding yet another type parameter to `NodeRef` that restricts // the use of `ascend` and `into_root_mut` on reborrowed pointers, preventing this unsafety. - unsafe fn reborrow_mut(&mut self) -> NodeRef<marker::Mut, K, V, Type> { + unsafe fn reborrow_mut(&mut self) -> NodeRef<marker::Mut<'_>, K, V, Type> { NodeRef { height: self.height, node: self.node, @@ -932,7 +932,7 @@ impl<BorrowType, K, V, NodeType, HandleType> /// Temporarily takes out another, immutable handle on the same location. pub fn reborrow(&self) - -> Handle<NodeRef<marker::Immut, K, V, NodeType>, HandleType> { + -> Handle<NodeRef<marker::Immut<'_>, K, V, NodeType>, HandleType> { // We can't use Handle::new_kv or Handle::new_edge because we don't know our type Handle { @@ -957,7 +957,7 @@ impl<'a, K, V, NodeType, HandleType> // FIXME(@gereeter) consider adding yet another type parameter to `NodeRef` that restricts // the use of `ascend` and `into_root_mut` on reborrowed pointers, preventing this unsafety. pub unsafe fn reborrow_mut(&mut self) - -> Handle<NodeRef<marker::Mut, K, V, NodeType>, HandleType> { + -> Handle<NodeRef<marker::Mut<'_>, K, V, NodeType>, HandleType> { // We can't use Handle::new_kv or Handle::new_edge because we don't know our type Handle { @@ -1072,7 +1072,7 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker:: /// Unsafely asserts to the compiler some static information about whether the underlying /// node of this handle is a `Leaf`. unsafe fn cast_unchecked<NewType>(&mut self) - -> Handle<NodeRef<marker::Mut, K, V, NewType>, marker::Edge> { + -> Handle<NodeRef<marker::Mut<'_>, K, V, NewType>, marker::Edge> { Handle::new_edge(self.node.cast_unchecked(), self.idx) } @@ -1562,8 +1562,8 @@ unsafe fn move_kv<K, V>( // Source and destination must have the same height. unsafe fn move_edges<K, V>( - mut source: NodeRef<marker::Mut, K, V, marker::Internal>, source_offset: usize, - mut dest: NodeRef<marker::Mut, K, V, marker::Internal>, dest_offset: usize, + mut source: NodeRef<marker::Mut<'_>, K, V, marker::Internal>, source_offset: usize, + mut dest: NodeRef<marker::Mut<'_>, K, V, marker::Internal>, dest_offset: usize, count: usize) { let source_ptr = source.as_internal_mut().edges.as_mut_ptr(); diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index 9c50bd7e918..ba3b3ed76c8 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -80,7 +80,7 @@ pub struct Iter<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Iter") .field(&self.iter.clone()) .finish() @@ -128,7 +128,7 @@ pub struct Difference<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for Difference<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Difference") .field(&self.a) .field(&self.b) @@ -151,7 +151,7 @@ pub struct SymmetricDifference<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for SymmetricDifference<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("SymmetricDifference") .field(&self.a) .field(&self.b) @@ -174,7 +174,7 @@ pub struct Intersection<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for Intersection<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Intersection") .field(&self.a) .field(&self.b) @@ -197,7 +197,7 @@ pub struct Union<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for Union<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Union") .field(&self.a) .field(&self.b) @@ -244,7 +244,7 @@ impl<T: Ord> BTreeSet<T> { /// assert_eq!(Some(&5), set.range(4..).next()); /// ``` #[stable(feature = "btree_range", since = "1.17.0")] - pub fn range<K: ?Sized, R>(&self, range: R) -> Range<T> + pub fn range<K: ?Sized, R>(&self, range: R) -> Range<'_, T> where K: Ord, T: Borrow<K>, R: RangeBounds<K> { Range { iter: self.map.range(range) } @@ -706,7 +706,7 @@ impl<T> BTreeSet<T> { /// assert_eq!(set_iter.next(), None); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter<T> { + pub fn iter(&self) -> Iter<'_, T> { Iter { iter: self.map.keys() } } @@ -905,7 +905,7 @@ impl<T: Ord + Clone> BitOr<&BTreeSet<T>> for &BTreeSet<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T: Debug> Debug for BTreeSet<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_set().entries(self.iter()).finish() } } diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index e2da0041b4a..f601fa2c8d1 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -64,7 +64,7 @@ pub struct Iter<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Iter") .field(&self.len) .finish() @@ -96,7 +96,7 @@ pub struct IterMut<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for IterMut<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IterMut") .field(&self.list) .field(&self.len) @@ -119,7 +119,7 @@ pub struct IntoIter<T> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for IntoIter<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IntoIter") .field(&self.list) .finish() @@ -333,7 +333,7 @@ impl<T> LinkedList<T> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter<T> { + pub fn iter(&self) -> Iter<'_, T> { Iter { head: self.head, tail: self.tail, @@ -367,7 +367,7 @@ impl<T> LinkedList<T> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter_mut(&mut self) -> IterMut<T> { + pub fn iter_mut(&mut self) -> IterMut<'_, T> { IterMut { head: self.head, tail: self.tail, @@ -766,7 +766,7 @@ impl<T> LinkedList<T> { /// assert_eq!(odds.into_iter().collect::<Vec<_>>(), vec![1, 3, 5, 9, 11, 13, 15]); /// ``` #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] - pub fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<T, F> + pub fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F> where F: FnMut(&mut T) -> bool { // avoid borrow issues. @@ -1023,7 +1023,7 @@ impl<T, F> Drop for DrainFilter<'_, T, F> impl<T: fmt::Debug, F> fmt::Debug for DrainFilter<'_, T, F> where F: FnMut(&mut T) -> bool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("DrainFilter") .field(&self.list) .finish() @@ -1166,7 +1166,7 @@ impl<T: Clone> Clone for LinkedList<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Debug> fmt::Debug for LinkedList<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self).finish() } } diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index abfb83d4139..f92c7ed04f4 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -801,7 +801,7 @@ impl<T> VecDeque<T> { /// assert_eq!(&c[..], b); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter<T> { + pub fn iter(&self) -> Iter<'_, T> { Iter { tail: self.tail, head: self.head, @@ -827,7 +827,7 @@ impl<T> VecDeque<T> { /// assert_eq!(&buf.iter_mut().collect::<Vec<&mut i32>>()[..], b); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter_mut(&mut self) -> IterMut<T> { + pub fn iter_mut(&mut self) -> IterMut<'_, T> { IterMut { tail: self.tail, head: self.head, @@ -961,7 +961,7 @@ impl<T> VecDeque<T> { /// ``` #[inline] #[stable(feature = "drain", since = "1.6.0")] - pub fn drain<R>(&mut self, range: R) -> Drain<T> + pub fn drain<R>(&mut self, range: R) -> Drain<'_, T> where R: RangeBounds<usize> { // Memory safety @@ -2127,7 +2127,7 @@ pub struct Iter<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail); f.debug_tuple("Iter") .field(&front) @@ -2232,7 +2232,7 @@ pub struct IterMut<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<'a, T: fmt::Debug> fmt::Debug for IterMut<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (front, back) = RingSlices::ring_slices(&*self.ring, self.head, self.tail); f.debug_tuple("IterMut") .field(&front) @@ -2323,7 +2323,7 @@ pub struct IntoIter<T> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for IntoIter<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IntoIter") .field(&self.inner) .finish() @@ -2381,7 +2381,7 @@ pub struct Drain<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for Drain<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Drain") .field(&self.after_tail) .field(&self.after_head) @@ -2657,7 +2657,7 @@ impl<'a, T: 'a + Copy> Extend<&'a T> for VecDeque<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Debug> fmt::Debug for VecDeque<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self).finish() } } diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index be35b448750..a8a99c7e7a3 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -552,7 +552,7 @@ use crate::string; /// [`format_args!`]: ../../std/macro.format_args.html /// [`format!`]: ../../std/macro.format.html #[stable(feature = "rust1", since = "1.0.0")] -pub fn format(args: Arguments) -> string::String { +pub fn format(args: Arguments<'_>) -> string::String { let capacity = args.estimated_capacity(); let mut output = string::String::with_capacity(capacity); output diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 5d69b100547..ab0ade7e554 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -63,6 +63,9 @@ #![no_std] #![needs_allocator] +#![deny(rust_2018_idioms)] +#![allow(explicit_outlives_requirements)] + #![warn(deprecated_in_future)] #![warn(intra_doc_link_resolution_failure)] #![warn(missing_debug_implementations)] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index c24e2163839..01a26b6f423 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1122,21 +1122,21 @@ impl<T: ?Sized + Hash> Hash for Rc<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + fmt::Display> fmt::Display for Rc<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + fmt::Debug> fmt::Debug for Rc<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> fmt::Pointer for Rc<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&(&**self as *const T), f) } } @@ -1460,7 +1460,7 @@ impl<T: ?Sized> Clone for Weak<T> { #[stable(feature = "rc_weak", since = "1.4.0")] impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "(Weak)") } } diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 92d3e52d60c..cb497f5bde2 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1494,7 +1494,7 @@ impl String { /// assert_eq!(s, ""); /// ``` #[stable(feature = "drain", since = "1.6.0")] - pub fn drain<R>(&mut self, range: R) -> Drain + pub fn drain<R>(&mut self, range: R) -> Drain<'_> where R: RangeBounds<usize> { // Memory safety @@ -1678,14 +1678,14 @@ impl FromUtf8Error { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for FromUtf8Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.error, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for FromUtf16Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt("invalid utf-16: lone surrogate found", f) } } @@ -1876,7 +1876,7 @@ impl Default for String { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for String { #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&**self, f) } } @@ -1884,7 +1884,7 @@ impl fmt::Display for String { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for String { #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -2106,14 +2106,14 @@ impl Clone for ParseError { #[stable(feature = "str_parse_error", since = "1.5.0")] impl fmt::Debug for ParseError { - fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { match *self {} } } #[stable(feature = "str_parse_error2", since = "1.8.0")] impl fmt::Display for ParseError { - fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { match *self {} } } @@ -2374,7 +2374,7 @@ pub struct Drain<'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Drain<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Drain { .. }") } } diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 2512e27e316..52f8879d184 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -257,7 +257,7 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Weak<U>> for Weak<T> {} #[stable(feature = "arc_weak", since = "1.4.0")] impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "(Weak)") } } @@ -1554,21 +1554,21 @@ impl<T: ?Sized + Eq> Eq for Arc<T> {} #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + fmt::Display> fmt::Display for Arc<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + fmt::Debug> fmt::Debug for Arc<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> fmt::Pointer for Arc<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&(&**self as *const T), f) } } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index b43ba6cb57c..66a73e75799 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1122,7 +1122,7 @@ impl<T> Vec<T> { /// assert_eq!(v, &[]); /// ``` #[stable(feature = "drain", since = "1.6.0")] - pub fn drain<R>(&mut self, range: R) -> Drain<T> + pub fn drain<R>(&mut self, range: R) -> Drain<'_, T> where R: RangeBounds<usize> { // Memory safety @@ -1979,7 +1979,7 @@ impl<T> Vec<T> { /// ``` #[inline] #[stable(feature = "vec_splice", since = "1.21.0")] - pub fn splice<R, I>(&mut self, range: R, replace_with: I) -> Splice<I::IntoIter> + pub fn splice<R, I>(&mut self, range: R, replace_with: I) -> Splice<'_, I::IntoIter> where R: RangeBounds<usize>, I: IntoIterator<Item=T> { Splice { @@ -2034,7 +2034,7 @@ impl<T> Vec<T> { /// assert_eq!(odds, vec![1, 3, 5, 9, 11, 13, 15]); /// ``` #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] - pub fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<T, F> + pub fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F> where F: FnMut(&mut T) -> bool, { let old_len = self.len(); @@ -2150,7 +2150,7 @@ impl<T> Default for Vec<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Debug> fmt::Debug for Vec<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -2293,7 +2293,7 @@ pub struct IntoIter<T> { #[stable(feature = "vec_intoiter_debug", since = "1.13.0")] impl<T: fmt::Debug> fmt::Debug for IntoIter<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IntoIter") .field(&self.as_slice()) .finish() @@ -2463,7 +2463,7 @@ pub struct Drain<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<'a, T: 'a + fmt::Debug> fmt::Debug for Drain<'a, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Drain") .field(&self.iter.as_slice()) .finish() @@ -2652,7 +2652,7 @@ impl<T> Drain<'_, T> { /// An iterator produced by calling `drain_filter` on Vec. #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] #[derive(Debug)] -pub struct DrainFilter<'a, T: 'a, F> +pub struct DrainFilter<'a, T, F> where F: FnMut(&mut T) -> bool, { vec: &'a mut Vec<T>, |
