Skip to content

Commit 857530c

Browse files
committed
liballoc: fix some idiom lints.
1 parent 95a9518 commit 857530c

File tree

14 files changed

+90
-87
lines changed

14 files changed

+90
-87
lines changed

src/liballoc/borrow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<B: ?Sized> fmt::Debug for Cow<'_, B>
332332
where B: fmt::Debug + ToOwned,
333333
<B as ToOwned>::Owned: fmt::Debug
334334
{
335-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
335+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
336336
match *self {
337337
Borrowed(ref b) => fmt::Debug::fmt(b, f),
338338
Owned(ref o) => fmt::Debug::fmt(o, f),
@@ -345,7 +345,7 @@ impl<B: ?Sized> fmt::Display for Cow<'_, B>
345345
where B: fmt::Display + ToOwned,
346346
<B as ToOwned>::Owned: fmt::Display
347347
{
348-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
348+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
349349
match *self {
350350
Borrowed(ref b) => fmt::Display::fmt(b, f),
351351
Owned(ref o) => fmt::Display::fmt(o, f),

src/liballoc/boxed.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,21 +605,21 @@ impl Box<dyn Any + Send> {
605605

606606
#[stable(feature = "rust1", since = "1.0.0")]
607607
impl<T: fmt::Display + ?Sized> fmt::Display for Box<T> {
608-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
608+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
609609
fmt::Display::fmt(&**self, f)
610610
}
611611
}
612612

613613
#[stable(feature = "rust1", since = "1.0.0")]
614614
impl<T: fmt::Debug + ?Sized> fmt::Debug for Box<T> {
615-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
615+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
616616
fmt::Debug::fmt(&**self, f)
617617
}
618618
}
619619

620620
#[stable(feature = "rust1", since = "1.0.0")]
621621
impl<T: ?Sized> fmt::Pointer for Box<T> {
622-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
622+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
623623
// It's not possible to extract the inner Uniq directly from the Box,
624624
// instead we cast it to a *const which aliases the Unique
625625
let ptr: *const T = &**self;

src/liballoc/collections/binary_heap.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub struct PeekMut<'a, T: 'a + Ord> {
232232

233233
#[stable(feature = "collection_debug", since = "1.17.0")]
234234
impl<T: Ord + fmt::Debug> fmt::Debug for PeekMut<'_, T> {
235-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
235+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
236236
f.debug_tuple("PeekMut")
237237
.field(&self.heap.data[0])
238238
.finish()
@@ -295,7 +295,7 @@ impl<T: Ord> Default for BinaryHeap<T> {
295295

296296
#[stable(feature = "binaryheap_debug", since = "1.4.0")]
297297
impl<T: fmt::Debug + Ord> fmt::Debug for BinaryHeap<T> {
298-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
298+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
299299
f.debug_list().entries(self.iter()).finish()
300300
}
301301
}
@@ -353,7 +353,7 @@ impl<T: Ord> BinaryHeap<T> {
353353
/// }
354354
/// ```
355355
#[stable(feature = "rust1", since = "1.0.0")]
356-
pub fn iter(&self) -> Iter<T> {
356+
pub fn iter(&self) -> Iter<'_, T> {
357357
Iter { iter: self.data.iter() }
358358
}
359359

@@ -404,7 +404,7 @@ impl<T: Ord> BinaryHeap<T> {
404404
/// assert_eq!(heap.peek(), Some(&2));
405405
/// ```
406406
#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
407-
pub fn peek_mut(&mut self) -> Option<PeekMut<T>> {
407+
pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T>> {
408408
if self.is_empty() {
409409
None
410410
} else {
@@ -765,7 +765,7 @@ impl<T: Ord> BinaryHeap<T> {
765765
/// ```
766766
#[inline]
767767
#[stable(feature = "drain", since = "1.6.0")]
768-
pub fn drain(&mut self) -> Drain<T> {
768+
pub fn drain(&mut self) -> Drain<'_, T> {
769769
Drain { iter: self.data.drain(..) }
770770
}
771771

@@ -937,7 +937,7 @@ pub struct Iter<'a, T: 'a> {
937937

938938
#[stable(feature = "collection_debug", since = "1.17.0")]
939939
impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
940-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
940+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
941941
f.debug_tuple("Iter")
942942
.field(&self.iter.as_slice())
943943
.finish()
@@ -1000,7 +1000,7 @@ pub struct IntoIter<T> {
10001000

10011001
#[stable(feature = "collection_debug", since = "1.17.0")]
10021002
impl<T: fmt::Debug> fmt::Debug for IntoIter<T> {
1003-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1003+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10041004
f.debug_tuple("IntoIter")
10051005
.field(&self.iter.as_slice())
10061006
.finish()

src/liballoc/collections/btree/map.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl<K, Q: ?Sized> super::Recover<Q> for BTreeMap<K, ()>
249249

250250
fn replace(&mut self, key: K) -> Option<K> {
251251
self.ensure_root_is_owned();
252-
match search::search_tree::<marker::Mut, K, (), K>(self.root.as_mut(), &key) {
252+
match search::search_tree::<marker::Mut<'_>, K, (), K>(self.root.as_mut(), &key) {
253253
Found(handle) => Some(mem::replace(handle.into_kv_mut().0, key)),
254254
GoDown(handle) => {
255255
VacantEntry {
@@ -280,7 +280,7 @@ pub struct Iter<'a, K: 'a, V: 'a> {
280280

281281
#[stable(feature = "collection_debug", since = "1.17.0")]
282282
impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for Iter<'_, K, V> {
283-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
283+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
284284
f.debug_list().entries(self.clone()).finish()
285285
}
286286
}
@@ -315,7 +315,7 @@ pub struct IntoIter<K, V> {
315315

316316
#[stable(feature = "collection_debug", since = "1.17.0")]
317317
impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for IntoIter<K, V> {
318-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
318+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
319319
let range = Range {
320320
front: self.front.reborrow(),
321321
back: self.back.reborrow(),
@@ -338,7 +338,7 @@ pub struct Keys<'a, K: 'a, V: 'a> {
338338

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

358358
#[stable(feature = "collection_debug", since = "1.17.0")]
359359
impl<K, V: fmt::Debug> fmt::Debug for Values<'_, K, V> {
360-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
360+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
361361
f.debug_list().entries(self.clone()).finish()
362362
}
363363
}
@@ -390,7 +390,7 @@ pub struct Range<'a, K: 'a, V: 'a> {
390390

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

414414
#[stable(feature = "collection_debug", since = "1.17.0")]
415415
impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for RangeMut<'_, K, V> {
416-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
416+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
417417
let range = Range {
418418
front: self.front.reborrow(),
419419
back: self.back.reborrow(),
@@ -443,7 +443,7 @@ pub enum Entry<'a, K: 'a, V: 'a> {
443443

444444
#[stable(feature= "debug_btree_map", since = "1.12.0")]
445445
impl<K: Debug + Ord, V: Debug> Debug for Entry<'_, K, V> {
446-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
446+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
447447
match *self {
448448
Vacant(ref v) => f.debug_tuple("Entry")
449449
.field(v)
@@ -471,7 +471,7 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> {
471471

472472
#[stable(feature= "debug_btree_map", since = "1.12.0")]
473473
impl<K: Debug + Ord, V> Debug for VacantEntry<'_, K, V> {
474-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
474+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
475475
f.debug_tuple("VacantEntry")
476476
.field(self.key())
477477
.finish()
@@ -494,7 +494,7 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
494494

495495
#[stable(feature= "debug_btree_map", since = "1.12.0")]
496496
impl<K: Debug + Ord, V: Debug> Debug for OccupiedEntry<'_, K, V> {
497-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
497+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
498498
f.debug_struct("OccupiedEntry")
499499
.field("key", self.key())
500500
.field("value", self.get())
@@ -818,7 +818,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
818818
/// assert_eq!(Some((&5, &"b")), map.range(4..).next());
819819
/// ```
820820
#[stable(feature = "btree_range", since = "1.17.0")]
821-
pub fn range<T: ?Sized, R>(&self, range: R) -> Range<K, V>
821+
pub fn range<T: ?Sized, R>(&self, range: R) -> Range<'_, K, V>
822822
where T: Ord, K: Borrow<T>, R: RangeBounds<T>
823823
{
824824
let root1 = self.root.as_ref();
@@ -859,7 +859,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
859859
/// }
860860
/// ```
861861
#[stable(feature = "btree_range", since = "1.17.0")]
862-
pub fn range_mut<T: ?Sized, R>(&mut self, range: R) -> RangeMut<K, V>
862+
pub fn range_mut<T: ?Sized, R>(&mut self, range: R) -> RangeMut<'_, K, V>
863863
where T: Ord, K: Borrow<T>, R: RangeBounds<T>
864864
{
865865
let root1 = self.root.as_mut();
@@ -892,7 +892,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
892892
/// assert_eq!(count["a"], 3);
893893
/// ```
894894
#[stable(feature = "rust1", since = "1.0.0")]
895-
pub fn entry(&mut self, key: K) -> Entry<K, V> {
895+
pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
896896
// FIXME(@porglezomp) Avoid allocating if we don't insert
897897
self.ensure_root_is_owned();
898898
match search::search_tree(self.root.as_mut(), &key) {
@@ -1783,7 +1783,7 @@ impl<K: Ord, V: Ord> Ord for BTreeMap<K, V> {
17831783

17841784
#[stable(feature = "rust1", since = "1.0.0")]
17851785
impl<K: Debug, V: Debug> Debug for BTreeMap<K, V> {
1786-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1786+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17871787
f.debug_map().entries(self.iter()).finish()
17881788
}
17891789
}
@@ -1940,7 +1940,7 @@ impl<K, V> BTreeMap<K, V> {
19401940
/// assert_eq!((*first_key, *first_value), (1, "a"));
19411941
/// ```
19421942
#[stable(feature = "rust1", since = "1.0.0")]
1943-
pub fn iter(&self) -> Iter<K, V> {
1943+
pub fn iter(&self) -> Iter<'_, K, V> {
19441944
Iter {
19451945
range: Range {
19461946
front: first_leaf_edge(self.root.as_ref()),
@@ -1972,7 +1972,7 @@ impl<K, V> BTreeMap<K, V> {
19721972
/// }
19731973
/// ```
19741974
#[stable(feature = "rust1", since = "1.0.0")]
1975-
pub fn iter_mut(&mut self) -> IterMut<K, V> {
1975+
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> {
19761976
let root1 = self.root.as_mut();
19771977
let root2 = unsafe { ptr::read(&root1) };
19781978
IterMut {
@@ -2049,7 +2049,7 @@ impl<K, V> BTreeMap<K, V> {
20492049
/// String::from("goodbye!")]);
20502050
/// ```
20512051
#[stable(feature = "map_values_mut", since = "1.10.0")]
2052-
pub fn values_mut(&mut self) -> ValuesMut<K, V> {
2052+
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
20532053
ValuesMut { inner: self.iter_mut() }
20542054
}
20552055

src/liballoc/collections/btree/node.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<K, V> Root<K, V> {
230230
}
231231

232232
pub fn as_ref(&self)
233-
-> NodeRef<marker::Immut, K, V, marker::LeafOrInternal> {
233+
-> NodeRef<marker::Immut<'_>, K, V, marker::LeafOrInternal> {
234234
NodeRef {
235235
height: self.height,
236236
node: self.node.as_ptr(),
@@ -240,7 +240,7 @@ impl<K, V> Root<K, V> {
240240
}
241241

242242
pub fn as_mut(&mut self)
243-
-> NodeRef<marker::Mut, K, V, marker::LeafOrInternal> {
243+
-> NodeRef<marker::Mut<'_>, K, V, marker::LeafOrInternal> {
244244
NodeRef {
245245
height: self.height,
246246
node: self.node.as_ptr(),
@@ -262,7 +262,7 @@ impl<K, V> Root<K, V> {
262262
/// Adds a new internal node with a single edge, pointing to the previous root, and make that
263263
/// new node the root. This increases the height by 1 and is the opposite of `pop_level`.
264264
pub fn push_level(&mut self)
265-
-> NodeRef<marker::Mut, K, V, marker::Internal> {
265+
-> NodeRef<marker::Mut<'_>, K, V, marker::Internal> {
266266
debug_assert!(!self.is_shared_root());
267267
let mut new_node = Box::new(unsafe { InternalNode::new() });
268268
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> {
535535
/// Unsafely asserts to the compiler some static information about whether this
536536
/// node is a `Leaf`.
537537
unsafe fn cast_unchecked<NewType>(&mut self)
538-
-> NodeRef<marker::Mut, K, V, NewType> {
538+
-> NodeRef<marker::Mut<'_>, K, V, NewType> {
539539

540540
NodeRef {
541541
height: self.height,
@@ -555,7 +555,7 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
555555
/// of a reborrowed handle, out of bounds.
556556
// FIXME(@gereeter) consider adding yet another type parameter to `NodeRef` that restricts
557557
// the use of `ascend` and `into_root_mut` on reborrowed pointers, preventing this unsafety.
558-
unsafe fn reborrow_mut(&mut self) -> NodeRef<marker::Mut, K, V, Type> {
558+
unsafe fn reborrow_mut(&mut self) -> NodeRef<marker::Mut<'_>, K, V, Type> {
559559
NodeRef {
560560
height: self.height,
561561
node: self.node,
@@ -932,7 +932,7 @@ impl<BorrowType, K, V, NodeType, HandleType>
932932

933933
/// Temporarily takes out another, immutable handle on the same location.
934934
pub fn reborrow(&self)
935-
-> Handle<NodeRef<marker::Immut, K, V, NodeType>, HandleType> {
935+
-> Handle<NodeRef<marker::Immut<'_>, K, V, NodeType>, HandleType> {
936936

937937
// We can't use Handle::new_kv or Handle::new_edge because we don't know our type
938938
Handle {
@@ -957,7 +957,7 @@ impl<'a, K, V, NodeType, HandleType>
957957
// FIXME(@gereeter) consider adding yet another type parameter to `NodeRef` that restricts
958958
// the use of `ascend` and `into_root_mut` on reborrowed pointers, preventing this unsafety.
959959
pub unsafe fn reborrow_mut(&mut self)
960-
-> Handle<NodeRef<marker::Mut, K, V, NodeType>, HandleType> {
960+
-> Handle<NodeRef<marker::Mut<'_>, K, V, NodeType>, HandleType> {
961961

962962
// We can't use Handle::new_kv or Handle::new_edge because we don't know our type
963963
Handle {
@@ -1072,7 +1072,7 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
10721072
/// Unsafely asserts to the compiler some static information about whether the underlying
10731073
/// node of this handle is a `Leaf`.
10741074
unsafe fn cast_unchecked<NewType>(&mut self)
1075-
-> Handle<NodeRef<marker::Mut, K, V, NewType>, marker::Edge> {
1075+
-> Handle<NodeRef<marker::Mut<'_>, K, V, NewType>, marker::Edge> {
10761076

10771077
Handle::new_edge(self.node.cast_unchecked(), self.idx)
10781078
}
@@ -1562,8 +1562,8 @@ unsafe fn move_kv<K, V>(
15621562

15631563
// Source and destination must have the same height.
15641564
unsafe fn move_edges<K, V>(
1565-
mut source: NodeRef<marker::Mut, K, V, marker::Internal>, source_offset: usize,
1566-
mut dest: NodeRef<marker::Mut, K, V, marker::Internal>, dest_offset: usize,
1565+
mut source: NodeRef<marker::Mut<'_>, K, V, marker::Internal>, source_offset: usize,
1566+
mut dest: NodeRef<marker::Mut<'_>, K, V, marker::Internal>, dest_offset: usize,
15671567
count: usize)
15681568
{
15691569
let source_ptr = source.as_internal_mut().edges.as_mut_ptr();

0 commit comments

Comments
 (0)