@@ -637,6 +637,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
637
637
if place. is_indirect ( )
638
638
&& let Some ( base) = self . locals [ place. local ]
639
639
&& let Some ( new_local) = self . try_as_local ( base, location)
640
+ && place. local != new_local
640
641
{
641
642
place. local = new_local;
642
643
self . reused_locals . insert ( new_local) ;
@@ -646,18 +647,20 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
646
647
647
648
for i in 0 ..projection. len ( ) {
648
649
let elem = projection[ i] ;
649
- if let ProjectionElem :: Index ( idx ) = elem
650
- && let Some ( idx) = self . locals [ idx ]
650
+ if let ProjectionElem :: Index ( idx_local ) = elem
651
+ && let Some ( idx) = self . locals [ idx_local ]
651
652
{
652
653
if let Some ( offset) = self . evaluated [ idx] . as_ref ( )
653
654
&& let Ok ( offset) = self . ecx . read_target_usize ( offset)
654
655
&& let Some ( min_length) = offset. checked_add ( 1 )
655
656
{
656
657
projection. to_mut ( ) [ i] =
657
658
ProjectionElem :: ConstantIndex { offset, min_length, from_end : false } ;
658
- } else if let Some ( new_idx) = self . try_as_local ( idx, location) {
659
- projection. to_mut ( ) [ i] = ProjectionElem :: Index ( new_idx) ;
660
- self . reused_locals . insert ( new_idx) ;
659
+ } else if let Some ( new_idx_local) = self . try_as_local ( idx, location)
660
+ && idx_local != new_idx_local
661
+ {
662
+ projection. to_mut ( ) [ i] = ProjectionElem :: Index ( new_idx_local) ;
663
+ self . reused_locals . insert ( new_idx_local) ;
661
664
}
662
665
}
663
666
}
0 commit comments