@@ -118,18 +118,25 @@ impl<'mir, 'tcx> BitDenotation<'tcx> for RequiresStorage<'mir, 'tcx> {
118
118
self . borrowed_locals . borrow ( ) . analysis ( ) . statement_effect ( sets, stmt, loc) ;
119
119
120
120
// If a place is assigned to in a statement, it needs storage for that statement.
121
- match stmt. kind {
122
- StatementKind :: StorageDead ( l) => sets. kill ( l) ,
123
- StatementKind :: Assign ( box ( ref place, _) )
124
- | StatementKind :: SetDiscriminant { box ref place, .. } => {
121
+ match & stmt. kind {
122
+ StatementKind :: StorageDead ( l) => sets. kill ( * l) ,
123
+ StatementKind :: Assign ( box ( place, _) )
124
+ | StatementKind :: SetDiscriminant { box place, .. } => {
125
125
sets. gen ( place. local ) ;
126
126
}
127
- StatementKind :: InlineAsm ( box InlineAsm { ref outputs, .. } ) => {
127
+ StatementKind :: InlineAsm ( box InlineAsm { outputs, .. } ) => {
128
128
for place in & * * outputs {
129
129
sets. gen ( place. local ) ;
130
130
}
131
131
}
132
- _ => ( ) ,
132
+
133
+ // Nothing to do for these. Match exhaustively so this fails to compile when new
134
+ // variants are added.
135
+ StatementKind :: AscribeUserType ( ..)
136
+ | StatementKind :: FakeRead ( ..)
137
+ | StatementKind :: Nop
138
+ | StatementKind :: Retag ( ..)
139
+ | StatementKind :: StorageLive ( ..) => { }
133
140
}
134
141
}
135
142
@@ -145,23 +152,58 @@ impl<'mir, 'tcx> BitDenotation<'tcx> for RequiresStorage<'mir, 'tcx> {
145
152
// If a place is borrowed in a terminator, it needs storage for that terminator.
146
153
self . borrowed_locals . borrow ( ) . analysis ( ) . terminator_effect ( sets, terminator, loc) ;
147
154
148
- if let TerminatorKind :: Call { destination : Some ( ( place, _) ) , .. } = terminator. kind {
149
- sets. gen ( place. local ) ;
155
+ match & terminator. kind {
156
+ TerminatorKind :: Call { destination : Some ( ( Place { local, .. } , _) ) , .. }
157
+ | TerminatorKind :: Yield { resume_arg : Place { local, .. } , .. } => {
158
+ sets. gen ( * local) ;
159
+ }
160
+
161
+ // Nothing to do for these. Match exhaustively so this fails to compile when new
162
+ // variants are added.
163
+ TerminatorKind :: Call { destination : None , .. }
164
+ | TerminatorKind :: Abort
165
+ | TerminatorKind :: Assert { .. }
166
+ | TerminatorKind :: Drop { .. }
167
+ | TerminatorKind :: DropAndReplace { .. }
168
+ | TerminatorKind :: FalseEdges { .. }
169
+ | TerminatorKind :: FalseUnwind { .. }
170
+ | TerminatorKind :: GeneratorDrop
171
+ | TerminatorKind :: Goto { .. }
172
+ | TerminatorKind :: Resume
173
+ | TerminatorKind :: Return
174
+ | TerminatorKind :: SwitchInt { .. }
175
+ | TerminatorKind :: Unreachable => { }
150
176
}
151
177
}
152
178
153
179
fn terminator_effect ( & self , sets : & mut GenKillSet < Local > , loc : Location ) {
154
- // For call terminators the destination requires storage for the call
155
- // and after the call returns successfully, but not after a panic.
156
- // Since `propagate_call_unwind` doesn't exist, we have to kill the
157
- // destination here, and then gen it again in `propagate_call_return`.
158
- if let TerminatorKind :: Call { destination : Some ( ( ref place, _) ) , .. } =
159
- self . body [ loc. block ] . terminator ( ) . kind
160
- {
161
- if let Some ( local) = place. as_local ( ) {
162
- sets. kill ( local) ;
180
+ match & self . body [ loc. block ] . terminator ( ) . kind {
181
+ // For call terminators the destination requires storage for the call
182
+ // and after the call returns successfully, but not after a panic.
183
+ // Since `propagate_call_unwind` doesn't exist, we have to kill the
184
+ // destination here, and then gen it again in `propagate_call_return`.
185
+ TerminatorKind :: Call { destination : Some ( ( Place { local, .. } , _) ) , .. } => {
186
+ sets. kill ( * local) ;
163
187
}
188
+
189
+ // Nothing to do for these. Match exhaustively so this fails to compile when new
190
+ // variants are added.
191
+ TerminatorKind :: Call { destination : None , .. }
192
+ | TerminatorKind :: Yield { .. }
193
+ | TerminatorKind :: Abort
194
+ | TerminatorKind :: Assert { .. }
195
+ | TerminatorKind :: Drop { .. }
196
+ | TerminatorKind :: DropAndReplace { .. }
197
+ | TerminatorKind :: FalseEdges { .. }
198
+ | TerminatorKind :: FalseUnwind { .. }
199
+ | TerminatorKind :: GeneratorDrop
200
+ | TerminatorKind :: Goto { .. }
201
+ | TerminatorKind :: Resume
202
+ | TerminatorKind :: Return
203
+ | TerminatorKind :: SwitchInt { .. }
204
+ | TerminatorKind :: Unreachable => { }
164
205
}
206
+
165
207
self . check_for_move ( sets, loc) ;
166
208
}
167
209
0 commit comments