@@ -84,7 +84,7 @@ impl SbTagExtra {
84
84
#[ derive( Debug ) ]
85
85
pub struct FrameExtra {
86
86
/// The ID of the call this frame corresponds to.
87
- pub call_id : CallId ,
87
+ call_id : CallId ,
88
88
89
89
/// If this frame is protecting any tags, they are listed here. We use this list to do
90
90
/// incremental updates of the global list of protected tags stored in the
@@ -94,7 +94,7 @@ pub struct FrameExtra {
94
94
///
95
95
/// This will contain one tag per reference passed to the function, so
96
96
/// a size of 2 is enough for the vast majority of functions.
97
- pub protected_tags : SmallVec < [ SbTag ; 2 ] > ,
97
+ protected_tags : SmallVec < [ SbTag ; 2 ] > ,
98
98
}
99
99
100
100
/// Extra per-allocation state.
@@ -202,18 +202,23 @@ impl GlobalStateInner {
202
202
id
203
203
}
204
204
205
- pub fn new_call ( & mut self ) -> CallId {
206
- let id = self . next_call_id ;
207
- trace ! ( "new_call : Assigning ID {}" , id ) ;
208
- if self . tracked_call_ids . contains ( & id ) {
209
- register_diagnostic ( NonHaltingDiagnostic :: CreatedCallId ( id ) ) ;
205
+ pub fn new_frame ( & mut self ) -> FrameExtra {
206
+ let call_id = self . next_call_id ;
207
+ trace ! ( "new_frame : Assigning call ID {}" , call_id ) ;
208
+ if self . tracked_call_ids . contains ( & call_id ) {
209
+ register_diagnostic ( NonHaltingDiagnostic :: CreatedCallId ( call_id ) ) ;
210
210
}
211
- self . next_call_id = NonZeroU64 :: new ( id . get ( ) + 1 ) . unwrap ( ) ;
212
- id
211
+ self . next_call_id = NonZeroU64 :: new ( call_id . get ( ) + 1 ) . unwrap ( ) ;
212
+ FrameExtra { call_id , protected_tags : SmallVec :: new ( ) }
213
213
}
214
214
215
215
pub fn end_call ( & mut self , frame : & machine:: FrameData < ' _ > ) {
216
- for tag in & frame. stacked_borrows . protected_tags {
216
+ for tag in & frame
217
+ . stacked_borrows
218
+ . as_ref ( )
219
+ . expect ( "we should have Stacked Borrows data" )
220
+ . protected_tags
221
+ {
217
222
self . protected_tags . remove ( tag) ;
218
223
}
219
224
}
@@ -342,8 +347,15 @@ impl<'tcx> Stack {
342
347
let call_id = threads
343
348
. all_stacks ( )
344
349
. flatten ( )
345
- . find ( |t| t. extra . stacked_borrows . protected_tags . contains ( & item. tag ( ) ) )
346
- . map ( |frame| frame. extra . stacked_borrows . call_id )
350
+ . map ( |frame| {
351
+ frame
352
+ . extra
353
+ . stacked_borrows
354
+ . as_ref ( )
355
+ . expect ( "we should have Stacked Borrows data" )
356
+ } )
357
+ . find ( |frame| frame. protected_tags . contains ( & item. tag ( ) ) )
358
+ . map ( |frame| frame. call_id )
347
359
. unwrap ( ) ; // FIXME: Surely we should find something, but a panic seems wrong here?
348
360
if let Some ( ( tag, _alloc_range, _offset, _access) ) = provoking_access {
349
361
Err ( err_sb_ub (
@@ -835,7 +847,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
835
847
) ;
836
848
837
849
if protect {
838
- this. frame_mut ( ) . extra . stacked_borrows . protected_tags . push ( new_tag) ;
850
+ this. frame_mut ( ) . extra . stacked_borrows . as_mut ( ) . unwrap ( ) . protected_tags . push ( new_tag) ;
839
851
this. machine . stacked_borrows . as_mut ( ) . unwrap ( ) . get_mut ( ) . protected_tags . insert ( new_tag) ;
840
852
}
841
853
// FIXME: can't hold the current span handle across the borrows of self above
0 commit comments