Skip to content

Commit b0006df

Browse files
author
Alexander Regueiro
committed
A few cosmetic improvements to code & comments in liballoc and libcore
1 parent 1fb3c4e commit b0006df

File tree

13 files changed

+109
-111
lines changed

13 files changed

+109
-111
lines changed

src/liballoc/collections/linked_list/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ fn test_append() {
102102
assert_eq!(m.pop_front(), Some(elt))
103103
}
104104
assert_eq!(n.len(), 0);
105-
// let's make sure it's working properly, since we
106-
// did some direct changes to private members
105+
// Let's make sure it's working properly, since we
106+
// did some direct changes to private members.
107107
n.push_back(3);
108108
assert_eq!(n.len(), 1);
109109
assert_eq!(n.pop_front(), Some(3));

src/liballoc/raw_vec.rs

Lines changed: 74 additions & 76 deletions
Large diffs are not rendered by default.

src/liballoc/raw_vec/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ fn allocator_param() {
55
use crate::alloc::AllocErr;
66

77
// Writing a test of integration between third-party
8-
// allocators and RawVec is a little tricky because the RawVec
8+
// allocators and `RawVec` is a little tricky because the `RawVec`
99
// API does not expose fallible allocation methods, so we
1010
// cannot check what happens when allocator is exhausted
1111
// (beyond detecting a panic).
1212
//
13-
// Instead, this just checks that the RawVec methods do at
13+
// Instead, this just checks that the `RawVec` methods do at
1414
// least go through the Allocator API when it reserves
1515
// storage.
1616

@@ -44,7 +44,7 @@ fn allocator_param() {
4444
fn reserve_does_not_overallocate() {
4545
{
4646
let mut v: RawVec<u32> = RawVec::new();
47-
// First `reserve` allocates like `reserve_exact`
47+
// First, `reserve` allocates like `reserve_exact`.
4848
v.reserve(0, 9);
4949
assert_eq!(9, v.capacity());
5050
}

src/liballoc/rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ impl<T: ?Sized> Rc<T> {
567567
/// let x = Rc::from_raw(x_ptr);
568568
/// assert_eq!(&*x, "hello");
569569
///
570-
/// // Further calls to `Rc::from_raw(x_ptr)` would be memory unsafe.
570+
/// // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.
571571
/// }
572572
///
573573
/// // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!

src/liballoc/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ impl<T: ?Sized> Arc<T> {
547547
/// let x = Arc::from_raw(x_ptr);
548548
/// assert_eq!(&*x, "hello");
549549
///
550-
/// // Further calls to `Arc::from_raw(x_ptr)` would be memory unsafe.
550+
/// // Further calls to `Arc::from_raw(x_ptr)` would be memory-unsafe.
551551
/// }
552552
///
553553
/// // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!

src/libcore/any.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ impl dyn Any {
153153
#[stable(feature = "rust1", since = "1.0.0")]
154154
#[inline]
155155
pub fn is<T: Any>(&self) -> bool {
156-
// Get TypeId of the type this function is instantiated with
156+
// Get `TypeId` of the type this function is instantiated with.
157157
let t = TypeId::of::<T>();
158158

159-
// Get TypeId of the type in the trait object
159+
// Get `TypeId` of the type in the trait object.
160160
let concrete = self.type_id();
161161

162-
// Compare both TypeIds on equality
162+
// Compare both `TypeId`s on equality.
163163
t == concrete
164164
}
165165

src/libcore/marker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,10 @@ unsafe impl<T: ?Sized> Freeze for *mut T {}
602602
unsafe impl<T: ?Sized> Freeze for &T {}
603603
unsafe impl<T: ?Sized> Freeze for &mut T {}
604604

605-
/// Types which can be safely moved after being pinned.
605+
/// Types that can be safely moved after being pinned.
606606
///
607607
/// Since Rust itself has no notion of immovable types, and considers moves
608-
/// (e.g. through assignment or [`mem::replace`]) to always be safe,
608+
/// (e.g., through assignment or [`mem::replace`]) to always be safe,
609609
/// this trait cannot prevent types from moving by itself.
610610
///
611611
/// Instead it is used to prevent moves through the type system,

src/libcore/ptr/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ impl<T: ?Sized> *const T {
10421042
(self as *const u8) == null()
10431043
}
10441044

1045-
/// Cast to a pointer to a different type
1045+
/// Casts to a pointer of another type.
10461046
#[stable(feature = "ptr_cast", since = "1.38.0")]
10471047
#[inline]
10481048
pub const fn cast<U>(self) -> *const U {
@@ -1726,7 +1726,7 @@ impl<T: ?Sized> *mut T {
17261726
(self as *mut u8) == null_mut()
17271727
}
17281728

1729-
/// Cast to a pointer to a different type
1729+
/// Casts to a pointer of another type.
17301730
#[stable(feature = "ptr_cast", since = "1.38.0")]
17311731
#[inline]
17321732
pub const fn cast<U>(self) -> *mut U {

src/libcore/ptr/non_null.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<T: ?Sized> NonNull<T> {
125125
&mut *self.as_ptr()
126126
}
127127

128-
/// Cast to a pointer of another type
128+
/// Casts to a pointer of another type.
129129
#[stable(feature = "nonnull_cast", since = "1.27.0")]
130130
#[inline]
131131
pub const fn cast<U>(self) -> NonNull<U> {

src/libstd/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl Error for VarError {
290290
///
291291
/// Note that while concurrent access to environment variables is safe in Rust,
292292
/// some platforms only expose inherently unsafe non-threadsafe APIs for
293-
/// inspecting the environment. As a result extra care needs to be taken when
293+
/// inspecting the environment. As a result, extra care needs to be taken when
294294
/// auditing calls to unsafe external FFI functions to ensure that any external
295295
/// environment accesses are properly synchronized with accesses in Rust.
296296
///

0 commit comments

Comments
 (0)