From 299fed59010a7cd59c5d4daa0afd097c0b1c9a1c Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 3 Dec 2025 13:04:54 +0100 Subject: [PATCH] Rust: Apply fixes from code review --- rust/ql/lib/codeql/rust/internal/Type.qll | 4 ---- rust/ql/test/library-tests/type-inference/raw_pointer.rs | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/rust/ql/lib/codeql/rust/internal/Type.qll b/rust/ql/lib/codeql/rust/internal/Type.qll index af37fb567e5..fb639cb9acf 100644 --- a/rust/ql/lib/codeql/rust/internal/Type.qll +++ b/rust/ql/lib/codeql/rust/internal/Type.qll @@ -352,16 +352,12 @@ class PtrMutType extends PtrType { PtrMutType() { this.getStruct() instanceof Builtins::PtrMutType } override string toString() { result = "*mut" } - - override Location getLocation() { result instanceof EmptyLocation } } class PtrConstType extends PtrType { PtrConstType() { this.getStruct() instanceof Builtins::PtrConstType } override string toString() { result = "*const" } - - override Location getLocation() { result instanceof EmptyLocation } } /** diff --git a/rust/ql/test/library-tests/type-inference/raw_pointer.rs b/rust/ql/test/library-tests/type-inference/raw_pointer.rs index 82f6f1afe16..bf4537f30ce 100644 --- a/rust/ql/test/library-tests/type-inference/raw_pointer.rs +++ b/rust/ql/test/library-tests/type-inference/raw_pointer.rs @@ -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; } }