Skip to content

Commit 5b5fce6

Browse files
committed
Auto merge of rust-lang#116483 - GuillaumeGomez:rollup-z65pno1, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - rust-lang#115454 (Clarify example in docs of str::char_slice) - rust-lang#115522 (Clarify ManuallyDrop bit validity) - rust-lang#115588 (Fix a comment in std::iter::successors) - rust-lang#116198 (Add more diagnostic items for clippy) - rust-lang#116329 (update some comments around swap()) - rust-lang#116475 (rustdoc-search: fix bug with multi-item impl trait) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d0d6399 + 61a4558 commit 5b5fce6

33 files changed

+64
-15
lines changed

alloc/src/borrow.rs

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub trait ToOwned {
5555
/// ```
5656
#[stable(feature = "rust1", since = "1.0.0")]
5757
#[must_use = "cloning is often expensive and is not expected to have side effects"]
58+
#[cfg_attr(not(test), rustc_diagnostic_item = "to_owned_method")]
5859
fn to_owned(&self) -> Self::Owned;
5960

6061
/// Uses borrowed data to replace owned data, usually by cloning.

alloc/src/rc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2701,6 +2701,7 @@ impl<T, I: iter::TrustedLen<Item = T>> ToRcSlice<T> for I {
27012701
///
27022702
/// [`upgrade`]: Weak::upgrade
27032703
#[stable(feature = "rc_weak", since = "1.4.0")]
2704+
#[cfg_attr(not(test), rustc_diagnostic_item = "RcWeak")]
27042705
pub struct Weak<
27052706
T: ?Sized,
27062707
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,

alloc/src/string.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2435,6 +2435,7 @@ pub trait ToString {
24352435
/// ```
24362436
#[rustc_conversion_suggestion]
24372437
#[stable(feature = "rust1", since = "1.0.0")]
2438+
#[cfg_attr(not(test), rustc_diagnostic_item = "to_string_method")]
24382439
fn to_string(&self) -> String;
24392440
}
24402441

alloc/src/sync.rs

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
311311
///
312312
/// [`upgrade`]: Weak::upgrade
313313
#[stable(feature = "arc_weak", since = "1.4.0")]
314+
#[cfg_attr(not(test), rustc_diagnostic_item = "ArcWeak")]
314315
pub struct Weak<
315316
T: ?Sized,
316317
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,

core/src/array/iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::{
1313
/// A by-value [array] iterator.
1414
#[stable(feature = "array_value_iter", since = "1.51.0")]
1515
#[rustc_insignificant_dtor]
16+
#[rustc_diagnostic_item = "ArrayIntoIter"]
1617
pub struct IntoIter<T, const N: usize> {
1718
/// This is the array we are iterating over.
1819
///

core/src/cell.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,7 @@ impl Clone for BorrowRef<'_> {
14231423
/// See the [module-level documentation](self) for more.
14241424
#[stable(feature = "rust1", since = "1.0.0")]
14251425
#[must_not_suspend = "holding a Ref across suspend points can cause BorrowErrors"]
1426+
#[rustc_diagnostic_item = "RefCellRef"]
14261427
pub struct Ref<'b, T: ?Sized + 'b> {
14271428
// NB: we use a pointer instead of `&'b T` to avoid `noalias` violations, because a
14281429
// `Ref` argument doesn't hold immutability for its whole scope, only until it drops.
@@ -1804,6 +1805,7 @@ impl<'b> BorrowRefMut<'b> {
18041805
/// See the [module-level documentation](self) for more.
18051806
#[stable(feature = "rust1", since = "1.0.0")]
18061807
#[must_not_suspend = "holding a RefMut across suspend points can cause BorrowErrors"]
1808+
#[rustc_diagnostic_item = "RefCellRefMut"]
18071809
pub struct RefMut<'b, T: ?Sized + 'b> {
18081810
// NB: we use a pointer instead of `&'b mut T` to avoid `noalias` violations, because a
18091811
// `RefMut` argument doesn't hold exclusivity for its whole scope, only until it drops.

core/src/cmp.rs

+1
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
809809
/// ```
810810
#[must_use]
811811
#[stable(feature = "rust1", since = "1.0.0")]
812+
#[rustc_diagnostic_item = "ord_cmp_method"]
812813
fn cmp(&self, other: &Self) -> Ordering;
813814

814815
/// Compares and returns the maximum of two values.

core/src/convert/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub use num::FloatToInt;
100100
#[stable(feature = "convert_id", since = "1.33.0")]
101101
#[rustc_const_stable(feature = "const_identity", since = "1.33.0")]
102102
#[inline(always)]
103+
#[rustc_diagnostic_item = "convert_identity"]
103104
pub const fn identity<T>(x: T) -> T {
104105
x
105106
}
@@ -642,6 +643,7 @@ pub trait TryFrom<T>: Sized {
642643

643644
/// Performs the conversion.
644645
#[stable(feature = "try_from", since = "1.34.0")]
646+
#[rustc_diagnostic_item = "try_from_fn"]
645647
fn try_from(value: T) -> Result<Self, Self::Error>;
646648
}
647649

core/src/default.rs

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ pub trait Default: Sized {
130130
/// }
131131
/// ```
132132
#[stable(feature = "rust1", since = "1.0.0")]
133+
#[rustc_diagnostic_item = "default_fn"]
133134
fn default() -> Self;
134135
}
135136

core/src/fmt/builders.rs

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ impl fmt::Write for PadAdapter<'_, '_> {
8484
#[must_use = "must eventually call `finish()` on Debug builders"]
8585
#[allow(missing_debug_implementations)]
8686
#[stable(feature = "debug_builders", since = "1.2.0")]
87+
#[rustc_diagnostic_item = "DebugStruct"]
8788
pub struct DebugStruct<'a, 'b: 'a> {
8889
fmt: &'a mut fmt::Formatter<'b>,
8990
result: fmt::Result,

core/src/fmt/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ impl<W: Write + ?Sized> Write for &mut W {
239239
/// documentation of the methods defined on `Formatter` below.
240240
#[allow(missing_debug_implementations)]
241241
#[stable(feature = "rust1", since = "1.0.0")]
242+
#[rustc_diagnostic_item = "Formatter"]
242243
pub struct Formatter<'a> {
243244
flags: u32,
244245
fill: char,

core/src/intrinsics.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1509,12 +1509,14 @@ extern "rust-intrinsic" {
15091509
///
15101510
/// This intrinsic does not have a stable counterpart.
15111511
#[rustc_nounwind]
1512+
#[rustc_diagnostic_item = "intrinsics_unaligned_volatile_load"]
15121513
pub fn unaligned_volatile_load<T>(src: *const T) -> T;
15131514
/// Performs a volatile store to the `dst` pointer.
15141515
/// The pointer is not required to be aligned.
15151516
///
15161517
/// This intrinsic does not have a stable counterpart.
15171518
#[rustc_nounwind]
1519+
#[rustc_diagnostic_item = "intrinsics_unaligned_volatile_store"]
15181520
pub fn unaligned_volatile_store<T>(dst: *mut T, val: T);
15191521

15201522
/// Returns the square root of an `f32`
@@ -2666,6 +2668,7 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -
26662668
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
26672669
#[inline(always)]
26682670
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
2671+
#[rustc_diagnostic_item = "ptr_copy_nonoverlapping"]
26692672
pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
26702673
extern "rust-intrinsic" {
26712674
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
@@ -2761,6 +2764,7 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
27612764
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
27622765
#[inline(always)]
27632766
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
2767+
#[rustc_diagnostic_item = "ptr_copy"]
27642768
pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
27652769
extern "rust-intrinsic" {
27662770
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
@@ -2834,6 +2838,7 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
28342838
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
28352839
#[inline(always)]
28362840
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
2841+
#[rustc_diagnostic_item = "ptr_write_bytes"]
28372842
pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
28382843
extern "rust-intrinsic" {
28392844
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]

core/src/iter/adapters/peekable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::ops::{ControlFlow, Try};
1212
#[derive(Clone, Debug)]
1313
#[must_use = "iterators are lazy and do nothing unless consumed"]
1414
#[stable(feature = "rust1", since = "1.0.0")]
15+
#[rustc_diagnostic_item = "IterPeekable"]
1516
pub struct Peekable<I: Iterator> {
1617
iter: I,
1718
/// Remember a peeked value, even if it was None.

core/src/iter/sources/empty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub const fn empty<T>() -> Empty<T> {
2727
/// This `struct` is created by the [`empty()`] function. See its documentation for more.
2828
#[must_use = "iterators are lazy and do nothing unless consumed"]
2929
#[stable(feature = "iter_empty", since = "1.2.0")]
30+
#[rustc_diagnostic_item = "IterEmpty"]
3031
pub struct Empty<T>(marker::PhantomData<fn() -> T>);
3132

3233
#[stable(feature = "core_impl_debug", since = "1.9.0")]

core/src/iter/sources/once.rs

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ pub fn once<T>(value: T) -> Once<T> {
6161
/// This `struct` is created by the [`once()`] function. See its documentation for more.
6262
#[derive(Clone, Debug)]
6363
#[stable(feature = "iter_once", since = "1.2.0")]
64+
#[rustc_diagnostic_item = "IterOnce"]
6465
pub struct Once<T> {
6566
inner: crate::option::IntoIter<T>,
6667
}

core/src/iter/sources/successors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ where
1717
F: FnMut(&T) -> Option<T>,
1818
{
1919
// If this function returned `impl Iterator<Item=T>`
20-
// it could be based on `unfold` and not need a dedicated type.
20+
// it could be based on `from_fn` and not need a dedicated type.
2121
// However having a named `Successors<T, F>` type allows it to be `Clone` when `T` and `F` are.
2222
Successors { next: first, succ }
2323
}

core/src/iter/traits/collect.rs

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ pub trait FromIterator<A>: Sized {
146146
/// assert_eq!(v, vec![5, 5, 5, 5, 5]);
147147
/// ```
148148
#[stable(feature = "rust1", since = "1.0.0")]
149+
#[rustc_diagnostic_item = "from_iter_fn"]
149150
fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self;
150151
}
151152

core/src/mem/manually_drop.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use crate::ptr;
44
/// A wrapper to inhibit compiler from automatically calling `T`’s destructor.
55
/// This wrapper is 0-cost.
66
///
7-
/// `ManuallyDrop<T>` is guaranteed to have the same layout as `T`, and is subject
8-
/// to the same layout optimizations as `T`. As a consequence, it has *no effect*
9-
/// on the assumptions that the compiler makes about its contents. For example,
10-
/// initializing a `ManuallyDrop<&mut T>` with [`mem::zeroed`] is undefined
11-
/// behavior. If you need to handle uninitialized data, use [`MaybeUninit<T>`]
12-
/// instead.
7+
/// `ManuallyDrop<T>` is guaranteed to have the same layout and bit validity as
8+
/// `T`, and is subject to the same layout optimizations as `T`. As a consequence,
9+
/// it has *no effect* on the assumptions that the compiler makes about its
10+
/// contents. For example, initializing a `ManuallyDrop<&mut T>` with [`mem::zeroed`]
11+
/// is undefined behavior. If you need to handle uninitialized data, use
12+
/// [`MaybeUninit<T>`] instead.
1313
///
1414
/// Note that accessing the value inside a `ManuallyDrop<T>` is safe.
1515
/// This means that a `ManuallyDrop<T>` whose content has been dropped must not

core/src/mem/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -723,15 +723,12 @@ pub unsafe fn uninitialized<T>() -> T {
723723
#[inline]
724724
#[stable(feature = "rust1", since = "1.0.0")]
725725
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
726+
#[rustc_diagnostic_item = "mem_swap"]
726727
pub const fn swap<T>(x: &mut T, y: &mut T) {
727728
// NOTE(eddyb) SPIR-V's Logical addressing model doesn't allow for arbitrary
728729
// reinterpretation of values as (chunkable) byte arrays, and the loop in the
729730
// block optimization in `swap_slice` is hard to rewrite back
730731
// into the (unoptimized) direct swapping implementation, so we disable it.
731-
// FIXME(eddyb) the block optimization also prevents MIR optimizations from
732-
// understanding `mem::replace`, `Option::take`, etc. - a better overall
733-
// solution might be to make `ptr::swap_nonoverlapping` into an intrinsic, which
734-
// a backend can choose to implement using the block optimization, or not.
735732
#[cfg(not(any(target_arch = "spirv")))]
736733
{
737734
// For types that are larger multiples of their alignment, the simple way
@@ -768,11 +765,14 @@ pub(crate) const fn swap_simple<T>(x: &mut T, y: &mut T) {
768765
// And LLVM actually optimizes it to 3×memcpy if called with
769766
// a type larger than it's willing to keep in a register.
770767
// Having typed reads and writes in MIR here is also good as
771-
// it lets MIRI and CTFE understand them better, including things
768+
// it lets Miri and CTFE understand them better, including things
772769
// like enforcing type validity for them.
773770
// Importantly, read+copy_nonoverlapping+write introduces confusing
774771
// asymmetry to the behaviour where one value went through read+write
775772
// whereas the other was copied over by the intrinsic (see #94371).
773+
// Furthermore, using only read+write here benefits limited backends
774+
// such as SPIR-V that work on an underlying *typed* view of memory,
775+
// and thus have trouble with Rust's untyped memory operations.
776776

777777
// SAFETY: exclusive references are always valid to read/write,
778778
// including being aligned, and nothing here panics so it's drop-safe.

core/src/ops/deref.rs

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ impl<T: ?Sized> Deref for &mut T {
180180
pub trait DerefMut: Deref {
181181
/// Mutably dereferences the value.
182182
#[stable(feature = "rust1", since = "1.0.0")]
183+
#[rustc_diagnostic_item = "deref_mut_method"]
183184
fn deref_mut(&mut self) -> &mut Self::Target;
184185
}
185186

core/src/ops/range.rs

+1
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ impl<T: Clone> Bound<&T> {
758758
/// `RangeBounds` is implemented by Rust's built-in range types, produced
759759
/// by range syntax like `..`, `a..`, `..b`, `..=c`, `d..e`, or `f..=g`.
760760
#[stable(feature = "collections_range", since = "1.28.0")]
761+
#[rustc_diagnostic_item = "RangeBounds"]
761762
pub trait RangeBounds<T: ?Sized> {
762763
/// Start index bound.
763764
///

core/src/ptr/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ mod mut_ptr;
494494
#[stable(feature = "drop_in_place", since = "1.8.0")]
495495
#[lang = "drop_in_place"]
496496
#[allow(unconditional_recursion)]
497+
#[rustc_diagnostic_item = "ptr_drop_in_place"]
497498
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
498499
// Code here does not matter - this is replaced by the
499500
// real drop glue by the compiler.
@@ -740,6 +741,7 @@ pub const fn from_mut<T: ?Sized>(r: &mut T) -> *mut T {
740741
#[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
741742
#[rustc_const_stable(feature = "const_slice_from_raw_parts", since = "1.64.0")]
742743
#[rustc_allow_const_fn_unstable(ptr_metadata)]
744+
#[rustc_diagnostic_item = "ptr_slice_from_raw_parts"]
743745
pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
744746
from_raw_parts(data.cast(), len)
745747
}
@@ -772,6 +774,7 @@ pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
772774
#[inline]
773775
#[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
774776
#[rustc_const_unstable(feature = "const_slice_from_raw_parts_mut", issue = "67456")]
777+
#[rustc_diagnostic_item = "ptr_slice_from_raw_parts_mut"]
775778
pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
776779
from_raw_parts_mut(data.cast(), len)
777780
}
@@ -850,6 +853,7 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
850853
#[inline]
851854
#[stable(feature = "rust1", since = "1.0.0")]
852855
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
856+
#[rustc_diagnostic_item = "ptr_swap"]
853857
pub const unsafe fn swap<T>(x: *mut T, y: *mut T) {
854858
// Give ourselves some scratch space to work with.
855859
// We do not have to worry about drops: `MaybeUninit` does nothing when dropped.
@@ -911,6 +915,7 @@ pub const unsafe fn swap<T>(x: *mut T, y: *mut T) {
911915
#[inline]
912916
#[stable(feature = "swap_nonoverlapping", since = "1.27.0")]
913917
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
918+
#[rustc_diagnostic_item = "ptr_swap_nonoverlapping"]
914919
pub const unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
915920
#[allow(unused)]
916921
macro_rules! attempt_swap_as_chunks {
@@ -1022,6 +1027,7 @@ const unsafe fn swap_nonoverlapping_simple_untyped<T>(x: *mut T, y: *mut T, coun
10221027
#[inline]
10231028
#[stable(feature = "rust1", since = "1.0.0")]
10241029
#[rustc_const_unstable(feature = "const_replace", issue = "83164")]
1030+
#[rustc_diagnostic_item = "ptr_replace"]
10251031
pub const unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
10261032
// SAFETY: the caller must guarantee that `dst` is valid to be
10271033
// cast to a mutable reference (valid for writes, aligned, initialized),
@@ -1147,6 +1153,7 @@ pub const unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
11471153
#[rustc_const_stable(feature = "const_ptr_read", since = "1.71.0")]
11481154
#[rustc_allow_const_fn_unstable(const_mut_refs, const_maybe_uninit_as_mut_ptr)]
11491155
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
1156+
#[rustc_diagnostic_item = "ptr_read"]
11501157
pub const unsafe fn read<T>(src: *const T) -> T {
11511158
// It would be semantically correct to implement this via `copy_nonoverlapping`
11521159
// and `MaybeUninit`, as was done before PR #109035. Calling `assume_init`
@@ -1264,6 +1271,7 @@ pub const unsafe fn read<T>(src: *const T) -> T {
12641271
#[rustc_const_stable(feature = "const_ptr_read", since = "1.71.0")]
12651272
#[rustc_allow_const_fn_unstable(const_mut_refs, const_maybe_uninit_as_mut_ptr)]
12661273
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
1274+
#[rustc_diagnostic_item = "ptr_read_unaligned"]
12671275
pub const unsafe fn read_unaligned<T>(src: *const T) -> T {
12681276
let mut tmp = MaybeUninit::<T>::uninit();
12691277
// SAFETY: the caller must guarantee that `src` is valid for reads.
@@ -1539,6 +1547,7 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
15391547
#[inline]
15401548
#[stable(feature = "volatile", since = "1.9.0")]
15411549
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
1550+
#[rustc_diagnostic_item = "ptr_read_volatile"]
15421551
pub unsafe fn read_volatile<T>(src: *const T) -> T {
15431552
// SAFETY: the caller must uphold the safety contract for `volatile_load`.
15441553
unsafe {
@@ -1865,6 +1874,7 @@ pub(crate) const unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usiz
18651874
#[stable(feature = "ptr_eq", since = "1.17.0")]
18661875
#[inline(always)]
18671876
#[must_use = "pointer comparison produces a value"]
1877+
#[rustc_diagnostic_item = "ptr_eq"]
18681878
pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
18691879
a == b
18701880
}

core/src/ptr/non_null.rs

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ use crate::slice::{self, SliceIndex};
6868
#[repr(transparent)]
6969
#[rustc_layout_scalar_valid_range_start(1)]
7070
#[rustc_nonnull_optimization_guaranteed]
71+
#[rustc_diagnostic_item = "NonNull"]
7172
pub struct NonNull<T: ?Sized> {
7273
pointer: *const T,
7374
}

core/src/slice/iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl<'a, T> IntoIterator for &'a mut [T] {
5959
/// [slices]: slice
6060
#[stable(feature = "rust1", since = "1.0.0")]
6161
#[must_use = "iterators are lazy and do nothing unless consumed"]
62+
#[rustc_diagnostic_item = "SliceIter"]
6263
pub struct Iter<'a, T: 'a> {
6364
/// The pointer to the next element to return, or the past-the-end location
6465
/// if the iterator is empty.

core/src/slice/raw.rs

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ use crate::ptr;
9090
#[stable(feature = "rust1", since = "1.0.0")]
9191
#[rustc_const_stable(feature = "const_slice_from_raw_parts", since = "1.64.0")]
9292
#[must_use]
93+
#[rustc_diagnostic_item = "slice_from_raw_parts"]
9394
pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
9495
// SAFETY: the caller must uphold the safety contract for `from_raw_parts`.
9596
unsafe {
@@ -136,6 +137,7 @@ pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T]
136137
#[stable(feature = "rust1", since = "1.0.0")]
137138
#[rustc_const_unstable(feature = "const_slice_from_raw_parts_mut", issue = "67456")]
138139
#[must_use]
140+
#[rustc_diagnostic_item = "slice_from_raw_parts_mut"]
139141
pub const unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] {
140142
// SAFETY: the caller must uphold the safety contract for `from_raw_parts_mut`.
141143
unsafe {

core/src/str/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ impl str {
808808
/// assert_eq!(Some((0, 'y')), char_indices.next()); // not (0, 'y̆')
809809
/// assert_eq!(Some((1, '\u{0306}')), char_indices.next());
810810
///
811-
/// // note the 3 here - the last character took up two bytes
811+
/// // note the 3 here - the previous character took up two bytes
812812
/// assert_eq!(Some((3, 'e')), char_indices.next());
813813
/// assert_eq!(Some((4, 's')), char_indices.next());
814814
///

core/src/str/traits.rs

+1
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ pub trait FromStr: Sized {
624624
/// assert_eq!(5, x);
625625
/// ```
626626
#[stable(feature = "rust1", since = "1.0.0")]
627+
#[rustc_diagnostic_item = "from_str_method"]
627628
fn from_str(s: &str) -> Result<Self, Self::Err>;
628629
}
629630

core/tests/array.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ fn array_mixed_equality_nans() {
663663

664664
#[test]
665665
fn array_into_iter_fold() {
666-
// Strings to help MIRI catch if we double-free or something
666+
// Strings to help Miri catch if we double-free or something
667667
let a = ["Aa".to_string(), "Bb".to_string(), "Cc".to_string()];
668668
let mut s = "s".to_string();
669669
a.into_iter().for_each(|b| s += &b);
@@ -679,7 +679,7 @@ fn array_into_iter_fold() {
679679

680680
#[test]
681681
fn array_into_iter_rfold() {
682-
// Strings to help MIRI catch if we double-free or something
682+
// Strings to help Miri catch if we double-free or something
683683
let a = ["Aa".to_string(), "Bb".to_string(), "Cc".to_string()];
684684
let mut s = "s".to_string();
685685
a.into_iter().rev().for_each(|b| s += &b);

0 commit comments

Comments
 (0)