@@ -367,20 +367,14 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
367
367
measureme:: Profiler :: new ( out) . expect ( "Couldn't create `measureme` profiler" )
368
368
} ) ;
369
369
let rng = StdRng :: seed_from_u64 ( config. seed . unwrap_or ( 0 ) ) ;
370
- let stacked_borrows = if config. stacked_borrows {
371
- Some ( RefCell :: new ( stacked_borrows:: GlobalStateInner :: new (
370
+ let stacked_borrows = config. stacked_borrows . then ( || {
371
+ RefCell :: new ( stacked_borrows:: GlobalStateInner :: new (
372
372
config. tracked_pointer_tags . clone ( ) ,
373
373
config. tracked_call_ids . clone ( ) ,
374
374
config. retag_fields ,
375
- ) ) )
376
- } else {
377
- None
378
- } ;
379
- let data_race = if config. data_race_detector {
380
- Some ( data_race:: GlobalState :: new ( config) )
381
- } else {
382
- None
383
- } ;
375
+ ) )
376
+ } ) ;
377
+ let data_race = config. data_race_detector . then ( || data_race:: GlobalState :: new ( config) ) ;
384
378
Evaluator {
385
379
stacked_borrows,
386
380
data_race,
@@ -691,32 +685,24 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
691
685
}
692
686
693
687
let alloc = alloc. into_owned ( ) ;
694
- let stacks = if let Some ( stacked_borrows ) = & ecx. machine . stacked_borrows {
695
- Some ( Stacks :: new_allocation (
688
+ let stacks = ecx. machine . stacked_borrows . as_ref ( ) . map ( |stacked_borrows| {
689
+ Stacks :: new_allocation (
696
690
id,
697
691
alloc. size ( ) ,
698
692
stacked_borrows,
699
693
kind,
700
694
ecx. machine . current_span ( ) ,
701
- ) )
702
- } else {
703
- None
704
- } ;
705
- let race_alloc = if let Some ( data_race) = & ecx. machine . data_race {
706
- Some ( data_race:: AllocExtra :: new_allocation (
695
+ )
696
+ } ) ;
697
+ let race_alloc = ecx. machine . data_race . as_ref ( ) . map ( |data_race| {
698
+ data_race:: AllocExtra :: new_allocation (
707
699
data_race,
708
700
& ecx. machine . threads ,
709
701
alloc. size ( ) ,
710
702
kind,
711
- ) )
712
- } else {
713
- None
714
- } ;
715
- let buffer_alloc = if ecx. machine . weak_memory {
716
- Some ( weak_memory:: AllocExtra :: new_allocation ( ) )
717
- } else {
718
- None
719
- } ;
703
+ )
704
+ } ) ;
705
+ let buffer_alloc = ecx. machine . weak_memory . then ( weak_memory:: AllocExtra :: new_allocation) ;
720
706
let alloc: Allocation < Provenance , Self :: AllocExtra > = alloc. adjust_from_tcx (
721
707
& ecx. tcx ,
722
708
AllocExtra {
0 commit comments