1
Fork 0

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); mem::forget(it);
})) }))
.unwrap(); .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. // so it's fine if these start failing, but probably worth knowing.
assert!(q.is_empty()); assert!(q.is_empty());
assert_eq!(a.dropped() + b.dropped() + c.dropped(), 1); assert_eq!(a.dropped() + b.dropped() + c.dropped(), 1);
@ -377,7 +377,7 @@ fn test_drain_sorted_forget() {
mem::forget(it); mem::forget(it);
})) }))
.unwrap(); .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. // so it's fine if these start failing, but probably worth knowing.
assert_eq!(q.len(), 2); assert_eq!(q.len(), 2);
assert_eq!(a.dropped(), 0); assert_eq!(a.dropped(), 0);

View file

@ -1216,7 +1216,7 @@ mod test_extract_if {
{ {
let mut it = map.extract_if(|dummy, _| dummy.query(true)); let mut it = map.extract_if(|dummy, _| dummy.query(true));
catch_unwind(AssertUnwindSafe(|| while it.next().is_some() {})).unwrap_err(); 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: // so this is just the current implementation:
let result = catch_unwind(AssertUnwindSafe(|| it.next())); let result = catch_unwind(AssertUnwindSafe(|| it.next()));
assert!(matches!(result, Ok(None))); assert!(matches!(result, Ok(None)));

View file

@ -3075,7 +3075,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
/// ///
/// drop(strong); /// drop(strong);
/// // But not any more. We can do weak.as_ptr(), but accessing the pointer would lead to /// // 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() }); /// // assert_eq!("hello", unsafe { &*weak.as_ptr() });
/// ``` /// ```
/// ///

View file

@ -804,7 +804,7 @@ impl<T, A: Allocator> Arc<T, A> {
// observe a non-zero strong count. Therefore we need at least "Release" ordering // 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`. // 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 // of `data_fn` we only need to look at what it could do with a reference to a
// non-upgradeable `Weak`: // non-upgradeable `Weak`:
// - It can *clone* the `Weak`, increasing the weak reference count. // - It can *clone* the `Weak`, increasing the weak reference count.
@ -2788,7 +2788,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
/// ///
/// drop(strong); /// drop(strong);
/// // But not any more. We can do weak.as_ptr(), but accessing the pointer would lead to /// // 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() }); /// // assert_eq!("hello", unsafe { &*weak.as_ptr() });
/// ``` /// ```
/// ///

View file

@ -172,7 +172,7 @@ macro_rules! impl_is_zero_option_of_bool {
fn is_zero(&self) -> bool { fn is_zero(&self) -> bool {
// SAFETY: This is *not* a stable layout guarantee, but // SAFETY: This is *not* a stable layout guarantee, but
// inside `core` we're allowed to rely on the current rustc // 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. // no padding, so long as they're nested less than 254 deep.
let raw: u8 = unsafe { core::mem::transmute(*self) }; let raw: u8 = unsafe { core::mem::transmute(*self) };
raw == 0 raw == 0

View file

@ -173,7 +173,7 @@ pub unsafe trait GlobalAlloc {
/// # Safety /// # Safety
/// ///
/// The caller has to ensure that `layout` has non-zero size. Like `alloc` /// 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. /// However the allocated block of memory is guaranteed to be initialized.
/// ///
/// # Errors /// # Errors
@ -234,7 +234,7 @@ pub unsafe trait GlobalAlloc {
/// does not overflow `isize` (i.e., the rounded value must be less than or /// does not overflow `isize` (i.e., the rounded value must be less than or
/// equal to `isize::MAX`). /// 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 /// (Extension subtraits might provide more specific bounds on
/// behavior, e.g., guarantee a sentinel address or a null pointer /// behavior, e.g., guarantee a sentinel address or a null pointer

View file

@ -1221,7 +1221,7 @@ impl<T: ?Sized> RefCell<T> {
/// Unlike `RefCell::borrow`, this method is unsafe because it does not /// Unlike `RefCell::borrow`, this method is unsafe because it does not
/// return a `Ref`, thus leaving the borrow flag untouched. Mutably /// return a `Ref`, thus leaving the borrow flag untouched. Mutably
/// borrowing the `RefCell` while the reference returned by this method /// borrowing the `RefCell` while the reference returned by this method
/// is alive is undefined behaviour. /// is alive is undefined behavior.
/// ///
/// # Examples /// # Examples
/// ///

View file

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

View file

@ -930,7 +930,7 @@ extern "rust-intrinsic" {
/// on most platforms. /// on most platforms.
/// On Unix, the /// On Unix, the
/// process will probably terminate with a signal like `SIGABRT`, `SIGILL`, `SIGTRAP`, `SIGSEGV` or /// 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_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn abort() -> !; pub fn abort() -> !;
@ -1384,7 +1384,7 @@ extern "rust-intrinsic" {
/// Like [`transmute`], but even less checked at compile-time: rather than /// Like [`transmute`], but even less checked at compile-time: rather than
/// giving an error for `size_of::<Src>() != size_of::<Dst>()`, it's /// 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 /// Prefer normal `transmute` where possible, for the extra checking, since
/// both do exactly the same thing at runtime, if they both compile. /// both do exactly the same thing at runtime, if they both compile.

View file

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

View file

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

View file

@ -355,7 +355,7 @@ where
} }
/// Creates a non-zero without checking whether the value is non-zero. /// 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 /// # Safety
/// ///
@ -952,9 +952,9 @@ macro_rules! nonzero_integer {
/// Multiplies two non-zero integers together, /// Multiplies two non-zero integers together,
/// assuming overflow cannot occur. /// 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*. /// *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!{ #[doc = sign_dependent_expr!{
$signedness ? $signedness ?
if signed { if signed {
@ -1323,9 +1323,9 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
/// Adds an unsigned integer to a non-zero value, /// Adds an unsigned integer to a non-zero value,
/// assuming overflow cannot occur. /// 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*. /// *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`.")] #[doc = concat!("`self + rhs > ", stringify!($Int), "::MAX`.")]
/// ///
/// # Examples /// # Examples
@ -1599,7 +1599,7 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
/// Computes the absolute value of self. /// Computes the absolute value of self.
#[doc = concat!("See [`", stringify!($Int), "::abs`]")] #[doc = concat!("See [`", stringify!($Int), "::abs`]")]
/// for documentation on overflow behaviour. /// for documentation on overflow behavior.
/// ///
/// # Example /// # Example
/// ///
@ -1878,7 +1878,7 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
/// Negates self, overflowing if this is equal to the minimum value. /// Negates self, overflowing if this is equal to the minimum value.
/// ///
#[doc = concat!("See [`", stringify!($Int), "::overflowing_neg`]")] #[doc = concat!("See [`", stringify!($Int), "::overflowing_neg`]")]
/// for documentation on overflow behaviour. /// for documentation on overflow behavior.
/// ///
/// # Example /// # Example
/// ///
@ -1943,7 +1943,7 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
/// of the type. /// of the type.
/// ///
#[doc = concat!("See [`", stringify!($Int), "::wrapping_neg`]")] #[doc = concat!("See [`", stringify!($Int), "::wrapping_neg`]")]
/// for documentation on overflow behaviour. /// for documentation on overflow behavior.
/// ///
/// # Example /// # Example
/// ///

View file

@ -3086,7 +3086,7 @@ macro_rules! uint_impl {
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "wrapping_next_power_of_two", issue = "32463", #[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")] #[rustc_const_unstable(feature = "wrapping_next_power_of_two", issue = "32463")]
#[must_use = "this returns the result of the operation, \ #[must_use = "this returns the result of the operation, \
without modifying the original"] without modifying the original"]

View file

@ -1043,7 +1043,7 @@ macro_rules! wrapping_int_impl_unsigned {
#[must_use = "this returns the result of the operation, \ #[must_use = "this returns the result of the operation, \
without modifying the original"] without modifying the original"]
#[unstable(feature = "wrapping_next_power_of_two", issue = "32463", #[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 { pub fn next_power_of_two(self) -> Self {
Wrapping(self.0.wrapping_next_power_of_two()) Wrapping(self.0.wrapping_next_power_of_two())
} }

View file

@ -15,7 +15,7 @@
/// ///
/// Types that implement `Deref` or `DerefMut` are often called "smart /// Types that implement `Deref` or `DerefMut` are often called "smart
/// pointers" and the mechanism of deref coercion has been specifically designed /// 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 /// 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 /// of a contained value (for example, [`Rc`][rc] or [`Cow`][cow]) or the
/// storage semantics of a contained value (for example, [`Box`][box]). /// 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 /// 1. a value of the type transparently behaves like a value of the target
/// type; /// type;
/// 1. the implementation of the deref function is cheap; and /// 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: /// In general, deref traits **should not** be implemented if:
/// ///
@ -185,7 +185,7 @@ impl<T: ?Sized> Deref for &mut T {
/// ///
/// Types that implement `DerefMut` or `Deref` are often called "smart /// Types that implement `DerefMut` or `Deref` are often called "smart
/// pointers" and the mechanism of deref coercion has been specifically designed /// 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 /// 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 /// of a contained value (for example, [`Rc`][rc] or [`Cow`][cow]) or the
/// storage semantics of a contained value (for example, [`Box`][box]). /// 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 //! It is further guaranteed that, for the cases above, one can
//! [`mem::transmute`] from all valid values of `T` to `Option<T>` and //! [`mem::transmute`] from all valid values of `T` to `Option<T>` and
//! from `Some::<T>(_)` to `T` (but transmuting `None::<T>` to `T` //! from `Some::<T>(_)` to `T` (but transmuting `None::<T>` to `T`
//! is undefined behaviour). //! is undefined behavior).
//! //!
//! # Method overview //! # 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 /// 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 /// 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 /// [`u32`]: prim@u32
/// [`exit`]: ../std/process/fn.exit.html /// [`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` /// 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 /// 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`. /// enum variants from generic types like `Result`.
/// ///
/// ## Infinite loops /// ## Infinite loops
@ -351,7 +351,7 @@ mod prim_never {}
/// ``` /// ```
/// ///
/// ```no_run /// ```no_run
/// // Undefined behaviour /// // Undefined behavior
/// let _ = unsafe { char::from_u32_unchecked(0x110000) }; /// 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 /// 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`). /// [`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 /// 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 /// unaligned field. This might be necessary if packed structs or uninitialized
/// memory is involved. /// memory is involved.
/// ///
@ -1453,7 +1453,7 @@ mod prim_usize {}
/// <code>&[bool]</code> can only point to an allocation containing the integer values `1` /// <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 /// ([`true`](../std/keyword.true.html)) or `0` ([`false`](../std/keyword.false.html)), but
/// creating a <code>&[bool]</code> that points to an allocation containing /// 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 /// 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. /// nullable but aligned pointer, and can be passed across FFI boundaries as such.
/// ///

View file

@ -134,7 +134,7 @@
//! # Provenance //! # Provenance
//! //!
//! Pointers are not *simply* an "integer" or "address". For instance, it's uncontroversial //! 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 //! 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!). //! 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" //! As another example, consider that [`wrapping_offset`] is documented to "remember"
@ -1125,7 +1125,7 @@ pub const unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
unsafe { swap_nonoverlapping_simple_untyped(x, y, count) } 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 /// 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. /// `swap_nonoverlapping` tries to use) so no need to manually SIMD it.

View file

@ -57,9 +57,9 @@ use crate::{cmp, fmt};
/// [`Searcher`] type, which does the actual work of finding /// [`Searcher`] type, which does the actual work of finding
/// occurrences of the pattern in a string. /// 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 /// [`str::find`] and [`str::contains`] can change. The table below describes
/// some of those behaviours. /// some of those behaviors.
/// ///
/// | Pattern type | Match condition | /// | Pattern type | Match condition |
/// |--------------------------|-------------------------------------------| /// |--------------------------|-------------------------------------------|

View file

@ -113,7 +113,7 @@ macro_rules! int_module {
// Rotating these should make no difference // Rotating these should make no difference
// //
// We test using 124 bits because to ensure that overlong bit shifts do // 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!(_0.rotate_left(124), _0);
assert_eq_const_safe!(_1.rotate_left(124), _1); assert_eq_const_safe!(_1.rotate_left(124), _1);
assert_eq_const_safe!(_0.rotate_right(124), _0); assert_eq_const_safe!(_0.rotate_right(124), _0);

View file

@ -79,7 +79,7 @@ macro_rules! uint_module {
// Rotating these should make no difference // Rotating these should make no difference
// //
// We test using 124 bits because to ensure that overlong bit shifts do // 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!(_0.rotate_left(124), _0);
assert_eq_const_safe!(_1.rotate_left(124), _1); assert_eq_const_safe!(_1.rotate_left(124), _1);
assert_eq_const_safe!(_0.rotate_right(124), _0); assert_eq_const_safe!(_0.rotate_right(124), _0);

View file

@ -76,7 +76,7 @@ impl Symbol {
.all(|b| matches!(b, b'_' | b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9')) .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 { fn can_be_raw(string: &str) -> bool {
match string { match string {
"_" | "super" | "self" | "Self" | "crate" => false, "_" | "super" | "self" | "Self" | "crate" => false,

View file

@ -1098,7 +1098,7 @@ mod test_extract_if {
_ => panic!(), _ => panic!(),
}); });
catch_unwind(AssertUnwindSafe(|| while it.next().is_some() {})).unwrap_err(); 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: // so this is just the current implementation:
let result = catch_unwind(AssertUnwindSafe(|| it.next())); let result = catch_unwind(AssertUnwindSafe(|| it.next()));
assert!(result.is_err()); assert!(result.is_err());

View file

@ -618,7 +618,7 @@ impl Error for JoinPathsError {
/// ///
/// # Deprecation /// # 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 /// 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` /// desired results; for instance, under Cygwin or Mingw it will return `/home/you`
/// when it should return `C:\Users\you`. /// when it should return `C:\Users\you`.

View file

@ -153,7 +153,7 @@ pub trait FileExt {
/// ///
/// It is possible to inadvertently set this flag, like in the example below. /// 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 /// Therefore, it is important to be vigilant while changing options to mitigate
/// unexpected behaviour. /// unexpected behavior.
/// ///
/// ```no_run /// ```no_run
/// use std::fs::File; /// use std::fs::File;

View file

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

View file

@ -119,7 +119,7 @@
//! when given a `.bat` file as the application to run, it will automatically //! 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. //! 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. //! [`Command::new`], and escapes the arguments according to `cmd.exe` rules.
//! Due to the complexity of `cmd.exe` argument handling, it might not be //! 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 //! 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. /// Rust IO buffers (eg, from `BufWriter`) will not be flushed.
/// Likewise, C stdio buffers will (on most platforms) 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. /// the current thread's stack and calls all destructors.
/// When `panic="abort"` is set, either as an argument to `rustc` or in a /// When `panic="abort"` is set, either as an argument to `rustc` or in a
/// crate's Cargo.toml, [`panic!`] and `abort` are similar. However, /// crate's Cargo.toml, [`panic!`] and `abort` are similar. However,

View file

@ -484,7 +484,7 @@ impl<T> Channel<T> {
/// ///
/// # Panicking /// # Panicking
/// If a destructor panics, the remaining messages are leaked, matching the /// If a destructor panics, the remaining messages are leaked, matching the
/// behaviour of the unbounded channel. /// behavior of the unbounded channel.
/// ///
/// # Safety /// # Safety
/// This method must only be called when dropping the last receiver. The /// This method must only be called when dropping the last receiver. The

View file

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

View file

@ -273,7 +273,7 @@ impl ExitStatus {
// We don't know what someone who calls into_raw() will do with this value, but it should // 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 // 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 // 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.) // Unix.)
// //
// The caller of `std::os::unix::into_raw` is probably wanting a Unix exit status, and may // 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 // Formerly, symlink creation required the SeCreateSymbolicLink privilege. For the Windows 10
// Creators Update, Microsoft loosened this to allow unprivileged symlink creation if the // 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 // 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 { let result = cvt(unsafe {
c::CreateSymbolicLinkW( c::CreateSymbolicLinkW(
link.as_ptr(), link.as_ptr(),

View file

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

View file

@ -99,7 +99,7 @@ impl Thread {
} }
// Attempt to use high-precision sleep (Windows 10, version 1803+). // Attempt to use high-precision sleep (Windows 10, version 1803+).
// On error fallback to the standard `Sleep` function. // 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() { if dur.is_zero() || high_precision_sleep(dur).is_err() {
unsafe { c::Sleep(super::dur2timeout(dur)) } unsafe { c::Sleep(super::dur2timeout(dur)) }
} }

View file

@ -119,7 +119,7 @@ fn test_windows_prefix_components() {
/// See #101358. /// 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. /// In which case this test will need to adjusted.
#[test] #[test]
fn broken_unc_path() { fn broken_unc_path() {

View file

@ -30,7 +30,7 @@
//! data the system has available at the time. //! data the system has available at the time.
//! //!
//! So in conclusion, we always want the output of the non-blocking pool, but //! 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, //! 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 //! 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 //! `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 //! succeed if the pool is initialized. If it isn't, we fall back to the file
//! access method. //! 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` //! 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 //! 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 //! however, we need to wait until initialization, which we can do by `poll`ing

View file

@ -66,7 +66,7 @@ impl Drop for AllocatedCondvar {
// On DragonFly pthread_cond_destroy() returns EINVAL if called on // On DragonFly pthread_cond_destroy() returns EINVAL if called on
// a condvar that was just initialized with // a condvar that was just initialized with
// libc::PTHREAD_COND_INITIALIZER. Once it is used or // 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); debug_assert!(r == 0 || r == libc::EINVAL);
} else { } else {
debug_assert_eq!(r, 0); debug_assert_eq!(r, 0);

View file

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

View file

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

View file

@ -283,7 +283,7 @@ impl RwLock {
futex_wake(&self.writer_notify) futex_wake(&self.writer_notify)
// Note that FreeBSD and DragonFlyBSD don't tell us whether they woke // Note that FreeBSD and DragonFlyBSD don't tell us whether they woke
// up any threads or not, and always return `false` here. That still // 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. // 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 //! * `pthread` is an external library, meaning the fast path of acquiring an
//! uncontended lock cannot be inlined. //! uncontended lock cannot be inlined.
//! * Some platforms (at least glibc before version 2.25) have buggy implementations //! * 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. //! guarded against.
//! * On some platforms (e.g. macOS), the lock is very slow. //! * On some platforms (e.g. macOS), the lock is very slow.
//! //!

View file

@ -5,7 +5,7 @@
//! rejection from the App Store). //! rejection from the App Store).
//! //!
//! Therefore, we need to look for other synchronization primitives. Luckily, Darwin //! 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 //! 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 //! provided by libdispatch, as the underlying Mach semaphore is only dubiously
//! public. //! public.

View file

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

View file

@ -35,7 +35,7 @@
// different implementations. // different implementations.
// //
// Unfortunately, NT Keyed Events are an undocumented Windows API. However: // 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] // several (unofficial) articles documenting the details. [1]
// - `parking_lot` has been using this API for years (on Windows versions // - `parking_lot` has been using this API for years (on Windows versions
// before Windows 8). [2] Many big projects extensively use parking_lot, // 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 // - It is the underlying API used by Windows SRW locks and Windows critical
// sections. [3] [4] // sections. [3] [4]
// - The source code of the implementations of Wine, ReactOs, and Windows XP // - 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 // - 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 // future. But since we only use it for older versions of Windows, that's not
// a problem. // a problem.

View file

@ -878,7 +878,7 @@ pub fn sleep(dur: Duration) {
/// ///
/// # Platform-specific behavior /// # Platform-specific behavior
/// ///
/// This function uses [`sleep`] internally, see its platform-specific behaviour. /// This function uses [`sleep`] internally, see its platform-specific behavior.
/// ///
/// ///
/// # Examples /// # 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 /// 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; struct PanicGuard;
impl Drop for PanicGuard { impl Drop for PanicGuard {

View file

@ -178,9 +178,9 @@ pub struct Instant(time::Instant);
/// system. /// system.
/// ///
/// A `SystemTime` does not count leap seconds. /// 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. /// 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) /// (e.g. whether the clock appears to run slow or fast, or stop, or jump)
/// depends on platform and configuration, /// depends on platform and configuration,
/// so should not be relied on. /// so should not be relied on.