Rust: Apply fixes from code review

This commit is contained in:
Simon Friis Vindum
2025-12-03 13:04:54 +01:00
parent a05d0a906c
commit 299fed5901
2 changed files with 4 additions and 8 deletions

View File

@@ -28,11 +28,11 @@ fn raw_mut_borrow() {
fn raw_mut_write(cond: bool) {
let a = 10i32;
// The type of `x` must be inferred from the write below.
// The type of `ptr_written` must be inferred from the write below.
let ptr_written = null_mut(); // $ target=null_mut type=ptr_written:TPtrMut.i32
if cond {
unsafe {
// NOTE: This write is undefined behavior because `x` is a null pointer.
// NOTE: This write is undefined behavior because `ptr_written` is a null pointer.
*ptr_written = a;
let _y = *ptr_written; // $ type=_y:i32
}
@@ -40,11 +40,11 @@ fn raw_mut_write(cond: bool) {
}
fn raw_type_from_deref(cond: bool) {
// The type of `x` must be inferred from the read below.
// The type of `ptr_read` must be inferred from the read below.
let ptr_read = null_mut(); // $ target=null_mut type=ptr_read:TPtrMut.i64
if cond {
unsafe {
// NOTE: This read is undefined behavior because `x` is a null pointer.
// NOTE: This read is undefined behavior because `ptr_read` is a null pointer.
let _y: i64 = *ptr_read;
}
}