summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-01-27 12:16:54 +0100
committerLaurenz <laurmaedje@gmail.com>2023-01-27 12:16:54 +0100
commit9d962c5c40da12207433a6e88aa34f11d036af37 (patch)
tree3b38502a4dc2cb1818f8282a400194937d0ac336 /src/util
parent43ef60c09cc48f6b7c6dd752ab7af7c0d6071bc5 (diff)
More `track_caller` annotations
Diffstat (limited to 'src/util')
-rw-r--r--src/util/fat.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/util/fat.rs b/src/util/fat.rs
index 728f6ae8..d3c9bb20 100644
--- a/src/util/fat.rs
+++ b/src/util/fat.rs
@@ -14,6 +14,7 @@ use std::mem;
/// Must only be called when `T` is a `dyn Trait`. The data address must point
/// to a value whose type implements the trait of `T` and the `vtable` must have
/// been extracted with [`vtable`].
+#[track_caller]
pub unsafe fn from_raw_parts<T: ?Sized>(data: *const (), vtable: *const ()) -> *const T {
let fat = FatPointer { data, vtable };
debug_assert_eq!(Layout::new::<*const T>(), Layout::new::<FatPointer>());
@@ -26,6 +27,7 @@ pub unsafe fn from_raw_parts<T: ?Sized>(data: *const (), vtable: *const ()) -> *
/// Must only be called when `T` is a `dyn Trait`. The data address must point
/// to a value whose type implements the trait of `T` and the `vtable` must have
/// been extracted with [`vtable`].
+#[track_caller]
pub unsafe fn from_raw_parts_mut<T: ?Sized>(data: *mut (), vtable: *const ()) -> *mut T {
let fat = FatPointer { data, vtable };
debug_assert_eq!(Layout::new::<*mut T>(), Layout::new::<FatPointer>());
@@ -36,6 +38,7 @@ pub unsafe fn from_raw_parts_mut<T: ?Sized>(data: *mut (), vtable: *const ()) ->
///
/// # Safety
/// Must only be called when `T` is a `dyn Trait`.
+#[track_caller]
pub unsafe fn vtable<T: ?Sized>(ptr: *const T) -> *const () {
debug_assert_eq!(Layout::new::<*const T>(), Layout::new::<FatPointer>());
mem::transmute_copy::<*const T, FatPointer>(&ptr).vtable