@@ -17,6 +17,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1717use rustc_data_structures:: static_assert_size;
1818use rustc_middle:: {
1919 mir,
20+ query:: TyCtxtAt ,
2021 ty:: {
2122 self ,
2223 layout:: { LayoutCx , LayoutError , LayoutOf , TyAndLayout } ,
@@ -259,6 +260,17 @@ impl interpret::Provenance for Provenance {
259260 }
260261 }
261262
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+
262274 fn join ( left : Option < Self > , right : Option < Self > ) -> Option < Self > {
263275 match ( left, right) {
264276 // 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> {
11701182
11711183 fn adjust_alloc_base_pointer (
11721184 ecx : & MiriInterpCx < ' mir , ' tcx > ,
1173- ptr : Pointer < AllocId > ,
1185+ ptr : Pointer < CtfeProvenance > ,
11741186 ) -> InterpResult < ' tcx , Pointer < Provenance > > {
1187+ let alloc_id = ptr. provenance . alloc_id ( ) ;
11751188 if cfg ! ( debug_assertions) {
11761189 // The machine promises to never call us on thread-local or extern statics.
1177- let alloc_id = ptr. provenance ;
11781190 match ecx. tcx . try_get_global_alloc ( alloc_id) {
11791191 Some ( GlobalAlloc :: Static ( def_id) ) if ecx. tcx . is_thread_local_static ( def_id) => {
11801192 panic ! ( "adjust_alloc_base_pointer called on thread-local static" )
@@ -1185,8 +1197,9 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
11851197 _ => { }
11861198 }
11871199 }
1200+ // FIXME: can we somehow preserve the immutability of `ptr`?
11881201 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 )
11901203 } else {
11911204 // Value does not matter, SB is disabled
11921205 BorTag :: default ( )
@@ -1245,7 +1258,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
12451258
12461259 #[ inline( always) ]
12471260 fn before_memory_read (
1248- _tcx : TyCtxt < ' tcx > ,
1261+ _tcx : TyCtxtAt < ' tcx > ,
12491262 machine : & Self ,
12501263 alloc_extra : & AllocExtra < ' tcx > ,
12511264 ( alloc_id, prov_extra) : ( AllocId , Self :: ProvenanceExtra ) ,
@@ -1265,7 +1278,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
12651278
12661279 #[ inline( always) ]
12671280 fn before_memory_write (
1268- _tcx : TyCtxt < ' tcx > ,
1281+ _tcx : TyCtxtAt < ' tcx > ,
12691282 machine : & mut Self ,
12701283 alloc_extra : & mut AllocExtra < ' tcx > ,
12711284 ( alloc_id, prov_extra) : ( AllocId , Self :: ProvenanceExtra ) ,
@@ -1285,7 +1298,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
12851298
12861299 #[ inline( always) ]
12871300 fn before_memory_deallocation (
1288- _tcx : TyCtxt < ' tcx > ,
1301+ _tcx : TyCtxtAt < ' tcx > ,
12891302 machine : & mut Self ,
12901303 alloc_extra : & mut AllocExtra < ' tcx > ,
12911304 ( alloc_id, prove_extra) : ( AllocId , Self :: ProvenanceExtra ) ,
0 commit comments