library: consistently use American spelling for 'behavior'

This commit is contained in:
Ralf Jung 2024-10-25 12:01:08 +02:00
parent 017ae1b21f
commit 854e3c43e0
46 changed files with 75 additions and 75 deletions

View File

@ -350,7 +350,7 @@ fn test_drain_forget() {
mem::forget(it);
}))
.unwrap();
// Behaviour after leaking is explicitly unspecified and order is arbitrary,
// Behavior after leaking is explicitly unspecified and order is arbitrary,
// so it's fine if these start failing, but probably worth knowing.
assert!(q.is_empty());
assert_eq!(a.dropped() + b.dropped() + c.dropped(), 1);
@ -377,7 +377,7 @@ fn test_drain_sorted_forget() {
mem::forget(it);
}))
.unwrap();
// Behaviour after leaking is explicitly unspecified,
// Behavior after leaking is explicitly unspecified,
// so it's fine if these start failing, but probably worth knowing.
assert_eq!(q.len(), 2);
assert_eq!(a.dropped(), 0);

View File

@ -1216,7 +1216,7 @@ fn pred_panic_reuse() {
{
let mut it = map.extract_if(|dummy, _| dummy.query(true));
catch_unwind(AssertUnwindSafe(|| while it.next().is_some() {})).unwrap_err();
// Iterator behaviour after a panic is explicitly unspecified,
// Iterator behavior after a panic is explicitly unspecified,
// so this is just the current implementation:
let result = catch_unwind(AssertUnwindSafe(|| it.next()));
assert!(matches!(result, Ok(None)));

View File

@ -3075,7 +3075,7 @@ pub fn allocator(&self) -> &A {
///
/// drop(strong);
/// // But not any more. We can do weak.as_ptr(), but accessing the pointer would lead to
/// // undefined behaviour.
/// // undefined behavior.
/// // assert_eq!("hello", unsafe { &*weak.as_ptr() });
/// ```
///

View File

@ -804,7 +804,7 @@ pub fn new_cyclic_in<F>(data_fn: F, alloc: A) -> Arc<T, A>
// observe a non-zero strong count. Therefore we need at least "Release" ordering
// in order to synchronize with the `compare_exchange_weak` in `Weak::upgrade`.
//
// "Acquire" ordering is not required. When considering the possible behaviours
// "Acquire" ordering is not required. When considering the possible behaviors
// of `data_fn` we only need to look at what it could do with a reference to a
// non-upgradeable `Weak`:
// - It can *clone* the `Weak`, increasing the weak reference count.
@ -2788,7 +2788,7 @@ pub fn allocator(&self) -> &A {
///
/// drop(strong);
/// // But not any more. We can do weak.as_ptr(), but accessing the pointer would lead to
/// // undefined behaviour.
/// // undefined behavior.
/// // assert_eq!("hello", unsafe { &*weak.as_ptr() });
/// ```
///

View File

@ -172,7 +172,7 @@ unsafe impl IsZero for $t {
fn is_zero(&self) -> bool {
// SAFETY: This is *not* a stable layout guarantee, but
// inside `core` we're allowed to rely on the current rustc
// behaviour that options of bools will be one byte with
// behavior that options of bools will be one byte with
// no padding, so long as they're nested less than 254 deep.
let raw: u8 = unsafe { core::mem::transmute(*self) };
raw == 0

View File

@ -173,7 +173,7 @@ pub unsafe trait GlobalAlloc {
/// # Safety
///
/// The caller has to ensure that `layout` has non-zero size. Like `alloc`
/// zero sized `layout` can result in undefined behaviour.
/// zero sized `layout` can result in undefined behavior.
/// However the allocated block of memory is guaranteed to be initialized.
///
/// # Errors
@ -234,7 +234,7 @@ unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
/// does not overflow `isize` (i.e., the rounded value must be less than or
/// equal to `isize::MAX`).
///
/// If these are not followed, undefined behaviour can result.
/// If these are not followed, undefined behavior can result.
///
/// (Extension subtraits might provide more specific bounds on
/// behavior, e.g., guarantee a sentinel address or a null pointer

View File

@ -1221,7 +1221,7 @@ pub fn undo_leak(&mut self) -> &mut T {
/// Unlike `RefCell::borrow`, this method is unsafe because it does not
/// return a `Ref`, thus leaving the borrow flag untouched. Mutably
/// borrowing the `RefCell` while the reference returned by this method
/// is alive is undefined behaviour.
/// is alive is undefined behavior.
///
/// # Examples
///

View File

@ -380,7 +380,7 @@ pub struct AssertParamIsEq<T: Eq + ?Sized> {
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
#[stable(feature = "rust1", since = "1.0.0")]
// This is a lang item only so that `BinOp::Cmp` in MIR can return it.
// It has no special behaviour, but does require that the three variants
// It has no special behavior, but does require that the three variants
// `Less`/`Equal`/`Greater` remain `-1_i8`/`0_i8`/`+1_i8` respectively.
#[lang = "Ordering"]
#[repr(i8)]

View File

@ -930,7 +930,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
/// on most platforms.
/// On Unix, the
/// process will probably terminate with a signal like `SIGABRT`, `SIGILL`, `SIGTRAP`, `SIGSEGV` or
/// `SIGBUS`. The precise behaviour is not guaranteed and not stable.
/// `SIGBUS`. The precise behavior is not guaranteed and not stable.
#[rustc_safe_intrinsic]
#[rustc_nounwind]
pub fn abort() -> !;
@ -1384,7 +1384,7 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// Like [`transmute`], but even less checked at compile-time: rather than
/// giving an error for `size_of::<Src>() != size_of::<Dst>()`, it's
/// **Undefined Behaviour** at runtime.
/// **Undefined Behavior** at runtime.
///
/// Prefer normal `transmute` where possible, for the extra checking, since
/// both do exactly the same thing at runtime, if they both compile.

View File

@ -298,7 +298,7 @@ fn UnwindContinue() -> UnwindActionArg
);
define!(
"mir_unwind_unreachable",
/// An unwind action that triggers undefined behaviour.
/// An unwind action that triggers undefined behavior.
fn UnwindUnreachable() -> UnwindActionArg
);
define!(

View File

@ -723,7 +723,7 @@ pub const fn as_mut_ptr(&mut self) -> *mut T {
/// this does not constitute a stable guarantee), because the only
/// requirement the compiler knows about it is that the data pointer must be
/// non-null. Dropping such a `Vec<T>` however will cause undefined
/// behaviour.
/// behavior.
///
/// [`assume_init`]: MaybeUninit::assume_init
/// [`Vec<T>`]: ../../std/vec/struct.Vec.html

View File

@ -355,7 +355,7 @@ pub const fn new(n: T) -> Option<Self> {
}
/// Creates a non-zero without checking whether the value is non-zero.
/// This results in undefined behaviour if the value is zero.
/// This results in undefined behavior if the value is zero.
///
/// # Safety
///
@ -952,9 +952,9 @@ pub const fn saturating_mul(self, other: Self) -> Self {
/// Multiplies two non-zero integers together,
/// assuming overflow cannot occur.
/// Overflow is unchecked, and it is undefined behaviour to overflow
/// Overflow is unchecked, and it is undefined behavior to overflow
/// *even if the result would wrap to a non-zero value*.
/// The behaviour is undefined as soon as
/// The behavior is undefined as soon as
#[doc = sign_dependent_expr!{
$signedness ?
if signed {
@ -1323,9 +1323,9 @@ pub const fn saturating_add(self, other: $Int) -> Self {
/// Adds an unsigned integer to a non-zero value,
/// assuming overflow cannot occur.
/// Overflow is unchecked, and it is undefined behaviour to overflow
/// Overflow is unchecked, and it is undefined behavior to overflow
/// *even if the result would wrap to a non-zero value*.
/// The behaviour is undefined as soon as
/// The behavior is undefined as soon as
#[doc = concat!("`self + rhs > ", stringify!($Int), "::MAX`.")]
///
/// # Examples
@ -1599,7 +1599,7 @@ pub const fn isqrt(self) -> Self {
/// Computes the absolute value of self.
#[doc = concat!("See [`", stringify!($Int), "::abs`]")]
/// for documentation on overflow behaviour.
/// for documentation on overflow behavior.
///
/// # Example
///
@ -1878,7 +1878,7 @@ pub const fn checked_neg(self) -> Option<Self> {
/// Negates self, overflowing if this is equal to the minimum value.
///
#[doc = concat!("See [`", stringify!($Int), "::overflowing_neg`]")]
/// for documentation on overflow behaviour.
/// for documentation on overflow behavior.
///
/// # Example
///
@ -1943,7 +1943,7 @@ pub const fn saturating_neg(self) -> Self {
/// of the type.
///
#[doc = concat!("See [`", stringify!($Int), "::wrapping_neg`]")]
/// for documentation on overflow behaviour.
/// for documentation on overflow behavior.
///
/// # Example
///

View File

@ -3086,7 +3086,7 @@ pub const fn checked_next_power_of_two(self) -> Option<Self> {
/// ```
#[inline]
#[unstable(feature = "wrapping_next_power_of_two", issue = "32463",
reason = "needs decision on wrapping behaviour")]
reason = "needs decision on wrapping behavior")]
#[rustc_const_unstable(feature = "wrapping_next_power_of_two", issue = "32463")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]

View File

@ -1043,7 +1043,7 @@ pub fn is_power_of_two(self) -> bool {
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[unstable(feature = "wrapping_next_power_of_two", issue = "32463",
reason = "needs decision on wrapping behaviour")]
reason = "needs decision on wrapping behavior")]
pub fn next_power_of_two(self) -> Self {
Wrapping(self.0.wrapping_next_power_of_two())
}

View File

@ -15,7 +15,7 @@
///
/// Types that implement `Deref` or `DerefMut` are often called "smart
/// pointers" and the mechanism of deref coercion has been specifically designed
/// to facilitate the pointer-like behaviour that name suggests. Often, the
/// to facilitate the pointer-like behavior that name suggests. Often, the
/// purpose of a "smart pointer" type is to change the ownership semantics
/// of a contained value (for example, [`Rc`][rc] or [`Cow`][cow]) or the
/// storage semantics of a contained value (for example, [`Box`][box]).
@ -42,7 +42,7 @@
/// 1. a value of the type transparently behaves like a value of the target
/// type;
/// 1. the implementation of the deref function is cheap; and
/// 1. users of the type will not be surprised by any deref coercion behaviour.
/// 1. users of the type will not be surprised by any deref coercion behavior.
///
/// In general, deref traits **should not** be implemented if:
///
@ -185,7 +185,7 @@ fn deref(&self) -> &T {
///
/// Types that implement `DerefMut` or `Deref` are often called "smart
/// pointers" and the mechanism of deref coercion has been specifically designed
/// to facilitate the pointer-like behaviour that name suggests. Often, the
/// to facilitate the pointer-like behavior that name suggests. Often, the
/// purpose of a "smart pointer" type is to change the ownership semantics
/// of a contained value (for example, [`Rc`][rc] or [`Cow`][cow]) or the
/// storage semantics of a contained value (for example, [`Box`][box]).

View File

@ -150,7 +150,7 @@
//! It is further guaranteed that, for the cases above, one can
//! [`mem::transmute`] from all valid values of `T` to `Option<T>` and
//! from `Some::<T>(_)` to `T` (but transmuting `None::<T>` to `T`
//! is undefined behaviour).
//! is undefined behavior).
//!
//! # Method overview
//!

View File

@ -100,7 +100,7 @@ mod prim_bool {}
///
/// Both match arms must produce values of type [`u32`], but since `break` never produces a value
/// at all we know it can never produce a value which isn't a [`u32`]. This illustrates another
/// behaviour of the `!` type - expressions with type `!` will coerce into any other type.
/// behavior of the `!` type - expressions with type `!` will coerce into any other type.
///
/// [`u32`]: prim@u32
/// [`exit`]: ../std/process/fn.exit.html
@ -134,7 +134,7 @@ mod prim_bool {}
///
/// Since the [`Err`] variant contains a `!`, it can never occur. If the `exhaustive_patterns`
/// feature is present this means we can exhaustively match on [`Result<T, !>`] by just taking the
/// [`Ok`] variant. This illustrates another behaviour of `!` - it can be used to "delete" certain
/// [`Ok`] variant. This illustrates another behavior of `!` - it can be used to "delete" certain
/// enum variants from generic types like `Result`.
///
/// ## Infinite loops
@ -351,7 +351,7 @@ mod prim_never {}
/// ```
///
/// ```no_run
/// // Undefined behaviour
/// // Undefined behavior
/// let _ = unsafe { char::from_u32_unchecked(0x110000) };
/// ```
///
@ -568,7 +568,7 @@ impl () {}
/// Instead of coercing a reference to a raw pointer, you can use the macros
/// [`ptr::addr_of!`] (for `*const T`) and [`ptr::addr_of_mut!`] (for `*mut T`).
/// These macros allow you to create raw pointers to fields to which you cannot
/// create a reference (without causing undefined behaviour), such as an
/// create a reference (without causing undefined behavior), such as an
/// unaligned field. This might be necessary if packed structs or uninitialized
/// memory is involved.
///
@ -1453,7 +1453,7 @@ mod prim_usize {}
/// <code>&[bool]</code> can only point to an allocation containing the integer values `1`
/// ([`true`](../std/keyword.true.html)) or `0` ([`false`](../std/keyword.false.html)), but
/// creating a <code>&[bool]</code> that points to an allocation containing
/// the value `3` causes undefined behaviour.
/// the value `3` causes undefined behavior.
/// In fact, <code>[Option]\<&T></code> has the same memory representation as a
/// nullable but aligned pointer, and can be passed across FFI boundaries as such.
///

View File

@ -134,7 +134,7 @@
//! # Provenance
//!
//! Pointers are not *simply* an "integer" or "address". For instance, it's uncontroversial
//! to say that a Use After Free is clearly Undefined Behaviour, even if you "get lucky"
//! to say that a Use After Free is clearly Undefined Behavior, even if you "get lucky"
//! and the freed memory gets reallocated before your read/write (in fact this is the
//! worst-case scenario, UAFs would be much less concerning if this didn't happen!).
//! As another example, consider that [`wrapping_offset`] is documented to "remember"
@ -1125,7 +1125,7 @@ macro_rules! attempt_swap_as_chunks {
unsafe { swap_nonoverlapping_simple_untyped(x, y, count) }
}
/// Same behaviour and safety conditions as [`swap_nonoverlapping`]
/// Same behavior and safety conditions as [`swap_nonoverlapping`]
///
/// LLVM can vectorize this (at least it can for the power-of-two-sized types
/// `swap_nonoverlapping` tries to use) so no need to manually SIMD it.

View File

@ -57,9 +57,9 @@
/// [`Searcher`] type, which does the actual work of finding
/// occurrences of the pattern in a string.
///
/// Depending on the type of the pattern, the behaviour of methods like
/// Depending on the type of the pattern, the behavior of methods like
/// [`str::find`] and [`str::contains`] can change. The table below describes
/// some of those behaviours.
/// some of those behaviors.
///
/// | Pattern type | Match condition |
/// |--------------------------|-------------------------------------------|

View File

@ -113,7 +113,7 @@ fn test_rotate() {
// Rotating these should make no difference
//
// We test using 124 bits because to ensure that overlong bit shifts do
// not cause undefined behaviour. See #10183.
// not cause undefined behavior. See #10183.
assert_eq_const_safe!(_0.rotate_left(124), _0);
assert_eq_const_safe!(_1.rotate_left(124), _1);
assert_eq_const_safe!(_0.rotate_right(124), _0);

View File

@ -79,7 +79,7 @@ fn test_rotate() {
// Rotating these should make no difference
//
// We test using 124 bits because to ensure that overlong bit shifts do
// not cause undefined behaviour. See #10183.
// not cause undefined behavior. See #10183.
assert_eq_const_safe!(_0.rotate_left(124), _0);
assert_eq_const_safe!(_1.rotate_left(124), _1);
assert_eq_const_safe!(_0.rotate_right(124), _0);

View File

@ -76,7 +76,7 @@ fn is_valid_ascii_ident(bytes: &[u8]) -> bool {
.all(|b| matches!(b, b'_' | b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9'))
}
// Mimics the behaviour of `Symbol::can_be_raw` from `rustc_span`
// Mimics the behavior of `Symbol::can_be_raw` from `rustc_span`
fn can_be_raw(string: &str) -> bool {
match string {
"_" | "super" | "self" | "Self" | "crate" => false,

View File

@ -1098,7 +1098,7 @@ fn drop(&mut self) {
_ => panic!(),
});
catch_unwind(AssertUnwindSafe(|| while it.next().is_some() {})).unwrap_err();
// Iterator behaviour after a panic is explicitly unspecified,
// Iterator behavior after a panic is explicitly unspecified,
// so this is just the current implementation:
let result = catch_unwind(AssertUnwindSafe(|| it.next()));
assert!(result.is_err());

View File

@ -618,7 +618,7 @@ fn description(&self) -> &str {
///
/// # Deprecation
///
/// This function is deprecated because the behaviour on Windows is not correct.
/// This function is deprecated because the behavior on Windows is not correct.
/// The 'HOME' environment variable is not standard on Windows, and may not produce
/// desired results; for instance, under Cygwin or Mingw it will return `/home/you`
/// when it should return `C:\Users\you`.

View File

@ -153,7 +153,7 @@ fn read_exact_at(&self, mut buf: &mut [u8], mut offset: u64) -> io::Result<()> {
///
/// It is possible to inadvertently set this flag, like in the example below.
/// Therefore, it is important to be vigilant while changing options to mitigate
/// unexpected behaviour.
/// unexpected behavior.
///
/// ```no_run
/// use std::fs::File;

View File

@ -1167,7 +1167,7 @@ impl FusedIterator for Ancestors<'_> {}
/// path.push(r"..\otherdir");
/// path.push("system32");
///
/// The behaviour of `PathBuf` may be changed to a panic on such inputs
/// The behavior of `PathBuf` may be changed to a panic on such inputs
/// in the future. [`Extend::extend`] should be used to add multi-part paths.
#[cfg_attr(not(test), rustc_diagnostic_item = "PathBuf")]
#[stable(feature = "rust1", since = "1.0.0")]
@ -1409,7 +1409,7 @@ pub fn pop(&mut self) -> bool {
/// (That is, it will have the same parent.)
///
/// The argument is not sanitized, so can include separators. This
/// behaviour may be changed to a panic in the future.
/// behavior may be changed to a panic in the future.
///
/// [`self.file_name`]: Path::file_name
/// [`pop`]: PathBuf::pop

View File

@ -119,7 +119,7 @@
//! when given a `.bat` file as the application to run, it will automatically
//! convert that into running `cmd.exe /c` with the batch file as the next argument.
//!
//! For historical reasons Rust currently preserves this behaviour when using
//! For historical reasons Rust currently preserves this behavior when using
//! [`Command::new`], and escapes the arguments according to `cmd.exe` rules.
//! Due to the complexity of `cmd.exe` argument handling, it might not be
//! possible to safely escape some special characters, and using them will result
@ -2318,7 +2318,7 @@ pub fn exit(code: i32) -> ! {
/// Rust IO buffers (eg, from `BufWriter`) will not be flushed.
/// Likewise, C stdio buffers will (on most platforms) not be flushed.
///
/// This is in contrast to the default behaviour of [`panic!`] which unwinds
/// This is in contrast to the default behavior of [`panic!`] which unwinds
/// the current thread's stack and calls all destructors.
/// When `panic="abort"` is set, either as an argument to `rustc` or in a
/// crate's Cargo.toml, [`panic!`] and `abort` are similar. However,

View File

@ -484,7 +484,7 @@ pub(crate) unsafe fn disconnect_receivers(&self) -> bool {
///
/// # Panicking
/// If a destructor panics, the remaining messages are leaked, matching the
/// behaviour of the unbounded channel.
/// behavior of the unbounded channel.
///
/// # Safety
/// This method must only be called when dropping the last receiver. The

View File

@ -288,7 +288,7 @@ pub fn is_completed(&self) -> bool {
///
/// If this [`Once`] has been poisoned because an initialization closure has
/// panicked, this method will also panic. Use [`wait_force`](Self::wait_force)
/// if this behaviour is not desired.
/// if this behavior is not desired.
#[unstable(feature = "once_wait", issue = "127527")]
pub fn wait(&self) {
if !self.inner.is_completed() {

View File

@ -273,7 +273,7 @@ pub fn into_raw(&self) -> c_int {
// We don't know what someone who calls into_raw() will do with this value, but it should
// have the conventional Unix representation. Despite the fact that this is not
// standardised in SuS or POSIX, all Unix systems encode the signal and exit status the
// same way. (Ie the WIFEXITED, WEXITSTATUS etc. macros have identical behaviour on every
// same way. (Ie the WIFEXITED, WEXITSTATUS etc. macros have identical behavior on every
// Unix.)
//
// The caller of `std::os::unix::into_raw` is probably wanting a Unix exit status, and may

View File

@ -1159,7 +1159,7 @@ pub fn symlink_inner(original: &Path, link: &Path, dir: bool) -> io::Result<()>
// Formerly, symlink creation required the SeCreateSymbolicLink privilege. For the Windows 10
// Creators Update, Microsoft loosened this to allow unprivileged symlink creation if the
// computer is in Developer Mode, but SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE must be
// added to dwFlags to opt into this behaviour.
// added to dwFlags to opt into this behavior.
let result = cvt(unsafe {
c::CreateSymbolicLinkW(
link.as_ptr(),

View File

@ -47,7 +47,7 @@ fn new<T: Into<OsString>>(key: T) -> Self {
}
}
// Comparing Windows environment variable keys[1] are behaviourally the
// Comparing Windows environment variable keys[1] are behaviorally the
// composition of two operations[2]:
//
// 1. Case-fold both strings. This is done using a language-independent
@ -338,8 +338,8 @@ pub fn spawn(
// If at least one of stdin, stdout or stderr are set (i.e. are non null)
// then set the `hStd` fields in `STARTUPINFO`.
// Otherwise skip this and allow the OS to apply its default behaviour.
// This provides more consistent behaviour between Win7 and Win8+.
// Otherwise skip this and allow the OS to apply its default behavior.
// This provides more consistent behavior between Win7 and Win8+.
let is_set = |stdio: &Handle| !stdio.as_raw_handle().is_null();
if is_set(&stderr) || is_set(&stdout) || is_set(&stdin) {
si.dwFlags |= c::STARTF_USESTDHANDLES;
@ -507,7 +507,7 @@ fn search_paths<Paths, Exists>(
Exists: FnMut(PathBuf) -> Option<Vec<u16>>,
{
// 1. Child paths
// This is for consistency with Rust's historic behaviour.
// This is for consistency with Rust's historic behavior.
if let Some(paths) = child_paths {
for path in env::split_paths(paths).filter(|p| !p.as_os_str().is_empty()) {
if let Some(path) = exists(path) {

View File

@ -191,7 +191,7 @@ fn windows_exe_resolver() {
/*
Some of the following tests may need to be changed if you are deliberately
changing the behaviour of `resolve_exe`.
changing the behavior of `resolve_exe`.
*/
let empty_paths = || None;

View File

@ -99,7 +99,7 @@ fn high_precision_sleep(dur: Duration) -> Result<(), ()> {
}
// Attempt to use high-precision sleep (Windows 10, version 1803+).
// On error fallback to the standard `Sleep` function.
// Also preserves the zero duration behaviour of `Sleep`.
// Also preserves the zero duration behavior of `Sleep`.
if dur.is_zero() || high_precision_sleep(dur).is_err() {
unsafe { c::Sleep(super::dur2timeout(dur)) }
}

View File

@ -119,7 +119,7 @@ fn test_windows_prefix_components() {
/// See #101358.
///
/// Note that the exact behaviour here may change in the future.
/// Note that the exact behavior here may change in the future.
/// In which case this test will need to adjusted.
#[test]
fn broken_unc_path() {

View File

@ -30,7 +30,7 @@
//! data the system has available at the time.
//!
//! So in conclusion, we always want the output of the non-blocking pool, but
//! may need to wait until it is initalized. The default behaviour of `getrandom`
//! may need to wait until it is initalized. The default behavior of `getrandom`
//! is to wait until the non-blocking pool is initialized and then draw from there,
//! so if `getrandom` is available, we use its default to generate the bytes. For
//! `HashMap`, however, we need to specify the `GRND_INSECURE` flags, but that
@ -39,7 +39,7 @@
//! succeed if the pool is initialized. If it isn't, we fall back to the file
//! access method.
//!
//! The behaviour of `/dev/urandom` is inverse to that of `getrandom`: it always
//! The behavior of `/dev/urandom` is inverse to that of `getrandom`: it always
//! yields data, even when the pool is not initialized. For generating `HashMap`
//! keys, this is not important, so we can use it directly. For secure data
//! however, we need to wait until initialization, which we can do by `poll`ing

View File

@ -66,7 +66,7 @@ fn drop(&mut self) {
// On DragonFly pthread_cond_destroy() returns EINVAL if called on
// a condvar that was just initialized with
// libc::PTHREAD_COND_INITIALIZER. Once it is used or
// pthread_cond_init() is called, this behaviour no longer occurs.
// pthread_cond_init() is called, this behavior no longer occurs.
debug_assert!(r == 0 || r == libc::EINVAL);
} else {
debug_assert_eq!(r, 0);

View File

@ -65,7 +65,7 @@ fn drop(&mut self) {
// On DragonFly pthread_mutex_destroy() returns EINVAL if called on a
// mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER.
// Once it is used (locked/unlocked) or pthread_mutex_init() is called,
// this behaviour no longer occurs.
// this behavior no longer occurs.
debug_assert!(r == 0 || r == libc::EINVAL);
} else {
debug_assert_eq!(r, 0);
@ -88,7 +88,7 @@ pub const fn new() -> Mutex {
/// since the `lock` and the lock must have occurred on the current thread.
///
/// # Safety
/// Causes undefined behaviour if the mutex is not locked.
/// Causes undefined behavior if the mutex is not locked.
#[inline]
pub(crate) unsafe fn get_assert_locked(&self) -> *mut libc::pthread_mutex_t {
unsafe { self.inner.get_unchecked().0.get() }

View File

@ -36,7 +36,7 @@ pub const fn new() -> Self {
/// ```
///
/// # Safety
/// This causes undefined behaviour if the assumption above is violated.
/// This causes undefined behavior if the assumption above is violated.
#[inline]
pub unsafe fn get_unchecked(&self) -> &T {
unsafe { &*self.ptr.load(Relaxed) }

View File

@ -283,7 +283,7 @@ fn wake_writer(&self) -> bool {
futex_wake(&self.writer_notify)
// Note that FreeBSD and DragonFlyBSD don't tell us whether they woke
// up any threads or not, and always return `false` here. That still
// results in correct behaviour: it just means readers get woken up as
// results in correct behavior: it just means readers get woken up as
// well in case both readers and writers were waiting.
}

View File

@ -8,7 +8,7 @@
//! * `pthread` is an external library, meaning the fast path of acquiring an
//! uncontended lock cannot be inlined.
//! * Some platforms (at least glibc before version 2.25) have buggy implementations
//! that can easily lead to undefined behaviour in safe Rust code when not properly
//! that can easily lead to undefined behavior in safe Rust code when not properly
//! guarded against.
//! * On some platforms (e.g. macOS), the lock is very slow.
//!

View File

@ -5,7 +5,7 @@
//! rejection from the App Store).
//!
//! Therefore, we need to look for other synchronization primitives. Luckily, Darwin
//! supports semaphores, which allow us to implement the behaviour we need with
//! supports semaphores, which allow us to implement the behavior we need with
//! only one primitive (as opposed to a mutex-condvar pair). We use the semaphore
//! provided by libdispatch, as the underlying Mach semaphore is only dubiously
//! public.

View File

@ -97,7 +97,7 @@ impl Parker {
/// The constructed parker must never be moved.
pub unsafe fn new_in_place(parker: *mut Parker) {
// Use the default mutex implementation to allow for simpler initialization.
// This could lead to undefined behaviour when deadlocking. This is avoided
// This could lead to undefined behavior when deadlocking. This is avoided
// by not deadlocking. Note in particular the unlocking operation before any
// panic, as code after the panic could try to park again.
(&raw mut (*parker).state).write(AtomicUsize::new(EMPTY));

View File

@ -35,7 +35,7 @@
// different implementations.
//
// Unfortunately, NT Keyed Events are an undocumented Windows API. However:
// - This API is relatively simple with obvious behaviour, and there are
// - This API is relatively simple with obvious behavior, and there are
// several (unofficial) articles documenting the details. [1]
// - `parking_lot` has been using this API for years (on Windows versions
// before Windows 8). [2] Many big projects extensively use parking_lot,
@ -43,7 +43,7 @@
// - It is the underlying API used by Windows SRW locks and Windows critical
// sections. [3] [4]
// - The source code of the implementations of Wine, ReactOs, and Windows XP
// are available and match the expected behaviour.
// are available and match the expected behavior.
// - The main risk with an undocumented API is that it might change in the
// future. But since we only use it for older versions of Windows, that's not
// a problem.

View File

@ -878,7 +878,7 @@ pub fn sleep(dur: Duration) {
///
/// # Platform-specific behavior
///
/// This function uses [`sleep`] internally, see its platform-specific behaviour.
/// This function uses [`sleep`] internally, see its platform-specific behavior.
///
///
/// # Examples
@ -949,7 +949,7 @@ pub fn sleep_until(deadline: Instant) {
}
/// Used to ensure that `park` and `park_timeout` do not unwind, as that can
/// cause undefined behaviour if not handled correctly (see #102398 for context).
/// cause undefined behavior if not handled correctly (see #102398 for context).
struct PanicGuard;
impl Drop for PanicGuard {

View File

@ -178,9 +178,9 @@
/// system.
///
/// A `SystemTime` does not count leap seconds.
/// `SystemTime::now()`'s behaviour around a leap second
/// `SystemTime::now()`'s behavior around a leap second
/// is the same as the operating system's wall clock.
/// The precise behaviour near a leap second
/// The precise behavior near a leap second
/// (e.g. whether the clock appears to run slow or fast, or stop, or jump)
/// depends on platform and configuration,
/// so should not be relied on.