@@ -359,13 +359,20 @@ impl<'a, 'tcx> Visitor<'tcx> for DeclMarker<'a, 'tcx> {
359
359
// Ignore stores of constants because `ConstProp` and `CopyProp` can remove uses of many
360
360
// of these locals. However, if the local is still needed, then it will be referenced in
361
361
// another place and we'll mark it as being used there.
362
- if ctx == PlaceContext :: MutatingUse ( MutatingUseContext :: Store ) {
363
- let stmt =
364
- & self . body . basic_blocks ( ) [ location. block ] . statements [ location. statement_index ] ;
365
- if let StatementKind :: Assign ( box ( p, Rvalue :: Use ( Operand :: Constant ( c) ) ) ) = & stmt. kind {
366
- if p. as_local ( ) . is_some ( ) {
367
- trace ! ( "skipping store of const value {:?} to {:?}" , c, local) ;
368
- return ;
362
+ if ctx == PlaceContext :: MutatingUse ( MutatingUseContext :: Store ) ||
363
+ ctx == PlaceContext :: MutatingUse ( MutatingUseContext :: Projection ) {
364
+ let block = & self . body . basic_blocks ( ) [ location. block ] ;
365
+ if location. statement_index != block. statements . len ( ) {
366
+ let stmt =
367
+ & block. statements [ location. statement_index ] ;
368
+
369
+ if let StatementKind :: Assign (
370
+ box ( p, Rvalue :: Use ( Operand :: Constant ( c) ) )
371
+ ) = & stmt. kind {
372
+ if !p. is_indirect ( ) {
373
+ trace ! ( "skipping store of const value {:?} to {:?}" , c, p) ;
374
+ return ;
375
+ }
369
376
}
370
377
}
371
378
}
@@ -392,7 +399,7 @@ impl<'tcx> MutVisitor<'tcx> for LocalUpdater<'tcx> {
392
399
self . map [ * l] . is_some ( )
393
400
}
394
401
StatementKind :: Assign ( box ( place, _) ) => {
395
- if let Some ( local) = place. as_local ( ) {
402
+ if let PlaceBase :: Local ( local) = place. base {
396
403
self . map [ local] . is_some ( )
397
404
} else {
398
405
true
0 commit comments