Rollup merge of #91916 - steffahn:fix-typos, r=dtolnay

Fix a bunch of typos

I hope that none of these files is not supposed to be modified.

FYI, I opened separate PRs for typos in submodules, in the respective repositories
* https://github.com/rust-lang/stdarch/pull/1267
* https://github.com/rust-lang/backtrace-rs/pull/455
This commit is contained in:
Matthias Krüger 2021-12-15 10:57:02 +01:00 committed by GitHub
commit 99f4458a8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 55 additions and 55 deletions

View File

@ -3,7 +3,7 @@ use std::mem::MaybeUninit;
use std::ptr::NonNull; use std::ptr::NonNull;
#[test] #[test]
fn unitialized_zero_size_box() { fn uninitialized_zero_size_box() {
assert_eq!( assert_eq!(
&*Box::<()>::new_uninit() as *const _, &*Box::<()>::new_uninit() as *const _,
NonNull::<MaybeUninit<()>>::dangling().as_ptr(), NonNull::<MaybeUninit<()>>::dangling().as_ptr(),

View File

@ -162,7 +162,7 @@ fn test_join_for_different_lengths_with_long_separator() {
} }
#[test] #[test]
fn test_join_isue_80335() { fn test_join_issue_80335() {
use core::{borrow::Borrow, cell::Cell}; use core::{borrow::Borrow, cell::Cell};
struct WeirdBorrow { struct WeirdBorrow {

View File

@ -157,11 +157,11 @@ impl Layout {
/// ///
/// - If `T` is `Sized`, this function is always safe to call. /// - If `T` is `Sized`, this function is always safe to call.
/// - If the unsized tail of `T` is: /// - If the unsized tail of `T` is:
/// - a [slice], then the length of the slice tail must be an intialized /// - a [slice], then the length of the slice tail must be an initialized
/// integer, and the size of the *entire value* /// integer, and the size of the *entire value*
/// (dynamic tail length + statically sized prefix) must fit in `isize`. /// (dynamic tail length + statically sized prefix) must fit in `isize`.
/// - a [trait object], then the vtable part of the pointer must point /// - a [trait object], then the vtable part of the pointer must point
/// to a valid vtable for the type `T` acquired by an unsizing coersion, /// to a valid vtable for the type `T` acquired by an unsizing coercion,
/// and the size of the *entire value* /// and the size of the *entire value*
/// (dynamic tail length + statically sized prefix) must fit in `isize`. /// (dynamic tail length + statically sized prefix) must fit in `isize`.
/// - an (unstable) [extern type], then this function is always safe to /// - an (unstable) [extern type], then this function is always safe to

View File

@ -898,7 +898,7 @@ impl<T: ?Sized> RefCell<T> {
Ok(Ref { value: unsafe { &*self.value.get() }, borrow: b }) Ok(Ref { value: unsafe { &*self.value.get() }, borrow: b })
} }
None => Err(BorrowError { None => Err(BorrowError {
// If a borrow occured, then we must already have an outstanding borrow, // If a borrow occurred, then we must already have an outstanding borrow,
// so `borrowed_at` will be `Some` // so `borrowed_at` will be `Some`
#[cfg(feature = "debug_refcell")] #[cfg(feature = "debug_refcell")]
location: self.borrowed_at.get().unwrap(), location: self.borrowed_at.get().unwrap(),
@ -983,7 +983,7 @@ impl<T: ?Sized> RefCell<T> {
Ok(RefMut { value: unsafe { &mut *self.value.get() }, borrow: b }) Ok(RefMut { value: unsafe { &mut *self.value.get() }, borrow: b })
} }
None => Err(BorrowMutError { None => Err(BorrowMutError {
// If a borrow occured, then we must already have an outstanding borrow, // If a borrow occurred, then we must already have an outstanding borrow,
// so `borrowed_at` will be `Some` // so `borrowed_at` will be `Some`
#[cfg(feature = "debug_refcell")] #[cfg(feature = "debug_refcell")]
location: self.borrowed_at.get().unwrap(), location: self.borrowed_at.get().unwrap(),
@ -1104,7 +1104,7 @@ impl<T: ?Sized> RefCell<T> {
Ok(unsafe { &*self.value.get() }) Ok(unsafe { &*self.value.get() })
} else { } else {
Err(BorrowError { Err(BorrowError {
// If a borrow occured, then we must already have an outstanding borrow, // If a borrow occurred, then we must already have an outstanding borrow,
// so `borrowed_at` will be `Some` // so `borrowed_at` will be `Some`
#[cfg(feature = "debug_refcell")] #[cfg(feature = "debug_refcell")]
location: self.borrowed_at.get().unwrap(), location: self.borrowed_at.get().unwrap(),

View File

@ -516,7 +516,7 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
/// * It must also be safe to drop `self` after calling `self.__iterator_get_unchecked(idx)`. /// * It must also be safe to drop `self` after calling `self.__iterator_get_unchecked(idx)`.
/// * If `T` is a subtype of `Self`, then it must be safe to coerce `self` to `T`. /// * If `T` is a subtype of `Self`, then it must be safe to coerce `self` to `T`.
// //
// FIXME: Clarify interaction with SourceIter/InPlaceIterable. Calling `SouceIter::as_inner` // FIXME: Clarify interaction with SourceIter/InPlaceIterable. Calling `SourceIter::as_inner`
// after `__iterator_get_unchecked` is supposed to be allowed. // after `__iterator_get_unchecked` is supposed to be allowed.
#[doc(hidden)] #[doc(hidden)]
#[unstable(feature = "trusted_random_access", issue = "none")] #[unstable(feature = "trusted_random_access", issue = "none")]

View File

@ -777,7 +777,7 @@ range_exact_iter_impl! {
usize u8 u16 usize u8 u16
isize i8 i16 isize i8 i16
// These are incorect per the reasoning above, // These are incorrect per the reasoning above,
// but removing them would be a breaking change as they were stabilized in Rust 1.0.0. // but removing them would be a breaking change as they were stabilized in Rust 1.0.0.
// So e.g. `(0..66_000_u32).len()` for example will compile without error or warnings // So e.g. `(0..66_000_u32).len()` for example will compile without error or warnings
// on 16-bit platforms, but continue to give a wrong result. // on 16-bit platforms, but continue to give a wrong result.
@ -805,7 +805,7 @@ range_incl_exact_iter_impl! {
u8 u8
i8 i8
// These are incorect per the reasoning above, // These are incorrect per the reasoning above,
// but removing them would be a breaking change as they were stabilized in Rust 1.26.0. // but removing them would be a breaking change as they were stabilized in Rust 1.26.0.
// So e.g. `(0..=u16::MAX).len()` for example will compile without error or warnings // So e.g. `(0..=u16::MAX).len()` for example will compile without error or warnings
// on 16-bit platforms, but continue to give a wrong result. // on 16-bit platforms, but continue to give a wrong result.

View File

@ -40,7 +40,7 @@ impl Number {
&& !self.many_digits && !self.many_digits
} }
/// The fast path algorithmn using machine-sized integers and floats. /// The fast path algorithm using machine-sized integers and floats.
/// ///
/// This is extracted into a separate function so that it can be attempted before constructing /// This is extracted into a separate function so that it can be attempted before constructing
/// a Decimal. This only works if both the mantissa and the exponent /// a Decimal. This only works if both the mantissa and the exponent

View File

@ -1,4 +1,4 @@
//! Shared utilties used by both float and integer formatting. //! Shared utilities used by both float and integer formatting.
#![doc(hidden)] #![doc(hidden)]
#![unstable( #![unstable(
feature = "numfmt", feature = "numfmt",

View File

@ -221,7 +221,7 @@ impl<'a, T> IterMut<'a, T> {
// the length, to also allows for the fast `ptr == end` check. // the length, to also allows for the fast `ptr == end` check.
// //
// See the `next_unchecked!` and `is_empty!` macros as well as the // See the `next_unchecked!` and `is_empty!` macros as well as the
// `post_inc_start` method for more informations. // `post_inc_start` method for more information.
unsafe { unsafe {
assume(!ptr.is_null()); assume(!ptr.is_null());

View File

@ -104,7 +104,7 @@ pub unsafe fn ptr_rotate<T>(mut left: usize, mut mid: *mut T, mut right: usize)
// - overflows cannot happen for `i` since the function's safety contract ask for // - overflows cannot happen for `i` since the function's safety contract ask for
// `mid+right-1 = x+left+right` to be valid for writing // `mid+right-1 = x+left+right` to be valid for writing
// - underflows cannot happen because `i` must be bigger or equal to `left` for // - underflows cannot happen because `i` must be bigger or equal to `left` for
// a substraction of `left` to happen. // a subtraction of `left` to happen.
// //
// So `x+i` is valid for reading and writing if the caller respected the contract // So `x+i` is valid for reading and writing if the caller respected the contract
tmp = unsafe { x.add(i).replace(tmp) }; tmp = unsafe { x.add(i).replace(tmp) };
@ -202,7 +202,7 @@ pub unsafe fn ptr_rotate<T>(mut left: usize, mut mid: *mut T, mut right: usize)
loop { loop {
// SAFETY: // SAFETY:
// `left >= right` so `[mid-right, mid+right)` is valid for reading and writing // `left >= right` so `[mid-right, mid+right)` is valid for reading and writing
// Substracting `right` from `mid` each turn is counterbalanced by the addition and // Subtracting `right` from `mid` each turn is counterbalanced by the addition and
// check after it. // check after it.
unsafe { unsafe {
ptr::swap_nonoverlapping(mid.sub(right), mid, right); ptr::swap_nonoverlapping(mid.sub(right), mid, right);
@ -218,7 +218,7 @@ pub unsafe fn ptr_rotate<T>(mut left: usize, mut mid: *mut T, mut right: usize)
loop { loop {
// SAFETY: `[mid-left, mid+left)` is valid for reading and writing because // SAFETY: `[mid-left, mid+left)` is valid for reading and writing because
// `left < right` so `mid+left < mid+right`. // `left < right` so `mid+left < mid+right`.
// Adding `left` to `mid` each turn is counterbalanced by the substraction and check // Adding `left` to `mid` each turn is counterbalanced by the subtraction and check
// after it. // after it.
unsafe { unsafe {
ptr::swap_nonoverlapping(mid.sub(left), mid, left); ptr::swap_nonoverlapping(mid.sub(left), mid, left);

View File

@ -748,7 +748,7 @@ generate_pattern_iterators! {
} }
impl<'a, P: Pattern<'a>> Split<'a, P> { impl<'a, P: Pattern<'a>> Split<'a, P> {
/// Returns remainder of the splitted string /// Returns remainder of the split string
/// ///
/// # Examples /// # Examples
/// ///
@ -769,7 +769,7 @@ impl<'a, P: Pattern<'a>> Split<'a, P> {
} }
impl<'a, P: Pattern<'a>> RSplit<'a, P> { impl<'a, P: Pattern<'a>> RSplit<'a, P> {
/// Returns remainder of the splitted string /// Returns remainder of the split string
/// ///
/// # Examples /// # Examples
/// ///
@ -808,7 +808,7 @@ generate_pattern_iterators! {
} }
impl<'a, P: Pattern<'a>> SplitTerminator<'a, P> { impl<'a, P: Pattern<'a>> SplitTerminator<'a, P> {
/// Returns remainder of the splitted string /// Returns remainder of the split string
/// ///
/// # Examples /// # Examples
/// ///
@ -829,7 +829,7 @@ impl<'a, P: Pattern<'a>> SplitTerminator<'a, P> {
} }
impl<'a, P: Pattern<'a>> RSplitTerminator<'a, P> { impl<'a, P: Pattern<'a>> RSplitTerminator<'a, P> {
/// Returns remainder of the splitted string /// Returns remainder of the split string
/// ///
/// # Examples /// # Examples
/// ///
@ -931,7 +931,7 @@ generate_pattern_iterators! {
} }
impl<'a, P: Pattern<'a>> SplitN<'a, P> { impl<'a, P: Pattern<'a>> SplitN<'a, P> {
/// Returns remainder of the splitted string /// Returns remainder of the split string
/// ///
/// # Examples /// # Examples
/// ///
@ -952,7 +952,7 @@ impl<'a, P: Pattern<'a>> SplitN<'a, P> {
} }
impl<'a, P: Pattern<'a>> RSplitN<'a, P> { impl<'a, P: Pattern<'a>> RSplitN<'a, P> {
/// Returns remainder of the splitted string /// Returns remainder of the split string
/// ///
/// # Examples /// # Examples
/// ///
@ -1236,7 +1236,7 @@ impl<'a> DoubleEndedIterator for SplitWhitespace<'a> {
impl FusedIterator for SplitWhitespace<'_> {} impl FusedIterator for SplitWhitespace<'_> {}
impl<'a> SplitWhitespace<'a> { impl<'a> SplitWhitespace<'a> {
/// Returns remainder of the splitted string /// Returns remainder of the split string
/// ///
/// # Examples /// # Examples
/// ///
@ -1292,7 +1292,7 @@ impl<'a> DoubleEndedIterator for SplitAsciiWhitespace<'a> {
impl FusedIterator for SplitAsciiWhitespace<'_> {} impl FusedIterator for SplitAsciiWhitespace<'_> {}
impl<'a> SplitAsciiWhitespace<'a> { impl<'a> SplitAsciiWhitespace<'a> {
/// Returns remainder of the splitted string /// Returns remainder of the split string
/// ///
/// # Examples /// # Examples
/// ///
@ -1360,7 +1360,7 @@ impl<'a, P: Pattern<'a, Searcher: ReverseSearcher<'a>>> DoubleEndedIterator
impl<'a, P: Pattern<'a>> FusedIterator for SplitInclusive<'a, P> {} impl<'a, P: Pattern<'a>> FusedIterator for SplitInclusive<'a, P> {}
impl<'a, P: Pattern<'a>> SplitInclusive<'a, P> { impl<'a, P: Pattern<'a>> SplitInclusive<'a, P> {
/// Returns remainder of the splitted string /// Returns remainder of the split string
/// ///
/// # Examples /// # Examples
/// ///

View File

@ -259,7 +259,7 @@ fn iterator_drops() {
// This test does not work on targets without panic=unwind support. // This test does not work on targets without panic=unwind support.
// To work around this problem, test is marked is should_panic, so it will // To work around this problem, test is marked is should_panic, so it will
// be automagically skipped on unsuitable targets, such as // be automagically skipped on unsuitable targets, such as
// wasm32-unknown-unkown. // wasm32-unknown-unknown.
// //
// It means that we use panic for indicating success. // It means that we use panic for indicating success.
#[test] #[test]

View File

@ -49,7 +49,7 @@ static EXCEPTION_TYPE_INFO: TypeInfo = TypeInfo {
}; };
struct Exception { struct Exception {
// This is necessary because C++ code can capture our execption with // This is necessary because C++ code can capture our exception with
// std::exception_ptr and rethrow it multiple times, possibly even in // std::exception_ptr and rethrow it multiple times, possibly even in
// another thread. // another thread.
caught: AtomicBool, caught: AtomicBool,

View File

@ -1369,7 +1369,7 @@ fn symlink_hard_link() {
// "hard_link" should appear as a symlink. // "hard_link" should appear as a symlink.
assert!(check!(fs::symlink_metadata(tmpdir.join("hard_link"))).file_type().is_symlink()); assert!(check!(fs::symlink_metadata(tmpdir.join("hard_link"))).file_type().is_symlink());
// We sould be able to open "file" via any of the above names. // We should be able to open "file" via any of the above names.
let _ = check!(fs::File::open(tmpdir.join("file"))); let _ = check!(fs::File::open(tmpdir.join("file")));
assert!(fs::File::open(tmpdir.join("file.renamed")).is_err()); assert!(fs::File::open(tmpdir.join("file.renamed")).is_err());
let _ = check!(fs::File::open(tmpdir.join("symlink"))); let _ = check!(fs::File::open(tmpdir.join("symlink")));

View File

@ -362,7 +362,7 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>
let start_len = buf.len(); let start_len = buf.len();
let start_cap = buf.capacity(); let start_cap = buf.capacity();
let mut initialized = 0; // Extra initalized bytes from previous loop iteration let mut initialized = 0; // Extra initialized bytes from previous loop iteration
loop { loop {
if buf.len() == buf.capacity() { if buf.len() == buf.capacity() {
buf.reserve(32); // buf is full, need more space buf.reserve(32); // buf is full, need more space
@ -370,7 +370,7 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>
let mut read_buf = ReadBuf::uninit(buf.spare_capacity_mut()); let mut read_buf = ReadBuf::uninit(buf.spare_capacity_mut());
// SAFETY: These bytes were initalized but not filled in the previous loop // SAFETY: These bytes were initialized but not filled in the previous loop
unsafe { unsafe {
read_buf.assume_init(initialized); read_buf.assume_init(initialized);
} }

View File

@ -1179,7 +1179,7 @@ where
}) })
}) == Ok(Some(())) }) == Ok(Some(()))
{ {
// Succesfully wrote to capture buffer. // Successfully wrote to capture buffer.
return; return;
} }

View File

@ -749,7 +749,7 @@ fn ipv4_from_constructors() {
} }
#[test] #[test]
fn ipv6_from_contructors() { fn ipv6_from_constructors() {
assert_eq!(Ipv6Addr::LOCALHOST, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)); assert_eq!(Ipv6Addr::LOCALHOST, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
assert!(Ipv6Addr::LOCALHOST.is_loopback()); assert!(Ipv6Addr::LOCALHOST.is_loopback());
assert_eq!(Ipv6Addr::UNSPECIFIED, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)); assert_eq!(Ipv6Addr::UNSPECIFIED, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0));

View File

@ -365,7 +365,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
// The call to `intrinsics::r#try` is made safe by: // The call to `intrinsics::r#try` is made safe by:
// - `do_call`, the first argument, can be called with the initial `data_ptr`. // - `do_call`, the first argument, can be called with the initial `data_ptr`.
// - `do_catch`, the second argument, can be called with the `data_ptr` as well. // - `do_catch`, the second argument, can be called with the `data_ptr` as well.
// See their safety preconditions for more informations // See their safety preconditions for more information
unsafe { unsafe {
return if intrinsics::r#try(do_call::<F, R>, data_ptr, do_catch::<F, R>) == 0 { return if intrinsics::r#try(do_call::<F, R>, data_ptr, do_catch::<F, R>) == 0 {
Ok(ManuallyDrop::into_inner(data.r)) Ok(ManuallyDrop::into_inner(data.r))
@ -398,7 +398,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
// expects normal function pointers. // expects normal function pointers.
#[inline] #[inline]
fn do_call<F: FnOnce() -> R, R>(data: *mut u8) { fn do_call<F: FnOnce() -> R, R>(data: *mut u8) {
// SAFETY: this is the responsibilty of the caller, see above. // SAFETY: this is the responsibility of the caller, see above.
unsafe { unsafe {
let data = data as *mut Data<F, R>; let data = data as *mut Data<F, R>;
let data = &mut (*data); let data = &mut (*data);
@ -420,7 +420,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
// expects normal function pointers. // expects normal function pointers.
#[inline] #[inline]
fn do_catch<F: FnOnce() -> R, R>(data: *mut u8, payload: *mut u8) { fn do_catch<F: FnOnce() -> R, R>(data: *mut u8, payload: *mut u8) {
// SAFETY: this is the responsibilty of the caller, see above. // SAFETY: this is the responsibility of the caller, see above.
// //
// When `__rustc_panic_cleaner` is correctly implemented we can rely // When `__rustc_panic_cleaner` is correctly implemented we can rely
// on `obj` being the correct thing to pass to `data.p` (after wrapping // on `obj` being the correct thing to pass to `data.p` (after wrapping

View File

@ -126,7 +126,7 @@ impl Thread {
// In this case, `inner`'s ownership has been moved to us, // In this case, `inner`'s ownership has been moved to us,
// And we are responsible for dropping it. The acquire // And we are responsible for dropping it. The acquire
// ordering is not necessary because the parent thread made // ordering is not necessary because the parent thread made
// no memory acccess needing synchronization since the call // no memory access needing synchronization since the call
// to `acre_tsk`. // to `acre_tsk`.
// Safety: See above. // Safety: See above.
let _ = unsafe { Box::from_raw(inner as *const _ as *mut ThreadInner) }; let _ = unsafe { Box::from_raw(inner as *const _ as *mut ThreadInner) };
@ -264,7 +264,7 @@ impl Drop for Thread {
// one will ever join it. // one will ever join it.
// The ownership of `self.inner` is moved to the child thread. // The ownership of `self.inner` is moved to the child thread.
// However, the release ordering is not necessary because we // However, the release ordering is not necessary because we
// made no memory acccess needing synchronization since the call // made no memory access needing synchronization since the call
// to `acre_tsk`. // to `acre_tsk`.
} }
LIFECYCLE_FINISHED => { LIFECYCLE_FINISHED => {

View File

@ -104,7 +104,7 @@ impl FdMeta {
fn potential_sendfile_source(&self) -> bool { fn potential_sendfile_source(&self) -> bool {
match self { match self {
// procfs erronously shows 0 length on non-empty readable files. // procfs erroneously shows 0 length on non-empty readable files.
// and if a file is truly empty then a `read` syscall will determine that and skip the write syscall // and if a file is truly empty then a `read` syscall will determine that and skip the write syscall
// thus there would be benefit from attempting sendfile // thus there would be benefit from attempting sendfile
FdMeta::Metadata(meta) FdMeta::Metadata(meta)

View File

@ -284,7 +284,7 @@ impl ExitStatus {
// //
// The other view would be to say that the caller on Fuchsia ought to know that `into_raw` // The other view would be to say that the caller on Fuchsia ought to know that `into_raw`
// will give a raw Fuchsia status (whatever that is - I don't know, personally). That is // will give a raw Fuchsia status (whatever that is - I don't know, personally). That is
// not possible here becaause we must return a c_int because that's what Unix (including // not possible here because we must return a c_int because that's what Unix (including
// SuS and POSIX) say a wait status is, but Fuchsia apparently uses a u64, so it won't // SuS and POSIX) say a wait status is, but Fuchsia apparently uses a u64, so it won't
// necessarily fit. // necessarily fit.
// //

View File

@ -124,7 +124,7 @@ impl<F> DlsymWeak<F> {
} }
} }
// Cold because it should only happen during first-time initalization. // Cold because it should only happen during first-time initialization.
#[cold] #[cold]
unsafe fn initialize(&self) -> Option<F> { unsafe fn initialize(&self) -> Option<F> {
assert_eq!(mem::size_of::<F>(), mem::size_of::<usize>()); assert_eq!(mem::size_of::<F>(), mem::size_of::<usize>());

View File

@ -24,7 +24,7 @@ static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::Dlmalloc::new();
unsafe impl GlobalAlloc for System { unsafe impl GlobalAlloc for System {
#[inline] #[inline]
unsafe fn alloc(&self, layout: Layout) -> *mut u8 { unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
// SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access. // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling malloc() is safe because preconditions on this function match the trait method preconditions. // Calling malloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock(); let _lock = lock::lock();
unsafe { DLMALLOC.malloc(layout.size(), layout.align()) } unsafe { DLMALLOC.malloc(layout.size(), layout.align()) }
@ -32,7 +32,7 @@ unsafe impl GlobalAlloc for System {
#[inline] #[inline]
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
// SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access. // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling calloc() is safe because preconditions on this function match the trait method preconditions. // Calling calloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock(); let _lock = lock::lock();
unsafe { DLMALLOC.calloc(layout.size(), layout.align()) } unsafe { DLMALLOC.calloc(layout.size(), layout.align()) }
@ -40,7 +40,7 @@ unsafe impl GlobalAlloc for System {
#[inline] #[inline]
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
// SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access. // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling free() is safe because preconditions on this function match the trait method preconditions. // Calling free() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock(); let _lock = lock::lock();
unsafe { DLMALLOC.free(ptr, layout.size(), layout.align()) } unsafe { DLMALLOC.free(ptr, layout.size(), layout.align()) }
@ -48,7 +48,7 @@ unsafe impl GlobalAlloc for System {
#[inline] #[inline]
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
// SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access. // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling realloc() is safe because preconditions on this function match the trait method preconditions. // Calling realloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock(); let _lock = lock::lock();
unsafe { DLMALLOC.realloc(ptr, layout.size(), layout.align(), new_size) } unsafe { DLMALLOC.realloc(ptr, layout.size(), layout.align(), new_size) }

View File

@ -73,7 +73,7 @@ pub struct ReentrantMutex {
unsafe impl Send for ReentrantMutex {} unsafe impl Send for ReentrantMutex {}
unsafe impl Sync for ReentrantMutex {} unsafe impl Sync for ReentrantMutex {}
// Reentrant mutexes are similarly implemented to mutexs above except that // Reentrant mutexes are similarly implemented to mutexes above except that
// instead of "1" meaning unlocked we use the id of a thread to represent // instead of "1" meaning unlocked we use the id of a thread to represent
// whether it has locked a mutex. That way we have an atomic counter which // whether it has locked a mutex. That way we have an atomic counter which
// always holds the id of the thread that currently holds the lock (or 0 if the // always holds the id of the thread that currently holds the lock (or 0 if the
@ -96,7 +96,7 @@ impl ReentrantMutex {
pub unsafe fn lock(&self) { pub unsafe fn lock(&self) {
let me = thread::my_id(); let me = thread::my_id();
while let Err(owner) = self._try_lock(me) { while let Err(owner) = self._try_lock(me) {
// SAFETY: the caller must gurantee that `self.ptr()` and `owner` are valid i32. // SAFETY: the caller must guarantee that `self.ptr()` and `owner` are valid i32.
let val = unsafe { wasm32::memory_atomic_wait32(self.ptr(), owner as i32, -1) }; let val = unsafe { wasm32::memory_atomic_wait32(self.ptr(), owner as i32, -1) };
debug_assert!(val == 0 || val == 1); debug_assert!(val == 0 || val == 1);
} }
@ -136,7 +136,7 @@ impl ReentrantMutex {
match *self.recursions.get() { match *self.recursions.get() {
0 => { 0 => {
self.owner.swap(0, SeqCst); self.owner.swap(0, SeqCst);
// SAFETY: the caller must gurantee that `self.ptr()` is valid i32. // SAFETY: the caller must guarantee that `self.ptr()` is valid i32.
unsafe { unsafe {
wasm32::memory_atomic_notify(self.ptr() as *mut i32, 1); wasm32::memory_atomic_notify(self.ptr() as *mut i32, 1);
} // wake up one waiter, if any } // wake up one waiter, if any

View File

@ -124,7 +124,7 @@ fn write(
// //
// If the data is not valid UTF-8 we write out as many bytes as are valid. // If the data is not valid UTF-8 we write out as many bytes as are valid.
// If the first byte is invalid it is either first byte of a multi-byte sequence but the // If the first byte is invalid it is either first byte of a multi-byte sequence but the
// provided byte slice is too short or it is the first byte of an invalide multi-byte sequence. // provided byte slice is too short or it is the first byte of an invalid multi-byte sequence.
let len = cmp::min(data.len(), MAX_BUFFER_SIZE / 2); let len = cmp::min(data.len(), MAX_BUFFER_SIZE / 2);
let utf8 = match str::from_utf8(&data[..len]) { let utf8 = match str::from_utf8(&data[..len]) {
Ok(s) => s, Ok(s) => s,

View File

@ -22,7 +22,7 @@
// //
// Unlike WaitOnAddress, NtWaitForKeyedEvent/NtReleaseKeyedEvent operate on a // Unlike WaitOnAddress, NtWaitForKeyedEvent/NtReleaseKeyedEvent operate on a
// HANDLE (created with NtCreateKeyedEvent). This means that we can be sure // HANDLE (created with NtCreateKeyedEvent). This means that we can be sure
// a succesfully awoken park() was awoken by unpark() and not a // a successfully awoken park() was awoken by unpark() and not a
// NtReleaseKeyedEvent call from some other code, as these events are not only // NtReleaseKeyedEvent call from some other code, as these events are not only
// matched by the key (address of the parker (state)), but also by this HANDLE. // matched by the key (address of the parker (state)), but also by this HANDLE.
// We lazily allocate this handle the first time it is needed. // We lazily allocate this handle the first time it is needed.

View File

@ -1,4 +1,4 @@
//! Parker implementaiton based on a Mutex and Condvar. //! Parker implementation based on a Mutex and Condvar.
use crate::sync::atomic::AtomicUsize; use crate::sync::atomic::AtomicUsize;
use crate::sync::atomic::Ordering::SeqCst; use crate::sync::atomic::Ordering::SeqCst;
@ -20,7 +20,7 @@ impl Parker {
Parker { state: AtomicUsize::new(EMPTY), lock: Mutex::new(()), cvar: Condvar::new() } Parker { state: AtomicUsize::new(EMPTY), lock: Mutex::new(()), cvar: Condvar::new() }
} }
// This implementaiton doesn't require `unsafe`, but other implementations // This implementation doesn't require `unsafe`, but other implementations
// may assume this is only called by the thread that owns the Parker. // may assume this is only called by the thread that owns the Parker.
pub unsafe fn park(&self) { pub unsafe fn park(&self) {
// If we were previously notified then we consume this notification and // If we were previously notified then we consume this notification and
@ -55,7 +55,7 @@ impl Parker {
} }
} }
// This implementaiton doesn't require `unsafe`, but other implementations // This implementation doesn't require `unsafe`, but other implementations
// may assume this is only called by the thread that owns the Parker. // may assume this is only called by the thread that owns the Parker.
pub unsafe fn park_timeout(&self, dur: Duration) { pub unsafe fn park_timeout(&self, dur: Duration) {
// Like `park` above we have a fast path for an already-notified thread, and // Like `park` above we have a fast path for an already-notified thread, and

View File

@ -582,7 +582,7 @@ pub mod fast {
Key { inner: LazyKeyInner::new(), dtor_state: Cell::new(DtorState::Unregistered) } Key { inner: LazyKeyInner::new(), dtor_state: Cell::new(DtorState::Unregistered) }
} }
// note that this is just a publically-callable function only for the // note that this is just a publicly-callable function only for the
// const-initialized form of thread locals, basically a way to call the // const-initialized form of thread locals, basically a way to call the
// free `register_dtor` function defined elsewhere in libstd. // free `register_dtor` function defined elsewhere in libstd.
pub unsafe fn register_dtor(a: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { pub unsafe fn register_dtor(a: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
@ -593,7 +593,7 @@ pub mod fast {
pub unsafe fn get<F: FnOnce() -> T>(&self, init: F) -> Option<&'static T> { pub unsafe fn get<F: FnOnce() -> T>(&self, init: F) -> Option<&'static T> {
// SAFETY: See the definitions of `LazyKeyInner::get` and // SAFETY: See the definitions of `LazyKeyInner::get` and
// `try_initialize` for more informations. // `try_initialize` for more information.
// //
// The caller must ensure no mutable references are ever active to // The caller must ensure no mutable references are ever active to
// the inner cell or the inner T when this is called. // the inner cell or the inner T when this is called.

View File

@ -273,7 +273,7 @@ impl Instant {
// While issues have been seen on arm64 platforms the Arm architecture // While issues have been seen on arm64 platforms the Arm architecture
// requires that the counter monotonically increases and that it must // requires that the counter monotonically increases and that it must
// provide a uniform view of system time (e.g. it must not be possible // provide a uniform view of system time (e.g. it must not be possible
// for a core to recieve a message from another core with a time stamp // for a core to receive a message from another core with a time stamp
// and observe time going backwards (ARM DDI 0487G.b D11.1.2). While // and observe time going backwards (ARM DDI 0487G.b D11.1.2). While
// there have been a few 64bit SoCs that have bugs which cause time to // there have been a few 64bit SoCs that have bugs which cause time to
// not monoticially increase, these have been fixed in the Linux kernel // not monoticially increase, these have been fixed in the Linux kernel