diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index d46950ed90315..a7c08f225b004 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -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::{ @@ -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(), ); diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 18dde3bc34ef1..d6f856a6f0a70 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -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)? diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 4c95da896a223..e526bfa2b52c7 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -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>, diff --git a/library/alloc/src/collections/btree/map/tests.rs b/library/alloc/src/collections/btree/map/tests.rs index 17389657afb92..c95aeeaa60558 100644 --- a/library/alloc/src/collections/btree/map/tests.rs +++ b/library/alloc/src/collections/btree/map/tests.rs @@ -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 } @@ -1615,7 +1615,7 @@ fn test_variance() { } #[allow(dead_code)] -fn test_sync() { +fn assert_sync() { fn map(v: &BTreeMap) -> impl Sync + '_ { v } @@ -1684,7 +1684,7 @@ fn test_sync() { } #[allow(dead_code)] -fn test_send() { +fn assert_send() { fn map(v: BTreeMap) -> impl Send { v } diff --git a/library/alloc/src/collections/btree/set/tests.rs b/library/alloc/src/collections/btree/set/tests.rs index 2fc17a7c8603f..7390ff5a59c8c 100644 --- a/library/alloc/src/collections/btree/set/tests.rs +++ b/library/alloc/src/collections/btree/set/tests.rs @@ -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}; @@ -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 } @@ -530,7 +531,7 @@ fn test_variance() { } #[allow(dead_code)] -fn test_sync() { +fn assert_sync() { fn set(v: &BTreeSet) -> impl Sync + '_ { v } @@ -569,7 +570,7 @@ fn test_sync() { } #[allow(dead_code)] -fn test_send() { +fn assert_send() { fn set(v: BTreeSet) -> impl Send { v } @@ -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(v: BTreeSet, state: &mut H) { + v.hash(state); + // Tested much more thoroughly outside the crate in btree_set_hash.rs + } + fn eq(v: BTreeSet) { + let _ = v.eq(&v); + } + fn ne(v: BTreeSet) { + let _ = v.ne(&v); + } + fn cmp(v: BTreeSet) { + let _ = v.cmp(&v); + } + fn min(v: BTreeSet, w: BTreeSet) { + let _ = v.min(w); + } + fn max(v: BTreeSet, w: BTreeSet) { + let _ = v.max(w); + } + fn clamp(v: BTreeSet, w: BTreeSet, x: BTreeSet) { + let _ = v.clamp(w, x); + } + fn partial_cmp(v: &BTreeSet) { + let _ = v.partial_cmp(&v); + } +} + #[test] fn test_ord_absence() { fn set(mut set: BTreeSet) { diff --git a/library/alloc/src/collections/vec_deque/iter_mut.rs b/library/alloc/src/collections/vec_deque/iter_mut.rs index 31e6e3b06af5f..ee2df0d516012 100644 --- a/library/alloc/src/collections/vec_deque/iter_mut.rs +++ b/library/alloc/src/collections/vec_deque/iter_mut.rs @@ -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, @@ -42,7 +42,7 @@ impl 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() } @@ -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) @@ -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) diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 702d97858eb45..075becfb7d11a 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -1020,7 +1020,7 @@ impl VecDeque { #[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) } @@ -1209,7 +1209,7 @@ impl VecDeque { 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) } diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index c4e5e44fec0b2..33bee4324fd38 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -2121,7 +2121,7 @@ impl Weak { // 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) } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 733a898b285ac..7c065f37d1fa8 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1743,7 +1743,7 @@ impl Weak { // 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) } diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 3c716672113e5..332be06dd1617 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -119,7 +119,7 @@ impl *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`. /// @@ -183,7 +183,7 @@ impl *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. @@ -1003,7 +1003,7 @@ impl *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 @@ -1025,7 +1025,7 @@ impl *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) } } diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 5d4e37641ee84..15ef64bc73f82 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -122,7 +122,7 @@ impl *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`. /// @@ -189,7 +189,7 @@ impl *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. @@ -368,7 +368,7 @@ impl *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`. /// @@ -434,7 +434,7 @@ impl *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. @@ -1266,7 +1266,7 @@ impl *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 @@ -1288,7 +1288,7 @@ impl *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) } } diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 58110b0680943..4f4e7eca28180 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -109,7 +109,7 @@ impl NonNull { /// /// * 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. @@ -142,7 +142,7 @@ impl NonNull { /// /// * 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. @@ -289,7 +289,7 @@ impl NonNull { /// /// * 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`. /// @@ -338,7 +338,7 @@ impl NonNull { /// /// * 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`. /// @@ -604,7 +604,7 @@ impl 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 @@ -628,7 +628,7 @@ impl 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)) } } diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index f9ea99ea8aa5c..7d5d70f17207c 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -380,7 +380,7 @@ impl [T] { I: SliceIndex, { // 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) } } @@ -416,7 +416,7 @@ impl [T] { I: SliceIndex, { // 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) } } diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index cd5ed35be79ba..1d4600fa4a2d7 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -416,7 +416,7 @@ impl str { #[inline] pub unsafe fn get_unchecked>(&self, i: I) -> &I::Output { // SAFETY: the caller must uphold the safety contract 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 { &*i.get_unchecked(self) } } @@ -451,7 +451,7 @@ impl str { #[inline] pub unsafe fn get_unchecked_mut>(&mut self, i: I) -> &mut I::Output { // SAFETY: the caller must uphold the safety contract 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 *i.get_unchecked_mut(self) } } @@ -504,7 +504,7 @@ impl str { #[inline] pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str { // SAFETY: the caller must uphold the safety contract 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 { &*(begin..end).get_unchecked(self) } } @@ -537,7 +537,7 @@ impl str { #[inline] pub unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str { // SAFETY: the caller must uphold the safety contract 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 *(begin..end).get_unchecked_mut(self) } } diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 5f28ffeda8fee..dd179df394889 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1564,7 +1564,9 @@ impl Step for Extended { builder.install(&etc.join("gfx/rust-logo.ico"), &exe, 0o644); // Generate msi installer - let wix = PathBuf::from(env::var_os("WIX").unwrap()); + let wix_path = env::var_os("WIX") + .expect("`WIX` environment variable must be set for generating MSI installer(s)."); + let wix = PathBuf::from(wix_path); let heat = wix.join("bin/heat.exe"); let candle = wix.join("bin/candle.exe"); let light = wix.join("bin/light.exe"); diff --git a/src/test/rustdoc/doc-notable_trait-mut_t_is_not_an_iterator.rs b/src/test/rustdoc/doc-notable_trait-mut_t_is_not_an_iterator.rs new file mode 100644 index 0000000000000..bfce46cf4444a --- /dev/null +++ b/src/test/rustdoc/doc-notable_trait-mut_t_is_not_an_iterator.rs @@ -0,0 +1,23 @@ +//! Test case for [#80737]. +//! +//! A SomeTrait that is implemented for `&mut T where T: SomeTrait` +//! should not be marked as "notable" for return values that do not +//! have bounds on the trait itself. +//! +//! [#80737]: https://github.com/rust-lang/rust/issues/80737 + +#![feature(rustdoc_internals)] +#![no_std] + +#[doc(primitive = "reference")] +/// Some useless docs, wouhou! +/// +/// We need to put this in here, because notable traits +/// that are implemented on foreign types don't show up. +mod reference {} + +// @has doc_notable_trait_mut_t_is_not_an_iterator/fn.fn_no_matches.html +// @!has - '//code[@class="content"]' 'Iterator' +pub fn fn_no_matches<'a, T: 'a>() -> &'a mut T { + panic!() +} diff --git a/triagebot.toml b/triagebot.toml index 7a9908fe8c075..fb9cee43b2dfb 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -91,6 +91,29 @@ exclude_labels = [ "requires-nightly", ] +[autolabel."T-rustdoc"] +trigger_files = [ + # Source code + "src/librustdoc", + "src/tools/rustdoc", + "src/rustdoc-json-types", + + # Tests + "src/test/rustdoc", + "src/test/rustdoc-ui", + "src/test/rustdoc-gui", + "src/test/rustdoc-js", + "src/test/rustdoc-js-std", + "src/test/rustdoc-json", + + # Internal tooling + "src/etc/htmldocck.py", + "src/tools/jsondocck", + "src/tools/rustdoc-gui", + "src/tools/rustdoc-js", + "src/tools/rustdoc-themes", +] + [notify-zulip."I-prioritize"] zulip_stream = 245100 # #t-compiler/wg-prioritization/alerts topic = "#{number} {title}"