File tree 7 files changed +20
-35
lines changed
7 files changed +20
-35
lines changed Original file line number Diff line number Diff line change @@ -1209,16 +1209,6 @@ dependencies = [
1209
1209
" tidy" ,
1210
1210
]
1211
1211
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
-
1222
1212
[[package ]]
1223
1213
name = " filetime"
1224
1214
version = " 0.2.25"
@@ -2295,15 +2285,6 @@ dependencies = [
2295
2285
" libc" ,
2296
2286
]
2297
2287
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
-
2307
2288
[[package ]]
2308
2289
name = " mime"
2309
2290
version = " 0.3.17"
@@ -4173,7 +4154,6 @@ version = "0.0.0"
4173
4154
dependencies = [
4174
4155
" bitflags" ,
4175
4156
" either" ,
4176
- " field-offset" ,
4177
4157
" gsgdt" ,
4178
4158
" polonius-engine" ,
4179
4159
" rustc-rayon-core" ,
@@ -4421,7 +4401,6 @@ dependencies = [
4421
4401
name = " rustc_query_impl"
4422
4402
version = " 0.0.0"
4423
4403
dependencies = [
4424
- " field-offset" ,
4425
4404
" measureme" ,
4426
4405
" rustc_data_structures" ,
4427
4406
" rustc_errors" ,
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ edition = "2021"
7
7
# tidy-alphabetical-start
8
8
bitflags = " 2.4.1"
9
9
either = " 1.5.0"
10
- field-offset = " 0.3.5"
11
10
gsgdt = " 0.1.2"
12
11
polonius-engine = " 0.13.0"
13
12
rustc-rayon-core = { version = " 0.5.0" }
Original file line number Diff line number Diff line change 1
1
use std:: ops:: Deref ;
2
2
3
- use field_offset:: FieldOffset ;
4
3
use rustc_data_structures:: sync:: { AtomicU64 , WorkerLocal } ;
5
4
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
6
5
use rustc_hir:: hir_id:: OwnerId ;
@@ -24,8 +23,10 @@ pub struct DynamicQuery<'tcx, C: QueryCache> {
24
23
pub eval_always : bool ,
25
24
pub dep_kind : DepKind ,
26
25
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 ,
29
30
pub cache_on_disk : fn ( tcx : TyCtxt < ' tcx > , key : & C :: Key ) -> bool ,
30
31
pub execute_query : fn ( tcx : TyCtxt < ' tcx > , k : C :: Key ) -> C :: Value ,
31
32
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"
5
5
6
6
[dependencies ]
7
7
# tidy-alphabetical-start
8
- field-offset = " 0.3.5"
9
8
measureme = " 11"
10
9
rustc_data_structures = { path = " ../rustc_data_structures" }
11
10
rustc_errors = { path = " ../rustc_errors" }
Original file line number Diff line number Diff line change 11
11
#![ warn( unreachable_pub) ]
12
12
// tidy-alphabetical-end
13
13
14
- use field_offset:: offset_of;
15
14
use rustc_data_structures:: stable_hasher:: HashStable ;
16
15
use rustc_data_structures:: sync:: AtomicU64 ;
17
16
use rustc_middle:: arena:: Arena ;
@@ -89,15 +88,27 @@ where
89
88
where
90
89
QueryCtxt < ' tcx > : ' a ,
91
90
{
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
+ }
93
98
}
94
99
95
100
#[ inline( always) ]
96
101
fn query_cache < ' a > ( self , qcx : QueryCtxt < ' tcx > ) -> & ' a Self :: Cache
97
102
where
98
103
' tcx : ' a ,
99
104
{
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
+ }
101
112
}
102
113
103
114
#[ inline( always) ]
Original file line number Diff line number Diff line change @@ -605,8 +605,8 @@ macro_rules! define_queries {
605
605
eval_always: is_eval_always!( [ $( $modifiers) * ] ) ,
606
606
dep_kind: dep_graph:: dep_kinds:: $name,
607
607
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) ,
610
610
cache_on_disk: |tcx, key| :: rustc_middle:: query:: cached:: $name( tcx, key) ,
611
611
execute_query: |tcx, key| erase( tcx. $name( key) ) ,
612
612
compute: |tcx, key| {
Original file line number Diff line number Diff line change @@ -285,7 +285,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
285
285
"expect-test" ,
286
286
"fallible-iterator" , // dependency of `thorin`
287
287
"fastrand" ,
288
- "field-offset" ,
289
288
"flate2" ,
290
289
"fluent-bundle" ,
291
290
"fluent-langneg" ,
@@ -327,7 +326,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
327
326
"measureme" ,
328
327
"memchr" ,
329
328
"memmap2" ,
330
- "memoffset" ,
331
329
"miniz_oxide" ,
332
330
"nix" ,
333
331
"nu-ansi-term" ,
@@ -367,14 +365,12 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
367
365
"rustc-rayon-core" ,
368
366
"rustc-stable-hash" ,
369
367
"rustc_apfloat" ,
370
- "rustc_version" ,
371
368
"rustix" ,
372
369
"ruzstd" , // via object in thorin-dwp
373
370
"ryu" ,
374
371
"scoped-tls" ,
375
372
"scopeguard" ,
376
373
"self_cell" ,
377
- "semver" ,
378
374
"serde" ,
379
375
"serde_derive" ,
380
376
"serde_json" ,
You can’t perform that action at this time.
0 commit comments