Skip to content

Commit fc84f5f

Browse files
committed
Auto merge of #56581 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests Successful merges: - #56000 (Add Armv8-M Mainline targets) - #56250 (Introduce ptr::hash for references) - #56434 (Improve query cycle errors for parallel queries) - #56516 (Replace usages of `..i + 1` ranges with `..=i`.) - #56555 (Send textual profile data to stderr, not stdout) - #56561 (Fix bug in from_key_hashed_nocheck) - #56574 (Fix a stutter in the docs for slice::exact_chunks) Failed merges: r? @ghost
2 parents 15a2607 + a40aa45 commit fc84f5f

File tree

30 files changed

+225
-77
lines changed

30 files changed

+225
-77
lines changed

src/liballoc/collections/vec_deque.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,7 +2795,7 @@ mod tests {
27952795
// 0, 1, 2, .., len - 1
27962796
let expected = (0..).take(len).collect::<VecDeque<_>>();
27972797
for tail_pos in 0..cap {
2798-
for to_remove in 0..len + 1 {
2798+
for to_remove in 0..=len {
27992799
tester.tail = tail_pos;
28002800
tester.head = tail_pos;
28012801
for i in 0..len {
@@ -2821,10 +2821,10 @@ mod tests {
28212821
let mut tester: VecDeque<usize> = VecDeque::with_capacity(7);
28222822

28232823
let cap = tester.capacity();
2824-
for len in 0..cap + 1 {
2825-
for tail in 0..cap + 1 {
2826-
for drain_start in 0..len + 1 {
2827-
for drain_end in drain_start..len + 1 {
2824+
for len in 0..=cap {
2825+
for tail in 0..=cap {
2826+
for drain_start in 0..=len {
2827+
for drain_end in drain_start..=len {
28282828
tester.tail = tail;
28292829
tester.head = tail;
28302830
for i in 0..len {
@@ -2866,10 +2866,10 @@ mod tests {
28662866
tester.reserve(63);
28672867
let max_cap = tester.capacity();
28682868

2869-
for len in 0..cap + 1 {
2869+
for len in 0..=cap {
28702870
// 0, 1, 2, .., len - 1
28712871
let expected = (0..).take(len).collect::<VecDeque<_>>();
2872-
for tail_pos in 0..max_cap + 1 {
2872+
for tail_pos in 0..=max_cap {
28732873
tester.tail = tail_pos;
28742874
tester.head = tail_pos;
28752875
tester.reserve(63);
@@ -2899,7 +2899,7 @@ mod tests {
28992899
// len is the length *before* splitting
29002900
for len in 0..cap {
29012901
// index to split at
2902-
for at in 0..len + 1 {
2902+
for at in 0..=len {
29032903
// 0, 1, 2, .., at - 1 (may be empty)
29042904
let expected_self = (0..).take(at).collect::<VecDeque<_>>();
29052905
// at, at + 1, .., len - 1 (may be empty)
@@ -2927,7 +2927,7 @@ mod tests {
29272927
fn test_from_vec() {
29282928
use vec::Vec;
29292929
for cap in 0..35 {
2930-
for len in 0..cap + 1 {
2930+
for len in 0..=cap {
29312931
let mut vec = Vec::with_capacity(cap);
29322932
vec.extend(0..len);
29332933

src/liballoc/tests/binary_heap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,11 @@ fn panic_safe() {
318318
const NTEST: usize = 10;
319319

320320
// don't use 0 in the data -- we want to catch the zeroed-out case.
321-
let data = (1..DATASZ + 1).collect::<Vec<_>>();
321+
let data = (1..=DATASZ).collect::<Vec<_>>();
322322

323323
// since it's a fuzzy test, run several tries.
324324
for _ in 0..NTEST {
325-
for i in 1..DATASZ + 1 {
325+
for i in 1..=DATASZ {
326326
DROP_COUNTER.store(0, Ordering::SeqCst);
327327

328328
let mut panic_ords: Vec<_> = data.iter()

src/liballoc/tests/btree/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ fn test_range() {
302302
for i in 0..size {
303303
for j in i..size {
304304
let mut kvs = map.range((Included(&i), Included(&j))).map(|(&k, &v)| (k, v));
305-
let mut pairs = (i..j + 1).map(|i| (i, i));
305+
let mut pairs = (i..=j).map(|i| (i, i));
306306

307307
for (kv, pair) in kvs.by_ref().zip(pairs.by_ref()) {
308308
assert_eq!(kv, pair);
@@ -321,7 +321,7 @@ fn test_range_mut() {
321321
for i in 0..size {
322322
for j in i..size {
323323
let mut kvs = map.range_mut((Included(&i), Included(&j))).map(|(&k, &mut v)| (k, v));
324-
let mut pairs = (i..j + 1).map(|i| (i, i));
324+
let mut pairs = (i..=j).map(|i| (i, i));
325325

326326
for (kv, pair) in kvs.by_ref().zip(pairs.by_ref()) {
327327
assert_eq!(kv, pair);

src/liballoc/tests/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ fn test_bool_from_str() {
13781378
fn check_contains_all_substrings(s: &str) {
13791379
assert!(s.contains(""));
13801380
for i in 0..s.len() {
1381-
for j in i+1..s.len() + 1 {
1381+
for j in i+1..=s.len() {
13821382
assert!(s.contains(&s[i..j]));
13831383
}
13841384
}

src/liballoc/tests/vec_deque.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,15 +861,15 @@ fn test_as_slices() {
861861
ring.push_back(i);
862862

863863
let (left, right) = ring.as_slices();
864-
let expected: Vec<_> = (0..i + 1).collect();
864+
let expected: Vec<_> = (0..=i).collect();
865865
assert_eq!(left, &expected[..]);
866866
assert_eq!(right, []);
867867
}
868868

869869
for j in -last..0 {
870870
ring.push_front(j);
871871
let (left, right) = ring.as_slices();
872-
let expected_left: Vec<_> = (-last..j + 1).rev().collect();
872+
let expected_left: Vec<_> = (-last..=j).rev().collect();
873873
let expected_right: Vec<_> = (0..first).collect();
874874
assert_eq!(left, &expected_left[..]);
875875
assert_eq!(right, &expected_right[..]);
@@ -889,15 +889,15 @@ fn test_as_mut_slices() {
889889
ring.push_back(i);
890890

891891
let (left, right) = ring.as_mut_slices();
892-
let expected: Vec<_> = (0..i + 1).collect();
892+
let expected: Vec<_> = (0..=i).collect();
893893
assert_eq!(left, &expected[..]);
894894
assert_eq!(right, []);
895895
}
896896

897897
for j in -last..0 {
898898
ring.push_front(j);
899899
let (left, right) = ring.as_mut_slices();
900-
let expected_left: Vec<_> = (-last..j + 1).rev().collect();
900+
let expected_left: Vec<_> = (-last..=j).rev().collect();
901901
let expected_right: Vec<_> = (0..first).collect();
902902
assert_eq!(left, &expected_left[..]);
903903
assert_eq!(right, &expected_right[..]);

src/libcore/ptr.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,6 +2516,36 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
25162516
a == b
25172517
}
25182518

2519+
/// Hash the raw pointer address behind a reference, rather than the value
2520+
/// it points to.
2521+
///
2522+
/// # Examples
2523+
///
2524+
/// ```
2525+
/// #![feature(ptr_hash)]
2526+
/// use std::collections::hash_map::DefaultHasher;
2527+
/// use std::hash::{Hash, Hasher};
2528+
/// use std::ptr;
2529+
///
2530+
/// let five = 5;
2531+
/// let five_ref = &five;
2532+
///
2533+
/// let mut hasher = DefaultHasher::new();
2534+
/// ptr::hash(five_ref, &mut hasher);
2535+
/// let actual = hasher.finish();
2536+
///
2537+
/// let mut hasher = DefaultHasher::new();
2538+
/// (five_ref as *const i32).hash(&mut hasher);
2539+
/// let expected = hasher.finish();
2540+
///
2541+
/// assert_eq!(actual, expected);
2542+
/// ```
2543+
#[unstable(feature = "ptr_hash", reason = "newly added", issue = "56286")]
2544+
pub fn hash<T, S: hash::Hasher>(hashee: *const T, into: &mut S) {
2545+
use hash::Hash;
2546+
hashee.hash(into);
2547+
}
2548+
25192549
// Impls for function pointers
25202550
macro_rules! fnptr_impls_safety_abi {
25212551
($FnTy: ty, $($Arg: ident),*) => {

src/libcore/slice/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,7 @@ impl<T> [T] {
702702
/// resulting code better than in the case of [`chunks`].
703703
///
704704
/// See [`chunks`] for a variant of this iterator that also returns the remainder as a smaller
705-
/// chunk, and [`rchunks_exact`] for the same iterator but starting at the end of the slice of
706-
/// the slice.
705+
/// chunk, and [`rchunks_exact`] for the same iterator but starting at the end of the slice.
707706
///
708707
/// # Panics
709708
///

src/librustc/hir/map/hir_id_validator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
100100

101101
if max != self.hir_ids_seen.len() - 1 {
102102
// Collect the missing ItemLocalIds
103-
let missing: Vec<_> = (0 .. max as u32 + 1)
103+
let missing: Vec<_> = (0 ..= max as u32)
104104
.filter(|&i| !self.hir_ids_seen.contains_key(&ItemLocalId::from_u32(i)))
105105
.collect();
106106

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl<'tcx> Mir<'tcx> {
339339
#[inline]
340340
pub fn args_iter(&self) -> impl Iterator<Item = Local> {
341341
let arg_count = self.arg_count;
342-
(1..arg_count + 1).map(Local::new)
342+
(1..=arg_count).map(Local::new)
343343
}
344344

345345
/// Returns an iterator over all user-defined variables and compiler-generated temporaries (all

src/librustc/ty/context.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,8 +1942,12 @@ pub mod tls {
19421942
/// This is a callback from libsyntax as it cannot access the implicit state
19431943
/// in librustc otherwise
19441944
fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1945-
with(|tcx| {
1946-
write!(f, "{}", tcx.sess.source_map().span_to_string(span))
1945+
with_opt(|tcx| {
1946+
if let Some(tcx) = tcx {
1947+
write!(f, "{}", tcx.sess.source_map().span_to_string(span))
1948+
} else {
1949+
syntax_pos::default_span_debug(span, f)
1950+
}
19471951
})
19481952
}
19491953

0 commit comments

Comments
 (0)