Skip to content

Commit e0eb63a

Browse files
authored
Rollup merge of rust-lang#106860 - anden3:doc-double-spaces, r=Dylan-DPC
Remove various double spaces in the libraries. I was just pretty bothered by this when reading the source for a function, and was suggested to check if this happened elsewhere.
2 parents bc0c816 + 2fea03f commit e0eb63a

File tree

35 files changed

+71
-71
lines changed

35 files changed

+71
-71
lines changed

library/alloc/src/alloc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use core::marker::Destruct;
2020
mod tests;
2121

2222
extern "Rust" {
23-
// These are the magic symbols to call the global allocator. rustc generates
23+
// These are the magic symbols to call the global allocator. rustc generates
2424
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
2525
// (the code expanding that attribute macro generates those functions), or to call
2626
// the default implementations in std (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
@@ -353,7 +353,7 @@ pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Dest
353353

354354
#[cfg(not(no_global_oom_handling))]
355355
extern "Rust" {
356-
// This is the magic symbol to call the global alloc error handler. rustc generates
356+
// This is the magic symbol to call the global alloc error handler. rustc generates
357357
// it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the
358358
// default implementations below (`__rdl_oom`) otherwise.
359359
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;

library/alloc/src/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,7 @@ pub struct Weak<T: ?Sized> {
21792179
// This is a `NonNull` to allow optimizing the size of this type in enums,
21802180
// but it is not necessarily a valid pointer.
21812181
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
2182-
// to allocate space on the heap. That's not a value a real pointer
2182+
// to allocate space on the heap. That's not a value a real pointer
21832183
// will ever have because RcBox has alignment at least 2.
21842184
// This is only possible when `T: Sized`; unsized `T` never dangle.
21852185
ptr: NonNull<RcBox<T>>,

library/alloc/src/sync.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ pub struct Weak<T: ?Sized> {
295295
// This is a `NonNull` to allow optimizing the size of this type in enums,
296296
// but it is not necessarily a valid pointer.
297297
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
298-
// to allocate space on the heap. That's not a value a real pointer
298+
// to allocate space on the heap. That's not a value a real pointer
299299
// will ever have because RcBox has alignment at least 2.
300300
// This is only possible when `T: Sized`; unsized `T` never dangle.
301301
ptr: NonNull<ArcInner<T>>,
@@ -1656,7 +1656,7 @@ impl<T: ?Sized> Arc<T> {
16561656
//
16571657
// The acquire label here ensures a happens-before relationship with any
16581658
// writes to `strong` (in particular in `Weak::upgrade`) prior to decrements
1659-
// of the `weak` count (via `Weak::drop`, which uses release). If the upgraded
1659+
// of the `weak` count (via `Weak::drop`, which uses release). If the upgraded
16601660
// weak ref was never dropped, the CAS here will fail so we do not care to synchronize.
16611661
if self.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() {
16621662
// This needs to be an `Acquire` to synchronize with the decrement of the `strong`
@@ -1712,7 +1712,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc<T> {
17121712
}
17131713

17141714
// This fence is needed to prevent reordering of use of the data and
1715-
// deletion of the data. Because it is marked `Release`, the decreasing
1715+
// deletion of the data. Because it is marked `Release`, the decreasing
17161716
// of the reference count synchronizes with this `Acquire` fence. This
17171717
// means that use of the data happens before decreasing the reference
17181718
// count, which happens before this fence, which happens before the
@@ -2172,7 +2172,7 @@ impl<T: ?Sized> Clone for Weak<T> {
21722172
} else {
21732173
return Weak { ptr: self.ptr };
21742174
};
2175-
// See comments in Arc::clone() for why this is relaxed. This can use a
2175+
// See comments in Arc::clone() for why this is relaxed. This can use a
21762176
// fetch_add (ignoring the lock) because the weak count is only locked
21772177
// where are *no other* weak pointers in existence. (So we can't be
21782178
// running this code in that case).

library/alloc/src/vec/into_iter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct IntoIter<
4040
// to avoid dropping the allocator twice we need to wrap it into ManuallyDrop
4141
pub(super) alloc: ManuallyDrop<A>,
4242
pub(super) ptr: *const T,
43-
pub(super) end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that
43+
pub(super) end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that
4444
// ptr == end is a quick test for the Iterator being empty, that works
4545
// for both ZST and non-ZST.
4646
}
@@ -146,9 +146,9 @@ impl<T, A: Allocator> IntoIter<T, A> {
146146
let mut this = ManuallyDrop::new(self);
147147

148148
// SAFETY: This allocation originally came from a `Vec`, so it passes
149-
// all those checks. We have `this.buf` ≤ `this.ptr` ≤ `this.end`,
149+
// all those checks. We have `this.buf` ≤ `this.ptr` ≤ `this.end`,
150150
// so the `sub_ptr`s below cannot wrap, and will produce a well-formed
151-
// range. `end` ≤ `buf + cap`, so the range will be in-bounds.
151+
// range. `end` ≤ `buf + cap`, so the range will be in-bounds.
152152
// Taking `alloc` is ok because nothing else is going to look at it,
153153
// since our `Drop` impl isn't going to run so there's no more code.
154154
unsafe {

library/alloc/src/vec/is_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ unsafe impl<T: IsZero, const N: usize> IsZero for [T; N] {
5757
#[inline]
5858
fn is_zero(&self) -> bool {
5959
// Because this is generated as a runtime check, it's not obvious that
60-
// it's worth doing if the array is really long. The threshold here
60+
// it's worth doing if the array is really long. The threshold here
6161
// is largely arbitrary, but was picked because as of 2022-07-01 LLVM
6262
// fails to const-fold the check in `vec![[1; 32]; n]`
6363
// See https://github.com/rust-lang/rust/pull/97581#issuecomment-1166628022

library/alloc/src/vec/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,7 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
24292429
self.reserve(range.len());
24302430

24312431
// SAFETY:
2432-
// - `slice::range` guarantees that the given range is valid for indexing self
2432+
// - `slice::range` guarantees that the given range is valid for indexing self
24332433
unsafe {
24342434
self.spec_extend_from_within(range);
24352435
}
@@ -2686,7 +2686,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for Vec<T, A> {
26862686

26872687
// HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is
26882688
// required for this method definition, is not available. Instead use the
2689-
// `slice::to_vec` function which is only available with cfg(test)
2689+
// `slice::to_vec` function which is only available with cfg(test)
26902690
// NB see the slice::hack module in slice.rs for more information
26912691
#[cfg(test)]
26922692
fn clone(&self) -> Self {

library/alloc/tests/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ fn test_stable_pointers() {
18491849
}
18501850

18511851
// Test that, if we reserved enough space, adding and removing elements does not
1852-
// invalidate references into the vector (such as `v0`). This test also
1852+
// invalidate references into the vector (such as `v0`). This test also
18531853
// runs in Miri, which would detect such problems.
18541854
// Note that this test does *not* constitute a stable guarantee that all these functions do not
18551855
// reallocate! Only what is explicitly documented at

library/core/src/array/iter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ impl<T, const N: usize> IntoIter<T, N> {
109109
/// use std::array::IntoIter;
110110
/// use std::mem::MaybeUninit;
111111
///
112-
/// # // Hi! Thanks for reading the code. This is restricted to `Copy` because
113-
/// # // otherwise it could leak. A fully-general version this would need a drop
112+
/// # // Hi! Thanks for reading the code. This is restricted to `Copy` because
113+
/// # // otherwise it could leak. A fully-general version this would need a drop
114114
/// # // guard to handle panics from the iterator, but this works for an example.
115115
/// fn next_chunk<T: Copy, const N: usize>(
116116
/// it: &mut impl Iterator<Item = T>,
@@ -211,7 +211,7 @@ impl<T, const N: usize> IntoIter<T, N> {
211211
let initialized = 0..0;
212212

213213
// SAFETY: We're telling it that none of the elements are initialized,
214-
// which is trivially true. And ∀N: usize, 0 <= N.
214+
// which is trivially true. And ∀N: usize, 0 <= N.
215215
unsafe { Self::new_unchecked(buffer, initialized) }
216216
}
217217

library/core/src/iter/range.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ impl<A: Step> Iterator for ops::Range<A> {
756756
where
757757
Self: TrustedRandomAccessNoCoerce,
758758
{
759-
// SAFETY: The TrustedRandomAccess contract requires that callers only pass an index
759+
// SAFETY: The TrustedRandomAccess contract requires that callers only pass an index
760760
// that is in bounds.
761761
// Additionally Self: TrustedRandomAccess is only implemented for Copy types
762762
// which means even repeated reads of the same index would be safe.

library/core/src/num/dec2flt/fpu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod fpu_precision {
2626
/// Developer's Manual (Volume 1).
2727
///
2828
/// The only field which is relevant for the following code is PC, Precision Control. This
29-
/// field determines the precision of the operations performed by the FPU. It can be set to:
29+
/// field determines the precision of the operations performed by the FPU. It can be set to:
3030
/// - 0b00, single precision i.e., 32-bits
3131
/// - 0b10, double precision i.e., 64-bits
3232
/// - 0b11, double extended precision i.e., 80-bits (default state)

library/core/src/num/int_macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ macro_rules! int_impl {
15381538
///
15391539
/// ```
15401540
/// #![feature(bigint_helper_methods)]
1541-
/// // Only the most significant word is signed.
1541+
/// // Only the most significant word is signed.
15421542
/// //
15431543
#[doc = concat!("// 10 MAX (a = 10 × 2^", stringify!($BITS), " + 2^", stringify!($BITS), " - 1)")]
15441544
#[doc = concat!("// + -5 9 (b = -5 × 2^", stringify!($BITS), " + 9)")]
@@ -1646,7 +1646,7 @@ macro_rules! int_impl {
16461646
///
16471647
/// ```
16481648
/// #![feature(bigint_helper_methods)]
1649-
/// // Only the most significant word is signed.
1649+
/// // Only the most significant word is signed.
16501650
/// //
16511651
#[doc = concat!("// 6 8 (a = 6 × 2^", stringify!($BITS), " + 8)")]
16521652
#[doc = concat!("// - -5 9 (b = -5 × 2^", stringify!($BITS), " + 9)")]

library/core/src/pin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ impl<P: DerefMut> Pin<P> {
753753
impl<'a, T: ?Sized> Pin<&'a T> {
754754
/// Constructs a new pin by mapping the interior value.
755755
///
756-
/// For example, if you wanted to get a `Pin` of a field of something,
756+
/// For example, if you wanted to get a `Pin` of a field of something,
757757
/// you could use this to get access to that field in one line of code.
758758
/// However, there are several gotchas with these "pinning projections";
759759
/// see the [`pin` module] documentation for further details on that topic.
@@ -856,7 +856,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
856856

857857
/// Construct a new pin by mapping the interior value.
858858
///
859-
/// For example, if you wanted to get a `Pin` of a field of something,
859+
/// For example, if you wanted to get a `Pin` of a field of something,
860860
/// you could use this to get access to that field in one line of code.
861861
/// However, there are several gotchas with these "pinning projections";
862862
/// see the [`pin` module] documentation for further details on that topic.

library/core/src/ptr/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ pub(crate) const unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usiz
17011701
// offset is not a multiple of `stride`, the input pointer was misaligned and no pointer
17021702
// offset will be able to produce a `p` aligned to the specified `a`.
17031703
//
1704-
// The naive `-p (mod a)` equation inhibits LLVM's ability to select instructions
1704+
// The naive `-p (mod a)` equation inhibits LLVM's ability to select instructions
17051705
// like `lea`. We compute `(round_up_to_next_alignment(p, a) - p)` instead. This
17061706
// redistributes operations around the load-bearing, but pessimizing `and` instruction
17071707
// sufficiently for LLVM to be able to utilize the various optimizations it knows about.

library/core/src/slice/iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn size_from_ptr<T>(_: *const T) -> usize {
6565
#[must_use = "iterators are lazy and do nothing unless consumed"]
6666
pub struct Iter<'a, T: 'a> {
6767
ptr: NonNull<T>,
68-
end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that
68+
end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that
6969
// ptr == end is a quick test for the Iterator being empty, that works
7070
// for both ZST and non-ZST.
7171
_marker: PhantomData<&'a T>,
@@ -186,7 +186,7 @@ impl<T> AsRef<[T]> for Iter<'_, T> {
186186
#[must_use = "iterators are lazy and do nothing unless consumed"]
187187
pub struct IterMut<'a, T: 'a> {
188188
ptr: NonNull<T>,
189-
end: *mut T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that
189+
end: *mut T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that
190190
// ptr == end is a quick test for the Iterator being empty, that works
191191
// for both ZST and non-ZST.
192192
_marker: PhantomData<&'a mut T>,

library/core/src/slice/iter/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ macro_rules! len {
2323
$self.end.addr().wrapping_sub(start.as_ptr().addr())
2424
} else {
2525
// We know that `start <= end`, so can do better than `offset_from`,
26-
// which needs to deal in signed. By setting appropriate flags here
26+
// which needs to deal in signed. By setting appropriate flags here
2727
// we can tell LLVM this, which helps it remove bounds checks.
2828
// SAFETY: By the type invariant, `start <= end`
2929
let diff = unsafe { unchecked_sub($self.end.addr(), start.as_ptr().addr()) };

library/core/src/slice/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ impl<T> [T] {
703703

704704
// Because this function is first compiled in isolation,
705705
// this check tells LLVM that the indexing below is
706-
// in-bounds. Then after inlining -- once the actual
706+
// in-bounds. Then after inlining -- once the actual
707707
// lengths of the slices are known -- it's removed.
708708
let (a, b) = (&mut a[..n], &mut b[..n]);
709709

@@ -1248,7 +1248,7 @@ impl<T> [T] {
12481248
ArrayChunksMut::new(self)
12491249
}
12501250

1251-
/// Returns an iterator over overlapping windows of `N` elements of a slice,
1251+
/// Returns an iterator over overlapping windows of `N` elements of a slice,
12521252
/// starting at the beginning of the slice.
12531253
///
12541254
/// This is the const generic equivalent of [`windows`].
@@ -2476,7 +2476,7 @@ impl<T> [T] {
24762476
let mid = left + size / 2;
24772477

24782478
// SAFETY: the while condition means `size` is strictly positive, so
2479-
// `size/2 < size`. Thus `left + size/2 < left + size`, which
2479+
// `size/2 < size`. Thus `left + size/2 < left + size`, which
24802480
// coupled with the `left + size <= self.len()` invariant means
24812481
// we have `left + size/2 < self.len()`, and this is in-bounds.
24822482
let cmp = f(unsafe { self.get_unchecked(mid) });

library/core/src/slice/sort.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ struct CopyOnDrop<T> {
1818

1919
impl<T> Drop for CopyOnDrop<T> {
2020
fn drop(&mut self) {
21-
// SAFETY: This is a helper class.
22-
// Please refer to its usage for correctness.
23-
// Namely, one must be sure that `src` and `dst` does not overlap as required by `ptr::copy_nonoverlapping`.
21+
// SAFETY: This is a helper class.
22+
// Please refer to its usage for correctness.
23+
// Namely, one must be sure that `src` and `dst` does not overlap as required by `ptr::copy_nonoverlapping`.
2424
unsafe {
2525
ptr::copy_nonoverlapping(self.src, self.dest, 1);
2626
}

library/core/tests/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ mod slice_index {
14881488
// optional:
14891489
//
14901490
// one or more similar inputs for which data[input] succeeds,
1491-
// and the corresponding output as an array. This helps validate
1491+
// and the corresponding output as an array. This helps validate
14921492
// "critical points" where an input range straddles the boundary
14931493
// between valid and invalid.
14941494
// (such as the input `len..len`, which is just barely valid)

library/std/src/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ impl FileType {
15121512
}
15131513

15141514
/// Tests whether this file type represents a regular file.
1515-
/// The result is mutually exclusive to the results of
1515+
/// The result is mutually exclusive to the results of
15161516
/// [`is_dir`] and [`is_symlink`]; only zero or one of these
15171517
/// tests may pass.
15181518
///

library/std/src/io/buffered/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ fn test_buffered_reader_seek_underflow_discard_buffer_between_seeks() {
288288
let mut reader = BufReader::with_capacity(5, ErrAfterFirstSeekReader { first_seek: true });
289289
assert_eq!(reader.fill_buf().ok(), Some(&[0, 0, 0, 0, 0][..]));
290290

291-
// The following seek will require two underlying seeks. The first will
292-
// succeed but the second will fail. This should still invalidate the
291+
// The following seek will require two underlying seeks. The first will
292+
// succeed but the second will fail. This should still invalidate the
293293
// buffer.
294294
assert!(reader.seek(SeekFrom::Current(i64::MIN)).is_err());
295295
assert_eq!(reader.buffer().len(), 0);

library/std/src/os/fd/owned.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl BorrowedFd<'_> {
100100

101101
// For ESP-IDF, F_DUPFD is used instead, because the CLOEXEC semantics
102102
// will never be supported, as this is a bare metal framework with
103-
// no capabilities for multi-process execution. While F_DUPFD is also
103+
// no capabilities for multi-process execution. While F_DUPFD is also
104104
// not supported yet, it might be (currently it returns ENOSYS).
105105
#[cfg(target_os = "espidf")]
106106
let cmd = libc::F_DUPFD;

library/std/src/panicking.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ pub mod panic_count {
306306
// and after increase and decrease, but not necessarily during their execution.
307307
//
308308
// Additionally, the top bit of GLOBAL_PANIC_COUNT (GLOBAL_ALWAYS_ABORT_FLAG)
309-
// records whether panic::always_abort() has been called. This can only be
309+
// records whether panic::always_abort() has been called. This can only be
310310
// set, never cleared.
311311
// panic::always_abort() is usually called to prevent memory allocations done by
312312
// the panic handling in the child created by `libc::fork`.
313-
// Memory allocations performed in a child created with `libc::fork` are undefined
313+
// Memory allocations performed in a child created with `libc::fork` are undefined
314314
// behavior in most operating systems.
315315
// Accessing LOCAL_PANIC_COUNT in a child created by `libc::fork` would lead to a memory
316316
// allocation. Only GLOBAL_PANIC_COUNT can be accessed in this situation. This is

library/std/src/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ pub struct Components<'a> {
607607

608608
// true if path *physically* has a root separator; for most Windows
609609
// prefixes, it may have a "logical" root separator for the purposes of
610-
// normalization, e.g., \\server\share == \\server\share\.
610+
// normalization, e.g., \\server\share == \\server\share\.
611611
has_physical_root: bool,
612612

613613
// The iterator is double-ended, and these two states keep track of what has

library/std/src/sys/itron/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl Drop for Thread {
294294
// Terminate and delete the task
295295
// Safety: `self.task` still represents a task we own (because
296296
// this method or `join_inner` is called only once for
297-
// each `Thread`). The task indicated that it's safe to
297+
// each `Thread`). The task indicated that it's safe to
298298
// delete by entering the `FINISHED` state.
299299
unsafe { terminate_and_delete_task(self.task) };
300300

0 commit comments

Comments
 (0)