Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

library: consistently use American spelling for 'behavior' #132137

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/alloc/src/collections/binary_heap/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/btree/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ mod test_extract_if {
{
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)));
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3075,7 +3075,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, 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() });
/// ```
///
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ impl<T, A: Allocator> 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.
Expand Down Expand Up @@ -2788,7 +2788,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, 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() });
/// ```
///
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/vec/is_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ macro_rules! impl_is_zero_option_of_bool {
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
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/alloc/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -234,7 +234,7 @@ pub unsafe trait GlobalAlloc {
/// 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
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ impl<T: ?Sized> RefCell<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
///
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ extern "rust-intrinsic" {
/// 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() -> !;
Expand Down Expand Up @@ -1384,7 +1384,7 @@ extern "rust-intrinsic" {

/// 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.
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/intrinsics/mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ define!(
);
define!(
"mir_unwind_unreachable",
/// An unwind action that triggers undefined behaviour.
/// An unwind action that triggers undefined behavior.
fn UnwindUnreachable() -> UnwindActionArg
);
define!(
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ impl<T> MaybeUninit<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
Expand Down
16 changes: 8 additions & 8 deletions library/core/src/num/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ where
}

/// 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
///
Expand Down Expand Up @@ -952,9 +952,9 @@ macro_rules! nonzero_integer {

/// 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 {
Expand Down Expand Up @@ -1323,9 +1323,9 @@ macro_rules! nonzero_integer_signedness_dependent_methods {

/// 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
Expand Down Expand Up @@ -1599,7 +1599,7 @@ macro_rules! nonzero_integer_signedness_dependent_methods {

/// Computes the absolute value of self.
#[doc = concat!("See [`", stringify!($Int), "::abs`]")]
/// for documentation on overflow behaviour.
/// for documentation on overflow behavior.
///
/// # Example
///
Expand Down Expand Up @@ -1878,7 +1878,7 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
/// 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
///
Expand Down Expand Up @@ -1943,7 +1943,7 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
/// of the type.
///
#[doc = concat!("See [`", stringify!($Int), "::wrapping_neg`]")]
/// for documentation on overflow behaviour.
/// for documentation on overflow behavior.
///
/// # Example
///
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3086,7 +3086,7 @@ macro_rules! uint_impl {
/// ```
#[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"]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ macro_rules! wrapping_int_impl_unsigned {
#[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())
}
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/ops/deref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]).
Expand All @@ -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:
///
Expand Down Expand Up @@ -185,7 +185,7 @@ impl<T: ?Sized> Deref for &mut 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]).
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
//!
Expand Down
10 changes: 5 additions & 5 deletions library/core/src/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -351,7 +351,7 @@ mod prim_never {}
/// ```
///
/// ```no_run
/// // Undefined behaviour
/// // Undefined behavior
/// let _ = unsafe { char::from_u32_unchecked(0x110000) };
/// ```
///
Expand Down Expand Up @@ -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.
///
Expand Down Expand Up @@ -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.
///
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) }
}

/// 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.
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ use crate::{cmp, fmt};
/// [`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 |
/// |--------------------------|-------------------------------------------|
Expand Down
2 changes: 1 addition & 1 deletion library/core/tests/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ macro_rules! int_module {
// 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);
Expand Down
2 changes: 1 addition & 1 deletion library/core/tests/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ macro_rules! uint_module {
// 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);
Expand Down
2 changes: 1 addition & 1 deletion library/proc_macro/src/bridge/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Symbol {
.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,
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/collections/hash/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ mod test_extract_if {
_ => 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());
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ impl Error for JoinPathsError {
///
/// # 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`.
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/os/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub trait FileExt {
///
/// 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;
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -1409,7 +1409,7 @@ impl PathBuf {
/// (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
Expand Down
Loading
Loading