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 7
7
use rustc:: ty:: subst:: SubstsRef ;
8
8
use rustc:: ty:: { self , Ty , TyCtxt } ;
9
9
use rustc:: mir:: * ;
10
- use rustc:: mir:: visit:: { MutVisitor , TyContext } ;
10
+ use rustc:: mir:: visit:: { MutVisitor , PlaceContext , TyContext } ;
11
11
use crate :: transform:: { MirPass , MirSource } ;
12
12
13
13
struct EraseRegionsVisitor < ' tcx > {
@@ -38,6 +38,25 @@ impl MutVisitor<'tcx> for EraseRegionsVisitor<'tcx> {
38
38
fn visit_substs ( & mut self , substs : & mut SubstsRef < ' tcx > , _: Location ) {
39
39
* substs = self . tcx . erase_regions ( substs) ;
40
40
}
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
+ }
41
60
}
42
61
43
62
pub struct EraseRegions ;
You can’t perform that action at this time.
0 commit comments