Skip to content

Commit b43eb42

Browse files
committed
Auto merge of rust-lang#62355 - Centril:rollup-xnxtcgm, r=Centril
Rollup of 16 pull requests Successful merges: - rust-lang#62039 (Remove needless lifetimes (rustc)) - rust-lang#62173 (rename InterpretCx -> InterpCx) - rust-lang#62240 (wfcheck: resolve the type-vars in `AdtField` types) - rust-lang#62249 (Use mem::take instead of mem::replace with default) - rust-lang#62252 (Update mem::replace example to not be identical to mem::take) - rust-lang#62258 (syntax: Unsupport `foo! bar { ... }` macros in the parser) - rust-lang#62268 (Clean up inherent_impls) - rust-lang#62287 (Use link attributes on extern "C" blocks with llvm-libuwind) - rust-lang#62295 (miri realloc: do not require giving old size+align) - rust-lang#62297 (refactor check_for_substitution) - rust-lang#62316 (When possible without changing semantics, implement Iterator::last in terms of DoubleEndedIterator::next_back for types in liballoc and libcore.) - rust-lang#62317 (Migrate `compile-pass` annotations to `build-pass`) - rust-lang#62337 (Fix bucket in CPU usage script) - rust-lang#62344 (simplify Option::get_or_insert) - rust-lang#62346 (enable a few more tests in Miri and update the comment for others) - rust-lang#62351 (remove bogus example from drop_in_place) Failed merges: r? @ghost
2 parents 088b987 + 6363a58 commit b43eb42

File tree

919 files changed

+1638
-1664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

919 files changed

+1638
-1664
lines changed

src/etc/cpu-usage-over-time-plot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
set -ex
1818

19-
bucket=rust-lang-ci-evalazure
19+
bucket=rust-lang-ci2
2020
commit=$1
2121
builder=$2
2222

src/liballoc/boxed.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,14 @@ impl<I: Iterator + ?Sized> Iterator for Box<I> {
728728
(**self).nth(n)
729729
}
730730
}
731+
732+
#[stable(feature = "rust1", since = "1.0.0")]
733+
impl<I: Iterator + Sized> Iterator for Box<I> {
734+
fn last(self) -> Option<I::Item> where I: Sized {
735+
(*self).last()
736+
}
737+
}
738+
731739
#[stable(feature = "rust1", since = "1.0.0")]
732740
impl<I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for Box<I> {
733741
fn next_back(&mut self) -> Option<I::Item> {

src/liballoc/collections/binary_heap.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,11 @@ impl<'a, T> Iterator for Iter<'a, T> {
10351035
fn size_hint(&self) -> (usize, Option<usize>) {
10361036
self.iter.size_hint()
10371037
}
1038+
1039+
#[inline]
1040+
fn last(self) -> Option<&'a T> {
1041+
self.iter.last()
1042+
}
10381043
}
10391044

10401045
#[stable(feature = "rust1", since = "1.0.0")]

src/liballoc/collections/btree/map.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,8 @@ impl<K: Ord, V> BTreeMap<K, V> {
770770
}
771771

772772
// First, we merge `self` and `other` into a sorted sequence in linear time.
773-
let self_iter = mem::replace(self, BTreeMap::new()).into_iter();
774-
let other_iter = mem::replace(other, BTreeMap::new()).into_iter();
773+
let self_iter = mem::take(self).into_iter();
774+
let other_iter = mem::take(other).into_iter();
775775
let iter = MergeIter {
776776
left: self_iter.peekable(),
777777
right: other_iter.peekable(),
@@ -1193,6 +1193,10 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> {
11931193
fn size_hint(&self) -> (usize, Option<usize>) {
11941194
(self.length, Some(self.length))
11951195
}
1196+
1197+
fn last(mut self) -> Option<(&'a K, &'a V)> {
1198+
self.next_back()
1199+
}
11961200
}
11971201

11981202
#[stable(feature = "fused", since = "1.26.0")]
@@ -1253,6 +1257,10 @@ impl<'a, K: 'a, V: 'a> Iterator for IterMut<'a, K, V> {
12531257
fn size_hint(&self) -> (usize, Option<usize>) {
12541258
(self.length, Some(self.length))
12551259
}
1260+
1261+
fn last(mut self) -> Option<(&'a K, &'a mut V)> {
1262+
self.next_back()
1263+
}
12561264
}
12571265

12581266
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1421,6 +1429,10 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
14211429
fn size_hint(&self) -> (usize, Option<usize>) {
14221430
self.inner.size_hint()
14231431
}
1432+
1433+
fn last(mut self) -> Option<&'a K> {
1434+
self.next_back()
1435+
}
14241436
}
14251437

14261438
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1458,6 +1470,10 @@ impl<'a, K, V> Iterator for Values<'a, K, V> {
14581470
fn size_hint(&self) -> (usize, Option<usize>) {
14591471
self.inner.size_hint()
14601472
}
1473+
1474+
fn last(mut self) -> Option<&'a V> {
1475+
self.next_back()
1476+
}
14611477
}
14621478

14631479
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1495,6 +1511,10 @@ impl<'a, K, V> Iterator for Range<'a, K, V> {
14951511
unsafe { Some(self.next_unchecked()) }
14961512
}
14971513
}
1514+
1515+
fn last(mut self) -> Option<(&'a K, &'a V)> {
1516+
self.next_back()
1517+
}
14981518
}
14991519

15001520
#[stable(feature = "map_values_mut", since = "1.10.0")]
@@ -1508,6 +1528,10 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
15081528
fn size_hint(&self) -> (usize, Option<usize>) {
15091529
self.inner.size_hint()
15101530
}
1531+
1532+
fn last(mut self) -> Option<&'a mut V> {
1533+
self.next_back()
1534+
}
15111535
}
15121536

15131537
#[stable(feature = "map_values_mut", since = "1.10.0")]
@@ -1626,6 +1650,10 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
16261650
unsafe { Some(self.next_unchecked()) }
16271651
}
16281652
}
1653+
1654+
fn last(mut self) -> Option<(&'a K, &'a mut V)> {
1655+
self.next_back()
1656+
}
16291657
}
16301658

16311659
impl<'a, K, V> RangeMut<'a, K, V> {

src/liballoc/collections/btree/set.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,9 @@ impl<'a, T> Iterator for Iter<'a, T> {
10191019
fn size_hint(&self) -> (usize, Option<usize>) {
10201020
self.iter.size_hint()
10211021
}
1022+
fn last(mut self) -> Option<&'a T> {
1023+
self.next_back()
1024+
}
10221025
}
10231026
#[stable(feature = "rust1", since = "1.0.0")]
10241027
impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
@@ -1073,6 +1076,10 @@ impl<'a, T> Iterator for Range<'a, T> {
10731076
fn next(&mut self) -> Option<&'a T> {
10741077
self.iter.next().map(|(k, _)| k)
10751078
}
1079+
1080+
fn last(mut self) -> Option<&'a T> {
1081+
self.next_back()
1082+
}
10761083
}
10771084

10781085
#[stable(feature = "btree_range", since = "1.17.0")]

src/liballoc/collections/linked_list.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ impl<T> LinkedList<T> {
708708
let len = self.len();
709709
assert!(at <= len, "Cannot split off at a nonexistent index");
710710
if at == 0 {
711-
return mem::replace(self, Self::new());
711+
return mem::take(self);
712712
} else if at == len {
713713
return Self::new();
714714
}
@@ -832,6 +832,11 @@ impl<'a, T> Iterator for Iter<'a, T> {
832832
fn size_hint(&self) -> (usize, Option<usize>) {
833833
(self.len, Some(self.len))
834834
}
835+
836+
#[inline]
837+
fn last(mut self) -> Option<&'a T> {
838+
self.next_back()
839+
}
835840
}
836841

837842
#[stable(feature = "rust1", since = "1.0.0")]
@@ -881,6 +886,11 @@ impl<'a, T> Iterator for IterMut<'a, T> {
881886
fn size_hint(&self) -> (usize, Option<usize>) {
882887
(self.len, Some(self.len))
883888
}
889+
890+
#[inline]
891+
fn last(mut self) -> Option<&'a mut T> {
892+
self.next_back()
893+
}
884894
}
885895

886896
#[stable(feature = "rust1", since = "1.0.0")]

src/liballoc/collections/vec_deque.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,6 +2206,11 @@ impl<'a, T> Iterator for Iter<'a, T> {
22062206
self.tail = self.head - iter.len();
22072207
final_res
22082208
}
2209+
2210+
#[inline]
2211+
fn last(mut self) -> Option<&'a T> {
2212+
self.next_back()
2213+
}
22092214
}
22102215

22112216
#[stable(feature = "rust1", since = "1.0.0")]
@@ -2319,6 +2324,11 @@ impl<'a, T> Iterator for IterMut<'a, T> {
23192324
accum = front.iter_mut().fold(accum, &mut f);
23202325
back.iter_mut().fold(accum, &mut f)
23212326
}
2327+
2328+
#[inline]
2329+
fn last(mut self) -> Option<&'a mut T> {
2330+
self.next_back()
2331+
}
23222332
}
23232333

23242334
#[stable(feature = "rust1", since = "1.0.0")]

src/liballoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
#![feature(maybe_uninit_extra, maybe_uninit_slice, maybe_uninit_array)]
113113
#![feature(alloc_layout_extra)]
114114
#![feature(try_trait)]
115+
#![feature(mem_take)]
115116

116117
// Allow testing this library
117118

src/liballoc/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl ToOwned for str {
203203
}
204204

205205
fn clone_into(&self, target: &mut String) {
206-
let mut b = mem::replace(target, String::new()).into_bytes();
206+
let mut b = mem::take(target).into_bytes();
207207
self.as_bytes().clone_into(&mut b);
208208
*target = unsafe { String::from_utf8_unchecked(b) }
209209
}

src/liballoc/string.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,11 @@ impl Iterator for Drain<'_> {
23852385
fn size_hint(&self) -> (usize, Option<usize>) {
23862386
self.iter.size_hint()
23872387
}
2388+
2389+
#[inline]
2390+
fn last(mut self) -> Option<char> {
2391+
self.next_back()
2392+
}
23882393
}
23892394

23902395
#[stable(feature = "drain", since = "1.6.0")]

0 commit comments

Comments
 (0)