@@ -122,11 +122,7 @@ where
122
122
}
123
123
124
124
fn visit_local ( & mut self , local : Local , context : PlaceContext , _: Location ) {
125
- match DefUse :: for_place ( local. into ( ) , context) {
126
- Some ( DefUse :: Def ) => self . 0 . kill ( local) ,
127
- Some ( DefUse :: Use ) => self . 0 . gen ( local) ,
128
- None => { }
129
- }
125
+ DefUse :: apply ( self . 0 , local. into ( ) , context) ;
130
126
}
131
127
}
132
128
@@ -137,20 +133,12 @@ where
137
133
T : GenKill < Local > ,
138
134
{
139
135
fn visit_place ( & mut self , place : & mir:: Place < ' tcx > , context : PlaceContext , location : Location ) {
140
- match DefUse :: for_place ( * place, context) {
141
- Some ( DefUse :: Def ) => self . 0 . kill ( place. local ) ,
142
- Some ( DefUse :: Use ) => self . 0 . gen ( place. local ) ,
143
- None => { }
144
- }
136
+ DefUse :: apply ( self . 0 , * place, context) ;
145
137
self . visit_projection ( place. as_ref ( ) , context, location) ;
146
138
}
147
139
148
140
fn visit_local ( & mut self , local : Local , context : PlaceContext , _: Location ) {
149
- match DefUse :: for_place ( local. into ( ) , context) {
150
- Some ( DefUse :: Def ) => self . 0 . kill ( local) ,
151
- Some ( DefUse :: Use ) => self . 0 . gen ( local) ,
152
- None => { }
153
- }
141
+ DefUse :: apply ( self . 0 , local. into ( ) , context) ;
154
142
}
155
143
}
156
144
@@ -161,6 +149,14 @@ enum DefUse {
161
149
}
162
150
163
151
impl DefUse {
152
+ fn apply < ' tcx > ( trans : & mut impl GenKill < Local > , place : Place < ' tcx > , context : PlaceContext ) {
153
+ match DefUse :: for_place ( place, context) {
154
+ Some ( DefUse :: Def ) => trans. kill ( place. local ) ,
155
+ Some ( DefUse :: Use ) => trans. gen ( place. local ) ,
156
+ None => { }
157
+ }
158
+ }
159
+
164
160
fn for_place < ' tcx > ( place : Place < ' tcx > , context : PlaceContext ) -> Option < DefUse > {
165
161
match context {
166
162
PlaceContext :: NonUse ( _) => None ,
0 commit comments