Skip to content

Commit

Permalink
Auto merge of rust-lang#91825 - matthiaskrgr:rollup-e4s8lwp, r=matthi…
Browse files Browse the repository at this point in the history
…askrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#91746 (Btree: assert more API compatibility)
 - rust-lang#91748 (rustdoc: Add regression test for Iterator as notable trait on &mut T)
 - rust-lang#91811 (bootstrap: Change unwrap() to expect() for WIX path)
 - rust-lang#91814 (doc: fix typo in comments)
 - rust-lang#91815 (better span for unexpected normalization failure in CTFE engine)
 - rust-lang#91817 (rustbot: Add autolabeling for `T-rustdoc`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Dec 12, 2021
2 parents 58457bb + 479e189 commit a0a4c7d
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 41 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_middle::ty::{
use rustc_mir_dataflow::storage::AlwaysLiveLocals;
use rustc_query_system::ich::StableHashingContext;
use rustc_session::Limit;
use rustc_span::{Pos, Span, DUMMY_SP};
use rustc_span::{Pos, Span};
use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout};

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

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {

sym::min_align_of_val | sym::size_of_val => {
// Avoid `deref_operand` -- this is not a deref, the ptr does not have to be
// dereferencable!
// dereferenceable!
let place = self.ref_to_mplace(&self.read_immediate(&args[0])?)?;
let (size, align) = self
.size_and_align_of_mplace(&place)?
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ where
self.memory.get_mut(place.ptr, size, place.align)
}

/// Check if this mplace is dereferencable and sufficiently aligned.
/// Check if this mplace is dereferenceable and sufficiently aligned.
fn check_mplace_access(
&self,
mplace: MPlaceTy<'tcx, M::PointerTag>,
Expand Down
6 changes: 3 additions & 3 deletions library/alloc/src/collections/btree/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ fn test_clone_from() {
}

#[allow(dead_code)]
fn test_variance() {
fn assert_covariance() {
fn map_key<'new>(v: BTreeMap<&'static str, ()>) -> BTreeMap<&'new str, ()> {
v
}
Expand Down Expand Up @@ -1615,7 +1615,7 @@ fn test_variance() {
}

#[allow(dead_code)]
fn test_sync() {
fn assert_sync() {
fn map<T: Sync>(v: &BTreeMap<T, T>) -> impl Sync + '_ {
v
}
Expand Down Expand Up @@ -1684,7 +1684,7 @@ fn test_sync() {
}

#[allow(dead_code)]
fn test_send() {
fn assert_send() {
fn map<T: Send>(v: BTreeMap<T, T>) -> impl Send {
v
}
Expand Down
38 changes: 35 additions & 3 deletions library/alloc/src/collections/btree/set/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use super::super::testing::rng::DeterministicRng;
use super::*;
use crate::vec::Vec;
use std::cmp::Ordering;
use std::hash::{Hash, Hasher};
use std::iter::FromIterator;
use std::panic::{catch_unwind, AssertUnwindSafe};

Expand Down Expand Up @@ -513,7 +514,7 @@ fn test_recovery() {
}

#[allow(dead_code)]
fn test_variance() {
fn assert_covariance() {
fn set<'new>(v: BTreeSet<&'static str>) -> BTreeSet<&'new str> {
v
}
Expand All @@ -530,7 +531,7 @@ fn test_variance() {
}

#[allow(dead_code)]
fn test_sync() {
fn assert_sync() {
fn set<T: Sync>(v: &BTreeSet<T>) -> impl Sync + '_ {
v
}
Expand Down Expand Up @@ -569,7 +570,7 @@ fn test_sync() {
}

#[allow(dead_code)]
fn test_send() {
fn assert_send() {
fn set<T: Send>(v: BTreeSet<T>) -> impl Send {
v
}
Expand Down Expand Up @@ -607,6 +608,37 @@ fn test_send() {
}
}

#[allow(dead_code)]
// Check that the member-like functions conditionally provided by #[derive()]
// are not overriden by genuine member functions with a different signature.
fn assert_derives() {
fn hash<T: Hash, H: Hasher>(v: BTreeSet<T>, state: &mut H) {
v.hash(state);
// Tested much more thoroughly outside the crate in btree_set_hash.rs
}
fn eq<T: PartialEq>(v: BTreeSet<T>) {
let _ = v.eq(&v);
}
fn ne<T: PartialEq>(v: BTreeSet<T>) {
let _ = v.ne(&v);
}
fn cmp<T: Ord>(v: BTreeSet<T>) {
let _ = v.cmp(&v);
}
fn min<T: Ord>(v: BTreeSet<T>, w: BTreeSet<T>) {
let _ = v.min(w);
}
fn max<T: Ord>(v: BTreeSet<T>, w: BTreeSet<T>) {
let _ = v.max(w);
}
fn clamp<T: Ord>(v: BTreeSet<T>, w: BTreeSet<T>, x: BTreeSet<T>) {
let _ = v.clamp(w, x);
}
fn partial_cmp<T: PartialOrd>(v: &BTreeSet<T>) {
let _ = v.partial_cmp(&v);
}
}

#[test]
fn test_ord_absence() {
fn set<K>(mut set: BTreeSet<K>) {
Expand Down
8 changes: 4 additions & 4 deletions library/alloc/src/collections/vec_deque/iter_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use super::{count, wrap_index, RingSlices};
/// [`iter_mut`]: super::VecDeque::iter_mut
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IterMut<'a, T: 'a> {
// Internal safety invariant: the entire slice is dereferencable.
// Internal safety invariant: the entire slice is dereferenceable.
ring: *mut [T],
tail: usize,
head: usize,
Expand Down Expand Up @@ -42,7 +42,7 @@ impl<T: fmt::Debug> fmt::Debug for IterMut<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail);
// SAFETY: these are the elements we have not handed out yet, so aliasing is fine.
// The `IterMut` invariant also ensures everything is dereferencable.
// The `IterMut` invariant also ensures everything is dereferenceable.
let (front, back) = unsafe { (&*front, &*back) };
f.debug_tuple("IterMut").field(&front).field(&back).finish()
}
Expand Down Expand Up @@ -78,7 +78,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
{
let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail);
// SAFETY: these are the elements we have not handed out yet, so aliasing is fine.
// The `IterMut` invariant also ensures everything is dereferencable.
// The `IterMut` invariant also ensures everything is dereferenceable.
let (front, back) = unsafe { (&mut *front, &mut *back) };
accum = front.iter_mut().fold(accum, &mut f);
back.iter_mut().fold(accum, &mut f)
Expand Down Expand Up @@ -132,7 +132,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
{
let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail);
// SAFETY: these are the elements we have not handed out yet, so aliasing is fine.
// The `IterMut` invariant also ensures everything is dereferencable.
// The `IterMut` invariant also ensures everything is dereferenceable.
let (front, back) = unsafe { (&mut *front, &mut *back) };
accum = back.iter_mut().rfold(accum, &mut f);
front.iter_mut().rfold(accum, &mut f)
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
#[stable(feature = "rust1", since = "1.0.0")]
pub fn iter_mut(&mut self) -> IterMut<'_, T> {
// SAFETY: The internal `IterMut` safety invariant is established because the
// `ring` we create is a dereferencable slice for lifetime '_.
// `ring` we create is a dereferenceable slice for lifetime '_.
let ring = ptr::slice_from_raw_parts_mut(self.ptr(), self.cap());

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

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

unsafe { IterMut::new(ring, tail, head, PhantomData) }
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2121,7 +2121,7 @@ impl<T: ?Sized> Weak<T> {
// a valid payload address, as the payload is at least as aligned as RcBox (usize).
ptr as *const T
} else {
// SAFETY: if is_dangling returns false, then the pointer is dereferencable.
// SAFETY: if is_dangling returns false, then the pointer is dereferenceable.
// The payload may be dropped at this point, and we have to maintain provenance,
// so use raw pointer manipulation.
unsafe { ptr::addr_of_mut!((*ptr).value) }
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ impl<T: ?Sized> Weak<T> {
// a valid payload address, as the payload is at least as aligned as ArcInner (usize).
ptr as *const T
} else {
// SAFETY: if is_dangling returns false, then the pointer is dereferencable.
// SAFETY: if is_dangling returns false, then the pointer is dereferenceable.
// The payload may be dropped at this point, and we have to maintain provenance,
// so use raw pointer manipulation.
unsafe { ptr::addr_of_mut!((*ptr).data) }
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl<T: ?Sized> *const T {
///
/// * The pointer must be properly aligned.
///
/// * It must be "dereferencable" in the sense defined in [the module documentation].
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
///
/// * The pointer must point to an initialized instance of `T`.
///
Expand Down Expand Up @@ -183,7 +183,7 @@ impl<T: ?Sized> *const T {
///
/// * The pointer must be properly aligned.
///
/// * It must be "dereferencable" in the sense defined in [the module documentation].
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
///
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
Expand Down Expand Up @@ -1003,7 +1003,7 @@ impl<T> *const [T] {
/// Returns a raw pointer to an element or subslice, without doing bounds
/// checking.
///
/// Calling this method with an out-of-bounds index or when `self` is not dereferencable
/// Calling this method with an out-of-bounds index or when `self` is not dereferenceable
/// is *[undefined behavior]* even if the resulting pointer is not used.
///
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
Expand All @@ -1025,7 +1025,7 @@ impl<T> *const [T] {
where
I: SliceIndex<[T]>,
{
// SAFETY: the caller ensures that `self` is dereferencable and `index` in-bounds.
// SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds.
unsafe { index.get_unchecked(self) }
}

Expand Down
12 changes: 6 additions & 6 deletions library/core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<T: ?Sized> *mut T {
///
/// * The pointer must be properly aligned.
///
/// * It must be "dereferencable" in the sense defined in [the module documentation].
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
///
/// * The pointer must point to an initialized instance of `T`.
///
Expand Down Expand Up @@ -189,7 +189,7 @@ impl<T: ?Sized> *mut T {
///
/// * The pointer must be properly aligned.
///
/// * It must be "dereferencable" in the sense defined in [the module documentation].
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
///
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
Expand Down Expand Up @@ -368,7 +368,7 @@ impl<T: ?Sized> *mut T {
///
/// * The pointer must be properly aligned.
///
/// * It must be "dereferencable" in the sense defined in [the module documentation].
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
///
/// * The pointer must point to an initialized instance of `T`.
///
Expand Down Expand Up @@ -434,7 +434,7 @@ impl<T: ?Sized> *mut T {
///
/// * The pointer must be properly aligned.
///
/// * It must be "dereferencable" in the sense defined in [the module documentation].
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
///
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
Expand Down Expand Up @@ -1266,7 +1266,7 @@ impl<T> *mut [T] {
/// Returns a raw pointer to an element or subslice, without doing bounds
/// checking.
///
/// Calling this method with an out-of-bounds index or when `self` is not dereferencable
/// Calling this method with an out-of-bounds index or when `self` is not dereferenceable
/// is *[undefined behavior]* even if the resulting pointer is not used.
///
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
Expand All @@ -1288,7 +1288,7 @@ impl<T> *mut [T] {
where
I: SliceIndex<[T]>,
{
// SAFETY: the caller ensures that `self` is dereferencable and `index` in-bounds.
// SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds.
unsafe { index.get_unchecked_mut(self) }
}

Expand Down
12 changes: 6 additions & 6 deletions library/core/src/ptr/non_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl<T: Sized> NonNull<T> {
///
/// * The pointer must be properly aligned.
///
/// * It must be "dereferencable" in the sense defined in [the module documentation].
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
///
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
Expand Down Expand Up @@ -142,7 +142,7 @@ impl<T: Sized> NonNull<T> {
///
/// * The pointer must be properly aligned.
///
/// * It must be "dereferencable" in the sense defined in [the module documentation].
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
///
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
Expand Down Expand Up @@ -289,7 +289,7 @@ impl<T: ?Sized> NonNull<T> {
///
/// * The pointer must be properly aligned.
///
/// * It must be "dereferencable" in the sense defined in [the module documentation].
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
///
/// * The pointer must point to an initialized instance of `T`.
///
Expand Down Expand Up @@ -338,7 +338,7 @@ impl<T: ?Sized> NonNull<T> {
///
/// * The pointer must be properly aligned.
///
/// * It must be "dereferencable" in the sense defined in [the module documentation].
/// * It must be "dereferenceable" in the sense defined in [the module documentation].
///
/// * The pointer must point to an initialized instance of `T`.
///
Expand Down Expand Up @@ -604,7 +604,7 @@ impl<T> NonNull<[T]> {
/// Returns a raw pointer to an element or subslice, without doing bounds
/// checking.
///
/// Calling this method with an out-of-bounds index or when `self` is not dereferencable
/// Calling this method with an out-of-bounds index or when `self` is not dereferenceable
/// is *[undefined behavior]* even if the resulting pointer is not used.
///
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
Expand All @@ -628,7 +628,7 @@ impl<T> NonNull<[T]> {
where
I: SliceIndex<[T]>,
{
// SAFETY: the caller ensures that `self` is dereferencable and `index` in-bounds.
// SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds.
// As a consequence, the resulting pointer cannot be null.
unsafe { NonNull::new_unchecked(self.as_ptr().get_unchecked_mut(index)) }
}
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl<T> [T] {
I: SliceIndex<Self>,
{
// SAFETY: the caller must uphold most of the safety requirements for `get_unchecked`;
// the slice is dereferencable because `self` is a safe reference.
// the slice is dereferenceable because `self` is a safe reference.
// The returned pointer is safe because impls of `SliceIndex` have to guarantee that it is.
unsafe { &*index.get_unchecked(self) }
}
Expand Down Expand Up @@ -416,7 +416,7 @@ impl<T> [T] {
I: SliceIndex<Self>,
{
// SAFETY: the caller must uphold the safety requirements for `get_unchecked_mut`;
// the slice is dereferencable because `self` is a safe reference.
// the slice is dereferenceable because `self` is a safe reference.
// The returned pointer is safe because impls of `SliceIndex` have to guarantee that it is.
unsafe { &mut *index.get_unchecked_mut(self) }
}
Expand Down
Loading

0 comments on commit a0a4c7d

Please sign in to comment.