Skip to content

Commit cd7ca5e

Browse files
author
Alexander Regueiro
committed
tests: comments
1 parent d963910 commit cd7ca5e

File tree

1,128 files changed

+1753
-1792
lines changed

Some content is hidden

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

1,128 files changed

+1753
-1792
lines changed

src/liballoc/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use core::usize;
1111
pub use core::alloc::*;
1212

1313
extern "Rust" {
14-
// These are the magic symbols to call the global allocator. rustc generates
14+
// These are the magic symbols to call the global allocator. rustc generates
1515
// them from the `#[global_allocator]` attribute if there is one, or uses the
1616
// default implementations in libstd (`__rdl_alloc` etc in `src/libstd/alloc.rs`)
1717
// otherwise.

src/liballoc/collections/btree/node.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
549549
/// `into_root_mut`) mess with the root of the tree, the result of `reborrow_mut`
550550
/// can easily be used to make the original mutable pointer dangling, or, in the case
551551
/// of a reborrowed handle, out of bounds.
552-
// FIXME(@gereeter) consider adding yet another type parameter to `NodeRef` that restricts
552+
// FIXME(gereeter): consider adding yet another type parameter to `NodeRef` that restricts
553553
// the use of `ascend` and `into_root_mut` on reborrowed pointers, preventing this unsafety.
554554
unsafe fn reborrow_mut(&mut self) -> NodeRef<marker::Mut<'_>, K, V, Type> {
555555
NodeRef {
@@ -578,12 +578,12 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
578578
impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Immut<'a>, K, V, Type> {
579579
fn into_key_slice(self) -> &'a [K] {
580580
// We have to be careful here because we might be pointing to the shared root.
581-
// In that case, we must not create an `&LeafNode`. We could just return
581+
// In that case, we must not create an `&LeafNode`. We could just return
582582
// an empty slice whenever the length is 0 (this includes the shared root),
583583
// but we want to avoid that run-time check.
584584
// Instead, we create a slice pointing into the node whenever possible.
585585
// We can sometimes do this even for the shared root, as the slice will be
586-
// empty. We cannot *always* do this because if the type is too highly
586+
// empty. We cannot *always* do this because if the type is too highly
587587
// aligned, the offset of `keys` in a "full node" might be outside the bounds
588588
// of the header! So we do an alignment check first, that will be
589589
// evaluated at compile-time, and only do any run-time check in the rare case
@@ -594,9 +594,9 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Immut<'a>, K, V, Type> {
594594
// Thanks to the alignment check above, we know that `keys` will be
595595
// in-bounds of some allocation even if this is the shared root!
596596
// (We might be one-past-the-end, but that is allowed by LLVM.)
597-
// Getting the pointer is tricky though. `NodeHeader` does not have a `keys`
597+
// Getting the pointer is tricky though. `NodeHeader` does not have a `keys`
598598
// field because we want its size to not depend on the alignment of `K`
599-
// (needed becuase `as_header` should be safe). We cannot call `as_leaf`
599+
// (needed becuase `as_header` should be safe). We cannot call `as_leaf`
600600
// because we might be the shared root.
601601
// For this reason, `NodeHeader` has this `K2` parameter (that's usually `()`
602602
// and hence just adds a size-0-align-1 field, not affecting layout).
@@ -950,7 +950,7 @@ impl<'a, K, V, NodeType, HandleType>
950950
/// `into_root_mut`) mess with the root of the tree, the result of `reborrow_mut`
951951
/// can easily be used to make the original mutable pointer dangling, or, in the case
952952
/// of a reborrowed handle, out of bounds.
953-
// FIXME(@gereeter) consider adding yet another type parameter to `NodeRef` that restricts
953+
// FIXME(gereeter): consider adding yet another type parameter to `NodeRef` that restricts
954954
// the use of `ascend` and `into_root_mut` on reborrowed pointers, preventing this unsafety.
955955
pub unsafe fn reborrow_mut(&mut self)
956956
-> Handle<NodeRef<marker::Mut<'_>, K, V, NodeType>, HandleType> {

src/liballoc/collections/vec_deque.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ impl<T> VecDeque<T> {
10141014
tail: drain_tail,
10151015
head: drain_head,
10161016
// Crucially, we only create shared references from `self` here and read from
1017-
// it. We do not write to `self` nor reborrow to a mutable reference.
1017+
// it. We do not write to `self` nor reborrow to a mutable reference.
10181018
// Hence the raw pointer we created above, for `deque`, remains valid.
10191019
ring: unsafe { self.buffer_as_slice() },
10201020
},

src/liballoc/raw_vec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ impl<T, A: Alloc> RawVec<T, A> {
651651
return Ok(());
652652
}
653653

654-
// Nothing we can really do about these checks :(
654+
// Nothing we can really do about these checks.
655655
let new_cap = match strategy {
656656
Exact => used_cap.checked_add(needed_extra_cap).ok_or(CapacityOverflow)?,
657657
Amortized => self.amortized_new_size(used_cap, needed_extra_cap)?,
@@ -794,7 +794,7 @@ mod tests {
794794
fn reserve_does_not_overallocate() {
795795
{
796796
let mut v: RawVec<u32> = RawVec::new();
797-
// First `reserve` allocates like `reserve_exact`
797+
// First `reserve` allocates like `reserve_exact`.
798798
v.reserve(0, 9);
799799
assert_eq!(9, v.cap());
800800
}
@@ -817,7 +817,7 @@ mod tests {
817817
// 3 is less than half of 12, so `reserve` must grow
818818
// exponentially. At the time of writing this test grow
819819
// factor is 2, so new capacity is 24, however, grow factor
820-
// of 1.5 is OK too. Hence `>= 18` in assert.
820+
// of 1.5 is ok too. Hence `>= 18` in assert.
821821
assert!(v.cap() >= 12 + 12 / 2);
822822
}
823823
}

src/liballoc/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ pub struct Weak<T: ?Sized> {
12201220
// This is a `NonNull` to allow optimizing the size of this type in enums,
12211221
// but it is not necessarily a valid pointer.
12221222
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
1223-
// to allocate space on the heap. That's not a value a real pointer
1223+
// to allocate space on the heap. That's not a value a real pointer
12241224
// will ever have because RcBox has alignment at least 2.
12251225
ptr: NonNull<RcBox<T>>,
12261226
}

src/liballoc/sync.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ pub struct Weak<T: ?Sized> {
234234
// This is a `NonNull` to allow optimizing the size of this type in enums,
235235
// but it is not necessarily a valid pointer.
236236
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
237-
// to allocate space on the heap. That's not a value a real pointer
237+
// to allocate space on the heap. That's not a value a real pointer
238238
// will ever have because RcBox has alignment at least 2.
239239
ptr: NonNull<ArcInner<T>>,
240240
}
@@ -749,7 +749,7 @@ impl<T: ?Sized> Clone for Arc<T> {
749749
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
750750
let old_size = self.inner().strong.fetch_add(1, Relaxed);
751751

752-
// However we need to guard against massive refcounts in case someone
752+
// However we need to guard against massive ref counts in case someone
753753
// is `mem::forget`ing Arcs. If we don't do this the count can overflow
754754
// and users will use-after free. We racily saturate to `isize::MAX` on
755755
// the assumption that there aren't ~2 billion threads incrementing
@@ -920,7 +920,7 @@ impl<T: ?Sized> Arc<T> {
920920
//
921921
// The acquire label here ensures a happens-before relationship with any
922922
// writes to `strong` (in particular in `Weak::upgrade`) prior to decrements
923-
// of the `weak` count (via `Weak::drop`, which uses release). If the upgraded
923+
// of the `weak` count (via `Weak::drop`, which uses release). If the upgraded
924924
// weak ref was never dropped, the CAS here will fail so we do not care to synchronize.
925925
if self.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() {
926926
// This needs to be an `Acquire` to synchronize with the decrement of the `strong`
@@ -978,7 +978,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc<T> {
978978
}
979979

980980
// This fence is needed to prevent reordering of use of the data and
981-
// deletion of the data. Because it is marked `Release`, the decreasing
981+
// deletion of the data. Because it is marked `Release`, the decreasing
982982
// of the reference count synchronizes with this `Acquire` fence. This
983983
// means that use of the data happens before decreasing the reference
984984
// count, which happens before this fence, which happens before the
@@ -1270,13 +1270,13 @@ impl<T: ?Sized> Clone for Weak<T> {
12701270
} else {
12711271
return Weak { ptr: self.ptr };
12721272
};
1273-
// See comments in Arc::clone() for why this is relaxed. This can use a
1274-
// fetch_add (ignoring the lock) because the weak count is only locked
1273+
// See comments in `Arc::clone()` for why this is relaxed. This can use a
1274+
// `fetch_add` (ignoring the lock) because the weak count is only locked
12751275
// where are *no other* weak pointers in existence. (So we can't be
12761276
// running this code in that case).
12771277
let old_size = inner.weak.fetch_add(1, Relaxed);
12781278

1279-
// See comments in Arc::clone() for why we do this (for mem::forget).
1279+
// See comments in `Arc::clone()` for why we do this (for `mem::forget`).
12801280
if old_size > MAX_REFCOUNT {
12811281
unsafe {
12821282
abort();

src/liballoc/tests/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ fn hash<T: Hash>(t: &T) -> u64 {
3535
s.finish()
3636
}
3737

38-
// FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten.
39-
// See https://github.com/kripken/emscripten-fastcomp/issues/169
38+
// FIXME: instantiated functions with `i128` in the signature is not supported in Emscripten.
39+
// See <https://github.com/kripken/emscripten-fastcomp/issues/169>.
4040
#[cfg(not(target_os = "emscripten"))]
4141
#[test]
4242
fn test_boxed_hasher() {

src/libcore/cell.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1310,8 +1310,8 @@ impl<'b> BorrowRefMut<'b> {
13101310
fn new(borrow: &'b Cell<BorrowFlag>) -> Option<BorrowRefMut<'b>> {
13111311
// NOTE: Unlike BorrowRefMut::clone, new is called to create the initial
13121312
// mutable reference, and so there must currently be no existing
1313-
// references. Thus, while clone increments the mutable refcount, here
1314-
// we explicitly only allow going from UNUSED to UNUSED - 1.
1313+
// references. Thus, while clone increments the mutable ref count, here
1314+
// we explicitly only allow going from `UNUSED` to `UNUSED - 1`.
13151315
match borrow.get() {
13161316
UNUSED => {
13171317
borrow.set(UNUSED - 1);

src/libcore/fmt/float.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn float_to_decimal_common_exact<T>(fmt: &mut Formatter, num: &T,
1313
let mut buf = MaybeUninit::<[u8; 1024]>::uninitialized(); // enough for f32 and f64
1414
let mut parts = MaybeUninit::<[flt2dec::Part; 4]>::uninitialized();
1515
// FIXME(#53491): Technically, this is calling `get_mut` on an uninitialized
16-
// `MaybeUninit` (here and elsewhere in this file). Revisit this once
16+
// `MaybeUninit` (here and elsewhere in this file). Revisit this once
1717
// we decided whether that is valid or not.
1818
let formatted = flt2dec::to_exact_fixed_str(flt2dec::strategy::grisu::format_exact,
1919
*num, sign, precision,

src/libcore/mem.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ impl<T> MaybeUninit<T> {
11761176
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
11771177
/// state, otherwise this will immediately cause undefined behavior.
11781178
// FIXME(#53491): We currently rely on the above being incorrect, i.e., we have references
1179-
// to uninitialized data (e.g., in `libcore/fmt/float.rs`). We should make
1179+
// to uninitialized data (e.g., in `libcore/fmt/float.rs`). We should make
11801180
// a final decision about the rules before stabilization.
11811181
#[unstable(feature = "maybe_uninit", issue = "53491")]
11821182
#[inline(always)]

src/libcore/num/dec2flt/algorithm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ fn underflow<T: RawFloat>(x: Big, v: Big, rem: Big) -> T {
380380
// \-----/\-------/ \------------/
381381
// q trunc. (represented by rem)
382382
//
383-
// Therefore, when the rounded-off bits are != 0.5 ULP, they decide the rounding
383+
// Therefore, when the rounded-off bits are not equal to half ULP, they decide the rounding
384384
// on their own. When they are equal and the remainder is non-zero, the value still
385385
// needs to be rounded up. Only when the rounded off bits are 1/2 and the remainder
386386
// is zero, we have a half-to-even situation.

src/libcore/ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
185185

186186
// The real `drop_in_place` -- the one that gets called implicitly when variables go
187187
// out of scope -- should have a safe reference and not a raw pointer as argument
188-
// type. When we drop a local variable, we access it with a pointer that behaves
188+
// type. When we drop a local variable, we access it with a pointer that behaves
189189
// like a safe reference; transmuting that to a raw pointer does not mean we can
190190
// actually access it with raw pointers.
191191
#[lang = "drop_in_place"]
@@ -372,7 +372,7 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
372372
// #[repr(simd)], even if we don't actually use this struct directly.
373373
//
374374
// FIXME repr(simd) broken on emscripten and redox
375-
// It's also broken on big-endian powerpc64 and s390x. #42778
375+
// It's also broken on big-endian powerpc64 and s390x. #42778
376376
#[cfg_attr(not(any(target_os = "emscripten", target_os = "redox",
377377
target_endian = "big")),
378378
repr(simd))]

src/libcore/slice/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,14 @@ impl<T> [T] {
451451
let ln = self.len();
452452

453453
// For very small types, all the individual reads in the normal
454-
// path perform poorly. We can do better, given efficient unaligned
454+
// path perform poorly. We can do better, given efficient unaligned
455455
// load/store, by loading a larger chunk and reversing a register.
456456

457457
// Ideally LLVM would do this for us, as it knows better than we do
458458
// whether unaligned reads are efficient (since that changes between
459459
// different ARM versions, for example) and what the best chunk size
460-
// would be. Unfortunately, as of LLVM 4.0 (2017-05) it only unrolls
461-
// the loop, so we need to do this ourselves. (Hypothesis: reverse
460+
// would be. Unfortunately, as of LLVM 4.0 (2017-05) it only unrolls
461+
// the loop, so we need to do this ourselves. (Hypothesis: reverse
462462
// is troublesome because the sides can be aligned differently --
463463
// will be, when the length is odd -- so there's no way of emitting
464464
// pre- and postludes to use fully-aligned SIMD in the middle.)
@@ -2106,8 +2106,8 @@ impl<T> [T] {
21062106
#[inline]
21072107
fn gcd(a: usize, b: usize) -> usize {
21082108
// iterative stein’s algorithm
2109-
// We should still make this `const fn` (and revert to recursive algorithm if we do)
2110-
// because relying on llvm to consteval all this is… well, it makes me uncomfortable.
2109+
// We should still make this `const fn` (and revert to recursive algorithm if we do),
2110+
// because relying on LLVM to const-eval all this does not make me comfortable.
21112111
let (ctz_a, mut ctz_b) = unsafe {
21122112
if a == 0 { return b; }
21132113
if b == 0 { return a; }
@@ -2873,7 +2873,7 @@ macro_rules! iterator {
28732873
#[inline(always)]
28742874
unsafe fn post_inc_start(&mut self, offset: isize) -> * $raw_mut T {
28752875
if mem::size_of::<T>() == 0 {
2876-
// This is *reducing* the length. `ptr` never changes with ZST.
2876+
// This is *reducing* the length. `ptr` never changes with ZST.
28772877
self.end = (self.end as * $raw_mut u8).wrapping_offset(-offset) as * $raw_mut T;
28782878
self.ptr
28792879
} else {
@@ -3321,7 +3321,7 @@ impl<T: fmt::Debug, P> fmt::Debug for Split<'_, T, P> where P: FnMut(&T) -> bool
33213321
}
33223322
}
33233323

3324-
// FIXME(#26925) Remove in favor of `#[derive(Clone)]`
3324+
// FIXME(#26925): remove in favor of `#[derive(Clone)]`.
33253325
#[stable(feature = "rust1", since = "1.0.0")]
33263326
impl<T, P> Clone for Split<'_, T, P> where P: Clone + FnMut(&T) -> bool {
33273327
fn clone(&self) -> Self {
@@ -3452,8 +3452,8 @@ impl<'a, T, P> Iterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {
34523452
if self.finished {
34533453
(0, Some(0))
34543454
} else {
3455-
// if the predicate doesn't match anything, we yield one slice
3456-
// if it matches every element, we yield len+1 empty slices.
3455+
// If the predicate doesn't match anything, we yield one slice
3456+
// if it matches every element, we yield `len + 1` empty slices.
34573457
(1, Some(self.v.len() + 1))
34583458
}
34593459
}

src/libcore/tests/pattern.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ impl From<Option<(usize, usize)>> for Step {
4444

4545
// ignore-tidy-linelength
4646

47-
// FIXME(Manishearth) these tests focus on single-character searching (CharSearcher)
48-
// and on next()/next_match(), not next_reject(). This is because
49-
// the memchr changes make next_match() for single chars complex, but next_reject()
50-
// continues to use next() under the hood. We should add more test cases for all
51-
// of these, as well as tests for StrSearcher and higher level tests for str::find() (etc)
47+
// FIXME(Manishearth): these tests focus on single-character searching (`CharSearcher`),
48+
// and on `next()`/`next_match()`, not `next_reject()`. This is because
49+
// the `memchr` changes make `next_match()` for single chars complex, but `next_reject()`
50+
// continues to `use next()` under the hood. We should add more test cases for all
51+
// of these, as well as tests for `StrSearcher` and higher level tests for `str::find()`, etc.
5252

5353
#[test]
5454
fn test_simple_iteration() {

src/libcore/tests/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ mod slice_index {
810810
// optional:
811811
//
812812
// one or more similar inputs for which data[input] succeeds,
813-
// and the corresponding output as an array. This helps validate
813+
// and the corresponding output as an array. This helps validate
814814
// "critical points" where an input range straddles the boundary
815815
// between valid and invalid.
816816
// (such as the input `len..len`, which is just barely valid)

src/libproc_macro/bridge/client.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ macro_rules! define_handles {
2525
}
2626
}
2727

28-
// FIXME(eddyb) generate the definition of `HandleStore` in `server.rs`.
28+
// FIXME(eddyb): generate the definition of `HandleStore` in `server.rs`.
2929
#[repr(C)]
3030
#[allow(non_snake_case)]
3131
pub(super) struct HandleStore<S: server::Types> {
@@ -171,7 +171,7 @@ define_handles! {
171171
Span,
172172
}
173173

174-
// FIXME(eddyb) generate these impls by pattern-matching on the
174+
// FIXME(eddyb): generate these impls by pattern-matching on the
175175
// names of methods - also could use the presence of `fn drop`
176176
// to distinguish between 'owned and 'interned, above.
177177
// Alternatively, special 'modes" could be listed of types in with_api
@@ -201,7 +201,7 @@ impl Clone for Literal {
201201
}
202202
}
203203

204-
// FIXME(eddyb) `Literal` should not expose internal `Debug` impls.
204+
// FIXME(eddyb): `Literal` should not expose internal `Debug` impls.
205205
impl fmt::Debug for Literal {
206206
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
207207
f.write_str(&self.debug())
@@ -291,7 +291,7 @@ impl BridgeState<'_> {
291291
impl Bridge<'_> {
292292
fn enter<R>(self, f: impl FnOnce() -> R) -> R {
293293
// Hide the default panic output within `proc_macro` expansions.
294-
// NB. the server can't do this because it may use a different libstd.
294+
// N.B., the server can't do this because it may use a different libstd.
295295
static HIDE_PANICS_DURING_EXPANSION: Once = Once::new();
296296
HIDE_PANICS_DURING_EXPANSION.call_once(|| {
297297
let prev = panic::take_hook();

0 commit comments

Comments
 (0)