Skip to content

Commit 058f1d3

Browse files
Rollup merge of rust-lang#127765 - bitfield:fix_stdlib_doc_nits, r=dtolnay
Fix doc nits Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo"), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits.
2 parents 1f83bf3 + fb7d2a8 commit 058f1d3

File tree

146 files changed

+808
-738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+808
-738
lines changed

alloc/src/alloc.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub struct Global;
5757
#[cfg(test)]
5858
pub use std::alloc::Global;
5959

60-
/// Allocate memory with the global allocator.
60+
/// Allocates memory with the global allocator.
6161
///
6262
/// This function forwards calls to the [`GlobalAlloc::alloc`] method
6363
/// of the allocator registered with the `#[global_allocator]` attribute
@@ -101,7 +101,7 @@ pub unsafe fn alloc(layout: Layout) -> *mut u8 {
101101
}
102102
}
103103

104-
/// Deallocate memory with the global allocator.
104+
/// Deallocates memory with the global allocator.
105105
///
106106
/// This function forwards calls to the [`GlobalAlloc::dealloc`] method
107107
/// of the allocator registered with the `#[global_allocator]` attribute
@@ -119,7 +119,7 @@ pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) {
119119
unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
120120
}
121121

122-
/// Reallocate memory with the global allocator.
122+
/// Reallocates memory with the global allocator.
123123
///
124124
/// This function forwards calls to the [`GlobalAlloc::realloc`] method
125125
/// of the allocator registered with the `#[global_allocator]` attribute
@@ -138,7 +138,7 @@ pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8
138138
unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) }
139139
}
140140

141-
/// Allocate zero-initialized memory with the global allocator.
141+
/// Allocates zero-initialized memory with the global allocator.
142142
///
143143
/// This function forwards calls to the [`GlobalAlloc::alloc_zeroed`] method
144144
/// of the allocator registered with the `#[global_allocator]` attribute
@@ -345,7 +345,7 @@ extern "Rust" {
345345
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;
346346
}
347347

348-
/// Signal a memory allocation error.
348+
/// Signals a memory allocation error.
349349
///
350350
/// Callers of memory allocation APIs wishing to cease execution
351351
/// in response to an allocation error are encouraged to call this function,

alloc/src/boxed.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1268,9 +1268,11 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
12681268
}
12691269

12701270
/// Consumes and leaks the `Box`, returning a mutable reference,
1271-
/// `&'a mut T`. Note that the type `T` must outlive the chosen lifetime
1272-
/// `'a`. If the type has only static references, or none at all, then this
1273-
/// may be chosen to be `'static`.
1271+
/// `&'a mut T`.
1272+
///
1273+
/// Note that the type `T` must outlive the chosen lifetime `'a`. If the type
1274+
/// has only static references, or none at all, then this may be chosen to be
1275+
/// `'static`.
12741276
///
12751277
/// This function is mainly useful for data that lives for the remainder of
12761278
/// the program's life. Dropping the returned reference will cause a memory
@@ -1853,7 +1855,7 @@ impl<T, const N: usize> TryFrom<Vec<T>> for Box<[T; N]> {
18531855
}
18541856

18551857
impl<A: Allocator> Box<dyn Any, A> {
1856-
/// Attempt to downcast the box to a concrete type.
1858+
/// Attempts to downcast the box to a concrete type.
18571859
///
18581860
/// # Examples
18591861
///
@@ -1912,7 +1914,7 @@ impl<A: Allocator> Box<dyn Any, A> {
19121914
}
19131915

19141916
impl<A: Allocator> Box<dyn Any + Send, A> {
1915-
/// Attempt to downcast the box to a concrete type.
1917+
/// Attempts to downcast the box to a concrete type.
19161918
///
19171919
/// # Examples
19181920
///
@@ -1971,7 +1973,7 @@ impl<A: Allocator> Box<dyn Any + Send, A> {
19711973
}
19721974

19731975
impl<A: Allocator> Box<dyn Any + Send + Sync, A> {
1974-
/// Attempt to downcast the box to a concrete type.
1976+
/// Attempts to downcast the box to a concrete type.
19751977
///
19761978
/// # Examples
19771979
///

alloc/src/collections/binary_heap/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ impl<T, A: Allocator> BinaryHeap<T, A> {
965965
}
966966

967967
/// Returns an iterator which retrieves elements in heap order.
968+
///
968969
/// This method consumes the original heap.
969970
///
970971
/// # Examples
@@ -1361,7 +1362,7 @@ struct Hole<'a, T: 'a> {
13611362
}
13621363

13631364
impl<'a, T> Hole<'a, T> {
1364-
/// Create a new `Hole` at index `pos`.
1365+
/// Creates a new `Hole` at index `pos`.
13651366
///
13661367
/// Unsafe because pos must be within the data slice.
13671368
#[inline]

alloc/src/collections/btree/map/entry.rs

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ impl<'a, K: Ord, V, A: Allocator + Clone> Entry<'a, K, V, A> {
189189
}
190190

191191
/// Ensures a value is in the entry by inserting, if empty, the result of the default function.
192+
///
192193
/// This method allows for generating key-derived values for insertion by providing the default
193194
/// function a reference to the key that was moved during the `.entry(key)` method call.
194195
///

alloc/src/fmt.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,7 @@ pub use core::fmt::{LowerHex, Pointer, UpperHex};
600600
#[cfg(not(no_global_oom_handling))]
601601
use crate::string;
602602

603-
/// The `format` function takes an [`Arguments`] struct and returns the resulting
604-
/// formatted string.
603+
/// Takes an [`Arguments`] struct and returns the resulting formatted string.
605604
///
606605
/// The [`Arguments`] instance can be created with the [`format_args!`] macro.
607606
///

alloc/src/raw_vec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl Cap {
5252
/// * Produces `Unique::dangling()` on zero-length allocations.
5353
/// * Avoids freeing `Unique::dangling()`.
5454
/// * Catches all overflows in capacity computations (promotes them to "capacity overflow" panics).
55-
/// * Guards against 32-bit systems allocating more than isize::MAX bytes.
55+
/// * Guards against 32-bit systems allocating more than `isize::MAX` bytes.
5656
/// * Guards against overflowing your length.
5757
/// * Calls `handle_alloc_error` for fallible allocations.
5858
/// * Contains a `ptr::Unique` and thus endows the user with all related benefits.
@@ -484,7 +484,7 @@ impl<T, A: Allocator> RawVec<T, A> {
484484

485485
// `finish_grow` is non-generic over `T`.
486486
let ptr = finish_grow(new_layout, self.current_memory(), &mut self.alloc)?;
487-
// SAFETY: finish_grow would have resulted in a capacity overflow if we tried to allocate more than isize::MAX items
487+
// SAFETY: finish_grow would have resulted in a capacity overflow if we tried to allocate more than `isize::MAX` items
488488
unsafe { self.set_ptr_and_cap(ptr, cap) };
489489
Ok(())
490490
}
@@ -504,7 +504,7 @@ impl<T, A: Allocator> RawVec<T, A> {
504504

505505
// `finish_grow` is non-generic over `T`.
506506
let ptr = finish_grow(new_layout, self.current_memory(), &mut self.alloc)?;
507-
// SAFETY: finish_grow would have resulted in a capacity overflow if we tried to allocate more than isize::MAX items
507+
// SAFETY: `finish_grow` would have resulted in a capacity overflow if we tried to allocate more than `isize::MAX` items
508508
unsafe {
509509
self.set_ptr_and_cap(ptr, cap);
510510
}

alloc/src/rc.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl<T> Rc<T> {
439439
/// }
440440
///
441441
/// impl Gadget {
442-
/// /// Construct a reference counted Gadget.
442+
/// /// Constructs a reference counted Gadget.
443443
/// fn new() -> Rc<Self> {
444444
/// // `me` is a `Weak<Gadget>` pointing at the new allocation of the
445445
/// // `Rc` we're constructing.
@@ -449,7 +449,7 @@ impl<T> Rc<T> {
449449
/// })
450450
/// }
451451
///
452-
/// /// Return a reference counted pointer to Self.
452+
/// /// Returns a reference counted pointer to Self.
453453
/// fn me(&self) -> Rc<Self> {
454454
/// self.me.upgrade().unwrap()
455455
/// }
@@ -1900,7 +1900,7 @@ impl<T: Clone, A: Allocator> Rc<T, A> {
19001900
}
19011901

19021902
impl<A: Allocator> Rc<dyn Any, A> {
1903-
/// Attempt to downcast the `Rc<dyn Any>` to a concrete type.
1903+
/// Attempts to downcast the `Rc<dyn Any>` to a concrete type.
19041904
///
19051905
/// # Examples
19061906
///
@@ -2586,7 +2586,7 @@ impl<T, const N: usize> From<[T; N]> for Rc<[T]> {
25862586
#[cfg(not(no_global_oom_handling))]
25872587
#[stable(feature = "shared_from_slice", since = "1.21.0")]
25882588
impl<T: Clone> From<&[T]> for Rc<[T]> {
2589-
/// Allocate a reference-counted slice and fill it by cloning `v`'s items.
2589+
/// Allocates a reference-counted slice and fills it by cloning `v`'s items.
25902590
///
25912591
/// # Example
25922592
///
@@ -2605,7 +2605,7 @@ impl<T: Clone> From<&[T]> for Rc<[T]> {
26052605
#[cfg(not(no_global_oom_handling))]
26062606
#[stable(feature = "shared_from_slice", since = "1.21.0")]
26072607
impl From<&str> for Rc<str> {
2608-
/// Allocate a reference-counted string slice and copy `v` into it.
2608+
/// Allocates a reference-counted string slice and copies `v` into it.
26092609
///
26102610
/// # Example
26112611
///
@@ -2624,7 +2624,7 @@ impl From<&str> for Rc<str> {
26242624
#[cfg(not(no_global_oom_handling))]
26252625
#[stable(feature = "shared_from_slice", since = "1.21.0")]
26262626
impl From<String> for Rc<str> {
2627-
/// Allocate a reference-counted string slice and copy `v` into it.
2627+
/// Allocates a reference-counted string slice and copies `v` into it.
26282628
///
26292629
/// # Example
26302630
///
@@ -2662,7 +2662,7 @@ impl<T: ?Sized, A: Allocator> From<Box<T, A>> for Rc<T, A> {
26622662
#[cfg(not(no_global_oom_handling))]
26632663
#[stable(feature = "shared_from_slice", since = "1.21.0")]
26642664
impl<T, A: Allocator> From<Vec<T, A>> for Rc<[T], A> {
2665-
/// Allocate a reference-counted slice and move `v`'s items into it.
2665+
/// Allocates a reference-counted slice and moves `v`'s items into it.
26662666
///
26672667
/// # Example
26682668
///
@@ -2695,8 +2695,8 @@ where
26952695
B: ToOwned + ?Sized,
26962696
Rc<B>: From<&'a B> + From<B::Owned>,
26972697
{
2698-
/// Create a reference-counted pointer from
2699-
/// a clone-on-write pointer by copying its content.
2698+
/// Creates a reference-counted pointer from a clone-on-write pointer by
2699+
/// copying its content.
27002700
///
27012701
/// # Example
27022702
///
@@ -3526,7 +3526,7 @@ impl<T: ?Sized, A: Allocator> AsRef<T> for Rc<T, A> {
35263526
#[stable(feature = "pin", since = "1.33.0")]
35273527
impl<T: ?Sized, A: Allocator> Unpin for Rc<T, A> {}
35283528

3529-
/// Get the offset within an `RcBox` for the payload behind a pointer.
3529+
/// Gets the offset within an `RcBox` for the payload behind a pointer.
35303530
///
35313531
/// # Safety
35323532
///
@@ -3734,7 +3734,7 @@ struct UniqueRcUninit<T: ?Sized, A: Allocator> {
37343734

37353735
#[cfg(not(no_global_oom_handling))]
37363736
impl<T: ?Sized, A: Allocator> UniqueRcUninit<T, A> {
3737-
/// Allocate a RcBox with layout suitable to contain `for_value` or a clone of it.
3737+
/// Allocates a RcBox with layout suitable to contain `for_value` or a clone of it.
37383738
fn new(for_value: &T, alloc: A) -> UniqueRcUninit<T, A> {
37393739
let layout = Layout::for_value(for_value);
37403740
let ptr = unsafe {

alloc/src/sync.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl<T> Arc<T> {
428428
/// }
429429
///
430430
/// impl Gadget {
431-
/// /// Construct a reference counted Gadget.
431+
/// /// Constructs a reference counted Gadget.
432432
/// fn new() -> Arc<Self> {
433433
/// // `me` is a `Weak<Gadget>` pointing at the new allocation of the
434434
/// // `Arc` we're constructing.
@@ -438,7 +438,7 @@ impl<T> Arc<T> {
438438
/// })
439439
/// }
440440
///
441-
/// /// Return a reference counted pointer to Self.
441+
/// /// Returns a reference counted pointer to Self.
442442
/// fn me(&self) -> Arc<Self> {
443443
/// self.me.upgrade().unwrap()
444444
/// }
@@ -2531,7 +2531,7 @@ unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for Arc<T, A> {
25312531
}
25322532

25332533
impl<A: Allocator> Arc<dyn Any + Send + Sync, A> {
2534-
/// Attempt to downcast the `Arc<dyn Any + Send + Sync>` to a concrete type.
2534+
/// Attempts to downcast the `Arc<dyn Any + Send + Sync>` to a concrete type.
25352535
///
25362536
/// # Examples
25372537
///
@@ -3545,7 +3545,7 @@ impl<T, const N: usize> From<[T; N]> for Arc<[T]> {
35453545
#[cfg(not(no_global_oom_handling))]
35463546
#[stable(feature = "shared_from_slice", since = "1.21.0")]
35473547
impl<T: Clone> From<&[T]> for Arc<[T]> {
3548-
/// Allocate a reference-counted slice and fill it by cloning `v`'s items.
3548+
/// Allocates a reference-counted slice and fills it by cloning `v`'s items.
35493549
///
35503550
/// # Example
35513551
///
@@ -3564,7 +3564,7 @@ impl<T: Clone> From<&[T]> for Arc<[T]> {
35643564
#[cfg(not(no_global_oom_handling))]
35653565
#[stable(feature = "shared_from_slice", since = "1.21.0")]
35663566
impl From<&str> for Arc<str> {
3567-
/// Allocate a reference-counted `str` and copy `v` into it.
3567+
/// Allocates a reference-counted `str` and copies `v` into it.
35683568
///
35693569
/// # Example
35703570
///
@@ -3583,7 +3583,7 @@ impl From<&str> for Arc<str> {
35833583
#[cfg(not(no_global_oom_handling))]
35843584
#[stable(feature = "shared_from_slice", since = "1.21.0")]
35853585
impl From<String> for Arc<str> {
3586-
/// Allocate a reference-counted `str` and copy `v` into it.
3586+
/// Allocates a reference-counted `str` and copies `v` into it.
35873587
///
35883588
/// # Example
35893589
///
@@ -3621,7 +3621,7 @@ impl<T: ?Sized, A: Allocator> From<Box<T, A>> for Arc<T, A> {
36213621
#[cfg(not(no_global_oom_handling))]
36223622
#[stable(feature = "shared_from_slice", since = "1.21.0")]
36233623
impl<T, A: Allocator + Clone> From<Vec<T, A>> for Arc<[T], A> {
3624-
/// Allocate a reference-counted slice and move `v`'s items into it.
3624+
/// Allocates a reference-counted slice and moves `v`'s items into it.
36253625
///
36263626
/// # Example
36273627
///
@@ -3654,8 +3654,8 @@ where
36543654
B: ToOwned + ?Sized,
36553655
Arc<B>: From<&'a B> + From<B::Owned>,
36563656
{
3657-
/// Create an atomically reference-counted pointer from
3658-
/// a clone-on-write pointer by copying its content.
3657+
/// Creates an atomically reference-counted pointer from a clone-on-write
3658+
/// pointer by copying its content.
36593659
///
36603660
/// # Example
36613661
///
@@ -3811,7 +3811,7 @@ impl<T: ?Sized, A: Allocator> AsRef<T> for Arc<T, A> {
38113811
#[stable(feature = "pin", since = "1.33.0")]
38123812
impl<T: ?Sized, A: Allocator> Unpin for Arc<T, A> {}
38133813

3814-
/// Get the offset within an `ArcInner` for the payload behind a pointer.
3814+
/// Gets the offset within an `ArcInner` for the payload behind a pointer.
38153815
///
38163816
/// # Safety
38173817
///
@@ -3833,7 +3833,7 @@ fn data_offset_align(align: usize) -> usize {
38333833
layout.size() + layout.padding_needed_for(align)
38343834
}
38353835

3836-
/// A unique owning pointer to a [`ArcInner`] **that does not imply the contents are initialized,**
3836+
/// A unique owning pointer to an [`ArcInner`] **that does not imply the contents are initialized,**
38373837
/// but will deallocate it (without dropping the value) when dropped.
38383838
///
38393839
/// This is a helper for [`Arc::make_mut()`] to ensure correct cleanup on panic.
@@ -3846,7 +3846,7 @@ struct UniqueArcUninit<T: ?Sized, A: Allocator> {
38463846

38473847
#[cfg(not(no_global_oom_handling))]
38483848
impl<T: ?Sized, A: Allocator> UniqueArcUninit<T, A> {
3849-
/// Allocate a ArcInner with layout suitable to contain `for_value` or a clone of it.
3849+
/// Allocates an ArcInner with layout suitable to contain `for_value` or a clone of it.
38503850
fn new(for_value: &T, alloc: A) -> UniqueArcUninit<T, A> {
38513851
let layout = Layout::for_value(for_value);
38523852
let ptr = unsafe {

alloc/src/vec/into_iter.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ impl<T, A: Allocator> IntoIter<T, A> {
114114
}
115115

116116
/// Drops remaining elements and relinquishes the backing allocation.
117-
/// This method guarantees it won't panic before relinquishing
118-
/// the backing allocation.
117+
///
118+
/// This method guarantees it won't panic before relinquishing the backing
119+
/// allocation.
119120
///
120121
/// This is roughly equivalent to the following, but more efficient
121122
///

0 commit comments

Comments
 (0)