From 6679f5ceb1bd367050bb69b239d94d6213696336 Mon Sep 17 00:00:00 2001 From: Brent Kerby Date: Sun, 2 May 2021 15:55:22 -0600 Subject: [PATCH] Change 'NULL' to 'null' --- compiler/rustc_codegen_llvm/src/metadata.rs | 2 +- compiler/rustc_lint/src/builtin.rs | 4 ++-- compiler/rustc_metadata/src/dynamic_lib.rs | 6 ++--- .../rustc_middle/src/mir/interpret/error.rs | 4 ++-- compiler/rustc_middle/src/mir/query.rs | 2 +- .../rustc_mir/src/interpret/intrinsics.rs | 8 +++---- compiler/rustc_mir/src/interpret/memory.rs | 10 ++++---- compiler/rustc_mir/src/interpret/place.rs | 2 +- compiler/rustc_mir/src/interpret/validity.rs | 6 ++--- library/alloc/src/boxed.rs | 2 +- library/core/src/intrinsics.rs | 6 ++--- library/core/src/mem/maybe_uninit.rs | 2 +- library/core/src/ptr/const_ptr.rs | 6 ++--- library/core/src/ptr/mod.rs | 24 +++++++++---------- library/core/src/ptr/mut_ptr.rs | 12 +++++----- library/core/src/ptr/non_null.rs | 2 +- library/panic_unwind/src/seh.rs | 2 +- library/std/src/ffi/c_str.rs | 2 +- library/std/src/sys/unix/ext/net/ancillary.rs | 4 ++-- library/std/src/sys/unix/fs.rs | 4 ++-- .../src/sys/unix/process/process_common.rs | 2 +- library/std/src/thread/local.rs | 2 +- .../consts/const-eval/ub-nonnull.32bit.stderr | 2 +- .../consts/const-eval/ub-nonnull.64bit.stderr | 2 +- src/test/ui/consts/const-eval/ub-nonnull.rs | 2 +- .../consts/const-eval/ub-ref-ptr.32bit.stderr | 4 ++-- .../consts/const-eval/ub-ref-ptr.64bit.stderr | 4 ++-- .../consts/const-eval/ub-upvars.32bit.stderr | 2 +- .../consts/const-eval/ub-upvars.64bit.stderr | 2 +- .../issue-45729-unsafe-in-generator.stderr | 2 +- src/test/ui/issues/issue-47412.stderr | 2 +- src/test/ui/traits/safety-fn-body.stderr | 2 +- .../issue-45087-unreachable-unsafe.stderr | 2 +- .../rfc-2585-unsafe_op_in_unsafe_fn.stderr | 4 ++-- .../unsafe/unsafe-fn-assign-deref-ptr.stderr | 2 +- src/test/ui/unsafe/unsafe-fn-deref-ptr.stderr | 2 +- .../ui/unsafe/unsafe-unstable-const-fn.stderr | 2 +- 37 files changed, 75 insertions(+), 75 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/metadata.rs b/compiler/rustc_codegen_llvm/src/metadata.rs index b007df573062..decc1e1f7000 100644 --- a/compiler/rustc_codegen_llvm/src/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/metadata.rs @@ -66,7 +66,7 @@ fn search_meta_section<'a>( let mut name_buf = None; let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf); let name = name_buf.map_or_else( - String::new, // We got a NULL ptr, ignore `name_len`. + String::new, // We got a null ptr, ignore `name_len`. |buf| { String::from_utf8( slice::from_raw_parts(buf.as_ptr() as *const u8, name_len as usize) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 3965a3dcdfd5..c9b038f0e879 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -2328,7 +2328,7 @@ const HAS_MIN_FEATURES: &[Symbol] = &[sym::specialization]; declare_lint! { /// The `invalid_value` lint detects creating a value that is not valid, - /// such as a NULL reference. + /// such as a null reference. /// /// ### Example /// @@ -2359,7 +2359,7 @@ declare_lint! { /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html pub INVALID_VALUE, Warn, - "an invalid value is being created (such as a NULL reference)" + "an invalid value is being created (such as a null reference)" } declare_lint_pass!(InvalidValue => [INVALID_VALUE]); diff --git a/compiler/rustc_metadata/src/dynamic_lib.rs b/compiler/rustc_metadata/src/dynamic_lib.rs index bdb53e3f75a4..1a900ccbf65f 100644 --- a/compiler/rustc_metadata/src/dynamic_lib.rs +++ b/compiler/rustc_metadata/src/dynamic_lib.rs @@ -105,7 +105,7 @@ mod dl { return Ok(ret.cast()); } - // A NULL return from `dlopen` indicates that an error has definitely occurred, so if + // A null return from `dlopen` indicates that an error has definitely occurred, so if // nothing is in `dlerror`, we are racing with another thread that has stolen our error // message. See the explanation on the `dl::error` module for more information. dlerror.get().and_then(|()| Err("Unknown error".to_string())) @@ -117,7 +117,7 @@ mod dl { ) -> Result<*mut u8, String> { let mut dlerror = error::lock(); - // Unlike `dlopen`, it's possible for `dlsym` to return NULL without overwriting `dlerror`. + // Unlike `dlopen`, it's possible for `dlsym` to return null without overwriting `dlerror`. // Because of this, we clear `dlerror` before calling `dlsym` to avoid picking up a stale // error message by accident. dlerror.clear(); @@ -128,7 +128,7 @@ mod dl { return Ok(ret.cast()); } - // If `dlsym` returns NULL but there is nothing in `dlerror` it means one of two things: + // If `dlsym` returns null but there is nothing in `dlerror` it means one of two things: // - We tried to load a symbol mapped to address 0. This is not technically an error but is // unlikely to occur in practice and equally unlikely to be handled correctly by calling // code. Therefore we treat it as an error anyway. diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index cc0df127434e..d4970a4f5321 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -185,7 +185,7 @@ impl fmt::Display for CheckInAllocMsg { "{}", match *self { CheckInAllocMsg::MemoryAccessTest => "memory access", - CheckInAllocMsg::NullPointerTest => "NULL pointer test", + CheckInAllocMsg::NullPointerTest => "null pointer test", CheckInAllocMsg::PointerArithmeticTest => "pointer arithmetic", CheckInAllocMsg::InboundsTest => "inbounds test", } @@ -309,7 +309,7 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> { allocation_size.bytes() ), DanglingIntPointer(_, CheckInAllocMsg::NullPointerTest) => { - write!(f, "NULL pointer is not allowed for this operation") + write!(f, "null pointer is not allowed for this operation") } DanglingIntPointer(i, msg) => { write!(f, "{} failed: 0x{:x} is not a valid pointer", msg, i) diff --git a/compiler/rustc_middle/src/mir/query.rs b/compiler/rustc_middle/src/mir/query.rs index fdd874c6f682..a80aa6ad3d81 100644 --- a/compiler/rustc_middle/src/mir/query.rs +++ b/compiler/rustc_middle/src/mir/query.rs @@ -81,7 +81,7 @@ impl UnsafetyViolationDetails { ), DerefOfRawPointer => ( "dereference of raw pointer", - "raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules \ + "raw pointers may be null, dangling or unaligned; they can violate aliasing rules \ and cause data races: all of these are undefined behavior", ), AssignToDroppingUnionField => ( diff --git a/compiler/rustc_mir/src/interpret/intrinsics.rs b/compiler/rustc_mir/src/interpret/intrinsics.rs index d74ef66a4b23..dea1b1133154 100644 --- a/compiler/rustc_mir/src/interpret/intrinsics.rs +++ b/compiler/rustc_mir/src/interpret/intrinsics.rs @@ -348,8 +348,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let b = self.read_immediate(&args[1])?.to_scalar()?; // Special case: if both scalars are *equal integers* - // and not NULL, we pretend there is an allocation of size 0 right there, - // and their offset is 0. (There's never a valid object at NULL, making it an + // and not null, we pretend there is an allocation of size 0 right there, + // and their offset is 0. (There's never a valid object at null, making it an // exception from the exception.) // This is the dual to the special exception for offset-by-0 // in the inbounds pointer offset operation (see the Miri code, `src/operator.rs`). @@ -501,7 +501,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { /// Offsets a pointer by some multiple of its type, returning an error if the pointer leaves its /// allocation. For integer pointers, we consider each of them their own tiny allocation of size - /// 0, so offset-by-0 (and only 0) is okay -- except that NULL cannot be offset by _any_ value. + /// 0, so offset-by-0 (and only 0) is okay -- except that null cannot be offset by _any_ value. pub fn ptr_offset_inbounds( &self, ptr: Scalar, @@ -521,7 +521,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // pointers to be properly aligned (unlike a read/write operation). let min_ptr = if offset_bytes >= 0 { ptr } else { offset_ptr }; let size = offset_bytes.unsigned_abs(); - // This call handles checking for integer/NULL pointers. + // This call handles checking for integer/null pointers. self.memory.check_ptr_access_align( min_ptr, Size::from_bytes(size), diff --git a/compiler/rustc_mir/src/interpret/memory.rs b/compiler/rustc_mir/src/interpret/memory.rs index fe5ebf0b6fe9..1aaa56403f46 100644 --- a/compiler/rustc_mir/src/interpret/memory.rs +++ b/compiler/rustc_mir/src/interpret/memory.rs @@ -2,7 +2,7 @@ //! //! Generally, we use `Pointer` to denote memory addresses. However, some operations //! have a "size"-like parameter, and they take `Scalar` for the address because -//! if the size is 0, then the pointer can also be a (properly aligned, non-NULL) +//! if the size is 0, then the pointer can also be a (properly aligned, non-null) //! integer. It is crucial that these operations call `check_align` *before* //! short-circuiting the empty case! @@ -105,7 +105,7 @@ pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> { /// Map for "extra" function pointers. extra_fn_ptr_map: FxHashMap, - /// To be able to compare pointers with NULL, and to check alignment for accesses + /// To be able to compare pointers with null, and to check alignment for accesses /// to ZSTs (where pointers may dangle), we keep track of the size even for allocations /// that do not exist any more. // FIXME: this should not be public, but interning currently needs access to it @@ -391,7 +391,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { Ok(bits) => { let bits = u64::try_from(bits).unwrap(); // it's ptr-sized assert!(size.bytes() == 0); - // Must be non-NULL. + // Must be non-null. if bits == 0 { throw_ub!(DanglingIntPointer(0, msg)) } @@ -404,7 +404,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { Err(ptr) => { let (allocation_size, alloc_align) = self.get_size_and_align(ptr.alloc_id, AllocCheck::Dereferenceable)?; - // Test bounds. This also ensures non-NULL. + // Test bounds. This also ensures non-null. // It is sufficient to check this for the end pointer. The addition // checks for overflow. let end_ptr = ptr.offset(size, self)?; @@ -436,7 +436,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { }) } - /// Test if the pointer might be NULL. + /// Test if the pointer might be null. pub fn ptr_may_be_null(&self, ptr: Pointer) -> bool { let (size, _align) = self .get_size_and_align(ptr.alloc_id, AllocCheck::MaybeDead) diff --git a/compiler/rustc_mir/src/interpret/place.rs b/compiler/rustc_mir/src/interpret/place.rs index 699b531f5018..d7c11aee21fb 100644 --- a/compiler/rustc_mir/src/interpret/place.rs +++ b/compiler/rustc_mir/src/interpret/place.rs @@ -375,7 +375,7 @@ where assert!(place.mplace.align <= align, "dynamic alignment less strict than static one?"); // Check (stricter) dynamic alignment, unless forced otherwise. place.mplace.align = force_align.unwrap_or(align); - // When dereferencing a pointer, it must be non-NULL, aligned, and live. + // When dereferencing a pointer, it must be non-null, aligned, and live. if let Some(ptr) = self.check_mplace_access(&place, Some(size))? { place.mplace.ptr = ptr.into(); } diff --git a/compiler/rustc_mir/src/interpret/validity.rs b/compiler/rustc_mir/src/interpret/validity.rs index 062ef7d8b4cb..19ceec70e042 100644 --- a/compiler/rustc_mir/src/interpret/validity.rs +++ b/compiler/rustc_mir/src/interpret/validity.rs @@ -427,7 +427,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' has.bytes() }, err_ub!(DanglingIntPointer(0, _)) => - { "a NULL {}", kind }, + { "a null {}", kind }, err_ub!(DanglingIntPointer(i, _)) => { "a dangling {} (address 0x{:x} is unallocated)", kind, i }, err_ub!(PointerOutOfBounds { .. }) => @@ -662,10 +662,10 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' let bits = match value.to_bits_or_ptr(op.layout.size, self.ecx) { Err(ptr) => { if lo == 1 && hi == max_hi { - // Only NULL is the niche. So make sure the ptr is NOT NULL. + // Only null is the niche. So make sure the ptr is NOT null. if self.ecx.memory.ptr_may_be_null(ptr) { throw_validation_failure!(self.path, - { "a potentially NULL pointer" } + { "a potentially null pointer" } expected { "something that cannot possibly fail to be {}", wrapping_range_format(valid_range, max_hi) diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index ef37fef04552..30a69bfe982f 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -84,7 +84,7 @@ //! /* Returns ownership to the caller */ //! struct Foo* foo_new(void); //! -//! /* Takes ownership from the caller; no-op when invoked with NULL */ +//! /* Takes ownership from the caller; no-op when invoked with null */ //! void foo_delete(struct Foo*); //! ``` //! diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 1ba0b23ae5be..d7dd7ee02c1f 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -1773,7 +1773,7 @@ extern "rust-intrinsic" { /// [violate memory safety][read-ownership]. /// /// Note that even if the effectively copied size (`count * size_of::()`) is - /// `0`, the pointers must be non-NULL and properly aligned. + /// `0`, the pointers must be non-null and properly aligned. /// /// [`read`]: crate::ptr::read /// [read-ownership]: crate::ptr::read#ownership-of-the-returned-value @@ -1857,7 +1857,7 @@ extern "rust-intrinsic" { /// [violate memory safety][read-ownership]. /// /// Note that even if the effectively copied size (`count * size_of::()`) is - /// `0`, the pointers must be non-NULL and properly aligned. + /// `0`, the pointers must be non-null and properly aligned. /// /// [`read`]: crate::ptr::read /// [read-ownership]: crate::ptr::read#ownership-of-the-returned-value @@ -1928,7 +1928,7 @@ pub(crate) fn is_aligned_and_not_null(ptr: *const T) -> bool { /// invalid value of `T` is undefined behavior. /// /// Note that even if the effectively copied size (`count * size_of::()`) is -/// `0`, the pointer must be non-NULL and properly aligned. +/// `0`, the pointer must be non-null and properly aligned. /// /// [valid]: crate::ptr#safety /// diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 4d7d47579ee4..f77acdd61807 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -10,7 +10,7 @@ use crate::ptr; /// /// The compiler, in general, assumes that a variable is properly initialized /// according to the requirements of the variable's type. For example, a variable of -/// reference type must be aligned and non-NULL. This is an invariant that must +/// reference type must be aligned and non-null. This is an invariant that must /// *always* be upheld, even in unsafe code. As a consequence, zero-initializing a /// variable of reference type causes instantaneous [undefined behavior][ub], /// no matter whether that reference ever gets used to access memory: diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index b9b2ba9ae61e..8348afb2a56a 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -66,7 +66,7 @@ impl *const T { /// /// # Safety /// - /// When calling this method, you have to ensure that *either* the pointer is NULL *or* + /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// /// * The pointer must be properly aligned. @@ -130,7 +130,7 @@ impl *const T { /// /// # Safety /// - /// When calling this method, you have to ensure that *either* the pointer is NULL *or* + /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// /// * The pointer must be properly aligned. @@ -974,7 +974,7 @@ impl *const [T] { /// /// # Safety /// - /// When calling this method, you have to ensure that *either* the pointer is NULL *or* + /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// /// * The pointer must be [valid] for reads for `ptr.len() * mem::size_of::()` many bytes, diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index ad8696ab9272..415bdde11eb8 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -149,7 +149,7 @@ mod mut_ptr; /// again. [`write()`] can be used to overwrite data without causing it to be /// dropped. /// -/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned. /// /// [valid]: self#safety /// @@ -315,7 +315,7 @@ pub const fn slice_from_raw_parts_mut(data: *mut T, len: usize) -> *mut [T] { /// /// * Both `x` and `y` must be properly aligned. /// -/// Note that even if `T` has size `0`, the pointers must be non-NULL and properly aligned. +/// Note that even if `T` has size `0`, the pointers must be non-null and properly aligned. /// /// [valid]: self#safety /// @@ -394,7 +394,7 @@ pub const unsafe fn swap(x: *mut T, y: *mut T) { /// beginning at `y` with the same size. /// /// Note that even if the effectively copied size (`count * size_of::()`) is `0`, -/// the pointers must be non-NULL and properly aligned. +/// the pointers must be non-null and properly aligned. /// /// [valid]: self#safety /// @@ -540,7 +540,7 @@ const unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { /// /// * `dst` must point to a properly initialized value of type `T`. /// -/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned. /// /// [valid]: self#safety /// @@ -588,7 +588,7 @@ pub const unsafe fn replace(dst: *mut T, mut src: T) -> T { /// /// * `src` must point to a properly initialized value of type `T`. /// -/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned. /// /// # Examples /// @@ -713,7 +713,7 @@ pub const unsafe fn read(src: *const T) -> T { /// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned /// value and the value at `*src` can [violate memory safety][read-ownership]. /// -/// Note that even if `T` has size `0`, the pointer must be non-NULL. +/// Note that even if `T` has size `0`, the pointer must be non-null. /// /// [read-ownership]: read#ownership-of-the-returned-value /// [valid]: self#safety @@ -818,7 +818,7 @@ pub const unsafe fn read_unaligned(src: *const T) -> T { /// * `dst` must be properly aligned. Use [`write_unaligned`] if this is not the /// case. /// -/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned. /// /// [valid]: self#safety /// @@ -910,7 +910,7 @@ pub const unsafe fn write(dst: *mut T, src: T) { /// /// * `dst` must be [valid] for writes. /// -/// Note that even if `T` has size `0`, the pointer must be non-NULL. +/// Note that even if `T` has size `0`, the pointer must be non-null. /// /// [valid]: self#safety /// @@ -1024,7 +1024,7 @@ pub const unsafe fn write_unaligned(dst: *mut T, src: T) { /// However, storing non-[`Copy`] types in volatile memory is almost certainly /// incorrect. /// -/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned. /// /// [valid]: self#safety /// [read-ownership]: read#ownership-of-the-returned-value @@ -1094,7 +1094,7 @@ pub unsafe fn read_volatile(src: *const T) -> T { /// /// * `dst` must be properly aligned. /// -/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned. /// /// [valid]: self#safety /// @@ -1496,7 +1496,7 @@ fnptr_impls_args! { A, B, C, D, E, F, G, H, I, J, K, L } /// /// Note, however, that the `expr` in `addr_of!(expr)` is still subject to all /// the usual rules. In particular, `addr_of!(*ptr::null())` is Undefined -/// Behavior because it dereferences a NULL pointer. +/// Behavior because it dereferences a null pointer. /// /// # Example /// @@ -1536,7 +1536,7 @@ pub macro addr_of($place:expr) { /// /// Note, however, that the `expr` in `addr_of_mut!(expr)` is still subject to all /// the usual rules. In particular, `addr_of_mut!(*ptr::null_mut())` is Undefined -/// Behavior because it dereferences a NULL pointer. +/// Behavior because it dereferences a null pointer. /// /// # Examples /// diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 55c019c51d51..292ac3e3f7fe 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -68,7 +68,7 @@ impl *mut T { /// /// # Safety /// - /// When calling this method, you have to ensure that *either* the pointer is NULL *or* + /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// /// * The pointer must be properly aligned. @@ -135,7 +135,7 @@ impl *mut T { /// /// # Safety /// - /// When calling this method, you have to ensure that *either* the pointer is NULL *or* + /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// /// * The pointer must be properly aligned. @@ -314,7 +314,7 @@ impl *mut T { /// /// # Safety /// - /// When calling this method, you have to ensure that *either* the pointer is NULL *or* + /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// /// * The pointer must be properly aligned. @@ -380,7 +380,7 @@ impl *mut T { /// /// # Safety /// - /// When calling this method, you have to ensure that *either* the pointer is NULL *or* + /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// /// * The pointer must be properly aligned. @@ -1237,7 +1237,7 @@ impl *mut [T] { /// /// # Safety /// - /// When calling this method, you have to ensure that *either* the pointer is NULL *or* + /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// /// * The pointer must be [valid] for reads for `ptr.len() * mem::size_of::()` many bytes, @@ -1288,7 +1288,7 @@ impl *mut [T] { /// /// # Safety /// - /// When calling this method, you have to ensure that *either* the pointer is NULL *or* + /// When calling this method, you have to ensure that *either* the pointer is null *or* /// all of the following is true: /// /// * The pointer must be [valid] for reads and writes for `ptr.len() * mem::size_of::()` diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index e525f6160438..1c65518af04f 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -519,7 +519,7 @@ impl NonNull<[T]> { I: SliceIndex<[T]>, { // SAFETY: the caller ensures that `self` is dereferencable and `index` in-bounds. - // As a consequence, the resulting pointer cannot be NULL. + // As a consequence, the resulting pointer cannot be null. unsafe { NonNull::new_unchecked(self.as_ptr().get_unchecked_mut(index)) } } } diff --git a/library/panic_unwind/src/seh.rs b/library/panic_unwind/src/seh.rs index 5597bbb93d23..58028d405764 100644 --- a/library/panic_unwind/src/seh.rs +++ b/library/panic_unwind/src/seh.rs @@ -316,7 +316,7 @@ pub unsafe fn panic(data: Box) -> u32 { } pub unsafe fn cleanup(payload: *mut u8) -> Box { - // A NULL payload here means that we got here from the catch (...) of + // A null payload here means that we got here from the catch (...) of // __rust_try. This happens when a non-Rust foreign exception is caught. if payload.is_null() { super::__rust_foreign_exception(); diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index ed4950c57a62..2f9845d7536c 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -498,7 +498,7 @@ impl CString { /// Failure to call [`CString::from_raw`] will lead to a memory leak. /// /// The C side must **not** modify the length of the string (by writing a - /// `NULL` somewhere inside the string or removing the final one) before + /// `null` somewhere inside the string or removing the final one) before /// it makes it back into Rust using [`CString::from_raw`]. See the safety section /// in [`CString::from_raw`]. /// diff --git a/library/std/src/sys/unix/ext/net/ancillary.rs b/library/std/src/sys/unix/ext/net/ancillary.rs index 011ae643f871..15ce7056fea3 100644 --- a/library/std/src/sys/unix/ext/net/ancillary.rs +++ b/library/std/src/sys/unix/ext/net/ancillary.rs @@ -49,7 +49,7 @@ pub(super) fn recv_vectored_with_ancillary_from( msg.msg_controllen = ancillary.buffer.len() as libc::socklen_t; } } - // macos requires that the control pointer is NULL when the len is 0. + // macos requires that the control pointer is null when the len is 0. if msg.msg_controllen > 0 { msg.msg_control = ancillary.buffer.as_mut_ptr().cast(); } @@ -97,7 +97,7 @@ pub(super) fn send_vectored_with_ancillary_to( msg.msg_controllen = ancillary.length as libc::socklen_t; } } - // macos requires that the control pointer is NULL when the len is 0. + // macos requires that the control pointer is null when the len is 0. if msg.msg_controllen > 0 { msg.msg_control = ancillary.buffer.as_mut_ptr().cast(); } diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index 45bae25a0c38..79617aa77b7b 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -116,7 +116,7 @@ cfg_has_statx! {{ match STATX_STATE.load(Ordering::Relaxed) { 0 => { - // It is a trick to call `statx` with NULL pointers to check if the syscall + // It is a trick to call `statx` with null pointers to check if the syscall // is available. According to the manual, it is expected to fail with EFAULT. // We do this mainly for performance, since it is nearly hundreds times // faster than a normal successful call. @@ -450,7 +450,7 @@ impl Iterator for ReadDir { super::os::set_errno(0); let entry_ptr = libc::readdir(self.inner.dirp.0); if entry_ptr.is_null() { - // NULL can mean either the end is reached or an error occurred. + // null can mean either the end is reached or an error occurred. // So we had to clear errno beforehand to check for an error now. return match super::os::errno() { 0 => None, diff --git a/library/std/src/sys/unix/process/process_common.rs b/library/std/src/sys/unix/process/process_common.rs index b9dcc4e4b9e3..c5bdd1bda4a7 100644 --- a/library/std/src/sys/unix/process/process_common.rs +++ b/library/std/src/sys/unix/process/process_common.rs @@ -153,7 +153,7 @@ impl Command { } pub fn arg(&mut self, arg: &OsStr) { - // Overwrite the trailing NULL pointer in `argv` and then add a new null + // Overwrite the trailing null pointer in `argv` and then add a new null // pointer. let arg = os2c(arg, &mut self.saw_nul); self.argv.0[self.args.len()] = arg.as_ptr(); diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index abd5b7784834..1f5f26e3e144 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -722,7 +722,7 @@ pub mod os { unsafe extern "C" fn destroy_value(ptr: *mut u8) { // SAFETY: // - // The OS TLS ensures that this key contains a NULL value when this + // The OS TLS ensures that this key contains a null value when this // destructor starts to run. We set it back to a sentinel value of 1 to // ensure that any future calls to `get` for this thread will return // `None`. diff --git a/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr b/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr index 3affde739afe..ce8ab632fcf3 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr @@ -14,7 +14,7 @@ error: any use of this value will cause an error | LL | / const OUT_OF_BOUNDS_PTR: NonNull = { unsafe { LL | | let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle -LL | | // Use address-of-element for pointer arithmetic. This could wrap around to NULL! +LL | | // Use address-of-element for pointer arithmetic. This could wrap around to null! LL | | let out_of_bounds_ptr = &ptr[255]; | | ^^^^^^^^ memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of alloc10 which has size 1 LL | | diff --git a/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr b/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr index 63815c46efe1..3f49a262ae46 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr @@ -14,7 +14,7 @@ error: any use of this value will cause an error | LL | / const OUT_OF_BOUNDS_PTR: NonNull = { unsafe { LL | | let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle -LL | | // Use address-of-element for pointer arithmetic. This could wrap around to NULL! +LL | | // Use address-of-element for pointer arithmetic. This could wrap around to null! LL | | let out_of_bounds_ptr = &ptr[255]; | | ^^^^^^^^ memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of alloc10 which has size 1 LL | | diff --git a/src/test/ui/consts/const-eval/ub-nonnull.rs b/src/test/ui/consts/const-eval/ub-nonnull.rs index 0bc406e01a0c..75c02a8da194 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.rs +++ b/src/test/ui/consts/const-eval/ub-nonnull.rs @@ -15,7 +15,7 @@ const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; #[deny(const_err)] // this triggers a `const_err` so validation does not even happen const OUT_OF_BOUNDS_PTR: NonNull = { unsafe { let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle - // Use address-of-element for pointer arithmetic. This could wrap around to NULL! + // Use address-of-element for pointer arithmetic. This could wrap around to null! let out_of_bounds_ptr = &ptr[255]; //~ ERROR any use of this value will cause an error //~| WARN this was previously accepted by the compiler but is being phased out mem::transmute(out_of_bounds_ptr) diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr b/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr index 32e13baa3f53..d4a61a463193 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr @@ -24,7 +24,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-ref-ptr.rs:21:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL reference + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a null reference | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -35,7 +35,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-ref-ptr.rs:24:1 | LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a null box | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr b/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr index 8bd4637a80be..17da7c25bac9 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr @@ -24,7 +24,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-ref-ptr.rs:21:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL reference + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a null reference | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -35,7 +35,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-ref-ptr.rs:24:1 | LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a null box | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/src/test/ui/consts/const-eval/ub-upvars.32bit.stderr b/src/test/ui/consts/const-eval/ub-upvars.32bit.stderr index 62756518a00e..33251535be90 100644 --- a/src/test/ui/consts/const-eval/ub-upvars.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-upvars.32bit.stderr @@ -6,7 +6,7 @@ LL | | let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) }; LL | | let another_var = 13; LL | | move || { let _ = bad_ref; let _ = another_var; } LL | | }; - | |__^ type validation failed: encountered a NULL reference at ... + | |__^ type validation failed: encountered a null reference at ... | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/src/test/ui/consts/const-eval/ub-upvars.64bit.stderr b/src/test/ui/consts/const-eval/ub-upvars.64bit.stderr index e9fabd9a3bcc..de6033702ae3 100644 --- a/src/test/ui/consts/const-eval/ub-upvars.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-upvars.64bit.stderr @@ -6,7 +6,7 @@ LL | | let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) }; LL | | let another_var = 13; LL | | move || { let _ = bad_ref; let _ = another_var; } LL | | }; - | |__^ type validation failed: encountered a NULL reference at ... + | |__^ type validation failed: encountered a null reference at ... | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/src/test/ui/generator/issue-45729-unsafe-in-generator.stderr b/src/test/ui/generator/issue-45729-unsafe-in-generator.stderr index 2aab6807aaa2..0bd3dbf6863c 100644 --- a/src/test/ui/generator/issue-45729-unsafe-in-generator.stderr +++ b/src/test/ui/generator/issue-45729-unsafe-in-generator.stderr @@ -4,7 +4,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function LL | *(1 as *mut u32) = 42; | ^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer | - = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error: aborting due to previous error diff --git a/src/test/ui/issues/issue-47412.stderr b/src/test/ui/issues/issue-47412.stderr index 0f003c44b70a..aebcbf074630 100644 --- a/src/test/ui/issues/issue-47412.stderr +++ b/src/test/ui/issues/issue-47412.stderr @@ -12,7 +12,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function LL | match *ptr {} | ^^^^ dereference of raw pointer | - = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/safety-fn-body.stderr b/src/test/ui/traits/safety-fn-body.stderr index 4f784a020d91..0aeb186828ee 100644 --- a/src/test/ui/traits/safety-fn-body.stderr +++ b/src/test/ui/traits/safety-fn-body.stderr @@ -4,7 +4,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function LL | *self += 1; | ^^^^^^^^^^ dereference of raw pointer | - = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error: aborting due to previous error diff --git a/src/test/ui/unsafe/issue-45087-unreachable-unsafe.stderr b/src/test/ui/unsafe/issue-45087-unreachable-unsafe.stderr index d112d7f46612..88322c3a0a68 100644 --- a/src/test/ui/unsafe/issue-45087-unreachable-unsafe.stderr +++ b/src/test/ui/unsafe/issue-45087-unreachable-unsafe.stderr @@ -4,7 +4,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function LL | *(1 as *mut u32) = 42; | ^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer | - = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error: aborting due to previous error diff --git a/src/test/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.stderr b/src/test/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.stderr index 3157783acb6a..ad93267ca014 100644 --- a/src/test/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.stderr +++ b/src/test/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.stderr @@ -17,7 +17,7 @@ error: dereference of raw pointer is unsafe and requires unsafe block (error E01 LL | *PTR; | ^^^^ dereference of raw pointer | - = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error: use of mutable static is unsafe and requires unsafe block (error E0133) --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:13:5 @@ -59,7 +59,7 @@ error: dereference of raw pointer is unsafe and requires unsafe block (error E01 LL | *PTR; | ^^^^ dereference of raw pointer | - = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error: use of mutable static is unsafe and requires unsafe block (error E0133) --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:28:5 diff --git a/src/test/ui/unsafe/unsafe-fn-assign-deref-ptr.stderr b/src/test/ui/unsafe/unsafe-fn-assign-deref-ptr.stderr index 28db83db92ac..b2a30f81e058 100644 --- a/src/test/ui/unsafe/unsafe-fn-assign-deref-ptr.stderr +++ b/src/test/ui/unsafe/unsafe-fn-assign-deref-ptr.stderr @@ -4,7 +4,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function LL | *p = 0; | ^^^^^^ dereference of raw pointer | - = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error: aborting due to previous error diff --git a/src/test/ui/unsafe/unsafe-fn-deref-ptr.stderr b/src/test/ui/unsafe/unsafe-fn-deref-ptr.stderr index e8e82dec0b0b..98cb7b876f80 100644 --- a/src/test/ui/unsafe/unsafe-fn-deref-ptr.stderr +++ b/src/test/ui/unsafe/unsafe-fn-deref-ptr.stderr @@ -4,7 +4,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function LL | return *p; | ^^ dereference of raw pointer | - = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error: aborting due to previous error diff --git a/src/test/ui/unsafe/unsafe-unstable-const-fn.stderr b/src/test/ui/unsafe/unsafe-unstable-const-fn.stderr index 4642a7a5fc9f..98d7ae9f8543 100644 --- a/src/test/ui/unsafe/unsafe-unstable-const-fn.stderr +++ b/src/test/ui/unsafe/unsafe-unstable-const-fn.stderr @@ -4,7 +4,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function LL | *a == b | ^^ dereference of raw pointer | - = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error: aborting due to previous error