Skip to content

Commit 372be4f

Browse files
committed
Auto merge of #60834 - Centril:rollup-fikyi9i, r=Centril
Rollup of 9 pull requests Successful merges: - #60130 (Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators) - #60443 (as_ptr returns a read-only pointer) - #60444 (forego caching for all participants in cycles, apart from root node) - #60719 (Allow subdirectories to be tested by x.py test) - #60780 (fix Miri) - #60788 (default to $ARCH-apple-macosx10.7.0 LLVM triple for darwin targets) - #60799 (Allow late-bound regions in existential types) - #60808 (Improve the "must use" lint for `Future`) - #60819 (submodules: update clippy from 3710ec5 to ad3269c) Failed merges: r? @ghost
2 parents f59c71e + 2e844ef commit 372be4f

File tree

28 files changed

+379
-29
lines changed

28 files changed

+379
-29
lines changed

Diff for: src/bootstrap/test.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,19 @@ impl Step for Compiletest {
11841184
Err(_) => p,
11851185
}
11861186
})
1187-
.filter(|p| p.starts_with(suite_path) && p.is_file())
1188-
.map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap())
1187+
.filter(|p| p.starts_with(suite_path) && (p.is_dir() || p.is_file()))
1188+
.filter_map(|p| {
1189+
// Since test suite paths are themselves directories, if we don't
1190+
// specify a directory or file, we'll get an empty string here
1191+
// (the result of the test suite directory without its suite prefix).
1192+
// Therefore, we need to filter these out, as only the first --test-args
1193+
// flag is respected, so providing an empty --test-args conflicts with
1194+
// any following it.
1195+
match p.strip_prefix(suite_path).ok().and_then(|p| p.to_str()) {
1196+
Some(s) if s != "" => Some(s),
1197+
_ => None,
1198+
}
1199+
})
11891200
.collect();
11901201

11911202
test_args.append(&mut builder.config.cmd.test_args());

Diff for: src/liballoc/collections/binary_heap.rs

+15
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,11 @@ impl<'a, T> Iterator for Iter<'a, T> {
992992
fn size_hint(&self) -> (usize, Option<usize>) {
993993
self.iter.size_hint()
994994
}
995+
996+
#[inline]
997+
fn last(mut self) -> Option<&'a T> {
998+
self.next_back()
999+
}
9951000
}
9961001

9971002
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1047,6 +1052,11 @@ impl<T> Iterator for IntoIter<T> {
10471052
fn size_hint(&self) -> (usize, Option<usize>) {
10481053
self.iter.size_hint()
10491054
}
1055+
1056+
#[inline]
1057+
fn last(mut self) -> Option<T> {
1058+
self.next_back()
1059+
}
10501060
}
10511061

10521062
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1093,6 +1103,11 @@ impl<T> Iterator for Drain<'_, T> {
10931103
fn size_hint(&self) -> (usize, Option<usize>) {
10941104
self.iter.size_hint()
10951105
}
1106+
1107+
#[inline]
1108+
fn last(mut self) -> Option<T> {
1109+
self.next_back()
1110+
}
10961111
}
10971112

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

Diff for: src/liballoc/collections/btree/map.rs

+40
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,11 @@ 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+
#[inline]
1198+
fn last(mut self) -> Option<(&'a K, &'a V)> {
1199+
self.next_back()
1200+
}
11961201
}
11971202

11981203
#[stable(feature = "fused", since = "1.26.0")]
@@ -1253,6 +1258,11 @@ impl<'a, K: 'a, V: 'a> Iterator for IterMut<'a, K, V> {
12531258
fn size_hint(&self) -> (usize, Option<usize>) {
12541259
(self.length, Some(self.length))
12551260
}
1261+
1262+
#[inline]
1263+
fn last(mut self) -> Option<(&'a K, &'a mut V)> {
1264+
self.next_back()
1265+
}
12561266
}
12571267

12581268
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1359,6 +1369,11 @@ impl<K, V> Iterator for IntoIter<K, V> {
13591369
fn size_hint(&self) -> (usize, Option<usize>) {
13601370
(self.length, Some(self.length))
13611371
}
1372+
1373+
#[inline]
1374+
fn last(mut self) -> Option<(K, V)> {
1375+
self.next_back()
1376+
}
13621377
}
13631378

13641379
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1421,6 +1436,11 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
14211436
fn size_hint(&self) -> (usize, Option<usize>) {
14221437
self.inner.size_hint()
14231438
}
1439+
1440+
#[inline]
1441+
fn last(mut self) -> Option<&'a K> {
1442+
self.next_back()
1443+
}
14241444
}
14251445

14261446
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1458,6 +1478,11 @@ impl<'a, K, V> Iterator for Values<'a, K, V> {
14581478
fn size_hint(&self) -> (usize, Option<usize>) {
14591479
self.inner.size_hint()
14601480
}
1481+
1482+
#[inline]
1483+
fn last(mut self) -> Option<&'a V> {
1484+
self.next_back()
1485+
}
14611486
}
14621487

14631488
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1495,6 +1520,11 @@ impl<'a, K, V> Iterator for Range<'a, K, V> {
14951520
unsafe { Some(self.next_unchecked()) }
14961521
}
14971522
}
1523+
1524+
#[inline]
1525+
fn last(mut self) -> Option<(&'a K, &'a V)> {
1526+
self.next_back()
1527+
}
14981528
}
14991529

15001530
#[stable(feature = "map_values_mut", since = "1.10.0")]
@@ -1508,6 +1538,11 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
15081538
fn size_hint(&self) -> (usize, Option<usize>) {
15091539
self.inner.size_hint()
15101540
}
1541+
1542+
#[inline]
1543+
fn last(mut self) -> Option<&'a mut V> {
1544+
self.next_back()
1545+
}
15111546
}
15121547

15131548
#[stable(feature = "map_values_mut", since = "1.10.0")]
@@ -1626,6 +1661,11 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
16261661
unsafe { Some(self.next_unchecked()) }
16271662
}
16281663
}
1664+
1665+
#[inline]
1666+
fn last(mut self) -> Option<(&'a K, &'a mut V)> {
1667+
self.next_back()
1668+
}
16291669
}
16301670

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

Diff for: src/liballoc/collections/btree/set.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,11 @@ impl<'a, T> Iterator for Iter<'a, T> {
10191019
fn size_hint(&self) -> (usize, Option<usize>) {
10201020
self.iter.size_hint()
10211021
}
1022+
1023+
#[inline]
1024+
fn last(mut self) -> Option<&'a T> {
1025+
self.next_back()
1026+
}
10221027
}
10231028
#[stable(feature = "rust1", since = "1.0.0")]
10241029
impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
@@ -1044,6 +1049,11 @@ impl<T> Iterator for IntoIter<T> {
10441049
fn size_hint(&self) -> (usize, Option<usize>) {
10451050
self.iter.size_hint()
10461051
}
1052+
1053+
#[inline]
1054+
fn last(mut self) -> Option<T> {
1055+
self.next_back()
1056+
}
10471057
}
10481058
#[stable(feature = "rust1", since = "1.0.0")]
10491059
impl<T> DoubleEndedIterator for IntoIter<T> {
@@ -1073,6 +1083,11 @@ impl<'a, T> Iterator for Range<'a, T> {
10731083
fn next(&mut self) -> Option<&'a T> {
10741084
self.iter.next().map(|(k, _)| k)
10751085
}
1086+
1087+
#[inline]
1088+
fn last(mut self) -> Option<&'a T> {
1089+
self.next_back()
1090+
}
10761091
}
10771092

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

Diff for: src/liballoc/string.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2377,6 +2377,10 @@ impl Iterator for Drain<'_> {
23772377
fn size_hint(&self) -> (usize, Option<usize>) {
23782378
self.iter.size_hint()
23792379
}
2380+
#[inline]
2381+
fn last(mut self) -> Option<char> {
2382+
self.next_back()
2383+
}
23802384
}
23812385

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

Diff for: src/liballoc/vec.rs

+14
Original file line numberDiff line numberDiff line change
@@ -2395,6 +2395,11 @@ impl<T> Iterator for IntoIter<T> {
23952395
fn count(self) -> usize {
23962396
self.len()
23972397
}
2398+
2399+
#[inline]
2400+
fn last(mut self) -> Option<T> {
2401+
self.next_back()
2402+
}
23982403
}
23992404

24002405
#[stable(feature = "rust1", since = "1.0.0")]
@@ -2514,6 +2519,11 @@ impl<T> Iterator for Drain<'_, T> {
25142519
fn size_hint(&self) -> (usize, Option<usize>) {
25152520
self.iter.size_hint()
25162521
}
2522+
2523+
#[inline]
2524+
fn last(mut self) -> Option<T> {
2525+
self.next_back()
2526+
}
25172527
}
25182528

25192529
#[stable(feature = "drain", since = "1.6.0")]
@@ -2583,6 +2593,10 @@ impl<I: Iterator> Iterator for Splice<'_, I> {
25832593
fn size_hint(&self) -> (usize, Option<usize>) {
25842594
self.drain.size_hint()
25852595
}
2596+
2597+
fn last(mut self) -> Option<Self::Item> {
2598+
self.next_back()
2599+
}
25862600
}
25872601

25882602
#[stable(feature = "vec_splice", since = "1.21.0")]

Diff for: src/libcore/ascii.rs

+2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ impl Iterator for EscapeDefault {
117117
type Item = u8;
118118
fn next(&mut self) -> Option<u8> { self.range.next().map(|i| self.data[i]) }
119119
fn size_hint(&self) -> (usize, Option<usize>) { self.range.size_hint() }
120+
#[inline]
121+
fn last(mut self) -> Option<u8> { self.next_back() }
120122
}
121123
#[stable(feature = "rust1", since = "1.0.0")]
122124
impl DoubleEndedIterator for EscapeDefault {

Diff for: src/libcore/future/future.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::task::{Context, Poll};
2323
/// When using a future, you generally won't call `poll` directly, but instead
2424
/// `await!` the value.
2525
#[doc(spotlight)]
26-
#[must_use = "futures do nothing unless polled"]
26+
#[must_use = "futures do nothing unless you `.await` or poll them"]
2727
#[stable(feature = "futures_api", since = "1.36.0")]
2828
pub trait Future {
2929
/// The type of value produced on completion.

Diff for: src/libcore/iter/adapters/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ impl<I> Iterator for Rev<I> where I: DoubleEndedIterator {
7373
{
7474
self.iter.position(predicate)
7575
}
76+
77+
#[inline]
78+
fn last(mut self) -> Option<Self::Item> {
79+
self.next_back()
80+
}
7681
}
7782

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

Diff for: src/libcore/slice/mod.rs

+26
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ impl<T> [T] {
359359
/// The caller must ensure that the slice outlives the pointer this
360360
/// function returns, or else it will end up pointing to garbage.
361361
///
362+
/// The caller must also ensure that the memory the pointer (non-transitively) points to
363+
/// is never written to (except inside an `UnsafeCell`) using this pointer or any pointer
364+
/// derived from it. If you need to mutate the contents of the slice, use [`as_mut_ptr`].
365+
///
362366
/// Modifying the container referenced by this slice may cause its buffer
363367
/// to be reallocated, which would also make any pointers to it invalid.
364368
///
@@ -374,6 +378,8 @@ impl<T> [T] {
374378
/// }
375379
/// }
376380
/// ```
381+
///
382+
/// [`as_mut_ptr`]: #method.as_mut_ptr
377383
#[stable(feature = "rust1", since = "1.0.0")]
378384
#[inline]
379385
pub const fn as_ptr(&self) -> *const T {
@@ -3541,6 +3547,11 @@ impl<'a, T, P> Iterator for Split<'a, T, P> where P: FnMut(&T) -> bool {
35413547
(1, Some(self.v.len() + 1))
35423548
}
35433549
}
3550+
3551+
#[inline]
3552+
fn last(mut self) -> Option<Self::Item> {
3553+
self.next_back()
3554+
}
35443555
}
35453556

35463557
#[stable(feature = "rust1", since = "1.0.0")]
@@ -3639,6 +3650,11 @@ impl<'a, T, P> Iterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {
36393650
(1, Some(self.v.len() + 1))
36403651
}
36413652
}
3653+
3654+
#[inline]
3655+
fn last(mut self) -> Option<Self::Item> {
3656+
self.next_back()
3657+
}
36423658
}
36433659

36443660
#[stable(feature = "rust1", since = "1.0.0")]
@@ -3704,6 +3720,11 @@ impl<'a, T, P> Iterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
37043720
fn size_hint(&self) -> (usize, Option<usize>) {
37053721
self.inner.size_hint()
37063722
}
3723+
3724+
#[inline]
3725+
fn last(mut self) -> Option<Self::Item> {
3726+
self.next_back()
3727+
}
37073728
}
37083729

37093730
#[stable(feature = "slice_rsplit", since = "1.27.0")]
@@ -3768,6 +3789,11 @@ impl<'a, T, P> Iterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
37683789
fn size_hint(&self) -> (usize, Option<usize>) {
37693790
self.inner.size_hint()
37703791
}
3792+
3793+
#[inline]
3794+
fn last(mut self) -> Option<Self::Item> {
3795+
self.next_back()
3796+
}
37713797
}
37723798

37733799
#[stable(feature = "slice_rsplit", since = "1.27.0")]

Diff for: src/libcore/str/mod.rs

+24
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,11 @@ impl<'a> Iterator for Lines<'a> {
13331333
fn size_hint(&self) -> (usize, Option<usize>) {
13341334
self.0.size_hint()
13351335
}
1336+
1337+
#[inline]
1338+
fn last(mut self) -> Option<Self::Item> {
1339+
self.next_back()
1340+
}
13361341
}
13371342

13381343
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1379,6 +1384,11 @@ impl<'a> Iterator for LinesAny<'a> {
13791384
fn size_hint(&self) -> (usize, Option<usize>) {
13801385
self.0.size_hint()
13811386
}
1387+
1388+
#[inline]
1389+
fn last(mut self) -> Option<Self::Item> {
1390+
self.next_back()
1391+
}
13821392
}
13831393

13841394
#[stable(feature = "rust1", since = "1.0.0")]
@@ -2188,7 +2198,11 @@ impl str {
21882198
/// [`u8`]. This pointer will be pointing to the first byte of the string
21892199
/// slice.
21902200
///
2201+
/// The caller must ensure that the returned pointer is never written to.
2202+
/// If you need to mutate the contents of the string slice, use [`as_mut_ptr`].
2203+
///
21912204
/// [`u8`]: primitive.u8.html
2205+
/// [`as_mut_ptr`]: #method.as_mut_ptr
21922206
///
21932207
/// # Examples
21942208
///
@@ -4217,6 +4231,11 @@ impl<'a> Iterator for SplitWhitespace<'a> {
42174231
fn size_hint(&self) -> (usize, Option<usize>) {
42184232
self.inner.size_hint()
42194233
}
4234+
4235+
#[inline]
4236+
fn last(mut self) -> Option<Self::Item> {
4237+
self.next_back()
4238+
}
42204239
}
42214240

42224241
#[stable(feature = "split_whitespace", since = "1.1.0")]
@@ -4243,6 +4262,11 @@ impl<'a> Iterator for SplitAsciiWhitespace<'a> {
42434262
fn size_hint(&self) -> (usize, Option<usize>) {
42444263
self.inner.size_hint()
42454264
}
4265+
4266+
#[inline]
4267+
fn last(mut self) -> Option<Self::Item> {
4268+
self.next_back()
4269+
}
42464270
}
42474271

42484272
#[stable(feature = "split_ascii_whitespace", since = "1.34.0")]

0 commit comments

Comments
 (0)