Skip to content

Commit 6679f5c

Browse files
committed
Change 'NULL' to 'null'
1 parent e10cbc3 commit 6679f5c

37 files changed

+75
-75
lines changed

compiler/rustc_codegen_llvm/src/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn search_meta_section<'a>(
6666
let mut name_buf = None;
6767
let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf);
6868
let name = name_buf.map_or_else(
69-
String::new, // We got a NULL ptr, ignore `name_len`.
69+
String::new, // We got a null ptr, ignore `name_len`.
7070
|buf| {
7171
String::from_utf8(
7272
slice::from_raw_parts(buf.as_ptr() as *const u8, name_len as usize)

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,7 +2328,7 @@ const HAS_MIN_FEATURES: &[Symbol] = &[sym::specialization];
23282328

23292329
declare_lint! {
23302330
/// The `invalid_value` lint detects creating a value that is not valid,
2331-
/// such as a NULL reference.
2331+
/// such as a null reference.
23322332
///
23332333
/// ### Example
23342334
///
@@ -2359,7 +2359,7 @@ declare_lint! {
23592359
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
23602360
pub INVALID_VALUE,
23612361
Warn,
2362-
"an invalid value is being created (such as a NULL reference)"
2362+
"an invalid value is being created (such as a null reference)"
23632363
}
23642364

23652365
declare_lint_pass!(InvalidValue => [INVALID_VALUE]);

compiler/rustc_metadata/src/dynamic_lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ mod dl {
105105
return Ok(ret.cast());
106106
}
107107

108-
// A NULL return from `dlopen` indicates that an error has definitely occurred, so if
108+
// A null return from `dlopen` indicates that an error has definitely occurred, so if
109109
// nothing is in `dlerror`, we are racing with another thread that has stolen our error
110110
// message. See the explanation on the `dl::error` module for more information.
111111
dlerror.get().and_then(|()| Err("Unknown error".to_string()))
@@ -117,7 +117,7 @@ mod dl {
117117
) -> Result<*mut u8, String> {
118118
let mut dlerror = error::lock();
119119

120-
// Unlike `dlopen`, it's possible for `dlsym` to return NULL without overwriting `dlerror`.
120+
// Unlike `dlopen`, it's possible for `dlsym` to return null without overwriting `dlerror`.
121121
// Because of this, we clear `dlerror` before calling `dlsym` to avoid picking up a stale
122122
// error message by accident.
123123
dlerror.clear();
@@ -128,7 +128,7 @@ mod dl {
128128
return Ok(ret.cast());
129129
}
130130

131-
// If `dlsym` returns NULL but there is nothing in `dlerror` it means one of two things:
131+
// If `dlsym` returns null but there is nothing in `dlerror` it means one of two things:
132132
// - We tried to load a symbol mapped to address 0. This is not technically an error but is
133133
// unlikely to occur in practice and equally unlikely to be handled correctly by calling
134134
// code. Therefore we treat it as an error anyway.

compiler/rustc_middle/src/mir/interpret/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl fmt::Display for CheckInAllocMsg {
185185
"{}",
186186
match *self {
187187
CheckInAllocMsg::MemoryAccessTest => "memory access",
188-
CheckInAllocMsg::NullPointerTest => "NULL pointer test",
188+
CheckInAllocMsg::NullPointerTest => "null pointer test",
189189
CheckInAllocMsg::PointerArithmeticTest => "pointer arithmetic",
190190
CheckInAllocMsg::InboundsTest => "inbounds test",
191191
}
@@ -309,7 +309,7 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> {
309309
allocation_size.bytes()
310310
),
311311
DanglingIntPointer(_, CheckInAllocMsg::NullPointerTest) => {
312-
write!(f, "NULL pointer is not allowed for this operation")
312+
write!(f, "null pointer is not allowed for this operation")
313313
}
314314
DanglingIntPointer(i, msg) => {
315315
write!(f, "{} failed: 0x{:x} is not a valid pointer", msg, i)

compiler/rustc_middle/src/mir/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl UnsafetyViolationDetails {
8181
),
8282
DerefOfRawPointer => (
8383
"dereference of raw pointer",
84-
"raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules \
84+
"raw pointers may be null, dangling or unaligned; they can violate aliasing rules \
8585
and cause data races: all of these are undefined behavior",
8686
),
8787
AssignToDroppingUnionField => (

compiler/rustc_mir/src/interpret/intrinsics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
348348
let b = self.read_immediate(&args[1])?.to_scalar()?;
349349

350350
// Special case: if both scalars are *equal integers*
351-
// and not NULL, we pretend there is an allocation of size 0 right there,
352-
// and their offset is 0. (There's never a valid object at NULL, making it an
351+
// and not null, we pretend there is an allocation of size 0 right there,
352+
// and their offset is 0. (There's never a valid object at null, making it an
353353
// exception from the exception.)
354354
// This is the dual to the special exception for offset-by-0
355355
// 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> {
501501

502502
/// Offsets a pointer by some multiple of its type, returning an error if the pointer leaves its
503503
/// allocation. For integer pointers, we consider each of them their own tiny allocation of size
504-
/// 0, so offset-by-0 (and only 0) is okay -- except that NULL cannot be offset by _any_ value.
504+
/// 0, so offset-by-0 (and only 0) is okay -- except that null cannot be offset by _any_ value.
505505
pub fn ptr_offset_inbounds(
506506
&self,
507507
ptr: Scalar<M::PointerTag>,
@@ -521,7 +521,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
521521
// pointers to be properly aligned (unlike a read/write operation).
522522
let min_ptr = if offset_bytes >= 0 { ptr } else { offset_ptr };
523523
let size = offset_bytes.unsigned_abs();
524-
// This call handles checking for integer/NULL pointers.
524+
// This call handles checking for integer/null pointers.
525525
self.memory.check_ptr_access_align(
526526
min_ptr,
527527
Size::from_bytes(size),

compiler/rustc_mir/src/interpret/memory.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! Generally, we use `Pointer` to denote memory addresses. However, some operations
44
//! have a "size"-like parameter, and they take `Scalar` for the address because
5-
//! if the size is 0, then the pointer can also be a (properly aligned, non-NULL)
5+
//! if the size is 0, then the pointer can also be a (properly aligned, non-null)
66
//! integer. It is crucial that these operations call `check_align` *before*
77
//! short-circuiting the empty case!
88
@@ -105,7 +105,7 @@ pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
105105
/// Map for "extra" function pointers.
106106
extra_fn_ptr_map: FxHashMap<AllocId, M::ExtraFnVal>,
107107

108-
/// To be able to compare pointers with NULL, and to check alignment for accesses
108+
/// To be able to compare pointers with null, and to check alignment for accesses
109109
/// to ZSTs (where pointers may dangle), we keep track of the size even for allocations
110110
/// that do not exist any more.
111111
// 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> {
391391
Ok(bits) => {
392392
let bits = u64::try_from(bits).unwrap(); // it's ptr-sized
393393
assert!(size.bytes() == 0);
394-
// Must be non-NULL.
394+
// Must be non-null.
395395
if bits == 0 {
396396
throw_ub!(DanglingIntPointer(0, msg))
397397
}
@@ -404,7 +404,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
404404
Err(ptr) => {
405405
let (allocation_size, alloc_align) =
406406
self.get_size_and_align(ptr.alloc_id, AllocCheck::Dereferenceable)?;
407-
// Test bounds. This also ensures non-NULL.
407+
// Test bounds. This also ensures non-null.
408408
// It is sufficient to check this for the end pointer. The addition
409409
// checks for overflow.
410410
let end_ptr = ptr.offset(size, self)?;
@@ -436,7 +436,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
436436
})
437437
}
438438

439-
/// Test if the pointer might be NULL.
439+
/// Test if the pointer might be null.
440440
pub fn ptr_may_be_null(&self, ptr: Pointer<M::PointerTag>) -> bool {
441441
let (size, _align) = self
442442
.get_size_and_align(ptr.alloc_id, AllocCheck::MaybeDead)

compiler/rustc_mir/src/interpret/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ where
375375
assert!(place.mplace.align <= align, "dynamic alignment less strict than static one?");
376376
// Check (stricter) dynamic alignment, unless forced otherwise.
377377
place.mplace.align = force_align.unwrap_or(align);
378-
// When dereferencing a pointer, it must be non-NULL, aligned, and live.
378+
// When dereferencing a pointer, it must be non-null, aligned, and live.
379379
if let Some(ptr) = self.check_mplace_access(&place, Some(size))? {
380380
place.mplace.ptr = ptr.into();
381381
}

compiler/rustc_mir/src/interpret/validity.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
427427
has.bytes()
428428
},
429429
err_ub!(DanglingIntPointer(0, _)) =>
430-
{ "a NULL {}", kind },
430+
{ "a null {}", kind },
431431
err_ub!(DanglingIntPointer(i, _)) =>
432432
{ "a dangling {} (address 0x{:x} is unallocated)", kind, i },
433433
err_ub!(PointerOutOfBounds { .. }) =>
@@ -662,10 +662,10 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
662662
let bits = match value.to_bits_or_ptr(op.layout.size, self.ecx) {
663663
Err(ptr) => {
664664
if lo == 1 && hi == max_hi {
665-
// Only NULL is the niche. So make sure the ptr is NOT NULL.
665+
// Only null is the niche. So make sure the ptr is NOT null.
666666
if self.ecx.memory.ptr_may_be_null(ptr) {
667667
throw_validation_failure!(self.path,
668-
{ "a potentially NULL pointer" }
668+
{ "a potentially null pointer" }
669669
expected {
670670
"something that cannot possibly fail to be {}",
671671
wrapping_range_format(valid_range, max_hi)

library/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
//!

0 commit comments

Comments
 (0)