@@ -17,6 +17,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
17
17
use rustc_data_structures:: static_assert_size;
18
18
use rustc_middle:: {
19
19
mir,
20
+ query:: TyCtxtAt ,
20
21
ty:: {
21
22
self ,
22
23
layout:: { LayoutCx , LayoutError , LayoutOf , TyAndLayout } ,
@@ -259,6 +260,17 @@ impl interpret::Provenance for Provenance {
259
260
}
260
261
}
261
262
263
+ fn fmt ( ptr : & Pointer < Self > , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
264
+ let ( prov, addr) = ptr. into_parts ( ) ; // address is absolute
265
+ write ! ( f, "{:#x}" , addr. bytes( ) ) ?;
266
+ if f. alternate ( ) {
267
+ write ! ( f, "{prov:#?}" ) ?;
268
+ } else {
269
+ write ! ( f, "{prov:?}" ) ?;
270
+ }
271
+ Ok ( ( ) )
272
+ }
273
+
262
274
fn join ( left : Option < Self > , right : Option < Self > ) -> Option < Self > {
263
275
match ( left, right) {
264
276
// If both are the *same* concrete tag, that is the result.
@@ -1170,11 +1182,11 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
1170
1182
1171
1183
fn adjust_alloc_base_pointer (
1172
1184
ecx : & MiriInterpCx < ' mir , ' tcx > ,
1173
- ptr : Pointer < AllocId > ,
1185
+ ptr : Pointer < CtfeProvenance > ,
1174
1186
) -> InterpResult < ' tcx , Pointer < Provenance > > {
1187
+ let alloc_id = ptr. provenance . alloc_id ( ) ;
1175
1188
if cfg ! ( debug_assertions) {
1176
1189
// The machine promises to never call us on thread-local or extern statics.
1177
- let alloc_id = ptr. provenance ;
1178
1190
match ecx. tcx . try_get_global_alloc ( alloc_id) {
1179
1191
Some ( GlobalAlloc :: Static ( def_id) ) if ecx. tcx . is_thread_local_static ( def_id) => {
1180
1192
panic ! ( "adjust_alloc_base_pointer called on thread-local static" )
@@ -1185,8 +1197,9 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
1185
1197
_ => { }
1186
1198
}
1187
1199
}
1200
+ // FIXME: can we somehow preserve the immutability of `ptr`?
1188
1201
let tag = if let Some ( borrow_tracker) = & ecx. machine . borrow_tracker {
1189
- borrow_tracker. borrow_mut ( ) . base_ptr_tag ( ptr . provenance , & ecx. machine )
1202
+ borrow_tracker. borrow_mut ( ) . base_ptr_tag ( alloc_id , & ecx. machine )
1190
1203
} else {
1191
1204
// Value does not matter, SB is disabled
1192
1205
BorTag :: default ( )
@@ -1245,7 +1258,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
1245
1258
1246
1259
#[ inline( always) ]
1247
1260
fn before_memory_read (
1248
- _tcx : TyCtxt < ' tcx > ,
1261
+ _tcx : TyCtxtAt < ' tcx > ,
1249
1262
machine : & Self ,
1250
1263
alloc_extra : & AllocExtra < ' tcx > ,
1251
1264
( alloc_id, prov_extra) : ( AllocId , Self :: ProvenanceExtra ) ,
@@ -1265,7 +1278,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
1265
1278
1266
1279
#[ inline( always) ]
1267
1280
fn before_memory_write (
1268
- _tcx : TyCtxt < ' tcx > ,
1281
+ _tcx : TyCtxtAt < ' tcx > ,
1269
1282
machine : & mut Self ,
1270
1283
alloc_extra : & mut AllocExtra < ' tcx > ,
1271
1284
( alloc_id, prov_extra) : ( AllocId , Self :: ProvenanceExtra ) ,
@@ -1285,7 +1298,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
1285
1298
1286
1299
#[ inline( always) ]
1287
1300
fn before_memory_deallocation (
1288
- _tcx : TyCtxt < ' tcx > ,
1301
+ _tcx : TyCtxtAt < ' tcx > ,
1289
1302
machine : & mut Self ,
1290
1303
alloc_extra : & mut AllocExtra < ' tcx > ,
1291
1304
( alloc_id, prove_extra) : ( AllocId , Self :: ProvenanceExtra ) ,
0 commit comments