about summary refs log tree commit diff
path: root/compiler/rustc_query_impl/src/lib.rs
diff options
context:
space:
mode:
authorDavid Venhoek <david@tweedegolf.com>2025-01-24 16:31:12 +0100
committerDavid Venhoek <david@venhoek.nl>2025-02-05 17:56:06 +0100
commit62bbaa8091a5d83e5b1b20d05e971b73782e6f86 (patch)
treef56fdb1b8e01cb24e511d68f964afb726af4e69a /compiler/rustc_query_impl/src/lib.rs
parent820bfffc25fee9866aa8176529091e04b8824f09 (diff)
downloadrust-62bbaa8091a5d83e5b1b20d05e971b73782e6f86.tar.gz
rust-62bbaa8091a5d83e5b1b20d05e971b73782e6f86.zip
Removed dependency on the field-offset crate.
Diffstat (limited to 'compiler/rustc_query_impl/src/lib.rs')
-rw-r--r--compiler/rustc_query_impl/src/lib.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs
index bbc83cca99d..73c205fdb17 100644
--- a/compiler/rustc_query_impl/src/lib.rs
+++ b/compiler/rustc_query_impl/src/lib.rs
@@ -11,7 +11,6 @@
 #![warn(unreachable_pub)]
 // tidy-alphabetical-end
 
-use field_offset::offset_of;
 use rustc_data_structures::stable_hasher::HashStable;
 use rustc_data_structures::sync::AtomicU64;
 use rustc_middle::arena::Arena;
@@ -89,7 +88,13 @@ where
     where
         QueryCtxt<'tcx>: 'a,
     {
-        self.dynamic.query_state.apply(&qcx.tcx.query_system.states)
+        // Safety:
+        // This is just manually doing the subfield referencing through pointer math.
+        unsafe {
+            &*(&qcx.tcx.query_system.states as *const QueryStates<'tcx>)
+                .byte_add(self.dynamic.query_state)
+                .cast::<QueryState<Self::Key>>()
+        }
     }
 
     #[inline(always)]
@@ -97,7 +102,13 @@ where
     where
         'tcx: 'a,
     {
-        self.dynamic.query_cache.apply(&qcx.tcx.query_system.caches)
+        // Safety:
+        // This is just manually doing the subfield referencing through pointer math.
+        unsafe {
+            &*(&qcx.tcx.query_system.caches as *const QueryCaches<'tcx>)
+                .byte_add(self.dynamic.query_cache)
+                .cast::<Self::Cache>()
+        }
     }
 
     #[inline(always)]