Skip to content

Commit 299fed5

Browse files
committed
Rust: Apply fixes from code review
1 parent a05d0a9 commit 299fed5

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

rust/ql/lib/codeql/rust/internal/Type.qll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,16 +352,12 @@ class PtrMutType extends PtrType {
352352
PtrMutType() { this.getStruct() instanceof Builtins::PtrMutType }
353353

354354
override string toString() { result = "*mut" }
355-
356-
override Location getLocation() { result instanceof EmptyLocation }
357355
}
358356

359357
class PtrConstType extends PtrType {
360358
PtrConstType() { this.getStruct() instanceof Builtins::PtrConstType }
361359

362360
override string toString() { result = "*const" }
363-
364-
override Location getLocation() { result instanceof EmptyLocation }
365361
}
366362

367363
/**

rust/ql/test/library-tests/type-inference/raw_pointer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ fn raw_mut_borrow() {
2828

2929
fn raw_mut_write(cond: bool) {
3030
let a = 10i32;
31-
// The type of `x` must be inferred from the write below.
31+
// The type of `ptr_written` must be inferred from the write below.
3232
let ptr_written = null_mut(); // $ target=null_mut type=ptr_written:TPtrMut.i32
3333
if cond {
3434
unsafe {
35-
// NOTE: This write is undefined behavior because `x` is a null pointer.
35+
// NOTE: This write is undefined behavior because `ptr_written` is a null pointer.
3636
*ptr_written = a;
3737
let _y = *ptr_written; // $ type=_y:i32
3838
}
3939
}
4040
}
4141

4242
fn raw_type_from_deref(cond: bool) {
43-
// The type of `x` must be inferred from the read below.
43+
// The type of `ptr_read` must be inferred from the read below.
4444
let ptr_read = null_mut(); // $ target=null_mut type=ptr_read:TPtrMut.i64
4545
if cond {
4646
unsafe {
47-
// NOTE: This read is undefined behavior because `x` is a null pointer.
47+
// NOTE: This read is undefined behavior because `ptr_read` is a null pointer.
4848
let _y: i64 = *ptr_read;
4949
}
5050
}

0 commit comments

Comments
 (0)