File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
src/librustc_mir/transform Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 77use rustc:: ty:: subst:: SubstsRef ;
88use rustc:: ty:: { self , Ty , TyCtxt } ;
99use rustc:: mir:: * ;
10- use rustc:: mir:: visit:: { MutVisitor , TyContext } ;
10+ use rustc:: mir:: visit:: { MutVisitor , PlaceContext , TyContext } ;
1111use crate :: transform:: { MirPass , MirSource } ;
1212
1313struct EraseRegionsVisitor < ' tcx > {
@@ -38,6 +38,25 @@ impl MutVisitor<'tcx> for EraseRegionsVisitor<'tcx> {
3838 fn visit_substs ( & mut self , substs : & mut SubstsRef < ' tcx > , _: Location ) {
3939 * substs = self . tcx . erase_regions ( substs) ;
4040 }
41+
42+ fn visit_place (
43+ & mut self ,
44+ place : & mut Place < ' tcx > ,
45+ context : PlaceContext ,
46+ location : Location ,
47+ ) {
48+ self . visit_place_base ( & mut place. base , context, location) ;
49+
50+ let new_projection: Vec < _ > = place. projection . iter ( ) . map ( |elem|
51+ if let PlaceElem :: Field ( field, ty) = elem {
52+ PlaceElem :: Field ( * field, self . tcx . erase_regions ( ty) )
53+ } else {
54+ elem. clone ( )
55+ }
56+ ) . collect ( ) ;
57+
58+ place. projection = new_projection. into_boxed_slice ( ) ;
59+ }
4160}
4261
4362pub struct EraseRegions ;
You can’t perform that action at this time.
0 commit comments