Skip to content

Commit deac8b3

Browse files
committed
Auto merge of rust-lang#84842 - blkerby:null_lowercase, r=joshtriplett
Replace 'NULL' with 'null' This replaces occurrences of "NULL" with "null" in docs, comments, and compiler error/lint messages. This is for the sake of consistency, as the lowercase "null" is already the dominant form in Rust. The all-caps NULL looks like the C macro (or SQL keyword), which seems out of place in a Rust context, given that NULL does not exist in the Rust language or standard library (instead having [`ptr::null()`](https://doc.rust-lang.org/stable/std/ptr/fn.null.html)).
2 parents a663840 + 077944c commit deac8b3

File tree

13 files changed

+35
-35
lines changed

13 files changed

+35
-35
lines changed

alloc/src/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
//! /* Returns ownership to the caller */
8585
//! struct Foo* foo_new(void);
8686
//!
87-
//! /* Takes ownership from the caller; no-op when invoked with NULL */
87+
//! /* Takes ownership from the caller; no-op when invoked with null */
8888
//! void foo_delete(struct Foo*);
8989
//! ```
9090
//!

core/src/intrinsics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ extern "rust-intrinsic" {
17731773
/// [violate memory safety][read-ownership].
17741774
///
17751775
/// Note that even if the effectively copied size (`count * size_of::<T>()`) is
1776-
/// `0`, the pointers must be non-NULL and properly aligned.
1776+
/// `0`, the pointers must be non-null and properly aligned.
17771777
///
17781778
/// [`read`]: crate::ptr::read
17791779
/// [read-ownership]: crate::ptr::read#ownership-of-the-returned-value
@@ -1857,7 +1857,7 @@ extern "rust-intrinsic" {
18571857
/// [violate memory safety][read-ownership].
18581858
///
18591859
/// Note that even if the effectively copied size (`count * size_of::<T>()`) is
1860-
/// `0`, the pointers must be non-NULL and properly aligned.
1860+
/// `0`, the pointers must be non-null and properly aligned.
18611861
///
18621862
/// [`read`]: crate::ptr::read
18631863
/// [read-ownership]: crate::ptr::read#ownership-of-the-returned-value
@@ -1928,7 +1928,7 @@ pub(crate) fn is_aligned_and_not_null<T>(ptr: *const T) -> bool {
19281928
/// invalid value of `T` is undefined behavior.
19291929
///
19301930
/// Note that even if the effectively copied size (`count * size_of::<T>()`) is
1931-
/// `0`, the pointer must be non-NULL and properly aligned.
1931+
/// `0`, the pointer must be non-null and properly aligned.
19321932
///
19331933
/// [valid]: crate::ptr#safety
19341934
///

core/src/mem/maybe_uninit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::ptr;
1010
///
1111
/// The compiler, in general, assumes that a variable is properly initialized
1212
/// according to the requirements of the variable's type. For example, a variable of
13-
/// reference type must be aligned and non-NULL. This is an invariant that must
13+
/// reference type must be aligned and non-null. This is an invariant that must
1414
/// *always* be upheld, even in unsafe code. As a consequence, zero-initializing a
1515
/// variable of reference type causes instantaneous [undefined behavior][ub],
1616
/// no matter whether that reference ever gets used to access memory:

core/src/ptr/const_ptr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<T: ?Sized> *const T {
6666
///
6767
/// # Safety
6868
///
69-
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
69+
/// When calling this method, you have to ensure that *either* the pointer is null *or*
7070
/// all of the following is true:
7171
///
7272
/// * The pointer must be properly aligned.
@@ -130,7 +130,7 @@ impl<T: ?Sized> *const T {
130130
///
131131
/// # Safety
132132
///
133-
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
133+
/// When calling this method, you have to ensure that *either* the pointer is null *or*
134134
/// all of the following is true:
135135
///
136136
/// * The pointer must be properly aligned.
@@ -974,7 +974,7 @@ impl<T> *const [T] {
974974
///
975975
/// # Safety
976976
///
977-
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
977+
/// When calling this method, you have to ensure that *either* the pointer is null *or*
978978
/// all of the following is true:
979979
///
980980
/// * The pointer must be [valid] for reads for `ptr.len() * mem::size_of::<T>()` many bytes,

core/src/ptr/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ mod mut_ptr;
149149
/// again. [`write()`] can be used to overwrite data without causing it to be
150150
/// dropped.
151151
///
152-
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
152+
/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned.
153153
///
154154
/// [valid]: self#safety
155155
///
@@ -315,7 +315,7 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
315315
///
316316
/// * Both `x` and `y` must be properly aligned.
317317
///
318-
/// Note that even if `T` has size `0`, the pointers must be non-NULL and properly aligned.
318+
/// Note that even if `T` has size `0`, the pointers must be non-null and properly aligned.
319319
///
320320
/// [valid]: self#safety
321321
///
@@ -394,7 +394,7 @@ pub const unsafe fn swap<T>(x: *mut T, y: *mut T) {
394394
/// beginning at `y` with the same size.
395395
///
396396
/// Note that even if the effectively copied size (`count * size_of::<T>()`) is `0`,
397-
/// the pointers must be non-NULL and properly aligned.
397+
/// the pointers must be non-null and properly aligned.
398398
///
399399
/// [valid]: self#safety
400400
///
@@ -540,7 +540,7 @@ const unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
540540
///
541541
/// * `dst` must point to a properly initialized value of type `T`.
542542
///
543-
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
543+
/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned.
544544
///
545545
/// [valid]: self#safety
546546
///
@@ -588,7 +588,7 @@ pub const unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
588588
///
589589
/// * `src` must point to a properly initialized value of type `T`.
590590
///
591-
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
591+
/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned.
592592
///
593593
/// # Examples
594594
///
@@ -713,7 +713,7 @@ pub const unsafe fn read<T>(src: *const T) -> T {
713713
/// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned
714714
/// value and the value at `*src` can [violate memory safety][read-ownership].
715715
///
716-
/// Note that even if `T` has size `0`, the pointer must be non-NULL.
716+
/// Note that even if `T` has size `0`, the pointer must be non-null.
717717
///
718718
/// [read-ownership]: read#ownership-of-the-returned-value
719719
/// [valid]: self#safety
@@ -818,7 +818,7 @@ pub const unsafe fn read_unaligned<T>(src: *const T) -> T {
818818
/// * `dst` must be properly aligned. Use [`write_unaligned`] if this is not the
819819
/// case.
820820
///
821-
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
821+
/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned.
822822
///
823823
/// [valid]: self#safety
824824
///
@@ -910,7 +910,7 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
910910
///
911911
/// * `dst` must be [valid] for writes.
912912
///
913-
/// Note that even if `T` has size `0`, the pointer must be non-NULL.
913+
/// Note that even if `T` has size `0`, the pointer must be non-null.
914914
///
915915
/// [valid]: self#safety
916916
///
@@ -1024,7 +1024,7 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
10241024
/// However, storing non-[`Copy`] types in volatile memory is almost certainly
10251025
/// incorrect.
10261026
///
1027-
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
1027+
/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned.
10281028
///
10291029
/// [valid]: self#safety
10301030
/// [read-ownership]: read#ownership-of-the-returned-value
@@ -1094,7 +1094,7 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
10941094
///
10951095
/// * `dst` must be properly aligned.
10961096
///
1097-
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
1097+
/// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned.
10981098
///
10991099
/// [valid]: self#safety
11001100
///
@@ -1496,7 +1496,7 @@ fnptr_impls_args! { A, B, C, D, E, F, G, H, I, J, K, L }
14961496
///
14971497
/// Note, however, that the `expr` in `addr_of!(expr)` is still subject to all
14981498
/// the usual rules. In particular, `addr_of!(*ptr::null())` is Undefined
1499-
/// Behavior because it dereferences a NULL pointer.
1499+
/// Behavior because it dereferences a null pointer.
15001500
///
15011501
/// # Example
15021502
///
@@ -1536,7 +1536,7 @@ pub macro addr_of($place:expr) {
15361536
///
15371537
/// Note, however, that the `expr` in `addr_of_mut!(expr)` is still subject to all
15381538
/// the usual rules. In particular, `addr_of_mut!(*ptr::null_mut())` is Undefined
1539-
/// Behavior because it dereferences a NULL pointer.
1539+
/// Behavior because it dereferences a null pointer.
15401540
///
15411541
/// # Examples
15421542
///

core/src/ptr/mut_ptr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<T: ?Sized> *mut T {
6868
///
6969
/// # Safety
7070
///
71-
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
71+
/// When calling this method, you have to ensure that *either* the pointer is null *or*
7272
/// all of the following is true:
7373
///
7474
/// * The pointer must be properly aligned.
@@ -135,7 +135,7 @@ impl<T: ?Sized> *mut T {
135135
///
136136
/// # Safety
137137
///
138-
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
138+
/// When calling this method, you have to ensure that *either* the pointer is null *or*
139139
/// all of the following is true:
140140
///
141141
/// * The pointer must be properly aligned.
@@ -314,7 +314,7 @@ impl<T: ?Sized> *mut T {
314314
///
315315
/// # Safety
316316
///
317-
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
317+
/// When calling this method, you have to ensure that *either* the pointer is null *or*
318318
/// all of the following is true:
319319
///
320320
/// * The pointer must be properly aligned.
@@ -380,7 +380,7 @@ impl<T: ?Sized> *mut T {
380380
///
381381
/// # Safety
382382
///
383-
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
383+
/// When calling this method, you have to ensure that *either* the pointer is null *or*
384384
/// all of the following is true:
385385
///
386386
/// * The pointer must be properly aligned.
@@ -1237,7 +1237,7 @@ impl<T> *mut [T] {
12371237
///
12381238
/// # Safety
12391239
///
1240-
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
1240+
/// When calling this method, you have to ensure that *either* the pointer is null *or*
12411241
/// all of the following is true:
12421242
///
12431243
/// * The pointer must be [valid] for reads for `ptr.len() * mem::size_of::<T>()` many bytes,
@@ -1288,7 +1288,7 @@ impl<T> *mut [T] {
12881288
///
12891289
/// # Safety
12901290
///
1291-
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
1291+
/// When calling this method, you have to ensure that *either* the pointer is null *or*
12921292
/// all of the following is true:
12931293
///
12941294
/// * The pointer must be [valid] for reads and writes for `ptr.len() * mem::size_of::<T>()`

core/src/ptr/non_null.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ impl<T> NonNull<[T]> {
519519
I: SliceIndex<[T]>,
520520
{
521521
// SAFETY: the caller ensures that `self` is dereferencable and `index` in-bounds.
522-
// As a consequence, the resulting pointer cannot be NULL.
522+
// As a consequence, the resulting pointer cannot be null.
523523
unsafe { NonNull::new_unchecked(self.as_ptr().get_unchecked_mut(index)) }
524524
}
525525
}

panic_unwind/src/seh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
316316
}
317317

318318
pub unsafe fn cleanup(payload: *mut u8) -> Box<dyn Any + Send> {
319-
// A NULL payload here means that we got here from the catch (...) of
319+
// A null payload here means that we got here from the catch (...) of
320320
// __rust_try. This happens when a non-Rust foreign exception is caught.
321321
if payload.is_null() {
322322
super::__rust_foreign_exception();

std/src/ffi/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ impl CString {
498498
/// Failure to call [`CString::from_raw`] will lead to a memory leak.
499499
///
500500
/// The C side must **not** modify the length of the string (by writing a
501-
/// `NULL` somewhere inside the string or removing the final one) before
501+
/// `null` somewhere inside the string or removing the final one) before
502502
/// it makes it back into Rust using [`CString::from_raw`]. See the safety section
503503
/// in [`CString::from_raw`].
504504
///

std/src/sys/unix/ext/net/ancillary.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub(super) fn recv_vectored_with_ancillary_from(
4949
msg.msg_controllen = ancillary.buffer.len() as libc::socklen_t;
5050
}
5151
}
52-
// macos requires that the control pointer is NULL when the len is 0.
52+
// macos requires that the control pointer is null when the len is 0.
5353
if msg.msg_controllen > 0 {
5454
msg.msg_control = ancillary.buffer.as_mut_ptr().cast();
5555
}
@@ -97,7 +97,7 @@ pub(super) fn send_vectored_with_ancillary_to(
9797
msg.msg_controllen = ancillary.length as libc::socklen_t;
9898
}
9999
}
100-
// macos requires that the control pointer is NULL when the len is 0.
100+
// macos requires that the control pointer is null when the len is 0.
101101
if msg.msg_controllen > 0 {
102102
msg.msg_control = ancillary.buffer.as_mut_ptr().cast();
103103
}

0 commit comments

Comments
 (0)