File tree Expand file tree Collapse file tree 7 files changed +20
-35
lines changed Expand file tree Collapse file tree 7 files changed +20
-35
lines changed Original file line number Diff line number Diff line change @@ -1209,16 +1209,6 @@ dependencies = [
12091209 " tidy" ,
12101210]
12111211
1212- [[package ]]
1213- name = " field-offset"
1214- version = " 0.3.6"
1215- source = " registry+https://github.com/rust-lang/crates.io-index"
1216- checksum = " 38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
1217- dependencies = [
1218- " memoffset" ,
1219- " rustc_version" ,
1220- ]
1221-
12221212[[package ]]
12231213name = " filetime"
12241214version = " 0.2.25"
@@ -2295,15 +2285,6 @@ dependencies = [
22952285 " libc" ,
22962286]
22972287
2298- [[package ]]
2299- name = " memoffset"
2300- version = " 0.9.1"
2301- source = " registry+https://github.com/rust-lang/crates.io-index"
2302- checksum = " 488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
2303- dependencies = [
2304- " autocfg" ,
2305- ]
2306-
23072288[[package ]]
23082289name = " mime"
23092290version = " 0.3.17"
@@ -4173,7 +4154,6 @@ version = "0.0.0"
41734154dependencies = [
41744155 " bitflags" ,
41754156 " either" ,
4176- " field-offset" ,
41774157 " gsgdt" ,
41784158 " polonius-engine" ,
41794159 " rustc-rayon-core" ,
@@ -4421,7 +4401,6 @@ dependencies = [
44214401name = " rustc_query_impl"
44224402version = " 0.0.0"
44234403dependencies = [
4424- " field-offset" ,
44254404 " measureme" ,
44264405 " rustc_data_structures" ,
44274406 " rustc_errors" ,
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ edition = "2021"
77# tidy-alphabetical-start
88bitflags = " 2.4.1"
99either = " 1.5.0"
10- field-offset = " 0.3.5"
1110gsgdt = " 0.1.2"
1211polonius-engine = " 0.13.0"
1312rustc-rayon-core = { version = " 0.5.0" }
Original file line number Diff line number Diff line change 11use std:: ops:: Deref ;
22
3- use field_offset:: FieldOffset ;
43use rustc_data_structures:: sync:: { AtomicU64 , WorkerLocal } ;
54use rustc_hir:: def_id:: { DefId , LocalDefId } ;
65use rustc_hir:: hir_id:: OwnerId ;
@@ -24,8 +23,10 @@ pub struct DynamicQuery<'tcx, C: QueryCache> {
2423 pub eval_always : bool ,
2524 pub dep_kind : DepKind ,
2625 pub handle_cycle_error : HandleCycleError ,
27- pub query_state : FieldOffset < QueryStates < ' tcx > , QueryState < C :: Key > > ,
28- pub query_cache : FieldOffset < QueryCaches < ' tcx > , C > ,
26+ // Offset of this query's state field in the QueryStates struct
27+ pub query_state : usize ,
28+ // Offset of this query's cache field in the QueryCaches struct
29+ pub query_cache : usize ,
2930 pub cache_on_disk : fn ( tcx : TyCtxt < ' tcx > , key : & C :: Key ) -> bool ,
3031 pub execute_query : fn ( tcx : TyCtxt < ' tcx > , k : C :: Key ) -> C :: Value ,
3132 pub compute : fn ( tcx : TyCtxt < ' tcx > , key : C :: Key ) -> C :: Value ,
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ edition = "2021"
55
66[dependencies ]
77# tidy-alphabetical-start
8- field-offset = " 0.3.5"
98measureme = " 11"
109rustc_data_structures = { path = " ../rustc_data_structures" }
1110rustc_errors = { path = " ../rustc_errors" }
Original file line number Diff line number Diff line change 1111#![ warn( unreachable_pub) ]
1212// tidy-alphabetical-end
1313
14- use field_offset:: offset_of;
1514use rustc_data_structures:: stable_hasher:: HashStable ;
1615use rustc_data_structures:: sync:: AtomicU64 ;
1716use rustc_middle:: arena:: Arena ;
@@ -89,15 +88,27 @@ where
8988 where
9089 QueryCtxt < ' tcx > : ' a ,
9190 {
92- self . dynamic . query_state . apply ( & qcx. tcx . query_system . states )
91+ // Safety:
92+ // This is just manually doing the subfield referencing through pointer math.
93+ unsafe {
94+ & * ( & qcx. tcx . query_system . states as * const QueryStates < ' tcx > )
95+ . byte_add ( self . dynamic . query_state )
96+ . cast :: < QueryState < Self :: Key > > ( )
97+ }
9398 }
9499
95100 #[ inline( always) ]
96101 fn query_cache < ' a > ( self , qcx : QueryCtxt < ' tcx > ) -> & ' a Self :: Cache
97102 where
98103 ' tcx : ' a ,
99104 {
100- self . dynamic . query_cache . apply ( & qcx. tcx . query_system . caches )
105+ // Safety:
106+ // This is just manually doing the subfield referencing through pointer math.
107+ unsafe {
108+ & * ( & qcx. tcx . query_system . caches as * const QueryCaches < ' tcx > )
109+ . byte_add ( self . dynamic . query_cache )
110+ . cast :: < Self :: Cache > ( )
111+ }
101112 }
102113
103114 #[ inline( always) ]
Original file line number Diff line number Diff line change @@ -605,8 +605,8 @@ macro_rules! define_queries {
605605 eval_always: is_eval_always!( [ $( $modifiers) * ] ) ,
606606 dep_kind: dep_graph:: dep_kinds:: $name,
607607 handle_cycle_error: handle_cycle_error!( [ $( $modifiers) * ] ) ,
608- query_state: offset_of!( QueryStates <' tcx> => $name) ,
609- query_cache: offset_of!( QueryCaches <' tcx> => $name) ,
608+ query_state: std :: mem :: offset_of!( QueryStates <' tcx>, $name) ,
609+ query_cache: std :: mem :: offset_of!( QueryCaches <' tcx>, $name) ,
610610 cache_on_disk: |tcx, key| :: rustc_middle:: query:: cached:: $name( tcx, key) ,
611611 execute_query: |tcx, key| erase( tcx. $name( key) ) ,
612612 compute: |tcx, key| {
Original file line number Diff line number Diff line change @@ -285,7 +285,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
285285 "expect-test" ,
286286 "fallible-iterator" , // dependency of `thorin`
287287 "fastrand" ,
288- "field-offset" ,
289288 "flate2" ,
290289 "fluent-bundle" ,
291290 "fluent-langneg" ,
@@ -327,7 +326,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
327326 "measureme" ,
328327 "memchr" ,
329328 "memmap2" ,
330- "memoffset" ,
331329 "miniz_oxide" ,
332330 "nix" ,
333331 "nu-ansi-term" ,
@@ -367,14 +365,12 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
367365 "rustc-rayon-core" ,
368366 "rustc-stable-hash" ,
369367 "rustc_apfloat" ,
370- "rustc_version" ,
371368 "rustix" ,
372369 "ruzstd" , // via object in thorin-dwp
373370 "ryu" ,
374371 "scoped-tls" ,
375372 "scopeguard" ,
376373 "self_cell" ,
377- "semver" ,
378374 "serde" ,
379375 "serde_derive" ,
380376 "serde_json" ,
You can’t perform that action at this time.
0 commit comments