@@ -571,6 +571,22 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
571
571
} )
572
572
}
573
573
574
+ /// This is used by [priroda](https://github.com/oli-obk/priroda) to get an OpTy from a local
575
+ ///
576
+ /// When you know the layout of the local in advance, you can pass it as last argument
577
+ pub fn access_local (
578
+ & self ,
579
+ frame : & super :: Frame < ' mir , ' tcx , M :: PointerTag > ,
580
+ local : mir:: Local ,
581
+ layout : Option < TyLayout < ' tcx > > ,
582
+ ) -> EvalResult < ' tcx , OpTy < ' tcx , M :: PointerTag > > {
583
+ assert_ne ! ( local, mir:: RETURN_PLACE ) ;
584
+ let op = * frame. locals [ local] . access ( ) ?;
585
+ let layout = from_known_layout ( layout,
586
+ || self . layout_of_local ( frame, local) ) ?;
587
+ Ok ( OpTy { op, layout } )
588
+ }
589
+
574
590
// Evaluate a place with the goal of reading from it. This lets us sometimes
575
591
// avoid allocations. If you already know the layout, you can pass it in
576
592
// to avoid looking it up again.
@@ -582,12 +598,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
582
598
use rustc:: mir:: Place :: * ;
583
599
let op = match * mir_place {
584
600
Local ( mir:: RETURN_PLACE ) => return err ! ( ReadFromReturnPointer ) ,
585
- Local ( local) => {
586
- let op = * self . frame ( ) . locals [ local] . access ( ) ?;
587
- let layout = from_known_layout ( layout,
588
- || self . layout_of_local ( self . cur_frame ( ) , local) ) ?;
589
- OpTy { op, layout }
590
- } ,
601
+ Local ( local) => self . access_local ( self . frame ( ) , local, layout) ?,
591
602
592
603
Projection ( ref proj) => {
593
604
let op = self . eval_place_to_op ( & proj. base , None ) ?;
0 commit comments