Skip to content

Commit a0a4c7d

Browse files
committed
Auto merge of #91825 - matthiaskrgr:rollup-e4s8lwp, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #91746 (Btree: assert more API compatibility) - #91748 (rustdoc: Add regression test for Iterator as notable trait on &mut T) - #91811 (bootstrap: Change unwrap() to expect() for WIX path) - #91814 (doc: fix typo in comments) - #91815 (better span for unexpected normalization failure in CTFE engine) - #91817 (rustbot: Add autolabeling for `T-rustdoc`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 58457bb + 479e189 commit a0a4c7d

File tree

17 files changed

+121
-41
lines changed

17 files changed

+121
-41
lines changed

compiler/rustc_const_eval/src/interpret/eval_context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::ty::{
1515
use rustc_mir_dataflow::storage::AlwaysLiveLocals;
1616
use rustc_query_system::ich::StableHashingContext;
1717
use rustc_session::Limit;
18-
use rustc_span::{Pos, Span, DUMMY_SP};
18+
use rustc_span::{Pos, Span};
1919
use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout};
2020

2121
use super::{
@@ -525,7 +525,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
525525
.try_subst_mir_and_normalize_erasing_regions(*self.tcx, self.param_env, value)
526526
.or_else(|e| {
527527
self.tcx.sess.delay_span_bug(
528-
DUMMY_SP,
528+
self.cur_span(),
529529
format!("failed to normalize {}", e.get_type_for_failure()).as_str(),
530530
);
531531

compiler/rustc_const_eval/src/interpret/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
140140

141141
sym::min_align_of_val | sym::size_of_val => {
142142
// Avoid `deref_operand` -- this is not a deref, the ptr does not have to be
143-
// dereferencable!
143+
// dereferenceable!
144144
let place = self.ref_to_mplace(&self.read_immediate(&args[0])?)?;
145145
let (size, align) = self
146146
.size_and_align_of_mplace(&place)?

compiler/rustc_const_eval/src/interpret/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ where
327327
self.memory.get_mut(place.ptr, size, place.align)
328328
}
329329

330-
/// Check if this mplace is dereferencable and sufficiently aligned.
330+
/// Check if this mplace is dereferenceable and sufficiently aligned.
331331
fn check_mplace_access(
332332
&self,
333333
mplace: MPlaceTy<'tcx, M::PointerTag>,

library/alloc/src/collections/btree/map/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ fn test_clone_from() {
15561556
}
15571557

15581558
#[allow(dead_code)]
1559-
fn test_variance() {
1559+
fn assert_covariance() {
15601560
fn map_key<'new>(v: BTreeMap<&'static str, ()>) -> BTreeMap<&'new str, ()> {
15611561
v
15621562
}
@@ -1615,7 +1615,7 @@ fn test_variance() {
16151615
}
16161616

16171617
#[allow(dead_code)]
1618-
fn test_sync() {
1618+
fn assert_sync() {
16191619
fn map<T: Sync>(v: &BTreeMap<T, T>) -> impl Sync + '_ {
16201620
v
16211621
}
@@ -1684,7 +1684,7 @@ fn test_sync() {
16841684
}
16851685

16861686
#[allow(dead_code)]
1687-
fn test_send() {
1687+
fn assert_send() {
16881688
fn map<T: Send>(v: BTreeMap<T, T>) -> impl Send {
16891689
v
16901690
}

library/alloc/src/collections/btree/set/tests.rs

+35-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use super::super::testing::rng::DeterministicRng;
33
use super::*;
44
use crate::vec::Vec;
55
use std::cmp::Ordering;
6+
use std::hash::{Hash, Hasher};
67
use std::iter::FromIterator;
78
use std::panic::{catch_unwind, AssertUnwindSafe};
89

@@ -513,7 +514,7 @@ fn test_recovery() {
513514
}
514515

515516
#[allow(dead_code)]
516-
fn test_variance() {
517+
fn assert_covariance() {
517518
fn set<'new>(v: BTreeSet<&'static str>) -> BTreeSet<&'new str> {
518519
v
519520
}
@@ -530,7 +531,7 @@ fn test_variance() {
530531
}
531532

532533
#[allow(dead_code)]
533-
fn test_sync() {
534+
fn assert_sync() {
534535
fn set<T: Sync>(v: &BTreeSet<T>) -> impl Sync + '_ {
535536
v
536537
}
@@ -569,7 +570,7 @@ fn test_sync() {
569570
}
570571

571572
#[allow(dead_code)]
572-
fn test_send() {
573+
fn assert_send() {
573574
fn set<T: Send>(v: BTreeSet<T>) -> impl Send {
574575
v
575576
}
@@ -607,6 +608,37 @@ fn test_send() {
607608
}
608609
}
609610

611+
#[allow(dead_code)]
612+
// Check that the member-like functions conditionally provided by #[derive()]
613+
// are not overriden by genuine member functions with a different signature.
614+
fn assert_derives() {
615+
fn hash<T: Hash, H: Hasher>(v: BTreeSet<T>, state: &mut H) {
616+
v.hash(state);
617+
// Tested much more thoroughly outside the crate in btree_set_hash.rs
618+
}
619+
fn eq<T: PartialEq>(v: BTreeSet<T>) {
620+
let _ = v.eq(&v);
621+
}
622+
fn ne<T: PartialEq>(v: BTreeSet<T>) {
623+
let _ = v.ne(&v);
624+
}
625+
fn cmp<T: Ord>(v: BTreeSet<T>) {
626+
let _ = v.cmp(&v);
627+
}
628+
fn min<T: Ord>(v: BTreeSet<T>, w: BTreeSet<T>) {
629+
let _ = v.min(w);
630+
}
631+
fn max<T: Ord>(v: BTreeSet<T>, w: BTreeSet<T>) {
632+
let _ = v.max(w);
633+
}
634+
fn clamp<T: Ord>(v: BTreeSet<T>, w: BTreeSet<T>, x: BTreeSet<T>) {
635+
let _ = v.clamp(w, x);
636+
}
637+
fn partial_cmp<T: PartialOrd>(v: &BTreeSet<T>) {
638+
let _ = v.partial_cmp(&v);
639+
}
640+
}
641+
610642
#[test]
611643
fn test_ord_absence() {
612644
fn set<K>(mut set: BTreeSet<K>) {

library/alloc/src/collections/vec_deque/iter_mut.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use super::{count, wrap_index, RingSlices};
1212
/// [`iter_mut`]: super::VecDeque::iter_mut
1313
#[stable(feature = "rust1", since = "1.0.0")]
1414
pub struct IterMut<'a, T: 'a> {
15-
// Internal safety invariant: the entire slice is dereferencable.
15+
// Internal safety invariant: the entire slice is dereferenceable.
1616
ring: *mut [T],
1717
tail: usize,
1818
head: usize,
@@ -42,7 +42,7 @@ impl<T: fmt::Debug> fmt::Debug for IterMut<'_, T> {
4242
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4343
let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail);
4444
// SAFETY: these are the elements we have not handed out yet, so aliasing is fine.
45-
// The `IterMut` invariant also ensures everything is dereferencable.
45+
// The `IterMut` invariant also ensures everything is dereferenceable.
4646
let (front, back) = unsafe { (&*front, &*back) };
4747
f.debug_tuple("IterMut").field(&front).field(&back).finish()
4848
}
@@ -78,7 +78,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
7878
{
7979
let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail);
8080
// SAFETY: these are the elements we have not handed out yet, so aliasing is fine.
81-
// The `IterMut` invariant also ensures everything is dereferencable.
81+
// The `IterMut` invariant also ensures everything is dereferenceable.
8282
let (front, back) = unsafe { (&mut *front, &mut *back) };
8383
accum = front.iter_mut().fold(accum, &mut f);
8484
back.iter_mut().fold(accum, &mut f)
@@ -132,7 +132,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
132132
{
133133
let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail);
134134
// SAFETY: these are the elements we have not handed out yet, so aliasing is fine.
135-
// The `IterMut` invariant also ensures everything is dereferencable.
135+
// The `IterMut` invariant also ensures everything is dereferenceable.
136136
let (front, back) = unsafe { (&mut *front, &mut *back) };
137137
accum = back.iter_mut().rfold(accum, &mut f);
138138
front.iter_mut().rfold(accum, &mut f)

library/alloc/src/collections/vec_deque/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
10201020
#[stable(feature = "rust1", since = "1.0.0")]
10211021
pub fn iter_mut(&mut self) -> IterMut<'_, T> {
10221022
// SAFETY: The internal `IterMut` safety invariant is established because the
1023-
// `ring` we create is a dereferencable slice for lifetime '_.
1023+
// `ring` we create is a dereferenceable slice for lifetime '_.
10241024
let ring = ptr::slice_from_raw_parts_mut(self.ptr(), self.cap());
10251025

10261026
unsafe { IterMut::new(ring, self.tail, self.head, PhantomData) }
@@ -1209,7 +1209,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
12091209
let (tail, head) = self.range_tail_head(range);
12101210

12111211
// SAFETY: The internal `IterMut` safety invariant is established because the
1212-
// `ring` we create is a dereferencable slice for lifetime '_.
1212+
// `ring` we create is a dereferenceable slice for lifetime '_.
12131213
let ring = ptr::slice_from_raw_parts_mut(self.ptr(), self.cap());
12141214

12151215
unsafe { IterMut::new(ring, tail, head, PhantomData) }

library/alloc/src/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ impl<T: ?Sized> Weak<T> {
21212121
// a valid payload address, as the payload is at least as aligned as RcBox (usize).
21222122
ptr as *const T
21232123
} else {
2124-
// SAFETY: if is_dangling returns false, then the pointer is dereferencable.
2124+
// SAFETY: if is_dangling returns false, then the pointer is dereferenceable.
21252125
// The payload may be dropped at this point, and we have to maintain provenance,
21262126
// so use raw pointer manipulation.
21272127
unsafe { ptr::addr_of_mut!((*ptr).value) }

library/alloc/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1743,7 +1743,7 @@ impl<T: ?Sized> Weak<T> {
17431743
// a valid payload address, as the payload is at least as aligned as ArcInner (usize).
17441744
ptr as *const T
17451745
} else {
1746-
// SAFETY: if is_dangling returns false, then the pointer is dereferencable.
1746+
// SAFETY: if is_dangling returns false, then the pointer is dereferenceable.
17471747
// The payload may be dropped at this point, and we have to maintain provenance,
17481748
// so use raw pointer manipulation.
17491749
unsafe { ptr::addr_of_mut!((*ptr).data) }

library/core/src/ptr/const_ptr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl<T: ?Sized> *const T {
119119
///
120120
/// * The pointer must be properly aligned.
121121
///
122-
/// * It must be "dereferencable" in the sense defined in [the module documentation].
122+
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
123123
///
124124
/// * The pointer must point to an initialized instance of `T`.
125125
///
@@ -183,7 +183,7 @@ impl<T: ?Sized> *const T {
183183
///
184184
/// * The pointer must be properly aligned.
185185
///
186-
/// * It must be "dereferencable" in the sense defined in [the module documentation].
186+
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
187187
///
188188
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
189189
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
@@ -1003,7 +1003,7 @@ impl<T> *const [T] {
10031003
/// Returns a raw pointer to an element or subslice, without doing bounds
10041004
/// checking.
10051005
///
1006-
/// Calling this method with an out-of-bounds index or when `self` is not dereferencable
1006+
/// Calling this method with an out-of-bounds index or when `self` is not dereferenceable
10071007
/// is *[undefined behavior]* even if the resulting pointer is not used.
10081008
///
10091009
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
@@ -1025,7 +1025,7 @@ impl<T> *const [T] {
10251025
where
10261026
I: SliceIndex<[T]>,
10271027
{
1028-
// SAFETY: the caller ensures that `self` is dereferencable and `index` in-bounds.
1028+
// SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds.
10291029
unsafe { index.get_unchecked(self) }
10301030
}
10311031

library/core/src/ptr/mut_ptr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<T: ?Sized> *mut T {
122122
///
123123
/// * The pointer must be properly aligned.
124124
///
125-
/// * It must be "dereferencable" in the sense defined in [the module documentation].
125+
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
126126
///
127127
/// * The pointer must point to an initialized instance of `T`.
128128
///
@@ -189,7 +189,7 @@ impl<T: ?Sized> *mut T {
189189
///
190190
/// * The pointer must be properly aligned.
191191
///
192-
/// * It must be "dereferencable" in the sense defined in [the module documentation].
192+
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
193193
///
194194
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
195195
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
@@ -368,7 +368,7 @@ impl<T: ?Sized> *mut T {
368368
///
369369
/// * The pointer must be properly aligned.
370370
///
371-
/// * It must be "dereferencable" in the sense defined in [the module documentation].
371+
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
372372
///
373373
/// * The pointer must point to an initialized instance of `T`.
374374
///
@@ -434,7 +434,7 @@ impl<T: ?Sized> *mut T {
434434
///
435435
/// * The pointer must be properly aligned.
436436
///
437-
/// * It must be "dereferencable" in the sense defined in [the module documentation].
437+
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
438438
///
439439
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
440440
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
@@ -1266,7 +1266,7 @@ impl<T> *mut [T] {
12661266
/// Returns a raw pointer to an element or subslice, without doing bounds
12671267
/// checking.
12681268
///
1269-
/// Calling this method with an out-of-bounds index or when `self` is not dereferencable
1269+
/// Calling this method with an out-of-bounds index or when `self` is not dereferenceable
12701270
/// is *[undefined behavior]* even if the resulting pointer is not used.
12711271
///
12721272
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
@@ -1288,7 +1288,7 @@ impl<T> *mut [T] {
12881288
where
12891289
I: SliceIndex<[T]>,
12901290
{
1291-
// SAFETY: the caller ensures that `self` is dereferencable and `index` in-bounds.
1291+
// SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds.
12921292
unsafe { index.get_unchecked_mut(self) }
12931293
}
12941294

library/core/src/ptr/non_null.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<T: Sized> NonNull<T> {
109109
///
110110
/// * The pointer must be properly aligned.
111111
///
112-
/// * It must be "dereferencable" in the sense defined in [the module documentation].
112+
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
113113
///
114114
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
115115
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
@@ -142,7 +142,7 @@ impl<T: Sized> NonNull<T> {
142142
///
143143
/// * The pointer must be properly aligned.
144144
///
145-
/// * It must be "dereferencable" in the sense defined in [the module documentation].
145+
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
146146
///
147147
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
148148
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
@@ -289,7 +289,7 @@ impl<T: ?Sized> NonNull<T> {
289289
///
290290
/// * The pointer must be properly aligned.
291291
///
292-
/// * It must be "dereferencable" in the sense defined in [the module documentation].
292+
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
293293
///
294294
/// * The pointer must point to an initialized instance of `T`.
295295
///
@@ -338,7 +338,7 @@ impl<T: ?Sized> NonNull<T> {
338338
///
339339
/// * The pointer must be properly aligned.
340340
///
341-
/// * It must be "dereferencable" in the sense defined in [the module documentation].
341+
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
342342
///
343343
/// * The pointer must point to an initialized instance of `T`.
344344
///
@@ -604,7 +604,7 @@ impl<T> NonNull<[T]> {
604604
/// Returns a raw pointer to an element or subslice, without doing bounds
605605
/// checking.
606606
///
607-
/// Calling this method with an out-of-bounds index or when `self` is not dereferencable
607+
/// Calling this method with an out-of-bounds index or when `self` is not dereferenceable
608608
/// is *[undefined behavior]* even if the resulting pointer is not used.
609609
///
610610
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
@@ -628,7 +628,7 @@ impl<T> NonNull<[T]> {
628628
where
629629
I: SliceIndex<[T]>,
630630
{
631-
// SAFETY: the caller ensures that `self` is dereferencable and `index` in-bounds.
631+
// SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds.
632632
// As a consequence, the resulting pointer cannot be null.
633633
unsafe { NonNull::new_unchecked(self.as_ptr().get_unchecked_mut(index)) }
634634
}

library/core/src/slice/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ impl<T> [T] {
380380
I: SliceIndex<Self>,
381381
{
382382
// SAFETY: the caller must uphold most of the safety requirements for `get_unchecked`;
383-
// the slice is dereferencable because `self` is a safe reference.
383+
// the slice is dereferenceable because `self` is a safe reference.
384384
// The returned pointer is safe because impls of `SliceIndex` have to guarantee that it is.
385385
unsafe { &*index.get_unchecked(self) }
386386
}
@@ -416,7 +416,7 @@ impl<T> [T] {
416416
I: SliceIndex<Self>,
417417
{
418418
// SAFETY: the caller must uphold the safety requirements for `get_unchecked_mut`;
419-
// the slice is dereferencable because `self` is a safe reference.
419+
// the slice is dereferenceable because `self` is a safe reference.
420420
// The returned pointer is safe because impls of `SliceIndex` have to guarantee that it is.
421421
unsafe { &mut *index.get_unchecked_mut(self) }
422422
}

0 commit comments

Comments
 (0)