@@ -12,7 +12,7 @@ use rustc::hir::{MutMutable, MutImmutable};
12
12
use rustc:: mir:: RetagKind ;
13
13
14
14
use crate :: {
15
- InterpResult , InterpError , MiriEvalContext , HelpersEvalContextExt , Evaluator , MutValueVisitor ,
15
+ InterpResult , InterpError , HelpersEvalContextExt ,
16
16
MemoryKind , MiriMemoryKind , RangeMap , AllocId , Pointer , Immediate , ImmTy , PlaceTy , MPlaceTy ,
17
17
} ;
18
18
@@ -632,54 +632,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
632
632
}
633
633
}
634
634
635
- // We need a visitor to visit all references. However, that requires
636
- // a `MemPlace`, so we have a fast path for reference types that
637
- // avoids allocating.
635
+ // We only reborrow "bare" references/boxes.
638
636
if let Some ( ( mutbl, protector) ) = qualify ( place. layout . ty , kind) {
639
637
// Fast path.
640
638
let val = this. read_immediate ( this. place_to_op ( place) ?) ?;
641
639
let val = this. retag_reference ( val, mutbl, protector) ?;
642
640
this. write_immediate ( val, place) ?;
643
- return Ok ( ( ) ) ;
644
- }
645
- let place = this. force_allocation ( place) ?;
646
-
647
- let mut visitor = RetagVisitor { ecx : this, kind } ;
648
- visitor. visit_value ( place) ?;
649
-
650
- // The actual visitor.
651
- struct RetagVisitor < ' ecx , ' mir , ' tcx > {
652
- ecx : & ' ecx mut MiriEvalContext < ' mir , ' tcx > ,
653
- kind : RetagKind ,
654
- }
655
- impl < ' ecx , ' mir , ' tcx >
656
- MutValueVisitor < ' mir , ' tcx , Evaluator < ' tcx > >
657
- for
658
- RetagVisitor < ' ecx , ' mir , ' tcx >
659
- {
660
- type V = MPlaceTy < ' tcx , Tag > ;
661
-
662
- #[ inline( always) ]
663
- fn ecx ( & mut self ) -> & mut MiriEvalContext < ' mir , ' tcx > {
664
- & mut self . ecx
665
- }
666
-
667
- // Primitives of reference type, that is the one thing we are interested in.
668
- fn visit_primitive ( & mut self , place : MPlaceTy < ' tcx , Tag > ) -> InterpResult < ' tcx >
669
- {
670
- // Cannot use `builtin_deref` because that reports *immutable* for `Box`,
671
- // making it useless.
672
- if let Some ( ( mutbl, protector) ) = qualify ( place. layout . ty , self . kind ) {
673
- let val = self . ecx . read_immediate ( place. into ( ) ) ?;
674
- let val = self . ecx . retag_reference (
675
- val,
676
- mutbl,
677
- protector
678
- ) ?;
679
- self . ecx . write_immediate ( val, place. into ( ) ) ?;
680
- }
681
- Ok ( ( ) )
682
- }
683
641
}
684
642
685
643
Ok ( ( ) )
0 commit comments