Skip to content

Commit 32d6b2f

Browse files
committed
Rollup merge of #58553 - scottmcm:more-ihle, r=Centril
Use more impl header lifetime elision Inspired by seeing explicit lifetimes on these two: - https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html#impl-FusedIterator - https://doc.rust-lang.org/nightly/std/primitive.u32.html#impl-Not And a follow-up to rust-lang/rust#54687, that started using IHLE in libcore. Most of the changes in here fall into two big categories: - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop`, `Debug`, and `Clone`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations [where the flipped one cannot elide the lifetime](https://internals.rust-lang.org/t/impl-type-parameter-aliases/9403/2?u=scottmcm). I also removed two lifetimes that turned out to be completely unused; see rust-lang/rust#41960 (comment)
2 parents 621aaca + a031a01 commit 32d6b2f

File tree

3 files changed

+73
-73
lines changed

3 files changed

+73
-73
lines changed

map.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ impl<K, V, S> Default for HashMap<K, V, S>
16411641
}
16421642

16431643
#[stable(feature = "rust1", since = "1.0.0")]
1644-
impl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap<K, V, S>
1644+
impl<K, Q: ?Sized, V, S> Index<&Q> for HashMap<K, V, S>
16451645
where K: Eq + Hash + Borrow<Q>,
16461646
Q: Eq + Hash,
16471647
S: BuildHasher
@@ -1673,14 +1673,14 @@ pub struct Iter<'a, K: 'a, V: 'a> {
16731673

16741674
// FIXME(#26925) Remove in favor of `#[derive(Clone)]`
16751675
#[stable(feature = "rust1", since = "1.0.0")]
1676-
impl<'a, K, V> Clone for Iter<'a, K, V> {
1677-
fn clone(&self) -> Iter<'a, K, V> {
1676+
impl<K, V> Clone for Iter<'_, K, V> {
1677+
fn clone(&self) -> Self {
16781678
Iter { inner: self.inner.clone() }
16791679
}
16801680
}
16811681

16821682
#[stable(feature = "std_debug", since = "1.16.0")]
1683-
impl<'a, K: Debug, V: Debug> fmt::Debug for Iter<'a, K, V> {
1683+
impl<K: Debug, V: Debug> fmt::Debug for Iter<'_, K, V> {
16841684
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
16851685
f.debug_list()
16861686
.entries(self.clone())
@@ -1726,14 +1726,14 @@ pub struct Keys<'a, K: 'a, V: 'a> {
17261726

17271727
// FIXME(#26925) Remove in favor of `#[derive(Clone)]`
17281728
#[stable(feature = "rust1", since = "1.0.0")]
1729-
impl<'a, K, V> Clone for Keys<'a, K, V> {
1730-
fn clone(&self) -> Keys<'a, K, V> {
1729+
impl<K, V> Clone for Keys<'_, K, V> {
1730+
fn clone(&self) -> Self {
17311731
Keys { inner: self.inner.clone() }
17321732
}
17331733
}
17341734

17351735
#[stable(feature = "std_debug", since = "1.16.0")]
1736-
impl<'a, K: Debug, V> fmt::Debug for Keys<'a, K, V> {
1736+
impl<K: Debug, V> fmt::Debug for Keys<'_, K, V> {
17371737
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
17381738
f.debug_list()
17391739
.entries(self.clone())
@@ -1755,14 +1755,14 @@ pub struct Values<'a, K: 'a, V: 'a> {
17551755

17561756
// FIXME(#26925) Remove in favor of `#[derive(Clone)]`
17571757
#[stable(feature = "rust1", since = "1.0.0")]
1758-
impl<'a, K, V> Clone for Values<'a, K, V> {
1759-
fn clone(&self) -> Values<'a, K, V> {
1758+
impl<K, V> Clone for Values<'_, K, V> {
1759+
fn clone(&self) -> Self {
17601760
Values { inner: self.inner.clone() }
17611761
}
17621762
}
17631763

17641764
#[stable(feature = "std_debug", since = "1.16.0")]
1765-
impl<'a, K, V: Debug> fmt::Debug for Values<'a, K, V> {
1765+
impl<K, V: Debug> fmt::Debug for Values<'_, K, V> {
17661766
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
17671767
f.debug_list()
17681768
.entries(self.clone())
@@ -2241,15 +2241,15 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> {
22412241
}
22422242

22432243
#[unstable(feature = "hash_raw_entry", issue = "56167")]
2244-
impl<'a, K, V, S> Debug for RawEntryBuilderMut<'a, K, V, S> {
2244+
impl<K, V, S> Debug for RawEntryBuilderMut<'_, K, V, S> {
22452245
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22462246
f.debug_struct("RawEntryBuilder")
22472247
.finish()
22482248
}
22492249
}
22502250

22512251
#[unstable(feature = "hash_raw_entry", issue = "56167")]
2252-
impl<'a, K: Debug, V: Debug, S> Debug for RawEntryMut<'a, K, V, S> {
2252+
impl<K: Debug, V: Debug, S> Debug for RawEntryMut<'_, K, V, S> {
22532253
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22542254
match *self {
22552255
RawEntryMut::Vacant(ref v) => {
@@ -2267,7 +2267,7 @@ impl<'a, K: Debug, V: Debug, S> Debug for RawEntryMut<'a, K, V, S> {
22672267
}
22682268

22692269
#[unstable(feature = "hash_raw_entry", issue = "56167")]
2270-
impl<'a, K: Debug, V: Debug> Debug for RawOccupiedEntryMut<'a, K, V> {
2270+
impl<K: Debug, V: Debug> Debug for RawOccupiedEntryMut<'_, K, V> {
22712271
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22722272
f.debug_struct("RawOccupiedEntryMut")
22732273
.field("key", self.key())
@@ -2277,15 +2277,15 @@ impl<'a, K: Debug, V: Debug> Debug for RawOccupiedEntryMut<'a, K, V> {
22772277
}
22782278

22792279
#[unstable(feature = "hash_raw_entry", issue = "56167")]
2280-
impl<'a, K, V, S> Debug for RawVacantEntryMut<'a, K, V, S> {
2280+
impl<K, V, S> Debug for RawVacantEntryMut<'_, K, V, S> {
22812281
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22822282
f.debug_struct("RawVacantEntryMut")
22832283
.finish()
22842284
}
22852285
}
22862286

22872287
#[unstable(feature = "hash_raw_entry", issue = "56167")]
2288-
impl<'a, K, V, S> Debug for RawEntryBuilder<'a, K, V, S> {
2288+
impl<K, V, S> Debug for RawEntryBuilder<'_, K, V, S> {
22892289
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22902290
f.debug_struct("RawEntryBuilder")
22912291
.finish()
@@ -2312,7 +2312,7 @@ pub enum Entry<'a, K: 'a, V: 'a> {
23122312
}
23132313

23142314
#[stable(feature= "debug_hash_map", since = "1.12.0")]
2315-
impl<'a, K: 'a + Debug, V: 'a + Debug> Debug for Entry<'a, K, V> {
2315+
impl<K: Debug, V: Debug> Debug for Entry<'_, K, V> {
23162316
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23172317
match *self {
23182318
Vacant(ref v) => {
@@ -2340,7 +2340,7 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
23402340
}
23412341

23422342
#[stable(feature= "debug_hash_map", since = "1.12.0")]
2343-
impl<'a, K: 'a + Debug, V: 'a + Debug> Debug for OccupiedEntry<'a, K, V> {
2343+
impl<K: Debug, V: Debug> Debug for OccupiedEntry<'_, K, V> {
23442344
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23452345
f.debug_struct("OccupiedEntry")
23462346
.field("key", self.key())
@@ -2361,7 +2361,7 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> {
23612361
}
23622362

23632363
#[stable(feature= "debug_hash_map", since = "1.12.0")]
2364-
impl<'a, K: 'a + Debug, V: 'a> Debug for VacantEntry<'a, K, V> {
2364+
impl<K: Debug, V> Debug for VacantEntry<'_, K, V> {
23652365
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23662366
f.debug_tuple("VacantEntry")
23672367
.field(self.key())
@@ -2448,15 +2448,15 @@ impl<'a, K, V> Iterator for Iter<'a, K, V> {
24482448
}
24492449
}
24502450
#[stable(feature = "rust1", since = "1.0.0")]
2451-
impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> {
2451+
impl<K, V> ExactSizeIterator for Iter<'_, K, V> {
24522452
#[inline]
24532453
fn len(&self) -> usize {
24542454
self.inner.len()
24552455
}
24562456
}
24572457

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

24612461
#[stable(feature = "rust1", since = "1.0.0")]
24622462
impl<'a, K, V> Iterator for IterMut<'a, K, V> {
@@ -2472,17 +2472,17 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> {
24722472
}
24732473
}
24742474
#[stable(feature = "rust1", since = "1.0.0")]
2475-
impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> {
2475+
impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
24762476
#[inline]
24772477
fn len(&self) -> usize {
24782478
self.inner.len()
24792479
}
24802480
}
24812481
#[stable(feature = "fused", since = "1.26.0")]
2482-
impl<'a, K, V> FusedIterator for IterMut<'a, K, V> {}
2482+
impl<K, V> FusedIterator for IterMut<'_, K, V> {}
24832483

24842484
#[stable(feature = "std_debug", since = "1.16.0")]
2485-
impl<'a, K, V> fmt::Debug for IterMut<'a, K, V>
2485+
impl<K, V> fmt::Debug for IterMut<'_, K, V>
24862486
where K: fmt::Debug,
24872487
V: fmt::Debug,
24882488
{
@@ -2539,14 +2539,14 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
25392539
}
25402540
}
25412541
#[stable(feature = "rust1", since = "1.0.0")]
2542-
impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {
2542+
impl<K, V> ExactSizeIterator for Keys<'_, K, V> {
25432543
#[inline]
25442544
fn len(&self) -> usize {
25452545
self.inner.len()
25462546
}
25472547
}
25482548
#[stable(feature = "fused", since = "1.26.0")]
2549-
impl<'a, K, V> FusedIterator for Keys<'a, K, V> {}
2549+
impl<K, V> FusedIterator for Keys<'_, K, V> {}
25502550

25512551
#[stable(feature = "rust1", since = "1.0.0")]
25522552
impl<'a, K, V> Iterator for Values<'a, K, V> {
@@ -2562,14 +2562,14 @@ impl<'a, K, V> Iterator for Values<'a, K, V> {
25622562
}
25632563
}
25642564
#[stable(feature = "rust1", since = "1.0.0")]
2565-
impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {
2565+
impl<K, V> ExactSizeIterator for Values<'_, K, V> {
25662566
#[inline]
25672567
fn len(&self) -> usize {
25682568
self.inner.len()
25692569
}
25702570
}
25712571
#[stable(feature = "fused", since = "1.26.0")]
2572-
impl<'a, K, V> FusedIterator for Values<'a, K, V> {}
2572+
impl<K, V> FusedIterator for Values<'_, K, V> {}
25732573

25742574
#[stable(feature = "map_values_mut", since = "1.10.0")]
25752575
impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
@@ -2585,17 +2585,17 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
25852585
}
25862586
}
25872587
#[stable(feature = "map_values_mut", since = "1.10.0")]
2588-
impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> {
2588+
impl<K, V> ExactSizeIterator for ValuesMut<'_, K, V> {
25892589
#[inline]
25902590
fn len(&self) -> usize {
25912591
self.inner.len()
25922592
}
25932593
}
25942594
#[stable(feature = "fused", since = "1.26.0")]
2595-
impl<'a, K, V> FusedIterator for ValuesMut<'a, K, V> {}
2595+
impl<K, V> FusedIterator for ValuesMut<'_, K, V> {}
25962596

25972597
#[stable(feature = "std_debug", since = "1.16.0")]
2598-
impl<'a, K, V> fmt::Debug for ValuesMut<'a, K, V>
2598+
impl<K, V> fmt::Debug for ValuesMut<'_, K, V>
25992599
where K: fmt::Debug,
26002600
V: fmt::Debug,
26012601
{
@@ -2620,17 +2620,17 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> {
26202620
}
26212621
}
26222622
#[stable(feature = "drain", since = "1.6.0")]
2623-
impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> {
2623+
impl<K, V> ExactSizeIterator for Drain<'_, K, V> {
26242624
#[inline]
26252625
fn len(&self) -> usize {
26262626
self.inner.len()
26272627
}
26282628
}
26292629
#[stable(feature = "fused", since = "1.26.0")]
2630-
impl<'a, K, V> FusedIterator for Drain<'a, K, V> {}
2630+
impl<K, V> FusedIterator for Drain<'_, K, V> {}
26312631

26322632
#[stable(feature = "std_debug", since = "1.16.0")]
2633-
impl<'a, K, V> fmt::Debug for Drain<'a, K, V>
2633+
impl<K, V> fmt::Debug for Drain<'_, K, V>
26342634
where K: fmt::Debug,
26352635
V: fmt::Debug,
26362636
{

0 commit comments

Comments
 (0)